Files
DP44/enriched-qwen3-coder-next/DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestObject.md
2026-04-17 14:55:32 -04:00

13 KiB
Raw Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestObject/TemplateChannelUI.cs
DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestObject/GroupTemplateTableInfo.cs
DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestObject/TestObjectList.cs
DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestObject/TestObjectTemplateCollection.cs
DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestObject/TestTestObject.cs
DataPRO/Modules/PreviousDBVersions/Version57/DatabaseExport/Classes/TestObject/TestObjectTemplate.cs
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 TestObjectTemplateChannel instance for UI binding purposes. No additional behavior beyond storage.

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() returns TemplateName.

TestObjectList

  • Static Property: public static TestObjectList TestObjectsList { get; }
    • Implements lazy-initialized singleton pattern (thread-safe via lock). Returns the single instance of TestObjectList.
  • Instance Method: public List<string> GetAllGroupSerialNumbers()
    • Queries tblTestObjects for all SerialNumber values, deduplicates, and returns them as a List<string>.
  • Instance Method: public TestObject GetTestObject(string serialNumber)
    • Retrieves a TestObject by serialNumber using ISO.TestObject.GetTestObject, wrapping the result in a new TestObject instance with SysBuilt flag preserved. Returns null if not found.
  • Instance Method: public TestObject GetAddedGroup(string serialNumber)
    • Alias for GetTestObject. Delegates directly to it.

TestObjectTemplateCollection

  • Static Property: public static TestObjectTemplateCollection TemplateCollection { get; }
    • Thread-safe lazy singleton via double-checked locking (volatile + null-coalescing assignment).
  • Instance Method: public GroupTemplateTableInfo[] GetAllTemplates(bool bIncludeEmbeddedAndSysBuilt = true)
    • Queries tblTestObjectTemplates. If bIncludeEmbeddedAndSysBuilt is false, filters rows where Embedded = 0 OR NULL and SysBuilt = 0.
    • For each row, constructs a GroupTemplateTableInfo:
      • ISOSupportLevel is inferred: NO_ISO if TestObjectType contains NON_ISO_TESTOBJECT_CHANNEL_TYPE or NONISOCHANNELTYPE; otherwise ISO_ONLY.
      • Embedded is safely parsed (treats DBNull as false).
    • Returns array of GroupTemplateTableInfo.
  • Instance Property: public TestObjectTemplate SysBuiltTestObjectTemplate { get; }
    • Returns the static _sysBuiltTestObjectTemplate field (currently unassigned in source; always null).
  • Instance Method: public TestObjectTemplate GetTemplate(string templateId)
    • Retrieves a template by templateId via ISO.TestObjectTemplate.GetTemplate.
    • If not found, returns a default-constructed TestObjectTemplate(); otherwise wraps the ISO template in a new TestObjectTemplate.

