# Specifications

# Mnemonics Database

We store our mnemonic defintions within a flat tab delimited plain text format. The format has evolved over time to support required functionality.

The first row contains the header. The header defines the columns contents. The columns can be in any order.

Each row defines a single mnemonic and is uniquely identified by the `DATA_ID`. `DATA_ID` is also often refered to as `Housekeeping ID` or `HKID` for shorthand.

<p class="callout info">If required, the column must exist but row values may still be empty. Empty values will be default initialized.</p>

<table id="bkmrk-column-type-descript"><thead><tr><th>Column</th><th>Type</th><th>Description</th><th>Required</th><th>Empty Allowed</th><th>Default Value</th></tr></thead><tbody><tr><td>SUB\_SYSTEM</td><td>String</td><td>The subsystem. May be empty. Ex: CDH</td><td>Yes</td><td>Yes</td><td>Empty String</td></tr><tr><td>NAME</td><td>String</td><td>The mnemonic's name. Ex: PowerSupplyCurrent</td><td>Yes</td><td>No</td><td></td></tr><tr><td>DESCRIPTION</td><td>String</td><td>The mnemonic's description</td><td>Yes</td><td>Yes</td><td>Empty String</td></tr><tr><td>ADC\_#</td><td>Integer</td><td>The ADC channel</td><td>No</td><td>Yes</td><td>0</td></tr><tr><td>DATA\_ID</td><td>Integer</td><td>The unique ID</td><td>Yes</td><td>No</td><td></td></tr><tr><td>PACKET\_TYPE</td><td>Integer</td><td>The packet type or CCSDS Application ID</td><td>Yes</td><td>No</td><td></td></tr><tr><td>PACKET\_SUBTYPE</td><td>Integer</td><td>Packet subtype</td><td>No</td><td>Yes</td><td>0</td></tr><tr><td>PACKET\_NAME</td><td>String</td><td>The name of the packet the mnemonic belongs to</td><td>No</td><td>Yes</td><td>Empty String</td></tr><tr><td>APPLY\_WHEN</td><td>String</td><td>Apply when condition of the format: HKID=RANGE.</td><td>No</td><td>Yes</td><td>No apply when conditions</td></tr><tr><td>DECODE\_TYPE</td><td>Integer</td><td>The decoder type</td><td>Yes</td><td>No</td><td></td></tr><tr><td>DECODE\_ID1</td><td>Integer</td><td>Decode ID 1</td><td>Yes</td><td>No</td><td></td></tr><tr><td>DECODE\_ID2</td><td>Integer</td><td>Decode ID 2</td><td>Yes</td><td>No</td><td></td></tr><tr><td>DECODE\_ID3</td><td>Integer</td><td>Decode ID 3</td><td>Yes</td><td>No</td><td></td></tr><tr><td>DECODE\_ID4</td><td>Integer</td><td>Decode ID 4</td><td>Yes</td><td>No</td><td></td></tr><tr><td>CLOCK</td><td>String</td><td>The clock's name</td><td>No</td><td>Yes</td><td>Empty String</td></tr><tr><td>RAW\_FMT</td><td>String</td><td>The raw format</td><td>Yes</td><td>No</td><td></td></tr><tr><td>ENG\_FMT</td><td>String</td><td>The string formatting when engineering conversion is applied</td><td>Yes</td><td>No</td><td></td></tr><tr><td>ENG\_EQ\_TYPE</td><td>Integer</td><td>The type of conversion to apply to the raw value</td><td>Yes</td><td>No</td><td></td></tr><tr><td>ENG\_K1</td><td>Double</td><td>Eng Coefficient 1</td><td>Yes</td><td>No</td><td></td></tr><tr><td>ENG\_K2</td><td>Double</td><td>Eng Coefficient 2</td><td>Yes</td><td>No</td><td></td></tr><tr><td>SCI\_UNITS</td><td>String</td><td>The science units</td><td>Yes</td><td>Yes</td><td></td></tr><tr><td>SCI\_FMT</td><td>String</td><td>The string formatting when science conversion is applied</td><td>Yes</td><td>No</td><td></td></tr><tr><td>SCI\_EQ\_TYPE</td><td>Integer</td><td>The type of conversion to apply</td><td>Yes</td><td>No</td><td></td></tr><tr><td>SCI\_FROM\_ENG</td><td>bool</td><td>If true, the engineering conversion will be applied before applying the science conversion</td><td>Yes</td><td>No</td><td></td></tr><tr><td>SCI\_K1</td><td>Double</td><td>Science Coefficient 1</td><td>Yes</td><td>No</td><td></td></tr><tr><td>SCI\_K2</td><td>Double</td><td>Science Coefficient 2</td><td>Yes</td><td>No</td><td></td></tr><tr><td>SCI\_K3</td><td>Double</td><td>Science Coefficient 3</td><td>Yes</td><td>No</td><td></td></tr><tr><td>SCI\_K4</td><td>Double</td><td>Science Coefficient 4</td><td>Yes</td><td>No</td><td></td></tr><tr><td>SCI\_K5</td><td>Double</td><td>Science Coefficient 5</td><td>Yes</td><td>No</td><td></td></tr><tr><td>SCI\_K6</td><td>Double</td><td>Science Coefficient 6</td><td>Yes</td><td>No</td><td></td></tr><tr><td>SCI\_K7</td><td>Double</td><td>Science Coefficeint 7</td><td>Yes</td><td>No</td><td></td></tr><tr><td>SCI\_K8</td><td>Double</td><td>Science Coefficient 8</td><td>Yes</td><td>No</td><td></td></tr><tr><td>MUX\_CH</td><td>Integer</td><td>The corresponding mux channel for this mnemonic</td><td>No</td><td>Yes</td><td></td></tr><tr><td>LIMIT\_TYPE\_1</td><td>Integer</td><td>Bit pattern defining the limit configuration</td><td>No</td><td>Yes</td><td></td></tr><tr><td>YELLOW\_LIMIT\_1</td><td>Double</td><td>The yellow limit value</td><td>No</td><td>Yes</td><td></td></tr><tr><td>RED\_LIMIT\_1</td><td>Double</td><td>The red limit value</td><td>No</td><td>Yes</td><td></td></tr><tr><td>LIMIT\_TYPE\_2</td><td>Integer</td><td>Bit pattern defining the limit configuration</td><td>No</td><td>Yes</td><td></td></tr><tr><td>YELLOW\_LIMIT\_2</td><td>Double</td><td>The yellow limit value</td><td>No</td><td>Yes</td><td></td></tr><tr><td>RED\_LIMIT\_2</td><td>Double</td><td>The red limit value</td><td>No</td><td>Yes</td><td></td></tr><tr><td>LIMITS</td><td>JSON</td><td>The limit set definition</td><td>No</td><td>Yes</td><td></td></tr><tr><td>EXTRA\_1</td><td>String</td><td>Used for various purposes depending on the SCI\_EQ\_TYPE</td><td>No</td><td>Yes</td><td></td></tr><tr><td>XINA\_MINE\_TYPE</td><td>Integer</td><td>The XINA mining mode</td><td>No</td><td>Yes</td><td></td></tr><tr><td>XINA\_MINE\_RAW</td><td>bool</td><td>Whether or not to mine the RAW values</td><td>No</td><td>Yes</td><td></td></tr><tr><td>XINA\_MINE\_ENG</td><td>bool</td><td>Whether or not to mine the ENG values</td><td>No</td><td>Yes</td><td></td></tr><tr><td>DISCRETE\_LABELS</td><td>String</td><td>Maps a value to string</td><td>No</td><td>Yes</td><td></td></tr><tr><td>BUNDLE\_ID</td><td>Integer</td><td>The XINA bundle ID</td><td>No</td><td>Yes</td><td></td></tr></tbody></table>

