How to define variable

In a template propertyChange script I get the following error. How do I define a variable in Python? Thanks.


TopDop_7129_20220603160020.zip (58.8 KB)

1 Like

You’re going to get better/quicker help if you supply the code in question as a snippet.

Sorry about that.

if event.propertyName == "cycleTime":
	datetime = system.date.now()
	time = str(system.date.format(datetime, "hh:mm"))
	
#RESET CYCLE SCORES
	if 	str(event.source.getComponent('Title').text) == "BLOWER DROP ":
		if time == "05:45": #RESET CYCLE SCORE AT SHIFT CHANGE
			BD_unitCount = 0
		event.source.cycleScore = BD_unitCount
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerDropZone13", BD_unitCount)
	elif str(event.source.getComponent('Title').text) == "BLOWER SHELF ":
		if time == "05:45": #RESET CYCLE SCORE AT SHIFT CHANGE 
			BS_unitCount = 0                                   
		event.source.cycleScore = BS_unitCount	           
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone13", BS_unitCount)
	elif str(event.source.getComponent('Title').text) == "HOCKEY STICK ":
		if time == "05:45": #RESET CYCLE SCORE AT SHIFT CHANGE 
			HS_unitCount = 0                                   
		event.source.cycleScore = HS_unitCount	  
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreHockeyStickZone10", HS_unitCount)
	elif str(event.source.getComponent('Title').text) == "INSULATION ":
		if time == "05:45": #RESET CYCLE SCORE AT SHIFT CHANGE 
			IN_unitCount = 0                                   
		event.source.cycleScore = IN_unitCount	  
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreInsulationZone8", IN_unitCount)
	elif str(event.source.getComponent('Title').text) == "SUPERSUB DROP ":
		if time == "05:45": #RESET CYCLE SCORE AT SHIFT CHANGE 
			SS_unitCount = 0                                   
		event.source.cycleScore = SS_unitCount	  
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreSuperSubZone17", SS_unitCount)

#INCREMENT CYCLE SCORES
	if event.newValue < event.oldValue and event.source.CycleTimeMem < event.source.cycleTimeTarget: 
		#system.gui.messageBox(str(event.source.instanceName)+ " 1 " +str(event.source.getComponent('Title').text))
		if 	str(event.source.getComponent('Title').text) == "BLOWER DROP ":
			BD_unitCount = event.source.cycleScore + 1
			if BD_unitCount == 2000:
				BD_unitCount = 0
			if BD_unitCount < 0:
				BD_unitCount = 0
			event.source.cycleScore = BD_unitCount
			#system.gui.messageBox(str(event.source.instanceName)+ " 2 " +str(event.source.getComponent('Title').text))
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerDropZone13", BD_unitCount)
			#system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", unitCount)
			
		elif str(event.source.getComponent('Title').text) == "BLOWER SHELF ":
			BS_unitCount = event.source.cycleScore + 1
			if BS_unitCount == 2000:
				BS_unitCount = 0
			if BS_unitCount < 0:	
				BS_unitCount = 0
			event.source.cycleScore = BS_unitCount
			#system.gui.messageBox(str(event.source.instanceName)+ " 2 " +str(event.source.getComponent('Title').text))
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone13", BS_unitCount)
			#system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", unitCount)
				
		elif str(event.source.getComponent('Title').text) == "HOCKEY STICK ":
			HS_unitCount = event.source.cycleScore + 1
			if HS_unitCount == 2000:
				HS_unitCount = 0
			if HS_unitCount < 0:
				HS_unitCount = 0
			event.source.cycleScore = HS_unitCount
			#system.gui.messageBox(str(event.source.instanceName)+ " 2 " +str(event.source.getComponent('Title').text))
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreHockeyStickZone10", HS_unitCount)
			#system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", unitCount)
				
		elif str(event.source.getComponent('Title').text) == "INSULATION ":
			IN_unitCount = event.source.cycleScore + 1
			if IN_unitCount == 2000:
				IN_unitCount = 0
			if IN_unitCount < 0:	
				IN_unitCount = 0
			event.source.cycleScore = IN_unitCount
			#system.gui.messageBox(str(event.source.instanceName)+ " 2 " +str(event.source.getComponent('Title').text))
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreInsulationZone8", IN_unitCount)
			#system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", unitCount)
			
		elif str(event.source.getComponent('Title').text) == "SUPERSUB DROP ":
			SS_unitCount = event.source.cycleScore + 1
			if SS_unitCount == 2000:
				SS_unitCount = 0
			if SS_unitCount < 0:	
				SS_unitCount = 0
			event.source.cycleScore = SS_unitCount
			#system.gui.messageBox(str(event.source.instanceName)+ " 2 " +str(event.source.getComponent('Title').text))
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreSuperSubZone17", SS_unitCount)
			#system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", unitCount)	
						
						
						
#DECREMENT CYCLESCORES				
	elif event.newValue < event.oldValue and event.source.CycleTimeMem > event.source.cycleTimeTarget:
		if 	str(event.source.getComponent('Title').text) == "BLOWER DROP ":
			BD_unitCount = event.source.cycleScore - 1
			if BD_unitCount < 0:
				BD_unitCount = 0
			event.source.cycleScore = BD_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerDropZone13", BD_unitCount)
		elif str(event.source.getComponent('Title').text) == "BLOWER SHELF ":
			BS_unitCount = event.source.cycleScore - 1
			if BS_unitCount < 0:
				BS_unitCount = 0
			event.source.cycleScore = BS_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone13", BS_unitCount)
		elif str(event.source.getComponent('Title').text) == "INSULATION ":
			IN_unitCount = event.source.cycleScore - 1
			if IN_unitCount < 0:
				IN_unitCount = 0
			event.source.cycleScore = IN_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreInsulationZone8", IN_unitCount)
		elif str(event.source.getComponent('Title').text) == "HOCKEY STICK ":
			HS_unitCount = event.source.cycleScore - 1
			if HS_unitCount < 0:
				HS_unitCount = 0
			event.source.cycleScore = HS_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreHockeyStickZone10", HS_unitCount)
		elif str(event.source.getComponent('Title').text) == "SUPERSUB DROP ":
			SS_unitCount = event.source.cycleScore - 1
			if SS_unitCount < 0:
				SS_unitCount = 0
			event.source.cycleScore = SS_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreSuperSubZone17", SS_unitCount)
			
			#system.gui.messageBox(time)
			#logger = system.util.getLogger("333")
			#logger.info("444")

Your issue is right here. In the event the time is NOT “05:45”, then you’ve never created a variable named BD_unitCount, yet the next line of code references such a variable. You MUST have created the BD_unitCount variable before you reference it. Do this before the RESET CYCLE SCORES area, otherwise the other usages will fail. It could also be true that it’s the other assignments failing, but it’s the same root cause.

Edit: It’s odd that your warning dialog calls out line 4, however, since that line number doesn’t match up with the code you’ve provided.

Second edit: Actually, the other areas which would fail are different variables which will all fail for the same reason.

Interesting. I’m still not sure a way out of this. Seems simple enough and I’ve tried several things.
Creating the variable outside the if but I can’t just type the variable, I can’t set it to a value either. I tried setting it to itself lol.

Sorry the code changed a little

Again, without the new code you won’t get much help.

if event.propertyName == "cycleTime":
	datetime = system.date.now()
	time = str(system.date.format(datetime, "hh:mm"))
	
#RESET CYCLE SCORES
	if 	str(event.source.getComponent('Title').text) == "BLOWER DROP ":
		if time == "05:45": #RESET CYCLE SCORE AT SHIFT CHANGE
			BD_unitCount = 0
		event.source.cycleScore = BD_unitCount
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerDropZone13", BD_unitCount)
	elif str(event.source.getComponent('Title').text) == "BLOWER SHELF ":
		if time == "05:45": #RESET CYCLE SCORE AT SHIFT CHANGE 
			BS_unitCount = 0                                   
		event.source.cycleScore = BS_unitCount	           
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone13", BS_unitCount)
	elif str(event.source.getComponent('Title').text) == "HOCKEY STICK ":
		if time == "05:45": #RESET CYCLE SCORE AT SHIFT CHANGE 
			HS_unitCount = 0                                   
		event.source.cycleScore = HS_unitCount	  
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreHockeyStickZone10", HS_unitCount)
	elif str(event.source.getComponent('Title').text) == "INSULATION ":
		if time == "05:45": #RESET CYCLE SCORE AT SHIFT CHANGE 
			IN_unitCount = 0                                   
		event.source.cycleScore = IN_unitCount	  
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreInsulationZone8", IN_unitCount)
	elif str(event.source.getComponent('Title').text) == "SUPERSUB DROP ":
		if time == "05:45": #RESET CYCLE SCORE AT SHIFT CHANGE 
			SS_unitCount = 0                                   
		event.source.cycleScore = SS_unitCount	  
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreSuperSubZone17", SS_unitCount)

#INCREMENT CYCLE SCORES
	if event.newValue < event.oldValue and event.source.CycleTimeMem < event.source.cycleTimeTarget: 
		#system.gui.messageBox(str(event.source.instanceName)+ " 1 " +str(event.source.getComponent('Title').text))
		if 	str(event.source.getComponent('Title').text) == "BLOWER DROP ":
			BD_unitCount = event.source.cycleScore + 1
			if BD_unitCount == 2000:
				BD_unitCount = 0
			if BD_unitCount < 0:
				BD_unitCount = 0
			event.source.cycleScore = BD_unitCount
			#system.gui.messageBox(str(event.source.instanceName)+ " 2 " +str(event.source.getComponent('Title').text))
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerDropZone13", BD_unitCount)
			#system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", unitCount)
			
		elif str(event.source.getComponent('Title').text) == "BLOWER SHELF ":
			BS_unitCount = event.source.cycleScore + 1
			if BS_unitCount == 2000:
				BS_unitCount = 0
			if BS_unitCount < 0:	
				BS_unitCount = 0
			event.source.cycleScore = BS_unitCount
			#system.gui.messageBox(str(event.source.instanceName)+ " 2 " +str(event.source.getComponent('Title').text))
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone13", BS_unitCount)
			#system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", unitCount)
				
		elif str(event.source.getComponent('Title').text) == "HOCKEY STICK ":
			HS_unitCount = event.source.cycleScore + 1
			if HS_unitCount == 2000:
				HS_unitCount = 0
			if HS_unitCount < 0:
				HS_unitCount = 0
			event.source.cycleScore = HS_unitCount
			#system.gui.messageBox(str(event.source.instanceName)+ " 2 " +str(event.source.getComponent('Title').text))
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreHockeyStickZone10", HS_unitCount)
			#system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", unitCount)
				
		elif str(event.source.getComponent('Title').text) == "INSULATION ":
			IN_unitCount = event.source.cycleScore + 1
			if IN_unitCount == 2000:
				IN_unitCount = 0
			if IN_unitCount < 0:	
				IN_unitCount = 0
			event.source.cycleScore = IN_unitCount
			#system.gui.messageBox(str(event.source.instanceName)+ " 2 " +str(event.source.getComponent('Title').text))
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreInsulationZone8", IN_unitCount)
			#system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", unitCount)
			
		elif str(event.source.getComponent('Title').text) == "SUPERSUB DROP ":
			SS_unitCount = event.source.cycleScore + 1
			if SS_unitCount == 2000:
				SS_unitCount = 0
			if SS_unitCount < 0:	
				SS_unitCount = 0
			event.source.cycleScore = SS_unitCount
			#system.gui.messageBox(str(event.source.instanceName)+ " 2 " +str(event.source.getComponent('Title').text))
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreSuperSubZone17", SS_unitCount)
			#system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", unitCount)	
						
						
						
#DECREMENT CYCLESCORES				
	elif event.newValue < event.oldValue and event.source.CycleTimeMem > event.source.cycleTimeTarget:
		if 	str(event.source.getComponent('Title').text) == "BLOWER DROP ":
			BD_unitCount = event.source.cycleScore - 1
			if BD_unitCount < 0:
				BD_unitCount = 0
			event.source.cycleScore = BD_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerDropZone13", BD_unitCount)
		elif str(event.source.getComponent('Title').text) == "BLOWER SHELF ":
			BS_unitCount = event.source.cycleScore - 1
			if BS_unitCount < 0:
				BS_unitCount = 0
			event.source.cycleScore = BS_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone13", BS_unitCount)
		elif str(event.source.getComponent('Title').text) == "INSULATION ":
			IN_unitCount = event.source.cycleScore - 1
			if IN_unitCount < 0:
				IN_unitCount = 0
			event.source.cycleScore = IN_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreInsulationZone8", IN_unitCount)
		elif str(event.source.getComponent('Title').text) == "HOCKEY STICK ":
			HS_unitCount = event.source.cycleScore - 1
			if HS_unitCount < 0:
				HS_unitCount = 0
			event.source.cycleScore = HS_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreHockeyStickZone10", HS_unitCount)
		elif str(event.source.getComponent('Title').text) == "SUPERSUB DROP ":
			SS_unitCount = event.source.cycleScore - 1
			if SS_unitCount < 0:
				SS_unitCount = 0
			event.source.cycleScore = SS_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreSuperSubZone17", SS_unitCount)
			
			#system.gui.messageBox(time)
			#logger = system.util.getLogger("333")
			#logger.info("444")

Sorry again I will do better. Also thanks for your time.

You haven’t moved the variable creation outside of the if statement. What is BD_unitCount supposed to be if the time is NOT “05:45”? Let’s say it is 1.

    BD_unitCount = 1
#RESET CYCLE SCORES
	if 	str(event.source.getComponent('Title').text) == "BLOWER DROP ":
		if time == "05:45": #RESET CYCLE SCORE AT SHIFT CHANGE
			BD_unitCount = 0
		event.source.cycleScore = BD_unitCount

Yes, I’ve tried that but I don’t want to set it to a value. It can’t accumulate as the day goes on if I set it to 1, each time the program runs this script it would set it to 1, no good.

Well, you have to assign it some value before you reference it - Python rules. This seems like something you should be storing in a tag, and then referencing/writing to that tag as needed. That would allow you to always have some retained/stored value. Perhaps a DB entry? No matter what, the variable must have a value before you use it on line 9 - where you get that value is up to you.

You can’t accumulate in a typical python variable–they don’t persist. Accumulate in a tag.

Thank you I’ve tried a couple different ways.
1.

You’ll need to read from the tag at the beginning to have the prior value, then modify as needed, then write it back.

In the end I’m trying to do that by writing back to the tag.

I’ve shortened the code now so we’re just working with one variable instead of 5.

if event.propertyName == "cycleTime":
	datetime = system.date.now()
	time = str(system.date.format(datetime, "hh:mm"))
	
	BD_unitCount = int("[default]ZCA/7129A/CycleScoreBlowerDropZone13")
	
#RESET CYCLE SCORES
	if 	str(event.source.getComponent('Title').text) == "BLOWER DROP ":
		if time == "05:45": #RESET CYCLE SCORE AT SHIFT CHANGE
			BD_unitCount = 0
		event.source.cycleScore = BD_unitCount
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerDropZone13", BD_unitCount)
	
#INCREMENT CYCLE SCORES
	if event.newValue < event.oldValue and event.source.CycleTimeMem < event.source.cycleTimeTarget: 
		#system.gui.messageBox(str(event.source.instanceName)+ " 1 " +str(event.source.getComponent('Title').text))
		if 	str(event.source.getComponent('Title').text) == "BLOWER DROP ":
			BD_unitCount = event.source.cycleScore + 1
			if BD_unitCount == 2000:
				BD_unitCount = 0
			if BD_unitCount < 0:
				BD_unitCount = 0
			event.source.cycleScore = BD_unitCount
			#system.gui.messageBox(str(event.source.instanceName)+ " 2 " +str(event.source.getComponent('Title').text))
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerDropZone13", BD_unitCount)
			#system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", unitCount)
			
