Se implementaron mejoras en el script de análisis XML para generar pines dinámicamente en compuertas lógicas basadas en la cardinalidad. Además, se corrigieron las rutas de búsqueda de elementos en el archivo parser_utils.py para asegurar la correcta extracción de valores de TemplateValue y Negated.
This commit is contained in:
parent
def0f0b2d7
commit
e196dca9c4
|
@ -6,6 +6,8 @@ __pycache__/
|
|||
# C extensions
|
||||
*.so
|
||||
|
||||
backend/script_groups/TwinCat/
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
temp/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"path": "."
|
||||
},
|
||||
{
|
||||
"path": "C:/Trabajo/SIDEL/13 - E5.007560 - Modifica O&U - SAE235/Reporte/ExportTwinCat"
|
||||
"path": "C:/Trabajo/SIDEL/13 - E5.007560 - Modifica O&U - SAE235/Reporte/Analisis"
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -273,6 +273,25 @@ def parse_lad_fbd_network(network_element):
|
|||
# --- Poblar Entradas ---
|
||||
# Lista base de pines posibles (podría obtenerse de XSDs o dinámicamente)
|
||||
possible_input_pins = set(["en", "in", "in1", "in2", "pre"])
|
||||
|
||||
# **NUEVO: Generar pines dinámicamente para compuertas OR/AND basándose en Cardinality**
|
||||
if original_type in ["O", "And"]: # Compuertas lógicas
|
||||
cardinality = instruction_info.get("template_values", {}).get("Card")
|
||||
if cardinality:
|
||||
try:
|
||||
num_inputs = int(cardinality)
|
||||
# Generar pines in1, in2, ..., inN
|
||||
for i in range(1, num_inputs + 1):
|
||||
possible_input_pins.add(f"in{i}")
|
||||
print(f"INFO: Compuerta {original_type} UID {instruction_uid} con cardinalidad {num_inputs} - generando pines in1...in{num_inputs}")
|
||||
except (ValueError, TypeError):
|
||||
print(f"Advertencia: Cardinalidad inválida '{cardinality}' para {original_type} UID {instruction_uid}")
|
||||
# Fallback a pines estándar
|
||||
possible_input_pins.update(["in1", "in2"])
|
||||
else:
|
||||
# Sin cardinalidad explícita, usar pines estándar
|
||||
possible_input_pins.update(["in1", "in2"])
|
||||
|
||||
# Añadir pines dinámicamente basados en el tipo de instrucción
|
||||
if original_type in ["Contact", "Coil", "SCoil", "RCoil", "SdCoil"]:
|
||||
possible_input_pins.add("operand")
|
||||
|
|
|
@ -276,15 +276,16 @@ def parse_part(part_element):
|
|||
template_values = {}
|
||||
negated_pins = {}
|
||||
try:
|
||||
for tv in part_element.xpath("./TemplateValue"):
|
||||
for tv in part_element.xpath("./flg:TemplateValue", namespaces=ns):
|
||||
tv_name = tv.get("Name")
|
||||
tv_type = tv.get("Type")
|
||||
if tv_name and tv_type:
|
||||
template_values[tv_name] = tv_type
|
||||
tv_value = tv.text.strip() if tv.text else tv_type # Obtener valor real del elemento
|
||||
if tv_name:
|
||||
template_values[tv_name] = tv_value
|
||||
except Exception as e:
|
||||
print(f"Advertencia: Error extrayendo TemplateValues Part UID={uid}: {e}")
|
||||
try:
|
||||
for negated_elem in part_element.xpath("./Negated"):
|
||||
for negated_elem in part_element.xpath("./flg:Negated", namespaces=ns):
|
||||
negated_pin_name = negated_elem.get("Name")
|
||||
if negated_pin_name:
|
||||
negated_pins[negated_pin_name] = True
|
||||
|
|
Loading…
Reference in New Issue