How do I configure startup settings?
Previous  Top  Next

When GSEOS starts up your custom configuration files can be loaded to setup GSEOS for your environment. There is two categories of startup files that can be loaded:

·Configuration Files  
·Python scripts  

Loading of Configuration files at startup

Configuration files are screen files (*.scr), command menu files (*.cm), desktop files (*.dt), log files (*.log), formula files (*.qlf), text reference files (*.tr), and any custom files you register with GSEOS. These can be loaded automatically by specifying the file name in the gseos.ini [Config] section. See the example below for a typical configuration entry:

[Config]
Load = System\System.qlf Common\Pluto.qlf i_LORRI\LOR_cust.qlf
Load = system\system.cpd Common\sce.cm
Load = Common\common.tr Common\basic.tr Common\Common_ltgray.tr
Load = i_LORRI\LOR_cust.tr
Load = i_LORRI\CMD_n_TLM\ApId_601.qlf
Load = i_LORRI\CMD_n_TLM\ApId_601.alarm
Load = i_LORRI\CMD_n_TLM\ApId_601.tr

It is also possible to load Python files (*.py, *.pyd, *.dll) here, this is only recommended for simple configurations, complex (mission or multipe instrument) configurations should use the alternate appoach listed below.

Loading of Python scripts at startup

It is often it is necessary load Python scripts at startup time. There are several different approaches with different consequences:

1.Specify the scripts to load in the gseos.ini [Config] section.  
2.Specify the scripts to load in a command batch file that is specified in the [Config] section of the gseos.ini file.  
3.Use a Python startup script that imports all the necessary configuration scripts.  

1. Using the [Config] section
The first approach is the simplest and most straightforward, you can just specify the Python scripts to load at startup time in the gseos.ini file [Config] section. You have to use the Load entry. You can specify multiple files for one Load entry and you can also specify as many Load entries in the [Config] section as you like. Please see the sample below:

[Config]
BlkFiles=system\system.blk  Messenger.blk common\pkt_tlm.blk rtiu\rtiu.blk
Load = LP1553Bios.dll common\common_cmds.py core\test_arg.py
Load = core\RTIUDec.py common\embx_cmds.py core\core.py common\config.py
Load = system\system.cpd common\com_DPU\instrument.cm common\com_DPU\embox.cm
Load = Instrument\i_DPU\startup_dpu.cpb

Multiple entries on one Load line are separated by white-spaces. In general it is probably the best approach to just specify one file per line.

Two things happen when these files get loaded:
The system checks if the path specified is already in the sys.path (the Python search path). If it is not the path gets prepended to sys.path to load the file. Once the file is successfully loaded the sys.path is restored to its previous contents.
If the module has been loaded before it will get reloaded, otherwise it will be imported.

The import is run in the __main__ namespace context. Say you specify
xyz.py, this means you can access the module xyz directly from the __main__ namespace, i.e. the console window: dir(xyz).
However, one limitation of this approach is that you can't do the equivalent of:
from xyz import *
and therefore import the contents of the module into the __main__ namespace. Say you define a command script MyCmds.py and you want to issue the commands directly from a button or the console window. You would need to invoke a command like so: MyCmds.POWER_ON(). The next approach will show you how to address this problem. Also, loading a package is not possible only Python modules can be loaded with this approach.

For simple configurations this is the recommended approach. More complex configurations for entire mission support or multiple instrument configurations should use approach 3.

Note:
In general it is a good idea to explicitly use namespaces and only import an entire module. If you load everything directly into the __main__ namespace this namespace gets cluttered and it is difficult to track down where individual attributes are defined.


2. Using a command batch (*.cpb) file
With this approach we can address the problem we encountered with directly specifying the Python scripts in the Using batch files for startup configuration is strongly discouraged since it might introduce time dependent behavior that is hard to control. Please refer to the next section for Python script based startup configuration.


3. Python script based startup configuration
The problem with the simple approach of loading Python scripts directly from the [Config] section is that you don't have the equivalent of:
from xxx import *

To facilitate this you can use the [PyStartup] section in the gseos.ini file. The [PyStartup] section has two keys: 'Import' and 'Exec'. 'Import' lets you import Python modules as well as Python packages. The module/package has to be on the search path to be loaded successfully.
'Exec' lets you execute an Python statement. We will use this feature to import the contents of the startup script into the __main__ namespace. Please see the example below for a startup configuration using the 'Exec' approach:

[PyStartup]
Import = TC_TLM_Load
Exec   = from Common.Startup import *
Exec   = from i_LORRI.StartupMaster import *

The statements are executed in the order listed. You can enter any number of startup scripts you need. However, it is recommended to perform all imports and other configuration within your startup script.


GSEOS startup order

The following lists the order in which GSEOS bootstraps the configuration files:

·Load block definition files from [Config] BlkFiles entries.  
·Execute [PyStartup] Import/Exec entries.  
·Load configuration files from [Config] Load section.  

Since batch files are time depended they will be executed when loaded from the [Config] Load section but may be preempted by other scripts depending on the processing of the message queue. Therefore batch files can be used for delayed initialization at startup.