上机bug修复,命令修复添加
This commit is contained in:
@@ -8,52 +8,68 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DeviceCommand.Devices
|
||||
{
|
||||
#region 枚举定义
|
||||
|
||||
/// <summary>
|
||||
/// 电源电气/耦合模式
|
||||
/// </summary>
|
||||
public enum PowerCouplingMode
|
||||
{
|
||||
/// <summary> 纯交流模式 </summary>
|
||||
AC,
|
||||
/// <summary> 纯直流模式 </summary>
|
||||
DC,
|
||||
/// <summary> 交直流混合模式 </summary>
|
||||
ACDC,
|
||||
/// <summary> 直交流混合模式 </summary>
|
||||
DCAC
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设备操作运行角色/模式
|
||||
/// </summary>
|
||||
public enum DeviceOperationMode
|
||||
{
|
||||
/// <summary> 电压源模式(常规源) </summary>
|
||||
VOLTage,
|
||||
/// <summary> 电子负载模式(放电拉载) </summary>
|
||||
LOAD,
|
||||
/// <summary> 电流源模式 </summary>
|
||||
CURRent
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
[ADPCommand]
|
||||
public class IT7800E : Tcp
|
||||
{
|
||||
//只有一个,八台产品一起用一个
|
||||
// 根据通用 SCPI 指令规范,使用换行符 (ASCII 字符 LF,即 \n) 作为标准结束符
|
||||
// 八台产品共用一个,使用换行符 \n (ASCII 0x0A) 作为 SCPI 结束符[cite: 1]
|
||||
private const string ScpiDelimiter = "\n";
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数:传入 <see cref="TcpConfig"/> 一次性初始化 IT7800E 交直流电源通信参数。
|
||||
/// </summary>
|
||||
public IT7800E(TcpConfig config) : base(config)
|
||||
{
|
||||
}
|
||||
|
||||
#region 1. IEEE 488.2 公共命令
|
||||
|
||||
/// <summary>
|
||||
/// 清除状态命令。清除标准事件状态寄存器和错误队列
|
||||
/// </summary>
|
||||
public virtual async Task 清除错误队列和状态字节(CancellationToken ct = default)
|
||||
{
|
||||
await SendAsync($"*CLS{ScpiDelimiter}", ct);
|
||||
await SendAsync($"*CLS{ScpiDelimiter}", ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取电源识别字符串(制造商、产品型号、系统 SN、软件版本号)
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询设备标识(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($"*IDN?{ScpiDelimiter}", ScpiDelimiter, ct); //
|
||||
return await WriteReadAsync($"*IDN?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 复位命令。使电源恢复到出厂默认预定义安全值
|
||||
/// </summary>
|
||||
public virtual async Task 重置设备(CancellationToken ct = default)
|
||||
{
|
||||
await SendAsync($"*RST{ScpiDelimiter}", ct); //
|
||||
await SendAsync($"*RST{ScpiDelimiter}", ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取状态字节寄存器
|
||||
/// </summary>
|
||||
public virtual async Task<string> 读取状态字节(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($"*STB?{ScpiDelimiter}", ScpiDelimiter, ct); //
|
||||
return await WriteReadAsync($"*STB?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -61,81 +77,57 @@ namespace DeviceCommand.Devices
|
||||
#region 2. 耦合模式与拉载开关控制
|
||||
|
||||
/// <summary>
|
||||
/// 设置电源输出源的电气模式/工作耦合模式
|
||||
/// (AC: 纯交流, DC: 纯直流, ACDC: 交直流混合模式)
|
||||
/// 设置电源输出源的电气模式/工作耦合模式 (AC, DC, ACDC, DCAC)[cite: 1]
|
||||
/// </summary>
|
||||
public virtual async Task 设置电源模式(string 模式, CancellationToken ct = default)
|
||||
public virtual async Task 设置电源模式(PowerCouplingMode 模式, CancellationToken ct = default)
|
||||
{
|
||||
string modeUpper = 模式.ToUpper();
|
||||
if (modeUpper != "AC" && modeUpper != "DC" && modeUpper != "ACDC")
|
||||
throw new ArgumentException("工作模式只能为 AC, DC, 或 ACDC");
|
||||
|
||||
await SendAsync($":SOURce:MODE {modeUpper}{ScpiDelimiter}", ct);
|
||||
await SendAsync($":SOURce:FUNCtion {模式}{ScpiDelimiter}", ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询电源当前的工作模式
|
||||
/// 查询电源当前的工作电气模式[cite: 1]
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询电源模式(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":SOURce:MODE?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($":SOURce:FUNCtion?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控制电源的主输出开关 (True: 开启输出, False: 关闭输出)
|
||||
/// </summary>
|
||||
public virtual async Task 设置DC输出(bool 开启, CancellationToken ct = default)
|
||||
{
|
||||
// 注意:虽然方法名叫设置DC输出,但对交直流电源它代表通用的主输出控制(Main Output)
|
||||
string 参数 = 开启 ? "ON" : "OFF";
|
||||
await SendAsync($":OUTPut {参数}{ScpiDelimiter}", ct);
|
||||
string 参数 = 开启 ? "ON" : "OFF"; //[cite: 1]
|
||||
await SendAsync($":OUTPut {参数}{ScpiDelimiter}", ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询电源当前主输出开关状态 (返回 ON 或 OFF)
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询DC输出状态(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":OUTPut?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($":OUTPut?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 3. 设定输出参数设置 (AC 电压/频率/DC 电压)
|
||||
|
||||
/// <summary>
|
||||
/// 设定交流(AC)模式下的电压有效值 (单位: V)
|
||||
/// </summary>
|
||||
public virtual async Task 设置交流电压(double 电压, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":SOURce:VOLTage:AC {0:F2}{1}", 电压, ScpiDelimiter);
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":SOURce:VOLTage {0:F2}{1}", 电压, ScpiDelimiter); //[cite: 1]
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设定直流(DC)模式或交直流(AC+DC)模式下的直流偏置电压值 (单位: V)
|
||||
/// </summary>
|
||||
public virtual async Task 设置直流电压(double 电压, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":SOURce:VOLTage:DC {0:F2}{1}", 电压, ScpiDelimiter);
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":SOURce:VOLTage:DC {0:F2}{1}", 电压, ScpiDelimiter); //[cite: 1]
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设定电源交流输出的频率值 (单位: Hz)
|
||||
/// </summary>
|
||||
public virtual async Task 设置频率(double 频率, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":SOURce:FREQuency {0:F2}{1}", 频率, ScpiDelimiter);
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":SOURce:FREQuency {0:F2}{1}", 频率, ScpiDelimiter); //[cite: 1]
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置硬件交流输出的有效值限流门限 (单位: A)
|
||||
/// </summary>
|
||||
public virtual async Task 设置电流(double 电流, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":SOURce:CURRent {0:F3}{1}", 电流, ScpiDelimiter);
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":SOURce:CURRent {0:F3}{1}", 电流, ScpiDelimiter); //[cite: 1]
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
@@ -143,109 +135,127 @@ namespace DeviceCommand.Devices
|
||||
|
||||
#region 4. 测量与数据回测(高频数据轮询核心)
|
||||
|
||||
/// <summary>
|
||||
/// 查询通道实时测得的电压有效值(RMS,支持 AC 或 DC 模式下的回测)(单位: V)
|
||||
/// </summary>
|
||||
[Monitorable("交流电源电压")]
|
||||
public virtual async Task<string> 查询实际电压(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":MEASure:VOLTage?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($":MEASure:VOLTage?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询通道实时测得的电流有效值(RMS)(单位: A)
|
||||
/// </summary>
|
||||
[Monitorable("交流电源电流")]
|
||||
public virtual async Task<string> 查询实际电流(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":MEASure:CURRent?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($":MEASure:CURRent?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询通道实时测得的有功功率值 (单位: W)
|
||||
/// </summary>
|
||||
[Monitorable("交流电源功率")]
|
||||
public virtual async Task<string> 查询实际功率(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":MEASure:POWer?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($":MEASure:POWer?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询通道实时测得的视在功率 (单位: VA)
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询视在功率(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":MEASure:POWer:APParent?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($":MEASure:POWer:APParent?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询通道实时测得的输出频率 (单位: Hz)
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询实际频率(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":MEASure:FREQuency?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($":MEASure:FREQuency?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询当前的功率因数 (PF)
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询功率因数(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":MEASure:PF?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($":MEASure:POWer:PFACtor?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 5. 保护参数设置与系统监控
|
||||
|
||||
/// <summary>
|
||||
/// 设置电源的过流保护(OCP)值 (单位: A)
|
||||
/// </summary>
|
||||
public virtual async Task 设置过流保护_OCP(double 电流, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":SOURce:CURRent:PROTection {0:F3}{1}", 电流, ScpiDelimiter);
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":SOURce:CURRent:PROTection:RMS {0:F3}{1}", 电流, ScpiDelimiter); //[cite: 1]
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置电源的过压保护(OVP)值 (单位: V)
|
||||
/// </summary>
|
||||
public virtual async Task 设置过压保护_OVP(double 电压, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":SOURce:VOLTage:PROTection {0:F2}{1}", 电压, ScpiDelimiter);
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":SOURce:VOLTage:PROTection:PEAK {0:F2}{1}", 电压, ScpiDelimiter); //[cite: 1]
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取系统的出错记录信息(获取上一条未处理的错误码)
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询错误信息(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":SYSTem:ERRor?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($":SYSTem:ERRor?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换仪器至计算机控制的远程控制模式 (锁定前面板按键)
|
||||
/// </summary>
|
||||
public virtual async Task 切换远程控制模式(CancellationToken ct = default)
|
||||
{
|
||||
await SendAsync($":SYSTem:REMote{ScpiDelimiter}", ct);
|
||||
await SendAsync($":SYSTem:REMote{ScpiDelimiter}", ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换仪器至前面板操作的本地模式 (前面板解锁)
|
||||
/// </summary>
|
||||
public virtual async Task 切换本地控制模式(CancellationToken ct = default)
|
||||
{
|
||||
await SendAsync($":SYSTem:LOCal{ScpiDelimiter}", ct);
|
||||
await SendAsync($":SYSTem:LOCal{ScpiDelimiter}", ct); //[cite: 1]
|
||||
}
|
||||
|
||||
public virtual async Task 清除保护告警(CancellationToken ct = default)
|
||||
{
|
||||
await SendAsync($":OUTPut:PROTection:CLEar{ScpiDelimiter}", ct); //[cite: 1]
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 6. 充放电与能量统计扩展命令
|
||||
|
||||
/// <summary>
|
||||
/// 清除最近的安时(Ah)与瓦时(Wh)统计数据[cite: 1]
|
||||
/// </summary>
|
||||
public virtual async Task 清除充放电电量统计(CancellationToken ct = default)
|
||||
{
|
||||
await SendAsync($"SENSe:AHOur:RESet{ScpiDelimiter}", ct); //[cite: 1]
|
||||
await SendAsync($"SENSe:WHOur:RESet{ScpiDelimiter}", ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除仪器当前的保护状态(例如触发 OCP/OVP 被锁死后进行软件解锁)
|
||||
/// 读取当前充放电累计的安时值 (单位: Ah)[cite: 1]
|
||||
/// </summary>
|
||||
public virtual async Task 清除保护告警(CancellationToken ct = default)
|
||||
public virtual async Task<string> 查询累计安时_Ah(CancellationToken ct = default)
|
||||
{
|
||||
await SendAsync($":PROTection:CLEar{ScpiDelimiter}", ct);
|
||||
return await WriteReadAsync($"FETCh:AHOur?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取当前充放电累计的瓦时值 (单位: Wh)[cite: 1]
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询累计瓦时_Wh(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($"FETCh:WHOur?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取充放电积分持续时间 (单位: 秒)[cite: 1]
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询积分时间(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($"FETCh:ENERgy:TIME?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换设备的操作模式 (VOLTage: 电源模式, LOAD: 负载模式/放电, CURRent: 电流源)[cite: 1]
|
||||
/// </summary>
|
||||
public virtual async Task 设置操作模式(DeviceOperationMode 模式, CancellationToken ct = default)
|
||||
{
|
||||
await SendAsync($"SYSTem:OPERation:MODE {模式}{ScpiDelimiter}", ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置放电截止电压/电压下限 (单位: V,用于防止电池过放)[cite: 1]
|
||||
/// </summary>
|
||||
public virtual async Task 设置电压下限(double 电压, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":SOURce:VOLTage:LIMit:LOW {0:F2}{1}", 电压, ScpiDelimiter); //[cite: 1]
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -24,15 +24,22 @@ namespace DeviceCommand.Devices
|
||||
#region 3.1. IEEE 488.2 公共命令
|
||||
|
||||
/// <summary>
|
||||
/// 清除状态命令。清除标准事件状态寄存器和错误队列
|
||||
/// 清除状态命令。清除标准事件状态寄存器和错误队列 (*CLS)
|
||||
/// </summary>
|
||||
public virtual async Task 清除错误队列和状态字节(CancellationToken ct = default)
|
||||
{
|
||||
await SendAsync($"*CLS{ScpiDelimiter}", ct);
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询错误信息
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询错误信息(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":SYSTem:ERRor?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取电子负载设备识别字符串(制造商、产品型号、系统 SN、软件版本号)
|
||||
/// 读取电子负载设备识别字符串 (*IDN?)
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询设备标识(CancellationToken ct = default)
|
||||
{
|
||||
@@ -40,7 +47,7 @@ namespace DeviceCommand.Devices
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 复位命令。使电子负载恢复到出厂默认配置状态
|
||||
/// 复位命令。使电子负载恢复到出厂默认配置状态 (*RST)
|
||||
/// </summary>
|
||||
public virtual async Task 重置设备(CancellationToken ct = default)
|
||||
{
|
||||
@@ -48,7 +55,7 @@ namespace DeviceCommand.Devices
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取标准状态字节寄存器
|
||||
/// 读取标准状态字节寄存器 (*STB?)
|
||||
/// </summary>
|
||||
public virtual async Task<string> 读取状态字节(CancellationToken ct = default)
|
||||
{
|
||||
@@ -56,18 +63,24 @@ namespace DeviceCommand.Devices
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存当前系统参数到指定的存储单元 (单元范围依型号而定)
|
||||
/// 保存当前系统参数到指定的存储单元 (1~100)
|
||||
/// </summary>
|
||||
public virtual async Task 保存当前状态(int 单元, CancellationToken ct = default)
|
||||
{
|
||||
if (单元 < 1 || 单元 > 100)
|
||||
throw new ArgumentOutOfRangeException(nameof(单元), "存储单元位置应在 1~100 之间");
|
||||
|
||||
await SendAsync($"*SAV {单元}{ScpiDelimiter}", ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 调用指定存储单元中保存的系统参数
|
||||
/// 调用指定存储单元中保存的系统参数 (1~100)
|
||||
/// </summary>
|
||||
public virtual async Task 调用存储状态(int 单元, CancellationToken ct = default)
|
||||
{
|
||||
if (单元 < 1 || 单元 > 100)
|
||||
throw new ArgumentOutOfRangeException(nameof(单元), "存储单元位置应在 1~100 之间");
|
||||
|
||||
await SendAsync($"*RCL {单元}{ScpiDelimiter}", ct);
|
||||
}
|
||||
|
||||
@@ -76,34 +89,30 @@ namespace DeviceCommand.Devices
|
||||
#region 3.2. 电子负载模式切换及拉载开关
|
||||
|
||||
/// <summary>
|
||||
/// 控制电子负载的输入控制开关(True: 开启拉载输入, False: 关闭拉载输入)
|
||||
/// 控制电子负载的输入控制开关(INPut:STATe <bool>)
|
||||
/// </summary>
|
||||
public virtual async Task 设置DC输入(bool 开启, CancellationToken ct = default)
|
||||
{
|
||||
string 参数 = 开启 ? "ON" : "OFF";
|
||||
await SendAsync($":INPut {参数}{ScpiDelimiter}", ct);
|
||||
string 参数 = 开启 ? "1" : "0";
|
||||
await SendAsync($"INPut:STATe {参数}{ScpiDelimiter}", ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询电子负载当前的拉载开关状态 (返回 ON 或 OFF)
|
||||
/// 查询电子负载当前的拉载开关状态 (返回 0 或 1)
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询DC输入状态(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":INPut?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($"INPut:STATe?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置电子负载的基本工作模式
|
||||
/// (CC: 恒电流, CV: 恒电压, CP: 恒功率, CR: 恒电阻)
|
||||
/// 设置电子负载的基本工作模式 (INPut:FUNCtion <mode>)
|
||||
/// (支持 CC, CV, CR, CP, CCD, CVD, CRD, CPD, OCP, OPP, ESR, MPP, SWEEP 等)
|
||||
/// </summary>
|
||||
public virtual async Task 设置负载模式(string 模式, CancellationToken ct = default)
|
||||
{
|
||||
// 转换为大写以确保设备命令解析兼容
|
||||
string modeUpper = 模式.ToUpper();
|
||||
if (modeUpper != "CC" && modeUpper != "CV" && modeUpper != "CP" && modeUpper != "CR")
|
||||
throw new ArgumentException("工作模式只能为 CC, CV, CP, 或 CR");
|
||||
|
||||
await SendAsync($":MODE {modeUpper}{ScpiDelimiter}", ct);
|
||||
await SendAsync($"INPut:FUNCtion {modeUpper}{ScpiDelimiter}", ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -111,79 +120,79 @@ namespace DeviceCommand.Devices
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询负载模式(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":MODE?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($"INPut:FUNCtion?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 3.3. 负载参数设置 (CC / CV / CP / CR)
|
||||
#region 3.3. 负载参数设置 (CC / CV / CP / CR 定态大量程)
|
||||
|
||||
/// <summary>
|
||||
/// 设定恒电流模式(CC)下的拉载电流目标值 (单位: A)
|
||||
/// 设定恒电流模式(CC)大量程下的拉载电流目标值 (单位: A)
|
||||
/// </summary>
|
||||
public virtual async Task 设置恒电流CC(double 电流, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":CURRent {0:F4}{1}", 电流, ScpiDelimiter);
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, "STATic:CC:HIGH:LEVel {0:F4}{1}", 电流, ScpiDelimiter);
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询恒电流模式下设定的拉载电流值
|
||||
/// 查询恒电流模式大量程下设定的拉载电流值
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询恒电流CC设定(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":CURRent?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($"STATic:CC:HIGH:LEVel?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设定恒电压模式(CV)下的拉载电压目标值 (单位: V)
|
||||
/// 设定恒电压模式(CV)大量程下的拉载电压目标值 (单位: V)
|
||||
/// </summary>
|
||||
public virtual async Task 设置恒电压CV(double 电压, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":VOLTage {0:F3}{1}", 电压, ScpiDelimiter);
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, "STATic:CV:HIGH:LEVel {0:F3}{1}", 电压, ScpiDelimiter);
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询恒电压模式下设定的拉载电压值
|
||||
/// 查询恒电压模式大量程下设定的拉载电压值
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询恒电压CV设定(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":VOLTage?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($"STATic:CV:HIGH:LEVel?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设定恒功率模式(CP)下的拉载功率目标值 (单位: W)
|
||||
/// 设定恒功率模式(CP)大量程下的拉载功率目标值 (单位: W)
|
||||
/// </summary>
|
||||
public virtual async Task 设置恒功率CP(double 功率, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":POWer {0:F3}{1}", 功率, ScpiDelimiter);
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, "STATic:CP:HIGH:LEVel {0:F3}{1}", 功率, ScpiDelimiter);
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询恒功率模式下设定的拉载功率值
|
||||
/// 查询恒功率模式大量程下设定的拉载功率值
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询恒功率CP设定(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":POWer?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($"STATic:CP:HIGH:LEVel?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设定恒电阻模式(CR)下的等效拉载电阻阻值 (单位: Ω)
|
||||
/// 设定恒电阻模式(CR)大量程下的等效拉载电阻阻值 (单位: Ω)
|
||||
/// </summary>
|
||||
public virtual async Task 设置恒电阻CR(double 电阻, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":RESistance {0:F4}{1}", 电阻, ScpiDelimiter);
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, "STATic:CR:HIGH:LEVel {0:F4}{1}", 电阻, ScpiDelimiter);
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询恒电阻模式下设定的拉载电阻值
|
||||
/// 查询恒电阻模式大量程下设定的拉载电阻值
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询恒电阻CR设定(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":RESistance?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($"STATic:CR:HIGH:LEVel?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -196,7 +205,7 @@ namespace DeviceCommand.Devices
|
||||
[Monitorable("高压直流负载电压")]
|
||||
public virtual async Task<string> 查询实际电压(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":MEASure:VOLTage?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($"MEASure:VOLTage?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -205,7 +214,7 @@ namespace DeviceCommand.Devices
|
||||
[Monitorable("高压直流负载电流")]
|
||||
public virtual async Task<string> 查询实际电流(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":MEASure:CURRent?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($"MEASure:CURRent?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -214,15 +223,7 @@ namespace DeviceCommand.Devices
|
||||
[Monitorable("高压直流负载功率")]
|
||||
public virtual async Task<string> 查询实际功率(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":MEASure:POWer?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 一键回读当前负载测得的电压、电流和功率的组合数组数据
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询电压电流功率数组(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":MEASure:VAP?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($"MEASure:POWer?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -230,29 +231,29 @@ namespace DeviceCommand.Devices
|
||||
#region 3.5. 保护限制参数设置
|
||||
|
||||
/// <summary>
|
||||
/// 设置电子负载的过流保护(OCP)报警值 (单位: A)
|
||||
/// 设置电子负载的电流软保护阈值 (单位: A, 设置为 0 表示关闭)
|
||||
/// </summary>
|
||||
public virtual async Task 设置过流保护值_OCP(double 电流, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":PROTection:CURRent {0:F3}{1}", 电流, ScpiDelimiter);
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, "INPut:CURRent:PROTection {0:F3}{1}", 电流, ScpiDelimiter);
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置电子负载的过功率保护(OPP)报警值 (单位: W)
|
||||
/// 设置电子负载的功率软保护阈值 (单位: W, 设置为 0 表示关闭)
|
||||
/// </summary>
|
||||
public virtual async Task 设置过功率保护值_OPP(double 功率, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":PROTection:POWer {0:F3}{1}", 功率, ScpiDelimiter);
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, "INPut:POWer:PROTection {0:F3}{1}", 功率, ScpiDelimiter);
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置电子负载的过压保护(OVP)报警值 (单位: V)
|
||||
/// 设置电子负载的电压软保护阈值 (单位: V, 设置为 0 表示关闭)
|
||||
/// </summary>
|
||||
public virtual async Task 设置过压保护值_OVP(double 电压, CancellationToken ct = default)
|
||||
{
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, ":PROTection:VOLTage {0:F3}{1}", 电压, ScpiDelimiter);
|
||||
string cmd = string.Format(CultureInfo.InvariantCulture, "INPut:VOLTage:PROTection {0:F3}{1}", 电压, ScpiDelimiter);
|
||||
await SendAsync(cmd, ct);
|
||||
}
|
||||
|
||||
@@ -261,37 +262,290 @@ namespace DeviceCommand.Devices
|
||||
#region 3.6. 系统控制及报警清除
|
||||
|
||||
/// <summary>
|
||||
/// 读取仪器的出错记录记录 (当系统产生告警或指令解析异常时读取)
|
||||
/// 读取负载报警/事件寄存器信息 (MEASure:EVENT?)
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询错误信息(CancellationToken ct = default)
|
||||
public virtual async Task<string> 查询报警事件信息(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":SYSTem:ERRor?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
return await WriteReadAsync($"MEASure:EVENT?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换电子负载到本地面板操作状态 (前面板按键解锁)
|
||||
/// </summary>
|
||||
public virtual async Task 切换本地控制模式(CancellationToken ct = default)
|
||||
{
|
||||
await SendAsync($":SYSTem:LOCal{ScpiDelimiter}", ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换电子负载到远程计算机操作状态 (前面板按键锁定)
|
||||
/// </summary>
|
||||
public virtual async Task 切换远程控制模式(CancellationToken ct = default)
|
||||
{
|
||||
await SendAsync($":SYSTem:REMote{ScpiDelimiter}", ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除负载当前的软件过流/过功率等保护(Protection)锁定触发状态
|
||||
/// 清除负载当前的保护触发锁定状态 (INPut:CLearPROTect)
|
||||
/// </summary>
|
||||
public virtual async Task 清除保护告警(CancellationToken ct = default)
|
||||
{
|
||||
await SendAsync($":PROTection:CLEar{ScpiDelimiter}", ct);
|
||||
await SendAsync($"INPut:CLearPROTect{ScpiDelimiter}", ct);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 3.7. 手册第 112~124 页中的原子控制命令
|
||||
|
||||
#region 组合测试 (COMBination:*)
|
||||
|
||||
public virtual async Task 设置组合量程_CVCC(int 量程, CancellationToken ct = default)
|
||||
=> await SendAsync($"COMBination:CVCC:RANGE {量程}{ScpiDelimiter}", ct);
|
||||
|
||||
public virtual async Task 设置恒压速率_CVCC(int 速率, CancellationToken ct = default)
|
||||
=> await SendAsync($"COMBination:CVCC:HIGH:RATE {速率}{ScpiDelimiter}", ct);
|
||||
|
||||
public virtual async Task 设置恒压大量程电压_CVCC(double 电压, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "COMBination:CVCC:HIGH:LEVel {0:F3}{1}", 电压, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置限定电流_CVCC(double 电流, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "COMBination:CVCC:CLIMit {0:F3}{1}", 电流, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置组合量程_CRCC(int 量程, CancellationToken ct = default)
|
||||
=> await SendAsync($"COMBination:CRCC:RANGE {量程}{ScpiDelimiter}", ct);
|
||||
|
||||
public virtual async Task 设置恒阻小量程电阻_CRCC(double 电阻, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "COMBination:CRCC:LOW:LEVel {0:F4}{1}", 电阻, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置限定电流_CRCC(double 电流, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "COMBination:CRCC:CLIMit {0:F3}{1}", 电流, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置上升斜率_CRCC(double 斜率, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "COMBination:CRCC:LOW:SLEWRate:RAIse {0:F1}{1}", 斜率, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置下降斜率_CRCC(double 斜率, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "COMBination:CRCC:LOW:SLEWRate:FALL {0:F1}{1}", 斜率, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置组合量程_CPCC(int 量程, CancellationToken ct = default)
|
||||
=> await SendAsync($"COMBination:CPCC:RANGE {量程}{ScpiDelimiter}", ct);
|
||||
|
||||
public virtual async Task 设置恒功率小量程功率_CPCC(double 功率, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "COMBination:CPCC:LOW:LEVel {0:F3}{1}", 功率, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置限定电流_CPCC(double 电流, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "COMBination:CPCC:CLIMit {0:F3}{1}", 电流, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置组合量程_CVCR(int 量程, CancellationToken ct = default)
|
||||
=> await SendAsync($"COMBination:CVCR:RANGE {量程}{ScpiDelimiter}", ct);
|
||||
|
||||
public virtual async Task 设置恒压大量程电压_CVCR(double 电压, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "COMBination:CVCR:HIGH:LEVel {0:F3}{1}", 电压, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置限定电阻_CVCR(double 电阻, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "COMBination:CVCR:CLIMit {0:F4}{1}", 电阻, ScpiDelimiter), ct);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 瞬态测试 (DYNAmic:*)
|
||||
|
||||
public virtual async Task 设置瞬态运行方式_CC(int 模式, CancellationToken ct = default)
|
||||
=> await SendAsync($"DYNAmic:CC:MODe {模式}{ScpiDelimiter}", ct); // 0-连续, 1-单次, 2-A/B
|
||||
|
||||
public virtual async Task 设置瞬态量程_CC(int 量程, CancellationToken ct = default)
|
||||
=> await SendAsync($"DYNAmic:CC:RANGE {量程}{ScpiDelimiter}", ct);
|
||||
|
||||
public virtual async Task 设置瞬态主值电流_CC(double 电流, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DYNAmic:CC:HIGH:LEVel:MAIN {0:F4}{1}", 电流, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置瞬态瞬态值电流_CC(double 电流, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DYNAmic:CC:HIGH:LEVel:TRANSient {0:F4}{1}", 电流, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置瞬态上升斜率_CC(double 斜率, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DYNAmic:CC:HIGH:SLEWRate:RAIse {0:F1}{1}", 斜率, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置瞬态下降斜率_CC(double 斜率, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DYNAmic:CC:HIGH:SLEWRate:FALL {0:F1}{1}", 斜率, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置瞬态主值脉宽_CC(double 时间_ms, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DYNAmic:CC:WIDth:MAIN {0:F1}{1}", 时间_ms, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置瞬态瞬态脉宽_CC(double 时间_ms, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DYNAmic:CC:WIDth:TRANSient {0:F1}{1}", 时间_ms, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置瞬态运行方式_CV(int 模式, CancellationToken ct = default)
|
||||
=> await SendAsync($"DYNAmic:CV:MODe {模式}{ScpiDelimiter}", ct);
|
||||
|
||||
public virtual async Task 设置瞬态量程_CV(int 量程, CancellationToken ct = default)
|
||||
=> await SendAsync($"DYNAmic:CV:RANGE {量程}{ScpiDelimiter}", ct);
|
||||
|
||||
public virtual async Task 设置瞬态主值电压_CV(double 电压, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DYNAmic:CV:HIGH:LEVel:MAIN {0:F3}{1}", 电压, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置瞬态瞬态值电压_CV(double 电压, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DYNAmic:CV:HIGH:LEVel:TRANSient {0:F3}{1}", 电压, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置瞬态主值脉宽_CV(double 时间_ms, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DYNAmic:CV:WIDth:MAIN {0:F1}{1}", 时间_ms, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置瞬态瞬态脉宽_CV(double 时间_ms, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DYNAmic:CV:WIDth:TRANSient {0:F1}{1}", 时间_ms, ScpiDelimiter), ct);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 充放电测试 (DISCHarge:* / CHARge:*)
|
||||
|
||||
public virtual async Task 设置放电电流(double 电流, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DISCHarge:CURRent {0:F3}{1}", 电流, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置放电终止电压(double 电压, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DISCHarge:VOLTage {0:F3}{1}", 电压, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置放电终止时间(double 时间_s, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DISCHarge:TIMe {0:F0}{1}", 时间_s, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置放电终止容量(double 容量_Ah, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "DISCHarge:CAPacity {0:F3}{1}", 容量_Ah, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task<string> 查询放电实时时间(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"DISCHarge:ECHO:TIMe?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
public virtual async Task<string> 查询放电实时容量(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"DISCHarge:ECHo:CAPacity?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
public virtual async Task 设置充电电流(double 电流, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "CHARge:CURRent {0:F3}{1}", 电流, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置充电电压(double 电压, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "CHARge:VOLTage {0:F3}{1}", 电压, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置充电恒压时间(int 时间_s, CancellationToken ct = default)
|
||||
=> await SendAsync($"CHARge:TIMe {时间_s}{ScpiDelimiter}", ct);
|
||||
|
||||
#endregion
|
||||
|
||||
#region OCP / OPP 保护扫描测试 (OCP:* / OPP:*)
|
||||
|
||||
public virtual async Task 设置OCP初始电流(double 电流, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "OCP:BCURrent {0:F3}{1}", 电流, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置OCP步进电流(double 电流, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "OCP:SCURrent {0:F3}{1}", 电流, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置OCP单步时间(double 时间_s, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "OCP:Time {0:F1}{1}", 时间_s, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置OCP终止电压(double 电压, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "OCP:EVOLtage {0:F3}{1}", 电压, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task<string> 查询OCP状态(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"OCP:STAtus?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
public virtual async Task<string> 读取OCP结果电流(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"OCP:RCURrent?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
public virtual async Task 设置OPP初始功率(double 功率, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "OPP:BPOWer {0:F3}{1}", 功率, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置OPP步进功率(double 功率, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "OPP:SPOWer {0:F3}{1}", 功率, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置OPP单步时间(double 时间_s, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "OPP:TIME {0:F1}{1}", 时间_s, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置OPP终止电压(double 电压, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "OPP:EVOLtage {0:F3}{1}", 电压, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task<string> 查询OPP状态(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"OPP:STAtus?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
public virtual async Task<string> 读取OPP结果功率(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"OPP:RPOWer?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扫频 SWEEP 与 波形拉载 WAVE (SWEEP:* / WAVE:*)
|
||||
|
||||
public virtual async Task 设置扫频最小电流(double 电流, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "SWEEP:TCURrent {0:F3}{1}", 电流, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置扫频最大电流(double 电流, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "SWEEP:MCURrent {0:F3}{1}", 电流, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置扫频起始频率(double 频率_Hz, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "SWEEP:SFRequency {0:F1}{1}", 频率_Hz, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置扫频结束频率(double 频率_Hz, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "SWEEP:EFRequency {0:F1}{1}", 频率_Hz, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置扫频单步时间(double 时间_ms, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "SWEEP:STPTime {0:F1}{1}", 时间_ms, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置扫频占空比(double 占空比, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "SWEEP:DUTYcycle {0:F1}{1}", 占空比, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task<string> 读取扫频当前运行频率(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"SWEEP:CFRequency?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
public virtual async Task<string> 读取扫频测试结果(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"SWEEP:RESult?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
public virtual async Task 设置波形量程(int 量程, CancellationToken ct = default)
|
||||
=> await SendAsync($"WAVE:RANGe {量程}{ScpiDelimiter}", ct);
|
||||
|
||||
public virtual async Task 设置波形类型(int 类型, CancellationToken ct = default)
|
||||
=> await SendAsync($"WAVE:TYPe {类型}{ScpiDelimiter}", ct); // 0-正弦波, 1-方波, 2-三角波, 3-锯齿波, 4-自定义
|
||||
|
||||
public virtual async Task 设置波形频率(double 频率_Hz, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "WAVE:FREQuency {0:F1}{1}", 频率_Hz, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置波形幅值(double 幅值, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "WAVE:SETValue {0:F3}{1}", 幅值, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置波形时间(double 时间_ms, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "WAVE:TIMe {0:F1}{1}", 时间_ms, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置波形叠加值(double 叠加值, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "WAVE:BVALue {0:F3}{1}", 叠加值, ScpiDelimiter), ct);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 内阻测试 ESR (ESR:*)
|
||||
|
||||
public virtual async Task 设置ESR带载量程(int 量程, CancellationToken ct = default)
|
||||
=> await SendAsync($"ESR:LOADRange {量程}{ScpiDelimiter}", ct);
|
||||
|
||||
public virtual async Task 设置ESR大量程带载电流(double 电流, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "ESR:CURRenthigh {0:F3}{1}", 电流, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置ESR测量方法(int 方法, CancellationToken ct = default)
|
||||
=> await SendAsync($"ESR:MODE {方法}{ScpiDelimiter}", ct); // 0-方波平均法, 1-单脉冲法
|
||||
|
||||
public virtual async Task 设置ESR采样量程(int 量程, CancellationToken ct = default)
|
||||
=> await SendAsync($"ESR:MEASurerange {量程}{ScpiDelimiter}", ct); // 0-1000mV, 1-100mV, 2-10mV
|
||||
|
||||
public virtual async Task<string> 查询ESR状态(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"ESR:STAtus?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
public virtual async Task<string> 读取ESR结果(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"ESR:RESult?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
#endregion
|
||||
|
||||
#region MPPT 测试 (MPP:*)
|
||||
|
||||
public virtual async Task 设置MPPT步进电压(double 电压_V, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "MPP:BVOLtage {0:F3}{1}", 电压_V, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置MPPT步进时间(double 时间_s, CancellationToken ct = default)
|
||||
=> await SendAsync(string.Format(CultureInfo.InvariantCulture, "MPP:TIME {0:F1}{1}", 时间_s, ScpiDelimiter), ct);
|
||||
|
||||
public virtual async Task 设置MPPT模式(int 模式, CancellationToken ct = default)
|
||||
=> await SendAsync($"MPP:MODE {模式}{ScpiDelimiter}", ct); // 0-扫描模式, 1-跟踪模式
|
||||
|
||||
public virtual async Task<string> 查询MPPT状态(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"MPP:STATus?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
public virtual async Task<string> 读取MPPT最大功率(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"MPP:MPOWer?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
public virtual async Task<string> 读取MPPT最大功率电压(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"MPP:MVOLtage?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
public virtual async Task<string> 读取MPPT最大功率电流(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"MPP:MCURrent?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
public virtual async Task<string> 读取MPPT开路电压(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"MPP:OVOLtage?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
public virtual async Task<string> 读取MPPT短路电流(CancellationToken ct = default)
|
||||
=> await WriteReadAsync($"MPP:SCURrent?{ScpiDelimiter}", ScpiDelimiter, ct);
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,13 @@ namespace DeviceCommand.Devices
|
||||
{
|
||||
await SendAsync($"*CLS{ScpiDelimiter}", ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询错误信息
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询错误信息(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":SYSTem:ERRor?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
/// <summary>
|
||||
/// 读取示波器识别字符串(制造商、型号、序列号、固件版本)
|
||||
/// </summary>
|
||||
|
||||
@@ -31,7 +31,13 @@ namespace DeviceCommand.Devices
|
||||
{
|
||||
await SendAsync($"*CLS{ScpiDelimiter}", ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询错误信息
|
||||
/// </summary>
|
||||
public virtual async Task<string> 查询错误信息(CancellationToken ct = default)
|
||||
{
|
||||
return await WriteReadAsync($":SYSTem:ERRor?{ScpiDelimiter}", ScpiDelimiter, ct); //[cite: 1]
|
||||
}
|
||||
/// <summary>
|
||||
/// 读取功率分析仪识别字符串(制造商、产品型号、系统 SN、软件版本号)
|
||||
/// </summary>
|
||||
|
||||
@@ -92,9 +92,9 @@ namespace DeviceEditModule.ViewModels
|
||||
set => SetProperty(ref _currentLimit, value);
|
||||
}
|
||||
|
||||
private string _selectedMode = "AC";
|
||||
private PowerCouplingMode _selectedMode = PowerCouplingMode.AC;
|
||||
/// <summary>待设置的电源工作模式:AC / DC / ACDC。</summary>
|
||||
public string SelectedMode
|
||||
public PowerCouplingMode SelectedMode
|
||||
{
|
||||
get => _selectedMode;
|
||||
set => SetProperty(ref _selectedMode, value);
|
||||
|
||||
@@ -155,8 +155,7 @@ namespace DeviceEditModule.ViewModels
|
||||
public ICommand SetOcpCommand { get; }
|
||||
public ICommand SetOppCommand { get; }
|
||||
public ICommand ClearAlarmCommand { get; }
|
||||
public ICommand SetRemoteModeCommand { get; }
|
||||
public ICommand SetLocalModeCommand { get; }
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -174,8 +173,7 @@ namespace DeviceEditModule.ViewModels
|
||||
SetOcpCommand = new DelegateCommand(async () => await Exec(async () => { await _device!.设置过流保护值_OCP(OcpValue, Ct()); AppendLog($"OCP已设为 {OcpValue} A"); }));
|
||||
SetOppCommand = new DelegateCommand(async () => await Exec(async () => { await _device!.设置过功率保护值_OPP(OppValue, Ct()); AppendLog($"OPP已设为 {OppValue} W"); }));
|
||||
ClearAlarmCommand = new DelegateCommand(async () => await Exec(async () => { await _device!.清除保护告警(Ct()); AppendLog("保护告警已清除"); }));
|
||||
SetRemoteModeCommand = new DelegateCommand(async () => await Exec(async () => { await _device!.切换远程控制模式(Ct()); AppendLog("已切换到远程控制模式"); }));
|
||||
SetLocalModeCommand = new DelegateCommand(async () => await Exec(async () => { await _device!.切换本地控制模式(Ct()); AppendLog("已切换到本地控制模式"); }));
|
||||
|
||||
|
||||
SetLoadValueCommand = new DelegateCommand(async () => await Exec(async () =>
|
||||
{
|
||||
|
||||
@@ -100,14 +100,15 @@
|
||||
<!-- 工作模式 -->
|
||||
<StackPanel Orientation="Horizontal" Margin="0,4">
|
||||
<TextBlock Text="工作模式" Style="{StaticResource ParamLabel}"/>
|
||||
<ComboBox Width="90" Height="32" Margin="4,0"
|
||||
<ComboBox xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
Width="90" Height="32" Margin="4,0"
|
||||
materialDesign:HintAssist.Hint=""
|
||||
SelectedItem="{Binding SelectedMode}"
|
||||
VerticalContentAlignment="Center" FontSize="12">
|
||||
<ComboBoxItem Content="CC"/>
|
||||
<ComboBoxItem Content="CV"/>
|
||||
<ComboBoxItem Content="CP"/>
|
||||
<ComboBoxItem Content="CR"/>
|
||||
<sys:String>CC</sys:String>
|
||||
<sys:String>CV</sys:String>
|
||||
<sys:String>CP</sys:String>
|
||||
<sys:String>CR</sys:String>
|
||||
</ComboBox>
|
||||
<Button Content="设置" Command="{Binding SetModeCommand}"
|
||||
Style="{StaticResource CmdBtn}"/>
|
||||
@@ -115,13 +116,13 @@
|
||||
Style="{StaticResource CmdBtn}"/>
|
||||
</StackPanel>
|
||||
<!-- 远程/本地 -->
|
||||
<StackPanel Orientation="Horizontal" Margin="0,4">
|
||||
<!--<StackPanel Orientation="Horizontal" Margin="0,4">
|
||||
<TextBlock Text="控制模式" Style="{StaticResource ParamLabel}"/>
|
||||
<Button Content="远程控制" Command="{Binding SetRemoteModeCommand}"
|
||||
Style="{StaticResource CmdBtn}"/>
|
||||
<Button Content="本地控制" Command="{Binding SetLocalModeCommand}"
|
||||
Style="{StaticResource CmdBtn}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>-->
|
||||
<!-- 系统操作 -->
|
||||
<StackPanel Orientation="Horizontal" Margin="0,4">
|
||||
<TextBlock Text="系统操作" Style="{StaticResource ParamLabel}"/>
|
||||
|
||||
@@ -13,7 +13,9 @@ namespace UIShare.Converters // 确保命名空间跟你项目一致
|
||||
if (double.TryParse(parameter.ToString(), out double targetWidth))
|
||||
{
|
||||
// 如果实际宽度 小于 设定的阈值(比如600),返回 True
|
||||
return actualWidth < targetWidth;
|
||||
//return actualWidth < targetWidth;
|
||||
//工控机屏幕较大直接给1000
|
||||
return actualWidth < 1000;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user