16 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-17T15:50:07.536950+00:00 | zai-org/GLM-5-FP8 | 1 | 64be47562bf23e82 |
SLICEDBCommands Module Documentation
1. Purpose
This module implements a command pattern architecture for communicating with SLICE DB hardware devices. It provides a hierarchical class structure for constructing, sending, and receiving command packets over a communication interface (ICommunication). The module handles various device operations including power management (voltage/current queries and configuration), network settings (IP, MAC, netmask), device arming/disarming for data acquisition, and device information queries (serial number, firmware versions, time synchronization). Commands are organized by functional category, each inheriting from a category-specific abstract base class that itself inherits from CommandBase.
2. Public Interface
CommandBase (Abstract)
File: CommandBase.cs
Namespace: DTS.DASLib.Command.SLICEDB
Base class for all SLICE DB commands. Inherits from SliceCommandBase.
| Constructor | Description |
|---|---|
CommandBase(DTS.Common.Interface.DASFactory.ICommunication sock) |
Initializes with default timeout and creates a new CommandPacket. |
CommandBase(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec) |
Initializes with specified timeout in milliseconds. |
| Method | Signature | Description |
|---|---|---|
GetCommandPacket() |
protected override CommandPacketBase GetCommandPacket() |
Factory method returning a new CommandPacket. |
GetCommandPacket(byte[] buffer) |
protected override CommandPacketBase GetCommandPacket(byte[] buffer) |
Factory method returning a CommandPacket constructed from byte buffer. |
CommandPacket
File: CommandPacket.cs
Namespace: DTS.DASLib.Command.SLICEDB
Represents a command packet for SLICE DB communication. Inherits from SliceCommandPacketBase.
| Constructor | Description |
|---|---|
CommandPacket() |
Creates an empty command packet. |
CommandPacket(byte[] Bytes) |
Creates a command packet from raw byte data. |
| Enum | Values |
|---|---|
CommandType |
Reserved = 0x00, Diagnostics, GPIO, Information, Network, Power, Arm |
| Method | Signature | Description |
|---|---|---|
GetNextSequenceNumber() |
public override void GetNextSequenceNumber() |
Thread-safe assignment of a globally incrementing sequence number to SequenceNumber. |
ConvertByteToCommandType(byte b) |
public override object ConvertByteToCommandType(byte b) |
Converts a byte to CommandType enum. |
DiagnosticsCommands (Abstract)
File: CalibrationCommands.cs
Namespace: DTS.DASLib.Command.SLICEDB
Base class for diagnostics-related commands.
| Enum | Values |
|---|---|
Measurements |
V1, BatteryVoltage, BatteryChargeCurrent, SliceBusCurrent, SliceBusVoltage |
Commands (protected) |
Reserved = 0x00, QueryOffset = 0x01, SetOffset = 0x02, QueryMultiplier = 0x03, SetMultiplier = 0x04 |
| Constructor | Description |
|---|---|
DiagnosticsCommands(DTS.Common.Interface.DASFactory.ICommunication sock) |
Sets command.Type to CommandType.Diagnostics. |
DiagnosticsCommands(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec) |
Sets command.Type to CommandType.Diagnostics with custom timeout. |
Note: Concrete implementations (QueryOffset, SetOffset, QueryMultiplier, SetMultiplier) are commented out in the source.
PowerCommands (Abstract)
File: PowerCommands.cs
Namespace: DTS.DASLib.Command.SLICEDB
Base class for power-related commands.
| Property | Signature | Description |
|---|---|---|
_Command |
protected abstract Commands _Command { get; } |
Abstract property defining the specific power command. |
| Constructor | Description |
|---|---|
PowerCommands(DTS.Common.Interface.DASFactory.ICommunication sock) |
Sets command.Type to CommandType.Power and initializes command via SetCommand. |
PowerCommands(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec) |
Same as above with custom timeout. |
| Method | Signature | Description |
|---|---|---|
CommandToString |
public override void CommandToString(ref List<List<string>> lines) |
Appends recorder.ConnectString to output. |
ResponseToString |
public override void ResponseToString(ref List<List<string>> lines) |
Appends recorder.ConnectString to output. |
Concrete Power Command Classes
| Class | _Command Value |
Public Property | Description |
|---|---|---|---|
QueryV1VoltageMV |
Commands.QueryV1VoltageMV |
uint V1VoltageMV { get; } |
Queries +V1 input voltage in millivolts. |
QueryBatteryVoltageMV |
Commands.QueryBatteryVoltageMV |
uint BatteryVoltageMV { get; } |
Queries battery voltage in millivolts. Sets MinimumProtocolVersion via GetMinProto(QueryBatteryVoltage). |
QueryBatteryChargeCurrentMA |
Commands.QueryBatteryChargeCurrentMA |
uint BatteryChargeCurrentMA { get; } |
Queries battery charge current in milliamps. |
QuerySliceBusInputCurrentMA |
Commands.QuerySliceBusInputCurrentMA |
uint SliceBusInputCurrentMA { get; } |
Queries SLICE bus current in milliamps. |
QuerySliceBusVoltageMV |
Commands.QuerySliceBusVoltageMV |
uint SliceBusVoltageMV { get; } |
Queries SLICE bus voltage in millivolts. |
SetSliceBusVoltageMV |
Commands.SetSliceBusVoltageMV |
uint SliceBusVoltageMV { get; set; } |
Sets SLICE bus voltage in millivolts. Setter allocates sizeof(uint) parameter buffer. |
Each concrete class provides two constructors matching the base class pattern and overrides WholePackage() to parse response data.
ArmCommands (Abstract)
File: ArmCommands.cs
Namespace: DTS.DASLib.Command.SLICEDB
Base class for arming/disarming commands.
| Property | Signature | Description |
|---|---|---|
_Command |
protected abstract Commands _Command { get; } |
Abstract property defining the specific arm command. |
| Constructor | Description |
|---|---|
ArmCommands(DTS.Common.Interface.DASFactory.ICommunication sock) |
Sets command.Type to CommandType.Arm and initializes command via SetCommand. |
ArmCommands(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec) |
Same as above with custom timeout. |
Concrete Arm Command Classes
| Class | _Command Value |
Public Property | Protocol Limit |
|---|---|---|---|
Arm |
Commands.arm_arm |
None | ProtocolLimitedCommands.Arm |
Disarm |
Commands.arm_disarm |
None | ProtocolLimitedCommands.Arm |
EnableFaultChecking |
Commands.arm_enablefaultchecking |
None | ProtocolLimitedCommands.EnableFaultChecking |
DisableFaultChecking |
Commands.arm_disablefaultchecking |
None | ProtocolLimitedCommands.EnableFaultChecking |
SetRecordingMode |
Commands.arm_setrecordingmode |
byte Value { get; set; } |
ProtocolLimitedCommands.Arm |
SetPostTriggerSec |
Commands.arm_setposttriggersec |
float Value { get; set; } |
ProtocolLimitedCommands.Arm |
SetONOverride |
Commands.arm_setonoverride |
bool Value { get; set; } |
ProtocolLimitedCommands.OnOverride |
SetInvertTriggerPolarity |
Commands.arm_setinverttriggerpolarity |
bool Value { get; set; } |
ProtocolLimitedCommands.Arm |
SetInvertStartPolarity |
Commands.arm_setinvertstartpolarity |
bool Value { get; set; } |
ProtocolLimitedCommands.Arm |
All concrete classes provide two constructors matching the base class pattern.
NetworkCommands (Abstract)
File: NetworkCommands.cs
Namespace: DTS.DASLib.Command.SLICEDB
Base class for network configuration commands.
| Property | Signature | Description |
|---|---|---|
_Command |
protected abstract Commands _Command { get; } |
Abstract property defining the specific network command. |
| Constructor | Description |
|---|---|
NetworkCommands(DTS.Common.Interface.DASFactory.ICommunication sock) |
Sets command.Type to CommandType.Network and initializes command via SetCommand. |
NetworkCommands(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec) |
Same as above with custom timeout. |
Concrete Network Command Classes
| Class | _Command Value |
Public Property | Direction |
|---|---|---|---|
QueryIPAddress |
Commands.QueryIPAddress |
string IPAddress { get; } |
Query |
SetIPAddress |
Commands.SetIPAddress |
string IPAddress { get; set; } |
Set |
QueryNetmask |
Commands.QueryNetmask |
string Netmask { get; } |
Query |
SetNetmask |
Commands.SetNetmask |
string Netmask { get; set; } |
Set |
QueryDefaultRoute |
Commands.QueryDefaultRoute |
string DefaultRoute { get; } |
Query |
SetDefaultRoute |
Commands.SetDefaultRoute |
string DefaultRoute { get; set; } |
Set |
QueryMACAddress |
Commands.QueryMACAddress |
string MACAddress { get; } |
Query |
SetMACAddress |
Commands.SetMACAddress |
string MACAddress { get; set; } |
Set |
Setter behavior: String setters allocate value.Length + 1 bytes for null-terminated parameter.
InformationCommands (Abstract)
File: InformationCommands.cs
Namespace: DTS.DASLib.Command.SLICEDB
Base class for device information commands.
| Property | Signature | Description |
|---|---|---|
_Command |
protected abstract Commands _Command { get; } |
Abstract property defining the specific information command. |
| Constructor | Description |
|---|---|
InformationCommands(DTS.Common.Interface.DASFactory.ICommunication sock) |
Sets command.Type to CommandType.Information and initializes command via SetCommand. |
InformationCommands(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec) |
Same as above with custom timeout. |
Concrete Information Command Classes
| Class | _Command Value |
Public Property | Description |
|---|---|---|---|
QuerySerialNumber |
Commands.QuerySerialNumber |
string SerialNumber { get; } |
Queries device serial number. |
SetSerialNumber |
Commands.SetSerialNumber |
string SerialNumber { get; set; } |
Sets device serial number. |
QueryFirmwareVersion |
Commands.QueryFirmwareVersion |
string FirmwareVersion { get; } |
Queries firmware version. |
QueryTime |
Commands.QueryTime |
DateTime CurrentTime { get; } |
Queries device time (epoch-based, returns DateTime). |
SetTime |
Commands.SetTime |
DateTime CurrentTime { get; set; } |
Sets device time (converts to epoch seconds + microseconds). |
QueryProtocolVersion |
Commands.QueryProtocolVersion |
byte ProtocolVersion { get; } |
Queries protocol version. |
QueryKernelVersion |
Commands.QueryKernelVersion |
string KernelFirmwareVersion { get; } |
Queries kernel firmware version. |
QueryMSPFirmwareVersion |
Commands.QueryMSPFirmwareVersion |
string MSPFirmwareVersion { get; } |
Queries MSP firmware version. |
QueryCalibrationDaysSince1970_01_01 |
Commands.QueryCalibrationDaysSince1970_01_01 |
string CalibrationDaysSince1970_01_01 { get; } |
Queries calibration date. |
SetCalibrationDaysSince1970_01_01 |
Commands.SetCalibrationDaysSince1970_01_01 |
string CalibrationDaysSince1970_01_01 { get; set; } |
Sets calibration date. |
3. Invariants
-
Sequence Number Uniqueness:
CommandPacket.GlobalSequenceNumberis incremented atomically underGlobalSequenceNumberLockto ensure thread-safe unique sequence numbers across all command packets. -
Command Type Assignment: All concrete command classes must set
command.Typeto the appropriateCommandPacket.CommandTypevalue in their constructor (e.g.,PowerCommandssetsCommandType.Power). -
Abstract Command Property: All concrete command classes inheriting from category base classes (
PowerCommands,ArmCommands,NetworkCommands,InformationCommands) must override the abstract_Commandproperty. -
Parameter Buffer Allocation: Setters that modify command parameters must allocate the
command.Parameterbyte array before callingcommand.SetParameter(). -
Protocol Version Enforcement: Certain commands (e.g.,
QueryBatteryVoltageMV,Arm,Disarm) setMinimumProtocolVersionviasock.GetMinProto()to ensure firmware compatibility. -
Time Representation:
QueryTimeandSetTimeuse Unix epoch (1970-01-01) with seconds and microseconds components stored asUInt32values.
4. Dependencies
This Module Depends On:
DTS.Common.ICommunication- Communication interface typesDTS.Common.Enums.DASFactory-DFConstantsAndEnums.CommandStatus,DFConstantsAndEnums.ProtocolLimitedCommandsDTS.Common.Interface.DASFactory-ICommunicationinterfaceSliceCommandBase(inferred from inheritance) - Base class forCommandBaseSliceCommandPacketBase(inferred from inheritance) - Base class forCommandPacketCommandPacketBase(inferred from return types) - Return type ofGetCommandPacket()
External Types Referenced:
CommandReceiveAction- Enum used inWholePackage()return valuesrecorderobject withConnectStringandSerialNumberproperties (inherited from base)
5. Gotchas
-
Duplicate Enum Values in PowerCommands.Commands: The
Commandsenum inPowerCommands.cscontains duplicate values:QuerySliceBusInputCurrentOvercurrentLimitMA = 0x17andQueryBatteryChargeCurrentOvercurrentLimitMA = 0x17SetSliceBusInputCurrentOvercurrentLimitMA = 0x18andSetBatteryChargeCurrentOvercurrentLimitMA = 0x18QuerySliceBusInputCurrentOvercurrentCount = 0x19andQueryBatteryChargeCurrentOvercurrentCount = 0x19SetSliceBusInputCurrentOvercurrentCount = 0x1AandSetBatteryChargeCurrentOvercurrentCount = 0x1A
This appears to be a bug or copy-paste error. No concrete implementations exist for these commands in the provided source.
-
Commented-Out Implementation Classes:
CalibrationCommands.cscontains commented-out stub classes (QueryOffset,SetOffset,QueryMultiplier,SetMultiplier), suggesting incomplete implementation. -
Misleading XML Documentation: Several XML comments are inaccurate:
SetRecordingMode.Value: Comment says "The current Dat0 reg of the SLICE DB" but property isbytefor recording mode.SetPostTriggerSec.Value: Same incorrect comment about "Dat0 reg".SetONOverride.Value: Comment says "The current StatusLED reg of the SLICE DB" but property isbool.SetCalibrationDaysSince1970_01_01.CalibrationDaysSince1970_01_01: Comment says "The serial number of the SLICE DB".QueryProtocolVersion.ResponseToString: Formats string as "Firmware Version" instead of "Protocol Version".QueryKernelVersion.ResponseToStringandQueryMSPFirmwareVersion.ResponseToString: Both format as "Firmware Version" without distinguishing kernel vs MSP.
-
Typo in Enum Value:
SetBattteryVoltageOvervoltageLimitMVhas three 't's in "Batttery" (value0x14). -
Inconsistent Status Checking: Some
WholePackage()implementations checkresponse.Status != StatusNoErrorand return early, while others checkresponse.Status == StatusNoErrorbefore processing. The behavior differs slightly in whether the output property gets set to a default value.