7.0 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T03:32:33.762922+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 3e9a6cf2611db268 |
Configuration
Purpose
This Configuration class is responsible for applying hardware-specific voltage thresholds and configuration settings to a list of Data Acquisition System (DAS) units (IDASCommunication instances) prior to test execution or diagnostics. It orchestrates the configuration process by reading threshold values from a centralized settings store (BatteryAndInputVoltageDefaults), applying them to each DAS object, resetting hardware lines to a known state, and then invoking ConfigurationService.SetConfiguration to push the updated configuration to the hardware. It also ensures that the resulting configuration files are persisted locally per test by copying them from a global configuration directory to the current test’s directory.
Public Interface
public void SetConfig(DataModel.TestTemplate currentTest, List<IDASCommunication> dasList, bool calledDuringDiagnostics, StatusHelpers.SetProgressValueDelegate setProgressFunction)
- Behavior: Applies DAS-specific voltage thresholds (input and battery) based on hardware type, using different thresholds depending on whether the call is for diagnostics (
calledDuringDiagnostics == true) or normal operation. After setting thresholds on eachIDASCommunicationobject, it resets hardware lines viaConfigurationService.ResetHardwareLines, then callsConfigurationService.SetConfigurationto commit the configuration to hardware. Progress is reported viaStatusHelpers.SetStatus2. On success, it copies DAS and module configuration XML files to the test directory. Thread-safe vialockonDASHardware.GetArmStatusLock. - Parameters:
currentTest: The active test context; used to determine the destination directory for config file copying.dasList: List of DAS units to configure.calledDuringDiagnostics: Iftrue, uses diagnostic thresholds (e.g.,BatteryHighDiagnosticsThreshold); otherwise uses armed thresholds (e.g.,BatteryHighArmedThreshold).setProgressFunction: Delegate used to report progress during configuration.
public static DialogResult ErrorCallback(string errorString, string units)
- Behavior: A static callback used by
ConfigurationService.SetConfigurationto handle configuration errors. Logs the error viaAPILogger.Log, and currently returnsDialogResult.OK(commented as a TODO: “Fix this”). - Note: Does not throw or re-raise the error; caller must rely on exception handling in
SetConfigto detect failure.
Invariants
- Thread Safety: The entire
SetConfigmethod body is guarded bylock (DASHardware.GetArmStatusLock), ensuring only one configuration operation occurs at a time. - Voltage Threshold Assignment: For each
IDASCommunication dasindasList, the following six properties are always set:MinimumValidInputVoltage,MaximumValidInputVoltageMinimumValidBatteryVoltage,MaximumValidBatteryVoltageBatteryHighVoltage,BatteryMediumVoltage,BatteryLowVoltageInputHighVoltage,InputMediumVoltage,InputLowVoltageThe values are derived fromBatteryAndInputVoltageDefaults.InputAndBatterySettings.GetValue(type.ToString(), ...), wheretype = das.GetHardwareType().
- Hardware Reset Precedes Configuration:
ConfigurationService.ResetHardwareLinesis always called beforeSetConfiguration, per the comment: “setting the configuration checks the hardware lines so make sure we reset them prior to setting configuration.” - Config File Copying: After successful configuration, XML files for each DAS and its modules are copied from a global
Constants.DAS_CONFIGSdirectory tocurrentTest.TestDirectory, overwriting existing files.
Dependencies
-
Imports/Usings:
DTS.Common.Interface.DASFactory.IDASCommunication: Interface for DAS communication objects.DTS.DASLib.Service.ConfigurationService: Core service used to perform hardware reset and configuration.DTS.Common.DataModel.Common.StatusHelpers: ProvidesSetStatus2andSetProgressValueDelegate.DTS.Common.Utilities.Logging.APILogger: Used for logging errors and exceptions.DTS.Common.DataModel.Classes.TSRAIRGo.TSRAIRGoStatus: DefinesStatusTypes.UPDATING_DAS_CONFIG.DTS.Common.Enums.TSRAIRGo: Enum namespace (used viaTSRAIRGoStatus).System.Windows.Forms.DialogResult: Used inErrorCallback.DTS.Common.DataModel.Common.DataModel.BatteryAndInputVoltageDefaults: Static source of voltage thresholds.DTS.Common.Constants: DefinesDAS_CONFIGS(directory name).DTS.Common.SerializedSettings: ProvidesMaxAAFRate_TDAS,MaxAAFRate_G5, andGetDefaultDSP().
-
External Dependencies:
DASHardware.GetArmStatusLock: A static lock object used for synchronization.Environment.CurrentDirectory: Base path for global config directory.- File system: Requires existence of
DAS_CONFIGSdirectory (viaConstants.DAS_CONFIGS) and read access to XML files.
-
Called By: Presumably invoked by higher-level test orchestration logic (e.g., before test start or diagnostics run). Not referenced in source, but usage is implied by test context (
currentTest) and progress reporting.
Gotchas
- Hardcoded Threshold Keys: Threshold keys (e.g.,
"BatteryHighDiagnosticsThreshold") are string literals; no compile-time safety. A mismatch in key names inBatteryAndInputVoltageDefaultswill result in default fallback values (viaGetValue’s second parameter), potentially leading to incorrect thresholds. - Blocking Wait Loop: The
while (!done.WaitOne(50, false)) { elapsed += 50; }loop is a polling-based wait. While functional, it may be inefficient or mask timing issues; no timeout is enforced beyond the loop’s implicit duration (noelapsed-based timeout check). ErrorCallbackDoes Not Propagate Errors: ReturnsDialogResult.OKunconditionally; actual failure detection relies on exceptions thrown inSetConfigorSetConfiguration. IfSetConfigurationfails silently (e.g., viaCallbackStatus.Failurewithout throwing), this may go unnoticed.- Assumes
das.DASInfoisInfoResult: InCopyGlobalConfigsToLocalFolder,((InfoResult)das.DASInfo).OwningDASandmodule.SerialNumberare cast without type checking. Ifdas.DASInfois not anInfoResult, this will throw at runtime. - No Validation of
dasList:SetConfigdoes not check for null or emptydasList, which could lead to no-op or unexpected behavior. AggregateProgress = false: Indicates per-DAS progress reporting is expected, but the callback logic usescbd.Target(a DAS instance) to report progress—this is consistent, but the setting may be easy to overlook.- Commented TODO:
//Fix thisnext toreturn DialogResult.OK;inErrorCallbackindicates known technical debt.