Files
DP44/DataPRO/SensorDB/TSF/TSFRackDescription.cs

261 lines
10 KiB
C#
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTS.SensorDB
{
/// <summary>
/// stolen from HLApi
/// used only sparsely in DataPRO
/// </summary>
public class TSFRackDescription
{
/// <summary>
/// the number specified in the .INI file
/// </summary>
private int _number;
public int Number { get { return _number; } set { _number = value; } }
private int _version;
public int Version { get { return _version; } set { _version = value; } }
private int _type;
public int Type { get { return _type; } set { _type = value; } }
private TSFSystemDescription _parent;
public TSFSystemDescription Parent { get { return _parent; } set { _parent = value; } }
/// <summary>
/// ??
/// </summary>
private int _flags;
public int Flags;
/// <summary>
/// ??
/// </summary>
private int _source;
public int Source { get { return _source; } set { _source = value; } }
/// <summary>
/// The calculated CRC for this struct
/// </summary>
private ulong _crc32;
public ulong CRC32 { get { return _crc32; } set { _crc32 = value; } }
// Variables to describe the HW configuration of this rack.
/// <summary>
/// Are the HW* valiables valid?
/// </summary>
private bool _hwInfoValid;
public bool HardwareInfoValid { get { return _hwInfoValid; } set { _hwInfoValid = value; } }
/// <summary>
/// How many SIM's do we have?
/// </summary>
private int _hwSIMCount;
private int HWSIMCount { get { return _hwSIMCount; } set { _hwSIMCount = value; } }
/// <summary>
/// How many TOM's do we have?
/// </summary>
private int _hwTOMCount;
public int HWTOMCount { get { return _hwTOMCount; } set { _hwTOMCount = value; } }
/// <summary>
/// How many analog channels do we have?
/// </summary>
private int _hwAnalogChannelCount;
public int HWAnalogChannelCount { get { return _hwAnalogChannelCount; } set { _hwAnalogChannelCount = value; } }
/// <summary>
/// How many squib channels do we have?
/// </summary>
private int _hwSquibChannelCount;
public int HWSquibChannelCount { get { return _hwSquibChannelCount; } set { _hwSquibChannelCount = value; } }
/// <summary>
/// How many digital outputs do we have?
/// </summary>
private int _hwDigitalOutputChannelCount;
public int HWDigitalOutputChannelCount { get { return _hwDigitalOutputChannelCount; } set { _hwDigitalOutputChannelCount = value; } }
/// <summary>
/// How many digital inputs do we have?
/// </summary>
private int _hwDigitalInputChannelCount;
public int HWDigitalInputChannelCount { get { return _hwDigitalInputChannelCount; } set { _hwDigitalInputChannelCount = value; } }
/// <summary>
/// The serial number of this rack
/// </summary>
private string _hwSerialNumber;
public string HWSerialNumber { get { return _hwSerialNumber; } set { _hwSerialNumber = value.Trim(); } }
/// <summary>
/// The IP address of this rack
/// </summary>
private string _hwIPAddress;
public string HWIPAddress { get { return _hwIPAddress; } set { _hwIPAddress = value; } }
/// <summary>
/// How many entries is there in the HWModuleList?
/// </summary>
public int HWModuleCount { get { return HWModuleList.Length; } }
/// <summary>
/// The address to an array of ModuleDescription's
/// </summary>
private List<TSFModuleDescription> _hwModuleList = new List<TSFModuleDescription>();
public TSFModuleDescription[] HWModuleList { get { return _hwModuleList.ToArray(); } set { _hwModuleList = new List<TSFModuleDescription>(value); } }
// This represents the different power sources for this rack
/// <summary>
/// Are the Power* and Battery* variables valid?
/// </summary>
private bool _powerInfoValid = false;
public bool PowerInfoValid { get { return _powerInfoValid; } set { _powerInfoValid = value; } }
/// <summary>
/// Current voltage of source 1
/// </summary>
private double _powerSource1Volts;
public double PowerSource1Volts { get { return _powerSource1Volts; } set { _powerSource1Volts = value; } }
/// <summary>
/// Current voltage of source 2
/// </summary>
private double _powerSource2Volts;
public double PowerSource2Volts { get { return _powerSource2Volts; } set { _powerSource2Volts = value; } }
/// <summary>
/// Not really a state, current charge voltage maybe?
/// </summary>
private double _batteryChargeState;
public double BatteryChargeState { get { return _batteryChargeState; } set { _batteryChargeState = value; } }
/// <summary>
/// Is it charging or draining?
/// </summary>
private int _batteryChargeDirection;
public int BatteryChargeDirection { get { return _batteryChargeDirection; } set { _batteryChargeDirection = value; } }
// This represents the digital inputs on this rack
/// <summary>
/// Is the DigitalInputBits valid?
/// </summary>
private bool _digitalInputBitsValid;
public bool DigitalInputBitsValid { get { return _digitalInputBitsValid; } set { _digitalInputBitsValid = value; } }
/// <summary>
/// One bit for each digital input
/// </summary>
private ulong _digitalInputBits;
public ulong DigitalInputBits { get { return _digitalInputBits; } set { _digitalInputBits = value; } }
// Current info about this racks LED's and fault/trigger lines.
/// <summary>
/// Is the LED/Fault/Trigger info below valid?
/// </summary>
private bool _LEDInfoValid;
public bool LEDInfoValid { get { return _LEDInfoValid; } set { _LEDInfoValid = value; } }
/// <summary>
/// What color is the cal LED? See HLAPI_LED_*
/// </summary>
private char _calLED;
public char CalLED { get { return _calLED; } set { _calLED = value; } }
/// <summary>
/// What color is the armed LED? See HLAPI_LED_*
/// </summary>
private char _armLED;
public char ArmLED { get { return _armLED; } set { _armLED = value; } }
/// <summary>
/// What color is the start record LED? See HLAPI_LED_*
/// </summary>
private char _statLED;
public char StatLED { get { return _statLED; } set { _statLED = value; } }
/// <summary>
/// Current state of trigger fault
/// </summary>
private bool _triggerFault;
public bool TriggerFault { get { return _triggerFault; } set { _triggerFault = value; } }
/// <summary>
/// Current state of the level trigger
/// </summary>
private bool _levelTrigger;
public bool LevelTrigger { get { return _levelTrigger; } set { _levelTrigger = value; } }
/// <summary>
/// This boolean indicates if this rack is currently powered down and should be ignored for all operations.
/// </summary>
private bool _isPoweredDown;
public bool IsPoweredDown { get { return _isPoweredDown; } set { _isPoweredDown = value; } }
/// <summary>
/// this boolean indicates if this rack (G5) is in a docking station or not
/// </summary>
private bool _isInDockingStation;
public bool IsInDockingStation { get { return _isInDockingStation; } set { _isInDockingStation = value; } }
public TSFRackDescription() { }
public TSFRackDescription(TSFRackDescription copy)
{
_armLED = copy.ArmLED;
_batteryChargeDirection = copy._batteryChargeDirection;
_batteryChargeState = copy._batteryChargeState;
_calLED = copy._calLED;
_crc32 = copy._crc32;
_digitalInputBits = copy._digitalInputBits;
_digitalInputBitsValid = copy._digitalInputBitsValid;
_flags = copy._flags;
_hwAnalogChannelCount = copy._hwAnalogChannelCount;
_hwDigitalInputChannelCount = copy._hwDigitalInputChannelCount;
_hwDigitalOutputChannelCount = copy._hwDigitalOutputChannelCount;
_hwInfoValid = copy._hwInfoValid;
_hwIPAddress = copy._hwIPAddress;
_hwModuleList = new List<TSFModuleDescription>();
foreach (var m in copy._hwModuleList) { _hwModuleList.Add(new TSFModuleDescription(m, this)); }
_hwSerialNumber = copy._hwSerialNumber;
_hwSIMCount = copy._hwSIMCount;
_hwSquibChannelCount = copy._hwSquibChannelCount;
_hwTOMCount = copy._hwTOMCount;
_isInDockingStation = copy._isInDockingStation;
_isPoweredDown = copy._isPoweredDown;
_LEDInfoValid = copy._LEDInfoValid;
_levelTrigger = copy._levelTrigger;
_parent = copy._parent;
_powerInfoValid = copy._powerInfoValid;
_powerSource1Volts = copy._powerSource1Volts;
_powerSource2Volts = copy._powerSource2Volts;
_source = copy._source;
_statLED = copy._statLED;
_triggerFault = copy._triggerFault;
_type = copy._type;
_version = copy._version;
_number = copy.Number;
}
public void SetModule(int moduleIndex, int trigMode, int trigChan, int trigDir, double trigLevel, int moduleType)
{
for (int i = _hwModuleList.Count; i <= moduleIndex; i++)
{
TSFModuleDescription hwModule = null;
if (i == moduleIndex)
{
hwModule = new TSFModuleDescription();
hwModule.Parent = this;
hwModule.Slot = moduleIndex;
hwModule.Type = moduleType;
}
_hwModuleList.Add(hwModule);
}
}
}
}