|
||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Phone: +41 56 310 5182 Updated: 02.11.2005 Printer friendly version |
Tcl-IOCTcl-IOC provides a Tcl shell for an EPICS R3.14 IOC. It is a replacement for iocsh that comes with EPICS base. This adds the full capability of a scripting programming language to EPICS iocCore. Access to registered EPICS functions and variables is supported similar to iocsh. RequirementsTcl is required and TclX is recommended for its capability to switch from scripting mode to interactive mode. Alternatively, wish, the graphical extension to the Tcl shell, can be used. To build Tcl-IOC, the sources or the development rpm of Tcl (tcl-devel) is required (i.e. the header file tcl.h is needed). To run Tcl-IOC, a run time installation of Tcl and TclX is sufficient. EPICS R3.14.7 is required (higher versions might also work). Download the tclioc.tgz package. See below how to install it. Tcl-IOC has been tested on the following systems:
It has not yet been tested on Windows systems. If you make it run on other systems, feedback is welcome. FeaturesTcl-IOC consistes of a shared library that can be linked with an IOC application and loaded into any Tcl shell (tclsh, tcl, wish, wishx, bltwish, ...) with the load command. Loading the library automatically adds iocCore, including all EPICS functions and variables to the Tcl shell. FunctionsFor each registered EPICS function, a Tcl command with the same name is created. Thus, any EPICS function available in iocsh can be called from the Tcl shell. Since iocsh functions have void results, the corresponding Tcl commands normally return an empty string. Many EPICS functions write to stdout, but input and output can be redirected:
Note that most EPICS functions also write error messages to stdout instead of stderr. Variables
Each registered EPICS variable is mapped to a global Tcl variable with
the same name.
Reading and writing of those Tcl variables is redirected
to the corresponding EPICS variable.
EPICS variables cannot be
Installing Tcl-IOCTcl-IOC comes as a BaseApp-style EPICS R3.14 project. It contains the following files: tclioc |-- Makefile |-- myTclIocApp | |-- Makefile | |-- example.subs | |-- example.template | |-- exampleiocsh.tcl | |-- myTclIocAppInclude.dbd | `-- simpleiocsh.tcl `-- src |-- Makefile |-- README |-- iocUtil.c `-- iocsh.cpp Unpack the project it in a <TOP> location and run make. This will create a loadable library and an example application. For further information on EPICS projects and <TOP> directories, please refer to the EPICS IOC Application Developer's Guide (download PDF), Chapter 4. Building a Tcl-IOC applicationA Tcl-IOC application is similar to any other EPICS IOC application. The differences are in the Makefile and the startup script. An example application can be found in the myTclIocApp subdirectory. Makefile changes
Example MakefileDifferences to a standard application Makefile are marked blue. TOP=../.. include $(TOP)/configure/CONFIG LOADABLE_LIBRARY = myApplication DBD += myApplication.dbd myApplication_SRCS += myApplication_registerRecordDeviceDriver.cpp myApplication_LIBS += tclioc include $(TOP)/configure/RULES Startup script changes
Example startup script
#!/usr/bin/tcl load libmyApplication.so tclioc dbLoadDatabase myApplication.dbd myApplication_registerRecordDeviceDriver #create records using TCL programming set scan "1 second" for {set n 1} {$n <= 100} {incr n} { dbLoadRecords example.template "number=$n,scan=$scan" } #set an EPICS variable set asCaDebug 1 #some EPICS commands with output redirection set logfile iocboot.log iocInit > $logfile dbnr 1 >> $logfile dbl >> $logfile # go interactive commandloop -prompt1 {puts -nonewline "epics> "} Author: Dirk Zimoch Phone: +41 56 310 5182 Email: dirk.zimoch@psi.ch Updated: 02.11.2005 Source: /afs/psi.ch/project/epics/webhosting/software/tclioc/index.php |