Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Add dither cmd sets and fix nsm cmd_set, etc #64

Merged
merged 6 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions Chandra/cmd_states/cmd_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ def manvr(*args):
)

def acis(*args):
cmds = [dict(cmd='ACISPKT', tlmsid=tlmsid) for tlmsid in args]
cmds = tuple(dict(cmd='ACISPKT', tlmsid=tlmsid) for tlmsid in args)
return cmds

def aciscti():
Expand All @@ -779,6 +779,13 @@ def aciscti():

def scs107():
return (dict(dur=1.025),
dict(cmd='COMMAND_SW',
dur=1.025,
tlmsid='OORMPDS'),
dict(cmd='COMMAND_HW',
dur=1.025,
tlmsid='AFIDP',
msid='AFLCRSET'),
dict(cmd='SIMTRANS',
params=dict(POS=-99616),
dur=65.66),
Expand All @@ -789,16 +796,35 @@ def scs107():
tlmsid='AA00000000',
dur=10.25),
dict(cmd='ACISPKT',
tlmsid='WSPOW00000'),
tlmsid='WSPOW0002A'),
)

def nsm():
return (dict(cmd='COMMAND_SW',
tlmsid='AONSMSAF'),
def dith_on():
return (dict(dur=1.025),
dict(cmd='COMMAND_SW',
tlmsid='AOENDITH',
)
)

def dith_off():
return (dict(dur=1.025),
dict(cmd='COMMAND_SW',
tlmsid='AODSDITH',
)
)

def nsm():
nsm_cmd = dict(cmd='COMMAND_SW',
tlmsid='AONSMSAF')
out = ((nsm_cmd,)
+ scs107()
+ dith_off()
)
return out

cmd_sets = dict(manvr=manvr, scs107=scs107, nsm=nsm, obsid=obsid,
acis=acis, aciscti=aciscti)
acis=acis, aciscti=aciscti,
dith_on=dith_on, dith_off=dith_off)
return cmd_sets[name](*args)


Expand Down
71 changes: 71 additions & 0 deletions Chandra/cmd_states/tests/test_cmd_sets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

from Chandra.cmd_states import cmd_set

# COMMAND_HW | TLMSID= AFIDP, HEX= 6480005, MSID= AFLCRSET

def test_cmd_sets1():
cmds = cmd_set('scs107')
exp = ({'dur': 1.025},
{'cmd': 'COMMAND_SW', 'dur': 1.025, 'tlmsid': 'OORMPDS'},
{'cmd': 'COMMAND_HW', 'dur': 1.025, 'tlmsid': 'AFIDP', 'msid': 'AFLCRSET'},
{'cmd': 'SIMTRANS', 'dur': 65.66, 'params': {'POS': -99616}},
{'cmd': 'ACISPKT', 'dur': 1.025, 'tlmsid': 'AA00000000'},
{'cmd': 'ACISPKT', 'dur': 10.25, 'tlmsid': 'AA00000000'},
{'cmd': 'ACISPKT', 'tlmsid': 'WSPOW0002A'})
assert cmds == exp


def test_cmd_sets2():
cmds = cmd_set('nsm')
exp = ({'cmd': 'COMMAND_SW', 'tlmsid': 'AONSMSAF'},
{'dur': 1.025},
{'cmd': 'COMMAND_SW', 'dur': 1.025, 'tlmsid': 'OORMPDS'},
{'cmd': 'COMMAND_HW', 'dur': 1.025, 'tlmsid': 'AFIDP', 'msid': 'AFLCRSET'},
{'cmd': 'SIMTRANS', 'dur': 65.66, 'params': {'POS': -99616}},
{'cmd': 'ACISPKT', 'dur': 1.025, 'tlmsid': 'AA00000000'},
{'cmd': 'ACISPKT', 'dur': 10.25, 'tlmsid': 'AA00000000'},
{'cmd': 'ACISPKT', 'tlmsid': 'WSPOW0002A'},
{'dur': 1.025},
{'cmd': 'COMMAND_SW', 'tlmsid': 'AODSDITH'})
assert cmds == exp


def test_cmd_sets3():
cmds = cmd_set('manvr', 0, 0, 0, 1)
exp = ({'cmd': 'COMMAND_SW',
'dur': 0.25625,
'msid': 'AONMMODE',
'tlmsid': 'AONMMODE'},
{'cmd': 'COMMAND_SW', 'dur': 4.1, 'msid': 'AONM2NPE', 'tlmsid': 'AONM2NPE'},
{'cmd': 'MP_TARGQUAT',
'dur': 5.894,
'params': {'Q1': 0.0, 'Q2': 0.0, 'Q3': 0.0, 'Q4': 1.0},
'tlmsid': 'AOUPTARQ'},
{'cmd': 'COMMAND_SW', 'msid': 'AOMANUVR', 'tlmsid': 'AOMANUVR'})
assert cmds == exp


def test_cmd_sets4():
cmds = cmd_set('obsid', 30000)
exp = ({'cmd': 'MP_OBSID', 'params': {'ID': 30000}},)
assert cmds == exp


def test_cmd_sets5():
cmds = cmd_set('acis', 'XTZ0000005', 'WSPOW0CF3F')
exp = ({'cmd': 'ACISPKT', 'tlmsid': 'XTZ0000005'},
{'cmd': 'ACISPKT', 'tlmsid': 'WSPOW0CF3F'})
assert cmds == exp


def test_cmd_sets6():
cmds = cmd_set('dith_on')
exp = ({'dur': 1.025}, {'cmd': 'COMMAND_SW', 'tlmsid': 'AOENDITH'})
assert cmds == exp


def test_cmd_sets7():
cmds = cmd_set('dith_off')
exp = ({'dur': 1.025}, {'cmd': 'COMMAND_SW', 'tlmsid': 'AODSDITH'})
assert cmds == exp