13 KiB
13 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T05:00:11.636548+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 5a4f5e976b551f99 |
Documentation: DatabaseExport.TestObject Module
1. Purpose
This module provides a legacy (Version57) abstraction layer over ISO 13499 test object and template data for database export operations. It encapsulates domain entities—such as TestObject, TestObjectTemplate, and TestTestObject—and their relationships, enabling retrieval, manipulation, and serialization of test configuration data (including channel definitions, zones, and metadata) from a database-backed ISO 13499 file structure. It serves as an intermediate layer between raw database access (DbOperations, ISO13499FileDb) and higher-level UI or export logic, specifically supporting legacy workflows where templates and test objects must be exported or migrated.
2. Public Interface
TemplateChannelUI
- Constructor:
public TemplateChannelUI(TestObjectTemplateChannel channel)- Wraps a
TestObjectTemplateChannelinstance for UI binding purposes. No additional behavior beyond storage.
- Wraps a
GroupTemplateTableInfo
- Constructor:
public GroupTemplateTableInfo(string templateName, SerializedSettings.ISOSupportLevels isoSupportLevel, bool sysBuilt, string templateDescription, DateTime lastModified, string lastModifiedBy, bool embedded)- Immutable data transfer object (DTO) representing metadata for a test object template.
- Properties:
TemplateName(string)ISOSupportLevel(SerializedSettings.ISOSupportLevels)SysBuilt(bool)TemplateDescription(string)LastModified(DateTime)LastModifiedBy(string)Embedded(bool)
- Overrides:
ToString()returnsTemplateName.
TestObjectList
- Static Property:
public static TestObjectList TestObjectsList { get; }- Implements lazy-initialized singleton pattern (thread-safe via
lock). Returns the single instance ofTestObjectList.
- Implements lazy-initialized singleton pattern (thread-safe via
- Instance Method:
public List<string> GetAllGroupSerialNumbers()- Queries
tblTestObjectsfor allSerialNumbervalues, deduplicates, and returns them as aList<string>.
- Queries
- Instance Method:
public TestObject GetTestObject(string serialNumber)- Retrieves a
TestObjectbyserialNumberusingISO.TestObject.GetTestObject, wrapping the result in a newTestObjectinstance withSysBuiltflag preserved. Returnsnullif not found.
- Retrieves a
- Instance Method:
public TestObject GetAddedGroup(string serialNumber)- Alias for
GetTestObject. Delegates directly to it.
- Alias for
TestObjectTemplateCollection
- Static Property:
public static TestObjectTemplateCollection TemplateCollection { get; }- Thread-safe lazy singleton via double-checked locking (
volatile+ null-coalescing assignment).
- Thread-safe lazy singleton via double-checked locking (
- Instance Method:
public GroupTemplateTableInfo[] GetAllTemplates(bool bIncludeEmbeddedAndSysBuilt = true)- Queries
tblTestObjectTemplates. IfbIncludeEmbeddedAndSysBuiltisfalse, filters rows whereEmbedded = 0 OR NULLandSysBuilt = 0. - For each row, constructs a
GroupTemplateTableInfo:ISOSupportLevelis inferred:NO_ISOifTestObjectTypecontainsNON_ISO_TESTOBJECT_CHANNEL_TYPEorNONISOCHANNELTYPE; otherwiseISO_ONLY.Embeddedis safely parsed (treatsDBNullasfalse).
- Returns array of
GroupTemplateTableInfo.
- Queries
- Instance Property:
public TestObjectTemplate SysBuiltTestObjectTemplate { get; }- Returns the static
_sysBuiltTestObjectTemplatefield (currently unassigned in source; alwaysnull).
- Returns the static
- Instance Method:
public TestObjectTemplate GetTemplate(string templateId)- Retrieves a template by
templateIdviaISO.TestObjectTemplate.GetTemplate. - If not found, returns a default-constructed
TestObjectTemplate(); otherwise wraps the ISO template in a newTestObjectTemplate.
- Retrieves a template by
TestTestObject
- Constructor:
public TestTestObject(TestObject obj)- Base constructor; delegates to
TestObjectbase class.
- Base constructor; delegates to
- Properties:
Position(MMEPositions)- Gets/sets position key (
#= channel defaults,@= user-set/multiple). - On set: updates
_position, togglesGroupPositionComboBoxVisible/GroupPositionButtonVisible, and if notUserSetKey, propagates position to all required sensors with valid serial numbers.
- Gets/sets position key (
GroupPositionComboBoxVisible,GroupPositionButtonVisible(System.Windows.Visibility)- Visibility depends on
ISOSupportLevel: alwaysCollapsedifNO_ISO; otherwise reflects internal_groupPosition*fields.
- Visibility depends on
TestObject(MMETestObjects)- Gets/sets the test object. On set, propagates
TestObject.Test_Objectto all required sensors with valid serial numbers.
- Gets/sets the test object. On set, propagates
AvailablePositions(MMEPositions[])- Returns all positions from
ISO13499FileDb.IsoDb.GetPositions().
- Returns all positions from
AvailableGroupPositions(MMEPositions[])- Returns
AvailablePositions+ a specialChannelDefaultsKey(#) entry and aUserSetKey(@) entry.
- Returns
ExcitationWarmupTimeMS(int)- Gets/sets warmup time (ms), default from
Properties.Settings.Default.DefaultTestExcitationWarmupMS.
- Gets/sets warmup time (ms), default from
TargetSampleRate(double)- Gets/sets target sample rate.
- Constants:
ChannelDefaultsKey = "#"UserSetKey = "@"
- Methods:
SetTestObject(string s),SetPosition(string s)- Setters that bypass property change propagation logic (e.g., no sensor propagation); only update backing field and raise
OnPropertyChanged.
- Setters that bypass property change propagation logic (e.g., no sensor propagation); only update backing field and raise
TestObjectTemplate
- Constants:
NON_ISO_TESTOBJECT_CHANNEL_TYPE = "x_NonISOTestObjectType_x"NON_ISO_TESTOBJECT_NAME = "x_NonISOTestObjectName_x"
- Properties:
LastModifiedBy(string, default"N/A")LastModified(DateTime, defaultSqlDateTime.MinValue)CurrentZoneIndex(int)- Setter updates
CurrentZoneandAreZoneControlsEnabled.
- Setter updates
CurrentZone(Zone)- Setter toggles
AreZoneControlsEnabledbased on nullability.
- Setter toggles
AreZoneControlsEnabled(bool)RequiredChannels(List<TestObjectTemplateChannel>)TemplateParent(string)SysBuilt(bool)Embedded(bool)OriginalTemplateName(string)TemplateName(string)TemplateDescription(string)IsLocalOnly(bool)TestObject(MMETestObjects)- Setter initializes
AvailableTestObjectTypesandTestObjectTypeIndex.
- Setter initializes
TestObjectType(string)- Setter populates
_channelsandTemplateAllChannels.
- Setter populates
TemplateAllChannels(TestObjectTemplateChannel[])- Getter sorts by
DisplayOrder; setter buildsTemplateAllUIChannels.
- Getter sorts by
TemplateAllUIChannels(TemplateChannelUI[])TemplateZones(Zone[])AvailableTestObjectTypes(string[])- Lazy-initialized from
ISO13499FileDb.IsoDb.GetTestObjectTypeForTestObject.
- Lazy-initialized from
TestObjectTypeIndex(int)- Getter: index in
AvailableTestObjectTypes; setter: updatesTestObjectTypeand rebuilds channels.
- Getter: index in
- Static Methods:
GetNonISOTestObject()- Finds or creates a system test object with code
NON_ISO_TESTOBJECT_NAME. Returns first unused alpha (A–Z) or numeric (0–9) code. ThrowsNotSupportedExceptionif none available.
- Finds or creates a system test object with code
- Instance Methods:
ToISOTestObjectTemplate()- Converts this instance to an
ISO.TestObjectTemplate, including zones, regions, channels, and metadata. Includes extensive logging viaEventLog.
- Converts this instance to an
GetValues()- Returns a dictionary mapping
GroupTemplateFieldsenum names to string values (from the ISO template).
- Returns a dictionary mapping
GetTemplateChannelValues(TestObjectTemplateChannel channel)- Returns a dictionary mapping
GroupTemplateChannelFieldsenum names to string values (from the channel).
- Returns a dictionary mapping
- Constructors:
TestObjectTemplate(TestObjectTemplate copy, ref ISO13499FileDb db)- Deep copy constructor.
TestObjectTemplate(ISO.TestObjectTemplate template, ref ISO13499FileDb db)- Wraps an ISO template.
TestObjectTemplate()- Default constructor: initializes
TestObjectbased onSerializedSettings.ISOSupportLevel. ForNO_ISO, callsInitializeNonISO().
- Default constructor: initializes
3. Invariants
- Singleton Consistency:
TestObjectList.TestObjectsListandTestObjectTemplateCollection.TemplateCollectionare lazily initialized singletons. Once created, the same instance persists for the application lifetime.
- Template Channel Sorting:
TestObjectTemplate.TemplateAllChannelsgetter always returns channels sorted byDisplayOrder.
- ISO Support Level Inference:
TestObjectTemplateCollection.GetAllTemplatesinfersISOSupportLevelstrictly based onTestObjectTypestring content (NON_ISO_TESTOBJECT_CHANNEL_TYPEorNONISOCHANNELTYPE→NO_ISO; else →ISO_ONLY).
- Embedded Field Handling:
GroupTemplateTableInfo.EmbeddedandTestObjectTemplate.Embeddedsafely handleDBNullin database queries (treated asfalse).
- Non-ISO Template Initialization:
- When
TestObjectTemplate()is constructed withNO_ISOsupport level,TestObjectis set to a system-created object with codeNON_ISO_TESTOBJECT_NAME, andTestObjectTypeis set toNON_ISO_TESTOBJECT_CHANNEL_TYPE.
- When
4. Dependencies
Imports/Usings
System,System.Collections.Generic,System.Data(viaDataRow,DataSet)DatabaseExportnamespace (same module)ISOnamespace (e.g.,ISO.TestObject,ISO.TestObjectTemplate,ISO13499FileDb)SerializedSettings(forISOSupportLevels)Properties.Settings(forDefaultTestExcitationWarmupMS)System.Diagnostics(forEventLog)
External Dependencies
- Database:
tblTestObjects(used byTestObjectList.GetAllGroupSerialNumbers)tblTestObjectTemplates(used byTestObjectTemplateCollection.GetAllTemplates)
- ISO Layer:
ISO13499FileDb.IsoDb(static property) for database access and metadata lookups.DbOperations.GetCommand()andDbOperations.Connection.QueryDataSet()for SQL execution.
- UI Framework:
System.Windows.Visibility(used inTestTestObjectfor WPF visibility properties).
- Other Modules:
MMEPositions,MMETestObjects,MMEPossibleChannels(fromISOor related modules).Zone,TemplateZone,TemplateRegion(referenced but not defined here; assumed external).
Dependents
- Inferred:
- UI layers (e.g., WPF) consuming
TemplateChannelUI,TestTestObject,GroupTemplateTableInfo. - Export/migration workflows relying on
TestObjectTemplateCollection.GetAllTemplates()andTestObjectList.TestObjectsList.
- UI layers (e.g., WPF) consuming
5. Gotchas
SysBuiltTestObjectTemplateis alwaysnull:- The static field
_sysBuiltTestObjectTemplateinTestObjectTemplateCollectionis declared but never assigned. AccessingSysBuiltTestObjectTemplatewill always returnnull.
- The static field
TestObjectTemplateCollection.GetAllTemplates()filtersEmbeddedpermissive:DBNullvalues inEmbeddedcolumn are treated asfalse, which may differ from database semantics ifNULLhas special meaning.
TestObjectTemplate.GetTemplate()returns default instance on failure:- Returns a new
TestObjectTemplate()(with default properties) instead ofnullwhen template is not found, potentially masking errors.
- Returns a new
TestTestObject.Positionpropagation is conditional:- Sensor position updates only occur for required channels with non-whitespace
SensorSerialNumber. Channels missing these are silently skipped.
- Sensor position updates only occur for required channels with non-whitespace
TestObjectTemplate()constructor behavior depends on global settings:- Default constructor behavior changes based on
SerializedSettings.ISOSupportLevel, which may not be obvious to callers expecting consistent initialization.
- Default constructor behavior changes based on
GetNonISOTestObject()may throw:- If no unused single-character test object codes (
A–Z,0–9) are available, it throwsNotSupportedExceptioninstead of returningnullor retrying.
- If no unused single-character test object codes (
TemplateAllChannelssetter rebuildsTemplateAllUIChannels:- Assigning directly to
TemplateAllChannelstriggers construction of newTemplateChannelUIwrappers. This side effect is not obvious from the property name.
- Assigning directly to
CurrentZoneIndexsetter has side effects:- Setting
CurrentZoneIndexupdatesCurrentZoneand togglesAreZoneControlsEnabled, which may affect UI state unexpectedly if not coordinated.
- Setting
TestObjectTemplate.ToISOTestObjectTemplate()logs heavily:- Uses
EventLog.Source = "DataPROInstaller"and writes many entries. May impact performance or cause issues in non-installer contexts (e.g., unit tests).
- Uses