Skip to content

Conversation

@ginoscott
Copy link
Contributor

When attempting to use a ParameterEntry as an argument for a command, you will get this error:

  File ".../yamcs/pymdb/xtce.py", line 186, in add_argument_type_set
    default=default,
NameError: name 'default' is not defined

This is because while arguments have 'default', ParameterEntry does not.
While it does instead have a 'initial_value' field, but it would be better to not assign a ParameterEntry's initial_value as the default argument since that would cause that argument to be hidden inside the default dropdown menu when trying to Send a Command in YAMCS.

This would help with not having to define the same field that appears in telemetry containers and commands twice -- once as a parameter and again as an argument.

@fqqb
Copy link
Member

fqqb commented May 4, 2025

I understand what you're saying with the difference between default and initial_value, but cannot exactly reproduce your error, nor your fix to it.

The closest I can get to an similar error, is for example by attempting to directly use an IntegerParameter as an argument, but that's not allowed.

Note there's a distinction between a command's arguments and a command's entries:

  • An argument is what the user sees in the form. There is no possibility to use parameter types for arguments. Argument types and parameter types are separate things in XTCE, and I kept that distinction in this library (while very similar, there are various differences between TM and TC data types).

  • A command's entries describes what is ultimately encoded into the generated command binary. For example, it's perfectly valid to have arguments in a different order than you have argument entries, or to add some extra bits between two encoded arguments (using FixedValueEntry, or relative offsets).

A ParameterEntry may also be used as a special kind of argument entry, however the purpose of this is to directly encode the current value of that parameter in the command binary, without any user involvement (not linked to a command argument). I do confirm there an issue in this library with this scenario, which is TODO: https://github.com/yamcs/pymdb/blob/v1.0.12/src/yamcs/pymdb/xtce.py#L446

If I have misunderstood you, maybe you can adapt below example to illustrate the issue that you are seeing:

import yamcs.pymdb as Y

system = Y.System("myproject")
ccsds_header = Y.ccsds.add_ccsds_header(system)

command_id = Y.IntegerArgument(
    name="command_id",
    signed=False,
    encoding=Y.uint16_t,
)
base_command = Y.Command(
    system=system,
    name="Base",
    abstract=True,
    base=ccsds_header.tc_command,
    assignments={
        ccsds_header.tc_secondary_header.name: "Not Present",
        ccsds_header.tc_apid.name: 101,
    },
    arguments=[
        command_id,
    ],
)

arg = Y.IntegerArgument(
    name="arg",
    encoding=Y.uint16_t,
)
par = Y.IntegerParameter(
    system=system,
    name="par",
    data_source=Y.DataSource.LOCAL,
    encoding=Y.int32_t,
)

Y.Command(
    system=system,
    base=base_command,
    name="SomeCommand",
    assignments={command_id.name: 3},
    arguments=[
        arg,
        # par,  # Not allowed
    ],
    entries=[
        Y.ArgumentEntry(arg),
        # Y.ParameterEntry(par),  # Currently broken
    ],
)

print(system.dumps())

since that would cause that argument to be hidden inside the default dropdown menu when trying to Send a Command in YAMCS.

See option collapseInitializedArguments in yamcs-web configuration settings:
https://docs.yamcs.org/yamcs-server-manual/web-interface/configuration/

@ginoscott
Copy link
Contributor Author

A ParameterEntry may also be used as a special kind of argument entry, however the purpose of this is to directly encode the current value of that parameter in the command binary, without any user involvement (not linked to a command argument).

Oh I see, I was not aware of this intended meaning of ParameterEntry. I'll close this PR then, since it was made in error.

Y.Command(
system=system,
base=base_command,
name="SomeCommand",
assignments={command_id.name: 3},
arguments=[
arg,
# par, # Not allowed -- wasn't aware of this
],
entries=[
Y.ArgumentEntry(arg),
# Y.ParameterEntry(par), # This is what I was trying to get working, but without the part where it refers to the current parameter value
],
)

@ginoscott ginoscott closed this May 7, 2025
@ginoscott ginoscott deleted the feature/support_parametery_entry_argument branch May 7, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants