GSEOS Python Interface
Previous  Top  Next

GSEOS uses the scripting language Python as its command and control language. You can interact with the GSEOS Python interpreter directly using the Console window. You can issue ordinary Python commands in this window and interface to GSEOS. The rest of this chapter describes the GSEOS Python interface. For further information on Python in general please refer to the Python Documentation on the Python home page at http://www.python.org.
The GSEOS interface to Python is relatively small. It provides support for commanding as well as Decoder, Monitor, and general GSEOS functionality. Your block definitions are exported as Python classes which allows you to access your real-time data easily through Python scripts.
Let's assume you defined a block called TLM in the block definition file with the following layout:

TLM
{
  Length    , , , 32;
  ApID      , , , 16;
  Data[800] , , ,  8;   
}

To access the value of the ApID item in the TLM block you simply type TLM.ApID in the console window. This prints out the current value of the ApID item. Note, that if you would issue the same command again you may get a different value since your instrument may have generated a new TLM block. Besides reading items you can also write items. This is useful when you write a decoder script to generate derived data (e.g. de-subcommutation). To write an item you simply assign a value to it, e.g.:

PHA.Data[10:20] = 2

The above line would set all elements between 10 and 20 (not including 20) of the Data item in the TLM block to 2. However, at this point you have not generated a new data block! If you would read the data back you would not get 2! In order for the block to be generated you have to forward it to the system with the send() command:

PHA.send()


Python structures it's modules in namespaces. The default namespace is __main__, this is the namespace all the block definitions are imported to. If you want to access blocks from your own scripts you will have to import these blocks from the __main__ module. So your scripts should have something like this in the beginning:

from __main__ import *

The command handling is implemented in the GseosCmd namespace.To use the GseosCmd module in your own scripts you have to import it, e.g.:

import GseosCmd
GseosCmd.ExecCmd("DEV_POWER(ON)")

The following subchapters describe the various interface modules in detail.