设备命令修改

This commit is contained in:
“hsc”
2026-08-06 14:04:28 +08:00
parent 5a565f7361
commit deb3544143
143 changed files with 730494 additions and 1287 deletions
+50
View File
@@ -0,0 +1,50 @@
import json, glob, os
output_dir = r"D:\ACP\测试项\ACP输出"
# 验证一个文件的格式
test_file = os.path.join(output_dir, "NCE-13——OBC放电.ACP")
d = json.load(open(test_file, encoding='utf-8'))
print("=== 设备方法映射验证 ===")
for s in d['StepCollection']:
m = s.get('Method')
if m:
params_info = ", ".join([f"{p['Name']}={'VAR' if p.get('IsUseVar') else str(p.get('Value'))}" for p in m.get('Parameters', [])])
print(f" [{s['Index']}] {m['FullName']}.{m['Name']} ({params_info})")
print("\n=== 格式验证 ===")
# 检查是否有 .ats 特有字段
has_old_fields = False
def check_steps(steps, prefix=""):
global has_old_fields
for s in steps:
m = s.get('Method')
if m:
if 'DeviceID' in m:
has_old_fields = True
print(f"{prefix}Step {s['Index']} 仍包含 DeviceID")
for p in m.get('Parameters', []):
for field in ['IsGlobal', 'InitialValue', 'IsSave', 'IsOutputToReport']:
if field in p:
has_old_fields = True
print(f"{prefix}Step {s['Index']} 参数 {p['Name']} 仍包含 {field}")
if 'IsEditable' not in p:
has_old_fields = True
print(f"{prefix}Step {s['Index']} 参数 {p.get('Name','')} 缺少 IsEditable")
sub = s.get('SubProgram')
if sub and isinstance(sub, dict):
check_steps(sub.get('StepCollection', []), prefix + " Sub.")
check_steps(d['StepCollection'])
if not has_old_fields:
print(" [OK] 无残留 .ats 字段")
print(" [OK] 所有参数包含 IsEditable")
print(" [OK] 无 DeviceID")
# 检查子程序
sub_count = sum(1 for s in d['StepCollection'] if s.get('SubProgram'))
print(f" 子程序步骤数: {sub_count}")
print(f" 总步骤数: {len(d['StepCollection'])}")
print(f" 顶层参数数: {len(d.get('Parameters', []))}")