Files
DP44/docs/ai/DataPRO/TDASCommands.md
2026-04-17 14:55:32 -04:00

6.4 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/TDASCommands/TestTriggerCommands.cs
DataPRO/TDASCommands/CommandBase.cs
DataPRO/TDASCommands/TDASCommandPacketBase.cs
2026-04-17T15:49:45.052194+00:00 zai-org/GLM-5-FP8 1 b0635eb6f7e0c765

TDAS Command Module Documentation

1. Purpose

This module provides the command infrastructure for communicating with TDAS (Test Data Acquisition System) hardware. It implements a command/response protocol for sending control commands (such as test triggers) and receiving data, handling packet construction, response parsing, communication throttling, and diagnostic logging. The module supports both single-module and broadcast command modes for controlling test trigger states (ARM, STATUS, OFF) across TDAS recording devices.


2. Public Interface

TestTrigger (class)

Executes test trigger commands against a specific TDAS module.

Constructors:

  • TestTrigger(DTS.Common.Interface.DASFactory.ICommunication sock) — Creates command with default 30000ms timeout.
  • TestTrigger(DTS.Common.Interface.DASFactory.ICommunication sock, int msTimeout) — Creates command with custom timeout.

Properties:

  • int ModuleIndex — Gets or sets the target module index.
  • SubCommandValues SubCommand — Gets or sets the subcommand (ARM, STATUS, OFF).
  • StatusValues TriggerStatus — Gets the trigger status from the response (ARMED, OFF).

Nested Enums:

  • SubCommandValues { ARM, STATUS, OFF }
  • StatusValues { ARMED, OFF }

TestTriggerBroadcast (class)

Executes broadcast test trigger commands to TDAS modules.

Constructors:

  • TestTriggerBroadcast(DTS.Common.Interface.DASFactory.ICommunication sock, int moduleIndex)
  • TestTriggerBroadcast(DTS.Common.Interface.DASFactory.ICommunication sock, int moduleIndex, int msTimeout)

Properties:

  • TestTrigger.SubCommandValues SubCommand — Gets or sets the subcommand.

CommandBase (class)

Base class for TDAS commands providing execution, response handling, and logging.

Constructors:

  • CommandBase(DTS.Common.Interface.DASFactory.ICommunication sock)
  • CommandBase(DTS.Common.Interface.DASFactory.ICommunication sock, int timeoutMillisec)

Properties:

  • string ResponseData — Lazy-loaded response data; calls ProcessData() on first access.
  • bool SingleModuleCommand — Gets or sets whether this is a single-module command.
  • string RackSerialNumber — Gets or sets the rack serial number (default: "NONE").

Methods:

  • bool IsErrored() — Returns true if response starts with "err" (case-insensitive).
  • string GetErrorString() — Extracts error message from response starting at "ERR" + 4 characters.
  • void SyncExecute() — Executes command with semaphore-based throttling.
  • static void InitializeSemaphore(double delay, int spots) — Initializes throttling parameters.
  • static void RollLog() — Triggers log file rollover.

TDASCommandPacketBase (class)

Builds and parses TDAS command packets.

Constructors:

  • TDASCommandPacketBase(CommandString cs) — Creates packet from a command string.
  • TDASCommandPacketBase(byte[] buffer, CommandPacketBase command) — Creates packet from response bytes.

Properties:

  • bool RackCommand — Gets or sets whether this is a rack-level command.
  • bool SingleModuleCommand
  • string RackSerialNumber
  • int ModuleIndex — Must be < 10; throws Exception otherwise. Setting this sets RackCommand = false.
  • bool AllModule
  • bool RebuildBytes — When true, forces byte rebuild on serialization.
  • bool ExpectsData
  • bool ExpectsMultipleLines
  • int LinesExpected
  • bool UseMDBMode — Enables MDB (Memory Data Block) parsing mode.
  • bool MonitorDataMode
  • bool RealtimeCommand
  • byte CharWait — Character wait value (default: 0x01).
  • int ReplyWait — Reply wait value (default: 30).

Methods:

  • byte[] ToBytes() — Serializes packet to 536-byte CDB format.
  • string GetCommandString(int index) — Gets command string at index.
  • CommandString GetCommandStringObject(int index) — Gets CommandString object at index.
  • string ToCommandString() — Returns ASCII command string from bytes.
  • int GetExpectedBytes() — Returns expected data bytes in MDB mode.
  • short[] GetData() — Extracts data from MDB blocks.
  • PacketState VerifyPacket(byte[] Bytes) — Validates response packet completeness.
  • void GetNextSequenceNumber() — Assigns next global sequence number (thread-safe).
  • void ComputeCRCs() — No-op in this implementation.

CommandString (abstract class)

Base class for defining command strings.

Properties:

  • virtual string RequiredResponseString — Required response marker for packet completion validation.
  • bool ExpectsData — Default: true.
  • bool ExpectsMultipleLines
  • int LinesExpected
  • bool RackCommand — Default: true.
  • bool SingleModuleCommand
  • string RackSerialNumber
  • int Length — Cached byte length of command.

Methods:

  • virtual byte[] GetParameters() — Override to provide command parameters; default returns empty array.
  • string GetCommandPortion() — Returns the command string.
  • string GetCommandDescription() — Returns command description.
  • byte[] GetBytes() — Serializes command with parameters and CRLF terminator.
  • void RebuildBytes() — Clears cached bytes to force rebuild.

CommandPacketException (class)

Exception for command packet errors.

Constructor:

  • CommandPacketException(ERROR_CODES errorCode, string description)

Properties:

  • ERROR_CODES ErrorCode — Returns UNKNOWN if not set.

Enum:

  • ERROR_CODES { TOO_MANY_COMMANDS = 0, TOO_MANY_BYTES = 1, UNKNOWN = 2 }

3. Invariants

  1. Module Index Constraint: ModuleIndex must be less than 10; otherwise TDASCommandPacketBase throws an Exception.
  2. Command Limits: Maximum of 1 command per packet (MAX_CMD = 1) and maximum 512 bytes per command (MAX_CMD_SIZE = 512).
  3. Packet Size: CDB packet size is fixed at 536 bytes (CDB_SIZE = 536).
  4. MDB Block Sizes: MDB_BLOCK_SIZE = 52, DMA_SIZE = 1024, DMA_BLOCK_SIZE = 1076.
  5. Default Timeout: Commands default to 30000ms timeout.
  6. Default Throttling: Semaphore defaults to 3 concurrent spots with 100ms delay.
  7. Status Packet Structure: TDAS status packet is 20 bytes, ending with 4 bytes of 0xFF at positions 16-19.
  8. Sequence Numbers: