Template property change script weird errors

I’m working with a template which has two UDT custom properties bound (see attached template), my problem is that I get an error related to the template´s property change script, which says:

[i]Traceback (most recent call last):

File “event:propertyChange”, line 3, in

AttributeError: ‘com.inductiveautomation.factorypmi.application.bin’ object has no attribute ‘ESTADO’

Ignition v7.6.6 (b2014040112)
Java: Oracle Corporation 1.7.0_51[/i]

I’m stuck since the UDT type MOTOR_VARIADOR in fact has an attribute ESTADO (see attached image)
SENOBLE_2014-07-17_1158_partial.proj (18.9 KB)




Can you show the code in the propertyChange event script?

Hi nmudge,

You can see the code in the attachment, in any case here you are:

if event.source.Compresor.FALLOS>0:
event.source.Color=1
elif event.source.Variador.ESTADO:
if event.source.Variador.MAN or not(event.source.Compresor.REMOTO):
event.source.Color=3
else:
event.source.Color=4
elif event.source.Variador.HORAS_SERV>event.source.Variador.HORAS_MANTENIMIENTO:
event.source.Color=2
else:
event.source.Color=0

Regards,

Can anybody help?

I’m gobsmacked, the only way I’ve been able to solve the problem, has consisted of creating new internal properties and assigning the ‘problematic’ existing attributes to these internal variables.

These are the kind of bugs that make me lose my confidence in Ignition.

First of all you will need to separate out the events using:

if event.propertyName == "Compresor": blah blah if event.propertyName == "Variador": blah blah

I don’t think you can drill down into the UDTs this way.
You can try doing the following:
Create Color as an internal property of the template.
Bind it to an expression:

if({TemplateName.Compresor::FALLOS}>0, 1, if({TemplateName.Variado::ESTADO}, if({TemplateName.Variado::MAN} || !{TemplateName.Compresor::REMOTO}, 3, 4), if({TemplateName.Variado::HORAS_SERV}>{TemplateName.Variado::HORAS_MANTENIMIENTO}, 2, 0)))

jpark is right. You cannot access tag values in a UDT that way. It isn’t a bug.

To access tags in a UDT instance in scripting you will need to use the system.tag.read function or bind the subtag to a property on a component.

Example:

value = system.tag.read("MOTOR1/ESTADO").value

Nick,

I don’t agree with you, I’ve many other templates for pumps, tanks, towers, etc where I’ve directly used the UDT properties in scripting and work perfectly.

I tested further and you are right and I am wrong. I now agree with you that UDT instance sub tags can be referenced the way you are doing it in scripting.

Are you sure that the Variador template property is actually bound to an instance of the MOTOR_VARIADOR UDT?

I get the same error you get when the Variador property is not bound.

Yes, it’s bound however I get that strange error.

I see. Is it possible for you to export the window that is using the template that is having the error? Or if you don’t want to export that window then can you duplicate the same error in another window? Then upload the export to this thread.

If there is a bug and if we can reproduce it then IA will get it fixed.

Here you are Nick,
SENOBLE_2014-07-24_1034_partial.proj (62 KB)

Thanks Jose,

I was able to consistently reproduce the error. I would get the “AttributeError: ‘com.inductiveautomation.factorypmi.application.bin’ object has no attribute ‘ESTADO’” when opening the Aqua_clima window. Is this when you are getting the error?

This seems to be a timing problem. I was able to fix the problem by using this code in the propertyChange event script:

def func(event=event):
	if event.source.Compresor.FALLOS>0:
		event.source.Color=1
	elif event.source.Variador.ESTADO:
		if event.source.Variador.MAN or not(event.source.Compresor.REMOTO):
			event.source.Color=3
		else:
			event.source.Color=4
	elif event.source.Variador.HORAS_SERV>event.source.Variador.HORAS_MANTENIMIENTO:
		event.source.Color=2		
	else:
		event.source.Color=0

system.util.invokeLater(func)

Let me know if this fixes it for you too.

Yes it does.

Thanks Nick.