using System.Collections.Generic; namespace APS7100TestTool.Libraries { /// /// SCPI 命令信息 /// public class ScpiCommandInfo { public string Category { get; set; } = string.Empty; public string Command { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; public bool IsQuery { get; set; } public string? Example { get; set; } public string DisplayText => $"{Command} - {Description}"; public string FullDescription => IsQuery ? $"📖 查询命令\n命令: {Command}\n说明: {Description}" + (string.IsNullOrEmpty(Example) ? "" : $"\n示例: {Example}") : $"⚙️ 设置命令\n命令: {Command}\n说明: {Description}" + (string.IsNullOrEmpty(Example) ? "" : $"\n示例: {Example}"); } /// /// APS7100 SCPI 命令库 /// /// ⚠ 重要说明: /// APS7100 使用完整的、层级严格的 SCPI 命令树 /// 核心根节点:MEAS / SOUR / OUTP / STAT / DATA /// /// 命令特点: /// 1. 几乎都带二级/三级节点 /// 2. 不支持简写的无子节点查询(如 OUTP? 不行,必须 OUTP:STAT?) /// 3. 测量命令必须走 SCALar 路径 /// public static class ScpiCommandLibrary { public static List GetAllCommands() { return new List { // ==================== IEEE 488.2 标准命令 ==================== new ScpiCommandInfo { Category = "IEEE 488.2", Command = "*IDN?", Description = "查询设备识别信息", IsQuery = true, Example = "返回: GWINSTEK,APS-7100,SN123456,V1.00" }, new ScpiCommandInfo { Category = "IEEE 488.2", Command = "*RST", Description = "重置设备到出厂状态", IsQuery = false, Example = null }, new ScpiCommandInfo { Category = "IEEE 488.2", Command = "*CLS", Description = "清除状态寄存器", IsQuery = false, Example = null }, new ScpiCommandInfo { Category = "IEEE 488.2", Command = "*TST?", Description = "设备自检", IsQuery = true, Example = "返回: 0(正常) 或错误码" }, new ScpiCommandInfo { Category = "IEEE 488.2", Command = "*OPC?", Description = "查询操作完成状态", IsQuery = true, Example = "返回: 1(完成)" }, new ScpiCommandInfo { Category = "IEEE 488.2", Command = "*WAI", Description = "等待所有挂起操作完成", IsQuery = false, Example = null }, new ScpiCommandInfo { Category = "IEEE 488.2", Command = "*TRG", Description = "触发设备", IsQuery = false, Example = null }, new ScpiCommandInfo { Category = "IEEE 488.2", Command = "*SAV 0", Description = "保存设置到位置 0", IsQuery = false, Example = "*SAV 0 ~ *SAV 9" }, new ScpiCommandInfo { Category = "IEEE 488.2", Command = "*RCL 0", Description = "从位置 0 恢复设置", IsQuery = false, Example = "*RCL 0 ~ *RCL 9" }, new ScpiCommandInfo { Category = "IEEE 488.2", Command = "*ESR?", Description = "查询事件状态寄存器", IsQuery = true, Example = "返回: 0-255" }, new ScpiCommandInfo { Category = "IEEE 488.2", Command = "*ESE", Description = "设置事件状态使能寄存器", IsQuery = false, Example = "*ESE 32" }, new ScpiCommandInfo { Category = "IEEE 488.2", Command = "*STB?", Description = "查询状态字节", IsQuery = true, Example = "返回: 0-255" }, new ScpiCommandInfo { Category = "IEEE 488.2", Command = "*SRE", Description = "设置服务请求使能", IsQuery = false, Example = "*SRE 32" }, // ==================== SYSTEM 系统命令 ==================== new ScpiCommandInfo { Category = "系统命令", Command = "SYST:ERR?", Description = "查询错误队列", IsQuery = true, Example = "返回: 0,\"No error\"" }, new ScpiCommandInfo { Category = "系统命令", Command = "SYST:VERS?", Description = "查询 SCPI 版本", IsQuery = true, Example = "返回: 1999.0" }, new ScpiCommandInfo { Category = "系统命令", Command = "SYST:REM", Description = "进入远程控制模式", IsQuery = false, Example = "⚠ 已经是远程模式时再次发送会报错!\n程序会自动跟踪状态避免重复发送" }, new ScpiCommandInfo { Category = "系统命令", Command = "SYST:COMM:RLST LOCAL", Description = "返回本地控制模式(面板有效)", IsQuery = false, Example = null }, new ScpiCommandInfo { Category = "系统命令", Command = "SYST:KLOC ON", Description = "锁定前面板按键", IsQuery = false, Example = "⚠ APS7100 使用 KLOC,不是 RWLOCK" }, new ScpiCommandInfo { Category = "系统命令", Command = "SYST:KLOC OFF", Description = "解锁前面板按键", IsQuery = false, Example = "⚠ APS7100 使用 KLOC,不是 RWLOCK" }, // ==================== OUTPUT 输出控制 ==================== new ScpiCommandInfo { Category = "输出控制", Command = "OUTP:STAT ON", Description = "开启输出", IsQuery = false, Example = "⚠ 必须使用 OUTP:STAT,不支持 OUTP ON" }, new ScpiCommandInfo { Category = "输出控制", Command = "OUTP:STAT OFF", Description = "关闭输出", IsQuery = false, Example = "⚠ 必须使用 OUTP:STAT,不支持 OUTP OFF" }, new ScpiCommandInfo { Category = "输出控制", Command = "OUTP:STAT?", Description = "查询输出状态", IsQuery = true, Example = "返回: 0(关) 或 1(开)\n⚠ 不支持 OUTP?" }, new ScpiCommandInfo { Category = "输出控制", Command = "OUTP:PROT:CLE", Description = "清除输出保护状态", IsQuery = false, Example = null }, // ==================== SOURCE 电压设置 ==================== new ScpiCommandInfo { Category = "电压设置", Command = "SOUR:VOLT 220", Description = "设置输出电压为 220V", IsQuery = false, Example = "范围视量程而定" }, new ScpiCommandInfo { Category = "电压设置", Command = "SOUR:VOLT?", Description = "查询电压设定值", IsQuery = true, Example = "返回: 220.0" }, new ScpiCommandInfo { Category = "电压设置", Command = "SOUR:VOLT:RANG R155", Description = "设置电压量程 0-155V", IsQuery = false, Example = "⚠ APS7100 量程: R155/R310/R600/AUTO" }, new ScpiCommandInfo { Category = "电压设置", Command = "SOUR:VOLT:RANG R310", Description = "设置电压量程 0-310V", IsQuery = false, Example = "⚠ 不支持 LOW/HIGH" }, new ScpiCommandInfo { Category = "电压设置", Command = "SOUR:VOLT:RANG R600", Description = "设置电压量程 0-600V", IsQuery = false, Example = "部分型号支持" }, new ScpiCommandInfo { Category = "电压设置", Command = "SOUR:VOLT:RANG AUTO", Description = "设置电压量程为自动", IsQuery = false, Example = null }, new ScpiCommandInfo { Category = "电压设置", Command = "SOUR:VOLT:RANG?", Description = "查询电压量程", IsQuery = true, Example = "返回: R155/R310/R600/AUTO" }, // ==================== SOURCE 频率设置 ==================== new ScpiCommandInfo { Category = "频率设置", Command = "SOUR:FREQ 50", Description = "设置输出频率为 50Hz", IsQuery = false, Example = "常用: 50/60/400 Hz" }, new ScpiCommandInfo { Category = "频率设置", Command = "SOUR:FREQ 60", Description = "设置输出频率为 60Hz", IsQuery = false, Example = null }, new ScpiCommandInfo { Category = "频率设置", Command = "SOUR:FREQ 400", Description = "设置输出频率为 400Hz (航空标准)", IsQuery = false, Example = null }, new ScpiCommandInfo { Category = "频率设置", Command = "SOUR:FREQ?", Description = "查询频率设定值", IsQuery = true, Example = "返回: 50.0" }, // ==================== SOURCE 相位设置 ==================== new ScpiCommandInfo { Category = "相位设置", Command = "SOUR:PHAS 0", Description = "设置输出相位为 0°", IsQuery = false, Example = "用于多相或并机控制" }, new ScpiCommandInfo { Category = "相位设置", Command = "SOUR:PHAS?", Description = "查询相位设定值", IsQuery = true, Example = "返回: 0.0" }, // ==================== SOURCE 电流限制 ==================== new ScpiCommandInfo { Category = "电流限制", Command = "SOUR:CURR:LIM:RMS 5", Description = "设置电流限值为 5A (RMS)", IsQuery = false, Example = "⚠ APS7100 只有电流限制,没有电流设定\n❌ SOUR:CURR 5 不可用" }, new ScpiCommandInfo { Category = "电流限制", Command = "SOUR:CURR:LIM:RMS?", Description = "查询电流限值 (RMS)", IsQuery = true, Example = "返回: 5.0\n⚠ 必须使用 SOUR:CURR:LIM:RMS?\n❌ SOUR:CURR? 不可用" }, // ==================== MEASURE 测量命令 ==================== new ScpiCommandInfo { Category = "测量命令", Command = "MEAS:SCAL:VOLT?", Description = "测量实际输出电压 (V RMS)", IsQuery = true, Example = "返回: 220.5\n⚠ 必须走 SCALar 路径\n❌ MEAS:VOLT? 不可用" }, new ScpiCommandInfo { Category = "测量命令", Command = "MEAS:SCAL:CURR?", Description = "测量实际输出电流 (A RMS)", IsQuery = true, Example = "返回: 2.345\n⚠ 必须走 SCALar 路径\n❌ MEAS:CURR? 不可用" }, new ScpiCommandInfo { Category = "测量命令", Command = "MEAS:SCAL:FREQ?", Description = "测量实际输出频率 (Hz)", IsQuery = true, Example = "返回: 50.01\n⚠ 必须走 SCALar 路径\n❌ MEAS:FREQ? 不可用" }, new ScpiCommandInfo { Category = "测量命令", Command = "MEAS:SCAL:POW:AC:REAL?", Description = "测量有功功率 P (W)", IsQuery = true, Example = "返回: 517.0\n⚠ 必须使用完整路径\n❌ MEAS:POW? 不可用" }, new ScpiCommandInfo { Category = "测量命令", Command = "MEAS:SCAL:POW:AC:APP?", Description = "测量视在功率 S (VA)", IsQuery = true, Example = "返回: 544.0" }, new ScpiCommandInfo { Category = "测量命令", Command = "MEAS:SCAL:POW:AC:PFAC?", Description = "测量功率因数 PF", IsQuery = true, Example = "返回: 0.95\n⚠ 使用 PFAC,不是 PF\n❌ MEAS:PF? 不可用" }, // ==================== INITIATE 触发命令 ==================== new ScpiCommandInfo { Category = "触发命令", Command = "INIT:IMM", Description = "立即执行(启动 Sequence/Simulation)", IsQuery = false, Example = "用于启动序列、模拟、瞬态测试" }, new ScpiCommandInfo { Category = "触发命令", Command = "INIT:IMM:TRAN", Description = "立即执行瞬态", IsQuery = false, Example = null }, // ==================== STATUS 状态命令 ==================== new ScpiCommandInfo { Category = "状态命令", Command = "STAT:OPER?", Description = "查询操作状态寄存器", IsQuery = true, Example = "返回: 状态位掩码" }, new ScpiCommandInfo { Category = "状态命令", Command = "STAT:QUES?", Description = "查询可疑状态寄存器", IsQuery = true, Example = "返回: 状态位掩码" }, // ==================== DATA/TRACE 序列命令 ==================== new ScpiCommandInfo { Category = "序列命令", Command = "DATA:SEQ:CLE", Description = "清除序列数据", IsQuery = false, Example = "用于电压跌落、频率扫变、IEC测试" }, new ScpiCommandInfo { Category = "序列命令", Command = "DATA:SEQ:STOR 0", Description = "存储序列到位置 0", IsQuery = false, Example = null }, new ScpiCommandInfo { Category = "序列命令", Command = "DATA:SEQ:REC 0", Description = "从位置 0 调用序列", IsQuery = false, Example = null }, new ScpiCommandInfo { Category = "序列命令", Command = "DATA:SIM:CLE", Description = "清除模拟数据", IsQuery = false, Example = null }, new ScpiCommandInfo { Category = "序列命令", Command = "DATA:SIM:STOR 0", Description = "存储模拟到位置 0", IsQuery = false, Example = null }, new ScpiCommandInfo { Category = "序列命令", Command = "DATA:SIM:REC 0", Description = "从位置 0 调用模拟", IsQuery = false, Example = null }, }; } public static List GetCategories() { var categories = new List(); foreach (var cmd in GetAllCommands()) { if (!categories.Contains(cmd.Category)) { categories.Add(cmd.Category); } } return categories; } public static List GetCommandsByCategory(string category) { var commands = new List(); foreach (var cmd in GetAllCommands()) { if (cmd.Category == category) { commands.Add(cmd); } } return commands; } } }