BallAerospace / COSMOS

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

Migrating COSMOS4 targets to COSMOS5, scripts and telemetry not seen by other targets #1693

Open vidfare opened 2 years ago

vidfare commented 2 years ago

We have an application in COSMOS4 that we want to run in COSMOS5 (5.0.4). The application consists of multiple targets and multiple interfaces. I have created a plugin with the migrate command that consists of the targets used by the application from COSMOS4.

(In the examples I use other names than in our application)

A simplified version of the plugins plugins.txt file looks like:

TARGET SYSTEM SYSTEM
TARGET DEF DEF
TARGET GHI GHI

INTERFACE GHI_INT simulated_target_interface.rb ghi_target.rb
  MAP_TARGET GHI

INTERFACE ABC_INT abc_interface.rb
  MAP_TARGET DEF

The scripts abc_interface.rb and ghi_target.rb are in the target GHI's lib directory. The script simulated_target_interface.rb is included in the COSMOS5 installation.

Problem finding scripts Some targets uses Ruby scripts that are in other target's lib directories. That worked in COSMOS4 but in COSMOS 5 I get errors like: DEFAULT__INTERFACE__ABC_INT Unable to require abc_interface.rb due to cannot load such file -- abc_interface.rb. Ensure abc_interface.rb is in the COSMOS lib directory.

Problem reading telemetry The Ruby scrips in the application reads telemetry that are created by other targets. The scripts uses the functions System.telemetry.packet(), System.telemetry.set_value(), System.telemetry.value() to create, set, and read telemetry. When a script in a target tries to read telemetry from another target I get errors like: DEFAULT__INTERFACE__GHI_INT GHI_INT: Connection Failed: RuntimeError : Telemetry target 'SYSTEM' does not exist The SYSTEM telemetry is defined in a file in targets/SYSTEM/cmd_tlm/. The target SYSTEM is present in the WebGUI CmdTlmServer->TARGETS and CmdTlmServer->TLM PACKETS, but the target script ghi_target.rb can't read from it.

Questions Can a target in COSMOS5 not use script files from other targets? What is the "COSMOS lib directory", is it any central lib directory in COSMOS5? I only see the lib directories under every target. Can a target in COSMOS5 not read telemetry created by other targets?

jmthomas commented 2 years ago
  1. Can a target in COSMOS5 not use script files from other targets?

Yes but you need to provide a fully qualified path: require ABC/lib/abc_interface.rb.

  1. What is the "COSMOS lib directory", is it any central lib directory in COSMOS5? I only see the lib directories under every target.

That message is a carry-over from COSMOS 4. COSMOS 5 doesn't have a global lib directory as COSMOS 4 did as plugins are meant to be standalone.

  1. Can a target in COSMOS5 not read telemetry created by other targets?

Yes but not through System as in COSMOS 5. You need to use the new APIs like tlm() or get_tlm_packet().

vidfare commented 2 years ago

Thanks for the answers. But it didn't really work.

Can a target in COSMOS5 not use script files from other targets? _Yes but you need to provide a fully qualified path: require ABC/lib/abcinterface.rb.

This doesn't work for me. Maybe you mean require in a Ruby file. I get this problem when a TLM definition file under ABC/cmd_tlm/tlms.txt calls a script to convert a value: E.g. READ_CONVERSION convert_field.rb 'tlm' And the file convert_field.rb is in another target DEF/lib/convert_field.rb The file ABC/target contains: REQUIRE convert_field.rb

Can a target in COSMOS5 not read telemetry created by other targets? _Yes but not through System as in COSMOS 5. You need to use the new APIs like tlm() or get_tlmpacket().

I have not tried using the APIs, but I found when I added mappings to the plugin.txt file the errors about missing telemetry targets was gone.

TARGET SYSTEM SYSTEM
TARGET DEF DEF
TARGET GHI GHI

INTERFACE GHI_INT simulated_target_interface.rb ghi_target.rb
  MAP_TARGET GHI
  MAP_TARGET SYSTEM # <- Added this

INTERFACE ABC_INT abc_interface.rb
  MAP_TARGET DEF
jmthomas commented 2 years ago

I think PR #1703 will fix the top level lib dir.

vidfare commented 2 years ago

I have cloned the latest COSMOS5 from Git. But COSMOS5 doesn't find the scripts in the lib directory. I'm unsure where the top-level lib directory actually is. I have tested with a lib directory in the gem directory i.e. where the plugin.txt is. I have also tested copy the scrips to the lib directory /targets//lib. But none of these lib directories work.