5.0 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T03:53:10.384931+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | dd0ee32e99af1e4e |
ARM
Purpose
This module provides a centralized static interface for updating the ARM (Armed/Recording Monitor) status of a Data Acquisition System (DAS) record in the database. It acts as a thin data-access wrapper that translates in-memory ARM state flags, metrics, and metadata into a stored procedure call (sp_ArmStatusSet) to persist the current operational state of a DAS unit—such as armed status, triggering, fault conditions, recording progress, and sensor readings—ensuring consistency between the application’s runtime state and the persisted state in the database.
Public Interface
ARM.SetArmStatus(...)
public static void SetArmStatus(
int iDASRecordId,
bool isArmed,
bool isTriggered,
bool isTriggerShorted,
bool isStartShorted,
bool isRecording,
bool isFaulted,
bool isInRealtime,
bool isInFlashWrite,
bool isUndefined,
bool isInPostTestDiagnostics,
double timeRemainingSeconds,
double percentComplete,
ulong totalSamples,
ulong currentSample,
uint sampleRate,
double? inputMilliVolts,
double? batteryMilliVolts,
int? eventNumber,
int recordingMode,
string faultMessage,
bool isRearming,
bool hasBeenRecording,
double? timeLeftInArm
)
Behavior: Updates the ARM status for the DAS record identified by iDASRecordId by invoking the stored procedure sp_ArmStatusSet. All parameters map directly to corresponding database columns/parameters. If the database connection is not active (!DbWrapper.Connected), the method returns early without executing the procedure. It handles nullable types by substituting defaults (0 for numerics, "" for strings) before passing to SQL. It captures and processes output parameters (@errorNumber, @errorMessage, @new_id) via DbWrapper.ProcessReturn, and ensures the command connection is disposed in a finally block.
Invariants
- Connection requirement: The method performs no operation if
DbWrapper.Connectedisfalse. - Non-nullability enforcement: Nullable parameters (
double?,int?) are coalesced to non-null defaults (0or"") before being passed to SQL—noNULLvalues are sent for any parameter. - Stored procedure contract: Assumes
sp_ArmStatusSetexists and accepts the exact 24 parameters listed (including 3 output parameters). - Resource cleanup: The underlying
SqlCommand.Connectionis explicitly disposed after execution, regardless of success or failure. - No return value: The method does not expose the output values (
@errorNumber,@errorMessage,@new_id) to callers—processing is delegated entirely toDbWrapper.ProcessReturn.
Dependencies
- Internal dependencies:
DbWrapper.Connected(property) andDbWrapper.GetDASFactoryCommand()(method) — used to check connectivity and obtain a configuredSqlCommand.DbWrapper.ProcessReturn(...)— processes output parameters from the stored procedure call.
- External dependencies:
System.DataandSystem.Data.SqlClient— forSqlDbType,CommandType,SqlParameter,ParameterDirection, andIDbCommand.- Database: Requires the stored procedure
sp_ArmStatusSetto exist in the DASFactory database with the exact parameter list and types.
Depended on by: Presumably other components in the DAS system that need to update ARM status (e.g., recording state machines, fault handlers, telemetry services)—though not visible in this file.
Gotchas
- Silent no-op on disconnect: If
DbWrapper.Connectedisfalse, the method returns without logging or raising an exception—this may mask connectivity issues. - Loss of null semantics: Nullable parameters (
inputMilliVolts,batteryMilliVolts,eventNumber,timeLeftInArm) are converted to0or""whennull, potentially overwriting meaningfulNULLstates in the database (e.g., “unknown” vs. “zero”). ulong→inttruncation risk:totalSamples,currentSample(ulong) are passed asSqlDbType.Int(signed 32-bit), which may cause silent overflow or incorrect values for large sample counts (> 2³¹−1).- Hardcoded stored procedure name: The procedure name
"sp_ArmStatusSet"is hardcoded—no abstraction or configuration layer. - No validation of input values: No checks for invalid combinations (e.g.,
isRecording == truebutisArmed == false)—assumes caller maintains logical consistency. - Output parameters unused by caller: Though
@new_idis declared and returned, its value is not exposed—suggests possible legacy or incomplete implementation.
None identified from source alone. — Note: The above gotchas are inferred from observed behavior and type mismatches; no explicit documentation or comments exist in the source.