105 lines
4.3 KiB
C#
105 lines
4.3 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Data;
|
|
|
|
namespace DatabaseExport
|
|
{
|
|
public class ISOHardwareChannel //: INotifyPropertyChanged
|
|
{
|
|
public Hardware ParentDAS { get; set; }
|
|
|
|
public int SupportedBridges { get; set; } = 12;
|
|
|
|
public int SupportedSquibFireModes { get; set; } = 16;
|
|
|
|
public int SupportedExcitations { get; set; } = 16;
|
|
|
|
public int SupportedDigitalInputModes { get; set; } = 16;
|
|
|
|
public int SupportedDigitalOutputModes { get; set; } = 16;
|
|
|
|
public int ChannelIdx { get; set; }
|
|
|
|
public int DASDisplayOrder { get; set; }
|
|
|
|
public string ModuleSerialNumber { get; set; } = "";
|
|
|
|
public int ModuleArrayIndex { get; set; } = 0;
|
|
|
|
public ISOHardwareChannel(ISOHardwareChannel copy, Hardware h)
|
|
{
|
|
SupportedSquibFireModes = copy.SupportedSquibFireModes;
|
|
SupportedExcitations = copy.SupportedExcitations;
|
|
SupportedDigitalOutputModes = copy.SupportedDigitalOutputModes;
|
|
SupportedDigitalInputModes = copy.SupportedDigitalInputModes;
|
|
SupportedBridges = copy.SupportedBridges;
|
|
ParentDAS = h;
|
|
LocalOnly = copy.LocalOnly;
|
|
DASDisplayOrder = copy.DASDisplayOrder;
|
|
ChannelIdx = copy.ChannelIdx;
|
|
ModuleArrayIndex = copy.ModuleArrayIndex;
|
|
ModuleSerialNumber = copy.ModuleSerialNumber;
|
|
}
|
|
|
|
public ISOHardwareChannel(DataRow dr, Hardware hardware)
|
|
{
|
|
ParentDAS = hardware;
|
|
|
|
var fields = Enum.GetValues(typeof(DbOperations.DAS.DASChannelFields)).Cast<DbOperations.DAS.DASChannelFields>().ToArray();
|
|
foreach (var field in fields)
|
|
{
|
|
var o = dr[field.ToString()];
|
|
if (DBNull.Value.Equals(o)) { continue; }
|
|
switch (field)
|
|
{
|
|
case DbOperations.DAS.DASChannelFields.ChannelIdx:
|
|
ChannelIdx = Convert.ToInt32(o);
|
|
break;
|
|
case DbOperations.DAS.DASChannelFields.HardwareId:
|
|
//don't need, it gets it from the hardware passed in
|
|
break;
|
|
case DbOperations.DAS.DASChannelFields.SupportedBridges:
|
|
SupportedBridges = Convert.ToInt32(o);
|
|
break;
|
|
case DbOperations.DAS.DASChannelFields.SupportedExcitations:
|
|
SupportedExcitations = Convert.ToInt32(o);
|
|
break;
|
|
case DbOperations.DAS.DASChannelFields.SupportedDigitalInputModes:
|
|
SupportedDigitalInputModes = Convert.ToInt32(o);
|
|
break;
|
|
case DbOperations.DAS.DASChannelFields.SupportedDigitalOutputModes:
|
|
SupportedDigitalOutputModes = Convert.ToInt32(o);
|
|
break;
|
|
case DbOperations.DAS.DASChannelFields.SupportedSquibFireModes:
|
|
SupportedSquibFireModes = Convert.ToInt32(o);
|
|
break;
|
|
case DbOperations.DAS.DASChannelFields.DASDisplayOrder:
|
|
DASDisplayOrder = Convert.ToInt32(o);
|
|
break;
|
|
case DbOperations.DAS.DASChannelFields.ModuleSerialNumber:
|
|
ModuleSerialNumber = o as string;
|
|
break;
|
|
case DbOperations.DAS.DASChannelFields.LocalOnly:
|
|
LocalOnly = Convert.ToBoolean(o);
|
|
break;
|
|
case DbOperations.DAS.DASChannelFields.ModuleArrayIndex:
|
|
ModuleArrayIndex = Convert.ToInt32(o);
|
|
break;
|
|
default:
|
|
throw new NotSupportedException("Unknown field:" + field.ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool LocalOnly { get; set; } = false;
|
|
|
|
public static int PhysicalCompare(ISOHardwareChannel left, ISOHardwareChannel right)
|
|
{
|
|
if (left == right) { return 0; }
|
|
if (null == left) { return -1; }
|
|
if (null == right) { return 1; }
|
|
return left.ChannelIdx.CompareTo(right.ChannelIdx);
|
|
}
|
|
}
|
|
}
|