init
This commit is contained in:
157
Common/DTS.CommonCore/Classes/Groups/ChannelDbRecord.cs
Normal file
157
Common/DTS.CommonCore/Classes/Groups/ChannelDbRecord.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using DTS.Common.Interface.Channels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data;
|
||||
|
||||
namespace DTS.Common.Classes.Channels
|
||||
{
|
||||
/// <summary>
|
||||
/// represents a record of a channel in the db
|
||||
/// <inheritdoc cref="IChannelDbRecord"/>
|
||||
/// </summary>
|
||||
public class ChannelDbRecord : Base.BasePropertyChanged, IChannelDbRecord
|
||||
{
|
||||
protected long _id = -1;
|
||||
/// <summary>
|
||||
/// The database id of the Channel
|
||||
/// </summary>
|
||||
[Key]
|
||||
public long Id
|
||||
{
|
||||
get => _id;
|
||||
set => SetProperty(ref _id, value, "Id");
|
||||
}
|
||||
|
||||
private int _groupId = -1;
|
||||
public int GroupId
|
||||
{
|
||||
get => _groupId;
|
||||
set => SetProperty(ref _groupId, value, "GroupId");
|
||||
}
|
||||
|
||||
private string _isoCode = "";
|
||||
public string IsoCode
|
||||
{
|
||||
get => _isoCode;
|
||||
set => SetProperty(ref _isoCode, value, "IsoCode");
|
||||
}
|
||||
|
||||
private string _isoChannelName = "";
|
||||
public string IsoChannelName
|
||||
{
|
||||
get => _isoChannelName;
|
||||
set => SetProperty(ref _isoChannelName, value, "IsoChannelName");
|
||||
}
|
||||
private string _userCode;
|
||||
public string UserCode
|
||||
{
|
||||
get => _userCode;
|
||||
set => SetProperty(ref _userCode, value, "UserCode");
|
||||
}
|
||||
private string _userChannelName = "";
|
||||
public string UserChannelName
|
||||
{
|
||||
get => _userChannelName;
|
||||
set => SetProperty(ref _userChannelName, value, "UserChannelName");
|
||||
}
|
||||
|
||||
private int _dasId = -1;
|
||||
public int DASId
|
||||
{
|
||||
get => _dasId;
|
||||
set => SetProperty(ref _dasId, value, "DASId");
|
||||
}
|
||||
|
||||
protected int _dasChannelIndex = -1;
|
||||
public int DASChannelIndex
|
||||
{
|
||||
get => _dasChannelIndex;
|
||||
set => SetProperty(ref _dasChannelIndex, value, "DASChannelIndex");
|
||||
}
|
||||
private int _groupChannelOrder = -1;
|
||||
public int GroupChannelOrder
|
||||
{
|
||||
get => _groupChannelOrder;
|
||||
set => SetProperty(ref _groupChannelOrder, value, "GroupChannelOrder");
|
||||
}
|
||||
private int _testSetupOrder = -1;
|
||||
public int TestSetupOrder
|
||||
{
|
||||
get => _testSetupOrder;
|
||||
set => SetProperty(ref _testSetupOrder, value, "TestSetupOrder");
|
||||
}
|
||||
|
||||
private int _sensorId = -1;
|
||||
public int SensorId
|
||||
{
|
||||
get => _sensorId;
|
||||
set => SetProperty(ref _sensorId, value, "SensorId");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IsDisabled is declared here, and redirects to Disabled so that
|
||||
/// existing uses of IsDisabled do not need to be modified.
|
||||
/// </summary>
|
||||
|
||||
public bool IsDisabled
|
||||
{
|
||||
get => Disabled;
|
||||
set
|
||||
{
|
||||
Disabled = value;
|
||||
OnPropertyChanged("IsDisabled");
|
||||
}
|
||||
}
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
private DateTime _lastModified = DateTime.Today;
|
||||
public DateTime LastModified
|
||||
{
|
||||
get => _lastModified;
|
||||
set => SetProperty(ref _lastModified, value, "LastModified");
|
||||
}
|
||||
private string _lastModifiedBy = "";
|
||||
public string LastModifiedBy
|
||||
{
|
||||
get => _lastModifiedBy;
|
||||
set => SetProperty(ref _lastModifiedBy, value, "LastModifiedBy");
|
||||
}
|
||||
|
||||
public ChannelDbRecord() { }
|
||||
public ChannelDbRecord(IChannelDbRecord copy)
|
||||
{
|
||||
Id = copy.Id;
|
||||
GroupId = copy.GroupId;
|
||||
IsoCode = copy.IsoCode;
|
||||
IsoChannelName = copy.IsoChannelName;
|
||||
UserCode = copy.UserCode;
|
||||
UserChannelName = copy.UserChannelName;
|
||||
DASId = copy.DASId;
|
||||
DASChannelIndex = copy.DASChannelIndex;
|
||||
GroupChannelOrder = copy.GroupChannelOrder;
|
||||
TestSetupOrder = copy.TestSetupOrder;
|
||||
SensorId = copy.SensorId;
|
||||
Disabled = copy.Disabled;
|
||||
LastModified = copy.LastModified;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
}
|
||||
public ChannelDbRecord(IDataReader reader)
|
||||
{
|
||||
Id = Utility.GetInt(reader, "Id", -1);
|
||||
GroupId = Utility.GetInt(reader, "GroupId", -1);
|
||||
IsoCode = Utility.GetString(reader, "IsoCode");
|
||||
IsoChannelName = Utility.GetString(reader, "IsoChannelName");
|
||||
UserCode = Utility.GetString(reader, "UserCode");
|
||||
UserChannelName = Utility.GetString(reader, "UserChannelName");
|
||||
DASId = Utility.GetInt(reader, "DASId", -1);
|
||||
DASChannelIndex = Utility.GetInt(reader, "DASChannelIndex", -1);
|
||||
GroupChannelOrder = Utility.GetInt(reader, "GroupChannelOrder", -1);
|
||||
TestSetupOrder = Utility.GetInt(reader, "TestSetupOrder", -1);
|
||||
SensorId = Utility.GetInt(reader, "SensorId", -1);
|
||||
Disabled = Utility.GetBool(reader, "Disabled");
|
||||
LastModified = Utility.GetDateTime(reader, "LastModified", DateTime.MinValue);
|
||||
LastModifiedBy = Utility.GetString(reader, "LastModifiedBy");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
using DTS.Common.Interface.Channels;
|
||||
namespace DTS.Common.Classes.Groups.ChannelSettings
|
||||
{
|
||||
public class ChannelSettingBase : IChannelSetting
|
||||
{
|
||||
//analog parameters
|
||||
public const string RANGE = "Range";
|
||||
public const string CFC = "CFC";
|
||||
//FB 13120 Add FilterClass
|
||||
public const string FilterClass = "FilterClass";
|
||||
public const string POLARITY = "Polarity";
|
||||
public const string POSITION = "Position";
|
||||
public const string ZEROMETHOD = "ZeroMethod";
|
||||
public const string ZEROMETHODSTART = "ZeroMethodStart";
|
||||
public const string ZEROMETHODEND = "ZeroMethodEnd";
|
||||
public const string USERVALUE1 = "UserValue1";
|
||||
public const string USERVALUE2 = "UserValue2";
|
||||
public const string USERVALUE3 = "UserValue3";
|
||||
public const string INITIAL_OFFSET = "InitialOffset";
|
||||
|
||||
/// <summary>
|
||||
/// the string key for the ac coupled enabled channel setting
|
||||
/// http://manuscript.dts.local/f/cases/29760/Implement-ACCoupleEnable-for-TSR-AIR
|
||||
/// </summary>
|
||||
public const string ACCouplingEnabled = "ACCouplingEnabled";
|
||||
//depreciated parameters
|
||||
//public const string LIMIT_DURATION = "LimitDuration";
|
||||
//public const string DURATION = "Duration";
|
||||
//public const string DELAY = "Delay";
|
||||
//33415 Voltage insertion channel should be half bridge
|
||||
public const string BRIDGE_TYPE = "BridgeType";
|
||||
|
||||
//squib parameters
|
||||
public const string SQUIB_CURRENT = "SquibCurrent";
|
||||
public const string SQUIB_LIMIT_DURATION = "SquibLimitDuration";
|
||||
public const string SQUIB_DURATION = "SquibDuration";
|
||||
public const string SQUIB_DELAY = "SquibDelay";
|
||||
public const string SQMODE = "SQMode";
|
||||
|
||||
//digital out parameters
|
||||
public const string DIGITALOUT_LIMIT_DURATION = "DigitalOutLimitDuration";
|
||||
public const string DIGITALOUT_DURATION = "DigitalOutDuration";
|
||||
public const string DIGITALOUT_DELAY = "DigitalOutDelay";
|
||||
public const string OUTPUT_MODE = "OutputMode";
|
||||
|
||||
//digital in parameters
|
||||
public const string DIMODE = "DIMode";
|
||||
public const string DEFAULT_VALUE = "DefaultValue";
|
||||
public const string ACTIVE_VALUE = "ActiveValue";
|
||||
|
||||
//uart parameters 18363
|
||||
public const string BAUD_RATE = "UartBaudRate";
|
||||
public const string DATA_BITS = "UartDataBits";
|
||||
public const string STOP_BITS = "UartStopBits";
|
||||
public const string PARITY = "UartParity";
|
||||
public const string FLOW_CONTROL = "UartFlowControl";
|
||||
public const string DATA_FORMAT = "UartDataFormat";
|
||||
//streamout parameters 18363
|
||||
public const string UDP_PROFILE = "StreamOutUDPProfile";
|
||||
public const string UDP_ADDRESS = "StreamOutUDPAddress";
|
||||
public const string UDP_TIME_CHID = "StreamOutUDPTimeChannelId";
|
||||
public const string UDP_DATA_CHID = "StreamOutUDPDataChannelId";
|
||||
public const string UDP_TMNS_CONFIG = "StreamOutUDPTmNSConfig";
|
||||
public const string IRIG_TDP_INTERVAL_MS = "StreamOutIRIGTimeDataPacketIntervalMs";
|
||||
public const string TMATS_INTERVAL_MS = "StreamOutTMATSIntervalMs";
|
||||
//streamin parameters 26828
|
||||
public const string UDP_ADDRESS_IN = "StreamInUDPAddress";
|
||||
|
||||
public ChannelSettingBase(int settingType, string name, string defaultValue)
|
||||
{
|
||||
SettingTypeId = settingType;
|
||||
SettingName = name;
|
||||
DefaultValue = defaultValue;
|
||||
}
|
||||
public IChannelSetting Clone()
|
||||
{
|
||||
return new ChannelSettingBase(this);
|
||||
}
|
||||
private ChannelSettingBase(IChannelSetting setting)
|
||||
{
|
||||
ChannelId = setting.ChannelId;
|
||||
SettingTypeId = setting.SettingTypeId;
|
||||
SettingName = setting.SettingName;
|
||||
DefaultValue = setting.DefaultValue;
|
||||
Value = setting.Value;
|
||||
}
|
||||
public long ChannelId { get; set; }
|
||||
public int SettingTypeId { get; protected set; }
|
||||
public string SettingName { get; protected set; }
|
||||
public string DefaultValue { get; protected set; }
|
||||
public string Value { get; set; }
|
||||
|
||||
public double DoubleValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (double.TryParse(Value, System.Globalization.NumberStyles.Any,
|
||||
System.Globalization.CultureInfo.InvariantCulture, out double d))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
return DoubleDefaultValue;
|
||||
}
|
||||
set => Value = value.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public double DoubleDefaultValue => double.Parse(DefaultValue, System.Globalization.NumberStyles.Any,
|
||||
System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
public int IntValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (int.TryParse(Value, System.Globalization.NumberStyles.Any,
|
||||
System.Globalization.CultureInfo.InvariantCulture, out int d))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
return IntDefaultValue;
|
||||
}
|
||||
set => Value = value.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
public int IntDefaultValue => int.Parse(DefaultValue, System.Globalization.NumberStyles.Any,
|
||||
System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
public bool BoolValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (bool.TryParse(Value, out bool b))
|
||||
{
|
||||
return b;
|
||||
}
|
||||
return BoolDefaultValue;
|
||||
}
|
||||
set => Value = value.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public bool BoolDefaultValue => bool.Parse(DefaultValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using DTS.Common.Interface.Channels;
|
||||
using System.Data;
|
||||
|
||||
namespace DTS.Common.Classes.Groups.ChannelSettings
|
||||
{
|
||||
public class ChannelSettingRecord : Common.Base.BasePropertyChanged, IChannelSettingRecord
|
||||
{
|
||||
private int _id;
|
||||
public int Id
|
||||
{
|
||||
get => _id;
|
||||
set => SetProperty(ref _id, value, "Id");
|
||||
}
|
||||
|
||||
private string _settingName;
|
||||
public string SettingName
|
||||
{
|
||||
get => _settingName;
|
||||
set => SetProperty(ref _settingName, value, "SettingName");
|
||||
}
|
||||
|
||||
private string _defaultValue;
|
||||
public string DefaultValue
|
||||
{
|
||||
get => _defaultValue;
|
||||
set => SetProperty(ref _defaultValue, value, "DefaultValue");
|
||||
}
|
||||
public ChannelSettingRecord() { }
|
||||
public ChannelSettingRecord(IDataReader reader)
|
||||
{
|
||||
Id = Utility.GetInt(reader, "Id");
|
||||
SettingName = Utility.GetString(reader, "SettingName");
|
||||
DefaultValue = Utility.GetString(reader, "DefaultValue");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Interface.Channels;
|
||||
using System.Data;
|
||||
|
||||
namespace DTS.Common.Classes.Groups.ChannelSettings
|
||||
{
|
||||
public class GroupChannelSettingRecord: BasePropertyChanged, IGroupChannelSettingRecord
|
||||
{
|
||||
private long _channelId;
|
||||
public long ChannelId
|
||||
{
|
||||
get => _channelId;
|
||||
set => SetProperty(ref _channelId, value, "ChannelId");
|
||||
}
|
||||
private int _settingId;
|
||||
public int SettingId
|
||||
{
|
||||
get => _settingId;
|
||||
set => SetProperty(ref _settingId, value, "SettingId");
|
||||
}
|
||||
private string _settingValue;
|
||||
public string SettingValue
|
||||
{
|
||||
get => _settingValue;
|
||||
set => SetProperty(ref _settingValue, value, "SettingValue");
|
||||
}
|
||||
public GroupChannelSettingRecord() { }
|
||||
public GroupChannelSettingRecord(IDataReader reader, int storedProcedureVersionUsed)
|
||||
{
|
||||
if (storedProcedureVersionUsed >= Constants.BULK_GROUPCHANNELSETTINGS_GET_DB_VERSION)
|
||||
{
|
||||
ChannelId = Utility.GetLong(reader, "ChannelId");
|
||||
}
|
||||
else
|
||||
{
|
||||
ChannelId = 0;
|
||||
}
|
||||
SettingId = Utility.GetInt(reader, "SettingId");
|
||||
SettingValue = Utility.GetString(reader, "SettingValue");
|
||||
}
|
||||
public GroupChannelSettingRecord(long channelId, int settingId, string settingValue)
|
||||
{
|
||||
ChannelId = channelId;
|
||||
SettingId = settingId;
|
||||
SettingValue = settingValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
4614
Common/DTS.CommonCore/Classes/Groups/GroupChannel.cs
Normal file
4614
Common/DTS.CommonCore/Classes/Groups/GroupChannel.cs
Normal file
File diff suppressed because it is too large
Load Diff
79
Common/DTS.CommonCore/Classes/Groups/GroupDbRecord.cs
Normal file
79
Common/DTS.CommonCore/Classes/Groups/GroupDbRecord.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using DTS.Common.Interface.Groups;
|
||||
using DTS.Common.Interface.Groups.GroupList;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data;
|
||||
|
||||
namespace DTS.Common.Classes.Groups
|
||||
{
|
||||
/// <summary>
|
||||
/// represents a record of a channel in the db
|
||||
/// <inheritdoc cref="IChannelDbRecord"/>
|
||||
/// </summary>
|
||||
public class GroupDbRecord : Base.BasePropertyChanged, IGroupDbRecord
|
||||
{
|
||||
protected int _id = -1;
|
||||
/// <summary>
|
||||
/// The database id of the Channel
|
||||
/// </summary>
|
||||
[Key]
|
||||
public int Id
|
||||
{
|
||||
get => _id;
|
||||
set => SetProperty(ref _id, value, "Id");
|
||||
}
|
||||
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)
|
||||
{
|
||||
Id = copy.Id;
|
||||
SerialNumber = copy.SerialNumber;
|
||||
Picture = copy.Picture;
|
||||
DisplayName = copy.DisplayName;
|
||||
Description = copy.Description;
|
||||
Embedded = copy.Embedded;
|
||||
LastModified = copy.LastModified;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
StaticGroupId = copy.StaticGroupId;
|
||||
ExtraProperties = copy.ExtraProperties;
|
||||
}
|
||||
public GroupDbRecord(IGroup copy, List<KeyValuePair<string,string>> extraProperties)
|
||||
{
|
||||
Id = copy.Id;
|
||||
SerialNumber = copy.Name;
|
||||
Picture = "";
|
||||
DisplayName = copy.DisplayName;
|
||||
Description = copy.Description;
|
||||
Embedded = copy.Embedded;
|
||||
LastModified = copy.LastModified;
|
||||
LastModifiedBy = copy.LastModifiedBy;
|
||||
StaticGroupId = copy.StaticGroupId;
|
||||
|
||||
ExtraProperties = JsonConvert.SerializeObject(extraProperties);
|
||||
}
|
||||
public GroupDbRecord(IDataReader reader)
|
||||
{
|
||||
Id = Utility.GetInt(reader, "Id", -1);
|
||||
SerialNumber = Utility.GetString(reader, "SerialNumber");
|
||||
Picture = Utility.GetString(reader, "Picture");
|
||||
DisplayName = Utility.GetString(reader, "DisplayName");
|
||||
Description = Utility.GetString(reader, "Description");
|
||||
Embedded = Utility.GetBool(reader, "Embedded");
|
||||
LastModified = Utility.GetDateTime(reader, "LastModified", DateTime.MinValue);
|
||||
LastModifiedBy = Utility.GetString(reader, "LastModifiedBy");
|
||||
StaticGroupId = Utility.GetNullableInt(reader, "StaticGroupId");
|
||||
ExtraProperties = Utility.GetString(reader, "ExtraProperties");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DTS.Common.Classes.Groups
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// this class encapsulates a single channel or row in a TDC GRP file
|
||||
/// </summary>
|
||||
public class GroupGRPImportChannel: BasePropertyChanged
|
||||
{
|
||||
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 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 enum InputModes
|
||||
{
|
||||
na, //Not applicable. Used to denote a non-Digital Input channel
|
||||
TLH, //TransitionLowToHigh (DigitalInput)
|
||||
THL, //TransitionHighToLow (DigitalInput)
|
||||
CCNO, //ContactClosureNormallyOpen(DigitalInput)
|
||||
CCNC //ContactClosureNormallyClosed(DigitalInput)
|
||||
}
|
||||
public const InputModes DefaultInputMode = InputModes.CCNO;
|
||||
public InputModes? InputMode { get; set; } = null;
|
||||
|
||||
public const double DefaultDefaultValue = 0.0;
|
||||
public double? DefaultValue { get; set; } = null;
|
||||
|
||||
public const double DefaultActiveValue = 1.0;
|
||||
public double? ActiveValue { get; set; } = null;
|
||||
|
||||
public enum FireModes
|
||||
{
|
||||
na, //Not applicable. Used to denote a non-Squib channel
|
||||
CD, //CapacitorDischarge (Squib)
|
||||
CC //ConstantCurrent (Squib)
|
||||
}
|
||||
public const FireModes DefaultFireMode = FireModes.CD;
|
||||
public FireModes? FireMode { get; set; } = null;
|
||||
|
||||
public const double DefaultDelay = 0.00;
|
||||
public double? Delay { get; set; } = null;
|
||||
|
||||
public const bool DefaultLimitDuration = true;
|
||||
public bool? LimitDuration { get; set; } = null;
|
||||
|
||||
public const double DefaultDuration = 10.0;
|
||||
public double? Duration { get; set; } = null;
|
||||
|
||||
public const double DefaultCurrent = 1.5;
|
||||
public double? Current { get; set; } = null;
|
||||
/// <summary>
|
||||
/// error for the group, or null if there are no errors
|
||||
/// an error at this level means the group can't be imported
|
||||
/// </summary>
|
||||
public GroupGRPImportError Error { get; set; } = null;
|
||||
public GroupGRPImportGroup ParentGroup { get; set; }
|
||||
|
||||
public string GroupName => null == ParentGroup ? "---" : ParentGroup.GroupName;
|
||||
|
||||
/// <summary>
|
||||
/// forces refresh for anything bound to GroupName
|
||||
/// </summary>
|
||||
public void GroupNameInvalidate()
|
||||
{
|
||||
OnPropertyChanged("GroupName");
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Common/DTS.CommonCore/Classes/Groups/GroupGRPImportError.cs
Normal file
35
Common/DTS.CommonCore/Classes/Groups/GroupGRPImportError.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
namespace DTS.Common.Classes.Groups
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// this class encapsulates and enumerates all possible errors while importing a .GRP file
|
||||
/// </summary>
|
||||
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()
|
||||
{
|
||||
return ExtraInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Common/DTS.CommonCore/Classes/Groups/GroupGRPImportGroup.cs
Normal file
42
Common/DTS.CommonCore/Classes/Groups/GroupGRPImportGroup.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DTS.Common.Classes.Groups
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// this class encapsulates a group, or basically a .grp file
|
||||
/// </summary>
|
||||
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; }
|
||||
/// <summary>
|
||||
/// all channels in the gGRP file
|
||||
/// </summary>
|
||||
public GroupGRPImportChannel [] Channels { get; set; } = { };
|
||||
/// <summary>
|
||||
/// all errors discovered while GRP file
|
||||
/// this would include things like an empty file, a file with garbage only
|
||||
/// </summary>
|
||||
public GroupGRPImportError[] GroupErrors { get; set; } = null;
|
||||
|
||||
private bool _groupNameHasError;
|
||||
|
||||
/// <summary>
|
||||
/// indicates whether the group name specifically has an error
|
||||
/// the group name is exposed in a textbox, the design of this field was to
|
||||
/// control a red box around that textbox
|
||||
/// </summary>
|
||||
public bool GroupNameHasError
|
||||
{
|
||||
get => _groupNameHasError;
|
||||
set => SetProperty(ref _groupNameHasError, value, "GroupNameHasError");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using DTS.Common.Interface.Groups;
|
||||
using DTS.Common.Interface.Groups.GroupList;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data;
|
||||
|
||||
namespace DTS.Common.Classes.Groups
|
||||
{
|
||||
/// <summary>
|
||||
/// represents a record in the GroupHardware table in the db
|
||||
/// <inheritdoc cref="IChannelDbRecord"/>
|
||||
/// </summary>
|
||||
public class GroupHardwareDbRecord : Base.BasePropertyChanged, IGroupHardwareDbRecord
|
||||
{
|
||||
protected int _id = -1;
|
||||
/// <summary>
|
||||
/// The database id of the Channel
|
||||
/// </summary>
|
||||
[Key]
|
||||
public int Id
|
||||
{
|
||||
get => _id;
|
||||
set => SetProperty(ref _id, value, "Id");
|
||||
}
|
||||
|
||||
private int _groupId = -1;
|
||||
public int GroupId
|
||||
{
|
||||
get => _groupId;
|
||||
set => SetProperty(ref _groupId, value, "GroupId");
|
||||
}
|
||||
|
||||
private int _dasId = -1;
|
||||
public int DASId
|
||||
{
|
||||
get => _dasId;
|
||||
set => SetProperty(ref _dasId, value, "DASId");
|
||||
}
|
||||
|
||||
private string _serialNumber = string.Empty;
|
||||
public string SerialNumber
|
||||
{
|
||||
get => _serialNumber;
|
||||
set => SetProperty(ref _serialNumber, value, "SerialNumber");
|
||||
}
|
||||
|
||||
public GroupHardwareDbRecord() { }
|
||||
public GroupHardwareDbRecord(IGroupHardwareDbRecord copy)
|
||||
{
|
||||
Id = copy.Id;
|
||||
GroupId = copy.GroupId;
|
||||
DASId = copy.DASId;
|
||||
SerialNumber = copy.SerialNumber;
|
||||
}
|
||||
public GroupHardwareDbRecord(IDataReader reader)
|
||||
{
|
||||
Id = Utility.GetInt(reader, "RecordId", -1);
|
||||
GroupId = Utility.GetInt(reader, "GroupId", -1);
|
||||
DASId = Utility.GetInt(reader, "DASId", -1);
|
||||
SerialNumber = Utility.GetString(reader, "SerialNumber");
|
||||
}
|
||||
}
|
||||
}
|
||||
236
Common/DTS.CommonCore/Classes/Groups/GroupHelper.cs
Normal file
236
Common/DTS.CommonCore/Classes/Groups/GroupHelper.cs
Normal file
@@ -0,0 +1,236 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DTS.Common.Classes.Groups
|
||||
{
|
||||
public abstract class GroupHelper
|
||||
{
|
||||
#region StaticGroupNames
|
||||
private static Dictionary<int, string> StaticGroupNames = new Dictionary<int, string>();
|
||||
public static void ClearStaticGroupNames()
|
||||
{
|
||||
StaticGroupNames.Clear();
|
||||
}
|
||||
public static void SetStaticGroupName(int id, string name)
|
||||
{
|
||||
StaticGroupNames[id] = name;
|
||||
}
|
||||
public static string GetStaticGroupName(int Id)
|
||||
{
|
||||
var name = string.Empty;
|
||||
|
||||
if (StaticGroupNames.ContainsKey(Id))
|
||||
{
|
||||
name = StaticGroupNames[Id];
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
#endregion StaticGroupNames
|
||||
|
||||
#region EmbeddedGroupIdList
|
||||
private static List<int> EmbeddedGroupIdList = new List<int>();
|
||||
|
||||
public static void ClearEmbeddedGroupIdList()
|
||||
{
|
||||
EmbeddedGroupIdList.Clear();
|
||||
}
|
||||
public static void SetEmbeddedGroupId(int id)
|
||||
{
|
||||
EmbeddedGroupIdList.Add(id);
|
||||
}
|
||||
public static bool IsGroupEmbedded(int Id)
|
||||
{
|
||||
return EmbeddedGroupIdList.Contains(Id);
|
||||
}
|
||||
#endregion EmbeddedGroupIdList
|
||||
|
||||
#region TestSetupGroupIds
|
||||
private static Dictionary<int, int> TestSetupGroupIds = new Dictionary<int, int>();
|
||||
public static void ClearTestSetupGroupIds()
|
||||
{
|
||||
TestSetupGroupIds.Clear();
|
||||
}
|
||||
public static void SetTestSetupGroupId(int groupId, int testSetupId)
|
||||
{
|
||||
TestSetupGroupIds[groupId] = testSetupId;
|
||||
}
|
||||
public static int GetTestSetupGroupId(int groupId)
|
||||
{
|
||||
var testSetupGroupId = 0;
|
||||
|
||||
if (TestSetupGroupIds.ContainsKey(groupId))
|
||||
{
|
||||
testSetupGroupId = TestSetupGroupIds[groupId];
|
||||
}
|
||||
|
||||
return testSetupGroupId;
|
||||
}
|
||||
#endregion TestSetupGroupIds
|
||||
|
||||
#region GroupChannelIds
|
||||
private static Dictionary<int, List<int>> GroupChannelIds = new Dictionary<int, List<int>>();
|
||||
public static void ClearGroupChannelIds()
|
||||
{
|
||||
GroupChannelIds.Clear();
|
||||
}
|
||||
public static void AddGroupChannelId(int sensorId, int groupId)
|
||||
{
|
||||
if (!GroupChannelIds.ContainsKey(sensorId))
|
||||
{
|
||||
GroupChannelIds.Add(sensorId, new List<int>());
|
||||
}
|
||||
GroupChannelIds[sensorId].Add(groupId);
|
||||
}
|
||||
public static List<int> GetGroupIdsFromChannels(int sensorId)
|
||||
{
|
||||
var groupIdList = new List<int>();
|
||||
|
||||
if (GroupChannelIds.ContainsKey(sensorId))
|
||||
{
|
||||
groupIdList = GroupChannelIds[sensorId];
|
||||
}
|
||||
|
||||
return groupIdList;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DASIds
|
||||
private static Dictionary<string, int> DASIds = new Dictionary<string, int>();
|
||||
public static void ClearDASIds()
|
||||
{
|
||||
DASIds.Clear();
|
||||
}
|
||||
public static void SetDASId(string serialNumber, int dasId)
|
||||
{
|
||||
DASIds[serialNumber] = dasId;
|
||||
}
|
||||
public static int GetDASId(string serialNumber)
|
||||
{
|
||||
return DASIds[serialNumber];
|
||||
}
|
||||
#endregion DASIds
|
||||
|
||||
#region BaseModuleChannelIndexList
|
||||
public static Dictionary<string, Dictionary<string, List<int>>> BaseModuleChannelIndexList = new Dictionary<string, Dictionary<string, List<int>>>();
|
||||
public static void ClearBaseModuleChannelIndexList()
|
||||
{
|
||||
BaseModuleChannelIndexList.Clear();
|
||||
}
|
||||
public static void SetBaseModuleChannelIndexList(string baseSerialNumberSubstring, Dictionary<string, List<int>> tempDictionary)
|
||||
{
|
||||
BaseModuleChannelIndexList[baseSerialNumberSubstring] = tempDictionary;
|
||||
}
|
||||
public static List<int> GetChannelIndexes(string targetBaseSerialNumber, string targetModuleSerialNumber)
|
||||
{
|
||||
var channelIndexList = new List<int>();
|
||||
|
||||
foreach (var baseModuleIndexListTriple in BaseModuleChannelIndexList)
|
||||
{
|
||||
if (baseModuleIndexListTriple.Key == targetBaseSerialNumber)
|
||||
{
|
||||
var moduleIndexListTuple = baseModuleIndexListTriple.Value;
|
||||
foreach (var moduleSerialNumber in moduleIndexListTuple.Keys)
|
||||
{
|
||||
if (moduleSerialNumber == targetModuleSerialNumber)
|
||||
{
|
||||
channelIndexList = moduleIndexListTuple[moduleSerialNumber];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return channelIndexList;
|
||||
}
|
||||
#endregion BaseModuleChannelIndexList
|
||||
|
||||
#region DASIdChannelIndexGroupIdList
|
||||
public static Dictionary<int, Dictionary<int, int>> DASIdChannelIndexGroupIdList = new Dictionary<int, Dictionary<int, int>>();
|
||||
public static void ClearDASIdChannelIndexGroupIdList()
|
||||
{
|
||||
DASIdChannelIndexGroupIdList.Clear();
|
||||
}
|
||||
public static void SetDASIdChannelIndexGroupIdList(int dasId, Dictionary<int, int> tempDictionary)
|
||||
{
|
||||
DASIdChannelIndexGroupIdList[dasId] = tempDictionary;
|
||||
}
|
||||
public static List<int> GetGroupIds(int targetDasId, List<int> targetChannelIndexList)
|
||||
{
|
||||
var groupIdList = new List<int>();
|
||||
|
||||
foreach (var dasIdChannelIndexGroupIdTriple in DASIdChannelIndexGroupIdList)
|
||||
{
|
||||
if (dasIdChannelIndexGroupIdTriple.Key == targetDasId)
|
||||
{
|
||||
var channelIndexGroupIdTuple = dasIdChannelIndexGroupIdTriple.Value;
|
||||
foreach (var channelIndex in channelIndexGroupIdTuple.Keys)
|
||||
{
|
||||
if (targetChannelIndexList.Contains(channelIndex))
|
||||
{
|
||||
groupIdList.Add(channelIndexGroupIdTuple[channelIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return groupIdList;
|
||||
}
|
||||
#endregion BaseModuleChannelIndexList
|
||||
|
||||
#region TestSetupHardwareIds
|
||||
private static Dictionary<int, List<int>> TestSetupHardwareIds = new Dictionary<int, List<int>>();
|
||||
public static void ClearTestSetupHardwareIds()
|
||||
{
|
||||
TestSetupHardwareIds.Clear();
|
||||
}
|
||||
public static void AddTestSetupHardwareId(int dasId, int testSetupId)
|
||||
{
|
||||
if (!TestSetupHardwareIds.ContainsKey(dasId))
|
||||
{
|
||||
TestSetupHardwareIds.Add(dasId, new List<int>());
|
||||
}
|
||||
TestSetupHardwareIds[dasId].Add(testSetupId);
|
||||
}
|
||||
public static List<int> GetTestSetupHardwareIds(int DASId)
|
||||
{
|
||||
var testSetupIdList = new List<int>();
|
||||
|
||||
if (TestSetupHardwareIds.ContainsKey(DASId))
|
||||
{
|
||||
testSetupIdList = TestSetupHardwareIds[DASId];
|
||||
}
|
||||
|
||||
return testSetupIdList;
|
||||
}
|
||||
#endregion TestSetupHardwareIds
|
||||
|
||||
#region GroupHardwareIds
|
||||
private static Dictionary<int, List<int>> GroupHardwareIds = new Dictionary<int, List<int>>();
|
||||
public static void ClearGroupHardwareIds()
|
||||
{
|
||||
GroupHardwareIds.Clear();
|
||||
}
|
||||
public static void AddGroupHardwareId(int dasId, int groupId)
|
||||
{
|
||||
if (!GroupHardwareIds.ContainsKey(dasId))
|
||||
{
|
||||
GroupHardwareIds.Add(dasId, new List<int>());
|
||||
}
|
||||
GroupHardwareIds[dasId].Add(groupId);
|
||||
}
|
||||
public static List<int> GetGroupHardwareIds(int DASId)
|
||||
{
|
||||
var groupIdList = new List<int>();
|
||||
|
||||
if (GroupHardwareIds.ContainsKey(DASId))
|
||||
{
|
||||
groupIdList = GroupHardwareIds[DASId];
|
||||
}
|
||||
|
||||
return groupIdList;
|
||||
}
|
||||
#endregion GroupHardwareIds
|
||||
}
|
||||
}
|
||||
86
Common/DTS.CommonCore/Classes/Groups/TestSetupGroupRecord.cs
Normal file
86
Common/DTS.CommonCore/Classes/Groups/TestSetupGroupRecord.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using DTS.Common.Interface.Groups;
|
||||
using System.Data;
|
||||
|
||||
namespace DTS.Common.Classes.Groups
|
||||
{
|
||||
/// <summary>
|
||||
/// represents an association of groups to test setups and additional
|
||||
/// test setup specific meta data for a group
|
||||
/// <inheritdoc cref="ITestSetupGroupRecord"/>
|
||||
/// </summary>
|
||||
public class TestSetupGroupRecord : Base.BasePropertyChanged, ITestSetupGroupRecord
|
||||
{
|
||||
private int _groupId = -1;
|
||||
/// <summary>
|
||||
/// database id of group
|
||||
/// </summary>
|
||||
public int GroupId
|
||||
{
|
||||
get => _groupId;
|
||||
set => SetProperty(ref _groupId, value, "GroupId");
|
||||
}
|
||||
private int _displayOrder = -1;
|
||||
/// <summary>
|
||||
/// display order of group
|
||||
/// </summary>
|
||||
public int DisplayOrder
|
||||
{
|
||||
get => _displayOrder;
|
||||
set => SetProperty(ref _displayOrder, value, "DisplayOrder");
|
||||
}
|
||||
private string _position = "";
|
||||
/// <summary>
|
||||
/// Position field (ISO 13499) for group, if available
|
||||
/// [groups can be made of mixed position fields]
|
||||
/// </summary>
|
||||
public string Position
|
||||
{
|
||||
get => _position;
|
||||
set => SetProperty(ref _position, value, "Position");
|
||||
}
|
||||
private string _testObjectType = "";
|
||||
/// <summary>
|
||||
/// Test Object field (ISO 13499) for group, if available
|
||||
/// [groups can be made of mixed test object fields]
|
||||
/// </summary>
|
||||
public string TestObjectType
|
||||
{
|
||||
get => _testObjectType;
|
||||
set => SetProperty(ref _testObjectType, value, "TestObjectType");
|
||||
}
|
||||
private int _testSetupId = -1;
|
||||
/// <summary>
|
||||
/// database id of test setup group belongs to
|
||||
/// </summary>
|
||||
public int TestSetupId
|
||||
{
|
||||
get => _testSetupId;
|
||||
set => SetProperty(ref _testSetupId, value, "TestSetupId");
|
||||
}
|
||||
public TestSetupGroupRecord() { }
|
||||
/// <summary>
|
||||
/// creates record using data reader
|
||||
/// </summary>
|
||||
/// <param name="reader"></param>
|
||||
public TestSetupGroupRecord(IDataReader reader)
|
||||
{
|
||||
GroupId = Utility.GetInt(reader, "GroupId");
|
||||
DisplayOrder = Utility.GetInt(reader, "DisplayOrder");
|
||||
Position = Utility.GetString(reader, "Position");
|
||||
TestObjectType = Utility.GetString(reader, "TestObjectType");
|
||||
TestSetupId = Utility.GetInt(reader, "TestSetupId");
|
||||
}
|
||||
/// <summary>
|
||||
/// copy constructor
|
||||
/// </summary>
|
||||
/// <param name="copy"></param>
|
||||
public TestSetupGroupRecord(ITestSetupGroupRecord copy)
|
||||
{
|
||||
GroupId = copy.GroupId;
|
||||
DisplayOrder = copy.DisplayOrder;
|
||||
Position = copy.Position;
|
||||
TestObjectType = copy.TestObjectType;
|
||||
TestSetupId = copy.TestSetupId;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user