16 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T03:46:47.989856+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | fe72794d5a98f1f5 |
SLICE Command Module Documentation
1. Purpose
This module implements the command-layer abstraction for the SLICE protocol, providing strongly-typed command classes for interacting with SLICE hardware devices. It defines a hierarchy of command classes grouped by functional domain—stack setup, stack utility, firmware update, and PTP 1588 time synchronization—each inheriting from CommandBase. Commands are serialized into CommandPacket instances, which handle protocol-level details such as sequence numbering, type identification, and parameter encoding. The module serves as the primary interface between application logic and the underlying communication layer (ICommunication), enabling structured, type-safe command execution and response parsing.
2. Public Interface
Core Base Classes
-
Commands_Stack_Setup(abstract class)
Base class for stack setup commands. Setscommand.Type = CommandPacket.CommandType.StackSetup.
Constructors:Commands_Stack_Setup(ICommunication sock)Commands_Stack_Setup(ICommunication sock, int TimeoutMillisec)
-
Commands_Stack_Utility(abstract class)
Base class for stack utility commands (e.g., flash operations, power control). Setscommand.Type = CommandPacket.CommandType.StackUtility.
Defines internalCommandsenum with values likeBusPowerControl,ForceEnumeration, etc.
Constructors:Commands_Stack_Utility(ICommunication sock)Commands_Stack_Utility(ICommunication sock, int TimeoutMillisec)
-
FirmwareUpdateCommands(abstract class)
Base class for firmware update commands. Setscommand.Type = CommandPacket.CommandType.FirmwareUpdate.
Defines internalCommandsenum with values likeQueryFirmwareUpdateBlockSize,ProgramFirmwareUpdateBlock,Load_SliceProStackFirmwareImage, etc.
DefinesFirmwareModeenum (FW,BL,BLL).
Constants:MAX_FILE_ID = 30,MAX_FILE_LENGTH = 400.
Abstract property_Commandmust be implemented by derived classes.
Constructors:FirmwareUpdateCommands(ICommunication sock)FirmwareUpdateCommands(ICommunication sock, int TimeoutMillisec)
-
Ptp1588Commands(abstract class)
Base class for PTP 1588 time synchronization commands. Setscommand.Type = CommandPacket.CommandType.Ptp1588.
Defines enums:PtpClockType,PtpMode,PtpDelayMechanism,PtpSyncStatus,PtpTimestampUnits.
Defines internalCommandsenum (e.g.,SetMode,GetTime,SetAutoTriggerTime).
Static helper:ToTimestampString(uint s, uint ns)→ formats as"s.fffffffff".
Abstract property_Commandmust be implemented.
Constructors:Ptp1588Commands(ICommunication sock)Ptp1588Commands(ICommunication sock, int TimeoutMillisec)
Concrete Command Classes
Stack Utility Commands
-
BusPowerControl
Controls bus power on/off.
Properties:PowerOn: bool— sets parameter[0] to1(on) or0(off).
Constructors:BusPowerControl(ICommunication sock)BusPowerControl(ICommunication sock, int TimeoutMillisec)
Overrides:CommandToString(),ResponseToString().
-
ForceEnumeration
Triggers enumeration of connected SLICE modules.
Properties:SLICECount: int— populated from response parameter[0] on success.
Constructors:ForceEnumeration(ICommunication sock)ForceEnumeration(ICommunication sock, int TimeoutMillisec)
Overrides:WholePackage()(parses response),CommandToString(),ResponseToString().
Firmware Update Commands
-
QueryFirmwareUpdateBlockSize
Queries maximum firmware block size.
Properties:BlockSize: ushort— populated from response parameter[0] on success.
Constructors:QueryFirmwareUpdateBlockSize(ICommunication sock)QueryFirmwareUpdateBlockSize(ICommunication sock, int TimeoutMillisec)
Overrides:WholePackage(),ResponseToString(ref List<List<string>> lines).
-
QueryBootloaderVersion
Queries bootloader version string.
Properties:Version: string— populated from response parameter[0] on success.
Constructors:QueryBootloaderVersion(ICommunication sock)QueryBootloaderVersion(ICommunication sock, int TimeoutMillisec)
Overrides:WholePackage(),ResponseToString(ref List<List<string>> lines).
-
ProgramFirmwareUpdateBlock
Programs a firmware block.
Properties:BlockBaseAddress: uint— sets parameter[0–3].BlockSize: ushort— set internally fromDatalength; sets parameter[4–5].BlockCRC16: ushort— sets parameter[6–7].Upper: bool— sets parameter[8] to1if true.Data: byte[]— sets parameter[10..] (requirescommand.Parameterexpansion).
Constructors:ProgramFirmwareUpdateBlock(ICommunication sock)ProgramFirmwareUpdateBlock(ICommunication sock, int TimeoutMillisec)
Overrides:CommandToString(ref List<List<string>> lines).
-
FinishFirmwareUpdate
Finalizes firmware update with image CRC.
Properties:ImageCRC16: ushort— sets parameter[0–1].
Constructors:FinishFirmwareUpdate(ICommunication sock)FinishFirmwareUpdate(ICommunication sock, int TimeoutMillisec)
Overrides:CommandToString(ref List<List<string>> lines),ResponseToString(ref List<List<string>> lines).
-
QueryInFirmwareUpdateMode
Queries current firmware update mode.
Properties:InUpdateMode: bool—trueif not inFWmode.IsFwMode,IsBlMode,IsBllMode: bool— mode flags.Mode: FirmwareMode— actual mode enum.
Constructors:QueryInFirmwareUpdateMode(ICommunication sock)QueryInFirmwareUpdateMode(ICommunication sock, int TimeoutMillisec)
Overrides:WholePackage().
-
Load_SliceProStackFirmwareImage
Loads a 400-byte firmware block to base NAND (requires protocol ≥137).
Properties:StartByteCount: uint— sets parameter[2–5].Data: byte[]— sets parameter[6..]; throwsNotImplementedExceptionif length >MAX_FILE_LENGTH(400).Size: int— length ofData.MaximumFileStreamBytes: int→400._fileID = 20(hardcoded for firmware).MinimumProtocolVersionset viasock.GetMinProto(ProtocolLimitedCommands.StackFirmwareUpdate).command.ShouldLog = false.
Constructors:Load_SliceProStackFirmwareImage(ICommunication sock)Load_SliceProStackFirmwareImage(ICommunication sock, int TimeoutMillisec)
Overrides:CommandToString(ref List<List<string>> lines).
-
Start_SliceProStackFirmwareUpdate,Set_SliceProStackFirmwareUpdateMode,Get_SliceProStackFirmwareUpdateMode
Support Slice Pro stack firmware updates (protocol ≥137).Set_SliceProStackFirmwareUpdateMode:SliceModuleCount: int— sets_sliceProUpdateModearray size.SliceModuledateMode: byte[]— setscommand.Parameter.
Get_SliceProStackFirmwareUpdateMode:SliceModuleCount: int— populated fromresponse.Parameter.Length.SliceModuledateMode: byte[]— populated from response parameters.
OverridesWholePackage().
PTP 1588 Commands
-
Ptp1588SetMode
Sets PTP mode.
Methods:SetClockType(PtpClockType)— sets parameter[0–1].SetDelayMechanism(PtpDelayMechanism)— sets parameter[2–3].
Constructors:Ptp1588SetMode(ICommunication sock)Ptp1588SetMode(ICommunication sock, int TimeoutMillisec)
Overrides:CommandToString(ref List<List<string>> lines).
-
Ptp1588GetMode
Gets PTP mode.
Properties:ClockType: PtpClockTypeDelayMechanism: PtpDelayMechanism
Constructors:Ptp1588GetMode(ICommunication sock)Ptp1588GetMode(ICommunication sock, int TimeoutMillisec)
Overrides:WholePackage().
-
Ptp1588GetSyncStatus
Gets PTP sync status.
Properties:SyncStatus: PtpSyncStatusOFM: int— offset from master (ns).FreqAdj: int— frequency adjustment.
Constructors:Ptp1588GetSyncStatus(ICommunication sock)Ptp1588GetSyncStatus(ICommunication sock, int TimeoutMillisec)
Overrides:WholePackage()(requiresresponse.ParameterLength > 6for full data).
-
Ptp1588SetTime,Ptp1588GetTime,Ptp1588SetAutoTriggerTime,Ptp1588GetAutoTriggerTime
Time setting/getting commands.SetTime/SetAutoTriggerTime:SetSeconds(uint),SetNanoseconds(uint).GetTime/GetAutoTriggerTime:Seconds: uint,Nanoseconds: uint,Timestamp: string(viaToTimestampString).
Constructors and overrides similar to above.
-
Ptp1588GetTimestamp
Gets timestamp for a specified trigger source.
Properties:TimestampUnit: PtpTimestampUnits(set via property).Seconds,Nanoseconds,Timestamp,IsValid: bool.
Constructors:Ptp1588GetTimestamp(ICommunication sock)Ptp1588GetTimestamp(ICommunication sock, int TimeoutMillisec)
Overrides:CommandToString(ref List<List<string>> lines),ResponseToString(ref List<List<string>> lines).
-
Ptp1588SetEnableTimestamping
Enables/disables trigger timestamping.
Methods:SetEnable(bool)— sets parameter[0] to1or0.
Constructors:Ptp1588SetEnableTimestamping(ICommunication sock)Ptp1588SetEnableTimestamping(ICommunication sock, int TimeoutMillisec).
-
Ptp1588SetAdcClockFrequency
Requests ADC clock frequency.
Properties:RequestedFrequency: uint(set via property).ActualFrequency: uint— populated from response parameter[0] on success.
Constructors:Ptp1588SetAdcClockFrequency(ICommunication sock)Ptp1588SetAdcClockFrequency(ICommunication sock, int TimeoutMillisec)
Overrides:WholePackage(),CommandToString(ref List<List<string>> lines),ResponseToString(ref List<List<string>> lines).
-
Ptp1588RunClockAdjustmentCalibration
Runs clock calibration.
Methods:SetDuration(ushort)— sets parameter[0–1].SetSaveAttribute(bool)— sets parameter[2].
Constructors:Ptp1588RunClockAdjustmentCalibration(ICommunication sock)Ptp1588RunClockAdjustmentCalibration(ICommunication sock, int TimeoutMillisec).
-
QueryClockSyncStatus
Queries clock sync configuration (requires protocol ≥ version fromProtocolLimitedCommands.QueryClockSyncStatus).
Properties:InputState,OutputState,SyncStatus: byte.ClockSyncProfile: ClockSyncProfile(enum fromDTS.Common.Enums).InputSources,OutputSources: List<T>(populated fromEnum.GetValues).InputSyncStatus: IDictionary<InputClockSource, bool>— built by maskingSyncStatuswith each source enum value.
Overrides:WholePackage().
-
SetClockSyncConfig
Sets clock sync configuration (requires protocol ≥ version fromProtocolLimitedCommands.SetClockSyncConfig).
Overrides:ResponseToString(ref List<List<string>> lines)(reports success/failure).
3. Invariants
-
Command Type Consistency:
Each command class setscommand.Typeto a specificCommandPacket.CommandTypevalue in its constructor (e.g.,StackSetup,StackUtility,FirmwareUpdate,Ptp1588). Derived classes must not override this. -
Sequence Number Uniqueness:
CommandPacket.GetNextSequenceNumber()uses a staticGlobalSequenceNumberincremented under lock (GlobalSequenceNumberLock). Sequence numbers are monotonically increasing and unique per process. -
Parameter Initialization:
Commands initializecommand.Parameterto a fixed-sizebyte[]in constructors. Dynamic expansion occurs only inProgramFirmwareUpdateBlock.DataandLoad_SliceProStackFirmwareImage.Datawhen data exceeds initial capacity. -
Protocol Version Enforcement:
Commands requiring specific protocol versions (e.g.,Load_SliceProStackFirmwareImage,SetClockSyncConfig) setMinimumProtocolVersionviasock.GetMinProto(...). -
Response Parsing Guard:
WholePackage()overrides checkresponse.Status == CommandStatus.StatusNoErrorbefore parsing parameters. -
Command Parameter Layout:
Parameter offsets are fixed and documented by command (e.g.,ProgramFirmwareUpdateBlock.BlockBaseAddress→ parameter[0–3],BlockSize→ parameter[4–5]). Offsets are not inferred dynamically.
4. Dependencies
Dependencies on this module:
DTS.DASLib.Command.SLICE.CommandBase→ Base for all command classes.DTS.DASLib.Command.SLICE.CommandPacket→ Packet structure and sequence numbering.DTS.Common.Interface.DASFactory.ICommunication→ Communication channel abstraction (passed to constructors).DTS.Common.Enums.DASFactory.DFConstantsAndEnums→CommandStatus,ProtocolLimitedCommands,InputClockSource,OutputClockSource,ClockSyncProfile.DTS.Common.ICommunication→ Used inICommunicationinterface (likely aliased or re-exported).
Dependencies of this module:
DTS.DASLib.Communication(namespace) — referenced inStackUtilityCommands.csbut not used (likely legacy).DTS.DASLib.Utility— referenced but unused inStackUtilityCommands.cs.DTS.Common— for enums, logging, utilities.System,System.Collections.Generic,System.Text,System.Threading,System.Reflection,System.IO,System.Diagnostics— standard libraries.
5. Gotchas
-
Load_SliceProStackFirmwareImage.DatathrowsNotImplementedExceptionif input data length exceedsMAX_FILE_LENGTH(400 bytes). This is a hard limit; no fallback or chunking is provided. -
Ptp1588GetSyncStatussilently degrades: Ifresponse.ParameterLength ≤ 6,SyncStatusdefaults toNotSyncedwithout error logging. -
Set_SliceProStackFirmwareUpdateMode.SliceModuledateModesetter copies values but does not validate array length againstSliceModuleCount— mismatched lengths may cause silent truncation orIndexOutOfRangeException. -
QueryClockSyncStatus.InputSyncStatusis populated only forInputClockSourceenum values except the first (sources[0]) due tofor (int i = 1; i < sources.Count; i++). The first source is skipped. -
ProgramFirmwareUpdateBlock.Datasetter expandscommand.Parameteronly if current length is insufficient, but does not shrink it. Repeated use may retain unused bytes. -
FirmwareUpdateCommandsandPtp1588Commandsusecommand.SetCommand((byte)_Command, _Command.ToString()), but_Command.ToString()is not used elsewhere in the codebase — likely for debugging only. -
BusPowerControl.PowerOnsetter always writes to parameter[0], regardless of prior state — no idempotency or validation. -
QueryInFirmwareUpdateMode.InUpdateModelogic is inverted:InUpdateMode = (Mode != FirmwareMode.FW), butIsFwMode = (Mode == FirmwareMode.FW). This may cause confusion. -
Ptp1588SetAdcClockFrequencyuses typo in command name:Commands.SetAdcClockFrquency(missing 'e' in "Frequency"). -
Load_SliceProStackFirmwareImage._fileIDis hardcoded to20(firmware ID), butMAX_FILE_ID = 30suggests user IDs (1–10) are possible — no public API to change_fileID. -
No validation of
command.Parameterbounds in setters like `ProgramFirmware