Ignition app become dead slow

My ignition app becomes dead show even doing nothing in developer but becoming slow.
The console continuously showed this message and I could not find the exact variable which caused this.

Looks like you're repeatedly calling an extension method on a power chart. My guess is you're doing this in a cell update event or some other infinite loop on the EDT. This has locked up your designer.

The error itself means that you've tried to convert something with a value of None to an integer, which doesn't work.

If this is happening in a cell update event, you may be hosed, as it will be difficult to make any change to that window. If you can manage to delete the table or close the window, you might be able to do something.

Your best bet might be to force the designer closed. Re-open the designer, and without opening the suspect window, hold shift and right click on the window. Select "Copy XML to Clipboard", and then paste that here as preformatted text.

2 Likes

First thanks for reply.
Here i have code to change the tag value to string.

level_value = val_CutList_Level[i].value if val_CutList_Level[i].value is not None else 0
			size_value = val_CutList_Size[i].value if val_CutList_Size[i].value is not None else 0
			levelsize = str(level_value + 1) + '/' + str(size_value)

I want to show this as "5/2" so I am trying to concatenate the two integer values.

Other than the indentation being incorrect in what you posted, there is nothing wrong with that code, and it should result in a string of the form you've shown.

However, that script does not contain any call to int() which is where the error in your OP is being generated.

3 Likes

That is the configureCell extension method on a PowerTable.

That method gets called for every cell in the table, and repeatedly called when the table scrolls or anything else makes it repaint.

Doing anything in that method that calls out across the network (any gateway tag read or database query or system.net.* operation) will crush your client.

Show the whole extension method so we can point out the flaws and make suggestions for alternate techniques. Paste and mark as code as described here:

Wiki - how to post code on this forum.

5 Likes

Thanks, Pturment...You are right i am using "configureCell" to change some graphics of each cell after changing data. Here below is the whole code.

initialize

def initialize(self):	
	from java.awt import Dimension
	table = self.getTable()
	header = table.getTableHeader()
	dim = header.getPreferredSize()
	header.setPreferredSize(Dimension(int(dim.getWidth()),20))
	header.revalidate()

configureCell

