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

44 lines
1.6 KiB
Python

import json
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.json"
with open(json_file, "r", encoding="utf-8") as f:
data = json.load(f)
print("Network IDs y comentarios:")
for i, network in enumerate(data["networks"]):
print(
f'{i+1:2d}. ID: {network["id"]:>3s} - Title: "{network["title"]}" - Comment: "{network["comment"]}"'
)
print(f'\nTotal redes: {len(data["networks"])}')
# La red 13 seria la numero 13 en la lista (index 12)
if len(data["networks"]) >= 13:
network_13 = data["networks"][12] # index 12 = red numero 13
print(f"\n=== RED 13 (Index 12) ===")
print(f'ID: {network_13["id"]}')
print(f'Title: "{network_13["title"]}"')
print(f'Comment: "{network_13["comment"]}"')
print(f'Language: {network_13["language"]}')
print(f'Logic instructions: {len(network_13["logic"])}')
# Mostrar tipos de instrucciones
if network_13["logic"]:
print("Instruction types:")
for instr in network_13["logic"]:
print(f' - UID {instr["uid"]}: {instr["type"]}')
# Buscar Sr o Set/Reset
sr_instructions = [
instr
for instr in network_13["logic"]
if instr["type"] in ["Sr", "S", "R", "Set", "Reset"]
]
if sr_instructions:
print(f"\nSr/Set/Reset instructions found: {len(sr_instructions)}")
for instr in sr_instructions:
print(f" - {instr}")
else:
print("No logic instructions found!")