Mercury2 Hardware Manager  1.0dev
The hardware manager component of the Mercury2 ground station suite.
 All Classes Namespaces Functions Variables Pages
hwm.command.metadata Namespace Reference

This module contains functions used to build a command's meta-data dictionary. More...

Classes

class  InvalidCommandMetadata
 
class  InvalidCommandAddress
 

Functions

def build_metadata_dict
 Builds the command meta-data structure for a specific command. More...
 

Detailed Description

This module contains functions used to build a command's meta-data dictionary.

This dictionary defines how to reach a specific command, what parameters it accepts, and whether or not it requires an active session to run.

Periodically, a command's meta-data dictionary is loaded by the system state packager which then serializes it and sends it to the user interface. The user interface will use the metadata to build an appropriate form to allow the user to easily execute the command.

Function Documentation

def hwm.command.metadata.build_metadata_dict (   command_parameters,
  command_id,
  command_handler_name,
  requires_active_session = True,
  dangerous = True,
  schedulable = False,
  use_as_initial_value = False 
)

Builds the command meta-data structure for a specific command.

Command handlers use this function to build the command meta-data structures for the commands they service. For the most part, all command meta-data structures must be built using this command. If a command meta-data structure does not conform to this format, an error will be generated by the status packager or the user interface won't be able to construct a form for it.

Exceptions
Maythrow InvalidCommandParameters in the event that the supplied parameter dictionary isn't valid.
Maythrow InvalidCommandAddress if neither command_handler_name or device_id are set.
Parameters
command_parametersAn array of dictionaries containing the parameters that the command accepts along with any basic restrictions on the parameter value. Currently, the following types and restrictions are supported:
  • type: string
    • minlength - The min length of the string (integer)
    • maxlength - The max length of the string (integer)
  • type: number
    • minvalue - The minimum value of the number (inclusive, integer)
    • maxvalue - The maximum value of the number (inclusive, integer)
    • integer - Whether or not the number must be an integer (boolean)
  • type: boolean
  • type: select
    • multiselect - Whether or not multiple options can be selected (boolean)
    • options - An array containing valid [title, value] pairs for the argument (required for select, array)
  • Any Type
    • required - Whether or not the argument is required to submit the command (boolean)
    • description - A description of the argument (string)
    • title - A short title for the argument (required, string)

If a restriction is left blank, the user interface will use a default value. Unrecognized/unsupported attributes will be ignored (but allowed).

Parameters
command_idThe ID of the command. This must be unique per command handler.
command_handler_nameThe name of the system command handler that the command is located in. This is used by user interface to address user commands to the appropriate handler. If the command is a device command, then this will be the device ID.
requires_active_sessionWhether or not the command requires an active session to be executed. If the command is a system command, then the command handler must perform its own validations on the session. If the command is a device command, the command parser will make sure that the user has an active session with a pipeline that uses the hardware device before executing the command (and the command handler may perform any additional validations on its own if needed).
dangerousIf the command is dangerous, it could possibly dangerously modify the ground station state (e.g. turn of devices, delete sessions, etc.). This flag will cause the user interface to restrict access to the command by default (which can be overridden if desired).
schedulableIndicates that the command can be scheduled using the reservation scheduling service (if the active pipeline supports it). If it can, the user interface will use this to build a form to schedule this command during the reservation process.
use_as_initial_valueIf set, the user interface will use this command when building the device or system's initial state configuration forms during the reservation process. This can be used, for example, to set the initial frequency that a radio should be tunned to.
Returns
Returns a dictionary containing the command meta-data.