Perspective Gateway Events Bugs and Problems

Hello community, I need help resolving a bug in Perspective Gateway Events and Python Scripting associated with it.

I’m running on of the following:

Ignition Platform: 8.1.15
OPC-UA Module: 9.1.15
SQL Bridge Module: 10.1.15
MQTT Engine Module: 4.0.7
MQTT Transmission Module: 4.0.7
Vision Module: 11.1.15
Perspective Module: 2.1.15
Logix Driver: 5.1.15

Java Version: Azul Systems Inc. 11.0.14.1
Operating System: Linux | amd64

Work Environment: Grain Processing Facility
Objective: When an Operator is operating an wireless remote controller to control machinery that utilizes over +100 Status Inputs and “17” Command Outputs, I want to use the Perspective “Gateway Event Scripts” with the “Tag Change” handler to run a Python Script. This Python Script will evaluate over +100 Status Inputs when the “17” Command Output Tags are triggered. Inside the Script consists “Definition” functions that run sub-routines with Multi-threading and Time Libraries to merge back together in the Main Routine.

This script as said will evaluate Inputs and Outputs and when there is a Fault it the machinery/operation, it’ll notify you on the Client display an error/status message that is written to a writable Tag. So each time the operator puts in a command, it’ll run the script rather than constantly and evaluate all conditions and will display them. That is why I’m using Gateway Event Scripts and due to the Gateway Event Scripts Bug, I have my program running in the Project Library rather the Event Script.

Please note, due to a bug in the Gateway Event Scripts, “Variables defined in the outermost scope can not be seen by functions…” - (Gateway Event Scripts Bug). Therefore the Python Script is written and run inside the Project Library and that code is called inside the Gateway Event Script Tag Change Handler.

I’ve ran the code like a simulator in the “Script Console” and it runs without problem. I’ve monitored the “TagChangeScriptExecutor” in the “Log Activity” of the “Gateway Scripts” on the Gateway browser. Status of it has been Successful and run time duration is approx.: 1.214 seconds.

Samples will be provided below.

Gateway Event Scripts (Tag Change) - Tags: 1 of 17 is shown and all has been verified
[Tech Tag Provider]Shipping/Dock/TowerC/Swing/InSelected

Gateway Event Scripts (Tag Change) - Script:

CTower_Troubleshooter2.MainProgram() //#Call Function to Run Project Library Script

Project Library Script (CTower_Troubleshooter2) - Script:
*Note: This is only samples. I know the code isn’t the most clean and effecient, I’m still a begginer who is open to new and better methods and such :slight_smile:

#Import Libraries
import threading
import time

#Swing Input Command Tags
SwingIn = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/InSelected").value
SwingOut = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/OutSelected").value

#Swing Input Status Tags
SwingInBoard = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/InBoard").value
SwingInInt2 = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/InInternal2").value
SwingInOutput = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/InOutput").value
SwingInPermissive = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/InPermissive").value
SwingLowPressure = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/LowPressure").value
SwingNotInBoard = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/NotInBoard").value
SwingNotOutBoard = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/NotOutBoard").value
SwingOutBoard = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/OutBoard").value
SwingOutInt1 = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/OutInternal1").value
SwingOutInt2 = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/OutInternal2").value
SwingOutOutput = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/OutOutput").value
SwingOutPermissive = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/OutPermissive").value
SwingSlackRopeISH = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/SlackRopeISH").value
SwingSlackRopeOSH = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/SlackRopeOSH").value
SwingAngle = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/SwingAngle").value
SwingBrakeReleased = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/SwingBrakeReleased").value
SwingInBoomAngleLimit = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/SwingInBoomAngleLimit").value
SwingInChuteAngleLimit = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/SwingInChuteAngleLimit").value
SwingOutChuteAngleLimit = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/SwingOutChuteAngleLimit").value
SwingPumpInAuto = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/SwingPumpInAuto").value
SwingPumpInLocal  = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/SwingPumpInLocal").value
SwingPumpLowOil = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/SwingPumpLowOil").value
SwingPumpRunning = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/SwingPumpRunning").value
SwingSwash = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/SwingSwash").value
SwingZZ1P_Breaker = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/ZZ1P_Breaker").value
SwingZZ1P_Output = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/ZZ1P_Output").value
SwingZZ1Q_Breaker = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/ZZ1Q_Breaker").value
SwingZZ1Q_Output = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/ZZ1Q_Output").value
SwingZZ2_Breaker = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/ZZ2_Breaker").value
SwingZZ2_Output = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/ZZ2_Output").value
SwingZZ2P_Breaker = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/ZZ2P_Breaker").value
SwingZZ2P_Output = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/ZZ2P_Output").value
SwingZZ2Q_Breaker = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/ZZ2Q_Breaker").value
SwingZZ2Q_Output = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Swing/ZZ2Q_Output").value

