-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from OpenC3/python
Add python code
- Loading branch information
Showing
6 changed files
with
124 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from openc3.script import * | ||
|
||
|
||
class FakeSat: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |