using DTS.Common.Interface.DataRecorders; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Data; namespace DTS.Common.Classes.Hardware { /// /// representation of a DASChannel in the db /// /// public class DASChannelDBRecord : Common.Base.BasePropertyChanged, IDASChannelDBRecord { /// /// a string id for the hardware the channel belongs to /// (serialnumber_dastype) /// public string HardwareId { get; set; } [Key] [Column("DASChannelId")] /// /// the id/key of the DAS channel record in the db /// public int DaschannelId { get; set; } [Column("DASId")] /// /// the das db id of the Hardware this channel belongs to /// public int? Dasid { get; set; } private int _channelIdx; /// /// the physical channel index of the channel among channels on the DAS /// public int ChannelIdx { get => _channelIdx; set => SetProperty(ref _channelIdx, value, "ChannelIdx"); } /// /// BitMask indicating the supported bridges on a das by default (half (4) + full (8))bridge /// public const int DEFAULT_SUPPORTED_BRIDGES = 12; private int _supportedBridges = DEFAULT_SUPPORTED_BRIDGES; /// /// BitMask for bridges supported by the channel /// Bit 0 indicates IEPE /// Bit 1 indicates quarter bridge /// Bit 2 indicates half bridge /// Bit 3 indicates full bridge /// Bit 4 indicates digital input /// Bit 5 indicates squib fire /// Bit 6 indicates digital output /// Bit 7 indicates Half bridge signal plus (G5 signal plus) /// Bit 8 indicates RealTime Clock /// Bit 9 indicates UART /// public int SupportedBridges { get => _supportedBridges; set => SetProperty(ref _supportedBridges, value, "SupportedBridges"); } /// /// BitMask indicating the supported excitations for a das channel by default /// (5V by default) /// public const int DEFAULT_SUPPORTED_EXCITATIONS = 16; private int _supporedExcitations = DEFAULT_SUPPORTED_EXCITATIONS; /// /// BitMask indicating what excitation options the channel supports /// Bit 0 indicates an invalid excitation (undefined) /// Bit 1 indicates 2V /// Bit 2 indicates 2.5V /// Bit 3 indicates 3V /// Bit 4 indicates 5V /// Bit 5 indicates 10V /// Bit 6 indicates 1V /// public int SupportedExcitations { get => _supporedExcitations; set => SetProperty(ref _supporedExcitations, value, "SupportedExcitations"); } [Column("DASDisplayOrder")] private int _dasDisplayOrder; /// /// The display order of the channel among channels on the DAS /// note that the physical order of channels and the display order may not match for /// some hardware /// public int DASDisplayOrder { get => _dasDisplayOrder; set => SetProperty(ref _dasDisplayOrder, value, "DASDisplayOrder"); } private bool _bLocalOnly; /// /// Indicates that record should be stored only in the local db and not propagated to a central db /// deprecated /// public bool LocalOnly { get => _bLocalOnly; set => SetProperty(ref _bLocalOnly, value, "LocalOnly"); } /// /// Bitmask indicating the default supported digital input modes for a channel (CCNC) /// public const int DEFAULT_SUPPORTED_DI_MODES = 16; private int _supportedDigitalInputModes = DEFAULT_SUPPORTED_DI_MODES; /// /// BitMask indicating what Digital input modes are supported on the channel (if channel supports digital input bridge type) /// Bit 0 indicates an invalid mode /// Bit 1 indicates Transition low to high (TLH) /// Bit 2 indicates Transition high to low (THL) /// Bit 3 indicates Contact closure normally open (CCNO) /// Bit 4 indicates Contact closure normally closed (CCNC) /// public int SupportedDigitalInputModes { get => _supportedDigitalInputModes; set => SetProperty(ref _supportedDigitalInputModes, value, "SupportedDigitalInputModes"); } /// /// BitMask indicating the default squib fire modes supported by a channel (note that 16 is invalid, but /// I'm preserving what is in the existing code) /// public const int DEFAULT_SQUIB_FIRE_MODES = 16; private int _supportedSquibFireModes = DEFAULT_SQUIB_FIRE_MODES; /// /// BitMask indicating what Squib fire modes are supported on the channel (if the channel supports squib fire bridge type) /// Bit 0 indicates an invalid mode (fire mode not set) /// Bit 1 indicates capacitor discharge /// Bit 2 indicates constant current /// Bit 3 indicates AC discharge /// public int SupportedSquibFireModes { get => _supportedSquibFireModes; set => SetProperty(ref _supportedSquibFireModes, value, "SupportedSquibFireModes"); } /// /// Default digital output mode for channels 16 doesn't exist, but I'm preserving the existing behavior values /// public const int DEFAULT_SUPPORTED_DO_MODES = 16; private int _supportedDigitalOutputModes = DEFAULT_SUPPORTED_DO_MODES; /// /// BitMask indicating what digital output modes are supported on the channel (if the channel supports digital output bridge type) /// Bit 0 indicates 5V low to high (FVLH) /// Bit 1 indicates 5V high to low transition (FVHL) /// Bit 2 indicates contact closure normally open (CCNO) /// Bit 3 indicates contact closure normally closed (CCNC) /// public int SupportedDigitalOutputModes { get => _supportedDigitalOutputModes; set => SetProperty(ref _supportedDigitalOutputModes, value, "SupportedDigitalOutputModes"); } [StringLength(16)] protected string _moduleSerialNumber = ""; /// /// Serial number of module channel belongs to /// public string ModuleSerialNumber { get => _moduleSerialNumber; set => SetProperty(ref _moduleSerialNumber, value, "ModuleSerialNumber"); } public int SettingId { get; set; } protected int _moduleArrayIndex; /// /// Array index of module among modules on a DAS or Rack /// public int ModuleArrayIndex { get => _moduleArrayIndex; set => _moduleArrayIndex = value; } public DASChannelDBRecord() { } /// /// constructor using a datareader to retrieve values /// /// public DASChannelDBRecord(IDataReader reader) { HardwareId = Utility.GetString(reader, "HardwareId", string.Empty); ChannelIdx = Utility.GetInt(reader, "ChannelIdx", -1); SupportedBridges = Utility.GetInt(reader, "SupportedBridges", DEFAULT_SUPPORTED_BRIDGES); SupportedExcitations = Utility.GetInt(reader, "SupportedExcitations", DEFAULT_SUPPORTED_EXCITATIONS); SupportedDigitalInputModes = Utility.GetInt(reader, "SupportedDigitalInputModes", DEFAULT_SUPPORTED_DI_MODES); SupportedDigitalOutputModes = Utility.GetInt(reader, "SupportedDigitalOutputModes", DEFAULT_SUPPORTED_DO_MODES); SupportedSquibFireModes = Utility.GetInt(reader, "SupportedSquibFireModes", DEFAULT_SQUIB_FIRE_MODES); DASDisplayOrder = Utility.GetInt(reader, "DASDisplayOrder", 0); ModuleSerialNumber = Utility.GetString(reader, "ModuleSerialNumber", string.Empty); LocalOnly = Utility.GetBool(reader, "LocalOnly", false); ModuleArrayIndex = Utility.GetInt(reader, "ModuleArrayIndex", -1); } /// /// copy constructor /// /// public DASChannelDBRecord(IDASChannelDBRecord copy) { HardwareId = copy.HardwareId; ChannelIdx = copy.ChannelIdx; SupportedBridges = copy.SupportedBridges; SupportedExcitations = copy.SupportedExcitations; SupportedDigitalInputModes = copy.SupportedDigitalInputModes; SupportedDigitalOutputModes = copy.SupportedDigitalOutputModes; SupportedSquibFireModes = copy.SupportedSquibFireModes; DASDisplayOrder = copy.DASDisplayOrder; ModuleSerialNumber = copy.ModuleSerialNumber; LocalOnly = copy.LocalOnly; ModuleArrayIndex = copy.ModuleArrayIndex; } } }