179 lines
6.6 KiB
C#
179 lines
6.6 KiB
C#
|
|
using System;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
namespace DTS.Serialization.SoMat
|
|||
|
|
{
|
|||
|
|
public class SoMatChannel
|
|||
|
|
{
|
|||
|
|
public int LogicalChannel { get; set; }
|
|||
|
|
public string ChanType { get; set; } = "SEQUENTIAL";
|
|||
|
|
public string ChanName { get; set; } = "";
|
|||
|
|
public ulong NumDataPoints { get; set; } = 0;
|
|||
|
|
public int NumDims { get; set; } = 2;
|
|||
|
|
public int DataMode { get; set; } = 1;
|
|||
|
|
public string DataModeType { get; set; } = "TIMHIS";
|
|||
|
|
public string AxisLabelDim1 { get; set; } = "Time";
|
|||
|
|
public string AxisLabelDim2 { get; set; } = "";
|
|||
|
|
public string AxisUnitsDim1 { get; set; } = "Secs";
|
|||
|
|
public string AxisUnitsDim2 { get; set; } = "";
|
|||
|
|
public string SampleRate { get; set; } = "";
|
|||
|
|
public string TimeBase { get; set; } = "";
|
|||
|
|
public string MaxValue { get; set; } = "";
|
|||
|
|
public string MinValue { get; set; } = "";
|
|||
|
|
public string UserMax { get; set; } = "";
|
|||
|
|
public string UserMin { get; set; } = "";
|
|||
|
|
public string ChanDim2 { get; set; } = "1";
|
|||
|
|
public string DescDim2 { get; set; } = "";
|
|||
|
|
public string CTypeDim2 { get; set; } = "8";
|
|||
|
|
public string HDWParams { get; set; } = "";
|
|||
|
|
public string CalParams { get; set; } = "";
|
|||
|
|
public string DGParams { get; set; } = "";
|
|||
|
|
|
|||
|
|
public enum TriggerModes { ALWAYS_ON, GATE, TRIGGER, ONE_SHOT };
|
|||
|
|
public TriggerModes TriggerMode { get; set; } = TriggerModes.TRIGGER;
|
|||
|
|
|
|||
|
|
public string _elapsedTime = "";
|
|||
|
|
public string ElapsedTime
|
|||
|
|
{
|
|||
|
|
get => _elapsedTime;
|
|||
|
|
set => _elapsedTime = value;
|
|||
|
|
}
|
|||
|
|
public string HistType { get; set; } = "Other";
|
|||
|
|
public string AcquisitionRate { get; set; } = "";
|
|||
|
|
public string RTCStart { get; set; } = "";
|
|||
|
|
public string RTCEnd { get; set; } = "";
|
|||
|
|
public int PhysicalChannelNumber { get; set; }
|
|||
|
|
public void Serialize(System.IO.StreamWriter sw)
|
|||
|
|
{
|
|||
|
|
sw.Write("DM_LogicalChan=");
|
|||
|
|
sw.WriteLine(LogicalChannel.ToString());
|
|||
|
|
|
|||
|
|
sw.Write("DM_ChanType=");
|
|||
|
|
sw.WriteLine(ChanType);
|
|||
|
|
|
|||
|
|
sw.Write("DM_ChanName=");
|
|||
|
|
sw.WriteLine(ChanName);
|
|||
|
|
|
|||
|
|
sw.Write("DM_NumPoints=");
|
|||
|
|
sw.WriteLine(NumDataPoints.ToString());
|
|||
|
|
|
|||
|
|
sw.Write("DM_NumDims=");
|
|||
|
|
sw.WriteLine(NumDims.ToString());
|
|||
|
|
|
|||
|
|
sw.Write("DM_DataMode=");
|
|||
|
|
sw.WriteLine(DataMode.ToString());
|
|||
|
|
|
|||
|
|
sw.Write("DM_DataModeType=");
|
|||
|
|
sw.WriteLine(DataModeType);
|
|||
|
|
|
|||
|
|
sw.Write("DM_AxisLabel.Dim1=");
|
|||
|
|
sw.WriteLine(AxisLabelDim1);
|
|||
|
|
|
|||
|
|
sw.Write("DM_AxisLabel.Dim2=");
|
|||
|
|
sw.WriteLine(AxisLabelDim2);
|
|||
|
|
|
|||
|
|
sw.Write("DM_AxisUnits.Dim1=");
|
|||
|
|
sw.WriteLine(AxisUnitsDim1);
|
|||
|
|
|
|||
|
|
sw.Write("DM_AxisUnits.Dim2=");
|
|||
|
|
sw.WriteLine(AxisUnitsDim2);
|
|||
|
|
|
|||
|
|
sw.Write("DM_SampleRate=");
|
|||
|
|
sw.WriteLine(SampleRate);
|
|||
|
|
|
|||
|
|
sw.Write("DM_TimeBase=");
|
|||
|
|
sw.WriteLine(TimeBase);
|
|||
|
|
|
|||
|
|
sw.Write("DM_MaxValue=");
|
|||
|
|
sw.WriteLine(MaxValue);
|
|||
|
|
|
|||
|
|
sw.Write("DM_MinValue=");
|
|||
|
|
sw.WriteLine(MinValue);
|
|||
|
|
|
|||
|
|
sw.Write("DM_UserMax=");
|
|||
|
|
sw.WriteLine(UserMax);
|
|||
|
|
|
|||
|
|
sw.Write("DM_UserMin=");
|
|||
|
|
sw.WriteLine(UserMin);
|
|||
|
|
|
|||
|
|
sw.Write("2100_Chan.Dim2=");
|
|||
|
|
sw.WriteLine(ChanDim2);
|
|||
|
|
|
|||
|
|
sw.Write("2100_CDESC.Dim2=");
|
|||
|
|
sw.WriteLine(DescDim2);
|
|||
|
|
|
|||
|
|
sw.Write("2100_CTYPE.Dim2=");
|
|||
|
|
sw.WriteLine(CTypeDim2);
|
|||
|
|
|
|||
|
|
sw.Write("HDWParams=");
|
|||
|
|
sw.WriteLine(HDWParams);
|
|||
|
|
|
|||
|
|
sw.Write("CALParams=");
|
|||
|
|
sw.WriteLine(CalParams);
|
|||
|
|
|
|||
|
|
sw.Write("DGParams=");
|
|||
|
|
sw.WriteLine(DGParams);
|
|||
|
|
|
|||
|
|
sw.Write("Trig=");
|
|||
|
|
sw.WriteLine(TriggerMode);
|
|||
|
|
|
|||
|
|
sw.Write("DM_ElapsedTime=");
|
|||
|
|
sw.WriteLine(ElapsedTime);
|
|||
|
|
|
|||
|
|
sw.Write("DM_HistType=");
|
|||
|
|
sw.WriteLine(HistType);
|
|||
|
|
|
|||
|
|
sw.Write("DM_AcquisitionRate=");
|
|||
|
|
sw.WriteLine(AcquisitionRate);
|
|||
|
|
|
|||
|
|
sw.Write("RTCStart=");
|
|||
|
|
sw.WriteLine(RTCStart);
|
|||
|
|
|
|||
|
|
sw.Write("RTCEnd=");
|
|||
|
|
sw.WriteLine(RTCEnd);
|
|||
|
|
|
|||
|
|
sw.Write("DM_PhysicalChan=");
|
|||
|
|
sw.WriteLine(PhysicalChannelNumber);
|
|||
|
|
|
|||
|
|
sw.WriteLine();
|
|||
|
|
}
|
|||
|
|
public SoMatChannel(Test.Module.Channel channel, int logicalChannel, FilteredData filteredData, int moduleArrayIndex,
|
|||
|
|
int numChannelsPerModule, DateTime inceptionDateTime)
|
|||
|
|
{
|
|||
|
|
LogicalChannel = logicalChannel;
|
|||
|
|
var aic = channel as Test.Module.AnalogInputChannel;
|
|||
|
|
|
|||
|
|
ChanName = aic.ChannelDescriptionString;
|
|||
|
|
NumDataPoints = aic.ParentModule.NumberOfSamples;
|
|||
|
|
AxisLabelDim2 = aic.SerialNumber;
|
|||
|
|
AxisUnitsDim2 = aic.EngineeringUnits.TrimEnd();
|
|||
|
|
//0:0.###E+00
|
|||
|
|
SampleRate = aic.ParentModule.SampleRateHz.ToString("0.00000E+00");
|
|||
|
|
|
|||
|
|
if (aic.TimeOfFirstSampleValid) { TimeBase = aic.TimeOfFirstSampleSec.ToString("0.00000E+00"); }
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
var start = aic.ParentModule.StartRecordSampleNumber - (double)aic.ParentModule.TriggerSampleNumbers[0];
|
|||
|
|
start /= aic.ParentModule.SampleRateHz;
|
|||
|
|
TimeBase = start.ToString("0.00000E+00");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_filteredData = filteredData;
|
|||
|
|
MaxValue = filteredData.Data.Max().ToString("0.00000E+00");
|
|||
|
|
MinValue = filteredData.Data.Min().ToString("0.00000E+00");
|
|||
|
|
UserMax = aic.DesiredRange.ToString("0.00000E+00");
|
|||
|
|
UserMin = (-1D * aic.DesiredRange).ToString("0.00000E+00");
|
|||
|
|
DescDim2 = aic.SerialNumber;
|
|||
|
|
var elapsedTime = aic.ParentModule.NumberOfSamples / (double)aic.ParentModule.SampleRateHz;
|
|||
|
|
ElapsedTime = (elapsedTime).ToString("0.00000E+00");
|
|||
|
|
var elapsed = new TimeSpan(0, 0, 0, 0, Convert.ToInt32(elapsedTime * 1000D));
|
|||
|
|
AcquisitionRate = aic.ParentModule.SampleRateHz.ToString("F4");
|
|||
|
|
var end = inceptionDateTime.Add(elapsed);
|
|||
|
|
RTCStart = $"{inceptionDateTime.ToShortDateString()} {inceptionDateTime.ToShortTimeString()} {end.ToShortDateString()} {end.ToShortTimeString()}";
|
|||
|
|
RTCEnd = $"{end.ToShortDateString()} {end.ToShortTimeString()}";
|
|||
|
|
PhysicalChannelNumber = 1 + moduleArrayIndex * numChannelsPerModule + aic.Number;
|
|||
|
|
}
|
|||
|
|
private readonly FilteredData _filteredData;
|
|||
|
|
}
|
|||
|
|
}
|