Skip to content

Instantly share code, notes, and snippets.

@jdiez17
Created January 13, 2025 13:08
Show Gist options
  • Save jdiez17/9adcefaec3a4514dcdcdd1b4277c94a0 to your computer and use it in GitHub Desktop.
Save jdiez17/9adcefaec3a4514dcdcdd1b4277c94a0 to your computer and use it in GitHub Desktop.
# /// script
# dependencies = [ "yamcs-pymdb" ]
# ///
from yamcs.pymdb import *
service = System("Raccoon")
service_type_id = 130
base_cmd = Command(
system=service,
name="base",
abstract=True,
base="/PUS/pus-tc",
assignments={"type": service_type_id},
)
generated_cmd_test = Command(
system=service,
base=base_cmd,
assignments={"subtype": 1},
name="GeneratedCommandTest",
arguments=[
IntegerArgument(
name="BatteryNum",
minimum=1,
maximum=3,
encoding=uint8_t,
signed=False,
),
IntegerArgument(
name="CustomLength",
minimum=0,
maximum=244,
encoding=IntegerEncoding(bits=5),
signed=False,
),
EnumeratedArgument(
name="EnumArg",
choices=[[0, "OFF"], [1, "ON"], [2, "EXPLODE"]],
encoding=uint8_t,
),
EnumeratedArgument(
name="EnumeratedArgCustomType",
choices=[[0, "AUS"], [1, "EIN"], [2, "JA"]],
encoding=IntegerEncoding(bits=4),
),
],
)
pcu_voltage_array_parameter = ArrayParameter(
system=service, name="Voltages", length=5, data_type=IntegerDataType(bits=16)
)
pcu_telemetry = Container(
system=service,
base="/PUS/pus-tm",
name="PCUTelemetry",
condition=AndExpression(
EqExpression("/PUS/pus-tm/type", service_type_id), EqExpression("/PUS/pus-tm/subtype", 1)
),
entries=[
ParameterEntry(pcu_voltage_array_parameter),
ParameterEntry(
EnumeratedParameter(
system=service,
name="PcuState",
choices=[[0, "ON"], [1, "OFF"], [2, "FAULT"]],
encoding=uint8_t,
)
),
],
)
print(service.dumps())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment