[MAT logo][Prev][Up][Next]

Custom modules - Tcl


The Tcl language was designed to be a simple scripting language. Unless you're already familiar with it or have some other reason for using it, it's probably better to use python instead.


The tcl interface has to be installed before it is used. After compiling the rest of the MatPLC, change to the lang/tcl directory and type autoconf; ./configure; make as usual, followed by make install

See the README file in the lang/tcl directory for more details.

Commands and options

This page describes the Tcl commands implemented by the MatPLC extension; it assumes a working knowledge of Tcl programming and the MatPLC 'C' language programming interface.

Load the module with an explicit load command, or with package require lplc.

The module implements a single new Tcl command, lplc, which has the form:

lplc subcommand [options...]

The following subcommands and options are implemented:

lplc init [-module string] [-array arrayname] [--PLCoptions]
Attaches to a running MatPLC. Due to the nature of the plc_init() routine in matplc.a, this call does not return until initialization is successful.

The default module for Tcl scripts is "TCL". This can be overridden with the -module option.

If an array name is specified, the init command creates an associative array with the specified name, populated as follows:
array(count)number of points
array(x,name)name of point at index x (where 0 <= x < count)

If the point at index x is not valid (i.e. handle.valid == 0), the name is INVALID. (this should not happen, as the indeces are dictated by the configuration.)

The --PLC options specified by the plc_init() routine can be passed on the command line as well. Note that this list includes --PLCmodule=string, another method for overriding the default module.

lplc done
Disconnects from the MatPLC.

lplc getpt [-name pointname]
Returns the current value of the named point.

Generates a Tcl error if a handle to the named point could not be got.

Note: the getpt subcommand performs a plc_update() and then a plc_get()

lplc setpt [-name pointname] [-value value]
Sets the named point to the specified value.

Generates a Tcl; error if a handle to the named point could not be got.

note: the setpt subcommand performs a plc_set() and then a plc_update()

lplc update [-array arrayname]

Updates the module's copy of the MatPLC data.

If an array name is specified, the array is populated as follows:
array(x,value) value of point at index x


$Date: 2004/12/28 05:32:11 $