6.1 KiB
6.1 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-17T15:59:45.195241+00:00 | zai-org/GLM-5-FP8 | 1 | 419e1018bcd6dde6 |
Documentation: DASFactoryDb.Download.Download
1. Purpose
This module provides a data access layer for managing download-related database operations in a DAS (Data Acquisition System) Factory context. It serves as an abstraction layer for persisting and clearing event metadata—including download statuses, fault flags, arm attempts, event information, download requests, and event GUIDs—via SQL Server stored procedures. The class is designed to support the lifecycle of data recorder events from initial recording through download completion.
2. Public Interface
Clear Methods
| Method | Signature | Behavior |
|---|---|---|
ClearExistingEventDownloadStatus |
void ClearExistingEventDownloadStatus(int idasRecordId) |
Clears all existing download status records for the specified DAS record via sp_EventDownloadStatusClear. |
ClearExistingEventArmAttempts |
void ClearExistingEventArmAttempts(int idasRecordId) |
Clears all arm attempt records for a given data recorder via sp_EventArmAttemptsClear. |
ClearExistingFaultFlags |
void ClearExistingFaultFlags(int idasRecordId) |
Clears event fault flag records via sp_EventFaultFlagsClear. |
ClearExistingDownloadReports |
void ClearExistingDownloadReports(int idasRecordId) |
Clears event info/download report records via sp_DownloadReportClear. |
ClearExistingEventGuids |
void ClearExistingEventGuids(int idasRecordId) |
Clears event GUID records via sp_EventGuidsClear. |
ClearExistingDownloadRequests |
void ClearExistingDownloadRequests(int idasRecordId) |
Clears download request records via sp_DownloadRequestsClear. |
ClearExistingUARTDownloadRequests |
void ClearExistingUARTDownloadRequests(int idasRecordId) |
Clears UART download request records via sp_UARTDownloadRequestsClear. |
Insert Methods
| Method | Signature | Behavior |
|---|---|---|
InsertEventFaultFlags |
void InsertEventFaultFlags(int iDASRecordId, ushort faultFlag) |
Inserts a fault flag record via sp_EventFaultFlagsInsert. The ushort is stored as SmallInt. |
InsertEventArmAttempts |
void InsertEventArmAttempts(int iDASRecordId, int armAttempts) |
Inserts arm attempt count via sp_EventArmAttemptsInsert. The int is stored as SmallInt. |
InsertEventInfo |
void InsertEventInfo(int iDASRecordId, int eventNumber, Guid testGUID, ushort faultFlags, int armAttempts, DateTime testTime, string testID, string description, bool hasBeenDownloaded, bool wasTriggered, string xml) |
Inserts comprehensive event information via sp_EventInfoInsert. The xml parameter is stored as UTF-8 encoded bytes in a VarBinary field named @Modules. |
InsertEventDownloadStatus |
void InsertEventDownloadStatus(int iDASRecordId, bool downloadStatus) |
Inserts download status via sp_EventDownloadStatusInsert. |
DownloadRequestInsert |
void DownloadRequestInsert(int iDASRecordId, ushort eventNumber, int dasChannelNumber, ulong startSample, ulong endSample, ulong samplesToSkip, double startRecordTimeStampSec, double triggerTimeStampSec, double startRecordTimeStampNanoSec, double triggerTimestampNanoSec, bool PTPMasterSync) |
Inserts a download request via sp_DownloadRequestsInsert. Sample values are stored as Int; timestamps as Decimal. |
UARTDownloadRequestInsert |
void UARTDownloadRequestInsert(int iDASRecordId, ushort eventNumber, ulong totalByteCount, ulong triggerByteCount, ulong faultByteCount, ulong startTimestamp, ulong endTimestamp, int baudRate) |
Inserts a UART download request via sp_UARTDownloadRequestsInsert. Byte counts and timestamps stored as Decimal. |
EventGuidInsert |
void EventGuidInsert(int iDASRecordId, Guid guid) |
Inserts an event GUID via sp_EventGuidsInsert. The GUID is converted to uppercase string. |
3. Invariants
- Connection Guard: All public methods immediately return without action if
DbWrapper.Connectedisfalse. - Stored Procedure Usage: All database operations are performed via stored procedures; no inline SQL is used.
- Error Parameter Pattern: Every stored procedure call includes
@errorNumber(output,Int) and@errorMessage(output,NVarChar(255)) parameters. - Connection Disposal: All methods dispose of the database connection in a
finallyblock, ensuring cleanup even on exception. - Command Source: All methods obtain commands via
DbWrapper.GetDASFactoryCommand(). - GUID Normalization: GUIDs are stored as uppercase strings in
NVarChar(50)fields. - DateTime Handling: In
InsertEventInfo,DateTime.MinValueis converted toSqlDateTime.MinValuebefore storage.
4. Dependencies
This Module Depends On
DbWrapper(external, not shown): ProvidesConnectedproperty,GetDASFactoryCommand()factory method, andProcessReturn(SqlParameter, SqlParameter)error handling.System.Data.SqlClient: ADO.NET SQL Server provider.- SQL Server Database: Requires the following stored procedures to exist:
sp_EventDownloadStatusClear,sp_EventDownloadStatusInsertsp_EventArmAttemptsClear,sp_EventArmAttemptsInsertsp_EventFaultFlagsClear,sp_EventFaultFlagsInsertsp_DownloadReportClearsp_EventGuidsClear,sp_EventGuidsInsertsp_DownloadRequestsClear,sp_DownloadRequestsInsertsp_UARTDownloadRequestsClear,sp_UARTDownloadRequestsInsertsp_EventInfoInsert
What Depends On This Module
- Unclear from source alone: No consumers are visible in this file.
5. Gotchas
Critical Bug: Incorrect Parameter Value in DownloadRequestInsert
cmd.Parameters.Add(
new SqlParameter("@StartRecordTimestampNanoSec", SqlDbType.Decimal)
{ Value = startRecordTimeStampSec }); // BUG: Should be startRecordTimeStampNanoSec
The parameter @StartRecordTimestampNanoSec is incorrectly assigned startRecordTimeStampSec instead of startRecordTimeStampNanoSec. This will result in incorrect nanosecond timestamp data being persisted.