Scripts allow engineers to automate tasks. In the case of Argos, the engineer writes Python scripts. The Argos ICS uses the program sapi for scripting. Sapi is part of the common software TwiceAsNice and eases the access to property trees of the instruments. This pages describes the way to control the Argos instruments by sapi.

Sapi

  1. The offical documentation of sapi describes its invocation.
  2. Ranger is able to execute python scripts, too. The documentation for this feature explains the Nice module which is imported automatically in sapi.

Instruments

The official location for python instrument modules is $INSROOT/lib/pythonX.Y/site-packages.

Diode Source

Python module https://github.com/LBTO/argos/blob/master/src/basda/service/diodesource/scripts/diodesource.py
Concrete sapi script https://github.com/LBTO/argos/blob/master/src/basda/service/diodesource/scripts/printStatus_sapi.py
Sapi script starter https://github.com/LBTO/argos/blob/master/src/basda/service/diodesource/scripts/printDiodesourceStatus

I/O Switch

Python module io_switch.py
Concrete sapi script setOnAndOff_sapi.py

Laser

Python module https://github.com/LBTO/argos/blob/master/src/basda/service/laser/scripts/laser.py
Concrete sapi script https://github.com/LBTO/argos/blob/master/src/basda/service/laser/scripts/printStatus_sapi.py
Sapi script starter https://github.com/LBTO/argos/blob/master/src/basda/service/laser/scripts/printLaserStatus

MoCon

X Stage

Concrete sapi script MoccaStageXServiceWorkerPyTest.py
Regression test for python wrapper Regression test

XY Stage

Concrete sapi script sapi script
Regression test for python wrapper Regression test

Oscilloscope

Python module osci.py
Concrete sapi script printStatus_sapi.py
Sapi scrip starter printOsciStatus

Power Meter

Python module power_meter.py
Concrete sapi script printPower_sapi.py

Prosilica Camera

Python module avtcamera.py
Concrete sapi script avtcamera_sapi.py
Image and ds9 script avt_ds9_sapi.py

Pulse Generator

Python module pulse_generator.py
Concrete sapi script propertyTreeRegressionTest_sapi.py

Swing Arm

Python module https://github.com/LBTO/argos/blob/master/src/basda/service/swingarm/script/argos_swing_arm.py
Concrete sapi script https://github.com/LBTO/argos/blob/master/src/basda/service/swingarm/script/swing_arm_demo_sapi.py

UEI Temp Monitor

Python module uei_monitor.py
Concrete sapi script monitor_demo_sapi.py

White Light Source

Python module https://github.com/LBTO/argos/blob/master/src/basda/service/whitelightsource/script/argos_white_light_source.py
Concrete sapi script https://github.com/LBTO/argos/blob/master/src/basda/service/whitelightsource/script/demo_sapi.py

Example

The script directory of the power meter service contains a working demonstration of sapi for retrieving the measured powers. This might be useful in order to understand the relationship between the service configuration and the sapi command line arguments. The file README explains the sapi command line in more detail.

Remote Sapi Script Execution

The script interpreter sapi uses the middleware from the common software TwiceAsNice which enables engineers to control devices remotely. Therefore, engineers can write and run their Python scripts at their local machine without logging into the machine where the service is running on.

For example, the following sapi invocation binds the remote property tree with root node PowerMeters from the machine with IP address 149.217.40.36 to the local node named POWERMETERS:
sapi "--POWERMETERS.CONFIG:Endpoint=[NAME=PowerMeters.CONFIG, HOST=149.217.40.36, PORT=10031]"        --PYTHON=./printPower_sapi.py

The only prerequisite for executing sapi scripts remotely is an installed version of wiki: TaN installation

Invoking the Interactive Interpreter

Sometimes, the engineer needs to control devices interactively. With sapi, this task is simple: the command line argument --PYTHON=INTER starts the python interpreter console.

Here is an example:
$ sapi "--POWERMETERS.CONFIG:Endpoint=[NAME=PowerMeters.CONFIG, HOST=149.217.40.36, PORT=10031]" --PYTHON=INTER
2011-02-28 11:22:50.517388 INFO JOHNDOE 55cents:20585.b7f4a6d0 kulas Nice/Qt/LoadDynamicWidgets.cc:58 WidgetFactoryTypeMapInitializerLoadDynamicWidgets::WidgetFactoryTypeMapInitializerLoadDynamicWidgets() [Loading QtTypelib: BasdaServiceState_NiceTypeQt]
2011-02-28 11:22:50.522030 INFO JOHNDOE 55cents:20585.b7f4a6d0 kulas Basda/Qt/ServiceState.cc:18 void instantType() [Load Basda::ServiceStateQt]
2011-02-28 11:22:50.522383 INFO JOHNDOE 55cents:20585.b7f4a6d0 kulas Nice/Qt/LoadDynamicWidgets.cc:96 WidgetFactoryTypeMapInitializerLoadDynamicWidgets::WidgetFactoryTypeMapInitializerLoadDynamicWidgets() [Load qt widgets done]
2011-02-28 11:22:50.528977 INFO JOHNDOE 55cents:20585.b7f4a6d0 kulas Nice/App/Config.cc:59 static bool Nice::Parser::parseFile(const std::string&, const Nice::JointPtr&) [with E = Nice::ParserFits] [Parsing file :/home/kulas/apps/etc/nice.cfg]


>>> from power_meter import PowerMeter
>>> powerMeter= PowerMeter("POWERMETERS.POWER_METERS.DEV0")
>>> powerMeter.getMeasuredPowerInWatt()
3.0
>>> 
Topic revision: r3 - 07 Aug 2018, AndrewColson
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback