ParamManagerScripts/backend/script_groups/XML Parser to SCL/debug_sr_processed.py

38 lines
1.4 KiB
Python

import json
# Cargar el JSON procesado
json_file = r"C:\Trabajo\SIDEL\09 - SAE452 - Diet as Regular - San Giorgio in Bosco\ExportTia\CPU_315F-2_PN_DP\ProgramBlocks_XML\parsing\System_Run_Out_processed.json"
with open(json_file, "r", encoding="utf-8") as f:
data = json.load(f)
# Encontrar la red 13 (ID: D5) y la instrucción Sr
for network in data["networks"]:
if network["id"] == "D5":
print(f"=== RED 13 (ID: D5) PROCESADA ===")
print(f'Title: "{network["title"]}"')
print(f'Comment: "{network["comment"]}"')
for instr in network["logic"]:
if instr["type"] == "Sr" or "Sr" in instr["type"]:
print(f'\n=== INSTRUCCIÓN Sr (UID {instr["uid"]}) ===')
print(f'Type: {instr["type"]}')
print(f"SCL generado:")
print(f'{instr.get("scl", "NO SCL ENCONTRADO")}')
print(f'Inputs: {instr.get("inputs", {})}')
print(f'Outputs: {instr.get("outputs", {})}')
break
else:
print("No se encontró instrucción Sr en la red!")
# Mostrar todas las instrucciones para debugging
print(f"\n=== TODAS LAS INSTRUCCIONES EN LA RED 13 ===")
for instr in network["logic"]:
print(
f'UID {instr["uid"]} - Type: {instr["type"]} - SCL: {len(instr.get("scl", ""))} chars'
)
break
else:
print("RED 13 (ID: D5) no encontrada en el JSON procesado!")