init
This commit is contained in:
325
DataPRO/SLICEDBCommands/PowerCommands.cs
Normal file
325
DataPRO/SLICEDBCommands/PowerCommands.cs
Normal file
@@ -0,0 +1,325 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Enums.DASFactory;
|
||||
using DTS.Common.ICommunication;
|
||||
|
||||
namespace DTS.DASLib.Command.SLICEDB
|
||||
{
|
||||
public abstract class PowerCommands : CommandBase
|
||||
{
|
||||
protected enum Commands
|
||||
{
|
||||
Reserved = 0x00,
|
||||
|
||||
QueryV1VoltageMV = 0x01,
|
||||
QueryBatteryVoltageMV = 0x02,
|
||||
QueryBatteryChargeCurrentMA = 0x03,
|
||||
QuerySliceBusInputCurrentMA = 0x04,
|
||||
QuerySliceBusVoltageMV = 0x05,
|
||||
|
||||
SetSliceBusVoltageMV = 0x06,
|
||||
|
||||
QueryMinimumV1MVForSliceBusEnable = 0x07,
|
||||
SetMinimumV1MVForSliceBusEnable = 0x08,
|
||||
QueryMinimumV1MVForBatteryChargeEnable = 0x09,
|
||||
SetMinimumV1MVForBatteryChargeEnable = 0x0A,
|
||||
QueryDefaultSliceBusVoltageMV = 0x0B,
|
||||
SetDefaultSliceBusVoltageMV = 0x0C,
|
||||
QueryDelayBeforeSliceBusVoltageEnableMS = 0x0D,
|
||||
SetDelayBeforeSliceBusVoltageEnableMS = 0x0E,
|
||||
|
||||
QueryV1OvervoltageLimitMV = 0x0F,
|
||||
SetV1OvervoltageLimitMV = 0x10,
|
||||
QueryV1OvervoltageCount = 0x11,
|
||||
SetV1OvervoltageCount = 0x12,
|
||||
|
||||
QueryBatteryVoltageOvervoltageLimitMV = 0x13,
|
||||
SetBattteryVoltageOvervoltageLimitMV = 0x14,
|
||||
QueryBatteryVoltageOvervoltageCount = 0x15,
|
||||
SetBatteryVoltageOvervoltageCount = 0x16,
|
||||
|
||||
QuerySliceBusInputCurrentOvercurrentLimitMA = 0x17,
|
||||
SetSliceBusInputCurrentOvercurrentLimitMA = 0x18,
|
||||
QuerySliceBusInputCurrentOvercurrentCount = 0x19,
|
||||
SetSliceBusInputCurrentOvercurrentCount = 0x1A,
|
||||
|
||||
QueryBatteryChargeCurrentOvercurrentLimitMA = 0x17,
|
||||
SetBatteryChargeCurrentOvercurrentLimitMA = 0x18,
|
||||
QueryBatteryChargeCurrentOvercurrentCount = 0x19,
|
||||
SetBatteryChargeCurrentOvercurrentCount = 0x1A,
|
||||
};
|
||||
protected abstract Commands _Command { get; }
|
||||
|
||||
protected PowerCommands(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
command.Type = CommandPacket.CommandType.Power;
|
||||
command.SetCommand((byte)_Command, _Command.ToString());
|
||||
}
|
||||
|
||||
protected PowerCommands(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
command.Type = CommandPacket.CommandType.Power;
|
||||
command.SetCommand((byte)_Command, _Command.ToString());
|
||||
}
|
||||
public override void CommandToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.CommandToString(ref lines);
|
||||
lines[0].Add(recorder.ConnectString);
|
||||
}
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines[0].Add(recorder.ConnectString);
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryV1VoltageMV : PowerCommands
|
||||
{
|
||||
protected override Commands _Command => Commands.QueryV1VoltageMV;
|
||||
|
||||
public QueryV1VoltageMV(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QueryV1VoltageMV(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private uint _val;
|
||||
|
||||
/// <summary>
|
||||
/// The input voltage (+V1 on connector P1) in millivolts
|
||||
/// </summary>
|
||||
public uint V1VoltageMV => _val;
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
_val = 0;
|
||||
if (response.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
response.GetParameter(0, out uint uVal);
|
||||
_val = uVal;
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>
|
||||
{
|
||||
$"+V1 (mV): {V1VoltageMV}"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryBatteryVoltageMV : PowerCommands
|
||||
{
|
||||
protected override Commands _Command => Commands.QueryBatteryVoltageMV;
|
||||
|
||||
public QueryBatteryVoltageMV(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
MinimumProtocolVersion = sock.GetMinProto(DFConstantsAndEnums.ProtocolLimitedCommands.QueryBatteryVoltage);
|
||||
}
|
||||
|
||||
public QueryBatteryVoltageMV(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
MinimumProtocolVersion = sock.GetMinProto(DFConstantsAndEnums.ProtocolLimitedCommands.QueryBatteryVoltage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The battery voltage (+BAT on connector J1) in millivolts
|
||||
/// </summary>
|
||||
public uint BatteryVoltageMV { get; private set; }
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
BatteryVoltageMV = 0;
|
||||
if (response.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
uint uVal;
|
||||
response.GetParameter(0, out uVal);
|
||||
BatteryVoltageMV = uVal;
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>
|
||||
{
|
||||
$"+BAT (mV): {BatteryVoltageMV}"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryBatteryChargeCurrentMA : PowerCommands
|
||||
{
|
||||
protected override Commands _Command => Commands.QueryBatteryChargeCurrentMA;
|
||||
|
||||
public QueryBatteryChargeCurrentMA(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QueryBatteryChargeCurrentMA(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private uint _val;
|
||||
|
||||
/// <summary>
|
||||
/// The battery charge current in milliamps
|
||||
/// </summary>
|
||||
public uint BatteryChargeCurrentMA => _val;
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
_val = 0;
|
||||
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
{
|
||||
uint uVal;
|
||||
response.GetParameter(0, out uVal);
|
||||
_val = uVal;
|
||||
}
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>
|
||||
{
|
||||
$"Battery Charge Current (mA): {BatteryChargeCurrentMA}"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class QuerySliceBusInputCurrentMA : PowerCommands
|
||||
{
|
||||
protected override Commands _Command => Commands.QuerySliceBusInputCurrentMA;
|
||||
|
||||
public QuerySliceBusInputCurrentMA(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QuerySliceBusInputCurrentMA(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private uint _val;
|
||||
|
||||
/// <summary>
|
||||
/// The slice bus current in milliamps
|
||||
/// </summary>
|
||||
public uint SliceBusInputCurrentMA => _val;
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
_val = 0;
|
||||
if (response.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
uint uVal;
|
||||
response.GetParameter(0, out uVal);
|
||||
_val = uVal;
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>
|
||||
{
|
||||
$"SLICE Bus Current (mA): {SliceBusInputCurrentMA}"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class QuerySliceBusVoltageMV : PowerCommands
|
||||
{
|
||||
protected override Commands _Command => Commands.QuerySliceBusVoltageMV;
|
||||
|
||||
public QuerySliceBusVoltageMV(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QuerySliceBusVoltageMV(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private uint _val;
|
||||
|
||||
/// <summary>
|
||||
/// The slice bus voltage in millivolts
|
||||
/// </summary>
|
||||
public uint SliceBusVoltageMV => _val;
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
_val = 0;
|
||||
if (response.Status != DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
uint uVal;
|
||||
response.GetParameter(0, out uVal);
|
||||
_val = uVal;
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>
|
||||
{
|
||||
$"SLICE Bus voltage (mV): {SliceBusVoltageMV}"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class SetSliceBusVoltageMV : PowerCommands
|
||||
{
|
||||
protected override Commands _Command => Commands.SetSliceBusVoltageMV;
|
||||
|
||||
public SetSliceBusVoltageMV(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public SetSliceBusVoltageMV(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private uint _val;
|
||||
|
||||
/// <summary>
|
||||
/// The slice bus voltage in millivolts
|
||||
/// </summary>
|
||||
public uint SliceBusVoltageMV
|
||||
{
|
||||
|
||||
set
|
||||
{
|
||||
_val = value;
|
||||
command.Parameter = new byte[sizeof(uint)];
|
||||
command.SetParameter(0, _val);
|
||||
}
|
||||
get => _val;
|
||||
}
|
||||
|
||||
public override void CommandToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.CommandToString(ref lines);
|
||||
lines.Add(new List<string> { string.Format("SLICE Bus voltage (mV): {0}", SliceBusVoltageMV) });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user