9.0 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T03:58:02.897735+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 371fccf4478077de |
Documentation: SLICE Base Input Module
1. Purpose
This module provides data acquisition and status reporting for power-related inputs on SLICE-based hardware units. It enables reading raw diagnostic values (e.g., input voltage, battery voltage, temperature, charging status) via the SLICEBaseInputReader class and encapsulating them into a standardized data model (BaseInputValues and its SLICE-specific subclass SLICEBaseInputValues). The SLICEBaseInputValues subclass implements domain-specific logic to compute battery voltage status (e.g., GREEN, YELLOW, RED, NOBATTERY, OFF) based on battery voltage, input voltage, and charge capacity, while also handling device-specific behavior for backup power measurement and enablement.
2. Public Interface
SLICEBaseInputValues (inherits BaseInputValues)
-
PossibleVoltageStatusenum
Defines voltage status levels:GREEN,YELLOW,RED,OFF.
Note: This enum is declared but not used in the current implementation. -
PossibleBatteryStatusenum
Defines battery status levels:GREEN,YELLOW,RED,NOBATTERY,OFF. -
BatteryVoltageStatus(override property)
Read-only computed property. Returns a string representation ofPossibleBatteryStatusbased on the following logic:- If
BatteryMilliVoltsValidisfalse, returns"NOBATTERY". - Else if
ChargeCapacityValidistrue:> 70%→"GREEN"> 40%→"YELLOW"- else →
"RED"
- Else if
InputMilliVoltsValidistrue, computes status using thresholds onInputMilliVoltsandBatteryMilliVolts(see detailed logic in source). - Else →
"RED".
Write setter is a no-op; value is always regenerated on read.
- If
SLICEBaseInputReader
-
Constructor
SLICEBaseInputReader(ICommunication comm)
Initializes the reader with a communication interface (ICommunication). Throws no exceptions documented. -
InputMilliVolts(virtual property)
Returns the input voltage in millivolts by querying theMeasureBaseDiagnosticChannelforBaseDiagnosticChannelList.InputVoltage. Multiplies raw measurement by1000.0. -
TemperatureC(virtual property)
Returns the temperature in degrees Celsius by queryingMeasureBaseDiagnosticChannelforBaseDiagnosticChannelList.TemperatureC. -
BatteryIsCharging(property)
Returnstrueif the base unit’s charge status switch (viaQuerySwitchImmediateforSwitches.BaseSwitches.ChargeStatus) is set to1. -
DirectBackupMilliVolts(virtual property)
Returns backup voltage in millivolts without enabling/disabling backup power. Returns0DifShouldMeasureBackupPower()returnsfalse. -
BackupMilliVolts(property)
Returns backup voltage in millivolts with power management:- If
ShouldEnableBackupPower()returnstrue, enables backup power, waits 1.5 seconds, reads viaDirectBackupMilliVolts, then disables backup power in afinallyblock. - If
ShouldEnableBackupPower()returnsfalse, directly returnsDirectBackupMilliVolts.
- If
-
ShouldEnableBackupPower()(private method)
Returnsfalsefor SLICE6, SLICE2, and USB variants (EthernetSlice6,EthernetSlice2,EthernetSlice6Air,EthernetSlice6AirBridge,EthernetTsrAir,WinUSBSlice6,CDCUSBSlice);trueotherwise. -
ShouldMeasureBackupPower()(public method)
Returnsfalsefor SLICE6 and USB variants (EthernetSlice6,EthernetSlice6Air,EthernetSlice6AirBridge,WinUSBSlice6,CDCUSBSlice),trueforEthernetSlice2andEthernetTsrAir, and defaults totruefor other types. -
EnableBackupPower()(private method)
SendsSetSwitchImmediatecommand to setSwitches.BaseSwitches.BackupPowerto1, but only ifShouldEnableBackupPower()returnstrue. -
DisableBackupPower()(private method)
SendsSetSwitchImmediatecommand to setSwitches.BaseSwitches.BackupPowerto0, but only ifShouldEnableBackupPower()returnstrue.
BaseInputValues (base class)
-
Properties
InputMilliVolts,InputVoltage(bothdouble)InputMilliVoltsValid(virtualbool) —trueifInputMilliVoltsis within(MinimumValidInputVoltage, MaximumValidInputVoltage)(default: 6–16 V).MinimumValidInputVoltage,MaximumValidInputVoltage(bothdouble, default 6 and 16).BatteryMilliVolts,BatteryVoltage(bothdouble)BatteryMilliVoltsValid(virtualbool) —trueifBatteryMilliVoltsis within(MinimumValidBatteryVoltage, MaximumValidBatteryVoltage)(default: 6–16 V).BatterySoC(double?) — battery state of charge (percentage),nullif not queried.MinimumValidBatteryVoltage,MaximumValidBatteryVoltage(bothdouble, default 6 and 16).BatteryIsCharging(bool)TemperatureC(double)BatteryVoltageStatus,InputVoltageStatus,StatusDisplayBattery,StatusDisplayInput(allstring, defaultnull)BatteryVoltageStatusColor,InputVoltageStatusColor(bothDFConstantsAndEnums.VoltageStatusColor, defaultnull)ChargeCapacity(double, defaultdouble.NaN)ChargeCapacityValid(bool) —trueifChargeCapacityis notNaN, and0 < ChargeCapacity < 100.
-
Constructors
- Default constructor.
- Copy constructor:
BaseInputValues(IBaseInputValues copy)— copies all properties from anotherIBaseInputValuesinstance.
3. Invariants
BatteryVoltageStatusinSLICEBaseInputValuesis always computed on read and never settable; the setter is a no-op.InputMilliVoltsValidandBatteryMilliVoltsValiddepend on configurable min/max thresholds (default 6–16 V), but are validated against raw millivolt values.ChargeCapacityValidrequiresChargeCapacityto be in(0, 100)and notNaN.BackupMilliVoltsalways disables backup power after measurement, regardless of success or failure, viafinallyblock.ShouldEnableBackupPower()andShouldMeasureBackupPower()may differ in behavior (e.g.,EthernetTsrAirreturnstrueforShouldMeasureBackupPower()butfalseforShouldEnableBackupPower()).- Backup power is not enabled for SLICE6 or USB variants (
EthernetSlice6,EthernetSlice6Air,EthernetSlice6AirBridge,WinUSBSlice6,CDCUSBSlice), perShouldEnableBackupPower().
4. Dependencies
Imports/Usings
System.Threading→ used forThread.Sleep(1500)inBackupMilliVolts.DTS.Common.Interface.DASFactory→ providesICommunication,MeasureBaseDiagnosticChannel,QuerySwitchImmediate,SetSwitchImmediate,Switches,MeasureBaseDiagnosticChannel.BaseDiagnosticChannelList.DTS.DASLib.Command.SLICE→ provides SLICE-specific command types (MeasureBaseDiagnosticChannel,QuerySwitchImmediate,SetSwitchImmediate,Switches).DTS.Common.Enums.DASFactory→ providesDFConstantsAndEnums.VoltageStatusColor.DTS.Common.Interface.DASFactory.Diagnostics→ used viaIBaseInputValues.
Inferred Usage
SLICEBaseInputReaderis used by higher-level services (e.g.,DiagnosticsService.Diagnose) to populateBaseInputValuesinstances.SLICEBaseInputValuesis likely instantiated or assigned where SLICE-specific battery status logic is required.
5. Gotchas
BatteryVoltageStatuslogic is complex and voltage-threshold-dependent: The fallback logic for battery status whenChargeCapacityValidisfalsebutInputMilliVoltsValidistrueuses multiple nestedifconditions with overlapping voltage ranges (e.g.,InputMilliVolts > 11000,> 9000,< 9). This may be error-prone and could lead to unexpected status if input voltage is exactly at boundary values (e.g.,9000,11000,9000mV).BackupMilliVoltshas side effects: It enables/disables backup power even if the device does not support it (guarded byShouldEnableBackupPower()), but the 1.5-second delay (Thread.Sleep) may block the calling thread. This is not async-friendly.ShouldEnableBackupPower()vsShouldMeasureBackupPower()divergence:EthernetTsrAiris explicitly excluded from enabling backup power but should measure it — a subtle distinction that could cause confusion if not understood.ChargeCapacityValidexcludes0: A valid battery at 0% charge would be considered invalid (ChargeCapacityValid = false), potentially forcing fallback to voltage-based status even when charge data is present.- No validation on
BatteryMilliVoltsvsInputMilliVolts: The logic assumesBatteryMilliVoltsis always ≤InputMilliVoltswhen input is present, but no explicit checks exist. InputMilliVoltsValiduses1000D * MinimumValidInputVoltage: This is redundant sinceInputMilliVoltsis already in millivolts; could be simplified toInputMilliVolts > MinimumValidInputVoltage * 1000.