Files
DP44/docs/ai/DataPRO/Modules/DatabaseImporter/DatabaseImport.md
2026-04-17 14:55:32 -04:00

11 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/DatabaseImporter/DatabaseImport/CustomChannel.cs
DataPRO/Modules/DatabaseImporter/DatabaseImport/TestGraph.cs
DataPRO/Modules/DatabaseImporter/DatabaseImport/SerializedSettings.cs
DataPRO/Modules/DatabaseImporter/DatabaseImport/DbImporter.cs
2026-04-17T15:54:30.728728+00:00 zai-org/GLM-5-FP8 1 92a90606b341eecd

DatabaseImport Module Documentation

Purpose

The DatabaseImport namespace provides infrastructure for managing custom channel definitions beyond the ISO13499 standard, graph configurations for test visualization, serialized application settings storage, and XML-based database import/migration functionality. This module serves as a bridge between the ISO13499-compliant database schema and user-defined extensions, enabling test configuration persistence and cross-version database migrations.


Public Interface

CustomChannel.cs

CustomChannel Class

A wrapper for MMEPossibleChannels that supports user-defined channels outside the ISO13499 standard.

Constructor:

public CustomChannel(MMEPossibleChannels channel, bool newChannel = true)
  • Creates a new CustomChannel wrapping an MMEPossibleChannels instance. If newChannel is true, creates a copy of the channel; otherwise uses the provided reference directly. Initializes lookup values for direction, filter class, fine locations, main location, physical dimension, position, and test object from the ISO database.

Properties:

public MMEPossibleChannels Channel { get; private set; }
public string Text1 { get; set; }  // Proxies to Channel.Text_L1 and Channel.SetText1()

Methods:

public int CompareTo(CustomChannel other)
  • Implements IComparable<CustomChannel>. Returns 0 if channels are equal, otherwise performs ordinal string comparison on Text1 properties.

CustomChannelList Class

A thread-safe singleton collection manager for CustomChannel instances.

Singleton Access:

public static CustomChannelList List { get; }
  • Thread-safe lazy initialization using lock pattern on LockObject.

Methods:

public void ReloadAll()
  • Clears the cached channel list, refreshes all data from IsoDb, and repopulates the channel collection.
public void DeleteAll()
  • Clears all cached channels and deletes SQL records via IsoDb.DeleteSQL().

Properties:

public ISO13499FileDb IsoDb { get; }
  • Lazy-initialized ISO13499FileDb instance with auto-refresh on first access.

TestGraph.cs

TestGraph Class

Manages graph configuration including channels, thresholds, and axis domains.

Constructor:

public TestGraph(TestTemplate template)
  • Initializes groups and added groups from the provided template.

Constants:

private const int MAX_CHANNELS_PER_GRAPH = 8;
private const string SEPARATOR = "§";

Properties:

public string GraphName { get; set; } = "";
public string GraphDescription { get; set; } = "";
public bool UseDomainMin { get; set; }
public double DomainMin { get; set; } = double.MinValue;
public bool UseDomainMax { get; set; }
public double DomainMax { get; set; } = double.MaxValue;
public bool UseRangeMin { get; set; }
public double RangeMin { get; set; } = double.MinValue;
public bool UseRangeMax { get; set; }
public double RangeMax { get; set; } = double.MaxValue;
public TestObjectChannel[] AvailableChannels { get; }

Methods:

public void SetThresholdsFromSQL(string sThresholds)
  • Parses a string containing threshold values separated by § with { and } delimiters. Parses tokens as doubles and adds to internal _thresholds list.
public void SetChannelsFromSQL(string sChannels)
  • Parses a string containing channel graph IDs separated by § with {, }, (, and ) delimiters. Looks up channels by graph ID and adds them via AddChannel().

SerializedSettings.cs

SerializedSettings Class (Sealed)

Provides typed access to application-wide settings stored in SettingsDB.

Nested Enums:

public enum Keys { /* 100+ setting keys including IgnorePowerMode, UseUserCodes, etc. */ }
public enum ISOSupportLevels { ISO_ONLY, TRANSITORY, NO_ISO }

Properties:

public static string ExportINIFile { get; set; }
public static IsoChannelSensorCompatibilityLevels IsoChannelSensorCompatibilityLevel { get; set; }
public static ISOSupportLevels ISOSupportLevel { get; set; }
public static bool TestSetupDefaultDontAllowOutOfCalSensors { get; set; }
public static SensorTypeToDimension[] AllSensorTypeToDimensions { get; set; }

Methods:

public static Dictionary<string, string> GetAllSensorTypeToDimensionMappings()
  • Returns a dictionary mapping sensor type codes to ISO physical dimensions.

SerializedSettings.SensorTypeToDimension Class

Nested class extending Tuple<string, string, string> representing sensor type mappings.

Constructor:

public SensorTypeToDimension(string sensorType, string name, string dimension)

Properties:

public string Code => Item1;      // Sensor type code
public string Name => Item2;      // Sensor type name
public string Dimension => Item3; // ISO physical dimension

DbImporter.cs

DbImporter Class

Handles XML-based database import and schema migrations.

Constructors:

public DbImporter()
public DbImporter(int dbType, string dbName, string server, bool useNTLMAuthentication, string localDbUser, string localDbPassword)
  • Parameterized constructor configures DbOperations for local (dbType=1) or centralized database connections.

Nested Types:

