using Common.Attributes;
using DeviceCommand.Base;
using Model.Models;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceCommand.Devices
{
///
/// ANEVH80 电子负载(一对三控制),基于 TCP 通信,使用 SCPI 指令集。
/// 用于被测产品的放电/带载测试,可模拟真实负载工况。
///
[ACPCommand]
public class ANEVH80 : Tcp
{
// SCPI 指令默认使用 \n 作为结束符
private const string ScpiDelimiter = "\n";
///
/// 构造函数,初始化 TCP 连接配置。
///
/// TCP 连接配置(IP、端口等)
public ANEVH80(TcpConfig config) : base(config)
{
}
///
/// 占位符方法,预留后续负载控制操作(如设置负载模式、设置电流等)。
/// 当前实现为查询频率测量值。
///
/// 异步取消令牌
/// 查询到的频率值,解析失败返回 0.0
public virtual async Task 占位符(CancellationToken ct = default)
{
string resp = await WriteReadAsync($"MEAS:FREQ?{ScpiDelimiter}", ScpiDelimiter, ct);
return double.TryParse(resp, NumberStyles.Any, CultureInfo.InvariantCulture, out double val) ? val : 0.0;
}
}
}