def configureCell(self, value, textValue, selected, rowIndex, colIndex, colName, rowView, colView):

	from javax.swing import BorderFactory
	from javax.swing import SwingConstants
	
	vfirsttocut = self.data.getValueAt(rowIndex,"firsttocut")
	vc1 = self.data.getValueAt(rowIndex,'change1')
	vc2 = self.data.getValueAt(rowIndex,'change2')
	vc3 = self.data.getValueAt(rowIndex,'change3')
	vc4 = self.data.getValueAt(rowIndex,'change4')	
	
	vc5=int(vc1)+int(vc2)+int(vc3)+int(vc4)
	
	vDest = self.data.getValueAt(rowIndex,'Dest')
	vDestEn = self.data.getValueAt(rowIndex,'DestEn')
	vDest_rev = self.data.getValueAt(rowIndex,'Dest_rev')
	vDestEn_rev = self.data.getValueAt(rowIndex,'DestEn_rev')

	
	dbcolor1='F814E0'
	dbcolor2='A3A3A3' #Grey color
	dbcolor3='DFDFDF' 
	dfont1='Arial, Bold, 16'
	dfont2='Arial Balck,Plain,10'	
	bordersize=4
	
	#Set value for Dest variable. It will set the formatting depending on Dest and DestEn value.
	if colName=='Dest_1': 
		if vDest==1:
			return {"background":dbcolor1,'font': dfont1,'text': '<html>' + textValue}
		elif functionlib.Check_bit(vDestEn,0)!=1:
			return {"background":dbcolor3,'text':'','font': dfont2,'border':BorderFactory.createMatteBorder(4,0,4,0, system.gui.color(dbcolor3))}
		else:			
			return {"background":dbcolor2,'font': dfont2,'text': '<html>' + textValue,
			'border':BorderFactory.createMatteBorder(bordersize,0,bordersize,0, system.gui.color(dbcolor3))}
	if colName=='Dest_2': 
		if vDest==2:
			return {"background":'DFFF00','font': dfont1,'text': '<html>' + textValue}
		elif functionlib.Check_bit(vDestEn,1)!=1:
			return {"background":dbcolor3,'text':'','font': dfont2,'border':BorderFactory.createMatteBorder(4,0,4,0, system.gui.color(dbcolor3))}
		else:
			return {"background":dbcolor2,'font': dfont2,'text': '<html>' + textValue,
			'border':BorderFactory.createMatteBorder(bordersize,0,bordersize,0, system.gui.color(dbcolor3))}
	if colName=='Dest_3': 
		if vDest==3:
			return {"background":'008080','font': dfont1,'foreground':'FDFDFD','text': '<html>' + textValue}
		elif functionlib.Check_bit(vDestEn,2)!=1:
			return {"background":dbcolor3,'text':'','font': dfont2,'border':BorderFactory.createMatteBorder(4,0,4,0, system.gui.color(dbcolor3))}
		else:
			return {"background":dbcolor2,'font': dfont2,'text': '<html>' + textValue,
			'border':BorderFactory.createMatteBorder(bordersize,0,bordersize,0, system.gui.color(dbcolor3))}
	if colName=='Dest_4': 
		if vDest==4:
			return {"background":'3E07F8','font': dfont1,'foreground':'FDFDFD','text': '<html>' + textValue}
		elif functionlib.Check_bit(vDestEn,3)!=1:
			return {"background":dbcolor3,'text':'','font': dfont2,'border':BorderFactory.createMatteBorder(4,0,4,0, system.gui.color(dbcolor3))}
		else:
			return {"background":dbcolor2,'font': dfont2,'text': '<html>' + textValue,
			'border':BorderFactory.createMatteBorder(bordersize,0,bordersize,0, system.gui.color(dbcolor3))}
	
	if colName=='DestX_shw': 
		if vDest>4 or vDest<1:
			return {"background":"F7051F",'text': '<html>' + 'X','font': 'Arial Balck,Bold,10','foreground':'FDFDFD'}
		else:
			return {'text':''}
	
	
	#Set value for Destrev variable. It will set the formatting depending on Destrev and DestEn_rev value.
	if colName=='R1': 
		if vDest_rev==1:
			return {"background":dbcolor1,'font': dfont1,'text': '<html>' + textValue}
		elif functionlib.Check_bit(vDestEn_rev,0)!=1:
			return {"background":dbcolor3,'text':'','font': dfont2,'border':BorderFactory.createMatteBorder(4,0,4,0, system.gui.color(dbcolor3))}
		else:			
			return {"background":dbcolor2,'text': '<html>' + textValue,'font': dfont2,
			'border':BorderFactory.createMatteBorder(bordersize,0,bordersize,0, system.gui.color(dbcolor3))}
	if colName=='R2': 
		if vDest_rev==2:
			return {"background":'DFFF00','font': dfont1,'text': '<html>' + textValue}
		elif functionlib.Check_bit(vDestEn_rev,1)!=1:
			return {"background":dbcolor3,'text':'','font': dfont2,'border':BorderFactory.createMatteBorder(4,0,4,0, system.gui.color(dbcolor3))}
		else:
			return {"background":dbcolor2,'font': dfont2,'text': '<html>' + textValue,
			'border':BorderFactory.createMatteBorder(bordersize,0,bordersize,0, system.gui.color(dbcolor3))}
	if colName=='R3': 
		if vDest_rev==3:
			return {"background":'008080','font': dfont1,'foreground':'FDFDFD','text': '<html>' + textValue}
		elif functionlib.Check_bit(vDestEn_rev,2)!=1:
			return {"background":dbcolor3,'text':'','font': dfont2,'border':BorderFactory.createMatteBorder(4,0,4,0, system.gui.color(dbcolor3))}
		else:
			return {"background":dbcolor2,'font': dfont2,'text': '<html>' + textValue,
			'border':BorderFactory.createMatteBorder(bordersize,0,bordersize,0, system.gui.color(dbcolor3))}
	if colName=='R4': 
		if vDest_rev==4:
			return {"background":'3E07F8','font': dfont1,'foreground':'FDFDFD','text': '<html>' + textValue}
		elif functionlib.Check_bit(vDestEn_rev,3)!=1:
			return {"background":dbcolor3,'text':'','font': dfont2,'border':BorderFactory.createMatteBorder(4,0,4,0, system.gui.color(dbcolor3))}
		else:
			return {"background":dbcolor2,'font': dfont2,'text': '<html>' + textValue,
			'border':BorderFactory.createMatteBorder(bordersize,0,bordersize,0, system.gui.color(dbcolor3))}
	
	if colName=='Dest_rev_shw': 
		if vDest_rev>4 or vDest_rev<1:
			return {"background":"F7051F",'text': '<html>' + 'X','font': 'Arial Balck,Bold,10','foreground':'FDFDFD'}
		else:
			return {'text':''}
	
	if colName=='Rev_shw' and value=='R': 
		return {'foreground':'FCFCFC','background': '9A0AF9','text': '<html>' + value}
		
	
	
	
	
	#Set the value of stat column according to its value and change to dispaly string.
	if colName == "Stat" and value==0 and vfirsttocut==1:		
		return {"background":"6AFA38",'text':'TO CUT'}
	elif colName == "Stat" and value==0:
		return {"background":"6AFA38",'text':'TO CUT'}
	elif colName == "Stat" and value==1:
		return {"background":"C6C4C4",'text':'CUT OK'}
	elif colName == "Stat" and value==2:
		return {'text':'DISCARD'}
	elif colName == "Stat" and value==3:
		return {'text':'SAMPLE'}
	elif colName == "Stat" and value==4:
		return {'text':'TAPE OK'}		
	
	#Change color of first 4 column C1-4. on click change the entire row color.
	if colName == "c1" and vc1==0:		
		return {"background":"06C5E3",'text': '<html>' + textValue}
	elif colName == "c1" and vc1==1:
		return {"background":"FDC754",'text': '<html>' + textValue}
	if colName == "c2" and vc2==0:		
		return {"background":"06C5E3",'text': '<html>' + textValue}
	elif colName == "c2" and vc2==1:
		return {"background":"FDC754",'text': '<html>' + textValue}
	if colName == "c3" and vc3==0:		
		return {"background":"06C5E3",'text': '<html>' + textValue}
	elif colName == "c3" and vc3==1:
		return {"background":"FDC754",'text': '<html>' + textValue}
	if colName == "c4" and vc4==0:		
		return {"background":"06C5E3",'text': '<html>' + textValue}
	elif colName == "c4" and vc4==1:
		return {"background":"FDC754",'text': '<html>' + textValue}
		
	
	#Show C if overlap have value >0
	if colName == "OvlapC" and value=='C':
		return {'foreground':'FCFCFC','background': '094EF9','text': '<html>' + textValue}
	
	valueStat = self.data.getValueAt(rowIndex,"Stat")
	
	#Blink the top TO CUT status row if any first 4 column change status. As other all row change color but this specific row which is ready TO CUT will blink for few seconds. 
	if valueStat ==0 and vfirsttocut==1 and vc5>=1 and self.parent.getComponent('Timer_Blink1').running:
		print 'in ConfiCell:',self.vTimerBlink
		if self.vTimerBlink % 2:			
			return{'background': 'FDC754'}
		else:			
			return{'background': '6AFA38'}	
	elif valueStat ==0 and vfirsttocut==1 and vc5>=1 :		
		return{'background': '6AFA38'}
	elif valueStat ==0 and vfirsttocut==1 and not vc5 :		
		return{'background': '6AFA38'}
	elif valueStat ==0 and vfirsttocut==0 and vc5>=1 :		
		return{'background': 'FDC754'}
	#if valueStat ==0 and vc1==1 or vc2==1 or vc3==1 or vc4==1  :
	#	return{'background': 'FDC754'}
	
	#TO CUT
	#if valueStat ==0 and vc5 and not vfirsttocut:
	#	return{'background': 'FDC754'}#'6AFA38'
	#CUT OK
	if valueStat ==1 :
		return{'background': 'C6C4C4'}
	#DISCARD
	if valueStat ==2 and vc5:
		return{'background': 'FDC754'}
	#SAMPLE
	if valueStat ==3 and vc5:
		return{'background': 'FDC754'}
	#TAPE OK
	if valueStat ==4 and vc5:
		return{'background': 'FDC754'}

