A Simple Driver Example
In this simple example the programmer does not need to define
action scripts. The needed scripts are already in stdsct.tcl.
Before presenting the driver, we look at the command we need
in the configuration file for any device using this driver:
makenv tem ls336
or, if for some reason the name of the controller has to be given
explicitly,
makenv tem ls336 _tem
This command looks if the driver script ~/sea/tcl/drivers/ls336.tcl
exists, if not, it tries to look for a driver of an older type.
It remembers the object name (tem) and the controller name (_tem).
If no controller name is given it is set to the object name
prepended by an underscore character.
Now we look at the driver file ~/sea/tcl/drivers/ls336.tcl:
proc stdConfig::ls336 {} {
controller std sendterminator=\r timeout=5
controllerDesc "LakeShore 336 controller"
prop startcmd "*IDN?"
obj LS336 -float rd
prop readcmd "KRDG?A"
prop readfmt "%g"
kids "LS336 settings" {
node set -float wr
prop readcmd "SETP?1"
prop readfmt "%g"
prop writecmd "SETP 1,%g"
}
}
Explanation, line by line
proc stdConfig::ls335 {} {
The initialization script must be in the namespace
stdConfig
controller std sendterminator=\r timeout=5
The controller object is defined with the name specified in
the makenv command, specifying the characteristics
of the protocol.
controllerDesc "LakeShore 336 controller"
A description of the controller object.
prop startcmd "*IDN?"
The command prop creates a property to the last defined
node, which is in this case the controller node.
The property startcmd defines a command which is sent
after initialization. Ideally this is a command requesting
the instrument type, software version number and possibly
a serial number.
After an interruption of the connection, this command is sent
again in order to check that the device is still the same.
obj LS336 -float rd
This creates the object with the name specified in the makenv
command. Its value is a float, and it is a rd node, which means,
it is a value read from the hardware device at regular intervals,
by default every 5 seconds. It is read only.
prop readcmd "KRDG?A"
We define a property of the object node: readcmd.
This is the command to be sent to get the value, in this case
the temperature of channel A.
prop readfmt "%g"
This is the format for converting the result to a floating point value.
In this case it is a normal floating point value. For the format syntax
see the tcl scan
command.
kids "LS336 settings" {
We define the children of the main node. The text is the title in the
SeaClient layout.
node set -float wr
The set node has type wr. This means
that its value is written to the hardware as soon
as it is changed and read back regularely (by default every 10 seconds).
prop readcmd "SETP?1"
prop readfmt "%g"
prop writecmd "SETP 1,%g"
Specify the read command and format, and the
write command. In the write command, %g will be
replaced by the target value.
Is this all?
We have not yet explained how the host and port of the connection
is specified. This is done by the following command:
cfgenv tem psts231.psi.ch:3006
In this command we tell the system to use host psts231 and
port 3006 for connecting a device called tem. This information
is persistent in the SeaServer of the instrument. It should not
be used in any script or configuration file, as these are shared
by the different instruments.
Printer Friendly
Page Info
This page last changed on 29-Apr-2011 13:08:16 UTC by MarkusZolliker.
|