Skip to main content

Scripting API Guide

This document provides the information necessary to write test procedures using the COSMOS scripting API. Scripting in COSMOS is designed to be simple and intuitive. The code completion ability for command and telemetry mnemonics makes Script Runner the ideal place to write your procedures, however any text editor will do. If there is functionality that you don't see here or perhaps an easier syntax for doing something, please submit a ticket.

Concepts

Programming Languages

COSMOS scripting is implemented using either Ruby or Python. Ruby and Python are very similar scripting languages and in many cases the COSMOS APIs are identical between the two. This guide is written to support both with additional language specific information found in the Script Writing Guide.

Using Script Runner

Script Runner is a graphical application that provides the ideal environment for running and implementing your test procedures. The Script Runner tool is broken into 4 main sections. At the top of the tool is a menu bar that allows you to do such things as open and save files, perform a syntax check, and execute your script.

Next is a tool bar that displays the currently executing script and three buttons, "Start/Go", "Pause/Retry", and "Stop". The Start/Go button is used to start the script and continue past errors or waits. The Pause/Retry button will pause the executing script. If an error is encountered the Pause button changes to Retry to re-execute the errored line. Finally, the Stop button will stop the executing script at any time.

Third is the display of the actual script. While the script is not running, you may edit and compose scripts in this area. A handy code completion feature is provided that will list out the available commands or telemetry points as you are writing your script. Simply begin writing a cmd( or tlm( line to bring up code completion. This feature greatly reduces typos in command and telemetry mnemonics.

Finally, the bottom of the display is the log messages. All commands that are sent, errors that occur, and user print statements appear in this area.

Telemetry Types

There are four different ways that telemetry values can be retrieved in COSMOS. The following chart explains their differences.

Telemetry TypeDescription
RawRaw telemetry is exactly as it is in the telemetry packet before any conversions. All telemetry items will have a raw value except for Derived telemetry points which have no real location in a packet. Requesting raw telemetry on a derived item will return nil.
ConvertedConverted telemetry is raw telemetry that has gone through a conversion factor such as a state conversion or a polynomial conversion. If a telemetry item does not have a conversion defined, then converted telemetry will be the same as raw telemetry. This is the most common type of telemety used in scripts.
FormattedFormatted telemetry is converted telemetry that has gone through a printf style conversion into a string. Formatted telemetry will always have a string representation. If no format string is defined for a telemetry point, then formatted telemetry will be the same as converted telemetry except represented as string.
Formatted with UnitsFormatted with Units telemetry is the same as Formatted telemetry except that a space and the units of the telemetry item are appended to the end of the string. If no units are defined for a telemetry item then this type is the same as Formatted telemetry.

Script Runner API

The following methods are designed to be used in Script Runner procedures. Many can also be used in custom built COSMOS tools. Please see the COSMOS Tool API section for methods that are more efficient to use in custom tools.

Migration from COSMOS v4

The following API methods are either deprecated (will not be ported to COSMOS 5) or currently unimplemented (eventually will be ported to COSMOS 5):

MethodToolStatus
clearTelemetry ViewerDeprecated, use clear_screen
clear_allTelemetry ViewerDeprecated, use clear_all_screens
close_local_screensTelemetry ViewerDeprecated, use clear_screen
clear_disconnected_targetsScript RunnerDeprecated
cmd_tlm_clear_countersCommand and Telemetry ServerDeprecated
cmd_tlm_reloadCommand and Telemetry ServerDeprecated
displayTelemetry ViewerDeprecated, use display_screen
get_all_packet_logger_infoCommand and Telemetry ServerDeprecated
get_all_target_infoCommand and Telemetry ServerDeprecated, use get_target_interfaces
get_background_tasksCommand and Telemetry ServerDeprecated
get_all_cmd_infoCommand and Telemetry ServerDeprecated, use get_all_cmds
get_all_tlm_infoCommand and Telemetry ServerDeprecated, use get_all_tlm
get_cmd_listCommand and Telemetry ServerDeprecated, use get_all_cmds
get_cmd_log_filenameCommand and Telemetry ServerDeprecated
get_cmd_param_listCommand and Telemetry ServerDeprecated, use get_cmd
get_cmd_tlm_disconnectScript RunnerDeprecated, use $disconnect
get_disconnected_targetsScript RunnerUnimplemented
get_interface_infoCommand and Telemetry ServerDeprecated, use get_interface
get_interface_targetsCommand and Telemetry ServerDeprecated
get_output_logs_filenamesCommand and Telemetry ServerDeprecated
get_packetCommand and Telemetry ServerDeprecated, use get_packets
get_packet_dataCommand and Telemetry ServerDeprecated, use get_packets
get_packet_logger_infoCommand and Telemetry ServerDeprecated
get_packet_loggersCommand and Telemetry ServerDeprecated
get_replay_modeReplayDeprecated
get_router_infoCommand and Telemetry ServerDeprecated, use get_router
get_scriptrunner_message_log_filenameCommand and Telemetry ServerDeprecated
get_server_messageCommand and Telemetry ServerDeprecated
get_server_message_log_filenameCommand and Telemetry ServerDeprecated
get_server_statusCommand and Telemetry ServerDeprecated
get_staleCommand and Telemetry ServerDeprecated
get_target_ignored_itemsCommand and Telemetry ServerDeprecated, use get_target
get_target_ignored_parametersCommand and Telemetry ServerDeprecated, use get_target
get_target_infoCommand and Telemetry ServerDeprecated, use get_target
get_target_listCommand and Telemetry ServerDeprecated, use get_target_names
get_tlm_detailsCommand and Telemetry ServerDeprecated
get_tlm_item_listCommand and Telemetry ServerDeprecated
get_tlm_listCommand and Telemetry ServerDeprecated
get_tlm_log_filenameCommand and Telemetry ServerDeprecated
interface_stateCommand and Telemetry ServerDeprecated, use get_interface
override_tlm_rawCommand and Telemetry ServerDeprecated, use override_tlm
open_directory_dialogScript RunnerDeprecated
replay_move_endReplayDeprecated
replay_move_indexReplayDeprecated
replay_move_startReplayDeprecated
replay_playReplayDeprecated
replay_reverse_playReplayDeprecated
replay_select_fileReplayDeprecated
replay_set_playback_delayReplayDeprecated
replay_statusReplayDeprecated
replay_step_backReplayDeprecated
replay_step_forwardReplayDeprecated
replay_stopReplayDeprecated
require_utilityScript RunnerDeprecated but exists for backwards compatibility, use load_utility
router_stateCommand and Telemetry ServerDeprecated, use get_router
save_file_dialogScript RunnerDeprecated
save_settingCommand and Telemetry ServerDeprecated but exists for backwards compatibility, use set_setting
set_cmd_tlm_disconnectScript RunnerDeprecated, use disconnect_script
set_disconnected_targetsScript RunnerUnimplemented
set_replay_modeReplayDeprecated
set_stdout_max_linesScript RunnerDeprecated
set_tlm_rawScript RunnerDeprecated, use set_tlm
show_backtraceScript RunnerDeprecated, backtrace always shown
shutdown_cmd_tlmCommand and Telemetry ServerDeprecated
start_cmd_logCommand and Telemetry ServerDeprecated
start_loggingCommand and Telemetry ServerDeprecated
start_new_scriptrunner_message_logCommand and Telemetry ServerDeprecated
start_new_server_message_logCommand and Telemetry ServerDeprecated
start_tlm_logCommand and Telemetry ServerDeprecated
stop_background_taskCommand and Telemetry ServerDeprecated
stop_cmd_logCommand and Telemetry ServerDeprecated
stop_loggingCommand and Telemetry ServerDeprecated
stop_tlm_logCommand and Telemetry ServerDeprecated
subscribe_limits_eventsCommand and Telemetry ServerDeprecated
subscribe_packet_dataCommand and Telemetry ServerDeprecated, use subscribe_packets
subscribe_server_messagesCommand and Telemetry ServerUnimplemented
tlm_variableScript RunnerDeprecated, use tlm() and pass type
unsubscribe_limits_eventsCommand and Telemetry ServerDeprecated
unsubscribe_packet_dataCommand and Telemetry ServerDeprecated
unsubscribe_server_messagesCommand and Telemetry ServerDeprecated
wait_rawScript RunnerDeprecated, use wait(..., type: :RAW)
wait_check_rawScript RunnerDeprecated, use wait_check(..., type: :RAW)
wait_tolerance_rawScript RunnerDeprecated, use wait_tolerance(..., type: :RAW)
wait_check_tolerance_rawScript RunnerDeprecated, use wait_check_tolerance(..., type: :RAW)

Retrieving User Input

These methods allow the user to enter values that are needed by the script.

ask

Prompts the user for input with a question. User input is automatically converted from a string to the appropriate data type. For example if the user enters "1", the number 1 as an integer will be returned.

Ruby / Python Syntax:

ask("<question>", <blank_or_default>, <password>)
ParameterDescription
questionQuestion to prompt the user with.
blank_or_defaultWhether or not to allow empty responses (optional - defaults to false). If a non-boolean value is passed it is used as a default value.
passwordWhether to treat the entry as a password which is displayed with dots and not logged. Default is false.

Ruby Example:

value = ask("Enter an integer")
value = ask("Enter a value or nothing", true)
value = ask("Enter a value", 10)
password = ask("Enter your password", false, true)

Python Example:

value = ask("Enter an integer")
value = ask("Enter a value or nothing", True)
value = ask("Enter a value", 10)
password = ask("Enter your password", False, True)

ask_string

Prompts the user for input with a question. User input is always returned as a string. For exampe if the user enters "1", the string "1" will be returned.

Ruby / Python Syntax:

ask_string("<question>", <blank_or_default>, <password>)
ParameterDescription
questionQuestion to prompt the user with.
blank_or_defaultWhether or not to allow empty responses (optional - defaults to false). If a non-boolean value is passed it is used as a default value.
passwordWhether to treat the entry as a password which is displayed with dots and not logged. Default is false.

Ruby Example:

string = ask_string("Enter a String")
string = ask_string("Enter a value or nothing", true)
string = ask_string("Enter a value", "test")
password = ask_string("Enter your password", false, true)

Python Example:

string = ask_string("Enter a String")
string = ask_string("Enter a value or nothing", True)
string = ask_string("Enter a value", "test")
password = ask_string("Enter your password", False, True)

message_box

vertical_message_box

combo_box

The message_box, vertical_message_box, and combo_box methods create a message box with arbitrary buttons or selections that the user can click. The text of the button clicked is returned.

Ruby / Python Syntax:

message_box("<message>", "<button text 1>", ...)
vertical_message_box("<message>", "<button text 1>", ...)
combo_box("<message>", "<selection text 1>", ...)
ParameterDescription
messageMessage to prompt the user with.
button/selection textText for a button or selection

Ruby Example:

value = message_box("Select the sensor number", 'One', 'Two')
value = vertical_message_box("Select the sensor number", 'One', 'Two')
value = combo_box("Select the sensor number", 'One', 'Two')
case value
when 'One'
  puts 'Sensor One'
when 'Two'
  puts 'Sensor Two'
end

Python Example:

value = message_box("Select the sensor number", 'One', 'Two')
value = vertical_message_box("Select the sensor number", 'One', 'Two')
value = combo_box("Select the sensor number", 'One', 'Two')
match value:
    case 'One':
        print('Sensor One')
    case 'Two':
        print('Sensor Two')

get_target_file

Return a file handle to a file in the target directory

Ruby Syntax:

get_target_file("<File Path>", original: false)

Python Syntax:

get_target_file("<File Path>", original=False)
ParameterDescription
pathThe path to the file in the target directory. Should assume to start with a TARGET name, e.g. INST/procedures/proc.rb
originalWhether to get the original file from the plug-in, or any modifications to the file. Default is false which means to grab the modified file. If the modified file does not exist the API will automatically try to pull the original.

Ruby Example:

file = get_target_file("INST/data/attitude.bin")
puts file.read().formatted # format a binary file
file.unlink # delete file
file = get_target_file("INST/procedures/checks.rb", original: true)
puts file.read()
file.unlink # delete file

Python Example:

from openc3.utilities.string import formatted

file = get_target_file("INST/data/attitude.bin")
print(formatted(file.read())) # format a binary file
file.close() # delete file
file = get_target_file("INST/procedures/checks.rb", original=True)
print(file.read())
file.close() # delete file

put_target_file

Writes a file to the target directory

Ruby or Python Syntax:

put_target_file("<File Path>", "IO or String")
ParameterDescription
pathThe path to the file in the target directory. Should assume to start with a TARGET name, e.g. INST/procedures/proc.rb. The file can previously exist or not. Note: The original file from the plug-in will not be modified, however existing modified files will be overwritten.
dataThe data can be an IO object or String

Ruby Example:

put_target_file("INST/test1.txt", "this is a string test")
file = Tempfile.new('test')
file.write("this is a Io test")
file.rewind
put_target_file("INST/test2.txt", file)
put_target_file("INST/test3.bin", "\x00\x01\x02\x03\xFF\xEE\xDD\xCC") # binary

Python Example:

put_target_file("INST/test1.txt", "this is a string test")
file = tempfile.NamedTemporaryFile(mode="w+t")
file.write("this is a Io test")
file.seek(0)
put_target_file("INST/test2.txt", file)
put_target_file("INST/test3.bin", b"\x00\x01\x02\x03\xFF\xEE\xDD\xCC") # binary

delete_target_file

Delete a file in the target directory

Ruby / Python Syntax:

delete_target_file("<File Path>")
ParameterDescription
pathThe path to the file in the target directory. Should assume to start with a TARGET name, e.g. INST/procedures/proc.rb. Note: Only files created with put_target_file can be deleted. Original files from the plugin installation will remain.

Ruby / Python Example:

put_target_file("INST/delete_me.txt", "to be deleted")
delete_target_file("INST/delete_me.txt")

open_file_dialog

open_files_dialog

The open_file_dialog and open_files_dialog methods create a file dialog box so the user can select a single or multiple files. The selected file(s) is returned.

Note: COSMOS 5 has deprecated the save_file_dialog and open_directory_dialog methods. save_file_dialog can be replaced by put_target_file if you want to write a file back to the target. open_directory_dialog doesn't make sense in new architecture so you must request individual files.

Ruby Syntax:

open_file_dialog("<title>", "<message>", filter: "<filter>")
open_files_dialog("<title>", "<message>", filter: "<filter>")

Python Syntax:

open_file_dialog("<title>", "<message>", filter="<filter>")
open_files_dialog("<title>", "<message>", filter="<filter>")
ParameterDescription
TitleThe title to put on the dialog. Required.
MessageThe message to display in the dialog box. Optional parameter.
filterNamed parameter to filter allowed file types. Optional parameter, specified as comma delimited file types, e.g. ".txt,.doc". See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept for more information.

Ruby Example:

file = open_file_dialog("Open a single file", "Choose something interesting", filter: ".txt")
puts file # Ruby File object
puts file.read
file.delete

files = open_files_dialog("Open multiple files") # message is optional
puts files # Array of File objects (even if you select only one)
files.each do |file|
  puts file
  puts file.read
  file.delete
end

Python Example:

file = open_file_dialog("Open a single file", "Choose something interesting", filter=".txt")
print(file)
print(file.read())
file.close()

files = open_files_dialog("Open multiple files") # message is optional
print(files) # Array of File objects (even if you select only one)
for file in files:
    print(file)
    print(file.read())
    file.close()

Providing information to the user

These methods notify the user that something has occurred.

prompt

Displays a message to the user and waits for them to press an ok button.

Ruby / Python Syntax:

prompt("<message>")
ParameterDescription
messageMessage to prompt the user with.

Ruby / Python Example:

prompt("Press OK to continue")

Commands

These methods provide capability to send commands to a target and receive information about commands in the system.

cmd

Sends a specified command.

Ruby Syntax:

cmd("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd("<Target Name>", "<Command Name>", "Param #1 Name" => <Param #1 Value>, "Param #2 Name" => <Param #2 Value>, ...)

Python Syntax:

cmd("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd("<Target Name>", "<Command Name>", {"Param #1 Name": <Param #1 Value>, "Param #2 Name": <Param #2 Value>, ...})
ParameterDescription
Target NameName of the target this command is associated with.
Command NameName of this command. Also referred to as its mnemonic.
Param #x NameName of a command parameter. If there are no parameters then the 'with' keyword should not be given.
Param #x ValueValue of the command parameter. Values are automatically converted to the appropriate type.
timeoutOptional named parameter to change the default timeout value of 5 seconds
log_messageOptional named parameter to prevent logging of the command

Ruby Example:

cmd("INST COLLECT with DURATION 10, TYPE NORMAL")
# In Ruby the brackets around parameters are optional
cmd("INST", "COLLECT", "DURATION" => 10, "TYPE" => "NORMAL")
cmd("INST", "COLLECT", { "DURATION" => 10, "TYPE" => "NORMAL" })
cmd("INST ABORT", timeout: 10, log_message: false)

Python Example:

cmd("INST COLLECT with DURATION 10, TYPE NORMAL")
cmd("INST", "COLLECT", { "DURATION": 10, "TYPE": "NORMAL" })
cmd("INST ABORT", timeout=10, log_message=False)

cmd_no_range_check

Sends a specified command without performing range checking on its parameters. This should only be used when it is necessary to intentionally send a bad command parameter to test a target.

Ruby Syntax:

cmd_no_range_check("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_no_range_check("<Target Name>", "<Command Name>", "Param #1 Name" => <Param #1 Value>, "Param #2 Name" => <Param #2 Value>, ...)

Python Syntax:

cmd_no_range_check("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_no_range_check("<Target Name>", "<Command Name>", {"Param #1 Name": <Param #1 Value>, "Param #2 Name": <Param #2 Value>, ...})
ParameterDescription
Target NameName of the target this command is associated with.
Command NameName of this command. Also referred to as its mnemonic.
Param #x NameName of a command parameter. If there are no parameters then the 'with' keyword should not be given.
Param #x ValueValue of the command parameter. Values are automatically converted to the appropriate type.
timeoutOptional named parameter to change the default timeout value of 5 seconds
log_messageOptional named parameter to prevent logging of the command

Ruby Example:

cmd_no_range_check("INST COLLECT with DURATION 11, TYPE NORMAL")
cmd_no_range_check("INST", "COLLECT", "DURATION" => 11, "TYPE" => "NORMAL")

Python Example:

cmd_no_range_check("INST COLLECT with DURATION 11, TYPE NORMAL")
cmd_no_range_check("INST", "COLLECT", {"DURATION": 11, "TYPE": "NORMAL"})

cmd_no_hazardous_check

Sends a specified command without performing the notification if it is a hazardous command. This should only be used when it is necessary to fully automate testing involving hazardous commands.

Ruby Syntax:

cmd_no_hazardous_check("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_no_hazardous_check("<Target Name>", "<Command Name>", "Param #1 Name" => <Param #1 Value>, "Param #2 Name" => <Param #2 Value>, ...)

Python Syntax:

cmd_no_hazardous_check("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_no_hazardous_check("<Target Name>", "<Command Name>", {"Param #1 Name": <Param #1 Value>, "Param #2 Name": <Param #2 Value>, ...})
ParameterDescription
Target NameName of the target this command is associated with.
Command NameName of this command. Also referred to as its mnemonic.
Param #x NameName of a command parameter. If there are no parameters then the 'with' keyword should not be given.
Param #x ValueValue of the command parameter. Values are automatically converted to the appropriate type.
timeoutOptional named parameter to change the default timeout value of 5 seconds
log_messageOptional named parameter to prevent logging of the command

Ruby / Python Example:

cmd_no_hazardous_check("INST CLEAR")
cmd_no_hazardous_check("INST", "CLEAR")

cmd_no_checks

Sends a specified command without performing the parameter range checks or notification if it is a hazardous command. This should only be used when it is necessary to fully automate testing involving hazardous commands that intentially have invalid parameters.

Ruby Syntax:

cmd_no_checks("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_no_checks("<Target Name>", "<Command Name>", "Param #1 Name" => <Param #1 Value>, "Param #2 Name" => <Param #2 Value>, ...)

Python Syntax:

cmd_no_checks("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_no_checks("<Target Name>", "<Command Name>", {"Param #1 Name": <Param #1 Value>, "Param #2 Name": <Param #2 Value>, ...})
ParameterDescription
Target NameName of the target this command is associated with.
Command NameName of this command. Also referred to as its mnemonic.
Param #x NameName of a command parameter. If there are no parameters then the 'with' keyword should not be given.
Param #x ValueValue of the command parameter. Values are automatically converted to the appropriate type.
timeoutOptional named parameter to change the default timeout value of 5 seconds
log_messageOptional named parameter to prevent logging of the command

Ruby Example:

cmd_no_checks("INST COLLECT with DURATION 11, TYPE SPECIAL")
cmd_no_checks("INST", "COLLECT", "DURATION" => 11, "TYPE" => "SPECIAL")

Python Example:

cmd_no_checks("INST COLLECT with DURATION 11, TYPE SPECIAL")
cmd_no_checks("INST", "COLLECT", {"DURATION": 11, "TYPE": "SPECIAL"})

cmd_raw

Sends a specified command without running conversions.

Ruby Syntax:

cmd_raw("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_raw("<Target Name>", "<Command Name>", "<Param #1 Name>" => <Param #1 Value>, "<Param #2 Name>" => <Param #2 Value>, ...)

Python Syntax:

cmd_raw("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_raw("<Target Name>", "<Command Name>", {"<Param #1 Name>": <Param #1 Value>, "<Param #2 Name>": <Param #2 Value>, ...})
ParameterDescription
Target NameName of the target this command is associated with.
Command NameName of this command. Also referred to as its mnemonic.
Param #x NameName of a command parameter. If there are no parameters then the 'with' keyword should not be given.
Param #x ValueValue of the command parameter. Values are automatically converted to the appropriate type.
timeoutOptional named parameter to change the default timeout value of 5 seconds
log_messageOptional named parameter to prevent logging of the command

Ruby Example:

cmd_raw("INST COLLECT with DURATION 10, TYPE 0")
cmd_raw("INST", "COLLECT", "DURATION" => 10, "TYPE" => 0)

Python Example:

cmd_raw("INST COLLECT with DURATION 10, TYPE 0")
cmd_raw("INST", "COLLECT", {"DURATION": 10, "TYPE": 0})

cmd_raw_no_range_check

Sends a specified command without running conversions or performing range checking on its parameters. This should only be used when it is necessary to intentionally send a bad command parameter to test a target.

Ruby Syntax:

cmd_raw_no_range_check("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_raw_no_range_check("<Target Name>", "<Command Name>", "<Param #1 Name>" => <Param #1 Value>, "<Param #2 Name>" => <Param #2 Value>, ...)

Python Syntax:

cmd_raw_no_range_check("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_raw_no_range_check("<Target Name>", "<Command Name>", {"<Param #1 Name>": <Param #1 Value>, "<Param #2 Name>": <Param #2 Value>, ...})
ParameterDescription
Target NameName of the target this command is associated with.
Command NameName of this command. Also referred to as its mnemonic.
Param #x NameName of a command parameter. If there are no parameters then the 'with' keyword should not be given.
Param #x ValueValue of the command parameter. Values are automatically converted to the appropriate type.
timeoutOptional named parameter to change the default timeout value of 5 seconds
log_messageOptional named parameter to prevent logging of the command

Ruby Example:

cmd_raw_no_range_check("INST COLLECT with DURATION 11, TYPE 0")
cmd_raw_no_range_check("INST", "COLLECT", "DURATION" => 11, "TYPE" => 0)

Python Example:

cmd_raw_no_range_check("INST COLLECT with DURATION 11, TYPE 0")
cmd_raw_no_range_check("INST", "COLLECT", {"DURATION": 11, "TYPE": 0})

cmd_raw_no_hazardous_check

Sends a specified command without running conversions or performing the notification if it is a hazardous command. This should only be used when it is necessary to fully automate testing involving hazardous commands.

Ruby Syntax:

cmd_raw_no_hazardous_check("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_raw_no_hazardous_check("<Target Name>", "<Command Name>", "<Param #1 Name>" => <Param #1 Value>, "<Param #2 Name>" => <Param #2 Value>, ...)

Python Syntax:

cmd_raw_no_hazardous_check("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_raw_no_hazardous_check("<Target Name>", "<Command Name>", {"<Param #1 Name>": <Param #1 Value>, "<Param #2 Name>": <Param #2 Value>, ...})
ParameterDescription
Target NameName of the target this command is associated with.
Command NameName of this command. Also referred to as its mnemonic.
Param #x NameName of a command parameter. If there are no parameters then the 'with' keyword should not be given.
Param #x ValueValue of the command parameter. Values are automatically converted to the appropriate type.
timeoutOptional named parameter to change the default timeout value of 5 seconds
log_messageOptional named parameter to prevent logging of the command

Ruby / Python Example:

cmd_raw_no_hazardous_check("INST CLEAR")
cmd_raw_no_hazardous_check("INST", "CLEAR")

cmd_raw_no_checks

Sends a specified command without running conversions or performing the parameter range checks or notification if it is a hazardous command. This should only be used when it is necessary to fully automate testing involving hazardous commands that intentially have invalid parameters.

Ruby Syntax:

cmd_raw_no_checks("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_raw_no_checks("<Target Name>", "<Command Name>", "<Param #1 Name>" => <Param #1 Value>, "<Param #2 Name>" => <Param #2 Value>, ...)

Python Syntax:

cmd_raw_no_checks("<Target Name> <Command Name> with <Param #1 Name> <Param #1 Value>, <Param #2 Name> <Param #2 Value>, ...")
cmd_raw_no_checks("<Target Name>", "<Command Name>", {"<Param #1 Name>": <Param #1 Value>, "<Param #2 Name>": <Param #2 Value>, ...})
ParameterDescription
Target NameName of the target this command is associated with.
Command NameName of this command. Also referred to as its mnemonic.
Param #x NameName of a command parameter. If there are no parameters then the 'with' keyword should not be given.
Param #x ValueValue of the command parameter. Values are automatically converted to the appropriate type.
timeoutOptional named parameter to change the default timeout value of 5 seconds
log_messageOptional named parameter to prevent logging of the command

Ruby Example:

cmd_raw_no_checks("INST COLLECT with DURATION 11, TYPE 1")
cmd_raw_no_checks("INST", "COLLECT", "DURATION" => 11, "TYPE" => 1)

Python Example:

cmd_raw_no_checks("INST COLLECT with DURATION 11, TYPE 1")
cmd_raw_no_checks("INST", "COLLECT", {"DURATION": 11, "TYPE": 1})

build_cmd (since 5.13.0, since 5.8.0 as build_command)

Builds a command binary string

Ruby Syntax:

build_cmd(<ARGS>, range_check: true, raw: false)

Python Syntax:

build_cmd(<ARGS>, range_check=True, raw=False)
ParameterDescription
ARGSCommand parameters (see cmd)
range_checkWhether to perform range checking on the command. Default is true.
rawWhether to write the command arguments as RAW or CONVERTED value. Default is CONVERTED.

Ruby Example:

x = build_cmd("INST COLLECT with DURATION 10, TYPE NORMAL")
puts x  #=> {"id"=>"1696437370872-0", "result"=>"SUCCESS", "time"=>"1696437370872305961", "received_time"=>"1696437370872305961", "target_name"=>"INST", "packet_name"=>"COLLECT", "received_count"=>"3", "buffer"=>"\x13\xE7\xC0\x00\x00\f\x00\x01\x00\x00A \x00\x00\xAB\x00\x00\x00\x00"}

Python Example:

x = build_cmd("INST COLLECT with DURATION 10, TYPE NORMAL")
print(x)  #=> {'id': '1697298167748-0', 'result': 'SUCCESS', 'time': '1697298167749155717', 'received_time': '1697298167749155717', 'target_name': 'INST', 'packet_name': 'COLLECT', 'received_count': '2', 'buffer': bytearray(b'\x13\xe7\xc0\x00\x00\x0c\x00\x01\x00\x00A \x00\x00\xab\x00\x00\x00\x00')}

send_raw

Sends raw data on an interface.

Ruby / Python Syntax:

send_raw(<Interface Name>, <Data>)
ParameterDescription
Interface NameName of the interface to send the raw data on.
DataRaw ruby string of data to send.

Ruby / Python Example:

send_raw("INST_INT", data)

get_all_cmds (since 5.13.0, since 5.0.0 as get_all_commands)

Returns an array of the commands that are available for a particular target. The returned array is an array of hashes which fully describe the command packet.

Ruby / Python Syntax:

get_all_cmds("<Target Name>")
ParameterDescription
Target NameName of the target.

Ruby Example:

cmd_list = get_all_cmds("INST")
puts cmd_list  #=>
# [{"target_name"=>"INST",
#   "packet_name"=>"ABORT",
#   "endianness"=>"BIG_ENDIAN",
#   "description"=>"Aborts a collect on the instrument",
#   "items"=> [{"name"=>"CCSDSVER", "bit_offset"=>0, "bit_size"=>3, ... }]
# ...
# }]

Python Example:

cmd_list = get_all_cmds("INST")
print(cmd_list)  #=>
# [{'target_name': 'INST',
#   'packet_name': 'ABORT',
#   'endianness': 'BIG_ENDIAN',
#   'description': 'Aborts a collect on the INST instrument',
#   'items': [{'name': 'CCSDSVER', 'bit_offset': 0, 'bit_size': 3, ... }]
# ...
# }]

get_all_cmd_names (since 5.13.0, since 5.0.6 as get_all_command_names)

Returns an array of the command names for a particular target.

Ruby / Python Syntax:

get_all_cmd_names("<Target Name>")
ParameterDescription
Target NameName of the target

Ruby Example:

cmd_list = get_all_cmd_names("INST")
puts cmd_list  #=> ['ABORT', 'ARYCMD', 'ASCIICMD', ...]

Python Example:

cmd_list = get_all_cmd_names("INST")
print(cmd_list)  #=> ['ABORT', 'ARYCMD', 'ASCIICMD', ...]

get_cmd (since 5.13.0, since 5.0.0 as get_command)

Returns a command hash which fully describes the command packet.

Ruby / Python Syntax:

get_cmd("<Target Name> <Packet Name>")
get_cmd("<Target Name>", "<Packet Name>")
ParameterDescription
Target NameName of the target.
Packet NameName of the packet.

Ruby / Python Example:

abort_cmd = get_cmd("INST ABORT")
puts abort_cmd  #=>
# [{"target_name"=>"INST",
#   "packet_name"=>"ABORT",
#   "endianness"=>"BIG_ENDIAN",
#   "description"=>"Aborts a collect on the instrument",
#   "items"=> [{"name"=>"CCSDSVER", "bit_offset"=>0, "bit_size"=>3, ... }]
# ...
# }]

Python Example:

abort_cmd = get_cmd("INST ABORT")
print(abort_cmd)  #=>
# [{'target_name': 'INST',
#   'packet_name': 'ABORT',
#   'endianness': 'BIG_ENDIAN',
#   'description': 'Aborts a collect on the INST instrument',
#   'items': [{'name': 'CCSDSVER', 'bit_offset': 0, 'bit_size': 3, ... }]
# ...
# }]

get_param (since 5.13.0, since 5.0.0 as get_parameter)

Returns a hash of the given command parameter

Ruby / Python Syntax:

get_param("<Target Name> <Command Name> <Parameter Name>")
get_param("<Target Name>", "<Command Name>", "<Parameter Name>")
ParameterDescription
Target NameName of the target.
Command NameName of the command.
Parameter NameName of the parameter.

Ruby Example:

param = get_param("INST COLLECT TYPE")
puts param  #=>
# {"name"=>"TYPE", "bit_offset"=>64, "bit_size"=>16, "data_type"=>"UINT",
#  "description"=>"Collect type which can be normal or special", "default"=>0,
#  "minimum"=>0, "maximum"=>65535, "endianness"=>"BIG_ENDIAN", "required"=>true, "overflow"=>"ERROR",
#  "states"=>{"NORMAL"=>{"value"=>0}, "SPECIAL"=>{"value"=>1, "hazardous"=>""}}, "limits"=>{}}

Python Example:

param = get_param("INST COLLECT TYPE")
print(param)  #=>
# {'name': 'TYPE', 'bit_offset': 64, 'bit_size': 16, 'data_type': 'UINT',
#  'description': 'Collect type which can be normal or special', 'default': 0,
#  'minimum': 0, 'maximum': 65535, 'endianness': 'BIG_ENDIAN', 'required': True, 'overflow': 'ERROR',
#  'states': {'NORMAL': {'value': 0}, 'SPECIAL': {'value': 1, 'hazardous': ''}}, 'limits': {}}

get_cmd_buffer

Returns a packet hash (similar to get_cmd) along with the raw packet buffer as a Ruby string.

Ruby / Python Syntax:

buffer = get_cmd_buffer("<Target Name> <Packet Name>")['buffer']
buffer = get_cmd_buffer("<Target Name>", "<Packet Name>")['buffer']
ParameterDescription
Target NameName of the target.
Packet NameName of the packet.

Ruby Example:

packet = get_cmd_buffer("INST COLLECT")
puts packet  #=>
# {"time"=>"1697298846752053420", "received_time"=>"1697298846752053420",
#  "target_name"=>"INST", "packet_name"=>"COLLECT", "received_count"=>"20", "stored"=>"false",
#  "buffer"=>"\x13\xE7\xC0\x00\x00\f\x00\x01\x00\x00@\xE0\x00\x00\xAB\x00\x00\x00\x00"}

Python Example:

packet = get_cmd_buffer("INST COLLECT")
print(packet)  #=>
# {'time': '1697298923745982470', 'received_time': '1697298923745982470',
#  'target_name': 'INST', 'packet_name': 'COLLECT', 'received_count': '21', 'stored': 'false',
#  'buffer': bytearray(b'\x13\xe7\xc0\x00\x00\x0c\x00\x01\x00\x00@\xe0\x00\x00\xab\x00\x00\x00\x00')}

get_cmd_hazardous

Returns true/false indicating whether a particular command is flagged as hazardous.

Ruby / Python Syntax:

get_cmd_hazardous("<Target Name>", "<Command Name>", <Command Params - optional>)
ParameterDescription
Target NameName of the target.
Command NameName of the command.
Command ParamsHash of the parameters given to the command (optional). Note that some commands are only hazardous based on parameter states.

Ruby Example:

hazardous = get_cmd_hazardous("INST", "COLLECT", {'TYPE' => 'SPECIAL'})
puts hazardous  #=> true

Python Example:

hazardous = get_cmd_hazardous("INST", "COLLECT", {'TYPE': 'SPECIAL'})
print(hazardous) #=> True

get_cmd_value

Returns reads a value from the most recently sent command packet. The pseudo-parameters 'PACKET_TIMESECONDS', 'PACKET_TIMEFORMATTED', 'RECEIVED_COUNT', 'RECEIVED_TIMEFORMATTED', and 'RECEIVED_TIMESECONDS' are also supported.

Ruby / Python Syntax:

get_cmd_value("<Target Name>", "<Command Name>", "<Parameter Name>", <Value Type - optional>)
ParameterDescription
Target NameName of the target.
Command NameName of the command.
Parameter NameName of the command parameter.
Value TypeValue Type to read. RAW, CONVERTED, FORMATTED, or WITH_UNITS. NOTE: Symbol in Ruby and str in Python

Ruby Example:

value = get_cmd_value("INST", "COLLECT", "TEMP", :RAW)
puts value  #=> 0.0

Python Example:

value = get_cmd_value("INST", "COLLECT", "TEMP", "RAW")
print(value)  #=> 0.0

get_cmd_time

Returns the time of the most recent command sent.

Ruby / Python Syntax:

get_cmd_time("<Target Name - optional>", "<Command Name - optional>")
ParameterDescription
Target NameName of the target. If not given, then the most recent command time to any target will be returned
Command NameName of the command. If not given, then the most recent command time to the given target will be returned

Ruby / Python Example:

target_name, command_name, time = get_cmd_time() # Name of the most recent command sent to any target and time
target_name, command_name, time = get_cmd_time("INST") # Name of the most recent command sent to the INST target and time
target_name, command_name, time = get_cmd_time("INST", "COLLECT") # Name of the most recent INST COLLECT command and time

get_cmd_cnt

Returns the number of times a specified command has been sent.

Ruby / Python Syntax:

get_cmd_cnt("<Target Name> <Command Name>")
get_cmd_cnt("<Target Name>", "<Command Name>")
ParameterDescription
Target NameName of the target.
Command NameName of the command.

Ruby / Python Example:

cmd_cnt = get_cmd_cnt("INST COLLECT") # Number of times the INST COLLECT command has been sent

Handling Telemetry

These methods allow the user to interact with telemetry items.

check, check_raw, check_formatted, check_with_units

Performs a verification of a telemetry item using its specified telemetry type. If the verification fails then the script will be paused with an error. If no comparision is given to check then the telemetry item is simply printed to the script output. Note: In most cases using wait_check is a better choice than using check.

Ruby / Python Syntax:

check("<Target Name> <Packet Name> <Item Name> <Comparison - optional>")
ParameterDescription
Target NameName of the target of the telemetry item.
Packet NameName of the telemetry packet of the telemetry item.
Item NameName of the telemetry item.
ComparisonA comparison to perform against the telemetry item. If a comparison is not given then the telemetry item will just be printed into the script log.

Ruby Example:

check("INST HEALTH_STATUS COLLECTS > 1")
check_raw("INST HEALTH_STATUS COLLECTS > 1")
check_formatted("INST HEALTH_STATUS COLLECTS > 1")
check_with_units("INST HEALTH_STATUS COLLECTS > 1")
# Ruby passes type as symbol
check("INST HEALTH_STATUS COLLECTS > 1", type: :RAW)

Python Example:

check("INST HEALTH_STATUS COLLECTS > 1")
check_raw("INST HEALTH_STATUS COLLECTS > 1")
check_formatted("INST HEALTH_STATUS COLLECTS > 1")
check_with_units("INST HEALTH_STATUS COLLECTS > 1")
# Python passes type as string
check("INST HEALTH_STATUS COLLECTS > 1", type='RAW')

check_tolerance

Checks a converted telemetry item against an expected value with a tolerance. If the verification fails then the script will be paused with an error. Note: In most cases using wait_check_tolerance is a better choice than using check_tolerance.

Ruby / Python Syntax:

check_tolerance("<Target Name> <Packet Name> <Item Name>", <Expected Value>, <Tolerance>)
ParameterDescription
Target NameName of the target of the telemetry item.
Packet NameName of the telemetry packet of the telemetry item.
Item NameName of the telemetry item.
Expected ValueExpected value of the telemetry item.
Tolerance± Tolerance on the expected value.
typeCONVERTED (default) or RAW (Ruby symbol, Python string)

Ruby Example:

check_tolerance("INST HEALTH_STATUS COLLECTS", 10.0, 5.0)
check_tolerance("INST HEALTH_STATUS TEMP1", 50000, 20000, type: :RAW)

Python Example:

check_tolerance("INST HEALTH_STATUS COLLECTS", 10.0, 5.0)
check_tolerance("INST HEALTH_STATUS TEMP1", 50000, 20000, type='RAW')

check_expression

Evaluates an expression. If the expression evaluates to false the script will be paused with an error. This method can be used to perform more complicated comparisons than using check as shown in the example. Note: In most cases using wait_check_expression is a better choice than using check_expression.

Remember that everything inside the check_expression string will be evaluated directly and thus must be valid syntax. A common mistake is to check a variable like so (Ruby variable interpolation):

check_expression("#{answer} == 'yes'") # where answer contains 'yes'

This evaluates to yes == 'yes' which is not valid syntax because the variable yes is not defined (usually). The correct way to write this expression is as follows:

check_expression("'#{answer}' == 'yes'") # where answer contains 'yes'

Now this evaluates to 'yes' == 'yes' which is true so the check passes.

Ruby / Python Syntax:

check_expression("<Expression>")
ParameterDescription
ExpressionAn expression to evaluate.

Ruby / Python Example:

check_expression("tlm('INST HEALTH_STATUS COLLECTS') > 5 and tlm('INST HEALTH_STATUS TEMP1') > 25.0")

check_exception

Executes a method and expects an exception to be raised. If the method does not raise an exception, a CheckError is raised.

Ruby / Python Syntax:

check_exception("<Method Name>", "<Method Params - optional>")
ParameterDescription
Method NameThe COSMOS scripting method to execute, e.g. 'cmd', etc.
Method ParamsParameters for the method

Ruby Example:

check_exception("cmd", "INST", "COLLECT", "TYPE" => "NORMAL")

Python Example:

check_exception("cmd", "INST", "COLLECT", {"TYPE": "NORMAL"})

tlm, tlm_raw, tlm_formatted, tlm_with_units

Reads the specified form of a telemetry item.

Ruby / Python Syntax:

tlm("<Target Name> <Packet Name> <Item Name>")
tlm("<Target Name>", "<Packet Name>", "<Item Name>")
ParameterDescription
Target NameName of the target of the telemetry item.
Packet NameName of the telemetry packet of the telemetry item.
Item NameName of the telemetry item.
typeNamed parameter specifying the type. RAW, CONVERTED (default), FORMATTED, WITH_UNITS (Ruby symbol, Python string).

Ruby Example:

value = tlm("INST HEALTH_STATUS COLLECTS")
value = tlm("INST", "HEALTH_STATUS", "COLLECTS")
value = tlm_raw("INST HEALTH_STATUS COLLECTS")
value = tlm_formatted("INST HEALTH_STATUS COLLECTS")
value = tlm_with_units("INST HEALTH_STATUS COLLECTS")
# Equivalent to tlm_raw
raw_value = tlm("INST HEALTH_STATUS COLLECTS", type: :RAW)

Python Example:

value = tlm("INST HEALTH_STATUS COLLECTS")
value = tlm("INST", "HEALTH_STATUS", "COLLECTS")
value = tlm_raw("INST HEALTH_STATUS COLLECTS")
value = tlm_formatted("INST HEALTH_STATUS COLLECTS")
value = tlm_with_units("INST HEALTH_STATUS COLLECTS")
# Equivalent to tlm_raw
raw_value = tlm("INST HEALTH_STATUS COLLECTS", type='RAW')

get_tlm_buffer

Returns a packet hash (similar to get_tlm) along with the raw packet buffer.

Ruby / Python Syntax:

buffer = get_tlm_buffer("<Target Name> <Packet Name>")['buffer']
buffer = get_tlm_buffer("<Target Name>", "<Packet Name>")['buffer']
ParameterDescription
Target NameName of the target.
Packet NameName of the packet.

Ruby / Python Example:

packet = get_tlm_buffer("INST HEALTH_STATUS")
packet['buffer']

get_tlm_packet

Returns the names, values, and limits states of all telemetry items in a specified packet. The value is returned as an array of arrays with each entry containing [item_name, item_value, limits_state].

Ruby / Python Syntax:

get_tlm_packet("<Target Name> <Packet Name>", <type>)
get_tlm_packet("<Target Name>", "<Packet Name>", <type>)
ParameterDescription
Target NameName of the target.
Packet NameName of the packet.
typeNamed parameter specifying the type. RAW, CONVERTED (default), FORMATTED, or WITH_UNITS (Ruby symbol, Python string).

Ruby Example:

names_values_and_limits_states = get_tlm_packet("INST HEALTH_STATUS", type: :FORMATTED)

Python Example:

names_values_and_limits_states = get_tlm_packet("INST HEALTH_STATUS", type='FORMATTED')

get_tlm_values (modified in 5.0.0)

Returns the values and current limits state for a specified set of telemetry items. Items can be in any telemetry packet in the system. They can all be retrieved using the same value type or a specific value type can be specified for each item.

Ruby / Python Syntax:

values, limits_states, limits_settings, limits_set = get_tlm_values(<Items>)
ParameterDescription
ItemsArray of strings of the form ['TGT__PKT__ITEM__TYPE', ... ]

Ruby / Python Example:

values = get_tlm_values(["INST__HEALTH_STATUS__TEMP1__CONVERTED", "INST__HEALTH_STATUS__TEMP2__RAW"])
print(values) # [[-100.0, :RED_LOW], [0, :RED_LOW]]

get_all_tlm (since 5.13.0, since 5.0.0 as get_all_telemetry)

Returns an array of all target packet hashes.

Ruby / Python Syntax:

get_all_tlm("<Target Name>")
ParameterDescription
Target NameName of the target.

Ruby / Python Example:

packets = get_all_tlm("INST")
print(packets)
#[{"target_name"=>"INST",
#  "packet_name"=>"ADCS",
#  "endianness"=>"BIG_ENDIAN",
#  "description"=>"Position and attitude data",
#  "stale"=>true,
#  "items"=>
#   [{"name"=>"CCSDSVER",
#     "bit_offset"=>0,
#     "bit_size"=>3,
#     ...

get_all_tlm_names (since 5.13.0, since 5.0.6 as get_all_telemetry_names)

Returns an array of all target packet names.

Ruby / Python Syntax:

get_all_tlm_names("<Target Name>")
ParameterDescription
Target NameName of the target

Ruby / Python Example:

get_all_tlm_names("INST")  #=> ["ADCS", "HEALTH_STATUS", ...]

get_tlm (since 5.13.0, since 5.0.0 as get_telemetry)

Returns a packet hash.

Ruby / Python Syntax:

get_tlm("<Target Name> <Packet Name>")
get_tlm("<Target Name>", "<Packet Name>")
ParameterDescription
Target NameName of the target.
Packet NameName of the packet.

Ruby / Python Example:

packet = get_tlm("INST HEALTH_STATUS")
print(packet)
#{"target_name"=>"INST",
# "packet_name"=>"HEALTH_STATUS",
# "endianness"=>"BIG_ENDIAN",
# "description"=>"Health and status from the instrument",
# "stale"=>true,
# "processors"=>
#  [{"name"=>"TEMP1STAT",
#    "class"=>"OpenC3::StatisticsProcessor",
#    "params"=>["TEMP1", 100, "CONVERTED"]},
#   {"name"=>"TEMP1WATER",
#    "class"=>"OpenC3::WatermarkProcessor",
#    "params"=>["TEMP1", "CONVERTED"]}],
# "items"=>
#  [{"name"=>"CCSDSVER",
#    "bit_offset"=>0,
#    "bit_size"=>3,
#    ...

get_item (since 5.0.0)

Returns an item hash.

Ruby / Python Syntax:

get_item("<Target Name> <Packet Name> <Item Name>")
get_item("<Target Name>", "<Packet Name>", "<Item Name>")
ParameterDescription
Target NameName of the target.
Packet NameName of the packet.
Item NameName of the item.

Ruby / Python Example:

item = get_item("INST HEALTH_STATUS CCSDSVER")
print(item)
#{"name"=>"CCSDSVER",
# "bit_offset"=>0,
# "bit_size"=>3,
# "data_type"=>"UINT",
# "description"=>"CCSDS packet version number (See CCSDS 133.0-B-1)",
# "endianness"=>"BIG_ENDIAN",
# "required"=>false,
# "overflow"=>"ERROR"}

get_tlm_cnt

Returns the number of times a specified telemetry packet has been received.

Ruby / Python Syntax:

get_tlm_cnt("<Target Name> <Packet Name>")
get_tlm_cnt("<Target Name>", "<Packet Name>")
ParameterDescription
Target NameName of the target.
Packet NameName of the telemetry packet.

Ruby / Python Example:

tlm_cnt = get_tlm_cnt("INST HEALTH_STATUS") # Number of times the INST HEALTH_STATUS telemetry packet has been received.

set_tlm

Sets a telemetry item value in the Command and Telemetry Server. This value will be overwritten if a new packet is received from an interface. For that reason this method is most useful if interfaces are disconnected or for testing via the Script Runner disconnect mode. Manually setting telemetry values allows for the execution of many logical paths in scripts.

Ruby / Python Syntax:

set_tlm("<Target> <Packet> <Item> = <Value>", <type>)
ParameterDescription
TargetTarget name
PacketPacket name
ItemItem name
ValueValue to set
typeValue type RAW, CONVERTED (default), FORMATTED, WITH_UNITS (Ruby symbol, Python string)

Ruby Example:

set_tlm("INST HEALTH_STATUS COLLECTS = 5") # type is :CONVERTED by default
check("INST HEALTH_STATUS COLLECTS == 5")
set_tlm("INST HEALTH_STATUS COLLECTS = 10", type: :RAW)
check("INST HEALTH_STATUS COLLECTS == 10", type: :RAW)

Python Example:

set_tlm("INST HEALTH_STATUS COLLECTS = 5") # type is CONVERTED by default
check("INST HEALTH_STATUS COLLECTS == 5")
set_tlm("INST HEALTH_STATUS COLLECTS = 10", type='RAW')
check("INST HEALTH_STATUS COLLECTS == 10", type='RAW')

inject_tlm

Injects a packet into the system as if it was received from an interface.

Ruby / Packet Syntax:

inject_tlm("<target_name>", "<packet_name>", <item_hash>, <type>)
ParameterDescription
TargetTarget name
PacketPacket name
Item HashHash of item name/value for each item. If an item is not specified in the hash, the current value table value will be used. Optional parameter, defaults to nil.
typeType of values in the item hash, RAW, CONVERTED (default), FORMATTED, WITH_UNITS (Ruby symbol, Python string)

Ruby Example:

inject_tlm("INST", "PARAMS", {'VALUE1' => 5.0, 'VALUE2' => 7.0})

Python Example:

inject_tlm("INST", "PARAMS", {'VALUE1': 5.0, 'VALUE2': 7.0})

override_tlm

Sets the converted value for a telmetry point in the Command and Telemetry Server. This value will be maintained even if a new packet is received on the interface unless the override is canceled with the normalize_tlm method.

Ruby / Python Syntax:

override_tlm("<Target> <Packet> <Item> = <Value>", <type>)
ParameterDescription
TargetTarget name
PacketPacket name
ItemItem name
ValueValue to set
typeType to override, ALL (default), RAW, CONVERTED, FORMATTED, WITH_UNITS (Ruby symbol, Python string)

Ruby Example:

override_tlm("INST HEALTH_STATUS TEMP1 = 5") # All requests for TEMP1 return 5
override_tlm("INST HEALTH_STATUS TEMP2 = 0", type: :RAW) # Only RAW tlm set to 0

Python Example:

override_tlm("INST HEALTH_STATUS TEMP1 = 5") # All requests for TEMP1 return 5
override_tlm("INST HEALTH_STATUS TEMP2 = 0", type='RAW') # Only RAW tlm set to 0

normalize_tlm

Clears the override of a telmetry point in the Command and Telemetry Server.

Ruby / Python Syntax:

normalize_tlm("<Target> <Packet> <Item>", <type>)
ParameterDescription
TargetTarget name
PacketPacket name
ItemItem name
typeType to normalize, ALL (default), RAW, CONVERTED, FORMATTED, WITH_UNITS (Ruby symbol, Python string)

Ruby Example:

normalize_tlm("INST HEALTH_STATUS TEMP1") # clear all overrides
normalize_tlm("INST HEALTH_STATUS TEMP1", type: :RAW) # clear only the RAW override

Python Example:

normalize_tlm("INST HEALTH_STATUS TEMP1") # clear all overrides
normalize_tlm("INST HEALTH_STATUS TEMP1", type='RAW') # clear only the RAW override

get_overrides

Returns an array of the the currently overriden values set by override_tlm. NOTE: This returns all the value types that are overriden which by default is all 4 values types when using override_tlm.

Ruby / Python Syntax:

get_overrides()

Ruby Example:

override_tlm("INST HEALTH_STATUS TEMP1 = 5")
puts get_overrides() #=>
# [ {"target_name"=>"INST", "packet_name"=>"HEALTH_STATUS", "item_name"=>"TEMP1", "value_type"=>"RAW", "value"=>5}
#   {"target_name"=>"INST", "packet_name"=>"HEALTH_STATUS", "item_name"=>"TEMP1", "value_type"=>"CONVERTED", "value"=>5}
#   {"target_name"=>"INST", "packet_name"=>"HEALTH_STATUS", "item_name"=>"TEMP1", "value_type"=>"FORMATTED", "value"=>"5"}
#   {"target_name"=>"INST", "packet_name"=>"HEALTH_STATUS", "item_name"=>"TEMP1", "value_type"=>"WITH_UNITS", "value"=>"5"} ]

Python Example:

override_tlm("INST HEALTH_STATUS TEMP1 = 5")
print(get_overrides()) #=>
# [ {'target_name': 'INST', 'packet_name': 'HEALTH_STATUS', 'item_name': 'TEMP1', 'value_type': 'RAW', 'value': 5},
#   {'target_name': 'INST', 'packet_name': 'HEALTH_STATUS', 'item_name': 'TEMP1', 'value_type': 'CONVERTED', 'value': 5},
#   {'target_name': 'INST', 'packet_name': 'HEALTH_STATUS', 'item_name': 'TEMP1', 'value_type': 'FORMATTED', 'value': '5'},
#   {'target_name': 'INST', 'packet_name': 'HEALTH_STATUS', 'item_name': 'TEMP1', 'value_type': 'WITH_UNITS', 'value': '5'} ]

Packet Data Subscriptions

Methods for subscribing to specific packets of data. This provides an interface to ensure that each telemetry packet is received and handled rather than relying on polling where some data may be missed.

subscribe_packets (since 5.0.3)

Allows the user to listen for one or more telemetry packets of data to arrive. A unique id is returned which is used to retrieve the data.

Ruby / Python Syntax:

subscribe_packets(packets)
ParameterDescription
packetsNested array of target name/packet name pairs that the user wishes to subscribe to.

Ruby / Python Example:

id = subscribe_packets([['INST', 'HEALTH_STATUS'], ['INST', 'ADCS']])

get_packets (since 5.0.3)

Streams packet data from a previous subscription.

Ruby Syntax:

get_packets(id, block: nil, count: 1000)

Python Syntax:

get_packets(id, block=None, count=1000)
ParameterDescription
idUnique id returned by subscribe_packets
blockNumber of milliseconds to block while waiting for packets form ANY stream, default nil / None (do not block)
countMaximum number of packets to return from EACH packet stream

Ruby Example:

id = subscribe_packets([['INST', 'HEALTH_STATUS'], ['INST', 'ADCS']])
wait 0.1
id, packets = get_packets(id)
packets.each do |packet|
  puts "#{packet['PACKET_TIMESECONDS']}: #{packet['target_name']} #{packet['packet_name']}"
end
# Reuse ID from last call, allow for 1s wait, only get 1 packet
id, packets = get_packets(id, block: 1000, count: 1)
packets.each do |packet|
  puts "#{packet['PACKET_TIMESECONDS']}: #{packet['target_name']} #{packet['packet_name']}"
end

Python Example:

id = subscribe_packets([['INST', 'HEALTH_STATUS'], ['INST', 'ADCS']])
wait(0.1)
id, packets = get_packets(id)
for packet in packets:
    print(f"{packet['PACKET_TIMESECONDS']}: {packet['target_name']} {packet['packet_name']}")

# Reuse ID from last call, allow for 1s wait, only get 1 packet
id, packets = get_packets(id, block=1000, count=1)
for packet in packets:
    print(f"{packet['PACKET_TIMESECONDS']}: {packet['target_name']} {packet['packet_name']}")

get_tlm_cnt

Get the receive count for a telemetry packet

Ruby / Python Syntax:

get_tlm_cnt("<Target> <Packet>")
get_tlm_cnt("<Target>", "<Packet>")
ParameterDescription
TargetTarget name
PacketPacket name

Ruby / Python Example:

get_tlm_cnt("INST HEALTH_STATUS")  #=> 10

get_tlm_cnts

Get the receive counts for an array of telemetry packets

Ruby / Python Syntax:

get_tlm_cnts([["<Target>", "<Packet>"], ["<Target>", "<Packet>"]])
ParameterDescription
TargetTarget name
PacketPacket name

Ruby / Python Example:

get_tlm_cnts([["INST", "ADCS"], ["INST", "HEALTH_STATUS"]])  #=> [100, 10]

get_packet_derived_items

Get the list of derived telemetry items for a packet

Ruby / Python Syntax:

get_packet_derived_items("<Target> <Packet>")
get_packet_derived_items("<Target>", "<Packet>")
ParameterDescription
TargetTarget name
PacketPacket name

Ruby / Python Example:

get_packet_derived_items("INST HEALTH_STATUS")  #=> ['PACKET_TIMESECONDS', 'PACKET_TIMEFORMATTED', ...]

Delays

These methods allow the user to pause the script to wait for telemetry to change or for an amount of time to pass.

wait

Pauses the script for a configurable amount of time (minimum 10ms) or until a converted telemetry item meets given criteria. It supports three different syntaxes as shown. If no parameters are given then an infinite wait occurs until the user presses Go. Note that on a timeout, wait does not stop the script, usually wait_check is a better choice.

Ruby / Python Syntax:

elapsed = wait() #=> Returns the actual time waited
elapsed = wait(<Time>) #=> Returns the actual time waited
ParameterDescription
TimeTime in Seconds to delay for.

Ruby / Python Syntax:

# Returns true or false based on the whether the expression is true or false
success = wait("<Target Name> <Packet Name> <Item Name> <Comparison>", <Timeout>, <Polling Rate (optional)>, type, quiet)
ParameterDescription
Target NameName of the target of the telemetry item.
Packet NameName of the telemetry packet of the telemetry item.
Item NameName of the telemetry item.
ComparisonA comparison to perform against the telemetry item.
TimeoutTimeout in seconds. Script will proceed if the wait statement times out waiting for the comparison to be true.
Polling RateHow often the comparison is evaluated in seconds. Defaults to 0.25 if not specified.
typeNamed parameter specifying the type. RAW, CONVERTED (default), FORMATTED, WITH_UNITS (Ruby symbol, Python string).
quietNamed parameter indicating whether to log the result. Defaults to true.

Ruby Example:

elapsed = wait
elapsed = wait 5
success = wait("INST HEALTH_STATUS COLLECTS == 3", 10)
success = wait("INST HEALTH_STATUS COLLECTS == 3", 10, type: :RAW, quiet: false)

Python Example:

elapsed = wait()
elapsed = wait(5)
success = wait("INST HEALTH_STATUS COLLECTS == 3", 10)
success = wait("INST HEALTH_STATUS COLLECTS == 3", 10, type='RAW', quiet=False)

wait_tolerance

Pauses the script for a configurable amount of time or until a converted telemetry item meets equals an expected value within a tolerance. Note that on a timeout, wait_tolerance does not stop the script, usually wait_check_tolerance is a better choice.

Ruby Python Syntax:

# Returns true or false based on the whether the expression is true or false
success = wait_tolerance("<Target Name> <Packet Name> <Item Name>", <Expected Value>, <Tolerance>, <Timeout>, <Polling Rate (optional), type, quiet>)
ParameterDescription
Target NameName of the target of the telemetry item.
Packet NameName of the telemetry packet of the telemetry item.
Item NameName of the telemetry item.
Expected ValueExpected value of the telemetry item.
Tolerance± Tolerance on the expected value.
TimeoutTimeout in seconds. Script will proceed if the wait statement times out waiting for the comparison to be true.
Polling RateHow often the comparison is evaluated in seconds. Defaults to 0.25 if not specified.
typeNamed parameter specifying the type. RAW, CONVERTED (default), FORMATTED, WITH_UNITS (Ruby symbol, Python string).
quietNamed parameter indicating whether to log the result. Defaults to true.

Ruby Examples:

success = wait_tolerance("INST HEALTH_STATUS COLLECTS", 10.0, 5.0, 10)
success = wait_tolerance("INST HEALTH_STATUS COLLECTS", 10.0, 5.0, 10, type: :RAW, quiet: true)

Python Examples:

success = wait_tolerance("INST HEALTH_STATUS COLLECTS", 10.0, 5.0, 10)
success = wait_tolerance("INST HEALTH_STATUS COLLECTS", 10.0, 5.0, 10, type='RAW', quiet=True)

wait_expression

Pauses the script until an expression is evaluated to be true or a timeout occurs. If a timeout occurs the script will continue. This method can be used to perform more complicated comparisons than using wait as shown in the example. Note that on a timeout, wait_expression does not stop the script, usually wait_check_expression is a better choice.

Syntax:

# Returns true or false based on the whether the expression is true or false
success = wait_expression("<Expression>", <Timeout>, <Polling Rate (optional)>, quiet)
ParameterDescription
ExpressionA ruby expression to evaluate.
TimeoutTimeout in seconds. Script will proceed if the wait statement times out waiting for the comparison to be true.
Polling RateHow often the comparison is evaluated in seconds. Defaults to 0.25 if not specified.
quietNamed parameter indicating whether to log the result. Defaults to true.

Ruby / Python Example:

success = wait_expression("tlm('INST HEALTH_STATUS COLLECTS') > 5 and tlm('INST HEALTH_STATUS TEMP1') > 25.0", 10)

wait_packet

Pauses the script until a certain number of packets have been received. If a timeout occurs the script will continue. Note that on a timeout, wait_packet does not stop the script, usually wait_check_packet is a better choice.

Ruby / Python Syntax:

# Returns true or false based on the whether the packet was received
success = wait_packet("<Target>", "<Packet>", <Num Packets>, <Timeout>, <Polling Rate (optional)>, quiet)
ParameterDescription
TargetThe target name
PacketThe packet name
Num PacketsThe number of packets to receive
TimeoutTimeout in seconds.
Polling RateHow often the comparison is evaluated in seconds. Defaults to 0.25 if not specified.
quietNamed parameter indicating whether to log the result. Defaults to true.

Ruby / Python Example:

success = wait_packet('INST', 'HEALTH_STATUS', 5, 10) # Wait for 5 INST HEALTH_STATUS packets over 10s

wait_check

Combines the wait and check keywords into one. This pauses the script until the converted value of a telemetry item meets given criteria or times out. On a timeout the script stops.

Ruby / Python Syntax:

# Returns the amount of time elapsed waiting for the expression
elapsed = wait_check("<Target Name> <Packet Name> <Item Name> <Comparison>", <Timeout>, <Polling Rate (optional)>, type)
ParameterDescription
Target NameName of the target of the telemetry item.
Packet NameName of the telemetry packet of the telemetry item.
Item NameName of the telemetry item.
ComparisonA comparison to perform against the telemetry item.
TimeoutTimeout in seconds. Script will stop if the wait statement times out waiting for the comparison to be true.
Polling RateHow often the comparison is evaluated in seconds. Defaults to 0.25 if not specified.
typeNamed parameter specifying the type. RAW, CONVERTED (default), FORMATTED, WITH_UNITS (Ruby symbol, Python string).

Ruby Example:

elapsed = wait_check("INST HEALTH_STATUS COLLECTS > 5", 10)
elapsed = wait_check("INST HEALTH_STATUS COLLECTS > 5", 10, type: :RAW)

Python Example:

elapsed = wait_check("INST HEALTH_STATUS COLLECTS > 5", 10)
elapsed = wait_check("INST HEALTH_STATUS COLLECTS > 5", 10, type='RAW')

wait_check_tolerance

Pauses the script for a configurable amount of time or until a converted telemetry item equals an expected value within a tolerance. On a timeout the script stops.

Ruby / Python Syntax:

# Returns the amount of time elapsed waiting for the expression
elapsed = wait_check_tolerance("<Target Name> <Packet Name> <Item Name>", <Expected Value>, <Tolerance>, <Timeout>, <Polling Rate (optional)>, type)
ParameterDescription
Target NameName of the target of the telemetry item.
Packet NameName of the telemetry packet of the telemetry item.
Item NameName of the telemetry item.
Expected ValueExpected value of the telemetry item.
Tolerance± Tolerance on the expected value.
TimeoutTimeout in seconds. Script will stop if the wait statement times out waiting for the comparison to be true.
Polling RateHow often the comparison is evaluated in seconds. Defaults to 0.25 if not specified.
typeNamed parameter specifying the type. RAW, CONVERTED (default), FORMATTED, WITH_UNITS (Ruby symbol, Python string).

Ruby Example:

elapsed = wait_check_tolerance("INST HEALTH_STATUS COLLECTS", 10.0, 5.0, 10)
elapsed = wait_check_tolerance("INST HEALTH_STATUS COLLECTS", 10.0, 5.0, 10, type: :RAW)

Python Example:

elapsed = wait_check_tolerance("INST HEALTH_STATUS COLLECTS", 10.0, 5.0, 10)
elapsed = wait_check_tolerance("INST HEALTH_STATUS COLLECTS", 10.0, 5.0, 10, type='RAW')

wait_check_expression

Pauses the script until an expression is evaluated to be true or a timeout occurs. If a timeout occurs the script will stop. This method can be used to perform more complicated comparisons than using wait as shown in the example. Also see the syntax notes for check_expression.

Ruby / Python Syntax:

# Returns the amount of time elapsed waiting for the expression
elapsed = wait_check_expression("<Expression>", <Timeout>, <Polling Rate (optional)>)
ParameterDescription
ExpressionA ruby expression to evaluate.
TimeoutTimeout in seconds. Script will stop if the wait statement times out waiting for the comparison to be true.
Polling RateHow often the comparison is evaluated in seconds. Defaults to 0.25 if not specified.

Ruby / Python Example:

elapsed = wait_check_expression("tlm('INST HEALTH_STATUS COLLECTS') > 5 and tlm('INST HEALTH_STATUS TEMP1') > 25.0", 10)

wait_check_packet

Pauses the script until a certain number of packets have been received. If a timeout occurs the script will stop.

Ruby / Python Syntax:

# Returns the amount of time elapsed waiting for the packets
elapsed = wait_check_packet("<Target>", "<Packet>", <Num Packets>, <Timeout>, <Polling Rate (optional)>, quiet)
ParameterDescription
TargetThe target name
PacketThe packet name
Num PacketsThe number of packets to receive
TimeoutTimeout in seconds. Script will stop if the wait statement times out waiting specified number of packets.
Polling RateHow often the comparison is evaluated in seconds. Defaults to 0.25 if not specified.
quietNamed parameter indicating whether to log the result. Defaults to true.

Ruby / Python Example:

elapsed = wait_check_packet('INST', 'HEALTH_STATUS', 5, 10) # Wait for 5 INST HEALTH_STATUS packets over 10s

Limits

These methods deal with handling telemetry limits.

limits_enabled?, limits_enabled

The limits_enabled? method returns true/false depending on whether limits are enabled for a telemetry item.

Ruby Syntax:

limits_enabled?("<Target Name> <Packet Name> <Item Name>")

Python Syntax:

limits_enabled("<Target Name> <Packet Name> <Item Name>")
ParameterDescription
Target NameName of the target of the telemetry item.
Packet NameName of the telemetry packet of the telemetry item.
Item NameName of the telemetry item.

Ruby Example:

enabled = limits_enabled?("INST HEALTH_STATUS TEMP1") #=> true or false

Python Example:

enabled = limits_enabled("INST HEALTH_STATUS TEMP1") #=> True or False

enable_limits

Enables limits monitoring for the specified telemetry item.

Ruby / Python Syntax:

enable_limits("<Target Name> <Packet Name> <Item Name>")
ParameterDescription
Target NameName of the target of the telemetry item.
Packet NameName of the telemetry packet of the telemetry item.
Item NameName of the telemetry item.

Ruby / Python Example:

enable_limits("INST HEALTH_STATUS TEMP1")

disable_limits

Disables limits monitoring for the specified telemetry item.

Ruby / Python Syntax:

disable_limits("<Target Name> <Packet Name> <Item Name>")
ParameterDescription
Target NameName of the target of the telemetry item.
Packet NameName of the telemetry packet of the telemetry item.
Item NameName of the telemetry item.

Ruby / Python Example:

disable_limits("INST HEALTH_STATUS TEMP1")

enable_limits_group

Enables limits monitoring on a set of telemetry items specified in a limits group.

Ruby / Python Syntax:

enable_limits_group("<Limits Group Name>")
ParameterDescription
Limits Group NameName of the limits group.

Ruby / Python Example:

enable_limits_group("SAFE_MODE")

disable_limits_group

Disables limits monitoring on a set of telemetry items specified in a limits group.

Ruby / Python Syntax:

disable_limits_group("<Limits Group Name>")
ParameterDescription
Limits Group NameName of the limits group.

Ruby / Python Example:

disable_limits_group("SAFE_MODE")

get_limits_groups

Returns the list of limits groups in the system.

Ruby / Python Syntax / Example:

limits_groups = get_limits_groups()

set_limits_set

Sets the current limits set. The default limits set is DEFAULT.

Ruby / Python Syntax:

set_limits_set("<Limits Set Name>")
ParameterDescription
Limits Set NameName of the limits set.

Ruby / Python Example:

set_limits_set("DEFAULT")

get_limits_set

Returns the name of the current limits set. The default limits set is DEFAULT.

Ruby / Python Syntax / Example:

limits_set = get_limits_set()

get_limits_sets

Returns the list of limits sets in the system.

Ruby / Python Syntax / Example:

limits_sets = get_limits_sets()

get_limits

Returns limits settings for a telemetry point.

Ruby / Python Syntax:

get_limits(<Target Name>, <Packet Name>, <Item Name>, <Limits Set (optional)>)
ParameterDescription
Target NameName of the target of the telemetry item.
Packet NameName of the telemetry packet of the telemetry item.
Item NameName of the telemetry item.
Limits SetGet the limits for a specific limits set. If not given then it defaults to returning the settings for the current limits set.

Ruby / Python Example:

limits_set, persistence_setting, enabled, red_low, yellow_low, yellow_high, red_high, green_low, green_high = get_limits('INST', 'HEALTH_STATUS', 'TEMP1')

set_limits

The set_limits_method sets limits settings for a telemetry point. Note: In most cases it would be better to update your config files or use different limits sets rather than changing limits settings in realtime.

Ruby / Python Syntax:

set_limits(<Target Name>, <Packet Name>, <Item Name>, <Red Low>, <Yellow Low>, <Yellow High>, <Red High>, <Green Low (optional)>, <Green High (optional)>, <Limits Set (optional)>, <Persistence (optional)>, <Enabled (optional)>)
ParameterDescription
Target NameName of the target of the telemetry item.
Packet NameName of the telemetry packet of the telemetry item.
Item NameName of the telemetry item.
Red LowRed Low setting for this limits set. Any value below this value will be make the item red.
Yellow LowYellow Low setting for this limits set. Any value below this value but greater than Red Low will be make the item yellow.
Yellow HighYellow High setting for this limits set. Any value above this value but less than Red High will be make the item yellow.
Red HighRed High setting for this limits set. Any value above this value will be make the item red.
Green LowOptional. If given, any value greater than Green Low and less than Green_High will make the item blue indicating a good operational value.
Green HighOptional. If given, any value greater than Green Low and less than Green_High will make the item blue indicating a good operational value.
Limits SetOptional. Set the limits for a specific limits set. If not given then it defaults to setting limts for the CUSTOM limits set.
PersistenceOptional. Set the number of samples this item must be out of limits before changing limits state. Defaults to no change. Note: This affects all limits settings across limits sets.
EnabledOptional. Whether or not limits are enabled for this item. Defaults to true. Note: This affects all limits settings across limits sets.

Ruby / Python Example:

set_limits('INST', 'HEALTH_STATUS', 'TEMP1', -10.0, 0.0, 50.0, 60.0, 30.0, 40.0, 'TVAC', 1, true)

get_out_of_limits

Returns an array with the target_name, packet_name, item_name, and limits_state of all items that are out of their limits ranges.

Ruby / Python Syntax / Example:

out_of_limits_items = get_out_of_limits()

get_overall_limits_state

Returns the overall limits state for the COSMOS system. Returns 'GREEN', 'YELLOW', or 'RED'.

Ruby / Python Syntax:

get_overall_limits_state(<Ignored Items> (optional))
ParameterDescription
Ignored ItemsArray of arrays with items to ignore when determining the overall limits state. [['TARGET_NAME', 'PACKET_NAME', 'ITEM_NAME'], ...]

Ruby / Python Example:

overall_limits_state = get_overall_limits_state()
overall_limits_state = get_overall_limits_state([['INST', 'HEALTH_STATUS', 'TEMP1']])

get_limits_events

Returns limits events based on an offset returned from the last time it was called.

Ruby / Python Syntax:

get_limits_event(<Offset>, count)
ParameterDescription
OffsetOffset returned by the previous call to get_limits_event. Default is nil for the initial call
countNamed parameter specifying the maximum number of limits events to return. Default is 100

Ruby / Python Example:

events = get_limits_event()
print(events)
#[["1613077715557-0",
#  {"type"=>"LIMITS_CHANGE",
#   "target_name"=>"TGT",
#   "packet_name"=>"PKT",
#   "item_name"=>"ITEM",
#   "old_limits_state"=>"YELLOW_LOW",
#   "new_limits_state"=>"RED_LOW",
#   "time_nsec"=>"1",
#   "message"=>"message"}],
# ["1613077715557-1",
#  {"type"=>"LIMITS_CHANGE",
#   "target_name"=>"TGT",
#   "packet_name"=>"PKT",
#   "item_name"=>"ITEM",
#   "old_limits_state"=>"RED_LOW",
#   "new_limits_state"=>"YELLOW_LOW",
#   "time_nsec"=>"2",
#   "message"=>"message"}]]
# The last offset is the first item ([0]) in the last event ([-1])
events = get_limits_event(events[-1][0])
print(events)
#[["1613077715657-0",
#  {"type"=>"LIMITS_CHANGE",
#   ...

Targets

Methods for getting knowledge about targets.

get_target_names

Returns a list of the targets in the system in an array.

Ruby Syntax / Example:

targets = get_target_names() #=> ['INST', 'INST2', 'EXAMPLE', 'TEMPLATED']

get_target

Returns a target hash containing all the information about the target.

Ruby Syntax:

get_target("<Target Name>")
ParameterDescription
Target NameName of the target.

Ruby Example:

target = get_target("INST")
print(target)
#{"name"=>"INST",
# "folder_name"=>"INST",
# "requires"=>[],
# "ignored_parameters"=>
#  ["CCSDSVER",
#   "CCSDSTYPE",
#   "CCSDSSHF",
#   "CCSDSAPID",
#   "CCSDSSEQFLAGS",
#   "CCSDSSEQCNT",
#   "CCSDSLENGTH",
#   "PKTID"],
# "ignored_items"=>
#  ["CCSDSVER",
#   "CCSDSTYPE",
#   "CCSDSSHF",
#   "CCSDSAPID",
#   "CCSDSSEQFLAGS",
#   "CCSDSSEQCNT",
#   "CCSDSLENGTH",
#   "RECEIVED_COUNT",
#   "RECEIVED_TIMESECONDS",
#   "RECEIVED_TIMEFORMATTED"],
# "limits_groups"=>[],
# "cmd_tlm_files"=>
#  [".../targets/INST/cmd_tlm/inst_cmds.txt",
#   ".../targets/INST/cmd_tlm/inst_tlm.txt"],
# "cmd_unique_id_mode"=>false,
# "tlm_unique_id_mode"=>false,
# "id"=>nil,
# "updated_at"=>1613077058266815900,
# "plugin"=>nil}

get_target_interfaces

Returns the interfaces for all targets. The return value is an array of arrays where each subarray contains the target name, and a String of all the interface names.

Syntax / Example:

target_ints = get_target_interfaces()
target_ints.each do |target_name, interfaces|
  puts "Target: #{target_name}, Interfaces: #{interfaces}"
end

Interfaces

These methods allow the user to manipulate COSMOS interfaces.

get_interface (since 5.0.0)

Returns an interface status including the as built interface and its current status (cmd/tlm counters, etc).

Ruby / Python Syntax:

get_interface("<Interface Name>")
ParameterDescription
Interface NameName of the interface.

Ruby / Python Example:

interface = get_interface("INST_INT")
print(interface)
#{"name"=>"INST_INT",
# "config_params"=>["interface.rb"],
# "target_names"=>["INST"],
# "connect_on_startup"=>true,
# "auto_reconnect"=>true,
# "reconnect_delay"=>5.0,
# "disable_disconnect"=>false,
# "options"=>[],
# "protocols"=>[],
# "log"=>true,
# "log_raw"=>false,
# "plugin"=>nil,
# "updated_at"=>1613076213535979900,
# "state"=>"CONNECTED",
# "clients"=>0,
# "txsize"=>0,
# "rxsize"=>0,
# "txbytes"=>0,
# "rxbytes"=>0,
# "txcnt"=>0,
# "rxcnt"=>0}

get_interface_names

Returns a list of the interfaces in the system in an array.

Ruby / Python Syntax / Example:

interface_names = get_interface_names() #=> ['INST_INT', 'INST2_INT', 'EXAMPLE_INT', 'TEMPLATED_INT']

connect_interface

Connects to targets associated with a COSMOS interface.

Ruby / Python Syntax:

connect_interface("<Interface Name>", <Interface Parameters (optional)>)
ParameterDescription
Interface NameName of the interface.
Interface ParametersParameters used to initialize the interface. If none are given then the interface will use the parameters that were given in the server configuration file.

Ruby / Python Example:

connect_interface("INT1")
connect_interface("INT1", hostname, port)

disconnect_interface

Disconnects from targets associated with a COSMOS interface.

Ruby / Python Syntax:

disconnect_interface("<Interface Name>")
ParameterDescription
Interface NameName of the interface.

Ruby / Python Example:

disconnect_interface("INT1")

start_raw_logging_interface

Starts logging of raw data on one or all interfaces. This is for debugging purposes only.

Ruby / Python Syntax:

start_raw_logging_interface("<Interface Name (optional)>")
ParameterDescription
Interface NameName of the Interface to command to start raw data logging. Defaults to 'ALL' which causes all interfaces that support raw data logging to start logging raw data.

Ruby / Python Example:

start_raw_logging_interface("int1")

stop_raw_logging_interface

Stops logging of raw data on one or all interfaces. This is for debugging purposes only.

Ruby / Python Syntax:

stop_raw_logging_interface("<Interface Name (optional)>")
ParameterDescription
Interface NameName of the Interface to command to stop raw data logging. Defaults to 'ALL' which causes all interfaces that support raw data logging to stop logging raw data.

Ruby / Python Example:

stop_raw_logging_interface("int1")

get_all_interface_info

Returns information about all interfaces. The return value is an array of arrays where each subarray contains the interface name, connection state, number of connected clients, transmit queue size, receive queue size, bytes transmitted, bytes received, command count, and telemetry count.

Ruby Syntax / Example:

interface_info = get_all_interface_info()
interface_info.each do |interface_name, connection_state, num_clients, tx_q_size, rx_q_size, tx_bytes, rx_bytes, cmd_count, tlm_count|
  puts "Interface: #{interface_name}, Connection state: #{connection_state}, Num connected clients: #{num_clients}"
  puts "Transmit queue size: #{tx_q_size}, Receive queue size: #{rx_q_size}, Bytes transmitted: #{tx_bytes}, Bytes received: #{rx_bytes}"
  puts "Cmd count: #{cmd_count}, Tlm count: #{tlm_count}"
end

Python Syntax / Example:

interface_info = get_all_interface_info()
for interface in interface_info():
    # [interface_name, connection_state, num_clients, tx_q_size, rx_q_size, tx_bytes, rx_bytes, cmd_count, tlm_count]
    print(f"Interface: {interface[0]}, Connection state: {interface[1]}, Num connected clients: {interface[2]}")
    print(f"Transmit queue size: {interface[3]}, Receive queue size: {interface[4]}, Bytes transmitted: {interface[5]}, Bytes received: {interface[6]}")
    print(f"Cmd count: {interface[7]}, Tlm count: {interface[8]}")

map_target_to_interface

Map a target to an interface allowing target commands and telemetry to be processed by that interface.

Ruby / Python Syntax:

map_target_to_interface("<Target Name>", "<Interface Name>", cmd_only, tlm_only, unmap_old)
ParameterDescription
Target NameName of the target
Interface NameName of the interface
cmd_onlyNamed parameter whether to map target commands only to the interface (default: false)
tlm_onlyNamed parameter whether to map target telemetry only to the interface (default: false)
unmap_oldNamed parameter whether remove the target from all existing interfaces (default: true)

Ruby Example:

map_target_to_interface("INST", "INST_INT", unmap_old: false)

Python Example:

map_target_to_interface("INST", "INST_INT", unmap_old=False)

interface_cmd

Send a command directly to an interface. This has no effect in the standard COSMOS interfaces but can be implemented by a custom interface to change behavior.

Ruby / Python Syntax:

interface_cmd("<Interface Name>", "<Command Name>", "<Command Parameters>")
ParameterDescription
Interface NameName of the interface
Command NameName of the command to send
Command ParametersAny parameters to send with the command

Ruby / Python Example:

interface_cmd("INST", "DISABLE_CRC")

interface_protocol_cmd

Send a command directly to an interface protocol. This has no effect in the standard COSMOS protocols but can be implemented by a custom protocol to change behavior.

Ruby / Python Syntax:

interface_protocol_cmd("<Interface Name>", "<Command Name>", "<Command Parameters>")
ParameterDescription
Interface NameName of the interface
Command NameName of the command to send
Command ParametersAny parameters to send with the command
read_writeWhether command gets send to read or write protocols. Must be one of READ, WRITE, or READ_WRITE (Ruby symbols, Python strings). The default is READ_WRITE.
indexWhich protocol in the stack the command should apply to. The default is -1 which applies the command to all.

Ruby Example:

interface_protocol_cmd("INST", "DISABLE_CRC", read_write: :READ_WRITE, index: -1)

Python Example:

interface_protocol_cmd("INST", "DISABLE_CRC", read_write='READ_WRITE', index=-1)

Routers

These methods allow the user to manipulate COSMOS routers.

connect_router

Connects a COSMOS router.

Ruby / Python Syntax:

connect_router("<Router Name>", <Router Parameters (optional)>)
ParameterDescription
Router NameName of the router.
Router ParametersParameters used to initialize the router. If none are given then the router will use the parameters that were given in the server configuration file.

Ruby / Python Example:

connect_ROUTER("INST_ROUTER")
connect_router("INST_ROUTER", 7779, 7779, nil, 10.0, 'PREIDENTIFIED')

disconnect_router

Disconnects a COSMOS router.

Ruby / Python Syntax:

disconnect_router("<Router Name>")
ParameterDescription
Router NameName of the router.

Ruby / Python Example:

disconnect_router("INT1_ROUTER")

get_router_names

Returns a list of the routers in the system in an array.

Ruby / Python Syntax / Example:

router_names = get_router_names() #=> ['ROUTER_INT']

get_router (since 5.0.0)

Returns a router status including the as built router and its current status (cmd/tlm counters, etc).

Ruby / Python Syntax:

get_router("<Router Name>")
ParameterDescription
Router NameName of the router.

Ruby / Python Example:

router = get_router("ROUTER_INT")
print(router)
#{"name"=>"ROUTER_INT",
# "config_params"=>["router.rb"],
# "target_names"=>["INST"],
# "connect_on_startup"=>true,
# "auto_reconnect"=>true,
# "reconnect_delay"=>5.0,
# "disable_disconnect"=>false,
# "options"=>[],
# "protocols"=>[],
# "log"=>true,
# "log_raw"=>false,
# "plugin"=>nil,
# "updated_at"=>1613076213535979900,
# "state"=>"CONNECTED",
# "clients"=>0,
# "txsize"=>0,
# "rxsize"=>0,
# "txbytes"=>0,
# "rxbytes"=>0,
# "txcnt"=>0,
# "rxcnt"=>0}

get_all_router_info

Returns information about all routers. The return value is an array of arrays where each subarray contains the router name, connection state, number of connected clients, transmit queue size, receive queue size, bytes transmitted, bytes received, packets received, and packets sent.

Ruby Syntax / Example:

router_info = get_all_router_info()
router_info.each do |router_name, connection_state, num_clients, tx_q_size, rx_q_size, tx_bytes, rx_bytes, pkts_rcvd, pkts_sent|
  puts "Router: #{router_name}, Connection state: #{connection_state}, Num connected clients: #{num_clients}"
  puts "Transmit queue size: #{tx_q_size}, Receive queue size: #{rx_q_size}, Bytes transmitted: #{tx_bytes}, Bytes received: #{rx_bytes}"
  puts "Packets received: #{pkts_rcvd}, Packets sent: #{pkts_sent}"
end

Python Syntax / Example:

router_info = get_all_router_info()
# router_name, connection_state, num_clients, tx_q_size, rx_q_size, tx_bytes, rx_bytes, pkts_rcvd, pkts_sent
for router in router_info:
    print(f"Router: {router[0]}, Connection state: {router[1]}, Num connected clients: {router[2]}")
    print(f"Transmit queue size: {router[3]}, Receive queue size: {router[4]}, Bytes transmitted: {router[5]}, Bytes received: {router[6]}")
    print(f"Packets received: {router[7]}, Packets sent: {router[8]}")

start_raw_logging_router

Starts logging of raw data on one or all routers. This is for debugging purposes only.

Ruby / Python Syntax:

start_raw_logging_router("<Router Name (optional)>")
ParameterDescription
Router NameName of the Router to command to start raw data logging. Defaults to 'ALL' which causes all routers that support raw data logging to start logging raw data.

Ruby / Python Example:

start_raw_logging_router("router1")

stop_raw_logging_router

Stops logging of raw data on one or all routers. This is for debugging purposes only.

Ruby / Python Syntax:

stop_raw_logging_router("<Router Name (optional)>")
ParameterDescription
Router NameName of the Router to command to stop raw data logging. Defaults to 'ALL' which causes all routers that support raw data logging to stop logging raw data.

Ruby / Python Example:

stop_raw_logging_router("router1")

router_cmd

Send a command directly to a router. This has no effect in the standard COSMOS routers but can be implemented by a custom router to change behavior.

Ruby / Python Syntax:

router_cmd("<Router Name>", "<Command Name>", "<Command Parameters>")
ParameterDescription
Router NameName of the router
Command NameName of the command to send
Command ParametersAny parameters to send with the command

Ruby / Python Example:

router_cmd("INST", "DISABLE_CRC")

router_protocol_cmd

Send a command directly to an router protocol. This has no effect in the standard COSMOS protocols but can be implemented by a custom protocol to change behavior.

Ruby / Python Syntax:

router_protocol_cmd("<Router Name>", "<Command Name>", "<Command Parameters>", read_write, index)
ParameterDescription
Router NameName of the router
Command NameName of the command to send
Command ParametersAny parameters to send with the command
read_writeWhether command gets send to read or write protocols. Must be one of READ, WRITE, or READ_WRITE (Ruby symbols, Python strings). The default is READ_WRITE.
indexWhich protocol in the stack the command should apply to. The default is -1 which applies the command to all.

Ruby Example:

router_protocol_cmd("INST", "DISABLE_CRC", read_write: :READ_WRITE, index: -1)

Python Example:

router_protocol_cmd("INST", "DISABLE_CRC", read_write='READ_WRITE', index=-1)

Stashing Data

These methods allow the user to store temporary data into COSMOS and retrieve it. The storage is implemented as a key / value storage (Ruby hash or Python dict). This can be used in scripts to store information that applies across multiple scripts or multiple runs of a single script.

stash_set

Sets a stash item.

Ruby / Python Syntax:

stash_set("<Stash Key>", <Stash Value>)
ParameterDescription
Stash KeyName of the stash key to set
Stash ValueValue to set

Ruby / Python Example:

stash_set('run_count', 5)
stash_set('setpoint', 23.4)

stash_get

Returns the specified stash item.

Ruby / Python Syntax:

stash_get("<Stash Key>")
ParameterDescription
Stash KeyName of the stash key to return

Ruby / Python Example:

stash_get('run_count')  #=> 5

stash_all

Returns all the stash items as a Ruby hash or Python dict.

Ruby Syntax / Example:

stash_all()  #=> ['run_count' => 5, 'setpoint' => 23.4]

Python Syntax / Example:

stash_all()  #=> ['run_count': 5, 'setpoint': 23.4]

stash_keys

Returns all the stash keys.

Ruby / Python Syntax / Example:

stash_keys()  #=> ['run_count', 'setpoint']

stash_delete

Deletes a stash item. Note this actions is permanent!

Ruby / Python Syntax:

stash_delete("<Stash Key>")
ParameterDescription
Stash KeyName of the stash key to delete

Ruby / Python Example:

stash_delete("run_count")

Executing Other Procedures

These methods allow the user to bring in files of subroutines and execute other test procedures.

start

Starts execution of another high level test procedure. No parameters can be given to high level test procedures. If parameters are necessary, then consider using a subroutine.

Syntax:

start("<Procedure Filename>")
ParameterDescription
Procedure FilenameName of the test procedure file. These files are normally in the procedures folder but may be anywhere in the Ruby search path. Additionally, absolute paths are supported.

Example:

start("test1.rb")

load_utility

Reads in a script file that contains useful subroutines for use in your test procedure. When these subroutines run in ScriptRunner or TestRunner, their lines will be highlighted. If you want to import subroutines but do not want their lines to be highlighted in ScriptRunner or TestRunner, use the standard Ruby 'load' or 'require' statement or Python 'import' statement.

Ruby / Python Syntax:

load_utility("TARGET/lib/<Utility Filename>")
ParameterDescription
Utility FilenameName of the script file containing subroutines including the .rb or .py extension. You need to include the full target name and path such as TARGET/lib/utility.rb

Example:

load_utility("TARGET/lib/mode_changes.rb") # Ruby
load_utility("TARGET/lib/mode_changes.py") # Python

Opening, Closing & Creating Telemetry Screens

These methods allow the user to open, close or create unique telemetry screens from within a test procedure.

display_screen

Opens a telemetry screen at the specified position.

Ruby / Python Syntax:

display_screen("<Target Name>", "<Screen Name>", <X Position (optional)>, <Y Position (optional)>)
ParameterDescription
Target NameTelemetry screen target name
Screen NameScreen name within the specified target
X PositionX coordinate for the upper left hand corner of the screen
Y PositionY coordinate for the upper left hand corner of the screen

Ruby / Python Example:

display_screen("INST", "ADCS", 100, 200)

clear_screen

Closes an open telemetry screen.

Ruby / Python Syntax:

clear_screen("<Target Name>", "<Screen Name>")
ParameterDescription
Target NameTelemetry screen target name
Screen NameScreen name within the specified target

Ruby / Python Example:

clear_screen("INST", "ADCS")

clear_all_screens

Closes all open screens.

Ruby / Python Syntax / Example:

clear_all_screens()

delete_screen

Deletes an existing Telemetry Viewer screen.

Ruby / Python Syntax:

delete_screen("<Target Name>", "<Screen Name>")
ParameterDescription
Target NameTelemetry screen target name
Screen NameScreen name within the specified target

Ruby / Python Example:

delete_screen("INST", "ADCS")

get_screen_list

The get_screen_list returns a list of available telemetry screens.

Ruby / Python Syntax / Example:

get_screen_list() #=> ['INST ADCS', 'INST COMMANDING', ...]

get_screen_definition

The get_screen_definition returns the text file contents of a telemetry screen definition.

Syntax:

get_screen_definition("<Target Name>", "<Screen Name>")
ParameterDescription
Target NameTelemetry screen target name
Screen NameScreen name within the specified target

Ruby / Python Example:

screen_definition = get_screen_definition("INST", "HS")

create_screen

The create_screen allows you to create a screen directly from a script. This screen is saved to Telemetry Viewer for future use in that application.

Python / Ruby Syntax:

create_screen("<Target Name>", "<Screen Name>" "<Definition>")
ParameterDescription
Target NameTelemetry screen target name
Screen NameScreen name within the specified target
DefinitionThe entire screen definition as a String

Ruby Example:

screen_def = '
  SCREEN AUTO AUTO 0.1 FIXED
  VERTICAL
    TITLE "New Screen"
    VERTICALBOX
      LABELVALUE INST HEALTH_STATUS TEMP1
    END
  END
'
# Here we pass in the screen definition as a string
create_screen("INST", "LOCAL", screen_def)

Python Example:

screen_def = '
  SCREEN AUTO AUTO 0.1 FIXED
  VERTICAL
    TITLE "New Screen"
    VERTICALBOX
      LABELVALUE INST HEALTH_STATUS TEMP1
    END
  END
'
# Here we pass in the screen definition as a string
create_screen("INST", "LOCAL", screen_def)

local_screen

The local_screen allows you to create a local screen directly from a script which is not permanently saved to the Telemetry Viewer screen list. This is useful for one off screens that help users interact with scripts.

Python / Ruby Syntax:

local_screen("<Screen Name>" "<Definition>", <X Position (optional)>, <Y Position (optional)>)
ParameterDescription
Screen NameScreen name within the specified target
DefinitionThe entire screen definition as a String
X PositionX coordinate for the upper left hand corner of the screen
Y PositionY coordinate for the upper left hand corner of the screen

NOTE: It is possible to specify a X, Y location off the visible display. If you do so and try to re-create the screen it will not display (because it is already displayed). Try issuing a clear_all_screens() first to clear any screens off the visible display space.

Ruby Example:

screen_def = '
  SCREEN AUTO AUTO 0.1 FIXED
  VERTICAL
    TITLE "Local Screen"
    VERTICALBOX
      LABELVALUE INST HEALTH_STATUS TEMP1
    END
  END
'
# Here we pass in the screen definition as a string
local_screen("TESTING", screen_def, 600, 75)

Python Example:

screen_def = """
  SCREEN AUTO AUTO 0.1 FIXED
  VERTICAL
    TITLE "Local Screen"
    VERTICALBOX
      LABELVALUE INST HEALTH_STATUS TEMP1
    END
  END
"""
# Here we pass in the screen definition as a string
local_screen("TESTING", screen_def, 600, 75)

Script Runner Settings

These methods allow the user to control various Script Runner settings.

set_line_delay

This method sets the line delay in script runner.

Ruby / Python Syntax:

set_line_delay(<Delay>)
ParameterDescription
DelayThe amount of time script runner will wait between lines when executing a script, in seconds. Should be ≥ 0.0

Ruby / Python Example:

set_line_delay(0.0)

get_line_delay

The method gets the line delay that script runner is currently using.

Ruby / Python Syntax / Example:

curr_line_delay = get_line_delay()

set_max_output

This method sets the maximum number of characters to display in Script Runner output before truncating. Default is 50,000 characters.

Ruby / Python Syntax:

set_max_output(<Characters>)
ParameterDescription
CharactersNumber of characters to output before truncating

Ruby / Python Example:

set_max_output(100)

get_max_output

The method gets the maximum number of characters to display in Script Runner output before truncating. Default is 50,000 characters.

Ruby / Python Syntax / Example:

print(get_max_output()) #=> 50000

disable_instrumentation

Disables instrumentation for a block of code (line highlighting and exception catching). This is especially useful for speeding up loops that are very slow if lines are instrumented. Consider breaking code like this into a seperate file and using either require/load to read the file for the same effect while still allowing errors to be caught by your script.

Disabling instrumentation will cause any error that occurs while disabled to cause your script to completely stop.

Ruby Syntax / Example:

disable_instrumentation do
  1000.times do
    # Don't want this to have to highlight 1000 times
  end
end

Python Syntax / Example:

with disable_instrumentation():
    for x in range(1000):
        # Don't want this to have to highlight 1000 times

Script Runner Suites

Creating Script Runner suites utilizes APIs to add groups to the defined suites. For more information please see running script suites.

add_group, add_group_setup, add_group_teardown, add_script

Adds a group's methods to the suite. The add_group method adds all the group methods including setup, teardown, and all the methods starting with 'script_' or 'test_'. The add_group_setup method adds just the setup method defined in the group class. The add_group_teardown method adds just the teardown method defined in the group class. The add_script method adds an individual method to the suite. NOTE: add_script can add any method including those not named with 'script_' or 'test_'.

Ruby / Python Syntax:

add_group(<Group Class>)
add_group_setup(<Group Class>)
add_group_teardown(<Group Class>)
add_script(<Group Class>, <Method>)
ParameterDescription
Group ClassName of the previously defined class which inherits from the OpenC3 Group class. The Ruby API passes a String with the name of the group. The Python API passes the Group class directly.
MethodName of the method in the OpenC3 Group class. The Ruby API passes a String with the name of the method. The Python API passes the Group class directly.

Ruby Example:

load 'openc3/script/suite.rb'

class ExampleGroup < OpenC3::Group
  def script_1
    # Insert test code here ...
  end
end
class WrapperGroup < OpenC3::Group
  def setup
    # Insert test code here ...
  end
  def my_method
    # Insert test code here ...
  end
  def teardown
    # Insert test code here ...
  end
end

class MySuite < OpenC3::Suite
  def initialize
    super()
    add_group('ExampleGroup')
    add_group_setup('WrapperGroup')
    add_script('WrapperGroup', 'my_method')
    add_group_teardown('WrapperGroup')
  end
end

Python Example:

from openc3.script import *
from openc3.script.suite import Group, Suite

class ExampleGroup(Group):
    def script_1(self):
        # Insert test code here ...
        pass
class WrapperGroup(Group):
    def setup(self):
        # Insert test code here ...
        pass
    def my_method(self):
        # Insert test code here ...
        pass
    def teardown(self):
        # Insert test code here ...
        pass
class MySuite(Suite):
    def __init__(self):
        super().__init__()
        self.add_group(ExampleGroup)
        self.add_group_setup(WrapperGroup)
        self.add_script(WrapperGroup, 'my_method')
        self.add_group_teardown(WrapperGroup)

Script Runner Debugging

These methods allow the user to debug scripts with ScriptRunner.

step_mode

Places ScriptRunner into step mode where Go must be hit to proceed to the next line.

Ruby / Python Syntax / Example:

step_mode()

run_mode

Places ScriptRunner into run mode where the next line is run automatically.

Ruby / Python Syntax / Example:

run_mode()

disconnect_script

Puts scripting into disconnect mode. In disconnect mode, commands are not sent to targets, checks are all successful, and waits expire instantly. Requests for telemetry (tlm()) typically return 0. Disconnect mode is useful for dry-running scripts without having connected targets.

Ruby / Python Syntax / Example:

disconnect_script()

Metadata

Metadata allows you to mark the regular target / packet data logged in COSMOS with your own fields. This metadata can then be searched and used to filter data when using other COSMOS tools.

metadata_all

Returns all the metadata that was previously set

Ruby / Python Syntax:

metadata_all()
ParameterDescription
limitAmount of metadata items to return. Default is 100.

Ruby Example:

metadata_all(limit: 500)

Python Example:

metadata_all(limit='500')

metadata_get

Returns metadata that was previously set

Ruby / Python Syntax:

metadata_get(start)
ParameterDescription
startNamed parameter, time at which to retrieve metadata as integer seconds from epoch

Ruby Example:

metadata_get(start: 500)

Python Example:

metadata_get(start='500')

metadata_set

Returns metadata that was previously set

Ruby / Python Syntax:

metadata_set(<Metadata>, start, color)
ParameterDescription
MetadataHash or dict of key value pairs to store as metadata.
startNamed parameter, time at which to store metadata. Default is now.
colorNamed parameter, color to display metadat in the calendar. Default is #003784.

Ruby Example:

metadata_set({ 'key' => 'value' })
metadata_set({ 'key' => 'value' }, color: '#ff5252')

Python Example:

metadata_set({ 'key': 'value' })
metadata_set({ 'key': 'value' }, color='ff5252')

metadata_update

Updates metadata that was previously set

Ruby / Python Syntax:

metadata_update(<Metadata>, start, color)
ParameterDescription
MetadataHash or dict of key value pairs to update as metadata.
startNamed parameter, time at which to update metadata. Default is latest metadata.
colorNamed parameter, color to display metadat in the calendar. Default is #003784.

Ruby Example:

metadata_update({ 'key' => 'value' })

Python Example:

metadata_update({ 'key': 'value' })

metadata_input

Prompts the user to set existing metadata values or create new a new one.

Ruby / Python Syntax / Example:

metadata_input()

Settings

COSMOS has several settings typically accessed through the Admin Settings tab. These APIs allow programmatic access to those same settings.

list_settings

Return all the current COSMOS setting name. These are the names that should be used in the other APIs.

Ruby Syntax / Example:

puts list_settings() #=> ["pypi_url", "rubygems_url", "source_url", "version"]

Python Syntax / Example:

print(list_settings()) #=> ['pypi_url', 'rubygems_url', 'source_url', 'version']

get_all_settings

Return all the current COSMOS settings along with their values.

Ruby Syntax / Example:

puts get_all_settings() #=>
# { "version"=>{"name"=>"version", "data"=>"5.11.4-beta0", "updated_at"=>1698074299509456507},
#   "pypi_url"=>{"name"=>"pypi_url", "data"=>"https://pypi.org/simple", "updated_at"=>1698026776574347007},
#   "rubygems_url"=>{"name"=>"rubygems_url", "data"=>"https://rubygems.org", "updated_at"=>1698026776574105465},
#   "source_url"=>{"name"=>"source_url", "data"=>"https://github.com/OpenC3/cosmos", "updated_at"=>1698026776573904132} }

Python Syntax / Example:

print(get_all_settings()) #=>
# { 'version': {'name': 'version', 'data': '5.11.4-beta0', 'updated_at': 1698074299509456507},
#   'pypi_url': {'name': 'pypi_url', 'data': 'https://pypi.org/simple', 'updated_at': 1698026776574347007},
#   'rubygems_url': {'name': 'rubygems_url', 'data': 'https://rubygems.org', 'updated_at': 1698026776574105465},
#   'source_url': {'name': 'source_url', 'data': 'https://github.com/OpenC3/cosmos', 'updated_at': 1698026776573904132} }

get_setting, get_settings

Return the data from the given COSMOS setting. Returns nil (Ruby) or None (Python) if the setting does not exist.

Ruby / Python Syntax:

get_setting(<Setting Name>)
get_settings(<Setting Name1>, <Setting Name2>, ...)
ParameterDescription
Setting NameName of the setting to return

Ruby Example:

puts get_setting('version') #=> "5.11.4-beta0"
puts get_settings('version', 'rubygems_url') #=> ["5.11.4-beta0", "https://rubygems.org"]

Python Example:

print(get_setting('version')) #=> '5.11.4-beta0'
print(get_setting('version', 'rubygems_url')) #=> ['5.11.4-beta0', 'https://rubygems.org']

set_setting

Sets the given setting value.

This API is only accessible externally (not within Script Runner) and requires the admin password.

Ruby / Python Syntax:

set_setting(<Setting Name>, <Setting Value>)
ParameterDescription
Setting NameName of the setting to change
Setting ValueSetting value to set

Ruby Example:

set_setting('rubygems_url', 'https://mygemserver')
puts get_settings('rubygems_url') #=> "https://mygemserver"

Python Example:

set_setting('pypi_url', 'https://mypypiserver')
print(get_settings('pypi_url')) #=> 'https://mypypiserver'

Configuration

Many COSMOS tools have the ability to load and save a configuration. These APIs allow you to programatically load and save the configuration.

config_tool_names

List all the configuration tool names which are used as the first parameter in the other APIs.

Ruby Syntax / Example:

names = config_tool_names()
pp names #=> ["telemetry_grapher", "data_viewer"]

Python Syntax / Example:

names = config_tool_names()
print(names) #=> ['telemetry_grapher', 'data_viewer']

list_configs

List all the saved configuration names under the given tool name.

Ruby / Python Syntax:

list_configs(<Tool Name>)
ParameterDescription
Tool NameName of the tool to retrieve configuration names from

Ruby Example:

configs = list_configs('telemetry_grapher')
pp configs #=> ['adcs', 'temps']

Python Example:

configs = list_configs('telemetry_grapher')
print(configs) #=> ['adcs', 'temps']

load_config

Load a particular tool configuration.

Tool configurations are not fully documented and subject to change between releases. Only modify values returned by load_config and do not change any keys.

Ruby / Python Syntax:

load_config(<Tool Name>, <Configuration Name>)
ParameterDescription
Tool NameName of the tool
Configuration NameName of the configuration

Ruby / Python Example:

config = load_config('telemetry_grapher', 'adcs')
print(config) #=>
# [ {
#   "items": [
#     {
#       "targetName": "INST",
#       "packetName": "ADCS",
#       "itemName": "CCSDSVER",
# ...

save_config

Save a particular tool configuration.

Ruby / Python Syntax:

save_config(<Tool Name>, <Configuration Name>, local_mode)
ParameterDescription
Tool NameName of the tool
Configuration NameName of the configuration
local_modeWhether to save the configuration in local mode

Ruby / Python Example:

save_config('telemetry_grapher', 'adcs', config)

delete_config

Delete a particular tool configuration.

Ruby / Python Syntax:

delete_config(<Tool Name>, <Configuration Name>, local_mode)
ParameterDescription
Tool NameName of the tool
Configuration NameName of the configuration
local_modeWhether to delete the configuration in local mode

Ruby / Python Example:

delete_config('telemetry_grapher', 'adcs')