I don't see anything especially bad in there, except the print. Don't do that in this particular extension method.

It is a large operation, though. There are constants and imports that have to be set up every time it is called. You should move the entire function to a project library script function, and move the imports and constant assignments outside the function (so they persist).

Consider making constants for all of your borders and color objects, too.

3 Likes

Don't convert things that don't need to be converted. For instance, you're doing a conversion to int on dim.getWidth() which is already an integer.

Your initialize script (which I don't see much point for but okay) can just be this:

def initialize(self):
    from java.awt import Dimension
    pSize = self.table.tableHeader.preferredSize
    self.table.tableHeader.preferredSize = Dimension(pSize.width, 20)

Row 13 is where your error is coming from, this likely means that one of the "change" cells is empty. So the conversion fails due to vc? being None. This is likely due to how you're retrieving the data.

If for some reason you can not insure that you are not getting empty data from the data source, then I would consider changing that section of the code to something like this:

pyData = system.dataset.toPyDataSet(self.data)
vfirsttocut = pyData[rowIndex,"firsttocut"]
changes = [pyData[rowIndex,change] if pyData[rowIndex,change] else 0 for change in ['change{}'.format(i)  for i in xrange(1,5)]]

vc1,vc2,vc3,vc4 = changes	
vc5=sum(changes)

vDest,vDestEn,vDest_rev,vDestEn_rev = [pyData[rowIndex,col] for col in ['Dest','DestEn','Dest_rev','DestEn_rev']]

This way if one of the cells happens to be empty, it will be replaced with a 0.

Hi, you are right that was the issue with int() if None came. So I use the following code and it Works fine. It is the same as you told but in another way I did.

if vc1 or vc2 or vc3 or vc4 is not None:
    vc5=int(vc1)+int(vc2)+int(vc3)+int(vc4)
else:
    vc5=0

Anyhow thanks a lot.