ait.core.cmd module

AIT Commands

The ait.core.cmd module provides commands and command dictionaries. Dictionaries contain command and argument definitions.

class ait.core.cmd.ArgDefn(*args, **kwargs)

Bases: ait.core.json.SlotSerializer, object

ArgDefn - Argument Definition

Argument Definitions encapsulate all information required to define a single command argument. This includes the argument name, its description, units, type, byte position within a command, name-value enumerations, and allowed value ranges. Name, type, and byte position are required. All others are optional.

A fixed argument (fixed=True) defines a fixed bit pattern in that argument’s byte position(s).

__init__(*args, **kwargs)

Creates a new Argument Definition.

decode(bytes)

Decodes the given bytes according to this AIT Argument Definition.

encode(value)

Encodes the given value according to this AIT Argument Definition.

slice(offset=0)

Returns a Python slice object (e.g. for array indexing) indicating the start and stop byte position of this Command argument. The start and stop positions may be translated by the optional byte offset.

validate(value, messages=None)

Returns True if the given Argument value is valid, False otherwise. Validation error messages are appended to an optional messages array.

bytes
desc
enum

The argument enumeration.

fixed
name
nbytes

The number of bytes required to encode this argument.

range
startbit

The argument start bit in the word

startword

The argument start word in the command

type

The argument type.

units
value
class ait.core.cmd.Cmd(defn, *args, **kwargs)

Bases: object

Cmd - Command

Commands reference their Command Definition and may contain arguments.

__init__(defn, *args, **kwargs)

Creates a new AIT Command based on the given command definition and command arguments. A Command may be created with either positional or keyword arguments, but not both.

encode(pad=106)

Encodes this AIT command to binary.

If pad is specified, it indicates the maximum size of the encoded command in bytes. If the encoded command is less than pad, the remaining bytes are set to zero.

Commands sent to ISS payloads over 1553 are limited to 64 words (128 bytes) with 11 words (22 bytes) of CCSDS overhead (SSP 52050J, Section 3.2.3.4). This leaves 53 words (106 bytes) for the command itself.

validate(messages=None)

Returns True if the given Command is valid, False otherwise. Validation error messages are appended to an optional messages array.

argdefns

The command argument definitions.

desc

The command description.

name

The command name.

opcode

The command opcode.

subsystem

The subsystem to which this command applies.

class ait.core.cmd.CmdDefn(*args, **kwargs)

Bases: ait.core.json.SlotSerializer, object

CmdDefn - Command Definition

Command Definitions encapsulate all information required to define a single command. This includes the command name, its opcode, subsystem, description and a list of argument definitions. Name and opcode are required. All others are optional.

__init__(*args, **kwargs)

Creates a new Command Definition.

staging_required()
toJSON()
validate(cmd, messages=None)

Returns True if the given Command is valid, False otherwise. Validation error messages are appended to an optional messages array.

argdefns
args

The argument definitions to this command (excludes fixed arguments).

argsize

The total size in bytes of all the command arguments.

ccsds
desc
name
nargs

The number of arguments to this command (excludes fixed arguments).

nbytes

The number of bytes required to encode this command.

Encoded commands are comprised of a two byte opcode, followed by a one byte size, and then the command argument bytes. The size indicates the number of bytes required to represent command arguments.

opcode

Returns the opcode for the given command.

subsystem
title
class ait.core.cmd.CmdDict(*args, **kwargs)

Bases: dict

Command Dictionaries provide a Python dictionary (i.e. hashtable) interface mapping Command names to Command Definitions.

__init__(*args, **kwargs)

Creates a new Command Dictionary from the given command dictionary filename.

add(defn)

Adds the given Command Definition to this Command Dictionary.

create(name, *args, **kwargs)

Creates a new AIT command with the given arguments.

decode(bytes)

Decodes the given bytes according to this AIT Command Definition.

load(content)

Loads Command Definitions from the given YAML content into into this Command Dictionary. Content may be either a filename containing YAML content or a YAML string.

Load has no effect if this Command Dictionary was already instantiated with a filename or YAML content.

toJSON()
ait.core.cmd.YAMLCtor_ArgDefn(loader, node)
ait.core.cmd.YAMLCtor_CmdDefn(loader, node)
ait.core.cmd.getDefaultCmdDict(reload=False)
ait.core.cmd.getDefaultDict(reload=False)
ait.core.cmd.getDefaultDictFilename()
ait.core.cmd.getDefaultSchema()
ait.core.cmd.getMaxCmdSize()

Returns the maximum size TReK command in bytes

Converts from words to bytes (hence the *2) and removes 1 word for CCSDS header (-1)