init
This commit is contained in:
150
DataPRO/IService/Classes/ServiceCallbackData.cs
Normal file
150
DataPRO/IService/Classes/ServiceCallbackData.cs
Normal file
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static DTS.Common.Enums.DASFactory.DFConstantsAndEnums;
|
||||
|
||||
namespace DTS.DASLib.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// the base class for our internal callbacks (specific service callback to generic service)
|
||||
/// </summary>
|
||||
public class ServiceCallbackData
|
||||
{
|
||||
public class DiagnosticNewData
|
||||
{
|
||||
public int DasChannelNumber { get; set; }
|
||||
public enum Actions
|
||||
{
|
||||
MeasureBridgeMv, MeasureShunt, ScaleFactorMv, FactoryExcitation, MeasureExcitation,
|
||||
MeasureOffset, CalSignalCheck, FinalOffset, MeasureNoise, RemoveOffset, ShuntCheck, QueryModules, MeasureVoltages,
|
||||
TestChannelRun, TestChannelRead, MeasureInternalOffset, MeasureFinalInternalOffset
|
||||
};
|
||||
public Actions Action { get; set; }
|
||||
public object Result { get; set; }
|
||||
}
|
||||
|
||||
public class TiltNewData
|
||||
{
|
||||
public double[] TiltData { get; set; }
|
||||
|
||||
public double[] AccelData { get; set; }
|
||||
}
|
||||
|
||||
public class TemperatureData
|
||||
{
|
||||
public int Channel1 { get; set; }
|
||||
public int Channel2 { get; set; }
|
||||
public DateTime[] Timestamps { get; set; }
|
||||
public double[] Sensor1 { get; set; }
|
||||
public double[] Sensor2 { get; set; }
|
||||
}
|
||||
public class UARTNewData
|
||||
{
|
||||
public ulong DataOffset { get; set; }
|
||||
public byte[] UARTData { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The different types of callbacks
|
||||
/// </summary>
|
||||
public enum CallbackStatus
|
||||
{
|
||||
ProgressReport,
|
||||
NewData,
|
||||
Timeout,
|
||||
Success,
|
||||
Failure,
|
||||
Canceled,
|
||||
InvalidParameters // and others
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What kind of message is this
|
||||
/// </summary>
|
||||
public CallbackStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If it was an error (Status==Failure), the message is here
|
||||
/// </summary>
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If it was an exception (Status==Failure), it's here otherwise null
|
||||
/// </summary>
|
||||
public System.Exception ErrorException { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If it was ProgressReport, this is the percentage done
|
||||
/// </summary>
|
||||
public int ProgressValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The user supplied data is here
|
||||
/// </summary>
|
||||
public object UserData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// callback could contain multiple non contiguous samples
|
||||
/// if so, we will need to know a separate sample number and short [][]
|
||||
/// for each break
|
||||
/// this is mostly for nicer realtime handling so data can be obtained from the
|
||||
/// h/w at a different rate then the UI is updated at
|
||||
/// </summary>
|
||||
private IList<SampleData> _Data = new List<SampleData>();
|
||||
/// <summary>
|
||||
/// returns a collection of <see cref="SampleData">SampleData</see>
|
||||
/// objects which contain sequences of channel data and a number indicating
|
||||
/// which samle number in the h/w each sequence begins at
|
||||
/// </summary>
|
||||
public SampleData[] DataSamples
|
||||
{
|
||||
get => _Data.ToArray();
|
||||
set => _Data = new List<SampleData>(value);
|
||||
}
|
||||
|
||||
private DiagnosticNewData _newDiagnosticData = null;
|
||||
|
||||
private TiltNewData _newTiltData = null;
|
||||
|
||||
private UARTNewData _newUartData = null;
|
||||
private TemperatureData _newTemperatureData = null;
|
||||
public DiagnosticNewData NewDiagnosticData => _newDiagnosticData;
|
||||
public void SetNewDiagnosticData(DiagnosticNewData data) { _newDiagnosticData = data; }
|
||||
|
||||
public void SetNewTiltData(TiltNewData data) { _newTiltData = data; }
|
||||
|
||||
public void SetNewTemperatureData(TemperatureData data) { _newTemperatureData = data; }
|
||||
public void SetNewUARTData(UARTNewData data) { _newUartData = data; }
|
||||
|
||||
private byte[] _byteData = null;
|
||||
public void SetNewByteData(byte[] data) { _byteData = data; }
|
||||
public byte[] ByteData { get => _byteData; }
|
||||
public TiltNewData NewTiltData => _newTiltData;
|
||||
|
||||
public UARTNewData NewUARTData => _newUartData;
|
||||
|
||||
public TemperatureData NewTemperatureData => _newTemperatureData;
|
||||
/// <summary>
|
||||
/// adds a new sample (composed of multiple channels of short [] data and
|
||||
/// a sample number indicating the start of the data
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="sampleNumber"></param>
|
||||
public void AddSampleData(short[][] data, ulong sampleNumber, ulong timeStamp, ulong sequenceNumber)
|
||||
{
|
||||
_Data.Add(new SampleData(data, sampleNumber, timeStamp, sequenceNumber));
|
||||
}
|
||||
/// <summary>
|
||||
/// returns the <see cref="SampleData">SampleData</see> struct
|
||||
/// at a given index among a collection of samples
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public SampleData GetSampleData(int index) { return _Data[index]; }
|
||||
/// <summary>
|
||||
/// the total number of different non contiguous samples in the data
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int GetNumberOfSamples() { return _Data.Count; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user