diff --git a/plugin.txt b/plugin.txt index 0a07c50..7dfb165 100644 --- a/plugin.txt +++ b/plugin.txt @@ -1,5 +1,5 @@ # Set VARIABLEs here to allow variation in your plugin -# See https://openc3.com/docs/v5/plugins for more information +# See https://docs.openc3.com/docs/configuration/plugins for more information VARIABLE fakesat_target_name FAKESAT VARIABLE fakesat_int_name FAKESAT_INT diff --git a/targets/FAKESAT/lib/fake_sat.py b/targets/FAKESAT/lib/fake_sat.py new file mode 100644 index 0000000..0826e48 --- /dev/null +++ b/targets/FAKESAT/lib/fake_sat.py @@ -0,0 +1,5 @@ +from openc3.script import * + + +class FakeSat: + pass diff --git a/targets/FAKESAT/procedures/mem_load.py b/targets/FAKESAT/procedures/mem_load.py new file mode 100644 index 0000000..0912c07 --- /dev/null +++ b/targets/FAKESAT/procedures/mem_load.py @@ -0,0 +1,10 @@ +# Note hex 0x20 is ASCII space ' ' character +data = "\x20" * 10 +cmd(f"FAKESAT TABLE_LOAD with DATA {data}") +cmd("FAKESAT", "TABLE_LOAD", {"DATA": data}) +wait(2) # Allow telemetry to change +# Can't use check for binary data so we grab the data +# and check simply using comparison +block = tlm("FAKESAT HEALTH_STATUS TABLE_DATA") +if data != block: + raise RuntimeError("TABLE_DATA not updated correctly!") diff --git a/targets/FAKESAT/procedures/ops_suite.py b/targets/FAKESAT/procedures/ops_suite.py new file mode 100644 index 0000000..c3dc216 --- /dev/null +++ b/targets/FAKESAT/procedures/ops_suite.py @@ -0,0 +1,51 @@ +from openc3.script.suite import Suite, Group + +load_utility("FAKESAT/lib/fake_sat.py") + + +class CollectGroup(Group): + def script_normal_collect(self): + print( + f"Running {Group.current_suite()}:{Group.current_group()}:{Group.current_script()}" + ) + Group.print("Perform Normal Collect") + + cmd_cnt = tlm("FAKESAT HEALTH_STATUS CMD_ACPT_CNT") + collect_cnt = tlm("FAKESAT IMAGER COLLECTS") + cmd("FAKESAT COLLECT with TYPE NORMAL, DURATION 5") + wait_check(f"FAKESAT HEALTH_STATUS CMD_ACPT_CNT == {cmd_cnt + 1}", 5) + wait_check(f"FAKESAT IMAGER COLLECTS == {collect_cnt + 1}", 5) + wait_check("FAKESAT IMAGER COLLECT_TYPE == 'NORMAL'", 5) + + def script_special_collect(self): + print( + f"Running {Group.current_suite()}:{Group.current_group()}:{Group.current_script()}" + ) + Group.print("Perform Special Collect") + + cmd_cnt = tlm("FAKESAT HEALTH_STATUS CMD_ACPT_CNT") + collect_cnt = tlm("FAKESAT IMAGER COLLECTS") + cmd("FAKESAT COLLECT with TYPE SPECIAL, DURATION 5") + wait_check(f"FAKESAT HEALTH_STATUS CMD_ACPT_CNT == {cmd_cnt + 1}", 5) + wait_check(f"FAKESAT IMAGER COLLECTS == {collect_cnt + 1}", 5) + wait_check("FAKESAT IMAGER COLLECT_TYPE == 'SPECIAL'", 5) + + +class ModeGroup(Group): + def script_safe(self): + fakesat = FakeSat() + fakesat.safe() + + def script_checkout(self): + fakesat = FakeSat() + fakesat.checkout() + + def script_operate(self): + fakesat = FakeSat() + fakesat.operate() + + +class OpsSuite(Suite): + def __init__(self): + self.add_group(CollectGroup) + self.add_group(ModeGroup) diff --git a/targets/FAKESAT/procedures/ops_suite.rb b/targets/FAKESAT/procedures/ops_suite.rb index 9815541..eda3eb0 100644 --- a/targets/FAKESAT/procedures/ops_suite.rb +++ b/targets/FAKESAT/procedures/ops_suite.rb @@ -29,13 +29,16 @@ def script_special_collect class ModeGroup < OpenC3::Group def script_safe - FakeSat.new.safe + fakesat = FakeSat.new + fakesat.safe end def script_checkout - FakeSat.new.checkout + fakesat = FakeSat.new + fakesat.checkout end def script_operate - FakeSat.new.operate + fakesat = FakeSat.new + fakesat.operate end end diff --git a/targets/FAKESAT/procedures/set_override_inject_tlm.py b/targets/FAKESAT/procedures/set_override_inject_tlm.py new file mode 100644 index 0000000..2746853 --- /dev/null +++ b/targets/FAKESAT/procedures/set_override_inject_tlm.py @@ -0,0 +1,51 @@ +set_line_delay(1) +screen_def = """ + SCREEN AUTO AUTO 0.1 FIXED + VERTICAL + VERTICALBOX + LABELVALUE FAKESAT HEALTH_STATUS MODE + END + END +""" +# Here we pass in the screen definition as a string +local_screen("TESTING", screen_def) +prompt("Watch the screen for mode changes ...") + +cmd("FAKESAT SET_MODE with MODE SAFE") +wait_check("FAKESAT HEALTH_STATUS MODE == 'SAFE'", 5) + +# Call set_tlm twice to ensure it gets processed as real tlm flows +set_tlm("FAKESAT HEALTH_STATUS MODE = 'OPERATE'") +wait(0.2) +set_tlm("FAKESAT HEALTH_STATUS MODE = 'OPERATE'") +wait(5) # Should see value briefly +# This check fails as we receive data and revert back to 'SAFE' +check("FAKESAT HEALTH_STATUS MODE == 'OPERATE'") +# set_tlm back to SAFE to restore in the disconnected version +set_tlm("FAKESAT HEALTH_STATUS MODE = 'SAFE'") +set_tlm("FAKESAT HEALTH_STATUS MODE = 0", type="RAW") + +override_tlm("FAKESAT HEALTH_STATUS MODE = 'OPERATE'") +wait(2) +# By default it overrides all the value types with the value +# This includes types that might not make sense like :RAW +check("FAKESAT HEALTH_STATUS MODE == 'OPERATE'", type="RAW") +check("FAKESAT HEALTH_STATUS MODE == 'OPERATE'", type="CONVERTED") +check("FAKESAT HEALTH_STATUS MODE == 'OPERATE'", type="FORMATTED") +check("FAKESAT HEALTH_STATUS MODE == 'OPERATE'", type="WITH_UNITS") +wait() +# Clear the overrides +normalize_tlm("FAKESAT HEALTH_STATUS MODE") +wait_check("FAKESAT HEALTH_STATUS MODE == 0", 5, type="RAW") +wait_check("FAKESAT HEALTH_STATUS MODE == 'SAFE'", 5) # default CONVERTED +wait_check("FAKESAT HEALTH_STATUS MODE == 'SAFE'", 5, type="FORMATTED") +wait_check("FAKESAT HEALTH_STATUS MODE == 'SAFE'", 5, type="WITH_UNITS") +wait() + +# Call inject_tlm twice to ensure it gets processed as real tlm flows +inject_tlm("FAKESAT", "HEALTH_STATUS", {"MODE": "OPERATE"}) +wait(0.2) +inject_tlm("FAKESAT", "HEALTH_STATUS", {"MODE": "OPERATE"}) +wait(2) +# With flowing tlm, the next received packet overwrites so we're back +wait_check("FAKESAT HEALTH_STATUS MODE == 'SAFE'", 2)