106 lines
3.9 KiB
C#
106 lines
3.9 KiB
C#
using Common.Attributes;
|
|
using DeviceCommand.Base;
|
|
using System;
|
|
using System.IO.Ports;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DeviceCommand.Device
|
|
{
|
|
[BOBCommand]
|
|
public class IT6724CReverse : Serial_Port
|
|
{
|
|
public IT6724CReverse(string COMPort, int BaudRate, int DataBits, StopBits stopBits, Parity parity, int ReadTimeout, int ReceiveTimeout)
|
|
{
|
|
ConfigureDevice(COMPort, BaudRate, DataBits, stopBits, parity, ReadTimeout, ReceiveTimeout);
|
|
}
|
|
|
|
public IT6724CReverse() { }
|
|
|
|
#region 设置命令
|
|
|
|
public virtual Task SetOutputAsync(bool state, CancellationToken ct = default)
|
|
=> SendAsync($"OUTPut {(state ? 1 : 0)}\r\n", ct);
|
|
|
|
public virtual Task SetRemoteModeAsync(CancellationToken ct = default)
|
|
=> SendAsync("SYSTem:REMote\r\n", ct);
|
|
|
|
public virtual Task BeeperTestAsync(CancellationToken ct = default)
|
|
=> SendAsync("SYSTem:BEEPer\r\n", ct);
|
|
|
|
public virtual Task SetCurrentAsync(double current, CancellationToken ct = default)
|
|
=> SendAsync($"CURRent {current}\r\n", ct);
|
|
|
|
public virtual Task SetOCPCurrentAsync(double current, CancellationToken ct = default)
|
|
=> SendAsync($"CURRent:PROTection {current}\r\n", ct);
|
|
|
|
public virtual Task SetOCPStateAsync(bool state, CancellationToken ct = default)
|
|
=> SendAsync($"CURRent:PROTection:STATe {(state ? 1 : 0)}\r\n", ct);
|
|
|
|
public virtual Task ClearOCPAsync(CancellationToken ct = default)
|
|
=> SendAsync("CURRent:PROTection:CLEar\r\n", ct);
|
|
|
|
public virtual Task SetVoltageAsync(double voltage, CancellationToken ct = default)
|
|
=> SendAsync($"VOLTage {voltage}\r\n", ct);
|
|
|
|
public virtual Task SetOVPVoltageAsync(double voltage, CancellationToken ct = default)
|
|
=> SendAsync($"VOLT:PROTection {voltage}\r\n", ct);
|
|
|
|
public virtual Task SetOVPStateAsync(bool state, CancellationToken ct = default)
|
|
=> SendAsync($"VOLT:PROTection:STATe {(state ? 1 : 0)}\r\n", ct);
|
|
|
|
public virtual Task ClearOVPAsync(CancellationToken ct = default)
|
|
=> SendAsync("VOLT:PROTection:CLEar\r\n", ct);
|
|
|
|
public virtual Task SendCustomCommandAsync(string command, CancellationToken ct = default)
|
|
=> SendAsync($"{command}\r\n", ct);
|
|
|
|
#endregion
|
|
|
|
#region 查询命令
|
|
|
|
public virtual async Task<string> QueryIDAsync(CancellationToken ct = default)
|
|
{
|
|
await SendAsync("*IDN?\r\n", ct);
|
|
return await ReadAsync(ct: ct);
|
|
}
|
|
|
|
public virtual async Task<bool> QueryOCPTrippedAsync(CancellationToken ct = default)
|
|
{
|
|
await SendAsync("CURRent:PROTection:TRIPed?\r\n", ct);
|
|
var result = await ReadAsync(ct: ct);
|
|
return result == "1";
|
|
}
|
|
|
|
public virtual async Task<bool> QueryOVPTrippedAsync(CancellationToken ct = default)
|
|
{
|
|
await SendAsync("VOLT:PROTection:TRIPed?\r\n", ct);
|
|
var result = await ReadAsync(ct: ct);
|
|
return result == "1";
|
|
}
|
|
|
|
public virtual async Task<double> QueryCurrentAsync(CancellationToken ct = default)
|
|
{
|
|
await SendAsync("MEASure:CURRent?\r\n", ct);
|
|
var result = await ReadAsync(ct: ct);
|
|
return Convert.ToDouble(result);
|
|
}
|
|
|
|
public virtual async Task<double> QueryVoltageAsync(CancellationToken ct = default)
|
|
{
|
|
await SendAsync("MEASure:VOLTage?\r\n", ct);
|
|
var result = await ReadAsync(ct: ct);
|
|
return Convert.ToDouble(result);
|
|
}
|
|
|
|
public virtual async Task<double> QueryPowerAsync(CancellationToken ct = default)
|
|
{
|
|
await SendAsync("MEASure:POWer?\r\n", ct);
|
|
var result = await ReadAsync(ct: ct);
|
|
return Convert.ToDouble(result);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|