#DECREMENT CYCLESCORES				
	elif event.newValue < event.oldValue and event.source.CycleTimeMem > event.source.cycleTimeTarget:
		if 	str(event.source.getComponent('Title').text) == "BLOWER DROP ":
			BD_unitCount = event.source.cycleScore - 1
			if BD_unitCount < 0:
				BD_unitCount = 0
			event.source.cycleScore = BD_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerDropZone13", BD_unitCount)
		

Oh… a system.read. I was just reading about this. I will try this now.

thanks

This doesn’t read from the tag. You need to use system.tag.read*().

Ok trying.

The docs are back online, have a read on readBlocking,
https://docs.inductiveautomation.com/display/DOC81/system.tag.readBlocking

You could also bind the tag value to a custom property on your component as well and just reference that in your script

Thank you @jlandwerlen I am reading that.

@nminchin I tried that first but I’m using a sorting method on my dataset template repeater parameter binding and the column values I’m sorting by were not updating so the sort method was not getting values to sort. This is why I’m now using system.tag.writeBlocking and system.tag.readBlocking. I will be looking into this again to have the project scale. This is what my script looked like when I was trying this. A lot cleaner…

if event.propertyName == "cycleTime":

#INCREMENT CYCLE SCORE
	if event.newValue < event.oldValue and event.source.CycleTimeMem < event.source.cycleTimeTarget:
		unitCount = event.source.unitCount + 1
		if unitCount == 2000:
			unitCount = 0
		if unitCount == -2000:
			unitCount = 0
			#system.gui.messageBox("2")
		event.source.unitCount = unitCount
		#system.gui.messageBox(str(unitCount))

#DECREMENT CYCLE SCORE
	elif event.newValue < event.oldValue and event.source.CycleTimeMem > event.source.cycleTimeTarget:
		#system.gui.messageBox("2")
		unitCount = event.source.unitCount - 1
		if unitCount == -2000:
			unitCount = 0
		event.source.unitCount = unitCount

I think I have this sorted out. Reading the tags first as @pturmel mentioned.

if event.propertyName == "cycleTime":
	datetime = system.date.now()
	time = str(system.date.format(datetime, "hh:mm"))
	ResetTime = "12:39"
	BD_unitCount = system.tag.readBlocking("[default]ZCA/7129A/CycleScoreBlowerDropZone13")
	BS_unitCount = system.tag.readBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11")
	IN_unitCount = system.tag.readBlocking("[default]ZCA/7129A/CycleScoreInsulationZone8")
	SS_unitCount = system.tag.readBlocking("[default]ZCA/7129A/CycleScoreSuperSubZone17")
	HS_unitCount = system.tag.readBlocking("[default]ZCA/7129A/CycleScoreHockeyStickZone10")
	
#RESET CYCLE SCORES	
	if 	str(event.source.getComponent('Title').text) == "BLOWER DROP ":
		if time == ResetTime: #RESET CYCLE SCORE AT SHIFT CHANGE
			BD_unitCount = 0
		#event.source.cycleScore = BD_unitCount
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerDropZone13", BD_unitCount)
	elif str(event.source.getComponent('Title').text) == "BLOWER SHELF ":
		if time == ResetTime: #RESET CYCLE SCORE AT SHIFT CHANGE 
			BS_unitCount = 0                                   
		#event.source.cycleScore = BS_unitCount	           
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", BS_unitCount)
	elif str(event.source.getComponent('Title').text) == "HOCKEY STICK ":
		if time == ResetTime: #RESET CYCLE SCORE AT SHIFT CHANGE 
			HS_unitCount = 0                                   
		#event.source.cycleScore = HS_unitCount	  
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreHockeyStickZone10", HS_unitCount)
	elif str(event.source.getComponent('Title').text) == "INSULATION ":
		if time == ResetTime: #RESET CYCLE SCORE AT SHIFT CHANGE 
			IN_unitCount = 0                                   
		#event.source.cycleScore = IN_unitCount	  
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreInsulationZone8", IN_unitCount)
	elif str(event.source.getComponent('Title').text) == "SUPERSUB DROP ":
		if time == ResetTime: #RESET CYCLE SCORE AT SHIFT CHANGE 
			SS_unitCount = 0                                   
		#event.source.cycleScore = SS_unitCount	  
		system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreSuperSubZone17", SS_unitCount)
		
