9.8 KiB
9.8 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||
|---|---|---|---|---|---|---|---|---|
|
2026-04-16T04:59:45.231634+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 45cdf642e27469a5 |
TestTemplate
Documentation: DatabaseExport.TestTemplate Module (Version 57)
1. Purpose
This module provides lightweight, read-only representations of test templates stored in the database (tblTestSetups) and supporting infrastructure for template management, primarily for export or migration workflows in legacy database versions (v57). It includes classes to load essential metadata from the database without instantiating the full TestTemplate object (which may trigger expensive side effects), and utilities to serialize/deserialize sensor settings and manage tag metadata. The module supports operations like retrieving templates by name, listing all templates in a simplified form, and handling special cases like the "Quick checkout" temporary template.
2. Public Interface
HardwareInclusionInstruction
HardwareInclusionInstruction(string hardwareId, Actions action)
Constructor. Initializes a rule to explicitly include or exclude a specific hardware item from a test, overriding group-based inclusion logic (e.g., to support "DAS-less" groups).HardwareId { get; }
The identifier of the hardware item to which the rule applies.Action { get; }
The action to take:Actions.Remove(exclude despite group membership) orActions.Add(include despite absence from groups).
TestTemplateLite
Name { get; set; }
Template name.Description { get; set; }
Template description (defaults to"").RecordingMode { get; set; }
Recording mode (e.g.,Recorder,CircularBuffer).PreTriggerSeconds { get; set; }
Pre-trigger duration in seconds. Behavior: Returns0.0forRecorderorHybridRecordermodes; otherwise returns the stored value.PostTriggerSeconds { get; set; }
Post-trigger duration in seconds.LastModified { get; set; }
Timestamp of last modification.LastModifiedBy { get; set; }
User who last modified the template.IsComplete { get; set; }
Whether the template is marked as complete.
TestTemplateTableObject
TestTemplateTableObject(string name, string description, RecordingModes recordingMode, DateTime lastModified, string lastModifiedBy, bool isComplete, string completionErrorMessage, bool useCustomerDetails, string customerDetails, int[] tagIds)
Constructor. Initializes a simplified row-like object representing atblTestSetupsentry.Name { get; private set; }
Template name.Description { get; private set; }
Template description.RecordingMode { get; private set; }
Recording mode enum value.LastModified { get; private set; }
Last modification timestamp.LastModifiedBy { get; private set; }
Last modifier user ID.IsComplete { get; private set; }
Completion status.CompletionErrorMessage { get; private set; }
Error message if template is incomplete.UseCustomerDetails { get; private set; }
Whether customer details are enabled.CustomerDetails { get; private set; }
Customer details string (likely an ID or reference).TagIds { get; private set; }
Array of tag IDs associated with the template.
TestTemplateList
TemporaryTemplate { get; set; }
Holds a temporaryTestTemplateinstance (e.g., for "Quick checkout") without persisting to DB.GetTemplate(string name) → TestTemplate
Retrieves aTestTemplateinstance fromtblTestSetupsby name. Only loads fields defined inDbOperations.TestSetups.Fields. Setstt._bIsLoaded = falseto indicate incomplete loading. Returnsnullif not found or on error. Special case: ReturnsTemporaryTemplateifname == "Quick checkout".GetSensorFromSettings(string settings, string serial, Dictionary<string, SensorData> lookup) → SensorData
Parses a comma-separated settings string (e.g.,"3=100,5=+") into aSensorDataobject. Useslookupif provided and containsserial; otherwise queriesSensorsCollection.SensorsList. Returnsnullif sensor not found. Supports settings:CFC,Position,Polarity,Range,Delay,Duration,OutputMode,SQMode,DIMode,LimitDuration,ActiveValue,DefaultValue.GetSensorFromSettings(string settings, string serial) → SensorData
Overload withoutlookup(passesnull).GetSensorSettings(SensorData sd) → string
SerializesSensorDatainto the same comma-separated format used byGetSensorFromSettings. Only includes settings with non-default/empty values.TestTemplatesList { get; }
Singleton accessor forTestTemplateList.SysBuiltObject(string serialNumber) → bool
QueriestblTestObjectsforSysBuiltflag of a given serial number. Returnsfalseif not found.ConvertToDictionary(DataTable dt, ref Dictionary<string, List<Dictionary<string, object>>> lookup, string key)
Populateslookupby grouping rows indtbykeycolumn. Each row becomes aDictionary<string, object>of column values.GetAllTemplates() → TestTemplateTableObject[]
QueriestblTestSetupsfor all templates and returns an array ofTestTemplateTableObject. HandlesUserTagsblob →int[]conversion viaGetTagIds. IfDirtyflag is true, re-fetches the fullTestTemplateto updateIsCompletestatus.GetTagIds(byte[] bytes) → int[]
Converts a byte array (fromUserTagscolumn) into anint[]usingBuffer.BlockCopy. Returns empty array on failure.
3. Invariants
TestTemplateLite.PreTriggerSeconds:
ForRecordingModes.RecorderandRecordingModes.HybridRecorder,PreTriggerSecondsis always0.0, regardless of the stored_preTriggerSecondsvalue.TestTemplateTableObjectimmutability:
All properties areprivate set, meaning instances are immutable after construction.TestTemplateList.GetTemplatebehavior:
Templates loaded viaGetTemplateare explicitly marked as not fully loaded (_bIsLoaded = false), indicating that onlytblTestSetupsfields were populated. Consumers must avoid relying on lazily-loaded data (e.g., channels, groups).TemporaryTemplatespecial case:
Only returned whenname == "Quick checkout"(exact string match). Empty/whitespace names returnnull.TagIdsblob format:
UserTagsis stored as abyte[]and converted toint[]assuming 4-byteintelements (viasizeof(int)). Failure to parse yields an empty array.
4. Dependencies
Internal Dependencies (from source):
DbOperations: Used for database access (GetCommand,CreateParam,QueryDataSet,TestSetupstable/field enums).Properties.Settings.Default.DownloadFolder: Used as fallback forExportFolderandDownloadFolderinGetTemplate.CustomerDetailsList.CustomerList,TestEngineerDetailsList.TestEngineerList,LabratoryDetailsList.LabratoryList: Used to resolve customer/test engineer/lab details from stored IDs.SensorsCollection.SensorsList: Used byGetSensorFromSettingsto look up sensors by serial number.ISO.TestObject.SensorSettings: Enum defining sensor setting types (e.g.,CFC,Range,Delay).OutputTOMDigitalChannel.DigitalOutputMode,OutputSquibChannel.SquibFireMode,DigitalInputScaleMultiplier.InputModes: Enums used in sensor settings parsing.
External Dependencies:
System.Data:SqlDbType,DataRow,DataTable,DataSet.System.Globalization:CultureInfo.InvariantCulturefor numeric parsing.
Inferred Consumers:
- Modules performing template export/migration (e.g.,
DatabaseExportnamespace usage implies integration with export pipelines). - Code needing lightweight template metadata (e.g., UI lists, version comparison, migration scripts).
5. Gotchas
PreTriggerSecondslogic is mode-dependent:
The property setter stores the value in_preTriggerSeconds, but the getter ignores it forRecorder/HybridRecordermodes. This may cause confusion if consumers expect the stored value to be returned.GetTemplatedoes not load full template data:
Despite returning aTestTemplate, onlytblTestSetupsfields are populated. Consumers must not assume groups, channels, or other related data are available.Dirtyflag triggers redundant full load:
InGetAllTemplates, ifDirtyis true,GetTemplateis called to re-fetchIsComplete. This may be inefficient and could fail silently (exceptions are caught and ignored).GetTagIdsassumes fixedintsize:
Usessizeof(int)(4 bytes) for conversion. May fail on platforms with non-standardintsizes or malformed blobs.TemporaryTemplateis mutable and global:
As a singleton property,TemporaryTemplatecan be overwritten by any caller. No thread-safety is implied beyond the singleton initialization.GetSensorFromSettingssilently handles missing sensors:
Returnsnullif sensor not found, but only after creating a placeholderSensorDatawith emptySerialNumberifserialis null/whitespace.GetSensorSettingsomits default/empty values:
Only includes settings with non-default values. This may cause round-trip mismatches if consumers expect all settings to be serialized.
None identified beyond the above.