48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
from .processor_utils import get_scl_representation, format_variable_name,get_target_scl_name
|
|
|
|
|
|
# TODO: Import necessary functions from processor_utils
|
|
# Example: from .processor_utils import get_scl_representation, format_variable_name
|
|
# Or: import processors.processor_utils as utils
|
|
|
|
# TODO: Define constants if needed (e.g., SCL_SUFFIX) or import them
|
|
SCL_SUFFIX = "_scl"
|
|
|
|
# --- Function code starts ---
|
|
def process_not(instruction, network_id, scl_map, access_map, data):
|
|
"""Genera la expresión SCL para la inversión lógica NOT."""
|
|
instr_uid = instruction["instruction_uid"]
|
|
instr_type = instruction["type"] # Not
|
|
if instr_type.endswith(SCL_SUFFIX) or "_error" in instr_type:
|
|
return False
|
|
|
|
in_info = instruction["inputs"].get("in")
|
|
in_scl = get_scl_representation(in_info, network_id, scl_map, access_map)
|
|
|
|
if in_scl is None:
|
|
return False # Dependencia no lista
|
|
|
|
# Formatear entrada (añadir paréntesis si es complejo)
|
|
in_scl_formatted = in_scl
|
|
if (" " in in_scl or "AND" in in_scl or "OR" in in_scl) and not (in_scl.startswith("(") and in_scl.endswith(")")):
|
|
in_scl_formatted = f"({in_scl})"
|
|
|
|
result_scl = f"NOT {in_scl_formatted}"
|
|
|
|
# Guardar resultado en mapa para 'out'
|
|
map_key_out = (network_id, instr_uid, "out")
|
|
scl_map[map_key_out] = result_scl
|
|
|
|
instruction["scl"] = f"// Logic NOT {instr_uid}: {result_scl}"
|
|
instruction["type"] = instr_type + SCL_SUFFIX
|
|
# NOT no tiene EN/ENO explícito en LAD, modifica el RLO
|
|
return True
|
|
|
|
# --- Function code ends ---
|
|
|
|
# --- Processor Information Function ---
|
|
def get_processor_info():
|
|
"""Devuelve la información para la operación Not."""
|
|
return {'type_name': 'not', 'processor_func': process_not, 'priority': 1}
|