#Swing In Sub-Routine
def SwingIn_Rtn():	#SWING IN COMMAND
	
	time.sleep(0.4)
	
	if SwingPumpRunning == True: 					
		if (SwingPumpInAuto == True) and (SwingPumpInLocal == False): #Check that the Swing Pump is Running in Auto for Luff Operation
			if (SwingIn == True) and (SwingSwash == 0): #Command to Lower is TRUE, but there is no Output to the Swash Plate of the Hydraulics
				
				if SwingBrakeReleased == True:
					if SwingInPermissive == True:
						if (SwingSlackRopeISH == False) and (SwingSlackRopeOSH == False): #Check for Fault
							if SwingInInt2 == True:
								if (SwingInBoomAngleLimit == False) and (SwingInChuteAngleLimit == False):
									if ((SwingZZ1P_Breaker == False) and (SwingZZ1P_Output == True) and (SwingOutBoard == True)) or ((SwingZZ1Q_Breaker == False) and (SwingZZ1Q_Output == True) and (SwingZZ2Q_Breaker == False) and (SwingZZ2Q_Output == True) and (SwingInBoard == True)):
										print("No Faults in PLC. Check Mechincal (SwingIn_Rtn()")
										  system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "No Faults in PLC. Check Mechincal")
									elif (SwingZZ1P_Breaker == True) and (SwingZZ1P_Output == True) and (SwingOutBoard == True):
										print("Swing In ZZ1P Breaker is Tripped")
										system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In ZZ1P Breaker is Tripped")
									elif (SwingZZ1Q_Breaker == True) and (SwingZZ1Q_Output == True) and (SwingInBoard == True):
										print("Swing In ZZ1Q Breaker is Tripped")	
									elif (SwingZZ2Q_Breaker == True) and (SwingZZ2Q_Output == True) and (SwingInBoard == True):
										print("Swing In ZZ2Q Breaker is Tripped")																	
										system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In ZZ2Q Breaker is Tripped")		
								elif (SwingInBoomAngleLimit == True) and (SwingInBoard == True):						
									print("Swing In Boom Angle is met at 14 Degrees")
									system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Boom Angle is met at 14 Degrees")												
								elif (SwingInChuteAngleLimit == True) and (SwingInBoard == True):						
									print("Swing In Chute Angle is met at 45 Degrees")
									system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Chute Angle is met at 45 Degrees")
							else:
								if (SwingInBoomAngleLimit == True) and (SwingInBoard == True):						
									print("Swing In Boom Angle is met at 14 Degrees")
									system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Boom Angle is met at 14 Degrees")												
								elif (SwingInChuteAngleLimit == True) and (SwingInBoard == True):						
									print("Swing In Chute Angle is met at 45 Degrees")
									system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Chute Angle is met at 45 Degrees")
						elif (SwingSlackRopeISH == True) or (SwingSlackRopeOSH == True):
							if SwingSlackRopeISH == True:
								print("Swing In Slack Rope ISH is currently Active")
								system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Slack Rope ISH is currently Active")
							elif SwingSlackRopeOSH == True:
								print("Swing In Slack Rope OSH is currently Active")
								system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Slack Rope OSH is currently Active")
							elif (SwingSlackRopeISH == True) and (SwingSlackRopeOSH == True):
								print("Both Swing In Slack Rope ISH and OSH are currently Active")
								system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Both Swing In Slack Rope ISH and OSH are currently Active")
					else:
						if SwingInInt2 == False:
							if (SwingInBoomAngleLimit == True) and (SwingInBoard == True):						
								print("Swing In Boom Angle is met at 14 Degrees")
								system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Boom Angle is met at 14 Degrees")												
							elif (SwingInChuteAngleLimit == True) and (SwingInBoard == True):						
								print("Swing In Chute Angle is met at 45 Degrees")
								system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Chute Angle is met at 45 Degrees")
						elif (SwingSlackRopeISH == True) or (SwingSlackRopeOSH == True):
							if SwingSlackRopeISH == True:
								print("Swing In Slack Rope ISH is currently Active")
								system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Slack Rope ISH is currently Active")
							elif SwingSlackRopeOSH == True:
								print("Swing In Slack Rope OSH is currently Active")
								system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Slack Rope OSH is currently Active")
							elif (SwingSlackRopeISH == True) and (SwingSlackRopeOSH == True):
								print("Both Swing In Slack Rope ISH and OSH are currently Active")
								system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Both Swing In Slack Rope ISH and OSH are currently Active")
				elif SwingBrakeReleased == False:
					if SwingInPermissive == False:	
						if SwingInInt2 == False:
							if (SwingInBoomAngleLimit == True) and (SwingInBoard == True):						
								print("Swing In Boom Angle is met at 14 Degrees")
								system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Boom Angle is met at 14 Degrees")												
							elif (SwingInChuteAngleLimit == True) and (SwingInBoard == True):						
								print("Swing In Chute Angle is met at 45 Degrees")
								system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Chute Angle is met at 45 Degrees")
							elif (SwingSlackRopeISH == True) or (SwingSlackRopeOSH == True):
								if SwingSlackRopeISH == True:
									print("Swing In Slack Rope ISH is currently Active")
									system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Slack Rope ISH is currently Active")
								elif SwingSlackRopeOSH == True:
									print("Swing In Slack Rope OSH is currently Active")
									system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In Slack Rope OSH is currently Active")
								elif (SwingSlackRopeISH == True) and (SwingSlackRopeOSH == True):
									print("Both Swing In Slack Rope ISH and OSH are currently Active")
									system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Both Swing In Slack Rope ISH and OSH are currently Active")
				
			elif (SwingIn == True) and (SwingSwash > 0): #Command to Lower is TRUE and the Output is Active		
				print("Swing In has No Command Fault Present")
				#system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing In has No Command Fault Present")	
				system.tag.writeBlocking(["[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus"], "Swing In has No Command Fault Present")	
			elif (SwingIn == False) and (SwingSwash == 0):
				print("No Command to Swing In")
				system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "No Command to Swing In")			
		elif (SwingPumpRunning == True)  and (SwingPumpInAuto == False) and (SwingPumpInLocal == True): 
			print("Swing Pump is Running in Local")
			system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing Pump is Running in Local")
		elif (SwingPumpRunning == False)  and (SwingPumpInAuto == False) and (SwingPumpInLocal == True):
			print("Swing Pump is not Running and is in Local")
			system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing Pump is not Running and is in Local")			
		elif (SwingPumpRunning == False)  and (SwingPumpInAuto == False) and (SwingPumpInLocal == False):
			print("Swing Pump is not Running and is in the Off Position")
			system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing Pump is not Running and is in the Off Position")			
		elif (SwingPumpRunning == False)  and (SwingPumpInAuto == True) and (SwingPumpInLocal == False):
			print("Swing Pump is not Running")
			system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing Pump is not Running")
	elif SwingPumpRunning != True:
		if SwingPumpLowOil == True:
			print("Swing Pump has a Low Oil Fault")
			system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing Pump has a Low Oil Fault") #WRITE to Swing In Status
		else:
			print("Swing Pump is not Running")
			system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Swing Pump is not Running") #WRITE to Swing In Status


