Previous How to start a COSMOS config.
Telemetry screens are dialogs that are created to show telemetry points to the operator. They are simple, hand-written text files that are easy to manipulate and organize. In this tutorial we'll create a screen to show the blink delay and then we'll set some limits on the delay to show what happens if a telemetry point starts getting out of control.
C:\data\blink\cosmos\config\targets>cd BLINK\ C:\data\blink\cosmos\config\targets\BLINK>mkdir screens C:\data\blink\cosmos\config\targets\BLINK>cd screens C:\data\blink\cosmos\config\targets\BLINK\screens>gvim soh.txt
SCREEN AUTO AUTO 0.5 VERTICAL TITLE "Blink State of Health" LABELVALUE BLINK SOH RECEIVED_TIMEFORMATTED WITH_UNITS 30 LABELVALUE BLINK SOH RECEIVED_COUNT LABELVALUE BLINK SOH DELAY END
On the Launcher open Telemetry Viewer and Display the SOH telemetry screen.
Now let's put some limits on the delay value. Open C:\data\blink\cosmos\config\targets\BLINK\cmd_tlm\tlm.txt.
TELEMETRY blink soh BIG_ENDIAN "State of health of the blink application." APPEND_ITEM length 8 UINT "Packet size so COSMOS can read the serial port." APPEND_ID_ITEM pktid 8 UINT 1 "Packet id so COSMOS can identify the packet and store it into the internal database." APPEND_ITEM delay 8 UINT "Current delay value (ms) between LED blinks." LIMITS DEFAULT 3 ENABLED 0 50 150 200
The values after "LIMITS DEFAULT 3 ENABLED" setup:
- RED LOW: 0
- YELLOW LOW: 50
- YELLOW HIGH: 150
- RED HIGH: 200
Obviously, we don't care how fast the LED blinks but these limits show how to configure COSMOS to respond if you do have a piece of hardware that can get too hot.
Now that there are limits defined for a telemetry point let's see what happens when a value goes out of bounds. First, add them to the tlm screen so we can see it visually. In the soh.txt telemetry screen we created above, replace
LABELVALUE BLINK SOH DELAY
LABELVALUELIMITSBAR BLINK SOH DELAY
In order to read the config file you need to close the SOH screen and reopen it from TlmViewer. Open the SOH tlm screen and look at the screen again. The limits bar shows a "thermometer bar" from red to yellow, with green in the middle and then yellow and red again. Our current value is 250, so the blink delay is "out of limits" and there is a pointer all the way to the right on the bar, showing the current value.
Configure a limits response. It's as simple as another line in the tlm.txt file on the delay telemetry point.
LIMITS_RESPONSE delay_limits_response.rb 10
C:\data\blink\cosmos\config\targets>cd BLINK\ C:\data\blink\cosmos\config\targets\BLINK>mkdir screens C:\data\blink\cosmos\config\targets\BLINK>cd screens C:\data\blink\cosmos\config\targets\BLINK\lib>gvim delay_limits_response.rb
# This file implements a class to handle responses to limits state changes. require 'cosmos/packets/limits_response' # DelayLimitsResponse class # # This class handles a limits response # class DelayLimitsResponse < Cosmos::LimitsResponse def call(packet, item, old_limits_state) case item.limits.state when :RED_HIGH cmd('BLINK', 'DELAY', 'DELAY' => 149) when :RED_LOW cmd('BLINK', 'DELAY', 'DELAY' => 51) end end end # class DelayLimitsResponse