12 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T04:17:01.479504+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | d08bce9ece7691a5 |
TestObject
Documentation Page: Test Object Edit Control Module
1. Purpose
This module provides UI controls and supporting logic for editing test objects (e.g., test setups, groups) in the DataPRO application. It enables users to configure sensors, hardware, import/export settings, and validate object state before saving. The controls implement the IPageContent interface to integrate with the application’s page navigation and permission system, and they coordinate with backend services (e.g., locking, hardware/channel management, import/export pipelines) via view models and domain interfaces. The module is part of the DataPROWin7.Controls.TestObject namespace and serves as the primary UI layer for test object editing workflows.
2. Public Interface
Interfaces
IEditObjectSensorsControlPagevoid SetOnlineSensors(DTS.SensorDB.SensorData[] sensors)
Sets the list of online sensors to display or process in the sensors control page. Used to populate sensor selection UI.
Classes
-
TableOptionsTable- Inherits from
GenericTable2. enum TableColumns { ColumnName, ColumnHeader, Visible, DisplayOrder, Width, UserData }- Constructor:
TableOptionsTable(ContentControl container, DataPROPage page)
Initializes a data grid with columns for table configuration (e.g., visibility, order, width). - Overrides
CreateColumns(string resourcePrefix, Type enumType)
Dynamically creates grid columns based onTableColumnsenum values. Special handling forVisible,DisplayOrder, andWidth(numeric/checkbox columns);UserDatais skipped.
- Inherits from
-
ImportObjectImportIGroupImportImportView ImportView { get; set; }
Gets/sets the view model for import configuration. Setting it assigns the view toContent.bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow)
Always returnstrue; no validation logic implemented (placeholder).void OnSetActive()
No-op stub.
-
ImportObjectOptionsIGroupImportOptionsView OptionsView { get; set; }
Gets/sets the view model for import options. Setting it assigns the view toContent.bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow)
Delegates validation toOptionsView.Validate(...). Aggregates errors/warnings into output parameters. If errors exist, reports them viapage.ReportErrors(...)using the active page fromMainWindow.void OnSetActive()
No-op stub.
-
ImportObjectPreviewIGroupImportPreviewView PreviewView { get; set; }
Gets/sets the view model for import preview. Setting it assigns the view toContent.bool DontValidate { get; set; }
Bypasses validation whentrue.bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow)
CallsPreviewView.Validate(isAdmin, out errors, out warnings). If errors exist, reports them and returnsfalse. If warnings exist, displays them viaThreadPool.QueueUserWorkItem(DoWarning, ...)and returnsfalse.static void DoWarning(object o)
Shows a modal message box with warnings (usingApp.DoMessageBox) and OK/Cancel buttons.void OnSetActive()
No-op stub.
-
SensorLockAndContend- Constructor:
SensorLockAndContend(DataPROPage page) bool HasLockedSensors { get; }
Returnstrueif any sensors are currently locked.LockRecord[] GetLockRecords()
Returns all currently locked sensor records.void LockSensors(SensorData[] sensorsToLock)
Attempts to lock each sensor. Handles lock contention:- If lock is stale (timeout exceeded) or held by same user/machine, steals it.
- Otherwise, records as contentious and calls
ContendLocks(...).
void FreeSensors()
Frees all locked sensors and clears contentious locks. Clears_sensorsContentiousLocksunconditionally.private void ContendLocks(User user)
For non-admin users: reports errors via_page.ReportErrors(...). For admins: prompts to steal locks viaStealLocks().private void StealLocks()
Frees and re-locks contentious sensors.
- Constructor:
-
EditObjectHardwareControl- Constructor:
EditObjectHardwareControl(DataPROPage page) string HardwareInfo { get; }
Returns formatted string (e.g.,"X channels required. Y channels included.") based onChannelsRequiredand hardware channel counts.int ChannelsRequired { get; set; }
Tracks required channel count (updated viaOnGroupChannelsChanged).void AddHardware(DASHardware hardware, IGroup group, Dictionary<string, DASHardware> lookup, DASHardware[] allHardware)
Adds hardware to group’sIncludedHardwarelist. Special handling for TSRAIR (creates embedded channels) and SLICETC.void OnSetActive()
Initializes hardware view model, subscribes to events, sets compact view mode, and populates hardware list.void UnSet(Action OnComplete = null)
Unsubscribes from events and unsets hardware view model.bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow)
Delegates toValidateTestObjectHardware(...), which currently always returnstrue.private void OnIncludedChanged(HardwareListHardwareIncludedEventArgs args)
Adds/removes hardware from group when included state changes. Handles pseudo-rack and TSRAIR module dependencies.private void OnGroupChannelsChanged(GroupChannelsChangedEventArgs obj)
UpdatesChannelsRequiredwhen group channel count changes.
- Constructor:
-
ExportGroup- Constructor:
ExportGroup(DataPROPage page) string ExportFile { get; set; }
Target export file path.string TCFFile { get; set; }
TCF file path (unused in source).bool UseFirstUseDate { get; set; } = true
Flag for sensor first-use date inclusion (UI visibility controlled bySerializedSettings.UseSensorFirstUseDate).bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow)
ChecksExportFileis non-empty and at least one group is selected. Marks invalid controls viaPageMainContentControl.MarkInvalid(...).void OnSetActive()
Populates_dt(DataTable) with groups fromIGroupListViewModel, sorted byLastModified.void Export()
Starts export asynchronously viaTask.Run(ExportGroupFunc). If file exists, prompts for overwrite.private void ExportGroupFunc()
CallsExportTestSetup.ExportToFile(...)with selected groups. Handles errors and updates status via delegates.private void FileOverwriteWarning(object o)
Shows overwrite warning modal; if OK, invokesExport()on dispatcher thread.
- Constructor:
3. Invariants
- Permissions: All
IPageContentimplementations enforce permission checks viaSetPermissions(...).IsEnabledis set only ifactualPermission >= requiredPermission. - Validation:
Validate(...)methods must populateerrors/warningslists; returningfalseindicates failure.ImportObjectOptions.ValidateandImportObjectPreview.Validatereport errors viapage.ReportErrors(...)on failure.ExportGroup.Validaterequires a non-emptyExportFileand at least one selected group.
- Locking:
SensorLockAndContend.LockSensorsmay steal locks only for admins (after user confirmation) or stale/self-held locks.FreeSensorsclears_sensorsContentiousLocksunconditionally before freeing locks.
- Hardware/Channel Consistency:
EditObjectHardwareControl.OnIncludedChangedensures hardware inclusion/exclusion updatesgroup.IncludedHardwareand channels.- TSRAIR and SLICETC hardware trigger special channel creation/removal logic.
- Event Subscription:
EditObjectHardwareControlsubscribes toGroupChannelsChangedEvent,HardwareListHardwareIncludedEvent, andHardwareListShowCompactEventinOnSetActive.- Unsubscribes in
UnSetto prevent leaks.
4. Dependencies
Imports/References (from source):
DTS.*namespaces:DTS.SensorDB(e.g.,SensorData,SensorsCollection)DTS.Slice.Users(e.g.,User,UserPermissionLevels)DTS.Common.*(e.g.,IGroup,IGroupImportImportView,LockManager,IEventAggregator,IUnityContainer)
Prism.*(e.g.,IEventAggregator,ContainerLocator)System.*(e.g.,Data,Windows.Controls,Threading)DataPROWin7.*(e.g.,DataModel,Common,Controls)C1.WPF.DataGrid(forExportGroupgrid columns)App,MainWindow,HomePage,DataPROPage,EditObjectPage,GenericTable2(internal types).
Depended on by:
EditObjectPage(inferred fromEditObjectHardwareControl,EditObjectInfoControl,ImportObject*,ExportGroupconstructors).DataPROPageandApp(viaDoMessageBox,CurrentUser,DoWarning).
5. Gotchas
ExportGroup.Exportdoes not block: It starts export in a backgroundTask.Run, butFileOverwriteWarningusesManualResetEvent.WaitOne()to block the dispatcher thread during overwrite confirmation. This risks deadlocks if not handled carefully.EditObjectHardwareControl.ValidateTestObjectHardwareis a stub: Always returnstrue; no actual hardware/channel validation occurs.ImportObjectImport.Validateis a stub: Always returnstrue; no validation logic implemented.SensorLockAndContend.FreeSensorsclears_sensorsContentiousLocksbefore freeing: IfFreeSensorsis called mid-contention, the contentious records are lost before resolution.EditObjectHardwareControl.OnSetActivesets column widths to0: Hardcoded column widths (TestSampleRateColumnWidth = 0, etc.) hide columns; may conflict with tile-specific settings (e.g., "Test Setups tile" comment).EditObjectInfoControl.TextBoxSourceUpdatedpublishesPageModifiedEventon data binding updates: This may fire frequently (e.g., on every keystroke), potentially causing performance issues or race conditions.ImportObjectPreview.Validatealways returnsfalseif warnings exist: Even ifbValidistrue, warnings trigger a modal and returnfalse. This may block progression despite valid data.ExportGroup.ExportusesExportTestSetup.PossibleStatus: Status enum is defined inExportTestSetup(not in this module), implying tight coupling.TableOptionsTableskipsTableColumns.UserDatainCreateColumns: Intentional, but may confuse developers expecting a column.EditObjectHardwareControlusesDASHardware.GetChildrenDASandGetEmbeddedModules: Logic for pseudo-rack/module dependencies is embedded inAddHardware/RemoveFromChannels; not centralized.SensorLockAndContendusesProperties.Settings.Default.StrandedLockTimeoutMinutes: Hardcoded timeout setting; no runtime configuration visible in source.