Module: Cosmos::Api
- Includes:
- Extract
- Included in:
- BackgroundTask, CmdTlmServer, Interface, LimitsResponse
- Defined in:
- lib/cosmos/tools/cmd_tlm_server/api.rb
Constant Summary
Constants included from Extract
Extract::SCANNING_REGULAR_EXPRESSION
Instance Method Summary collapse
-
#cmd(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target.
-
#cmd_no_checks(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without performing any value range checks or hazardous checks both on the command itself and its parameters.
-
#cmd_no_hazardous_check(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without performing any hazardous checks both on the command itself and its parameters.
-
#cmd_no_range_check(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without performing any value range checks on the parameters.
-
#cmd_raw(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without running conversions.
-
#cmd_raw_no_checks(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without running conversions or performing any value range checks or hazardous checks both on the command itself and its parameters.
-
#cmd_raw_no_hazardous_check(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without running conversions or performing any hazardous checks both on the command itself and its parameters.
-
#cmd_raw_no_range_check(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without performing any value range checks on the parameters or running conversions.
-
#connect_interface(interface_name, *params) ⇒ Object
Connects to an interface and starts its telemetry gathering thread.
-
#connect_router(router_name, *params) ⇒ Object
Connects a router and starts its command gathering thread.
-
#disable_limits(*args) ⇒ Object
Disable limit checking for a telemetry item.
-
#disable_limits_group(group_name) ⇒ Object
Disables limit checking for all the items in the given group.
-
#disconnect_interface(interface_name) ⇒ Object
Disconnects from an interface and kills its telemetry gathering thread.
-
#disconnect_router(router_name) ⇒ Object
Disconnects a router and kills its command gathering thread.
-
#enable_limits(*args) ⇒ Object
Enable limits checking for a telemetry item.
-
#enable_limits_group(group_name) ⇒ Object
Enables limit checking for all the items in the given group.
-
#get_cmd_hazardous(target_name, command_name, params = {}) ⇒ Boolean
Returns whether the specified command is hazardous.
-
#get_cmd_list(target_name) ⇒ Array<Array<String, String>>
Returns the list of all the command names and their descriptions from the given target.
-
#get_cmd_log_filename(packet_log_writer_name = 'DEFAULT') ⇒ String
The command packet log filename.
-
#get_cmd_param_list(target_name, command_name) ⇒ Array<Array<String, Object, nil|Array, nil|String, nil|String, nil|String, Boolean>] Array containing \[name, default, states, description, units_full, units, required] for all parameters in the command
Returns the list of all the parameters for the given command.
-
#get_interface_names ⇒ Array<String>
All the interface names.
-
#get_limits(target_name, packet_name, item_name, limits_set = nil) ⇒ Array<limits_set, persistence, enabled, red_low, yellow_low, red_high, yellow_high, green_low (optional), green_high (optional)] Limits information
Get the limits for a telemetry item.
- #get_limits_event(id, non_block = false) ⇒ Object
-
#get_limits_groups ⇒ Hash(String, Array)
The defined limits groups.
-
#get_limits_set ⇒ String
Returns the active limits set that applies to all telemetry.
-
#get_limits_sets ⇒ Array<Symbol>
Returns all defined limits sets.
-
#get_out_of_limits ⇒ Array<Array<String, String, String, Symbol>>
Return an array of arrays indicating all items in the packet that are out of limits [[target name, packet name, item name, item limits state], …].
-
#get_overall_limits_state(ignored_items = nil) ⇒ Symbol
The overall limits state for the system.
- #get_packet_data(id, non_block = false) ⇒ Object
-
#get_router_names ⇒ Array<String>
All the router names.
-
#get_server_message_log_filename ⇒ String
The server message log filename.
-
#get_target_list ⇒ Array<String>
Returns the list of all target names.
-
#get_tlm_details(item_array) ⇒ Array<Hash>
Returns an array of Hashes with all the attributes of the item.
-
#get_tlm_item_list(target_name, packet_name) ⇒ Array<String, Hash, String>
Returns the item names and their states and descriptions for a particular packet.
-
#get_tlm_list(target_name) ⇒ Array<String, String>
Returns the sorted packet names and their descriptions for a particular target.
-
#get_tlm_log_filename(packet_log_writer_name = 'DEFAULT') ⇒ String
The telemetry packet log filename.
-
#get_tlm_packet(target_name, packet_name, value_type = :CONVERTED) ⇒ Array<String, Object, Symbol|nil>
Returns all the values (along with their limits state) for a packet.
-
#get_tlm_values(item_array, value_types = :CONVERTED) ⇒ Array<String, Object, Array, Symbol|nil>
Returns all the item values (along with their limits state).
-
#initialize ⇒ Object
Sets api_requests to 0 and initializes the whitelist of allowable API method calls.
-
#interface_state(interface_name) ⇒ String
The state of the interface which is one of ‘CONNECTED’, ‘ATTEMPTING’ or ‘DISCONNECTED’.
-
#limits_enabled?(*args) ⇒ Boolean
Whether the limits are enabled for the given item.
-
#map_target_to_interface(target_name, interface_name) ⇒ Object
Associates a target and all its commands and telemetry with a particular interface.
-
#router_state(router_name) ⇒ String
The state of the router which is one of ‘CONNECTED’, ‘ATTEMPTING’ or ‘DISCONNECTED’.
-
#send_raw(interface_name, data) ⇒ Object
Send a raw binary string to the specified interface.
-
#set_limits(target_name, packet_name, item_name, red_low, yellow_low, yellow_high, red_high, green_low = nil, green_high = nil, limits_set = :CUSTOM, persistence = nil, enabled = true) ⇒ Array<limits_set, persistence, enabled, red_low, yellow_low, red_high, yellow_high, green_low (optional), green_high (optional)] Limits information
Set the limits for a telemetry item.
-
#set_limits_set(limits_set) ⇒ Object
Changes the active limits set that applies to all telemetry.
-
#set_tlm(*args) ⇒ Object
Set a telemetry item in a packet to a particular value and then verifies the value is within the acceptable limits.
-
#set_tlm_raw(*args) ⇒ Object
Set a telemetry item in a packet to a particular value and then verifies the value is within the acceptable limits.
-
#start_cmd_log(packet_log_writer_name = 'ALL', label = nil) ⇒ Object
Start command packet logging.
-
#start_logging(packet_log_writer_name = 'ALL', label = nil) ⇒ Object
Start both command and telemetry packet logging.
-
#start_new_server_message_log ⇒ Object
Starts a new server message log.
-
#start_raw_logging_interface(interface_name = 'ALL') ⇒ Object
Starts raw logging for an interface.
-
#start_raw_logging_router(router_name = 'ALL') ⇒ Object
Starts raw logging for a router.
-
#start_tlm_log(packet_log_writer_name = 'ALL', label = nil) ⇒ Object
Start telemetry packet logging.
-
#stop_cmd_log(packet_log_writer_name = 'ALL') ⇒ Object
Stop command packet logging.
-
#stop_logging(packet_log_writer_name = 'ALL') ⇒ Object
Stop both command and telemetry packet logging.
-
#stop_raw_logging_interface(interface_name = 'ALL') ⇒ Object
Stop raw logging for an interface.
-
#stop_raw_logging_router(router_name = 'ALL') ⇒ Object
Stops raw logging for a router.
-
#stop_tlm_log(packet_log_writer_name = 'ALL') ⇒ Object
Stop telemetry packet logging.
- #subscribe_limits_events(queue_size = CmdTlmServer::DEFAULT_LIMITS_EVENT_QUEUE_SIZE) ⇒ Object
- #subscribe_packet_data(packets, queue_size = CmdTlmServer::DEFAULT_PACKET_DATA_QUEUE_SIZE) ⇒ Object
-
#tlm(*args) ⇒ Numeric
Request a converted telemetry item from a packet.
-
#tlm_formatted(*args) ⇒ String
Request a formatted telemetry item from a packet.
-
#tlm_raw(*args) ⇒ Numeric
Request a raw telemetry item from a packet.
-
#tlm_variable(*args) ⇒ Object
Request a telemetry item from a packet with the specified conversion applied.
-
#tlm_with_units(*args) ⇒ String
Request a telemetry item with units from a packet.
- #unsubscribe_limits_events(id) ⇒ Object
- #unsubscribe_packet_data(id) ⇒ Object
Instance Method Details
#cmd(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target.
Accepts two different calling styles:
cmd("TGT CMD with PARAM1 val, PARAM2 val")
cmd('TGT','CMD','PARAM1'=>val,'PARAM2'=>val)
Favor the first syntax where possible as it is more succinct.
105 106 107 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 105 def cmd(*args) cmd_implementation(true, true, false, 'cmd', *args) end |
#cmd_no_checks(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without performing any value range checks or hazardous checks both on the command itself and its parameters.
Accepts two different calling styles:
cmd_no_checks("TGT CMD with PARAM1 val, PARAM2 val")
cmd_no_checks('TGT','CMD','PARAM1'=>val,'PARAM2'=>val)
Favor the first syntax where possible as it is more succinct.
152 153 154 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 152 def cmd_no_checks(*args) cmd_implementation(false, false, false, 'cmd_no_checks', *args) end |
#cmd_no_hazardous_check(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without performing any hazardous checks both on the command itself and its parameters. Useful in scripts to prevent popping up warnings to the user.
Accepts two different calling styles:
cmd_no_hazardous_check("TGT CMD with PARAM1 val, PARAM2 val")
cmd_no_hazardous_check('TGT','CMD','PARAM1'=>val,'PARAM2'=>val)
Favor the first syntax where possible as it is more succinct.
137 138 139 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 137 def cmd_no_hazardous_check(*args) cmd_implementation(true, false, false, 'cmd_no_hazardous_check', *args) end |
#cmd_no_range_check(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without performing any value range checks on the parameters. Useful for testing to allow sending command parameters outside the allowable range as defined in the configuration.
Accepts two different calling styles:
cmd_no_range_check("TGT CMD with PARAM1 val, PARAM2 val")
cmd_no_range_check('TGT','CMD','PARAM1'=>val,'PARAM2'=>val)
Favor the first syntax where possible as it is more succinct.
121 122 123 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 121 def cmd_no_range_check(*args) cmd_implementation(false, true, false, 'cmd_no_range_check', *args) end |
#cmd_raw(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without running conversions.
Accepts two different calling styles:
cmd_raw("TGT CMD with PARAM1 val, PARAM2 val")
cmd_raw('TGT','CMD','PARAM1'=>val,'PARAM2'=>val)
Favor the first syntax where possible as it is more succinct.
166 167 168 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 166 def cmd_raw(*args) cmd_implementation(true, true, true, 'cmd_raw', *args) end |
#cmd_raw_no_checks(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without running conversions or performing any value range checks or hazardous checks both on the command itself and its parameters.
Accepts two different calling styles:
cmd_raw_no_checks("TGT CMD with PARAM1 val, PARAM2 val")
cmd_raw_no_checks('TGT','CMD','PARAM1'=>val,'PARAM2'=>val)
Favor the first syntax where possible as it is more succinct.
213 214 215 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 213 def cmd_raw_no_checks(*args) cmd_implementation(false, false, true, 'cmd_raw_no_checks', *args) end |
#cmd_raw_no_hazardous_check(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without running conversions or performing any hazardous checks both on the command itself and its parameters. Useful in scripts to prevent popping up warnings to the user.
Accepts two different calling styles:
cmd_raw_no_hazardous_check("TGT CMD with PARAM1 val, PARAM2 val")
cmd_raw_no_hazardous_check('TGT','CMD','PARAM1'=>val,'PARAM2'=>val)
Favor the first syntax where possible as it is more succinct.
198 199 200 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 198 def cmd_raw_no_hazardous_check(*args) cmd_implementation(true, false, true, 'cmd_raw_no_hazardous_check', *args) end |
#cmd_raw_no_range_check(*args) ⇒ Array<String, String, Hash>
Send a command packet to a target without performing any value range checks on the parameters or running conversions. Useful for testing to allow sending command parameters outside the allowable range as defined in the configuration.
Accepts two different calling styles:
cmd_raw_no_range_check("TGT CMD with PARAM1 val, PARAM2 val")
cmd_raw_no_range_check('TGT','CMD','PARAM1'=>val,'PARAM2'=>val)
Favor the first syntax where possible as it is more succinct.
182 183 184 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 182 def cmd_raw_no_range_check(*args) cmd_implementation(false, true, true, 'cmd_raw_no_range_check', *args) end |
#connect_interface(interface_name, *params) ⇒ Object
Connects to an interface and starts its telemetry gathering thread. If optional parameters are given, the interface is recreated with new parameters.
662 663 664 665 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 662 def connect_interface(interface_name, *params) CmdTlmServer.interfaces.connect(interface_name, *params) nil end |
#connect_router(router_name, *params) ⇒ Object
Connects a router and starts its command gathering thread. If optional parameters are given, the router is recreated with new parameters.
704 705 706 707 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 704 def connect_router(router_name, *params) CmdTlmServer.routers.connect(router_name, *params) nil end |
#disable_limits(*args) ⇒ Object
Disable limit checking for a telemetry item
Accepts two different calling styles:
disable_limits("TGT PKT ITEM")
disable_limits('TGT','PKT','ITEM')
Favor the first syntax where possible as it is more succinct.
543 544 545 546 547 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 543 def disable_limits(*args) target_name, packet_name, item_name = tlm_process_args(args, 'disable_limits') System.limits.disable(target_name, packet_name, item_name) nil end |
#disable_limits_group(group_name) ⇒ Object
Disables limit checking for all the items in the given group.
577 578 579 580 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 577 def disable_limits_group(group_name) System.limits.disable_group(group_name) nil end |
#disconnect_interface(interface_name) ⇒ Object
Disconnects from an interface and kills its telemetry gathering thread
670 671 672 673 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 670 def disconnect_interface(interface_name) CmdTlmServer.interfaces.disconnect(interface_name) nil end |
#disconnect_router(router_name) ⇒ Object
Disconnects a router and kills its command gathering thread
712 713 714 715 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 712 def disconnect_router(router_name) CmdTlmServer.routers.disconnect(router_name) nil end |
#enable_limits(*args) ⇒ Object
Enable limits checking for a telemetry item
Accepts two different calling styles:
enable_limits("TGT PKT ITEM")
enable_limits('TGT','PKT','ITEM')
Favor the first syntax where possible as it is more succinct.
528 529 530 531 532 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 528 def enable_limits(*args) target_name, packet_name, item_name = tlm_process_args(args, 'enable_limits') System.limits.enable(target_name, packet_name, item_name) nil end |
#enable_limits_group(group_name) ⇒ Object
Enables limit checking for all the items in the given group.
571 572 573 574 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 571 def enable_limits_group(group_name) System.limits.enable_group(group_name) nil end |
#get_cmd_hazardous(target_name, command_name, params = {}) ⇒ Boolean
Returns whether the specified command is hazardous
271 272 273 274 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 271 def get_cmd_hazardous(target_name, command_name, params = {}) hazardous, _ = System.commands.cmd_hazardous?(target_name, command_name, params) return hazardous end |
#get_cmd_list(target_name) ⇒ Array<Array<String, String>>
Returns the list of all the command names and their descriptions from the given target.
232 233 234 235 236 237 238 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 232 def get_cmd_list(target_name) list = [] System.commands.packets(target_name).each do |name, command| list << [name, command.description] end return list.sort end |
#get_cmd_log_filename(packet_log_writer_name = 'DEFAULT') ⇒ String
Returns The command packet log filename.
727 728 729 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 727 def get_cmd_log_filename(packet_log_writer_name = 'DEFAULT') CmdTlmServer.packet_logging.cmd_filename(packet_log_writer_name) end |
#get_cmd_param_list(target_name, command_name) ⇒ Array<Array<String, Object, nil|Array, nil|String, nil|String, nil|String, Boolean>] Array containing \[name, default, states, description, units_full, units, required] for all parameters in the command
Returns the list of all the parameters for the given command.
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 248 def get_cmd_param_list(target_name, command_name) list = [] System.commands.params(target_name, command_name).each do |parameter| if parameter.format_string unless parameter.default.kind_of?(Array) list << [parameter.name, sprintf(parameter.format_string, parameter.default), parameter.states, parameter.description, parameter.units_full, parameter.units, parameter.required] else list << [parameter.name, "[]", parameter.states, parameter.description, parameter.units_full, parameter.units, parameter.required] end else list << [parameter.name, parameter.default, parameter.states, parameter.description, parameter.units_full, parameter.units, parameter.required] end end return list end |
#get_interface_names ⇒ Array<String>
Returns All the interface names.
652 653 654 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 652 def get_interface_names CmdTlmServer.interfaces.names end |
#get_limits(target_name, packet_name, item_name, limits_set = nil) ⇒ Array<limits_set, persistence, enabled, red_low, yellow_low, red_high, yellow_high, green_low (optional), green_high (optional)] Limits information
Get the limits for a telemetry item
550 551 552 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 550 def get_limits(target_name, packet_name, item_name, limits_set = nil) System.limits.get(target_name, packet_name, item_name, limits_set) end |
#get_limits_event(id, non_block = false) ⇒ Object
627 628 629 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 627 def get_limits_event(id, non_block = false) CmdTlmServer.get_limits_event(id, non_block) end |
#get_limits_groups ⇒ Hash(String, Array)
Returns The defined limits groups.
566 567 568 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 566 def get_limits_groups return System.limits.groups.keys end |
#get_limits_set ⇒ String
Returns the active limits set that applies to all telemetry
599 600 601 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 599 def get_limits_set return System.limits_set.to_s end |
#get_limits_sets ⇒ Array<Symbol>
Returns all defined limits sets
585 586 587 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 585 def get_limits_sets return System.limits.sets end |
#get_out_of_limits ⇒ Array<Array<String, String, String, Symbol>>
Return an array of arrays indicating all items in the packet that are out of limits
[[target name, packet name, item name, item limits state], ...]
495 496 497 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 495 def get_out_of_limits return System.limits.out_of_limits end |
#get_overall_limits_state(ignored_items = nil) ⇒ Symbol
Returns The overall limits state for the system.
500 501 502 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 500 def get_overall_limits_state (ignored_items = nil) return System.limits.overall_limits_state(ignored_items) end |
#get_packet_data(id, non_block = false) ⇒ Object
643 644 645 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 643 def get_packet_data(id, non_block = false) CmdTlmServer.get_packet_data(id, non_block) end |
#get_router_names ⇒ Array<String>
Returns All the router names.
694 695 696 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 694 def get_router_names CmdTlmServer.routers.names end |
#get_server_message_log_filename ⇒ String
Returns The server message log filename.
831 832 833 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 831 def CmdTlmServer..filename end |
#get_target_list ⇒ Array<String>
Returns the list of all target names
610 611 612 613 614 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 610 def get_target_list list = [] System.targets.each_key {|target_name| list << target_name } return list.sort end |
#get_tlm_details(item_array) ⇒ Array<Hash>
Returns an array of Hashes with all the attributes of the item.
482 483 484 485 486 487 488 489 490 491 492 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 482 def get_tlm_details(item_array) if !item_array.is_a?(Array) || !item_array[0].is_a?(Array) raise ArgumentError, "item_array must be nested array: [['TGT','PKT','ITEM'],...]" end details = [] item_array.each do |target_name, packet_name, item_name| _, item = System.telemetry.packet_and_item(target_name, packet_name, item_name) details << item.to_hash end details end |
#get_tlm_item_list(target_name, packet_name) ⇒ Array<String, Hash, String>
Returns the item names and their states and descriptions for a particular packet.
468 469 470 471 472 473 474 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 468 def get_tlm_item_list(target_name, packet_name) list = [] System.telemetry.items(target_name, packet_name).each do |item| list << [item.name, item.states, item.description] end list end |
#get_tlm_list(target_name) ⇒ Array<String, String>
Returns the sorted packet names and their descriptions for a particular target.
452 453 454 455 456 457 458 459 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 452 def get_tlm_list(target_name) list = [] packets = System.telemetry.packets(target_name) packets.each do |packet_name, packet| list << [packet_name, packet.description] end list.sort end |
#get_tlm_log_filename(packet_log_writer_name = 'DEFAULT') ⇒ String
Returns The telemetry packet log filename.
734 735 736 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 734 def get_tlm_log_filename(packet_log_writer_name = 'DEFAULT') CmdTlmServer.packet_logging.tlm_filename(packet_log_writer_name) end |
#get_tlm_packet(target_name, packet_name, value_type = :CONVERTED) ⇒ Array<String, Object, Symbol|nil>
Returns all the values (along with their limits state) for a packet.
413 414 415 416 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 413 def get_tlm_packet(target_name, packet_name, value_type = :CONVERTED) packet = System.telemetry.packet(target_name, packet_name) return packet.read_all_with_limits_states(value_type.to_s.intern) end |
#get_tlm_values(item_array, value_types = :CONVERTED) ⇒ Array<String, Object, Array, Symbol|nil>
Returns all the item values (along with their limits state). The items can be from any target and packet and thus must be fully qualified with their target and packet names.
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 426 def get_tlm_values(item_array, value_types = :CONVERTED) if !item_array.is_a?(Array) || (!item_array[0].is_a?(Array) and !item_array.empty?) raise ArgumentError, "item_array must be nested array: [['TGT','PKT','ITEM'],...]" end return [[], [], [], System.limits_set] if item_array.empty? if value_types.is_a?(Array) elem = value_types[0] else elem = value_types end # Due to JSON round tripping from scripts, value_types can be a String # so we must check for both Symbol and String if !elem.is_a?(Symbol) && !elem.is_a?(String) raise ArgumentError, "value_types must be a single symbol or array of symbols specifying the conversion method (:RAW, :CONVERTED, :FORMATTED, :WITH_UNITS)" end array = System.telemetry.values_and_limits_states(item_array, value_types) array << System.limits_set return array end |
#initialize ⇒ Object
Sets api_requests to 0 and initializes the whitelist of allowable API method calls
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 20 def initialize @api_whitelist = [ 'cmd', 'cmd_no_range_check', 'cmd_no_hazardous_check', 'cmd_no_checks', 'cmd_raw', 'cmd_raw_no_range_check', 'cmd_raw_no_hazardous_check', 'cmd_raw_no_checks', 'send_raw', 'get_cmd_list', 'get_cmd_param_list', 'get_cmd_hazardous', 'tlm', 'tlm_raw', 'tlm_formatted', 'tlm_with_units', 'tlm_variable', 'set_tlm', 'set_tlm_raw', 'get_tlm_packet', 'get_tlm_values', 'get_tlm_list', 'get_tlm_item_list', 'get_tlm_details', 'get_out_of_limits', 'get_overall_limits_state', 'limits_enabled?', 'enable_limits', 'disable_limits', 'get_limits', 'set_limits', 'get_limits_groups', 'enable_limits_group', 'disable_limits_group', 'get_limits_sets', 'set_limits_set', 'get_limits_set', 'get_target_list', 'subscribe_limits_events', 'unsubscribe_limits_events', 'get_limits_event', 'subscribe_packet_data', 'unsubscribe_packet_data', 'get_packet_data', 'get_interface_names', 'connect_interface', 'disconnect_interface', 'interface_state', 'map_target_to_interface', 'get_router_names', 'connect_router', 'disconnect_router', 'router_state', 'get_cmd_log_filename', 'get_tlm_log_filename', 'start_logging', 'stop_logging', 'start_cmd_log', 'start_tlm_log', 'stop_cmd_log', 'stop_tlm_log', 'start_raw_logging_interface', 'stop_raw_logging_interface', 'start_raw_logging_router', 'stop_raw_logging_router', 'get_server_message_log_filename', 'start_new_server_message_log'] end |
#interface_state(interface_name) ⇒ String
Returns The state of the interface which is one of ‘CONNECTED’, ‘ATTEMPTING’ or ‘DISCONNECTED’.
678 679 680 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 678 def interface_state(interface_name) CmdTlmServer.interfaces.state(interface_name) end |
#limits_enabled?(*args) ⇒ Boolean
Whether the limits are enabled for the given item
Accepts two different calling styles:
limits_enabled?("TGT PKT ITEM")
limits_enabled?('TGT','PKT','ITEM')
Favor the first syntax where possible as it is more succinct.
514 515 516 517 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 514 def limits_enabled?(*args) target_name, packet_name, item_name = tlm_process_args(args, 'limits_enabled?') return System.limits.enabled?(target_name, packet_name, item_name) end |
#map_target_to_interface(target_name, interface_name) ⇒ Object
Associates a target and all its commands and telemetry with a particular interface. All the commands will go out over and telemetry be received from that interface.
688 689 690 691 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 688 def map_target_to_interface(target_name, interface_name) CmdTlmServer.interfaces.map_target(target_name, interface_name) nil end |
#router_state(router_name) ⇒ String
Returns The state of the router which is one of ‘CONNECTED’, ‘ATTEMPTING’ or ‘DISCONNECTED’.
720 721 722 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 720 def router_state(router_name) CmdTlmServer.routers.state(router_name) end |
#send_raw(interface_name, data) ⇒ Object
Send a raw binary string to the specified interface.
221 222 223 224 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 221 def send_raw(interface_name, data) CmdTlmServer.commanding.send_raw(interface_name, data) nil end |
#set_limits(target_name, packet_name, item_name, red_low, yellow_low, yellow_high, red_high, green_low = nil, green_high = nil, limits_set = :CUSTOM, persistence = nil, enabled = true) ⇒ Array<limits_set, persistence, enabled, red_low, yellow_low, red_high, yellow_high, green_low (optional), green_high (optional)] Limits information
Set the limits for a telemetry item
555 556 557 558 559 560 561 562 563 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 555 def set_limits(target_name, packet_name, item_name, red_low, yellow_low, yellow_high, red_high, green_low = nil, green_high = nil, limits_set = :CUSTOM, persistence = nil, enabled = true) result = System.limits.set(target_name, packet_name, item_name, red_low, yellow_low, yellow_high, red_high, green_low, green_high, limits_set, persistence, enabled) if result[0] != nil limits_settings = [target_name, packet_name, item_name].concat(result) CmdTlmServer.instance.post_limits_event(:LIMITS_SETTINGS, limits_settings) Logger.info("Limits Settings Changed: #{limits_settings}") end result end |
#set_limits_set(limits_set) ⇒ Object
Changes the active limits set that applies to all telemetry
592 593 594 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 592 def set_limits_set(limits_set) System.limits_set = limits_set if System.limits_set != limits_set.to_s.upcase.intern end |
#set_tlm(*args) ⇒ Object
Set a telemetry item in a packet to a particular value and then verifies the value is within the acceptable limits. This method uses any conversions that apply to the item when setting the value.
Note: If this is done while COSMOS is currently receiving telemetry, this value could get overwritten at any time. Thus this capability is best used for testing or for telemetry items that are not received regularly through the target interface.
Accepts two different calling styles:
set_tlm("TGT PKT ITEM = 1.0")
set_tlm('TGT','PKT','ITEM', 10.0)
Favor the first syntax where possible as it is more succinct.
375 376 377 378 379 380 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 375 def set_tlm(*args) target_name, packet_name, item_name, value = set_tlm_process_args(args, 'set_tlm') System.telemetry.set_value(target_name, packet_name, item_name, value, :CONVERTED) System.telemetry.packet(target_name, packet_name).check_limits(System.limits_set, true) nil end |
#set_tlm_raw(*args) ⇒ Object
Set a telemetry item in a packet to a particular value and then verifies the value is within the acceptable limits. No conversions are applied.
Note: If this is done while COSMOS is currently receiving telemetry, this value could get overwritten at any time. Thus this capability is best used for testing or for telemetry items that are not received regularly through the target interface.
Accepts two different calling styles:
set_tlm_raw("TGT PKT ITEM = 1.0")
set_tlm_raw('TGT','PKT','ITEM', 10.0)
Favor the first syntax where possible as it is more succinct.
399 400 401 402 403 404 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 399 def set_tlm_raw(*args) target_name, packet_name, item_name, value = set_tlm_process_args(args, 'set_tlm_raw') System.telemetry.set_value(target_name, packet_name, item_name, value, :RAW) System.telemetry.packet(target_name, packet_name).check_limits(System.limits_set, true) nil end |
#start_cmd_log(packet_log_writer_name = 'ALL', label = nil) ⇒ Object
Start command packet logging.
764 765 766 767 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 764 def start_cmd_log(packet_log_writer_name = 'ALL', label = nil) CmdTlmServer.packet_logging.start_cmd(packet_log_writer_name, label) nil end |
#start_logging(packet_log_writer_name = 'ALL', label = nil) ⇒ Object
Start both command and telemetry packet logging.
744 745 746 747 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 744 def start_logging(packet_log_writer_name = 'ALL', label = nil) CmdTlmServer.packet_logging.start(packet_log_writer_name, label) nil end |
#start_new_server_message_log ⇒ Object
Starts a new server message log
836 837 838 839 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 836 def CmdTlmServer..start nil end |
#start_raw_logging_interface(interface_name = 'ALL') ⇒ Object
Starts raw logging for an interface
801 802 803 804 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 801 def start_raw_logging_interface(interface_name = 'ALL') CmdTlmServer.interfaces.start_raw_logging(interface_name) nil end |
#start_raw_logging_router(router_name = 'ALL') ⇒ Object
Starts raw logging for a router
817 818 819 820 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 817 def start_raw_logging_router(router_name = 'ALL') CmdTlmServer.routers.start_raw_logging(router_name) nil end |
#start_tlm_log(packet_log_writer_name = 'ALL', label = nil) ⇒ Object
Start telemetry packet logging.
775 776 777 778 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 775 def start_tlm_log(packet_log_writer_name = 'ALL', label = nil) CmdTlmServer.packet_logging.start_tlm(packet_log_writer_name, label) nil end |
#stop_cmd_log(packet_log_writer_name = 'ALL') ⇒ Object
Stop command packet logging.
784 785 786 787 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 784 def stop_cmd_log(packet_log_writer_name = 'ALL') CmdTlmServer.packet_logging.stop_cmd(packet_log_writer_name) nil end |
#stop_logging(packet_log_writer_name = 'ALL') ⇒ Object
Stop both command and telemetry packet logging.
753 754 755 756 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 753 def stop_logging(packet_log_writer_name = 'ALL') CmdTlmServer.packet_logging.stop(packet_log_writer_name) nil end |
#stop_raw_logging_interface(interface_name = 'ALL') ⇒ Object
Stop raw logging for an interface
809 810 811 812 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 809 def stop_raw_logging_interface(interface_name = 'ALL') CmdTlmServer.interfaces.stop_raw_logging(interface_name) nil end |
#stop_raw_logging_router(router_name = 'ALL') ⇒ Object
Stops raw logging for a router
825 826 827 828 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 825 def stop_raw_logging_router(router_name = 'ALL') CmdTlmServer.routers.stop_raw_logging(router_name) nil end |
#stop_tlm_log(packet_log_writer_name = 'ALL') ⇒ Object
Stop telemetry packet logging.
793 794 795 796 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 793 def stop_tlm_log(packet_log_writer_name = 'ALL') CmdTlmServer.packet_logging.stop_tlm(packet_log_writer_name) nil end |
#subscribe_limits_events(queue_size = CmdTlmServer::DEFAULT_LIMITS_EVENT_QUEUE_SIZE) ⇒ Object
617 618 619 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 617 def subscribe_limits_events(queue_size = CmdTlmServer::DEFAULT_LIMITS_EVENT_QUEUE_SIZE) CmdTlmServer.subscribe_limits_events(queue_size) end |
#subscribe_packet_data(packets, queue_size = CmdTlmServer::DEFAULT_PACKET_DATA_QUEUE_SIZE) ⇒ Object
632 633 634 635 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 632 def subscribe_packet_data(packets, queue_size = CmdTlmServer::DEFAULT_PACKET_DATA_QUEUE_SIZE) CmdTlmServer.subscribe_packet_data(packets, queue_size) end |
#tlm(*args) ⇒ Numeric
Request a converted telemetry item from a packet.
Accepts two different calling styles:
tlm("TGT PKT ITEM")
tlm('TGT','PKT','ITEM')
Favor the first syntax where possible as it is more succinct.
287 288 289 290 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 287 def tlm(*args) target_name, packet_name, item_name = tlm_process_args(args, 'tlm') System.telemetry.value(target_name, packet_name, item_name, :CONVERTED) end |
#tlm_formatted(*args) ⇒ String
Request a formatted telemetry item from a packet.
Accepts two different calling styles:
tlm_formatted("TGT PKT ITEM")
tlm_formatted('TGT','PKT','ITEM')
Favor the first syntax where possible as it is more succinct.
319 320 321 322 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 319 def tlm_formatted(*args) target_name, packet_name, item_name = tlm_process_args(args, 'tlm_formatted') System.telemetry.value(target_name, packet_name, item_name, :FORMATTED) end |
#tlm_raw(*args) ⇒ Numeric
Request a raw telemetry item from a packet.
Accepts two different calling styles:
tlm_raw("TGT PKT ITEM")
tlm_raw('TGT','PKT','ITEM')
Favor the first syntax where possible as it is more succinct.
303 304 305 306 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 303 def tlm_raw(*args) target_name, packet_name, item_name = tlm_process_args(args, 'tlm_raw') System.telemetry.value(target_name, packet_name, item_name, :RAW) end |
#tlm_variable(*args) ⇒ Object
Request a telemetry item from a packet with the specified conversion applied. This method is equivalent to calling the other tlm_xxx methods.
Accepts two different calling styles:
tlm_variable("TGT PKT ITEM", :RAW)
tlm_variable('TGT','PKT','ITEM', :RAW)
Favor the first syntax where possible as it is more succinct.
352 353 354 355 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 352 def tlm_variable(*args) target_name, packet_name, item_name, value_type = tlm_variable_process_args(args, 'tlm_variable') System.telemetry.value(target_name, packet_name, item_name, value_type) end |
#tlm_with_units(*args) ⇒ String
Request a telemetry item with units from a packet.
Accepts two different calling styles:
tlm_with_units("TGT PKT ITEM")
tlm_with_units('TGT','PKT','ITEM')
Favor the first syntax where possible as it is more succinct.
334 335 336 337 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 334 def tlm_with_units(*args) target_name, packet_name, item_name = tlm_process_args(args, 'tlm_with_units') System.telemetry.value(target_name, packet_name, item_name, :WITH_UNITS) end |
#unsubscribe_limits_events(id) ⇒ Object
622 623 624 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 622 def unsubscribe_limits_events(id) CmdTlmServer.unsubscribe_limits_events(id) end |
#unsubscribe_packet_data(id) ⇒ Object
638 639 640 |
# File 'lib/cosmos/tools/cmd_tlm_server/api.rb', line 638 def unsubscribe_packet_data(id) CmdTlmServer.unsubscribe_packet_data(id) end |