| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522 |
- using System.Collections.Generic;
- namespace APS7100TestTool.Libraries
- {
- /// <summary>
- /// SCPI 命令信息
- /// </summary>
- 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}");
- }
- /// <summary>
- /// APS7100 SCPI 命令库
- ///
- /// ⚠ 重要说明:
- /// APS7100 使用完整的、层级严格的 SCPI 命令树
- /// 核心根节点:MEAS / SOUR / OUTP / STAT / DATA
- ///
- /// 命令特点:
- /// 1. 几乎都带二级/三级节点
- /// 2. 不支持简写的无子节点查询(如 OUTP? 不行,必须 OUTP:STAT?)
- /// 3. 测量命令必须走 SCALar 路径
- /// </summary>
- public static class ScpiCommandLibrary
- {
- public static List<ScpiCommandInfo> GetAllCommands()
- {
- return new List<ScpiCommandInfo>
- {
- // ==================== 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<string> GetCategories()
- {
- var categories = new List<string>();
- foreach (var cmd in GetAllCommands())
- {
- if (!categories.Contains(cmd.Category))
- {
- categories.Add(cmd.Category);
- }
- }
- return categories;
- }
- public static List<ScpiCommandInfo> GetCommandsByCategory(string category)
- {
- var commands = new List<ScpiCommandInfo>();
- foreach (var cmd in GetAllCommands())
- {
- if (cmd.Category == category)
- {
- commands.Add(cmd);
- }
- }
- return commands;
- }
- }
- }
|