# Metadata File



# Mnemonic Limit Definitions

This page defines the format of the limit definitions used by the Data Viewer application.

A Limit Definition is a JSON object that describes limit thresholds for a single mnemonic telemetry value. The operator/user will be notified when a limit is triggered.

The top level object supports the following fields:

<table id="bkmrk-field-required-value"><thead><tr><th>Field</th><th align="right">Required</th><th>Value Format</th><th>Meaning</th></tr></thead><tbody><tr><td>`limits`</td><td align="right">Yes</td><td>JSON Array</td><td>Array of 1 or more limit objects. Each object defines a set of limit thresholds. If a Limit Definition does not define a context mnemonic, the array should contain a single object.</td></tr><tr><td>`cm`</td><td align="right">No</td><td>String or integer</td><td>Context Mnemonic. The optional mnemonic that is used to determine if a limit should be checked. For example, you may want to only check a current monitor mnemonic's limit when a temperature is between 25 and 30 celsius. In that case, the temperature mnemonic would be the context mnemonic. Can be provided as the mnemonic name or numeric ID e.g. `MMC.HK:WRP_CURRENT` or `5204`.</td></tr></tbody></table>

Each limit object supports the following fields:

<table id="bkmrk-field-required-value-1"><thead><tr><th>Field</th><th align="right">Required</th><th>Value Format</th><th>Meaning</th></tr></thead><tbody><tr><td>`cr`</td><td align="right">No</td><td>Single number or range syntax</td><td>Context range. Only used if `cm` is provided at the top level. If the context mnemonic equals this value or falls within this range, the limit will be checked. If `cm` is provided but `cr` is not, the limit object will be used as the "default" limit. Single number example: `1.5` the limit will be used when the context mnemonic's value equals `1.5.`. Range example: `"5.2..10.3"` the limit will be used when the context mnemonic's value falls between 5.2 and 10.3, inclusive.</td></tr><tr><td>`ec`</td><td align="right">No</td><td>Integer</td><td>Excursion count. Number of consecutive telemetry values that must exceed a threshold before the limit is triggered. Defaults to 2 if not provided.</td></tr><tr><td>`yh`</td><td align="right">No</td><td>Number</td><td>Yellow high threshold. Triggers a yellow high alarm when the telemetry value is greater than or equal to this value for the required excursion count.</td></tr><tr><td>`yl`</td><td align="right">No</td><td>Number</td><td>Yellow low threshold. Triggers a yellow low alarm when the telemetry value is less than or equal to this value for the required excursion count.</td></tr><tr><td>`rh`</td><td align="right">No</td><td>Number</td><td>Red high threshold. Triggers a red high alarm when the telemetry value is greater than or equal to this value for the required excursion count.</td></tr><tr><td>`rl`</td><td align="right">No</td><td>Number</td><td>Red low threshold. Triggers a red low alarm when the telemetry value is less than or equal to this value for the required excursion count.</td></tr></tbody></table>