###################### MAIN PROGRAM ##############################

def MainProgram():

###### Multi-Threading ######

	if CircPumpRunning != True: #Check if the Circulating Pumps are Running
		if Estop == True:
			print("Estop is Currently Active")
                        system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Estop is Currently Active")
			##SORRY, I CAN'T FIX THIS IN THIS POST ^^
		elif HighTemp == True:
			system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Circulating Hydraulic Pump is High Temperature")
		elif LowOil == True:
			system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Circulating Hydraulic Pump has Low Oil")
		elif CircPumpLowOilTemp == True:
			print("Circulating Hydraulic Pump has Low Oil Temperature")
			system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Circulating Hydraulic Pump has Low Oil Temperature")
		else:
			print("Circulating Hydraulic Pump is not Running")
			system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/SwingInStatus", "Circulating Hydraulic Pump is not Running")

	else:		
		SwingIn_Thread = threading.Thread(target = SwingIn_Rtn, args = ())
		SwingIn_Thread.start()		
	
	############# Rejoining Seperate Threads to the Main Thread ############

		SwingIn_Thread.join()


############### Counter to verify script is running ##############	
	        RunScriptCounter = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/RunScriptCounter").value
	        print("Run Script: " + str(RunScript))
	        RunScriptCounter += 1
	        system.tag.writeBlocking("[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/RunScriptCounter", [RunScriptCounter])	
	       if RunScriptCounter > 50:


