7.7 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||
|---|---|---|---|---|---|---|---|
|
2026-04-16T03:46:23.646675+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 6addfe530b08a7e8 |
IService
Documentation: SerializableDictionary<TKey, TValue> and Slice<T> Information Module
1. Purpose
This module provides two core components for the DAS (Data Acquisition System) service layer:
SerializableDictionary<TKey, TValue>is a generic dictionary implementation that supports XML serialization viaIXmlSerializable, enabling persistence of key-value metadata (e.g., user attributes for SlicePro/1.5 devices).- The
Slice<T>partial class (inSLICE Service.Information.cs) implements theIInformationActionsinterface to asynchronously query and populate device metadata (DASInfo) for each module in a Slice stack, including serial numbers, supported configurations, and capabilities.
Together, they support configuration discovery, state reporting, and data persistence in the Slice service layer.
2. Public Interface
SerializableDictionary<TKey, TValue>
-
GetSchema()
XmlSchema IXmlSerializable.GetSchema()
Returnsnull. Required byIXmlSerializablebut unused; no schema validation is enforced. -
ReadXml(XmlReader reader)
Deserializes XML into the dictionary. Expects root element<SerializedDictionary>containing repeated<Item>elements, each with<Key>and<Value>child elements. UsesXmlSerializerforTKeyandTValue.- Skips empty elements (
IsEmptyElement). - Reads
<Item>→<Key>→ deserialized key →<Value>→ deserialized value →Add(key, value). - Ends with
</SerializedDictionary>.
- Skips empty elements (
-
WriteXml(XmlWriter writer)
Serializes the dictionary to XML. Writes<SerializedDictionary>root, then iterates overKeys, writing each as<Item><Key>...</Key><Value>...</Value></Item>. UsesXmlSerializerfor keys and values.- Calls
writer.WriteStartDocument()andwriter.WriteEndDocument(). - Calls
writer.Flush()after each item.
- Calls
Note
: The class inherits from
Dictionary<TKey, TValue>, so all standard dictionary operations (Add,Item,Keys, etc.) are available.
Slice<T> (Information Region)
-
void IInformationActions.Query(ServiceCallback callback, object userData)
Initiates asynchronous execution ofAsyncQueryInformationviaLaunchAsyncWorker. Wraps callback and user data in aSliceServiceAsyncInfoobject. -
private void AsyncQueryInformation(object asyncInfo)
Executes the information query:- Sends
QueryStackContentscommand synchronously (SyncExecute()). - Constructs
InfoResultwith per-module metadata:ModuleNumber,SerialNumber,MaxRecordingSamples,NumberOfChannels,SupportedGains(cloned fromGainList),SupportedModes(hardcoded toCircularBuffer,RecorderMode),SupportedSampleRates(cloned fromSamplerateList),TypeOfModule=SliceBridge.
- Assigns result to
DASInfo. - Handles
CanceledException→info.Cancel(), other exceptions →info.Error(...).
Note
:
MaxNumberOfSamples,NumberOfChannelsPerModule,GainList, andSamplerateListare assumed to be defined elsewhere inSlice<T>(not visible in source). - Sends
-
private void DASFactoryQueryInformation()
Not part of the public interface (private method). Appears to be a duplicate ofAsyncQueryInformationbut usesStackContentsQueryinstead ofQueryStackContents.- Bug/Inconsistency: Contains a reference to
info.Success()/info.Cancel()/info.Error(...), butinfois not defined in scope (should bevar info = asyncInfo as SliceServiceAsyncInfo;). This is likely a copy-paste error or incomplete refactoring.
- Bug/Inconsistency: Contains a reference to
3. Invariants
-
SerializableDictionary- XML structure must match:
<SerializedDictionary><Item><Key>...</Key><Value>...</Value></Item>...</SerializedDictionary>. TKeyandTValuemust be serializable viaXmlSerializer(i.e., public parameterless constructor, public read/write properties/fields, or attributed appropriately).- Keys must be unique (enforced by
Dictionary<TKey, TValue>base class). ReadXmldoes not clear existing entries before deserialization (risk of duplicate key exceptions if deserializing into a non-empty instance).
- XML structure must match:
-
Slice<T>.QueryDASInfois overwritten on each successful query.SupportedModesis hardcoded to two values (CircularBuffer,RecorderMode) — not dynamically determined from hardware.SupportedGainsandSupportedSampleRatesare cloned from class-level fields (GainList,SamplerateList), implying these fields are populated elsewhere (e.g., during initialization).MaxNumberOfSamples,NumberOfChannelsPerModule,GainList,SamplerateListmust be initialized beforeQueryis called.
4. Dependencies
SerializableDictionary<TKey, TValue>
- Depends on:
System.Xml.Serialization(XmlRoot,IXmlSerializable,XmlSerializer)System.Collections.Generic(viaDictionary<TKey, TValue>)
- Used by:
- Presumably other modules needing serializable dictionaries (e.g., user attributes in
SlicePro/1.5), though no direct usage is visible in the provided files.
- Presumably other modules needing serializable dictionaries (e.g., user attributes in
Slice<T> (Information Module)
- Depends on:
DTS.DASLib.Command.SLICE.QueryStackContents(forAsyncQueryInformation)DTS.DASLib.Command.SLICE.StackContentsQuery(forDASFactoryQueryInformation)DTS.DASLib.Service.SliceServiceAsyncInfo(for async callback handling)DTS.DASLib.Service.InfoResult(for result structure)- Class-level fields:
MaxNumberOfSamples,NumberOfChannelsPerModule,GainList,SamplerateList - Base class
Communication<T>and interfaces (IInformationActions, etc.)
- Used by:
- External callers invoking
IInformationActions.Query(...)(e.g., UI or orchestration layer).
- External callers invoking
5. Gotchas
-
SerializableDictionaryWriteXmlcallswriter.WriteStartDocument()andwriter.WriteEndDocument(), which may conflict if the writer is already positioned inside an XML document (e.g., when serializing as part of a larger document).- No handling for duplicate keys during
ReadXml; will throwArgumentExceptionif the XML contains duplicate keys. ReadXmldoes not validate element names beyond"Item","Key","Value"— malformed XML may causeXmlExceptionor silent misbehavior.
-
Slice<T>DASFactoryQueryInformation()is broken:infois undefined (should bevar info = asyncInfo as SliceServiceAsyncInfo;). This method is likely unused or untested.SupportedModesis hardcoded — does not reflect actual hardware capabilities.GainList/SamplerateListcloning assumes shallow copy is sufficient (safe foruint[], but risky if types change to reference types).MaxRecordingSamplesandSupportedSampleRatesare set to fixed values (MaxNumberOfSamples,SamplerateList) — comments indicate these "should be adjusted to real-life", suggesting incomplete implementation.- No distinction between
QueryStackContentsandStackContentsQuery— unclear if they differ in behavior or are legacy variants.
-
General
Resources.Designer.csis auto-generated — manual edits will be lost. Localization strings for arming failures suggest error handling is partially implemented but may lack context (e.g.,{0}placeholder for device name).- No unit tests or examples provided; behavior relies on XML serialization contract and command execution semantics (not visible here).