11 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T11:28:10.843855+00:00 | zai-org/GLM-5-FP8 | 1 | b573bb7d2f5d27d0 |
Documentation: DTS.Common.ICommunication
1. Purpose
This module provides the core communication infrastructure for interacting with DAS (Data Acquisition System) hardware. It defines the contract for DAS-connected devices via IDASConnectedDevice, encapsulates device metadata through Communication_DASInfo, and implements an asynchronous, callback-driven communication layer via the abstract Communication<T> class. The module handles connection lifecycle management, command execution with timeout handling, cancellation support, and receive buffering for networked hardware devices.
2. Public Interface
IDASConnectedDevice (Interface)
Namespace: DTS.DASLib.Communication
Describes a device connected to a DAS (e.g., an S6 connected to an S6DB).
| Property | Type | Description |
|---|---|---|
DeviceType |
HardwareTypes |
The device type of the connected device. |
Port |
int |
The port on the DAS which the device is on (0-based). |
SpotOnPort |
int |
The spot on the chain or port the device is on (0-based). |
PhysicalAddress |
PhysicalAddress |
MAC Address or physical address. |
IPAddress |
string |
The IP address of the device. |
SerialNumber |
string |
The serial number of the device. |
Location |
string |
The location of the device. |
Version |
string |
The version of the device. |
CanceledException (Class)
Namespace: DTS.Common.ICommunication
Marker exception class extending ApplicationException. Used to signal operation cancellation.
Communication_DASInfo (Class)
Namespace: DTS.Common.ICommunication
Implements ICommunication_DASInfo. Holds metadata about a DAS device.
Properties:
FirstUseDate(DateTime?) — Date of first use;nullindicates hardware has not been used since calibration. Only valid whenIsFirstUseDateSupportedistrue.IsFirstUseDateSupported(bool) — Indicates hardware supports first use dates.IsStreamingSupported(bool) — Indicates whether streaming is supported.ConnectedDevices(IDASConnectedDevice[]) — Devices connected to the DAS (currently only used by SLICE6DB).
Methods:
void SetConnectedDevices(IDASConnectedDevice[] devices)— Sets theConnectedDevicesarray.string StackSerialNumber(int devid)— Returns a stacked serial number string. Returns"N/A"ifSerialNumbersis null/empty; returnsSerialNumbers[0]::SerialNumbers[devid]ifdevidis non-zero and valid; otherwise returnsSerialNumbers[0].
Constructors:
Communication_DASInfo()— Default constructor.Communication_DASInfo(string[] serials, string[] fwnums)— Constructs with cloned serial and firmware version arrays.
Communication<T> (Abstract Class)
Namespace: DTS.Common.ICommunication
Generic abstract base class for DAS communication. Type parameter T must implement IConnection and have a parameterless constructor.
Properties:
ErrorInSetup(bool) — Indicates an error occurred during setup.ConnectString(string) — Returnssock.ConnectString.Connected(bool) — Returnssock.Connected.DASInfo(ICommunication_DASInfo) — DAS information object.Transport(IConnection) — Gets the underlying connection; setter throwsNotSupportedException.ReceiveBufferSize(int) — Receive buffer size; default is 65536 (2^16).SerialNumber(string) — Device serial number.FirmwareVersion(string) — Firmware version; setter triggersFirmwareVersionUpdated().ProtocolVersion(byte) — Protocol version.MinimumProtocols(Dictionary<DFConstantsAndEnums.ProtocolLimitedCommands, byte>) — Minimum protocol versions for commands.FlushTimeoutMilliSec(int) — Flush timeout; default is 5ms.ExecuteIsBusy(bool) — Thread-safe flag indicating execution lock state.CancelEvent(ManualResetEvent) — Event signaling cancellation.
Methods:
int CompareTo(ICommunication dev)— Compares connect strings (case-insensitive ordinal).int CompareTo(string conStr)— Compares connect string to given string.abstract void InitMinProto()— Must be implemented to initializeMinimumProtocols.bool IsCommandSupported(ProtocolLimitedCommands command)— ReturnstrueifProtocolVersion >= GetMinProto(command).byte GetMinProto(ProtocolLimitedCommands command)— Returns minimum protocol version for command; returns0xFFif not found; throws ifMinimumProtocolsis null.void Flush(int timeoutMs)— FlushesSockDataBufferuntil empty or timeout.byte[] SyncExecute(byte[] byteData, int cbTimeout)— ThrowsNotSupportedException.void Connect(string connectString, CommunicationCallback callback, object callbackObject, int callbackTimeout, string hostIPAddress)— Initiates asynchronous connection.void Disconnect(bool reuseSocket, CommunicationCallback callback, object callbackObject, int callbackTimeout)— Initiates asynchronous disconnect.void ForceCancel()— Sets cancel state with 250ms sleep on clear.void Cancel()— Sets cancel state with 500ms sleep on clear.bool IsCanceled()— Returns current cancel state.void ClearCancel()— Clears cancel state after sleeping.void PseudoExecute(byte[] byteData, CommunicationCallback cb, object cbObject, int cbTimeout)— For commands that only receive data (no send). ThrowsCanceledExceptionif canceled,NotConnectedExceptionif not connected.void Execute(byte[] byteData, CommunicationCallback cb, object cbObject, int cbTimeout)— Sends data and processes response. ThrowsCanceledExceptionif canceled,NotConnectedExceptionif not connected.void SetupReader()— Initializes asynchronous receive loop.void Close(int timeout)— Empty implementation.
Events:
OnDisconnected(EventHandler) — Raised when the underlying connection disconnects.
Protected Methods:
void Lock()— Empty implementation.void Release()— Empty implementation.virtual void FirmwareVersionUpdated()— Called whenFirmwareVersionis set.
Communication.ActionData (Nested Abstract Class)
Base class for async operation tracking with timeout support.
Constructor: ActionData(CommunicationCallback cb, object obj, int to)
Methods:
void StartTimer()— Starts timeout timer.void KillTimer()— Stops and disposes timer.bool ReportCanceled()— Invokes callback withCommunicationResult.Canceled.abstract bool ReportFailure()— Must implement failure reporting.abstract bool ReportSuccess()— Must implement success reporting.abstract CommunicationResult GetTimeoutResult()— Must return result for timeout.
Properties:
TimerExpired(bool) — Returns whether timer has fired.
Communication.ExecuteActionData (Nested Class)
Extends ActionData for execute operations.
Additional Methods:
bool ReportReadSuccess(byte[] data)— Reports successful read with data.bool ReportReadTimeout()— Reports read timeout.bool ReportReadDisconnected()— Reports disconnection during read.
CommunicationReport (Class)
Namespace: DTS.Common.ICommunication
Implements ICommunicationReport.
Properties:
UserState(object) — User-provided state object.Result(CommunicationResult) — Result of the operation.Data(byte[]) — Received data (for read operations).
Constructor: CommunicationReport(object state, CommunicationResult res)
Communication.PseudoAsyncResult (Nested Class)
Implements IAsyncResult for PseudoExecute. IsCompleted and CompletedSynchronously return true. AsyncWaitHandle throws NotImplementedException.
3. Invariants
- Connection State Checks:
Connect()throws ifsockis null or already connected.Disconnect()throws ifsockis null. - Execute Pre-conditions: Both
Execute()andPseudoExecute()throwCanceledExceptionifIsCanceled()returnstrue, andNotConnectedExceptionifConnectedisfalse. - ExecuteIsBusy Thread Safety: The
ExecuteIsBusyproperty uses locking (_executeBusyMtLock) and asserts on re-entry or extra unlock attempts. - Transport Immutability: The
Transportproperty setter always throwsNotSupportedException. - MinimumProtocols Requirement:
GetMinProto()throwsNotSupportedExceptionifMinimumProtocolsis null. - SyncExecute Unavailable:
SyncExecute()always throwsNotSupportedException. - Clone Behavior:
Communication_DASInfoconstructor clones input arrays forSerialNumbersandFirmwareVersions. - Port/Spot Indexing:
PortandSpotOnPortinIDASConnectedDeviceare explicitly 0-based.
4. Dependencies
This module depends on:
DTS.Common.Enums.Hardware—HardwareTypesenumDTS.Common.Enums.Communication—CommunicationResult,CommunicationConstantsAndEnumsDTS.Common.Enums.DASFactory—DFConstantsAndEnumsDTS.Common.Interface.Communication—ICommunication_DASInfo,CommunicationCallbackdelegateDTS.Common.Interface.Connection—IConnectionDTS.Common.Classes.Connection— (referenced but implementation not shown)DTS.Common.Utilities.Logging—APILoggerDTS.Common.Utilities—SecureQueue<T>DTS.Common.Utils—WaitWithConditionSystem.Net.NetworkInformation—PhysicalAddressSystem.Net.Sockets—SocketExceptionSystem.Threading,System.Threading.Tasks— Async primitives
What depends on this module:
- Cannot be definitively determined from source alone, but
Communication_DASInfo.ConnectedDevicesreferencesIDASConnectedDevice, suggesting SLICE6DB implementations depend on this interface.
5. Gotchas
-
Empty Lock/Release Methods:
Lock()andRelease()are defined but have empty implementations. Their intended purpose is unclear from source alone. -
Close() is a No-Op: The
Close(int timeout)method has an empty body. Callers should not rely on it for cleanup. -
Cancel Sleep Behavior:
ClearCancel()sleeps for either 250ms (afterForceCancel()) or 500ms (afterCancel()) before clearing the cancel state. This blocking delay may be unexpected in time-sensitive contexts. -
Thread ID Check in Receive Callbacks: Both
ProcessReceivedDataandSRRecvCallbackcheck ifThread.CurrentThread.ManagedThreadIdchanges duringWaitWithCondition.Wait(), logging and returning early if it does. This suggests a historical threading issue. -
Transport Setter Always Throws: Attempting to set
TransportthrowsNotSupportedExceptionwith message "Communication::Transport Can't replace socket". -
PseudoAsyncResult.AsyncWaitHandle Throws: Accessing
AsyncWaitHandleonPseudoAsyncResultthrowsNotImplementedException. -
ConnectedDevices Default is Empty Array:
Communication_DASInfo.ConnectedDevicesinitializes to an empty array, not null. Code checking for null will not behave as expected. -
StackSerialNumber Index Logic:
StackSerialNumber(int devid)returns the stacked format only whendevid != 0 && devid < SerialNumbers.Length. Adevidof 0 returns justSerialNumbers[0], not a stacked string.