CSD parser#

The parse_cm.csd module implements an interpreter for the OP-19 Command Sequence Definition language. It is used to translate a Detailed Operations Timeline (DOT) or a FOT request into backstop commands. Some Caveats apply, but for most commanding the translation is accurate and well-tested.

By default this uses the configured ATS and RTS product files on OCCweb, but you can optionally use local versions of those files.

Examples#

Translate a DOT to a backstop CommandTable#

In this example we translate the DOT from MAR2122A into a kadi CommandTable with the corresponding backstop commands.

First we need to get the DOT file using the get_occweb_page() function:

>>> from kadi.occweb import get_occweb_page
>>> mar2122a = 'FOT/mission_planning/PRODUCTS/APPR_LOADS/2022/MAR/MAR2122A'
>>> dot = get_occweb_page(f'{mar2122a}/mps/mdMAR2122A.dot', cache=True)
>>> print(dot[:400])
!Schedule generated by MATLAB Tools at: 2022:073:16:05:24.432

ATS,ACQ,MANEUVER='TRUE',NUMENT=12,AQIM1=0,AQY1=-0.00375441,           O23840M001
AQZ1=-0.00453566,AQMBRT1=6.00000000,AQMFNT1=8.00000000,AQRES1='H',    O23840M001
AQBOX1=1,AQSIZE1=2,AQFLG1=3,AQIM2=1,AQY2=0.01037522,AQZ2=0.00470447,  O23840M001
AQMBRT2=6.00000000,AQMFNT2=8.00000000,AQRES2='H',AQBOX2=1,AQSIZE2=2,  O23840M001
AQFLG2=3,AQIM

In order to translate the DOT correctly, we need to set continuity. In typical flight planning these values are managed in ORviewer and provided to CMAN, but in this case we do this manually using the get_initial_globals_from_trp() function:

>>> from parse_cm.csd import get_initial_globals_from_trp
>>> trp = get_occweb_page(f'{mar2122a}/C079_2001.trp', cache=True)
>>> initial_globals = get_initial_globals_from_trp(trp)
>>> initial_globals
{'G_ACQFLG': 'FALSE',
'G_MANFLG': 'TRUE',
'G_SUNPOSMON': 'ENAB',
'G_TLM_FMT': 2,
'PREV_HRC_DETECTOR': 'HRC-I',
'SHUTTERS_HOME': 'TRUE',
'PREV_HRC_DEF_SETTINGS': 'FALSE',
'HRC_DOOR_OPEN': 'TRUE',
'G_MSFILTER': 'DISA',
'G_IU_ID': 'A',
'G_GRATING_STAT': 'NONE',
'G_98_STATE': 'ENAB'}

We need any FOT requests that were included:

>>> fot_request = get_occweb_page(f'{mar2122a}/fot/MAR2122A_RAD_DM.fot', cache=True)

And finally get the backstop commands from the DOT using the csd_cmd_gen() function:

>>> from parse_cm.csd import csd_cmd_gen
>>> cmds = csd_cmd_gen(dot, initial_globals=initial_globals,
...                    fot_requests=[fot_request])
>>> cmds
        date            type     tlmsid  scs           params
--------------------- ---------- -------- --- -------------------------
2022:079:20:30:44.820 COMMAND_SW AOACRSTD 128             MSID=AOACRSTD
2022:079:20:31:44.820 COMMAND_SW AOFUNCDS 128 AOPCADSD=21 MSID=AOFUNCDS
2022:079:20:32:44.820 COMMAND_SW AOFUNCDS 128 AOPCADSD=32 MSID=AOFUNCDS
2022:079:20:33:44.820 COMMAND_SW AONMMODE 128             MSID=AONMMODE
2022:079:20:33:44.820   ORBPOINT     None 131                 POS=91254
                ...        ...      ... ...                       ...
2022:086:22:30:01.285 COMMAND_HW   CTXAOF 128               MSID=CTXAOF
2022:086:22:30:01.542 COMMAND_HW   CTXBOF 128               MSID=CTXBOF
2022:086:22:30:01.799 COMMAND_HW   CPAAOF 128               MSID=CPAAOF
2022:086:22:30:02.056 COMMAND_HW   CPABOF 128               MSID=CPABOF
2022:086:22:30:02.313 COMMAND_SW OFMTSNRM 128             MSID=OFMTSNRM
Length = 1416 rows

Translate a FOT request to commands#

>>> from parse_cm.csd import csd_cmd_gen
>>> fot_req = '''
... RTSLOAD,A_QUP,SCS_NUM=214,
... Q1=0.70546907,
... Q2=0.32988307,
... Q3=0.53440900
... '''
>>> cmds = csd_cmd_gen(fot_req, date='2021:001')
>>> print(cmds)
         date             type     tlmsid  scs                         params
--------------------- ----------- -------- --- ------------------------------------------------------
2021:001:00:00:00.000 MP_TARGQUAT AOUPTARQ 214 Q1=0.70546907 Q2=0.32988307 Q3=0.534409 Q4=0.328477658

Caveats#

This command generation does not get to the level of CMAN, for instead the SCS is fixed to either 128, 131, or the specified SCS number, and the command “step” number is not generated. However, the key command parameters do match.

ACA hardware commanding via the AAC1CCSC command is not generated correctly. Instead you will see commands like AAC1CAL, AAC1INT, AAC1HDR, and/or AAC1IU.

By default, the ATS and RTS files which get used in the translation are the current flight configured products on OCCweb. These are downloaded from OCCweb as needed. If you translate an older DOT then problems may occur, either outright failures or command outputs that do not match the actual backstop commands at the time of original translation. In most cases, apart from regression testing, this is not an issue. The csd_dir option of csd_cmd_gen() provides a pathway to use a fixed or archived set of ATS / RTS products.

Testing#

Testing of this module has included running the command generation for dozens of historical DOT files and comparing the generated commands to the flight backstop. Current regression testing uses MAR2122A, MAR1422A, MAR0722A, FEB2822A, and FEB2122A.