UDT values "NoneType" when vision page internalFrameActivated

Hi All.

Ignition 8.1.1 (b2020120808)

I have a strange thing happening when running a script in the internalFrameActived event of my window

When I open the window I get:-

Traceback (most recent call last):
  File "<event:internalFrameActivated>", line 23, in <module>
TypeError: unsupported operand type(s) for &: 'NoneType' and 'int'

The code is pretty straight forward

headers = ["Device Name","Status"]
data = []

window = system.gui.getParentWindow(event).getComponentForPath('Root Container')

indevs = system.dataset.toPyDataSet(window.inputdevices)

for row in indevs:
	id = row["value"]
	desc = row["DeviceName"]
	#read the status of the associated tag index
	if id < 32:
		ok = window.safetyfunction_hmi.SDI_OK_0_31
		fp = window.safetyfunction_hmi.SDI_FP_0_31
	else:
		ok = window.safetyfunction_hmi.SDI_OK_32_63
		fp = window.safetyfunction_hmi.SDI_FP_32_63
		id = id - 32
	#make the bit
	id_mask = 2 ** id
	#see if this bit is on
#	try:
	ok_bit = (ok & id_mask)
	fp_bit = (fp & id_mask)
	#set the text
	if fp_bit > 0:
		data.append([desc,"Fault"])
	elif ok_bit > 0:
		data.append([desc,"OK:"])
	else:
		data.append([desc,"Tripped:"])
#	except:
#		data.append([desc,"Pending:"])
#		pass	
	
system.gui.getParentWindow(event).getComponentForPath('Root Container.Table').data = system.dataset.toDataSet(headers,data)

safetyfunction_hmi is a UDT parameter and line 23 where the error occurs is “ok_bit = (ok & id_mask)”

Any reference to the UDT returns a NoneType including the meta data.

Now it gets pretty strange, if I add a system.gui.messageBox(“Test”,“Test”) before the for loop. The code works perfectly fine.

(similarly adding the code to a button on the window works perfectly fine too)

Any info greatly appreciated

Regards
Dave

Tag data arrives asynchronously. You are simply accessing that property before the data arrives. Consider moving this code to a propertyChange event that notes when the UDT parameter populates.

Thanks pturmel

You learn something new every day.
I hadn’t realised that parameters were asynchronous.

Does that mean I shouldn’t use any parameters in window and internalframe events? or is it purely a UDT issue? (my table and string parameters have never suffered NoneType)

I will look to move the code elsewhere.

Regards
Dave

Not sure. I never use UDT parameters, whether for windows or for templates. I always pass tag paths and indirect bind from that.

1 Like

Thanks pturmel.

I will try passing in the path instead of the UDT.

regards
Dave