232 lines
8.3 KiB
Markdown
232 lines
8.3 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- Common/DTS.Common/Classes/Groups/GroupGRPImportError.cs
|
||
|
|
- Common/DTS.Common/Classes/Groups/GroupGRPImportGroup.cs
|
||
|
|
- Common/DTS.Common/Classes/Groups/GroupHardwareDbRecord.cs
|
||
|
|
- Common/DTS.Common/Classes/Groups/TestSetupGroupRecord.cs
|
||
|
|
- Common/DTS.Common/Classes/Groups/GroupDbRecord.cs
|
||
|
|
- Common/DTS.Common/Classes/Groups/GroupGRPImportChannel.cs
|
||
|
|
- Common/DTS.Common/Classes/Groups/ChannelDbRecord.cs
|
||
|
|
- Common/DTS.Common/Classes/Groups/GroupHelper.cs
|
||
|
|
generated_at: "2026-04-17T15:32:48.649594+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "656ed2feb99179fd"
|
||
|
|
---
|
||
|
|
|
||
|
|
# Documentation: DTS.Common.Classes.Groups
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
|
||
|
|
This module provides the core data structures for managing groups and channels within a data acquisition system (DAS). It handles three primary concerns: (1) importing GRP files with comprehensive error tracking via `GroupGRPImportError`, `GroupGRPImportGroup`, and `GroupGRPImportChannel`; (2) representing database records for groups, channels, hardware associations, and test setup relationships through `GroupDbRecord`, `ChannelDbRecord`, `GroupHardwareDbRecord`, and `TestSetupGroupRecord`; and (3) providing static caching and lookup utilities via `GroupHelper` for mapping between IDs, serial numbers, and hardware configurations across the system.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### GroupGRPImportError
|
||
|
|
Encapsulates errors encountered during GRP file import.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public class GroupGRPImportError
|
||
|
|
{
|
||
|
|
public enum Errors
|
||
|
|
{
|
||
|
|
FileEmpty,
|
||
|
|
InvalidISOCodeInput,
|
||
|
|
InvalidFullScaleInput,
|
||
|
|
InvalidSensorInput,
|
||
|
|
InvalidInvertInput,
|
||
|
|
SensorNotFound,
|
||
|
|
InvalidInputMode,
|
||
|
|
InvalidDefaultValue,
|
||
|
|
InvalidActiveValue,
|
||
|
|
InvalidFireMode,
|
||
|
|
InvalidDelay,
|
||
|
|
InvalidLimitDuration,
|
||
|
|
InvalidDuration,
|
||
|
|
InvalidCurrent
|
||
|
|
}
|
||
|
|
|
||
|
|
public Errors ErrorCode { get; set; }
|
||
|
|
public string File { get; set; }
|
||
|
|
public int Line { get; set; }
|
||
|
|
public string ExtraInfo { get; set; }
|
||
|
|
public override string ToString() // Returns ExtraInfo
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
### GroupGRPImportGroup
|
||
|
|
Represents a group parsed from a GRP file, extending `BasePropertyChanged`.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public class GroupGRPImportGroup : BasePropertyChanged
|
||
|
|
{
|
||
|
|
public bool Included { get; set; } = true;
|
||
|
|
public bool Overwrite { get; set; } = true;
|
||
|
|
public string GroupName { get; set; }
|
||
|
|
public string GroupTags { get; set; }
|
||
|
|
public string ImportingUserTags { get; set; }
|
||
|
|
public string SourceFile { get; set; }
|
||
|
|
public GroupGRPImportChannel[] Channels { get; set; } = { };
|
||
|
|
public GroupGRPImportError[] GroupErrors { get; set; } = null;
|
||
|
|
public bool GroupNameHasError { get; set; } // Notifies property change
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
### GroupGRPImportChannel
|
||
|
|
Represents a single channel/row in a TDC GRP file, extending `BasePropertyChanged`.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public class GroupGRPImportChannel : BasePropertyChanged
|
||
|
|
{
|
||
|
|
// Field position constants
|
||
|
|
public const uint SerialNumberField = 0;
|
||
|
|
public const uint DisplayNameField = 1;
|
||
|
|
public const uint ISOCodeField = 2;
|
||
|
|
public const uint InvertField = 3;
|
||
|
|
public const uint CapacityField = 4;
|
||
|
|
public const uint InputModeField = 5;
|
||
|
|
public const uint DefaultValueField = 6;
|
||
|
|
public const uint ActiveValueField = 7;
|
||
|
|
public const uint FireModeField = 8;
|
||
|
|
public const uint DelayField = 9;
|
||
|
|
public const uint LimitDurationField = 10;
|
||
|
|
public const uint DurationField = 11;
|
||
|
|
public const uint CurrentField = 12;
|
||
|
|
|
||
|
|
public enum InputModes { na, TLH, THL, CCNO, CCNC }
|
||
|
|
public enum FireModes { na, CD, CC }
|
||
|
|
|
||
|
|
// Default value constants
|
||
|
|
public const InputModes DefaultInputMode = InputModes.CCNO;
|
||
|
|
public const double DefaultDefaultValue = 0.0;
|
||
|
|
public const double DefaultActiveValue = 1.0;
|
||
|
|
public const FireModes DefaultFireMode = FireModes.CD;
|
||
|
|
public const double DefaultDelay = 0.00;
|
||
|
|
public const bool DefaultLimitDuration = true;
|
||
|
|
public const double DefaultDuration = 10.0;
|
||
|
|
public const double DefaultCurrent = 1.5;
|
||
|
|
|
||
|
|
// Properties
|
||
|
|
public string SensorSerialNumber { get; set; }
|
||
|
|
public string DisplayName { get; set; }
|
||
|
|
public string ISOCode { get; set; }
|
||
|
|
public bool Invert { get; set; }
|
||
|
|
public double FullScale { get; set; }
|
||
|
|
public InputModes? InputMode { get; set; } = null;
|
||
|
|
public double? DefaultValue { get; set; } = null;
|
||
|
|
public double? ActiveValue { get; set; } = null;
|
||
|
|
public FireModes? FireMode { get; set; } = null;
|
||
|
|
public double? Delay { get; set; } = null;
|
||
|
|
public bool? LimitDuration { get; set; } = null;
|
||
|
|
public double? Duration { get; set; } = null;
|
||
|
|
public double? Current { get; set; } = null;
|
||
|
|
public GroupGRPImportError Error { get; set; } = null;
|
||
|
|
public GroupGRPImportGroup ParentGroup { get; set; }
|
||
|
|
public string GroupName { get; } // Returns "---" if ParentGroup is null
|
||
|
|
|
||
|
|
public void GroupNameInvalidate() // Raises PropertyChanged for GroupName
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
### GroupDbRecord
|
||
|
|
Database record for a group, implementing `IGroupDbRecord`, extending `BasePropertyChanged`.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public class GroupDbRecord : BasePropertyChanged, IGroupDbRecord
|
||
|
|
{
|
||
|
|
[Key]
|
||
|
|
public int Id { get; set; } // Default -1
|
||
|
|
public string SerialNumber { get; set; }
|
||
|
|
public string Picture { get; set; }
|
||
|
|
public string DisplayName { get; set; }
|
||
|
|
public string Description { get; set; }
|
||
|
|
public bool Embedded { get; set; }
|
||
|
|
public DateTime LastModified { get; set; }
|
||
|
|
public string LastModifiedBy { get; set; }
|
||
|
|
public int? StaticGroupId { get; set; }
|
||
|
|
public string ExtraProperties { get; set; }
|
||
|
|
|
||
|
|
public GroupDbRecord()
|
||
|
|
public GroupDbRecord(IGroupDbRecord copy)
|
||
|
|
public GroupDbRecord(IGroup copy, List<KeyValuePair<string, string>> extraProperties)
|
||
|
|
public GroupDbRecord(IDataReader reader)
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
### ChannelDbRecord
|
||
|
|
Database record for a channel, implementing `IChannelDbRecord`, extending `BasePropertyChanged`.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public class ChannelDbRecord : BasePropertyChanged, IChannelDbRecord
|
||
|
|
{
|
||
|
|
[Key]
|
||
|
|
public long Id { get; set; } // Default -1
|
||
|
|
public int GroupId { get; set; } // Default -1
|
||
|
|
public string IsoCode { get; set; }
|
||
|
|
public string IsoChannelName { get; set; }
|
||
|
|
public string UserCode { get; set; }
|
||
|
|
public string UserChannelName { get; set; }
|
||
|
|
public int DASId { get; set; } // Default -1
|
||
|
|
public int DASChannelIndex { get; set; } // Default -1
|
||
|
|
public int GroupChannelOrder { get; set; } // Default -1
|
||
|
|
public int TestSetupOrder { get; set; } // Default -1
|
||
|
|
public int SensorId { get; set; } // Default -1
|
||
|
|
public bool IsDisabled { get; set; } // Redirects to Disabled, raises PropertyChanged for "IsDisabled"
|
||
|
|
public bool Disabled { get; set; }
|
||
|
|
public DateTime LastModified { get; set; }
|
||
|
|
public string LastModifiedBy { get; set; }
|
||
|
|
|
||
|
|
public ChannelDbRecord()
|
||
|
|
public ChannelDbRecord(IChannelDbRecord copy)
|
||
|
|
public ChannelDbRecord(IDataReader reader)
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
### GroupHardwareDbRecord
|
||
|
|
Database record for group hardware associations, implementing `IGroupHardwareDbRecord`.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public class GroupHardwareDbRecord : BasePropertyChanged, IGroupHardwareDbRecord
|
||
|
|
{
|
||
|
|
[Key]
|
||
|
|
public int Id { get; set; } // Default -1
|
||
|
|
public int GroupId { get; set; } // Default -1
|
||
|
|
public int DASId { get; set; } // Default -1
|
||
|
|
public string SerialNumber { get; set; }
|
||
|
|
|
||
|
|
public GroupHardwareDbRecord()
|
||
|
|
public GroupHardwareDbRecord(IGroupHardwareDbRecord copy)
|
||
|
|
public GroupHardwareDbRecord(IDataReader reader)
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
### TestSetupGroupRecord
|
||
|
|
Association between groups and test setups, implementing `ITestSetupGroupRecord`.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public class TestSetupGroupRecord : BasePropertyChanged, ITestSetupGroupRecord
|
||
|
|
{
|
||
|
|
public int GroupId { get; set; } // Default -1
|
||
|
|
public int DisplayOrder { get; set; } // Default -1
|
||
|
|
public string Position { get; set; } // ISO 13499 position field
|
||
|
|
public string TestObjectType { get; set; } // ISO 13499 test object field
|
||
|
|
public int TestSetupId { get; set; } // Default -1
|
||
|
|
|
||
|
|
public TestSetupGroupRecord()
|
||
|
|
public TestSetupGroupRecord(IDataReader reader)
|
||
|
|
public TestSetupGroupRecord(ITestSetupGroupRecord copy)
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
### GroupHelper
|
||
|
|
Abstract class providing static caching and lookup methods.
|
||
|
|
|
||
|
|
```csharp
|
||
|
|
public abstract class GroupHelper
|
||
|
|
{
|
||
|
|
// StaticGroupNames
|
||
|
|
public static void ClearStaticGroupNames()
|
||
|
|
public static void SetStaticGroupName(int id, string name)
|