12 KiB
12 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||
|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T03:34:52.105415+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 600a818df3b392d9 |
Documentation: DataModel.TestObject Module
1. Purpose
This module provides data model abstractions for ISO 13499-compliant test objects, templates, and related UI wrappers within the DataPROWin7 application. It serves as the bridge between low-level ISO database entities (DTS.Common.ISO.*) and high-level WPF UI components, enabling template management, test object instantiation, and channel configuration. The module supports both system-built and user-defined templates, embedded vs. external template references, and test-specific overrides (e.g., excitation settings, position assignments). It is central to test setup definition, serialization, and runtime configuration.
2. Public Interface
TemplateChannelUI
TemplateChannelUI(DTS.Common.ISO.TestObjectTemplateChannel channel)
Constructor that wraps an ISOTestObjectTemplateChannelinstance. Stores the channel in theChannelproperty.Channel(property)
Gets/sets the underlyingDTS.Common.ISO.TestObjectTemplateChannel. ImplementsINotifyPropertyChangedviaBasePropertyChanged.
TestObjectTemplateCollection
TemplateCollection(static property)
Singleton accessor. Returns the single instance ofTestObjectTemplateCollection, lazily initialized.SysBuiltTestObjectTemplate(property)
Returns the read-only system-built template (note:_sysBuiltTestObjectTemplateis declared but never initialized in the source — likely incomplete).GetTemplate(string templateId)(method)
Retrieves aTestObjectTemplatebytemplateIdfrom the ISO database (ApplicationProperties.IsoDb). Returnsnullif not found.
TestObjectList
TestObjectsList(static property)
Singleton accessor. Thread-safe (useslock(MyLock)). Returns the single instance ofTestObjectList.Add(TestObject to, bool bNotify)(method)
Adds aTestObjectto the list. SetsLastModifiedByandLastModifiedon the object, callsCommit(), and optionally raisesOnPropertyChanged("TestObjects")ifbNotifyistrue.UpdateAll()(method)
RaisesOnPropertyChanged("TestObjects")to notify UI of changes (e.g., after bulk operations).
TestTestObject
- Constructors
TestTestObject(TestObject obj)
Base constructor wrapping aTestObject.TestTestObject(TestTestObject obj, bool convertToEmbedded)
Copy constructor with support for converting to embedded mode (generates new GUIDs for template and serial number).TestTestObject(TestObject obj, bool convertToEmbedded)
Constructor for non-TestTestObjectinputs with embedded conversion support.TestTestObject(TestTestObject to)
Copy constructor for metadata (callsMetaCommonConstructor).
- Properties
Position(DTS.Common.ISO.MMEPositions)
Gets/sets the group position. When set toUserSetKey("@"), UI shows a button instead of a combo box. When set to a standard position, propagates the position to all required channels’ sensors.TestObject(DTS.Common.ISO.MMETestObjects)
Gets/sets the test object type. When set, propagates the test object to all required channels’ sensors.GroupPositionComboBoxVisible,GroupPositionButtonVisible(Visibility)
Controls UI visibility based onPositionvalue. Note: Non-ISO mode support is commented out.AvailableGroupPositions(MMEPositions[])
Returns an array containing_channelDefaultsGUID(#) and all positions fromApplicationProperties.IsoDb.GetPositions().AvailablePositions(MMEPositions[])
Returns positions fromApplicationProperties.IsoDb.GetPositions().ChannelTypes(string[])
Returns["(no channels)"]+ unique channel types fromApplicationProperties.IsoDb.AddedGroups(TestObject[])
Gets/sets a list of added system-built test objects; raisesOnPropertyChanged("AddedSysBuiltTestObjects")andOnPropertyChanged("AddedSysBuiltTestObjectsMME").DisplayOrder,IsAdd,SysBuilt,SerialNumberConverted
Metadata properties (no explicit backing fields beyondDisplayOrderandIsAdd).ExcitationWarmupTimeMS,TargetSampleRate,PreTriggerSeconds,PostTriggerSeconds
Test-specific configuration properties.
- Methods
Rename(string oldName, string newName)
UpdatesSerialNumber,OriginalSerialNumber,OriginalTemplate,TestSetupName, and generates new GUIDs forTemplateNameandOriginalTemplateName.SetTestObject(string s),SetPosition(string s)
Low-level setters that bypass property change notifications forPosition/TestObjectUI visibility logic.CompareTo(TestTestObject other)
Compares byDisplayOrder, then falls back to base comparison.
TestObjectTemplate
- Constructors
TestObjectTemplate()
Default constructor; initializes with empty strings and first available test object.TestObjectTemplate(TestObjectTemplate copy, ref ISO13499FileDb db)
Deep copy constructor.TestObjectTemplate(DTS.Common.ISO.TestObjectTemplate template, ref ISO13499FileDb db)
Wraps an ISO template.TestObjectTemplate(DTS.Common.ISO.TestObjectTemplate template, ref ISO13499FileDb db, List<MMETestObjects> testObjects)
Wraps an ISO template, preferring a provided list ofMMETestObjects.
- Properties
TemplateName,TemplateDescription,LastModified,LastModifiedBy,TemplateParent,SysBuilt,IsLocalOnly,Embedded,OriginalTemplateName
Standard metadata properties.EmbeddedandOriginalTemplateNamesynchronize with the underlying_templateobject.TestObject(MMETestObjects),TestObjectType(string)
Gets/sets test object and type. SettingTestObjectTypetriggers channel list regeneration and order assignment.RequiredChannels(List<TestObjectTemplateChannel>)
List of required channels (not auto-populated; must be set explicitly).TemplateAllChannels(TestObjectTemplateChannel[]),TemplateAllUIChannels(TemplateChannelUI[])
Arrays of all channels.TemplateAllChannelsstores the raw ISO channels;TemplateAllUIChannelswraps them inTemplateChannelUIfor UI binding.AvailableTestObjectTypes(string[])
Derived fromTestObjectviaApplicationProperties.IsoDb.GetTestObjectTypeForTestObject(...).TestObjectTypeIndex(int)
Index intoAvailableTestObjectTypes; setting it updatesTestObjectType.
- Methods
AssignOrders()
SortsTemplateAllChannelsand assignsDisplayOrderto channels with-1.ToISOTestObjectTemplate()
Converts to a standaloneDTS.Common.ISO.TestObjectTemplate(for persistence/export).MarkChanged(string tag)
RaisesOnPropertyChanged(tag).CompareTo(TestObjectTemplate rhs)
Compares byTemplateName(ordinal).ReadXML(XmlElement root, Dictionary<long, MMEPossibleChannels> importChannels)(static)
Deserializes an ISO template from XML. Delegates toProcessXMLElementandProcessChannelXMLNode.ProcessXMLElement,ProcessChannelXMLNode(private static)
XML parsing helpers.ProcessChannelXMLNodehandles channel-specific fields (e.g.,Required,DisplayOrder,LocalOnly,NameOfTheChannel).
3. Invariants
- Singleton Consistency:
TestObjectTemplateCollection.TemplateCollectionandTestObjectList.TestObjectsListare singletons.TestObjectsListuses explicit locking for thread safety;TemplateCollectiondoes not (potential race condition on first access). - Template Identity:
TestObjectTemplate.TemplateNameandOriginalTemplateNamemust be non-null.Embeddedtemplates useOriginalTemplateNamefor display (ToString()override). - Channel Ordering:
TestObjectTemplate.AssignOrders()ensuresDisplayOrderis non-decreasing and ≥ 0 for all channels after assignment. - Position Propagation:
SettingTestTestObject.Positionto a non-UserSetKeyvalue propagates the position to all required channels’ sensors viaSetSensor(...). - Test Object Propagation:
SettingTestTestObject.TestObjectpropagates the test object to all required channels’ sensors. - XML Field Validation:
ProcessChannelXMLNoderequiresMMEChannelIdandMMEChannelTypeto be present and parseable; otherwise, the channel is skipped. - Metadata Copying:
TestTestObjectcopy constructors callMetaCommonConstructorto ensure test-specific metadata (e.g.,ExcitationWarmupTimeMS,Position) is preserved.
4. Dependencies
Internal Dependencies
- Base Classes:
BasePropertyChanged(forINotifyPropertyChangedimplementation). - ISO Layer:
DTS.Common.ISO.TestObjectTemplate,TestObjectTemplateChannel,MMEPositions,MMETestObjects,MMEPossibleChannels,ISO13499FileDb. - Application Context:
ApplicationProperties.IsoDb(central database access),ApplicationProperties.CurrentUser(forLastModifiedBy). - WPF:
System.Windows.Visibility(for UI state).
External Dependencies
- Logging:
DTS.Common.Utilities.Logging(imported but no usage observed in source). - DataModel:
DTS.Common.DataModel(namespace for shared types). - Utilities:
System,System.Collections.Generic,System.Linq,System.Xml.
Usage by Other Modules
TestObjectTemplateCollectionis used to retrieve templates by ID (e.g., during test setup loading).TestObjectListis used to manage test objects in a list (e.g., during test execution).TestTestObjectis used for test-specific test objects with override capabilities.TemplateChannelUIis used in UI bindings for template channel properties.
5. Gotchas
- Uninitialized
SysBuiltTestObjectTemplate:
_sysBuiltTestObjectTemplateis declared but never assigned inTestObjectTemplateCollection. AccessingSysBuiltTestObjectTemplatewill returnnull. - Thread Safety Gap:
TestObjectTemplateCollection.TemplateCollectionis not thread-safe on first access (no locking), whileTestObjectList.TestObjectsListis. - Non-ISO Mode Code Commented Out:
GroupPositionComboBoxVisibleandGroupPositionButtonVisiblegetters contain commented-out logic forNO_ISOmode. This may cause unexpected UI behavior if non-ISO mode is active. - Channel Display Order Logic:
AssignOrders()andProcessChannelXMLNodeboth assignDisplayOrderto-1channels, butAssignOrders()uses the current max + 1, whileProcessChannelXMLNodeuses the newly added channel’s max + 1. This can lead to inconsistent ordering if channels are added incrementally. - Template Name Overwrite in
Rename:
RenamereplacesTemplateNameandOriginalTemplateNamewith new GUIDs, but does not updateTemplateParent. This may break template hierarchy references. TestObjectTemplateChannelDuplication:
TemplateAllChannelsandTemplateAllUIChannelsstore overlapping data.TemplateAllChannelsis derived from_allUIChannels, but setting one does not automatically sync the other (e.g.,TemplateAllChannelssetter callsTemplateAllUIChannels = ..., but not vice versa).TestTestObjectConstructor Overload Ambiguity:
Two constructors accept(TestObject obj, bool convertToEmbedded). One is forTestTestObject, the other forTestObject. This may cause confusion or unintended behavior if misused._userSetGUIDand_channelDefaultsGUID:
These staticMMEPositionsinstances are created withGuid.NewGuid()at type initialization. If multiple app domains or test runs occur, GUIDs may collide or behave unexpectedly (though unlikely in practice).ToISOTestObjectTemplateOmits Fields:
The method does not copyVersion,CRC32, orIconto the resulting ISO template, even though these are part ofGroupTemplateFields.ProcessChannelXMLNodeIgnores Many Fields:
SeveralGroupTemplateChannelFields(e.g.,BitResolution,ChannelAmplitudeClass,Comments) are parsed but not applied to the channel. This may lead to data loss during XML import.