**Notes:**

- At least 1 of the threshold values must be defined
- Threshold will be compared against the telemetry value's converted/science value

#### Example A:

- Limit definition for a `BOARD_TEMP` mnemonic
- Single limit with no context mnemonic
- Yellow high undefined
- Excursion count of 5 means the value must exceed the threshold for 5 consecutive values

```json
{
  "limits": [
    {
      "ec": 5,
      "rh": 20,
      "yl": -5,
      "rl": -12
    }
  ]
}

```

The below visualizes how the limit thresholds are evaluated:

```
y-axis: Telemetry value
      ^
      |
      |   RED HIGH alarm zone
      |   value >= 20 for 5 consecutive samples
  20  +------------------------------------------------ rh
      |
      |
      | 
      |   Nominal range
      |
      |
      |
  -5  +------------------------------------------------ yl
      |   YELLOW LOW alarm zone
      |   value =< -5 for 5 consecutive samples
      |
 -12  +------------------------------------------------ rl
      |   RED LOW alarm zone
      |   value =< -12 for 5 consecutive samples
      |
      +----------------------------------------------------> x-axis: time / samples
      |

```

#### Example B:

- Limit definition for a `CURRENT_MONITOR` mnemonic
- `BOARD_TEMP` context mnemonic is used to determine which limit should be checked
- Defines a "default" limit that is used when none of the context ranges are satisfied
- Defines a limit with a context range using the range syntax. If the `BOARD_TEMP` is \[0, 25\], then this limit will be used.

```json
{
  "cm": "BOARD_TEMP",
  "limits": [
    {
      "rh": 2.5,
      "yh": 2.0
    },
    {
      "cr": "0..25",
      "ec": 3,
      "rh": 2.3,
      "yh": 1.8
    }
  ]
}

```

#### Example C:

- Limit definition for a `VOLTAGE_MONITOR` mnemonic
- `MODE` context mnemonic is used to determine which limit should be checked
- If `MODE`'s value does not match any of the configured limits' context ranges, no limit will be checked. Note how the context range value is provided as a number.

```json
{
  "cm": "MODE",
  "limits": [
    {
      "cr": 0,
      "rh": 1.5,
      "yh": 1.0
    },
    {
      "cr": 1,
      "ec": 2,
      "rh": 5.0,
      "yh": 4.5
    },
    {
      "cr": 2,
      "ec": 4,
      "rh": 10.0,
      "yh": 9.5
    }
  ]
}

```

# Expected Values Definition

The Expected Values Definition file is a CSV file that is used by the c\_expectedvaluechk Python tool.