Sorry about some indentation in the script above, it wouldn’t let me to use tab and it got ugly.

So I’ve tested this code many times and works great, but when running it on the Client Gateway, it doesn’t update unless I press saved while the operator is putting a command in to trigger the Gateway Event Script.

Any help, would greatly be appreciated, thank you!

In that old post it is referred to as a bug, but is really just a legacy scoping implementation detail that remains that way for really old backwards compatibility reasons. Maybe that will change for v8.2 or so.

One big problem:

  • Your code is not in a function definition in your library script. Library scripts are executed once upon first reference, akin to an auto-import. You are expected to define functions for code you wish to run again, and call those functions directly. Code outside of any functions is effectively initialization code for that script.

Some further advice:

  • Don’t use jython’s stdlib for fundamentals that java provides. (Don’t use jython’s time or threading.)

  • Don’t use any form of .sleep(). Use a state machine and call it with a timer event if necessary.

  • Don’t use your own threads. Use system.util.invokeAsynchronous() to create threads, and only if you really need to.

  • Don’t read a bunch of individual tags with system.tag.read(). Build a list of tag paths to read and make one call to system.tag.readBlocking(). Learn to use python’s list comprehensions to efficiently build such lists.

  • Similarly, don’t make a bunch of individual calls to system.tag.write(). Collect tag paths and values in two lists and make one call to system.tag.writeBlocking().

  • Consider passing the event object from the event script as a function argument to your main function, so it can tell which of your 17 tags changed and be optimized accordingly. You probably also should pass the initialChange flag, so your script function knows when it is being called after a project save.

2 Likes

Thank you pturmel. Although I’m pretty new to python scripting, I’d tried my best to research, learn and implement what I could with the limited time before I’m off on a long weekend. I appreciate your help.

I created Two Lists for Tag Paths and the other to hold the Values from those Tag Paths that is read from one system.tag.readBlocking(). Then created similar for the ‘system.tag.writeBlocking()’. Since I’m only working with samples, I created what I thought and understood from your message by creating a definition function with Arguments that passes values through in my Main Function. Sorry, I’m a bit confused with the intialChange flag. I’ve spent some time on it earlier with what time I have available and am struggling how to use it in the Gateway Event Script. If you’re willing to provide an example preferably with how I could use it in my case, I would greatly appreciate it. Thanks for your tips and as mentioned before, I love to learn and get better if you and or others got anymore tips or corrections I need to make.

#Asign COMMAND Variables to VALUES

### These Tags are few (17), but needed to be eveluated each time the program runs ###
#CONTROL
StartPumps = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Control/StartPumps").value
StopPumps = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Control/StopPumps").value

#LUFF
LuffLower = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Luff/LowerSelected").value
LuffRaise = system.tag.read("[Tech Tag Provider]Shipping/Dock/TowerC/Luff/RaiseSelected").value

