62 lines
2.3 KiB
Plaintext
62 lines
2.3 KiB
Plaintext
using System.Collections.Generic;
|
|
using DTS.Common.Enums.DASFactory;
|
|
using DTS.Common.ICommunication;
|
|
|
|
namespace DTS.DASLib.Command.SLICE.RealtimeCommands
|
|
{
|
|
public class GetRealtimeSamplesSLICE6 : GetRealtimeSamples
|
|
{
|
|
public GetRealtimeSamplesSLICE6(DTS.Common.Interface.DASFactory.ICommunication sock)
|
|
: base(sock) { }
|
|
|
|
public GetRealtimeSamplesSLICE6(DTS.Common.Interface.DASFactory.ICommunication sock, int timeoutMillisec)
|
|
: base(sock, timeoutMillisec) { }
|
|
|
|
protected override CommandReceiveAction WholePackage()
|
|
{
|
|
try
|
|
{
|
|
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
|
|
{
|
|
// Figure out the number of samples returned
|
|
var samplesReturned = (response.ParameterLength - 8) / (_channels * 2);
|
|
_samplesReturned = samplesReturned;
|
|
_data = new List<short[]>(_channels);
|
|
|
|
// Grab the sample number
|
|
if (response.ParameterLength > 0)
|
|
{
|
|
response.GetParameter(0, out _sampleNumber);
|
|
}
|
|
|
|
// Create the data arrays by channel
|
|
for (int i = 0; i < _channels; i++)
|
|
{
|
|
_data.Add(new short[samplesReturned]);
|
|
}
|
|
|
|
// Grab the data
|
|
var parameter = 8;
|
|
for (var sample = 0; sample < samplesReturned; sample++)
|
|
{
|
|
for (var channel = 0; channel < _channels; channel++)
|
|
{
|
|
response.GetParameter(parameter, out ushort val);
|
|
//Slice6 data is signed data. No need to convert.
|
|
_data[channel][sample] = (short)((((val & 0x00FF) << 8) | ((val >> 8) & 0x00FF)));
|
|
|
|
parameter += 2;
|
|
}
|
|
}
|
|
return CommandReceiveAction.StopReceiving;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
_samplesReturned = 0;
|
|
}
|
|
return CommandReceiveAction.StopReceiving;
|
|
}
|
|
}
|
|
}
|