Client Application¶
The client application (fcfClient) is a simple utility allowing to send commands to the Device Manager from
the command line. In this context we use the words commands and events as synonyms.
The fcfClient uses the interface module fcfif
to compose the payload of the messages. The fcfClient
sends the messages using CII MAL request/reply.
$ fcfClient <serviceURI> <command> ["<parameters>"]
Where
<serviceURI> destination of the command (e.g. zpb.rr://127.0.0.1:12081/StdCmds
<command> command to be sent to the server (e.g. fcfif.Init)
<parameters> optional parameters of the command.
List of Commands¶
The commands (events) currently supported by the fcfClient utility are:
Command |
Parameters |
---|---|
fcfif.Init |
“” |
fcfif.Enable |
“” |
fcfif.Disable |
“” |
fcfif.State |
“” |
fcfif.Status |
“” |
fcfif.Setup |
“” |
fcfif.Recover |
“” |
fcfif.Reset |
“” |
fcfif.Config |
“” |
fcfif.DevNames |
“” |
fcfif.SetLog |
“<ERROR|INFO|DEBUG|TRACE>” |
fcfif.Simulate |
“<device id1>, … ,[<device idn>]” |
fcfif.StopSim |
“<device id1>, … ,[<device idn>]” |
fcfif.Ignore |
“<device id1>, … ,[<device idn>]” |
fcfif.StopIgn |
“<device id1>, … ,[<device idn>]” |
fcfif.HwInit |
“<device id1>, … ,[<device idn>]” |
fcfif.HwEnable |
“<device id1>, … ,[<device idn>]” |
fcfif.HwDisable |
“<device id1>, … ,[<device idn>]” |
fcfif.HwReset |
“<device id1>, … ,[<device idn>]” |
fcfif.BeginAcq |
“<filename prefix>” |
fcfif.EndAcq |
“” |
fcfif.Exit |
“” |
Warning
Due to the upgrade to CII, the payload of the SETUP command cannot be defined through a JSON file. For sending SETUP and other commands is better to use the Python interface.
Note
The HW commands like HwInit or HwEnable control the state of the controller associated to the device.
Examples¶
Note
The following examples assume the server is listening for incoming events under the URI zpb.rr://127.0.0.1:12081/StdCmds in the local host.
Enabling debug level in the server¶
$ fcfClient zpb.rr://127.0.0.1:12081/StdCmds fcfif.SetLog "DEBUG"
Initialising the server¶
$ fcfClient zpb.rr://127.0.0.1:12081/StdCmds fcfif.Init ""
Moving the server to Operational state¶
$ fcfClient zpb.rr://127.0.0.1:12081/StdCmds fcfif.Enable ""
Executing a Setup command from the command line¶
This is not possible in this version using fcfClient utility. Please use the Python client library instead.
Python Client Library¶
It is possible to communicate with the Device Manager through clients developed in
Python. The FCF provides a library that simplifies the interaction with the Device Manager (fcfclib
).
This is probably the easiest and more flexible way to interact with the Device Manager. The fcfclib
encapsulates the creation of the payload for the Setup command by providing predefined methods.
Users might want to interact directly with FCF ICD binding methods. This is, of course possible, but it is outside the scope of this library.
Note
This Python client library is new in version 2.
Error Handling¶
The fcfclib
reports as a RuntimeError exceptions that may be delivered by the Device Manager. Unfortunately a
due to a limitation of CII MAL, we cannot get the source error message yet from the Python exception.
Classes¶
The fcfclib
library provides internal classes to build the buffer for each devices. In addition, this
library provides one class that encapsulates the user interface with the DeviceManager. This class is
the DevmgrCommand class.
DevmgrCommand¶
The constructor of the DevmgrCommand class support two parameters: uri and timeout. The timeout is optional and has a default of one minute, expressed in milliseconds.
The class handles an internal buffer object that is used to build the payload of the Setup command. Each time the command is executed, the buffer is reset. The user can add multiple device settings into the internal buffer before executing the setup command.
The methods names of the class are shown in the tables below. They try to be self explanatory.
Methods for building Setup Payload¶
Method |
parameters |
---|---|
close_shutter |
device (string) |
open_shutter |
device (string) |
switch_lamp_on |
device (string) |
switch_lamp_on_with_intensity |
device (string), intensity (float) |
switch_lamp_on_with_timer |
device (string), timer (integer) |
move_motor_abs_enc |
device (string), position (integer) |
move_motor_abs_pos |
device (string), position (float) |
move_motor_rel_enc |
device (string), position (integer) |
move_motor_rel_pos |
device (string), position (float) |
move_motor_name_pos |
device (string), name (string) |
drot_motor_abs_pos |
device (string), position (float) |
move_drot_posangle |
device (string), position (float) |
start_drot_sky_tracking |
device (string) |
start_drot_elev_tracking |
device (string) |
start_drot_user_tracking |
device (string) |
stop_drot_tracking |
device (string) |
move_adc_motor1_abs_pos |
device (string), position (float) |
move_adc_posangle |
device (string), position (float) |
start_adc_tracking |
device (string) |
stop_adc_tracking |
device (string) |
set_piezo_auto |
device (string) |
set_piezo_pos |
device (string) |
set_piezo_home |
device (string) |
move_piezo_in_user_units |
device (string), pos1 (float), pos2 (float), pos3 (float) |
move_piezo_in_bits_units |
device (string), bit1 (integer), bit2 (integer), bit3 (integer) |
switch_actuator_off |
device (string) |
switch_lamp_off |
device (string) |
switch_lamp_off |
device (string) |
Methods for Command Interface¶
Method |
parameters |
---|---|
setup |
None |
status |
device list (argv) |
ignore |
device list (argv) |
simulate |
device list (argv) |
stop_ignore |
device list (argv) |
stop_simulate |
device list (argv) |
hw_init |
device list (argv) |
hw_enable |
device list (argv) |
hw_disable |
device list (argv) |
hw_reset |
device list (argv) |
devnames |
None |
state |
None |
init |
None |
enable |
None |
enable |
None |
disable |
None |
reset |
None |
stop |
None |
Examples¶
Retrieving the Status¶
import fcfclib.devmgrCommands as fcs
uri = "zpb.rr://127.0.0.1:12081/StdCmds"
fcsif = fcs.DevMgrCommands(uri)
print(fcsif.status())
['shutter1.simulated = true', 'shutter1.lcs.state = Undefined', 'shutter1.lcs.substate = Undefined',
'lamp1.simulated = true', 'lamp1.lcs.state = Undefined', 'lamp1.lcs.substate = Undefined',
'lamp1.lcs.intensity = 0.000000', 'motor1.simulated = true', 'motor1.lcs.state = Undefined',
'motor1.lcs.substate = Undefined', 'motor1.lcs.pos_target = 0.000000',
'motor1.lcs.pos_actual = 0.000000', 'motor1.lcs.vel_actual = 0.000000',
'motor1.lcs.axis_enable = false', "motor1.pos_actual_name = ''",
'motor1.pos_enc = -2147483648', '', 'OK']
Executing a single Setup¶
import fcfclib.devmgrCommands as fcs
uri = "zpb.rr://127.0.0.1:12081/StdCmds"
fcsif = fcs.DevMgrCommands(uri)
# Move single motor1 to absolute position 100 in user units
# Fill the internal setup buffer
fcsif.move_motor_abs_pos("motor1", 100)
# Send setup command to the Device Manager listening in port 12081
fcsif.setup()
Executing a Setup with multiple devices¶
import fcfclib.devmgrCommands as fcs
uri = "zpb.rr://127.0.0.1:12081/StdCmds"
fcsif = fcs.DevMgrCommands(uri)
# Setup multiple devices at once
# Fill the internal setup buffer
fcsif.move_motor_abs_pos("motor1", 100)
fcsif.switch_lamp_off("lamp1")
fcsif.close_shutter("shutter1")
# Send setup command to the Device Manager listening on port 12081
fcsif.setup()