######################################################################################################

##### CONTROL STATUSES TAG PATHS (0-3) #####
ControlStatus_TagPath = ["[Tech Tag Provider]Shipping/Dock/TowerC/Control/TransferControl", #TransferControl (0)
	"[Tech Tag Provider]Shipping/Dock/TowerC/ControlPowerSSMP", #ControlPowerSSMP (1)
	"[Tech Tag Provider]Shipping/Dock/TowerC/ControlRadio", #ControlRadio (2)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Estop"] #Estop (3)		
	
##### HYDRAULIC STATUSES TAG PATHS (0-6) #####
ControlStatus_TagPath = ["[Tech Tag Provider]Shipping/Dock/TowerC/Hydraulic/AllPumpsInAuto", #AllPumpsInAuto (0)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Hydraulic/CircPumpRunning", #CircPumpRunning (1)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Hydraulic/CircPumpInAuto", #CircPumpInAuto (2)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Hydraulic/CircPumpVentSolenoid", #CircPumpVentSolenoid (3)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Hydraulic/CircPumpLowOilTemp", #CircPumpLowOilTemp (4)					
	"[Tech Tag Provider]Shipping/Dock/TowerC/Hydraulic/HighTemp", #HighTemp (5)				
	"[Tech Tag Provider]Shipping/Dock/TowerC/Hydraulic/LowOil"] #LowOil (6)	

##### LUFF STATUSES TAG PATHS (0-20) #####
LuffStatus_TagPath = ["[Tech Tag Provider]Shipping/Dock/TowerC/Luff/BrakePumpHighTemp", #LuffBrakePumpHighTemp (0)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/BrakePumpInAuto", #LuffBrakePumpInAuto (1)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/BrakePumpInLocal", #LuffBrakePumpInLocal (2)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/BrakePumpLowOil", #LuffBrakePumpLowOil (3)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/LowerInternal1", #LuffLowerInt1 (4)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/LowerInternal2", #LuffLowerInt2 (5)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/LowerOutput", #LuffLowerOutput (6)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/LowerPermissive", #LuffLowerPermissive (7)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/LowerReadback", #LuffLowerReadback (8)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/LuffAngle", #LuffAngle (9)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/LuffBrakePumpRunning", #LuffBrakePumpRunning (10)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/LuffBrakeReleased", #LuffBrakeReleased (11)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/LuffBrakeSolenoid", #LuffBrakeSolenoid (12)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/LuffEncCount", #LuffEncCount (13)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/RaiseFastSpeedLimit", #LuffRaiseFastSpeedLimit (14)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/RaiseInternal1", #LuffRaiseInt1 (15)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/RaiseInternal2", #LuffRaiseInt2 (16)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/RaiseOutput", #LuffRaiseOutput (17)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/RaisePermissive", #LuffRaisePermissive (18)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/RaiseReadback", #LuffRaiseReadback (19)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/SlackRope"] #LuffSlackRope (20)
	
##### LUFF DRIVE STATUSES TAG PATHS (0-11) #####
LuffDriveStatus_TagPath = ["[Tech Tag Provider]Shipping/Dock/TowerC/Luff/Drive/ArmatureCurrent", #DriveArmatureCurrent (0)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/Drive/Enabled", #DriveEnabled (1)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/Drive/FieldCurrent", #DriveFieldCurrent (2)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/Drive/FuseFault", #DriveFuseFault (3)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/Drive/Lower", #DriveLower (4)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/Drive/LowerLimitFault", #DriveLowerLimitFault (5)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/Drive/MotorContactor", #DriveMotorContactor (6)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/Drive/OutputVoltage", #DriveOutputVoltage (7)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/Drive/OverSpeedFault", #DriveOverSpeedFault (8)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/Drive/Raise", #DriveRaise (9)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/Drive/RaiseLimitFault", #DriveRaiseLimitFault (10)
	"[Tech Tag Provider]Shipping/Dock/TowerC/Luff/Drive/ThermistorFault"] #DriveThermistorFault (11)

##### TROUBLESHOOTER TAG PATHS (0-...) #####
Troubleshooter_TagPath = ["[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/LuffLowerStatus", #LuffLowerStatus (0)
	"[Tech Tag Provider]Shipping/Dock/TowerC/TroubleShooter/LuffRaiseStatus"] #LuffRaiseStatus (1)
	#ADD THE REMAINDER TROUBLESHOOTER TAGS INSIDE LIST

##### TROUBLESHOOTER TAG VALUES (0-...) #####
TroubleshooterOutput_Values = [] #Create an Empty LIST
Troubleshooter_Values = system.tag.readBlocking(Troubleshooter_TagPath) #SYSTEM READS all VALUES of Tag Paths within the "LuffStatus_TagPath" LIST

for c in range(len(Troubleshooter_Values)): #"len" FUNCTION alwasy REURNS an INTEGER as it's counting the number of ITEMS in the OBJECT that you pass through	
	listTroubleshooterValues = [Troubleshooter_Values[c].value] 
	TroubleshooterOutput_Values.append(listTroubleshooterValues)
	


## LUFF STATUS LIST##LuffStatus_Values = [] #Create an Empty LIST
Luff_Values = system.tag.readBlocking(LuffStatus_TagPath) #SYSTEM READS all VALUES of Tag Paths within the "LuffStatus_TagPath" LIST

for a in range(len(Luff_Values)): #"len" FUNCTION alwasy REURNS an INTEGER as it's counting the number of ITEMS in the OBJECT that you pass through	
	listLuffValues = [Luff_Values[a].value] 
	LuffStatus_Values.append(listLuffValues)

## LUFF DRIVE STATUS LIST##
LuffDriveStatus_Values = [] #Create an Empty LIST
LuffDrive_Values = system.tag.readBlocking(LuffDriveStatus_TagPath) #SYSTEM READS all VALUES of Tag Paths within the "LuffStatus_TagPath" LIST

for b in range(len(LuffDrive_Values)): #"len" FUNCTION alwasy REURNS an INTEGER as it's counting the number of ITEMS in the OBJECT that you pass through	
	listLuffDriveValues = [LuffDrive_Values[b].value] 
	LuffDriveStatus_Values.append(listLuffDriveValues)


def LuffLower_Rtn(LuffStatus_Values, LuffDriveStatus_Values, TroubleshooterOutput_Values): #LUFF LOWER COMMAND
		
	LuffStatus_Values[0] = [False]
	
	if LuffStatus_Values[0] == [False]: #LuffBrakePumpRunning (10) *** I WOULD LIKE TO EVALUATE THE CONDITION WITH BOOLEANS, INTEGERS, AND FLOATS ***
		TroubleshooterOutput_Values[0] = "Troubleshooter LIST Output ITEM '0'"
	else:
		TroubleshooterOutput_Values[1] = "Troubleshooter LIST Output ITEM '1'"


##### MAIN PROGRAM #####				
						
LuffLower_Rtn(LuffStatus_Values, LuffDriveStatus_Values,TroubleshooterOutput_Values) #RUN Function with passing an ARGUEMENT
#print LuffStatus_Values[0]
#print LuffDriveStatus_Values[0]
print TroubleshooterOutput_Values[0]

I’m having struggles also removing the brackets around each ITEM in the LIST (Ex: [True], [False], [46.823] …) and I’ve tried removing them with the “.join” and some other methods so I can read the ITEMS in the LIST as Booleans. Please note, in these lists carries different datatypes in the system.readBlocking() such as: Booleans, Integers, and Floats that I need to evaluate them at such without losing them to a String datatype or some sorts. For the system.writeBlocking(), they only output Strings.

Sorry it’s a bit jambled, but I tried my best to put something together as much as I can with my limited knowledge and experience. All help is very much appreciated. Thank you! :slight_smile:

Fix the problem first. The bulk of your code is still not part of a function. Not a single tag read or write should be executed outside of a function. Your script should not have a “main” section that calls the function. The call comes from the gateway event.

The rest is advice to optimize, simplify, and minimize the chance of (relatively) minor problems.