ScpiCommandLibrary.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. using System.Collections.Generic;
  2. namespace APS7100TestTool.Libraries
  3. {
  4. /// <summary>
  5. /// SCPI 命令信息
  6. /// </summary>
  7. public class ScpiCommandInfo
  8. {
  9. public string Category { get; set; } = string.Empty;
  10. public string Command { get; set; } = string.Empty;
  11. public string Description { get; set; } = string.Empty;
  12. public bool IsQuery { get; set; }
  13. public string? Example { get; set; }
  14. public string DisplayText => $"{Command} - {Description}";
  15. public string FullDescription => IsQuery
  16. ? $"📖 查询命令\n命令: {Command}\n说明: {Description}" + (string.IsNullOrEmpty(Example) ? "" : $"\n示例: {Example}")
  17. : $"⚙️ 设置命令\n命令: {Command}\n说明: {Description}" + (string.IsNullOrEmpty(Example) ? "" : $"\n示例: {Example}");
  18. }
  19. /// <summary>
  20. /// APS7100 SCPI 命令库
  21. ///
  22. /// ⚠ 重要说明:
  23. /// APS7100 使用完整的、层级严格的 SCPI 命令树
  24. /// 核心根节点:MEAS / SOUR / OUTP / STAT / DATA
  25. ///
  26. /// 命令特点:
  27. /// 1. 几乎都带二级/三级节点
  28. /// 2. 不支持简写的无子节点查询(如 OUTP? 不行,必须 OUTP:STAT?)
  29. /// 3. 测量命令必须走 SCALar 路径
  30. /// </summary>
  31. public static class ScpiCommandLibrary
  32. {
  33. public static List<ScpiCommandInfo> GetAllCommands()
  34. {
  35. return new List<ScpiCommandInfo>
  36. {
  37. // ==================== IEEE 488.2 标准命令 ====================
  38. new ScpiCommandInfo
  39. {
  40. Category = "IEEE 488.2",
  41. Command = "*IDN?",
  42. Description = "查询设备识别信息",
  43. IsQuery = true,
  44. Example = "返回: GWINSTEK,APS-7100,SN123456,V1.00"
  45. },
  46. new ScpiCommandInfo
  47. {
  48. Category = "IEEE 488.2",
  49. Command = "*RST",
  50. Description = "重置设备到出厂状态",
  51. IsQuery = false,
  52. Example = null
  53. },
  54. new ScpiCommandInfo
  55. {
  56. Category = "IEEE 488.2",
  57. Command = "*CLS",
  58. Description = "清除状态寄存器",
  59. IsQuery = false,
  60. Example = null
  61. },
  62. new ScpiCommandInfo
  63. {
  64. Category = "IEEE 488.2",
  65. Command = "*TST?",
  66. Description = "设备自检",
  67. IsQuery = true,
  68. Example = "返回: 0(正常) 或错误码"
  69. },
  70. new ScpiCommandInfo
  71. {
  72. Category = "IEEE 488.2",
  73. Command = "*OPC?",
  74. Description = "查询操作完成状态",
  75. IsQuery = true,
  76. Example = "返回: 1(完成)"
  77. },
  78. new ScpiCommandInfo
  79. {
  80. Category = "IEEE 488.2",
  81. Command = "*WAI",
  82. Description = "等待所有挂起操作完成",
  83. IsQuery = false,
  84. Example = null
  85. },
  86. new ScpiCommandInfo
  87. {
  88. Category = "IEEE 488.2",
  89. Command = "*TRG",
  90. Description = "触发设备",
  91. IsQuery = false,
  92. Example = null
  93. },
  94. new ScpiCommandInfo
  95. {
  96. Category = "IEEE 488.2",
  97. Command = "*SAV 0",
  98. Description = "保存设置到位置 0",
  99. IsQuery = false,
  100. Example = "*SAV 0 ~ *SAV 9"
  101. },
  102. new ScpiCommandInfo
  103. {
  104. Category = "IEEE 488.2",
  105. Command = "*RCL 0",
  106. Description = "从位置 0 恢复设置",
  107. IsQuery = false,
  108. Example = "*RCL 0 ~ *RCL 9"
  109. },
  110. new ScpiCommandInfo
  111. {
  112. Category = "IEEE 488.2",
  113. Command = "*ESR?",
  114. Description = "查询事件状态寄存器",
  115. IsQuery = true,
  116. Example = "返回: 0-255"
  117. },
  118. new ScpiCommandInfo
  119. {
  120. Category = "IEEE 488.2",
  121. Command = "*ESE",
  122. Description = "设置事件状态使能寄存器",
  123. IsQuery = false,
  124. Example = "*ESE 32"
  125. },
  126. new ScpiCommandInfo
  127. {
  128. Category = "IEEE 488.2",
  129. Command = "*STB?",
  130. Description = "查询状态字节",
  131. IsQuery = true,
  132. Example = "返回: 0-255"
  133. },
  134. new ScpiCommandInfo
  135. {
  136. Category = "IEEE 488.2",
  137. Command = "*SRE",
  138. Description = "设置服务请求使能",
  139. IsQuery = false,
  140. Example = "*SRE 32"
  141. },
  142. // ==================== SYSTEM 系统命令 ====================
  143. new ScpiCommandInfo
  144. {
  145. Category = "系统命令",
  146. Command = "SYST:ERR?",
  147. Description = "查询错误队列",
  148. IsQuery = true,
  149. Example = "返回: 0,\"No error\""
  150. },
  151. new ScpiCommandInfo
  152. {
  153. Category = "系统命令",
  154. Command = "SYST:VERS?",
  155. Description = "查询 SCPI 版本",
  156. IsQuery = true,
  157. Example = "返回: 1999.0"
  158. },
  159. new ScpiCommandInfo
  160. {
  161. Category = "系统命令",
  162. Command = "SYST:REM",
  163. Description = "进入远程控制模式",
  164. IsQuery = false,
  165. Example = "⚠ 已经是远程模式时再次发送会报错!\n程序会自动跟踪状态避免重复发送"
  166. },
  167. new ScpiCommandInfo
  168. {
  169. Category = "系统命令",
  170. Command = "SYST:COMM:RLST LOCAL",
  171. Description = "返回本地控制模式(面板有效)",
  172. IsQuery = false,
  173. Example = null
  174. },
  175. new ScpiCommandInfo
  176. {
  177. Category = "系统命令",
  178. Command = "SYST:KLOC ON",
  179. Description = "锁定前面板按键",
  180. IsQuery = false,
  181. Example = "⚠ APS7100 使用 KLOC,不是 RWLOCK"
  182. },
  183. new ScpiCommandInfo
  184. {
  185. Category = "系统命令",
  186. Command = "SYST:KLOC OFF",
  187. Description = "解锁前面板按键",
  188. IsQuery = false,
  189. Example = "⚠ APS7100 使用 KLOC,不是 RWLOCK"
  190. },
  191. // ==================== OUTPUT 输出控制 ====================
  192. new ScpiCommandInfo
  193. {
  194. Category = "输出控制",
  195. Command = "OUTP:STAT ON",
  196. Description = "开启输出",
  197. IsQuery = false,
  198. Example = "⚠ 必须使用 OUTP:STAT,不支持 OUTP ON"
  199. },
  200. new ScpiCommandInfo
  201. {
  202. Category = "输出控制",
  203. Command = "OUTP:STAT OFF",
  204. Description = "关闭输出",
  205. IsQuery = false,
  206. Example = "⚠ 必须使用 OUTP:STAT,不支持 OUTP OFF"
  207. },
  208. new ScpiCommandInfo
  209. {
  210. Category = "输出控制",
  211. Command = "OUTP:STAT?",
  212. Description = "查询输出状态",
  213. IsQuery = true,
  214. Example = "返回: 0(关) 或 1(开)\n⚠ 不支持 OUTP?"
  215. },
  216. new ScpiCommandInfo
  217. {
  218. Category = "输出控制",
  219. Command = "OUTP:PROT:CLE",
  220. Description = "清除输出保护状态",
  221. IsQuery = false,
  222. Example = null
  223. },
  224. // ==================== SOURCE 电压设置 ====================
  225. new ScpiCommandInfo
  226. {
  227. Category = "电压设置",
  228. Command = "SOUR:VOLT 220",
  229. Description = "设置输出电压为 220V",
  230. IsQuery = false,
  231. Example = "范围视量程而定"
  232. },
  233. new ScpiCommandInfo
  234. {
  235. Category = "电压设置",
  236. Command = "SOUR:VOLT?",
  237. Description = "查询电压设定值",
  238. IsQuery = true,
  239. Example = "返回: 220.0"
  240. },
  241. new ScpiCommandInfo
  242. {
  243. Category = "电压设置",
  244. Command = "SOUR:VOLT:RANG R155",
  245. Description = "设置电压量程 0-155V",
  246. IsQuery = false,
  247. Example = "⚠ APS7100 量程: R155/R310/R600/AUTO"
  248. },
  249. new ScpiCommandInfo
  250. {
  251. Category = "电压设置",
  252. Command = "SOUR:VOLT:RANG R310",
  253. Description = "设置电压量程 0-310V",
  254. IsQuery = false,
  255. Example = "⚠ 不支持 LOW/HIGH"
  256. },
  257. new ScpiCommandInfo
  258. {
  259. Category = "电压设置",
  260. Command = "SOUR:VOLT:RANG R600",
  261. Description = "设置电压量程 0-600V",
  262. IsQuery = false,
  263. Example = "部分型号支持"
  264. },
  265. new ScpiCommandInfo
  266. {
  267. Category = "电压设置",
  268. Command = "SOUR:VOLT:RANG AUTO",
  269. Description = "设置电压量程为自动",
  270. IsQuery = false,
  271. Example = null
  272. },
  273. new ScpiCommandInfo
  274. {
  275. Category = "电压设置",
  276. Command = "SOUR:VOLT:RANG?",
  277. Description = "查询电压量程",
  278. IsQuery = true,
  279. Example = "返回: R155/R310/R600/AUTO"
  280. },
  281. // ==================== SOURCE 频率设置 ====================
  282. new ScpiCommandInfo
  283. {
  284. Category = "频率设置",
  285. Command = "SOUR:FREQ 50",
  286. Description = "设置输出频率为 50Hz",
  287. IsQuery = false,
  288. Example = "常用: 50/60/400 Hz"
  289. },
  290. new ScpiCommandInfo
  291. {
  292. Category = "频率设置",
  293. Command = "SOUR:FREQ 60",
  294. Description = "设置输出频率为 60Hz",
  295. IsQuery = false,
  296. Example = null
  297. },
  298. new ScpiCommandInfo
  299. {
  300. Category = "频率设置",
  301. Command = "SOUR:FREQ 400",
  302. Description = "设置输出频率为 400Hz (航空标准)",
  303. IsQuery = false,
  304. Example = null
  305. },
  306. new ScpiCommandInfo
  307. {
  308. Category = "频率设置",
  309. Command = "SOUR:FREQ?",
  310. Description = "查询频率设定值",
  311. IsQuery = true,
  312. Example = "返回: 50.0"
  313. },
  314. // ==================== SOURCE 相位设置 ====================
  315. new ScpiCommandInfo
  316. {
  317. Category = "相位设置",
  318. Command = "SOUR:PHAS 0",
  319. Description = "设置输出相位为 0°",
  320. IsQuery = false,
  321. Example = "用于多相或并机控制"
  322. },
  323. new ScpiCommandInfo
  324. {
  325. Category = "相位设置",
  326. Command = "SOUR:PHAS?",
  327. Description = "查询相位设定值",
  328. IsQuery = true,
  329. Example = "返回: 0.0"
  330. },
  331. // ==================== SOURCE 电流限制 ====================
  332. new ScpiCommandInfo
  333. {
  334. Category = "电流限制",
  335. Command = "SOUR:CURR:LIM:RMS 5",
  336. Description = "设置电流限值为 5A (RMS)",
  337. IsQuery = false,
  338. Example = "⚠ APS7100 只有电流限制,没有电流设定\n❌ SOUR:CURR 5 不可用"
  339. },
  340. new ScpiCommandInfo
  341. {
  342. Category = "电流限制",
  343. Command = "SOUR:CURR:LIM:RMS?",
  344. Description = "查询电流限值 (RMS)",
  345. IsQuery = true,
  346. Example = "返回: 5.0\n⚠ 必须使用 SOUR:CURR:LIM:RMS?\n❌ SOUR:CURR? 不可用"
  347. },
  348. // ==================== MEASURE 测量命令 ====================
  349. new ScpiCommandInfo
  350. {
  351. Category = "测量命令",
  352. Command = "MEAS:SCAL:VOLT?",
  353. Description = "测量实际输出电压 (V RMS)",
  354. IsQuery = true,
  355. Example = "返回: 220.5\n⚠ 必须走 SCALar 路径\n❌ MEAS:VOLT? 不可用"
  356. },
  357. new ScpiCommandInfo
  358. {
  359. Category = "测量命令",
  360. Command = "MEAS:SCAL:CURR?",
  361. Description = "测量实际输出电流 (A RMS)",
  362. IsQuery = true,
  363. Example = "返回: 2.345\n⚠ 必须走 SCALar 路径\n❌ MEAS:CURR? 不可用"
  364. },
  365. new ScpiCommandInfo
  366. {
  367. Category = "测量命令",
  368. Command = "MEAS:SCAL:FREQ?",
  369. Description = "测量实际输出频率 (Hz)",
  370. IsQuery = true,
  371. Example = "返回: 50.01\n⚠ 必须走 SCALar 路径\n❌ MEAS:FREQ? 不可用"
  372. },
  373. new ScpiCommandInfo
  374. {
  375. Category = "测量命令",
  376. Command = "MEAS:SCAL:POW:AC:REAL?",
  377. Description = "测量有功功率 P (W)",
  378. IsQuery = true,
  379. Example = "返回: 517.0\n⚠ 必须使用完整路径\n❌ MEAS:POW? 不可用"
  380. },
  381. new ScpiCommandInfo
  382. {
  383. Category = "测量命令",
  384. Command = "MEAS:SCAL:POW:AC:APP?",
  385. Description = "测量视在功率 S (VA)",
  386. IsQuery = true,
  387. Example = "返回: 544.0"
  388. },
  389. new ScpiCommandInfo
  390. {
  391. Category = "测量命令",
  392. Command = "MEAS:SCAL:POW:AC:PFAC?",
  393. Description = "测量功率因数 PF",
  394. IsQuery = true,
  395. Example = "返回: 0.95\n⚠ 使用 PFAC,不是 PF\n❌ MEAS:PF? 不可用"
  396. },
  397. // ==================== INITIATE 触发命令 ====================
  398. new ScpiCommandInfo
  399. {
  400. Category = "触发命令",
  401. Command = "INIT:IMM",
  402. Description = "立即执行(启动 Sequence/Simulation)",
  403. IsQuery = false,
  404. Example = "用于启动序列、模拟、瞬态测试"
  405. },
  406. new ScpiCommandInfo
  407. {
  408. Category = "触发命令",
  409. Command = "INIT:IMM:TRAN",
  410. Description = "立即执行瞬态",
  411. IsQuery = false,
  412. Example = null
  413. },
  414. // ==================== STATUS 状态命令 ====================
  415. new ScpiCommandInfo
  416. {
  417. Category = "状态命令",
  418. Command = "STAT:OPER?",
  419. Description = "查询操作状态寄存器",
  420. IsQuery = true,
  421. Example = "返回: 状态位掩码"
  422. },
  423. new ScpiCommandInfo
  424. {
  425. Category = "状态命令",
  426. Command = "STAT:QUES?",
  427. Description = "查询可疑状态寄存器",
  428. IsQuery = true,
  429. Example = "返回: 状态位掩码"
  430. },
  431. // ==================== DATA/TRACE 序列命令 ====================
  432. new ScpiCommandInfo
  433. {
  434. Category = "序列命令",
  435. Command = "DATA:SEQ:CLE",
  436. Description = "清除序列数据",
  437. IsQuery = false,
  438. Example = "用于电压跌落、频率扫变、IEC测试"
  439. },
  440. new ScpiCommandInfo
  441. {
  442. Category = "序列命令",
  443. Command = "DATA:SEQ:STOR 0",
  444. Description = "存储序列到位置 0",
  445. IsQuery = false,
  446. Example = null
  447. },
  448. new ScpiCommandInfo
  449. {
  450. Category = "序列命令",
  451. Command = "DATA:SEQ:REC 0",
  452. Description = "从位置 0 调用序列",
  453. IsQuery = false,
  454. Example = null
  455. },
  456. new ScpiCommandInfo
  457. {
  458. Category = "序列命令",
  459. Command = "DATA:SIM:CLE",
  460. Description = "清除模拟数据",
  461. IsQuery = false,
  462. Example = null
  463. },
  464. new ScpiCommandInfo
  465. {
  466. Category = "序列命令",
  467. Command = "DATA:SIM:STOR 0",
  468. Description = "存储模拟到位置 0",
  469. IsQuery = false,
  470. Example = null
  471. },
  472. new ScpiCommandInfo
  473. {
  474. Category = "序列命令",
  475. Command = "DATA:SIM:REC 0",
  476. Description = "从位置 0 调用模拟",
  477. IsQuery = false,
  478. Example = null
  479. },
  480. };
  481. }
  482. public static List<string> GetCategories()
  483. {
  484. var categories = new List<string>();
  485. foreach (var cmd in GetAllCommands())
  486. {
  487. if (!categories.Contains(cmd.Category))
  488. {
  489. categories.Add(cmd.Category);
  490. }
  491. }
  492. return categories;
  493. }
  494. public static List<ScpiCommandInfo> GetCommandsByCategory(string category)
  495. {
  496. var commands = new List<ScpiCommandInfo>();
  497. foreach (var cmd in GetAllCommands())
  498. {
  499. if (cmd.Category == category)
  500. {
  501. commands.Add(cmd);
  502. }
  503. }
  504. return commands;
  505. }
  506. }
  507. }