public enum TopLevelFields { CustomerDetails, TestEngineerDetails, LabDetails, DASList, SensorModels, Sensors, Calibrations, CustomDirections, CustomFilterClasses, CustomTestObjects, CustomFinLoc1s, CustomFinLoc2s, CustomFinLoc3s, CustomMainLocs, CustomPhysicalDimensions, CustomPositions, CustomChannels, GroupTemplates, Groups, TestSetups, Users, GlobalSettings }
public delegate void SetStatusDelegate(string status, bool output = false);

Methods:

public void ImportXML(string ImportFile, SetStatusDelegate SetStatus)
  • Imports an XML file into the database. Clears all tables via ImportSensorsImportControl.ClearAllTables(true), then processes each XML element type through ImportTestSetup.ProcessRootNode(). Post-import, calls AssignSettingsToAllUsers(), MigrateG5ChannelSupportedBridges(), and MigrateSPSChannelSupportedBridges().
public bool MigrateG5ChannelSupportedBridges()
  • Updates DASChannels.SupportedBridges from 12 to 140 for DAS Type=12 (TDAS G5 VDS). Addresses issue #12431 for 1.4 to 1.10 migrations.
public void MigrateSPSChannelSupportedBridges()
  • Updates DASChannels.SupportedBridges from 15 to 143 for DAS Type=19 with ProtocolVersion >= 154. Addresses issue #12850 for SPS channel count mismatch.
public bool IsServerConnected()
  • Returns result of DbOperations.IsServerConnected().

Invariants

  1. CustomChannelList Singleton: The List property always returns the same instance; _list is only created once under lock.

  2. Channel Uniqueness: In CustomChannelList.PopulateChannelsIfNecessary(), channels are keyed by ISO code; duplicate ISO codes are silently skipped via if (_dictChannels.ContainsKey(iso)) continue;.

  3. Max Channels Per Graph: TestGraph enforces MAX_CHANNELS_PER_GRAPH = 8. When _channels.Count >= MAX_CHANNELS_PER_GRAPH, AvailableChannels returns an empty array.

  4. Sensor Type Mapping Default Count: AllSensorTypeToDimensions defaults to 7 mappings if NUM_SENSORTYPE_MAPPINGS is not set or unparseable.

  5. ISO Support Level Default: ISOSupportLevel defaults to ISOSupportLevels.ISO_ONLY if parsing fails.

  6. Thread Safety: CustomChannelList uses LockObject for all state mutations (ReloadAll, DeleteAll, PopulateChannelsIfNecessary).


Dependencies

Imports (This module depends on):

  • System, System.Collections.Generic, System.Linq
  • System.Windows (CustomChannel.cs - Application.Current cast to App)
  • System.Data, System.Data.SqlClient (DbImporter.cs)
  • System.Xml (DbImporter.cs)
  • System.Text (DbImporter.cs)

External Types Referenced (not defined in source):

  • MMEPossibleChannels, MMETestObjects, MMEPositions, MMETransducerMainLocation, MMEFineLocations1/2/3, MMEPhysicalDimensions, MMEDirections, MMEFilterClasses
  • ISO13499FileDb, ISO13499FileDb.ExpiredISOFieldException
  • ISO.IsoCode
  • App (WPF application class)
  • TestObjectChannel, TestTestObject, TestTemplate, TestObjectTemplate
  • SensorsCollection.SensorsList
  • SettingsDB
  • DbOperations, DbOperations.Connection, DbOperationsEnum
  • ImportSensorsImportControl, ImportTestSetup
  • IsoChannelSensorCompatibilityLevels (enum)

Likely Dependents (inferred):

  • Test configuration modules (using TestGraph, CustomChannel)
  • Database migration tools (using DbImporter)
  • Settings management UI (using SerializedSettings)

Gotchas

  1. Expired ISO Field Exceptions Silently Collected: In CustomChannel constructor, ExpiredISOFieldException for main location lookup is caught and added to _expiredErrors list, but this list is never exposed or used elsewhere in the provided source. The exception is effectively swallowed.

  2. Commented-Out Base Class Inheritance: Both CustomChannel and CustomChannelList have commented-out inheritance from BasePropertyChanged, suggesting a refactoring or removal of change notification infrastructure. TestGraph similarly has this pattern.

  3. Hardcoded Default Sensor Mappings: GetSensorTypeMapping(int index) contains hardcoded default mappings for indices 0-6 (Acceleration, Force, Momentum, Displacement, Angular Acceleration, Angle, Voltage). Index 7+ returns empty strings.

  4. Magic Character in Sensor Mapping Serialization: SetSensorTypeMapping uses (char)149 as a delimiter, which is the "bullet" character (•). This could cause encoding issues.

  5. G5/SPS Migration Hardcoded Values: MigrateG5ChannelSupportedBridges() and MigrateSPSChannelSupportedBridges() use hardcoded magic numbers (140, 143, 154) without constants, tied to specific bug IDs (#12431, #12850).

  6. AvailableChannels Clears Lookup on Every Access: The AvailableChannels getter calls _lookup.Clear() at the start, which may have side effects if _lookup is used elsewhere between accesses.

  7. Squib Channel Mutation Side Effect: In AddChannels(), when handling voltage channels for squib sensors, the original channel object has its SquibChannelType and NameOfTheChannel modified before being added to the list, while current channels create a new instance.

  8. Exception Re-throw Loses Stack Trace: In ImportXML(), throw ex; re-throws the caught exception, losing the original stack trace. Should be throw;.

  9. Empty Catch Blocks: AssignSettingsToAllUsers() and SetUserProperty() have empty catch blocks, silently swallowing exceptions.