11 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T03:58:36.838770+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 6a51104a1281b13a |
Documentation: Download Request and Report Classes
1. Purpose
This module provides data structures and static utility methods to configure and persist download requests and event metadata for a DAS (Data Acquisition System). It defines concrete implementations (UARTDownloadRequest, DownloadRequest, DownloadReport) of their corresponding interfaces (IUARTDownloadRequest, IDownloadRequest, IDownloadReport) used to specify what data to download from the DAS device and which events are present/already downloaded. The SetWhatToDownload and SetEvent* static methods in these classes synchronize request/report state with both the DAS communication layer (IDASCommunication) and a backing database via DASFactoryDb.Download functions.
2. Public Interface
UARTDownloadRequest class
-
EventNumber(ushort): Gets or sets the event number from which to download UART data. -
TotalByteCount(ulong): Gets or sets the total number of bytes in the UART stream. -
TriggerByteCount(ulong): Gets or sets the byte offset within the stream where the trigger occurred. -
FaultByteCount(ulong): Gets or sets the byte offset within the stream where a fault occurred. -
StartTimestamp(ulong): Gets or sets the start timestamp of the UART stream. -
EndTimestamp(ulong): Gets or sets the end timestamp of the UART stream. -
BaudRate(int): Gets or sets the baud rate used during UART recording. -
SetWhatToDownload(IDASCommunication das, IUARTDownloadRequest request, bool bSetInDb)(static void):
Assigns the providedrequesttodas.WhatUARTToDownload(ifdasimplementsIUARTDownload). IfbSetInDbistrueand the database is connected, clears existing UART download requests fordas.RecordId, then inserts the new request (or does nothing ifrequestisnull). Exceptions during DB insertion are logged viaAPILogger.Log.
DownloadRequest class
-
ALL_CHANNELS(const byte): Value0xFF; indicates all channels should be downloaded. Currently the only supported value. -
EventNumber(ushort): Gets or sets the event number to download. -
DASChannelNumber(byte): Gets or sets the channel number; must beALL_CHANNELS(0xFF) per current implementation. -
StartSample(ulong,virtual): Gets or sets the first sample index to download. -
EndSample(ulong,virtual): Gets or sets the last sample index to download. -
SamplesToSkip(ulong): Gets or sets subsampling factor.0or1means no subsampling;n > 1means every nth sample. Invariant:(EndSample - StartSample + 1)must be divisible bySamplesToSkip. -
StartRecordTimestampSec(double): Gets or sets the integer seconds portion of the record start timestamp. -
TriggerTimestampSec(double): Gets or sets the integer seconds portion of the trigger timestamp. -
StartRecordTimestampNanoSec(double): Gets or sets the nanoseconds portion of the record start timestamp. -
TriggerTimestampNanoSec(double): Gets or sets the nanoseconds portion of the trigger timestamp. -
PTPMasterSync(bool): Gets or sets whether PTP master synchronization was used. -
SetWhatToDownload(IDASCommunication das, IDownloadRequest request, bool bSetInDb)(static void):
Assignsrequesttodas.WhatToDownload. Logs the request details if non-null. IfbSetInDbistrueand the database is connected, clears existing download requests fordas.RecordId, then inserts the new request (or does nothing ifrequestisnull). Exceptions during DB insertion are logged viaAPILogger.Log.
DownloadReport class
Nested Types
-
EventInfo(class, implementsIEventInfo):
Represents metadata for a single event/test.Modules(IDASModule[]): Array of modules involved in the event, indexed byModuleArrayIndex.EventNumber(int): Event number.TestGUID(Guid): Event GUID.FaultFlags(ushort): Fault flags.FaultFlagsEx(ushort): Extended fault flags.ArmAttempts(byte): Number of arm attempts.TestTime(DateTime): Timestamp of the event.TestID(string): Event ID string.Description(string): Event description.HasBeenDownloaded(bool): Whether the event has been downloaded.WasTriggered(bool): Whether the event received a trigger.ClearFaults()(void): ResetsFaultFlagsandFaultFlagsExto0.EventInfo(EventInfo copy)(constructor): Copies all fields from anotherEventInfo.
-
UARTEventInfo(class, implementsIUARTEventInfo):
Represents metadata for a single UART event.EventNumber(ushort): Event number.DataPresent(bool): Whether UART data exists for this event.DataDownloaded(bool): Whether UART data has been downloaded.TotalByteCount(ulong): Total bytes of UART data.TriggerByteCount(ulong): Byte offset of trigger.FaultByteCount(ulong): Byte offset of fault.StartTimestamp(ulong): UART stream start timestamp.EndTimestamp(ulong): UART stream end timestamp.BaudRate(uint): Baud rate during recording.
Instance Properties
Events(IEventInfo[]): Array of all events on the DAS.UARTEvents(IUARTEventInfo[]): Array of all UART events on the DAS.
Static Methods
-
SetEventDownloadStatus(IDASCommunication das, bool[] status, bool bStoreInDb)(static void):
Setsdas.EventDownloadedStatustostatus. IfbStoreInDband DB connected, clears and re-inserts status entries fordas.RecordId. Logs exceptions. -
SetEventArmAttempts(IDASCommunication das, byte[] armAttempts, bool storeInDb)(static void):
Setsdas.ArmAttemptstoarmAttempts. Persists to DB if applicable. -
SetEventFaultFlags(IDASCommunication das, ushort[] faultFlags, bool storeInDb)(static void):
Setsdas.FaultFlagstofaultFlags. Persists to DB if applicable. -
SetEventInfo(IDASCommunication das, IDownloadReport eventInfo, bool storeInDB)(static void):
Setsdas.EventInfotoeventInfo. Persists eachIEventInfoineventInfo.Eventsto DB by serializingModulesto XML and callingDownload.InsertEventInfo. Logs exceptions. -
SetEventGuids(IDASCommunication das, Guid[] guids, bool storeInDb)(static void):
Setsdas.EventGuidstoguids. Persists to DB if applicable.
3. Invariants
DownloadRequest.DASChannelNumbermust beALL_CHANNELS(0xFF). Other values are unsupported per the class documentation.DownloadRequest.SamplesToSkipmust divide(EndSample - StartSample + 1)exactly. The code does not enforce this at runtime; violation would likely cause downstream errors.DownloadRequest.SetWhatToDownloadandUARTDownloadRequest.SetWhatToDownload:- If
bSetInDbisfalseorDASFactoryDb.DbWrapper.Connectedisfalse, no DB operations occur. - DB operations always clear all existing requests for
das.RecordIdbefore inserting the new one (or none ifrequestisnull).
- If
DownloadReport.SetEventInfoserializeseventInfo.Modulesto XML usingXmlWriterwithConformanceLevel.Document. If anyIDASModule.WriteXmlimplementation fails, the entire operation fails and is logged.DownloadReport.EventInfo.ClearFaults()unconditionally sets bothFaultFlagsandFaultFlagsExto0.
4. Dependencies
Internal Dependencies (from source)
DASFactoryDb.Download: Provides DB functions:ClearExistingUARTDownloadRequests,UARTDownloadRequestInsertClearExistingDownloadRequests,DownloadRequestInsertClearExistingEventDownloadStatus,InsertEventDownloadStatusClearExistingEventArmAttempts,InsertEventArmAttemptsClearExistingFaultFlags,InsertEventFaultFlagsClearExistingDownloadReports,InsertEventInfoClearExistingEventGuids,EventGuidInsert
DASFactoryDb.DbWrapper: ProvidesConnectedproperty and is used to gate DB operations.DTS.Common.Interface.DASFactory: DefinesIDASCommunication,IDownloadRequest,IUARTDownloadRequest,IDownloadReport,IEventInfo,IUARTEventInfo.DTS.Common.Interface.DASFactory.Download: DefinesIUARTDownload(used inUARTDownloadRequest.SetWhatToDownloadto castdas).DTS.Common.Interface.DownloadEvent: DefinesIEventInfo(used inDownloadReport.EventInfo).DTS.Common.Utilities.Logging: ProvidesAPILoggerfor exception logging.
External Dependencies (inferred)
- Database: SQL Server (via
System.Data.SqlClientandSqlTypesimports inDownloadReport.cs). - XML serialization: Uses
System.XmlforIDASModule.WriteXmlserialization.
5. Gotchas
DownloadRequest.SamplesToSkipvalidation is not enforced: The code comments state(EndSample - StartSample + 1)must be a multiple ofSamplesToSkip, but no runtime check exists. Invalid values may cause errors downstream.UARTDownloadRequest.SetWhatToDownloadsilently ignores non-IUARTDownloadinstances: Ifdasdoes not implementIUARTDownload, the method returns early without settingWhatUARTToDownloador logging.DownloadReport.EventInfocopy constructor performs shallow copy:Modules = copy.Modulescopies the array reference, not the elements. Modifying the array or its contents via one instance affects the other.DownloadReport.SetEventInfoserializesModulesto XML: If anyIDASModule.WriteXmlimplementation is buggy or writes invalid XML, the entire operation fails and is logged. No partial persistence occurs.DownloadRequest.SetWhatToDownloadlogs only whenrequestis non-null: Ifrequestisnull, no log entry is made, even thoughdas.WhatToDownloadis set tonull.DownloadReport.UARTEventInfo.BaudRateisuint, butUARTDownloadRequest.BaudRateisint: Mismatched types may require conversion when copying data between them.- DB operations are all-or-nothing per call: Each
SetEvent*method clears all existing DB records for its respective field before inserting new ones. This is not incremental and may cause data loss if called with incomplete arrays. DownloadReport.SetEventDownloadStatus,SetEventArmAttempts,SetEventFaultFlags,SetEventGuidsdo not validate array length: Passing an array of incorrect length (e.g., mismatched with number of events) may cause DB inconsistencies or downstream errors.