TestTestObject

  • Constructor: public TestTestObject(TestObject obj)
    • Base constructor; delegates to TestObject base class.
  • Properties:
    • Position (MMEPositions)
      • Gets/sets position key (# = channel defaults, @ = user-set/multiple).
      • On set: updates _position, toggles GroupPositionComboBoxVisible/GroupPositionButtonVisible, and if not UserSetKey, propagates position to all required sensors with valid serial numbers.
    • GroupPositionComboBoxVisible, GroupPositionButtonVisible (System.Windows.Visibility)
      • Visibility depends on ISOSupportLevel: always Collapsed if NO_ISO; otherwise reflects internal _groupPosition* fields.
    • TestObject (MMETestObjects)
      • Gets/sets the test object. On set, propagates TestObject.Test_Object to all required sensors with valid serial numbers.
    • AvailablePositions (MMEPositions[])
      • Returns all positions from ISO13499FileDb.IsoDb.GetPositions().
    • AvailableGroupPositions (MMEPositions[])
      • Returns AvailablePositions + a special ChannelDefaultsKey (#) entry and a UserSetKey (@) entry.
    • ExcitationWarmupTimeMS (int)
      • Gets/sets warmup time (ms), default from Properties.Settings.Default.DefaultTestExcitationWarmupMS.
    • 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.

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, default SqlDateTime.MinValue)
    • CurrentZoneIndex (int)
      • Setter updates CurrentZone and AreZoneControlsEnabled.
    • CurrentZone (Zone)
      • Setter toggles AreZoneControlsEnabled based on nullability.
    • AreZoneControlsEnabled (bool)
    • RequiredChannels (List<TestObjectTemplateChannel>)
    • TemplateParent (string)
    • SysBuilt (bool)
    • Embedded (bool)
    • OriginalTemplateName (string)
    • TemplateName (string)
    • TemplateDescription (string)
    • IsLocalOnly (bool)
    • TestObject (MMETestObjects)
      • Setter initializes AvailableTestObjectTypes and TestObjectTypeIndex.
    • TestObjectType (string)
      • Setter populates _channels and TemplateAllChannels.
    • TemplateAllChannels (TestObjectTemplateChannel[])
      • Getter sorts by DisplayOrder; setter builds TemplateAllUIChannels.
    • TemplateAllUIChannels (TemplateChannelUI[])
    • TemplateZones (Zone[])
    • AvailableTestObjectTypes (string[])
      • Lazy-initialized from ISO13499FileDb.IsoDb.GetTestObjectTypeForTestObject.
    • TestObjectTypeIndex (int)
      • Getter: index in AvailableTestObjectTypes; setter: updates TestObjectType and rebuilds channels.
  • Static Methods:
    • GetNonISOTestObject()
      • Finds or creates a system test object with code NON_ISO_TESTOBJECT_NAME. Returns first unused alpha (AZ) or numeric (09) code. Throws NotSupportedException if none available.
  • Instance Methods:
    • ToISOTestObjectTemplate()
      • Converts this instance to an ISO.TestObjectTemplate, including zones, regions, channels, and metadata. Includes extensive logging via EventLog.
    • GetValues()
      • Returns a dictionary mapping GroupTemplateFields enum names to string values (from the ISO template).
    • GetTemplateChannelValues(TestObjectTemplateChannel channel)
      • Returns a dictionary mapping GroupTemplateChannelFields enum names to string values (from the channel).
  • 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 TestObject based on SerializedSettings.ISOSupportLevel. For NO_ISO, calls InitializeNonISO().

3. Invariants

  • Singleton Consistency:
    • TestObjectList.TestObjectsList and TestObjectTemplateCollection.TemplateCollection are lazily initialized singletons. Once created, the same instance persists for the application lifetime.
  • Template Channel Sorting:
    • TestObjectTemplate.TemplateAllChannels getter always returns channels sorted by DisplayOrder.
  • ISO Support Level Inference:
    • TestObjectTemplateCollection.GetAllTemplates infers ISOSupportLevel strictly based on TestObjectType string content (NON_ISO_TESTOBJECT_CHANNEL_TYPE or NONISOCHANNELTYPENO_ISO; else → ISO_ONLY).
  • Embedded Field Handling:
    • GroupTemplateTableInfo.Embedded and TestObjectTemplate.Embedded safely handle DBNull in database queries (treated as false).
  • Non-ISO Template Initialization:
    • When TestObjectTemplate() is constructed with NO_ISO support level, TestObject is set to a system-created object with code NON_ISO_TESTOBJECT_NAME, and TestObjectType is set to NON_ISO_TESTOBJECT_CHANNEL_TYPE.

4. Dependencies

Imports/Usings

  • System, System.Collections.Generic, System.Data (via DataRow, DataSet)
  • DatabaseExport namespace (same module)
  • ISO namespace (e.g., ISO.TestObject, ISO.TestObjectTemplate, ISO13499FileDb)
  • SerializedSettings (for ISOSupportLevels)
  • Properties.Settings (for DefaultTestExcitationWarmupMS)
  • System.Diagnostics (for EventLog)

External Dependencies

  • Database:
    • tblTestObjects (used by TestObjectList.GetAllGroupSerialNumbers)
    • tblTestObjectTemplates (used by TestObjectTemplateCollection.GetAllTemplates)
  • ISO Layer:
    • ISO13499FileDb.IsoDb (static property) for database access and metadata lookups.
    • DbOperations.GetCommand() and DbOperations.Connection.QueryDataSet() for SQL execution.
  • UI Framework:
    • System.Windows.Visibility (used in TestTestObject for WPF visibility properties).
  • Other Modules:
    • MMEPositions, MMETestObjects, MMEPossibleChannels (from ISO or 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() and TestObjectList.TestObjectsList.

5. Gotchas

  • SysBuiltTestObjectTemplate is always null:
    • The static field _sysBuiltTestObjectTemplate in TestObjectTemplateCollection is declared but never assigned. Accessing SysBuiltTestObjectTemplate will always return null.
  • TestObjectTemplateCollection.GetAllTemplates() filters Embedded permissive:
    • DBNull values in Embedded column are treated as false, which may differ from database semantics if NULL has special meaning.
  • TestObjectTemplate.GetTemplate() returns default instance on failure:
    • Returns a new TestObjectTemplate() (with default properties) instead of null when template is not found, potentially masking errors.
  • TestTestObject.Position propagation is conditional:
    • Sensor position updates only occur for required channels with non-whitespace SensorSerialNumber. Channels missing these are silently skipped.
  • 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.
  • GetNonISOTestObject() may throw:
    • If no unused single-character test object codes (AZ, 09) are available, it throws NotSupportedException instead of returning null or retrying.
  • TemplateAllChannels setter rebuilds TemplateAllUIChannels:
    • Assigning directly to TemplateAllChannels triggers construction of new TemplateChannelUI wrappers. This side effect is not obvious from the property name.
  • CurrentZoneIndex setter has side effects:
    • Setting CurrentZoneIndex updates CurrentZone and toggles AreZoneControlsEnabled, which may affect UI state unexpectedly if not coordinated.
  • 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).