343 lines
12 KiB
C#
343 lines
12 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using DTS.Common;
|
|
using DTS.DASLib.Command.SLICE;
|
|
using DTS.DASLib.Command;
|
|
using DTS.Common.ICommunication;
|
|
using DTS.Common.SerialConnection;
|
|
using DTS.Common.Interface.Connection;
|
|
using DTS.Common.Interface.DASFactory.Diagnostics;
|
|
using DTS.DASLib.Service.Classes.Diagnostics;
|
|
using DTS.Common.Interface.DASFactory.ARM;
|
|
using DTS.Common.Interface.DASFactory.Download;
|
|
using DTS.Common.Interface.DASFactory.Config;
|
|
using DTS.Common.Enums.DASFactory;
|
|
using DTS.Common.Interface.DASFactory;
|
|
using DTS.Common.Enums.Hardware;
|
|
using static DTS.Common.Enums.DASFactory.DFConstantsAndEnums;
|
|
|
|
namespace DTS.DASLib.Service
|
|
{
|
|
|
|
public partial class TDAS<T> : Communication<T>,
|
|
IDASCommunication,
|
|
IConfigurationActions,
|
|
IDiagnosticsActions,
|
|
ITriggerCheckActions,
|
|
IRealTimeActions,
|
|
IArmActions,
|
|
IDownloadActions where T : IConnection, new()
|
|
{
|
|
public ExcitationStatus ExcitationStatus { get; set; } = ExcitationStatus.Unknown;
|
|
public HardwareTypes GetHardwareType()
|
|
{
|
|
if (SerialNumber.StartsWith("5M"))
|
|
{
|
|
switch (G5Mode)
|
|
{
|
|
case G5Modes.INDUMMY: return HardwareTypes.G5INDUMMY;
|
|
case G5Modes.VDS:
|
|
default:
|
|
return HardwareTypes.G5VDS;
|
|
}
|
|
}
|
|
else if (SerialNumber.StartsWith("DR")) { return HardwareTypes.TDAS_Pro_Rack; }
|
|
else if (SerialNumber.StartsWith("SM")) { return HardwareTypes.SIM; }
|
|
else if (SerialNumber.StartsWith("TOM")) { return HardwareTypes.TOM; }
|
|
else if (SerialNumber.StartsWith("LR"))
|
|
{
|
|
return HardwareTypes.TDAS_LabRack;
|
|
}
|
|
else
|
|
{
|
|
//invalid serial number, just treat as rack?
|
|
return HardwareTypes.TDAS_Pro_Rack;
|
|
}
|
|
}
|
|
public bool StartRecord
|
|
{
|
|
get;
|
|
protected set;
|
|
}
|
|
public float InputLowVoltage { get; set; }
|
|
public float InputMediumVoltage { get; set; }
|
|
public float InputHighVoltage { get; set; }
|
|
public float BatteryLowVoltage { get; set; }
|
|
public float BatteryMediumVoltage { get; set; }
|
|
public float BatteryHighVoltage { get; set; }
|
|
public double MinimumValidInputVoltage { get; set; }
|
|
public double MaximumValidInputVoltage { get; set; }
|
|
public double MinimumValidBatteryVoltage { get; set; }
|
|
public double MaximumValidBatteryVoltage { get; set; }
|
|
public bool CheckAAF(float rate) { return true; }
|
|
/// <summary>
|
|
/// phase shift information not known for TDAS modules right now, so assuming 0
|
|
/// </summary>
|
|
/// <param name="ModuleIndex"></param>
|
|
/// <param name="ActualSampleRate"></param>
|
|
/// <param name="HardwareAAF"></param>
|
|
/// <returns></returns>
|
|
public ulong GetPhaseShiftSamples(uint ModuleIndex, double ActualSampleRate, uint HardwareAAF, ulong originalT0) { return 0; }
|
|
#region Configuration
|
|
|
|
// our public configure member
|
|
|
|
public IConfigurationData ConfigData { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region Diagnostics
|
|
|
|
// our public diagnostics member
|
|
|
|
public IDiagnosticActions[] ChannelDiagnostics { get; set; }
|
|
public void SetChannelDiagnosticActions(IDiagnosticActions[] actions, bool setInDb = true)
|
|
{
|
|
DiagnosticsActions.SetChannelDiagnosticActions(this, actions, setInDb);
|
|
}
|
|
public IDiagnosticResult[] ChannelDiagnosticsResults { get; set; }
|
|
public void ClearChannelDiagnosticsResults(bool bClearDb = true)
|
|
{
|
|
DiagnosticsResultActions.ClearChannelDiagnosticsResults(this, bClearDb);
|
|
}
|
|
|
|
public void SetChannelDiagnosticsResults(IDiagnosticResult[] results, bool setInDb)
|
|
{
|
|
DiagnosticsResultActions.SetChannelDiagnosticsResults(this, results, setInDb);
|
|
}
|
|
public IBaseInputValues BaseInput { get; set; }
|
|
public IOptimizationValues OptimizationValues { get; set; }
|
|
#region Clock Sync
|
|
public IDictionary<InputClockSource, bool> DASClockSyncStatus { get; set; } = null;
|
|
public bool ClockSyncInUTC { get; set; } = false;
|
|
|
|
public ClockSyncProfile DASClockSyncProfile { get; set; }
|
|
public byte PTPDomainID { get; set; }
|
|
#endregion
|
|
public IArmCheckActions ArmCheckActions { get; set; }
|
|
public IArmCheckResults ArmCheckResults { get; set; }
|
|
#endregion
|
|
|
|
#region Trigger check
|
|
|
|
// our public trigger check member
|
|
|
|
public ITriggerCheckResult TriggerResult { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region Real time
|
|
|
|
// our public real time member
|
|
|
|
public List<int> RealtimeDASChannels { get; set; }
|
|
public List<double> TiltAxisData { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region FlashErase
|
|
|
|
public FlashEraseStatus DASFlashEraseStatus { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region Arming
|
|
public bool GetIsInArm()
|
|
{
|
|
if (null == DASArmStatus) { return false; }
|
|
return DASArmStatus.IsArmed;
|
|
}
|
|
public bool GetIsInRealtime()
|
|
{
|
|
if (null == DASArmStatus) { return false; }
|
|
return DASArmStatus.IsInRealtime;
|
|
}
|
|
/// <summary>
|
|
/// returns true if the unit is known to be streaming
|
|
/// does not query the hardware, just returns a flag if it has been set
|
|
/// </summary>
|
|
/// <returns>true if known to be streaming, false otherwise</returns>
|
|
public bool GetIsStreaming()
|
|
{
|
|
return false;
|
|
}
|
|
public void SetInArm(bool WriteToDb)
|
|
{
|
|
if (null == DASArmStatus)
|
|
{
|
|
var armStatus = new ArmStatus()
|
|
{
|
|
IsArmed = true
|
|
};
|
|
ArmStatus.SetArmStatus(this, armStatus, WriteToDb);
|
|
}
|
|
else
|
|
{
|
|
DASArmStatus.IsArmed = true;
|
|
if (WriteToDb)
|
|
{
|
|
SetDASArmStatus();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetInRealtime(bool WriteToDb, bool ExitRealtimeIfPossible)
|
|
{
|
|
if (null == DASArmStatus)
|
|
{
|
|
var armStatus = new ArmStatus()
|
|
{
|
|
IsInRealtime = true
|
|
};
|
|
ArmStatus.SetArmStatus(this, armStatus, WriteToDb);
|
|
}
|
|
else
|
|
{
|
|
DASArmStatus.IsInRealtime = true;
|
|
if (WriteToDb)
|
|
{
|
|
SetDASArmStatus();
|
|
}
|
|
}
|
|
}
|
|
public IArmStatusData DASArmStatus { get; set; }
|
|
public void SetDASArmStatus(IArmStatusData status, bool bSetInDb)
|
|
{
|
|
ArmStatus.SetArmStatus(this, status, bSetInDb);
|
|
}
|
|
public void SetDASArmStatus()
|
|
{
|
|
ArmStatus.SetArmStatus(this, DASArmStatus, true);
|
|
}
|
|
private DFConstantsAndEnums.CommandStatus _autoArmStatus = DFConstantsAndEnums.CommandStatus.StatusNoError;
|
|
public DFConstantsAndEnums.CommandStatus AutoArmStatus
|
|
{
|
|
get { return _autoArmStatus; }
|
|
set { _autoArmStatus = value; }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Downloading
|
|
|
|
public IDownloadRequest WhatToDownload { get; set; }
|
|
public void SetWhatToDownload(IDownloadRequest request, bool bSetInDb = true)
|
|
{
|
|
DownloadRequest.SetWhatToDownload(this, request, bSetInDb);
|
|
}
|
|
public IDownloadReport EventInfo { get; set; }
|
|
public void SetEventInfo(IDownloadReport eventInfo, bool bSetInDb = true)
|
|
{
|
|
DownloadReport.SetEventInfo(this, eventInfo, bSetInDb);
|
|
}
|
|
public bool[] EventDownloadedStatus { get; set; }
|
|
public void SetEventDownloadStatus(bool[] status, bool storeInDb = true)
|
|
{
|
|
DownloadReport.SetEventDownloadStatus(this, status, storeInDb);
|
|
}
|
|
public Guid[] EventGuids { get; set; }
|
|
public void SetEventGuids(Guid[] guids, bool storeInDb = true)
|
|
{
|
|
DownloadReport.SetEventGuids(this, guids, storeInDb);
|
|
}
|
|
uint[] IDownload.ExtendedFaultFlags1 { get; set; }
|
|
uint[] IDownload.ExtendedFaultFlags2 { get; set; }
|
|
uint[] IDownload.ExtendedFaultFlags3 { get; set; }
|
|
uint[] IDownload.ExtendedFaultFlags4 { get; set; }
|
|
void IDownload.SetExtendedFaultFlags(uint[][] flags)
|
|
{
|
|
DownloadExtendedFaultFunctions.SetExtendedFaultFlags(flags, this);
|
|
}
|
|
public ushort[] FaultFlags { get; set; }
|
|
public void SetEventFaultFlags(ushort[] flags, bool storeInDb = true)
|
|
{
|
|
DownloadReport.SetEventFaultFlags(this, flags, storeInDb);
|
|
}
|
|
public byte[] ArmAttempts { get; set; }
|
|
public void SetEventArmAttemps(byte[] armAttempts, bool storeInDb = true)
|
|
{
|
|
DownloadReport.SetEventArmAttempts(this, armAttempts, storeInDb);
|
|
}
|
|
#endregion
|
|
|
|
#region Information
|
|
|
|
/// <summary>
|
|
/// note, this property hides a property inherited from ICommunication, but that
|
|
/// one is declared with a different type (Communication_DASInfo), so I'm assuming this
|
|
/// was intended to hide that property
|
|
/// 6/29/2010 - dtm
|
|
/// </summary>
|
|
|
|
public new IInfoResult DASInfo { get; set; }
|
|
public void SetDASInfo(IInfoResult dasInfo, bool bSetInDb = true)
|
|
{
|
|
InfoResult.SetDASInfo(this, dasInfo, bSetInDb);
|
|
}
|
|
public void SetDASInfo() { InfoResult.SetDASInfo(this); }
|
|
#endregion
|
|
|
|
#region Firmware Utility
|
|
|
|
#endregion
|
|
|
|
//I'm guessing hiding was not intended, this member hides an inherited member (from ICommunication)
|
|
//public string SerialNumber { get; set; }
|
|
public override string ToString()
|
|
{
|
|
var sn = SerialNumber;
|
|
if (!string.IsNullOrEmpty(sn))
|
|
return sn;
|
|
return "Unknown DAS";
|
|
}
|
|
|
|
public int NumberOfConfiguredChannels()
|
|
{
|
|
if (null == ConfigData) { return 0; }
|
|
return ConfigData.NumberOfConfiguredChannels();
|
|
}
|
|
|
|
|
|
public int NumberOfChannels()
|
|
{
|
|
if (null == ConfigData) { return 0; }
|
|
return ConfigData.NumberOfChannels();
|
|
}
|
|
|
|
|
|
public int CompareTo(IDASCommunication das)
|
|
{
|
|
if (das == null || string.IsNullOrEmpty(das.SerialNumber) || string.IsNullOrEmpty(SerialNumber))
|
|
return 0;
|
|
return SerialNumber.CompareTo(das.SerialNumber);
|
|
}
|
|
|
|
public bool DiagnosticsHasBeenRun { get; set; }
|
|
private bool _configureHasBeenRun = false;
|
|
public bool ConfigureHasBeenRun
|
|
{
|
|
get { return _configureHasBeenRun; }
|
|
set { _configureHasBeenRun = value; }
|
|
}
|
|
|
|
}
|
|
|
|
#region Sub classes used for identification
|
|
|
|
public class EthernetTDAS : TDAS<EthernetConnection>
|
|
{
|
|
|
|
public EthernetTDAS()
|
|
{
|
|
}
|
|
}
|
|
|
|
public class SerialTDAS : TDAS<SerialConnection>
|
|
{
|
|
public SerialTDAS()
|
|
{
|
|
}
|
|
}
|
|
#endregion
|
|
}
|