OpenC3/cosmos

View on GitHub
openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/screens/commanding.txt

Summary

Maintainability
Test Coverage
SCREEN AUTO AUTO 0.5

TITLE "<%= target_name %> Commanding Examples"

LABELVALUE <%= target_name %> HEALTH_STATUS COLLECTS
LABELVALUE <%= target_name %> HEALTH_STATUS COLLECT_TYPE
LABELVALUE <%= target_name %> HEALTH_STATUS DURATION

MATRIXBYCOLUMNS 2
  VERTICALBOX "Send Collect Command:"
    HORIZONTAL
      LABEL "Type: "
      # The ampersand '&' indicates a line continuation
      NAMED_WIDGET COLLECT_TYPE &
        COMBOBOX NORMAL SPECIAL
    END
    HORIZONTAL
      LABEL "  Duration: "
      NAMED_WIDGET DURATION TEXTFIELD 12 "10.0"
    END
    # This is an example of using a variable named 'type'. You can operate on variables with Javascript code.
    # All OpenC3 commands (api.cmd) must be separated by double semicolons ';;'. All code separated by semicolons is evaluated together.
    # Note: you can also request and use telemetry in screens using Javascript Promises, e.g.
    # api.tlm('INST2 PARAMS VALUE3', 'RAW').then(dur => api.cmd('INST2 COLLECT with TYPE '+type+', DURATION '+dur))"
    # The tlm() function returns a Promise which is resolved with then() at which point we send the command with the parameter
    # The plus '+' symbol indicates string concatenation with newlines.
    # NOTE: Both lines must use the same quote character: ' or "
    BUTTON 'Start Collect' "var type=screen.getNamedWidget('COLLECT_TYPE').text();" +
      "var dur=screen.getNamedWidget('DURATION').text();" +
      # You can have comments between string concatenations
      "api.cmd('<%= target_name %> COLLECT with TYPE '+type+', DURATION '+dur)"
  END

  VERTICALBOX "Parameter-less Commands:"
    HORIZONTAL
      NAMED_WIDGET GROUP RADIOGROUP 1 # Select 'Clear' initially, 0-based index
        RADIOBUTTON 'Abort'
        RADIOBUTTON 'Clear'
      END
      NAMED_WIDGET CHECK CHECKBUTTON 'Ignore Hazardous Checks' # No option is by default UNCHECKED
    END
    BUTTON 'Send' "screen.getNamedWidget('GROUP').selected() === 0 ? " +
      "api.cmd('<%= target_name %> ABORT') : (screen.getNamedWidget('CHECK').checked() ? " +
      "api.cmd_no_hazardous_check('<%= target_name %> CLEAR') : api.cmd('<%= target_name %> CLEAR'))"
  END

  VERTICALBOX "Run Script:"
    NAMED_WIDGET SCRIPTNAME COMBOBOX collect.py checks.py
    NAMED_WIDGET BG CHECKBUTTON 'Background'
    # The backslash '\' character indicates string concatenation without newlines.
    # NOTE: Both lines must use the same quote character: ' or "
    BUTTON 'Run Script' "var script=screen.getNamedWidget('SCRIPTNAME').text();" \
      "var ctype=screen.getNamedWidget('COLLECT_TYPE').text();" \
      # Set some environment variables to be used by the script as ENV['TYPE']
      # See INST2/procedures/checks.py for an example of usage
      "var env = {}; env['TYPE'] = ctype;" \
      "runScript('<%= target_name %>/procedures/'+script, !screen.getNamedWidget('BG').checked(), env)"
  END

  VERTICALBOX "Date / Time Chooser"
    HORIZONTAL 5
      NAMED_WIDGET DATE Date "Input Date"
      NAMED_WIDGET TIME Time
    END

    BUTTON 'Alert' "var date=screen.getNamedWidget('DATE').text();" +
      "var time=screen.getNamedWidget('TIME').text();" +
      # You can have comments between string concatenations
      "alert('DATE:'+date+' TIME:'+time)"
  END
END