Modifications to NAOMI Sequencer API ICD

 

Version: 1.1

 

Nigel Dipper  06-October-2000

 

University of Durham, Dept. of Physics

 

                                                                        wht-naomi-53

 

Scope:

This document specifies modifications and additions to ING document: WHT-NAOMI-16. Section numbers are those of that document.

 

2.2 The CommandToElectra Command

This command in the API sends a command to the NAOMI Sequencer.

...

 

2.2.3 Function Outputs

 

The CommandToElectra command will return a Python dictionary of the form:

 

{"StatusReturned": "<status>", "Tag": "<tag>"}

 

where <status> is one of:

            BE_OK                       :           Ok

            BE_FAILED                :           Failed. E.G. Comms failure with Sequencer

            BE_UNKNOWN        :           No such command

 

and <tag> is a unique identifier for this command.

 

The sequencer will create a unique status dictionary entry in the EPM with a name of the form: tag_<tag> where <tag> is the unique identifier above.  This EPM status dictionary is defined below in section 2.3.3.

 

2.3 The CommandStatus Command

This command is currently calledGetElectraStatus. It is used to retrieve one or more state variables from the NAOMI EPM. One common use is to retrieve a tagged status dictionary containing the current status of a  command being executed by the sequencer.

...

 

2.3.1 Function API

 

            ElectraMPI.GetElectraStatus("<First state variable>", ... , <Last state variable>")

 

 

 

2.3.3 Function Output

 

The function will return a Python dictionary of the form:

 

{"StatusReturned": "<status>",  "First state variable": "<value>", ..., "Last state variable": "<value>"}

 

where <status> is one of:

            BE_OK                       :           Ok

            BE_FAILED                :           Failed.  E.G. Problem talking to EPM

            BE_UNKNOWN        :           No such state variable in EPM

 

If StatusReturned is not BE_OK, no state variables will be returned.

 

For the case of a request for the tagged status of a sequencer command, the returned dictionary will be of the form:

 

{"StatusReturned": "<status>",  "tag_xxx": "<status dictionary>"}

 

where <status> is as in the above general case,

and where <status dictionary> is the dictionary retrieved from the EPM that corresponds to tag_xxx.

 

The status dictionary has the form:

 

{"CommandStatus": "<status>", "PID": "<pid>", "Command": " <command>",

  "LatestTimeout": "<time>", "Error": "<error dictionary>"}

 

where:

<status> is one of:

            Running                        :           Set initialy by the forked sequencer

            CompletedOk              :           Set on completion by forked sequencer

            Error                            :           Set by the script if an error occurs

            TimedOut                     :           Set by the script or by the crash detector

            Crashed                       :           Set by the crash detector

 

<pid> : Set to the pid of the forked sequencer. (Used by the crash detector).

 

<command> : Set to the original command name by the forked sequencer

 

<time> : Set to the latest completion time. A default value is set by the forked sequencer.

               This can be changed to a different value by the script.

 

<error dictionary> : Set by the script. If there is no error, this will not be present.

 

The error dictionary has the form:

 

{"Status": "<status code>", "Traceback": "<traceback string>",

  "Message": "<text error message>", "time": "<time>"}

 

where:

<status code> is an error status code

 

<traceback string> is a Python traceback string

 

<text error message> is an error message from the script

 

<time> is the time at which the error occured.

 

2.3.3.1 Example Command Status Dictionaries

 

A command to the sequencer that caused an error:

 

{'CommandStatus' : 'Error',   'PID' : '12345',    'Command' : 'CloseLoop()',

  'LatestTimeout' : '12:34:56',    'Error' : '{'Status' : 123,

 'Traceback' : '  Traceback (innermost last): File "<stdin>", line 1, in ? NameError: fred',

 'Message' : 'Something went wrong!',   'Time' : '12:34:56'}'  }

 

A command to the sequencer that started successfully and is still running:

 

{'CommandStatus' : 'Running', 'PID' : '12345', 'Command' : 'DoSomething()',

  'LatestTimeout' : '12:34:56'}

 

A command to the sequencer that completed successfully:

 

{'CommandStatus' : 'CompletedOk', 'PID' : '12345', 'Command' : 'DoSomething()'

'LatestTimeout' : '12:34:56'}

 

 

2.4 The FreeStatus Command

 

This command is currently calledFreeElectraStatus. It is used to delete one or more state variables from the NAOMI EPM. One common use is to delete a tagged status dictionary containing the current status of a  command that has completed (or failed) in the Sequencer.

In normal use, it will be limited to this one function and deletion of state variables that are not tagged command status dictionaries will not be possible.

 

...

 

2.4.3 Function Output

 

The function will return a Python dictionary of the form:

 

{"StatusReturned": "<status>"}

 

where <status> is one of:

            BE_OK                       :           Ok.

            BE_FAILED                :           Failed.  E.G. Problem talking to EPM

            BE_UNKNOWN        :           No such state variable in EPM