I have created a memory tag with next script in ValueEvents/Value Changed:
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
project.PruebaCambioStatus.PasodeValores(tagPath, previousValue, currentValue, initialChange)
In Project Library project/PruebaCambioStatus I have next function:
def PasodeValores(tagPath, previousValue, currentValue, initialChange):
def PasodeValores(tagPath, previousValue, currentValue, initialChange):
# Creamos un logger especĂfico para esta tarea
logger = system.util.getLogger("PruebaCambioStatus")
# Extraemos los valores reales (evitando el objeto calificado completo si solo queremos el valor)
pre_val = previousValue.value if previousValue is not None else None
cur_val = currentValue.value if currentValue is not None else None
# Formateamos el mensaje para el log
mensaje = "Path: {} | PreValue: {} | CurValue: {} | IniChange: {}".format(
tagPath, pre_val, cur_val, initialChange
)
# Publicamos en el log como INFO
logger.info(mensaje)
Once memory tag changes value, next error message appears in the log
([default]TurnoFicticio, valueChanged) Error executing tag event script: Traceback (most recent call last): File "tagevent:valueChanged", line 2, in valueChanged NameError: global name 'project' is not defined
How it can be solved?