8.1 KiB
8.1 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T02:42:22.673078+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | f67a48400fa70da5 |
ChannelSettings
Documentation: Channel Settings Module
1. Purpose
This module defines core data structures for modeling channel configuration settings in the DTS system. It provides three key classes: ChannelSettingRecord (a metadata record describing a type of setting), GroupChannelSettingRecord (an instance of a setting applied to a specific channel), and ChannelSettingBase (a concrete implementation of IChannelSetting that supports typed value accessors and constant-based setting name definitions). Together, they enable storage, retrieval, and manipulation of channel-specific configuration values, with support for multiple channel types (analog, digital, squib, UART, etc.) and versioned database interactions.
2. Public Interface
ChannelSettingRecord
ChannelSettingRecord()
Default constructor; initializes an empty record.ChannelSettingRecord(IDataReader reader)
Populates the record from anIDataReaderby reading columns"Id","SettingName", and"DefaultValue"usingUtility.GetIntandUtility.GetString.int Id
Gets/sets the unique identifier for this setting definition.string SettingName
Gets/sets the canonical name of the setting (e.g.,"Range","SquibCurrent").string DefaultValue
Gets/sets the default value string for this setting.
GroupChannelSettingRecord
GroupChannelSettingRecord()
Default constructor; initializes an empty record.GroupChannelSettingRecord(IDataReader reader, int storedProcedureVersionUsed)
Populates the record from anIDataReader. Behavior depends onstoredProcedureVersionUsed:- If
>= Constants.BULK_GROUPCHANNELSETTINGS_GET_DB_VERSION, reads"ChannelId"viaUtility.GetLong; otherwise setsChannelId = 0. - Always reads
"SettingId"(viaUtility.GetInt) and"SettingValue"(viaUtility.GetString).
- If
GroupChannelSettingRecord(long channelId, int settingId, string settingValue)
Constructor for programmatic creation; directly assignsChannelId,SettingId, andSettingValue.long ChannelId
Gets/sets the channel identifier the setting applies to.int SettingId
Gets/sets the foreign key referencingChannelSettingRecord.Id.string SettingValue
Gets/sets the actual value string for this channel’s setting instance.
ChannelSettingBase
ChannelSettingBase(int settingType, string name, string defaultValue)
Constructor initializingSettingTypeId,SettingName, andDefaultValue.IChannelSetting Clone()
Returns a newChannelSettingBaseinstance with all properties copied from the current instance.long ChannelId { get; set; }
Channel ID the setting applies to.int SettingTypeId { get; protected set; }
Type identifier for the setting (e.g., analog, digital).string SettingName { get; protected set; }
Name of the setting (e.g.,"Range").string DefaultValue { get; protected set; }
Default value string for this setting.string Value { get; set; }
Current value string for this setting instance.double DoubleValue { get; set; }
Gets/setsValueas adouble. Falls back toDoubleDefaultValueon parse failure.double DoubleDefaultValue { get; }
ParsesDefaultValueas adoubleusingCultureInfo.InvariantCulture.int IntValue { get; set; }
Gets/setsValueas anint. Falls back toIntDefaultValueon parse failure.int IntDefaultValue { get; }
ParsesDefaultValueas anintusingCultureInfo.InvariantCulture.bool BoolValue { get; set; }
Gets/setsValueas abool. Falls back toBoolDefaultValueon parse failure.bool BoolDefaultValue { get; }
ParsesDefaultValueas abool(uses defaultbool.Parsebehavior).
Constants (public static fields in ChannelSettingBase)
- Analog:
RANGE,CFC,FilterClass,POLARITY,POSITION,ZEROMETHOD,ZEROMETHODSTART,ZEROMETHODEND,USERVALUE1,USERVALUE2,USERVALUE3,INITIAL_OFFSET,ACCouplingEnabled - Deprecated:
LIMIT_DURATION,DURATION,DELAY(commented out) - Bridge/Insertion:
BRIDGE_TYPE - Squib:
SQUIB_CURRENT,SQUIB_LIMIT_DURATION,SQUIB_DURATION,SQUIB_DELAY,SQMODE - Digital Out:
DIGITALOUT_LIMIT_DURATION,DIGITALOUT_DURATION,DIGITALOUT_DELAY,OUTPUT_MODE - Digital In:
DIMODE,DEFAULT_VALUE,ACTIVE_VALUE - UART:
BAUD_RATE,DATA_BITS,STOP_BITS,PARITY,FLOW_CONTROL,DATA_FORMAT - Stream Out:
UDP_PROFILE,UDP_ADDRESS,UDP_TIME_CHID,UDP_DATA_CHID,UDP_TMNS_CONFIG,IRIG_TDP_INTERVAL_MS,TMATS_INTERVAL_MS - Stream In:
UDP_ADDRESS_IN
3. Invariants
ChannelSettingRecord.Idmust be non-negative (implied byinttype and database usage).GroupChannelSettingRecord.SettingIdmust correspond to a validChannelSettingRecord.Idin the database (enforced by foreign key at persistence layer, not here).GroupChannelSettingRecord.ChannelIdmay be0only when constructed fromIDataReaderwithstoredProcedureVersionUsed < Constants.BULK_GROUPCHANNELSETTINGS_GET_DB_VERSION. Otherwise, it must be positive.ChannelSettingBase.Valueis stored as a string; numeric/boolean accessors (DoubleValue,IntValue,BoolValue) parse it at runtime and fall back to defaults on failure.ChannelSettingBase.DefaultValuemust be parseable as the corresponding type (double,int,bool) forDoubleDefaultValue,IntDefaultValue, andBoolDefaultValueto succeed; otherwise, runtime exceptions may occur during parsing.
4. Dependencies
- Internal Dependencies:
DTS.Common.Interface.Channels(interfacesIChannelSettingRecord,IGroupChannelSettingRecord,IChannelSetting)DTS.Common.Base.BasePropertyChanged(base class forChannelSettingRecord)DTS.Common.Base.BasePropertyChanged(base class forGroupChannelSettingRecord)DTS.Common.Interface.Channels(interfaceIChannelSetting)System.Data(IDataReader)Utilityclass (static methods:GetInt,GetString,GetLong)Constantsclass (reference toBULK_GROUPCHANNELSETTINGS_GET_DB_VERSION)
- External Dependencies:
System(core types,CultureInfo,NumberStyles)DTS.Common.Interface.Channels(consumed by other modules for channel configuration management)
5. Gotchas
GroupChannelSettingRecordconstructor withIDataReadersilently setsChannelId = 0whenstoredProcedureVersionUsed < Constants.BULK_GROUPCHANNELSETTINGS_GET_DB_VERSION. This may mask missing data if the stored procedure version is misconfigured.ChannelSettingBaseparsing methods (DoubleValue,IntValue,BoolValue) do not distinguish between parse failure and a valid default value—e.g., ifValue = "0"andDefaultValue = "1",IntValuereturns0, not1. The fallback only occurs on parse failure (e.g.,Value = "abc").BoolDefaultValueusesbool.Parse(DefaultValue)withoutCultureInfo.InvariantCulture, unlike numeric defaults. This may cause culture-dependent failures ifDefaultValueis not"True"/"False"(case-sensitive).ChannelSettingBaseis mutable (Value,ChannelId, etc., have public setters). Cloning viaClone()is shallow but may be insufficient if consumers modify nested objects (none present here, but worth noting).ChannelSettingBasehas no validation onSettingNameorDefaultValue—invalid names or unparseable defaults may only surface at runtime during type conversion.ChannelSettingBaseconstants are string literals; typos in usage (e.g.,"Rang"instead of"Range") will compile but cause runtime mismatches with database or UI expectations.