8.6 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T03:40:40.401644+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 6e59e4819411113f |
Channel
Documentation: DTS.Serialization.Test.Module.Channel Submodule
1. Purpose
This module defines core serialization abstractions for channel data within the DTS test data serialization framework. It provides interfaces and classes to represent channel metadata, raw data arrays, and conversion mechanisms between domain-specific objects and a canonical Channel representation used for persistence or transmission. The module serves as the foundational layer for serializing and deserializing time-series channel data—including scaling, timing, and unit-conversion metadata—into and from XML.
2. Public Interface
IConvertable Interface
(Nested in DTS.Serialization.Test.Module.Channel)
-
Channel ToDtsSerializationTestModuleChannel()
Converts the implementing object into a canonicalChannelinstance. -
void FromDtsSerializationTestModuleChannel(Channel channel)
Initializes the implementing object using data from aChannelinstance.
Note
: This interface is intended to be implemented by domain objects that need to be serialized/deserialized as
Channelinstances. The interface name is intentionally misspelled (IConvertableinstead ofIConvertible) per source.
ChannelWithMeta Class
(Top-level in DTS.Serialization)
-
Channel Channel { get; }
The canonical channel object to be serialized. -
DataScaler Scaler { get; }
Scaling metadata associated with the channel. -
double SampleRate { get; }
Sample rate (in Hz) of the channel. -
double StartTime { get; }
Start time (in seconds) of the channel’s data. -
ChannelWithMeta(Channel channel, DataScaler scaler, double samplerate, double starttime)
Constructor initializing all properties. -
static double GetMinStartTime(double start, IList<ChannelWithMeta> channelsWithMeta)
Computes the earliest common start time across all provided channels and the givenstartoffset. UsesMath.Max(start, channelsWithMeta.Min(cwm => cwm.StartTime)).Comment in source: “Start is a generally a negative value, so to get the value for the start time of the minimum common data set, run Max()”.
-
static double GetMinStopTime(double stop, IList<ChannelWithMeta> channelsWithMeta)
Computes the latest common stop time across all channels. Uses:
Math.Min(stop, min(cwm.StartTime + (cwm.Channel.PersistentChannelInfo.Length - 1) / cwm.SampleRate)),
with intermediate casting todecimalto mitigate floating-point rounding errors.
DataArray<DataType> Class
(Nested in DTS.Serialization.Test.Module.Channel)
-
DataType[] Values { get; set; }
Underlying array of data values. Returns an empty array if uninitialized or null. -
double ScaleFactorMv { get; set; }
ADC-to-millivolt scaling factor. -
double MvPerEu { get; set; }
Sensitivity: millivolts per engineering unit. -
double ScaleFactorEU { get; set; }
EU scaling factor (unused in current XML schema per tags). -
bool UseEUScaleFactors { get; set; }
Flag indicating whether EU scale factors should be applied. -
short DataZeroLevel { get; set; }
Zero-level offset for ADC data. -
double UnitConversion { get; set; }
Unit conversion multiplier (default1.0). -
double Multiplier { get; set; }
General-purpose multiplier (default1.0). -
double UserOffsetEU { get; set; }
User-defined offset in engineering units (default0.0). -
DataArray()
Default constructor. -
DataArray(DataType[] values)
Constructor initializingValueswith the provided array. -
Implicit operator
List<DataType> → DataArray<DataType>
Converts aList<DataType>toDataArray<DataType>. -
Implicit operator
DataArray<DataType> → List<DataType>
ConvertsDataArray<DataType>toList<DataType>. -
void WriteXml(XmlWriter writer)
Serializes the instance to XML with the following structure:<Data Length="N" Type="System.Double" ScaleFactorMv="..." SensitivityMvEu="..."> <Datum Value="..." /> ... </Data>Includes attributes for
Length,Type,ScaleFactorMv, andSensitivityMvEu. Each datum is serialized as<Datum Value="..."/>. -
void ReadXml(XmlReader reader)
Deserializes XML into the instance. Requires:DataTypeto have a public staticParse(string)method.DataTypeto be constructible viaActivator.CreateInstance.- XML to contain
Length,Type,ScaleFactorMv, andSensitivityMvEuattributes.
-
XmlSchema GetSchema()
Always returnsnull. Per comment: “This method is never invoked during XML object serialization.” -
bool Equals(object obj)
Memberwise equality test: comparesScaleFactorMv,MvPerEu,Values.Length, and element-wiseValuesequality. -
int GetHashCode()
Returns base hash code (no custom hashing implemented).
3. Invariants
-
DataArray<DataType>Valuesis nevernullwhen accessed (returns empty array if uninitialized).- XML serialization/deserialization requires
DataTypeto implementParse(string)and be instantiable viaActivator.CreateInstance. ScaleFactorMvandMvPerEuare always serialized/deserialized as XML attributes (not child elements).DataZeroLevel,UseEUScaleFactors,UnitConversion,Multiplier,UserOffsetEUare not serialized in XML (no corresponding XML tags), though they are properties.
-
ChannelWithMetaGetMinStartTimeandGetMinStopTimeassumeStartTimeandSampleRateare non-negative and consistent across channels.GetMinStopTimeusesdecimalarithmetic internally to avoid floating-point rounding artifacts.
-
IConvertable- Implementers must ensure
FromDtsSerializationTestModuleChannelfully initializes the object from theChannelargument. ToDtsSerializationTestModuleChannelmust produce a fully populatedChannelinstance.
- Implementers must ensure
4. Dependencies
Imports/Usings
System,System.Collections.Generic,System.Linq→ used inChannelWithMeta.DTS.Common.DAS.Concepts→ providesDataScalertype (used inChannelWithMeta).System.Xml,System.Xml.Schema,System.Xml.Serialization→ used inDataArray<DataType>.DTS.Common.Utilities,DTS.Common.Utilities.DotNetProgrammingConstructs→ providesExceptionalbase class andProperty<T>wrapper (used inDataArray<DataType>).
Known Dependencies
DTS.Serialization.Test.Module.Channel(itself) —ChannelWithMetareferencesChannelandPersistentChannelInfo.Length.DataScaler— assumed to be defined inDTS.Common.DAS.Concepts.Property<T>— internal wrapper used for observable/validated properties inDataArray<T>.
Dependents (Inferred)
- Serialization/deserialization pipelines (e.g., XML writers/readers) that consume
DataArray<T>. - Higher-level serialization modules that use
IConvertableto bridge domain objects andChannel. ChannelWithMetaconsumers (e.g., file writers) that need to align multiple channels in time.
5. Gotchas
- Typo in interface name:
IConvertable(notIConvertible) — likely historical. DataArray<T>XML schema is incomplete: OnlyScaleFactorMvandMvPerEuare serialized; other properties (ScaleFactorEU,DataZeroLevel, etc.) are ignored in XML.GetSchema()always returnsnull: This is intentional per comment, but may confuse developers expecting a schema for validation.- Rounding mitigation in
GetMinStopTime: Usesdecimalcast to avoid floating-point artifacts (e.g.,4.999999999999995vs5.0), but this may be fragile ifStartTimeorSampleRateare very large/small. DataArray<T>requiresParse(string): IfDataTypelacks a staticParse(string)method,ReadXmlthrows an exception.Valuesproperty returns empty array if null: This avoids null-reference exceptions but may mask uninitialized state.- Implicit conversions are one-way in practice: While both implicit operators exist,
DataArray<T>is not aList<T>—conversions copy data, not reference.
None identified from source alone beyond the above.
Documentation generated from provided source files. No external assumptions or API speculation applied.