BallAerospace / COSMOS

Ball Aerospace COSMOS
https://ballaerospace.github.io/cosmos-website/
Other
360 stars 129 forks source link

Pass script parameters from TlmScreen #1729

Closed boematic closed 2 years ago

boematic commented 2 years ago

I'm looking to run a script from the "Telemetry Screens" but pass it parameters. Is this possible?

More detail: I have a Telemetry Screen for the user to input parameters. On this screen there is a Button that when pressed will run a script. The script will need the parameters that the user specified on the Telemetry Screen that I've created. Just wondering if this is possible and how to do it?

dmccomas commented 2 years ago

Yes, you can use the NAMED_WIDGET in the screen definition file and access the name in a ruby script. Here's an example from OpenSatKit that uses COSMOS 4.x

The screen definition file contains: NAMED_WIDGET Kunl TEXTFIELD 12 https://github.com/OpenSatKit/OpenSatKit/blob/master/cosmos/config/targets/F42/screens/ctrl_gains_screen.txt

The ruby script accesses the named widget with: screen_widget = screen.get_named_widget("Kunl") https://github.com/OpenSatKit/OpenSatKit/blob/master/cosmos/config/targets/F42/lib/f42_screens.rb

boematic commented 2 years ago

I tried it but I'm getting an error about "require not defined". I should have mentioned that I'm using COSMOS 5x. That probably makes a difference.

jmthomas commented 2 years ago

Unfortunately we don't yet have this ability directly. You could set metadata with set_metadata({'key' => 'val'}) and then access in your script with get_metadata().

You could also potentially call set_tlm(TGT PKT ITEM = 1) to set a particular telemetry point that doesn't get overwritten by a packet. Perhaps create a DERIVED item for this purpose.

boematic commented 2 years ago

Is there a timeline on when this might be added? I'm evaluating COSMOS for a new project and we would need that feature. If it gets added in the next 6 months then that would work for us.

CharlotteMorrison commented 2 years ago

@jmthomas is there documentation or an example of how to use the set_metadata({'key' => 'val'}) with get_metadata() to pass a value from a screen to a script? I tried adding those commands to a button and wasn't able to get them to work.

jmthomas commented 2 years ago

@boematic please create a new issue on OpenC3 if this is still important to you.

boematic commented 2 years ago

We've moved back to version 4 of COSMOS.