#INCREMENT CYCLE SCORES
	if event.newValue < event.oldValue and event.source.CycleTimeMem < event.source.cycleTimeTarget: 
		if 	str(event.source.getComponent('Title').text) == "BLOWER DROP ":
			BD_unitCount = event.source.cycleScore + 1
			if BD_unitCount == 2000:
				BD_unitCount = 0
			if BD_unitCount < 0:
				BD_unitCount = 0
			#event.source.cycleScore = BD_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerDropZone13", BD_unitCount)
		elif str(event.source.getComponent('Title').text) == "BLOWER SHELF ":
			BS_unitCount = event.source.cycleScore + 1
			if BS_unitCount == 2000:
				BS_unitCount = 0
			if BS_unitCount < 0:	
				BS_unitCount = 0
			#event.source.cycleScore = BS_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", BS_unitCount)	
		elif str(event.source.getComponent('Title').text) == "HOCKEY STICK ":
			HS_unitCount = event.source.cycleScore + 1
			if HS_unitCount == 2000:
				HS_unitCount = 0
			if HS_unitCount < 0:
				HS_unitCount = 0
			#event.source.cycleScore = HS_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreHockeyStickZone10", HS_unitCount)
		elif str(event.source.getComponent('Title').text) == "INSULATION ":
			IN_unitCount = event.source.cycleScore + 1
			if IN_unitCount == 2000:
				IN_unitCount = 0
			if IN_unitCount < 0:	
				IN_unitCount = 0
			#event.source.cycleScore = IN_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreInsulationZone8", IN_unitCount)
		elif str(event.source.getComponent('Title').text) == "SUPERSUB DROP ":
			SS_unitCount = event.source.cycleScore + 1
			if SS_unitCount == 2000:
				SS_unitCount = 0
			if SS_unitCount < 0:	
				SS_unitCount = 0
			#vent.source.cycleScore = SS_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreSuperSubZone17", SS_unitCount)

						
#DECREMENT CYCLESCORES				
	elif event.newValue < event.oldValue and event.source.CycleTimeMem > event.source.cycleTimeTarget:
		if 	str(event.source.getComponent('Title').text) == "BLOWER DROP ":
			BD_unitCount = event.source.cycleScore - 1
			if BD_unitCount < 0:
				BD_unitCount = 0
			#event.source.cycleScore = BD_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerDropZone13", BD_unitCount)
		elif str(event.source.getComponent('Title').text) == "BLOWER SHELF ":
			BS_unitCount = event.source.cycleScore - 1
			if BS_unitCount < 0:
				BS_unitCount = 0
			#event.source.cycleScore = BS_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreBlowerShelfZone11", BS_unitCount)
		elif str(event.source.getComponent('Title').text) == "INSULATION ":
			IN_unitCount = event.source.cycleScore - 1
			if IN_unitCount < 0:
				IN_unitCount = 0
			#event.source.cycleScore = IN_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreInsulationZone8", IN_unitCount)
		elif str(event.source.getComponent('Title').text) == "HOCKEY STICK ":
			HS_unitCount = event.source.cycleScore - 1
			if HS_unitCount < 0:
				HS_unitCount = 0
			#event.source.cycleScore = HS_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreHockeyStickZone10", HS_unitCount)
		elif str(event.source.getComponent('Title').text) == "SUPERSUB DROP ":
			SS_unitCount = event.source.cycleScore - 1
			if SS_unitCount < 0:
				SS_unitCount = 0
			#event.source.cycleScore = SS_unitCount
			system.tag.writeBlocking("[default]ZCA/7129A/CycleScoreSuperSubZone17", SS_unitCount)
			
			#system.gui.messageBox(time)
			#logger = system.util.getLogger("333")
			#logger.info("444")