BOB/DeviceCommand/Device/IT6724C.cs

160 lines
5.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 IT6724C : Serial_Port
{
public IT6724C(string COMPort, int BaudRate, int DataBits, StopBits stopBits, Parity parity, int ReadTimeout, int ReceiveTimeout)
{
ConfigureDevice(COMPort, BaudRate, DataBits, stopBits, parity, ReadTimeout, ReceiveTimeout);
}
public IT6724C() { }
#region
/// <summary>
/// 设置电源输出状态true 为开false 为关
/// </summary>
public virtual async Task (bool , CancellationToken ct = default)
=>await SendAsync($"OUTPut {(开关 ? 1 : 0)}\r\n", ct);
/// <summary>
/// 切换到远程控制模式
/// </summary>
public virtual async Task (CancellationToken ct = default)
=>await SendAsync("SYSTem:REMote\r\n", ct);
/// <summary>
/// 蜂鸣器测试
/// </summary>
public virtual async Task (CancellationToken ct = default)
=>await SendAsync("SYSTem:BEEPer\r\n", ct);
/// <summary>
/// 设置输出电流单位A
/// </summary>
public virtual async Task (double , CancellationToken ct = default)
=>await SendAsync($"CURRent {电流}\r\n", ct);
/// <summary>
/// 设置过流保护电流OCP单位A
/// </summary>
public virtual async Task OCP电流(double , CancellationToken ct = default)
=>await SendAsync($"CURRent:PROTection {电流}\r\n", ct);
/// <summary>
/// 设置过流保护状态true 为启用false 为禁用
/// </summary>
public virtual async Task OCP开关(bool , CancellationToken ct = default)
=>await SendAsync($"CURRent:PROTection:STATe {(开关 ? 1 : 0)}\r\n", ct);
/// <summary>
/// 清除过流保护触发状态
/// </summary>
public virtual async Task (CancellationToken ct = default)
=>await SendAsync("CURRent:PROTection:CLEar\r\n", ct);
/// <summary>
/// 设置输出电压单位V
/// </summary>
public virtual async Task (double , CancellationToken ct = default)
=>await SendAsync($"VOLTage {电压}\r\n", ct);
/// <summary>
/// 设置过压保护电压OVP单位V
/// </summary>
public virtual async Task OVP电压(double , CancellationToken ct = default)
=>await SendAsync($"VOLT:PROTection {电压}\r\n", ct);
/// <summary>
/// 设置过压保护状态true 为启用false 为禁用
/// </summary>
public virtual async Task OVP开关(bool , CancellationToken ct = default)
=>await SendAsync($"VOLT:PROTection:STATe {(开关 ? 1 : 0)}\r\n", ct);
/// <summary>
/// 清除过压保护触发状态
/// </summary>
public virtual async Task (CancellationToken ct = default)
=> await SendAsync("VOLT:PROTection:CLEar\r\n", ct);
/// <summary>
/// 发送自定义命令
/// </summary>
public virtual async Task (string , CancellationToken ct = default)
=>await SendAsync($"{指令}\r\n", ct);
#endregion
#region
/// <summary>
/// 查询仪器标识,返回制造商、型号、序列号、固件版本
/// </summary>
public virtual async Task<string> (CancellationToken ct = default)
{
await SendAsync("*IDN?\r\n", ct);
return await ReadAsync(ct: ct);
}
/// <summary>
/// 查询过流保护是否触发,返回 true 表示触发
/// </summary>
public virtual async Task<bool> (CancellationToken ct = default)
{
await SendAsync("CURRent:PROTection:TRIPed?\r\n", ct);
var result = await ReadAsync(ct: ct);
return result == "1";
}
/// <summary>
/// 查询过压保护是否触发,返回 true 表示触发
/// </summary>
public virtual async Task<bool> (CancellationToken ct = default)
{
await SendAsync("VOLT:PROTection:TRIPed?\r\n", ct);
var result = await ReadAsync(ct: ct);
return result == "1";
}
/// <summary>
/// 查询实际输出电流单位A
/// </summary>
public virtual async Task<double> (CancellationToken ct = default)
{
await SendAsync("MEASure:CURRent?\r\n", ct);
var result = await ReadAsync(ct: ct);
return Convert.ToDouble(result);
}
/// <summary>
/// 查询实际输出电压单位V
/// </summary>
public virtual async Task<double> (CancellationToken ct = default)
{
await SendAsync("MEASure:VOLTage?\r\n", ct);
var result = await ReadAsync(ct: ct);
return Convert.ToDouble(result);
}
/// <summary>
/// 查询实际输出功率单位W
/// </summary>
public virtual async Task<double> (CancellationToken ct = default)
{
await SendAsync("MEASure:POWer?\r\n", ct);
var result = await ReadAsync(ct: ct);
return Convert.ToDouble(result);
}
#endregion
}
}