init
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.ICommunication;
|
||||
|
||||
namespace DTS.DASLib.Command.SLICE.MulticastCommands
|
||||
{
|
||||
public class MulticastSetGatewayAddress : MulticastCommandBase
|
||||
{
|
||||
const int COMMAND_PAYLOAD_SIZE = DOUBLE_MAC_ADDR_SIZE + IP_ADDR_SIZE;
|
||||
|
||||
protected override Commands Command => Commands.SetGatewayAddress;
|
||||
|
||||
private string _gateway;
|
||||
public string Gateway { set { _gateway = value; command.SetParameter(FIRST_PARAMETER_OFFSET, _gateway); } }
|
||||
|
||||
public MulticastSetGatewayAddress(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
command.Parameter = new byte[COMMAND_PAYLOAD_SIZE];
|
||||
}
|
||||
|
||||
public MulticastSetGatewayAddress(DTS.Common.Interface.DASFactory.ICommunication sock, int timeoutMillisec)
|
||||
: base(sock, timeoutMillisec)
|
||||
{
|
||||
command.Parameter = new byte[COMMAND_PAYLOAD_SIZE];
|
||||
}
|
||||
|
||||
public override void CommandToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.CommandToString(ref lines);
|
||||
lines.Add(new List<string> { $"MAC: {CommandClientMac} Gateway: {_gateway}" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user