Expression tag - runScript() issue (ignition 7.9)

Creating a new expression tag that when holds a True value runs one of my functions every 5 seconds.

Tag Diagnostics state “Error evaluating tag: Error executing script for runScript() expression:shared.ofs.main.monitorPtValueReset()”
image

Within the expression the code written is

runScript("shared.ofs.main.monitorPtValueReset()", 5000)

image

The function is created to intermittently check the line status and stop downtime spans once the line is running. Code is as follows:

def monitorPtValueReset(tagPath):	
		
	
	readURL = SERVER + TEST_LINE + LINE_POSTFIX + RUNNING_CHECK_ENDPOINT
	response = system.net.httpGet(readURL, username=USER, password=PASS)
	
	r = system.util.jsonDecode(response)
	if(r['spanClass'] == 'Running'):
		running = True
	else:
		running = False
		
	
	if (running):				
		#Build corresponding monitor point paths
 	    currentLine = tagPath.split('/')[0]
		currentLinePost = tagPath.split('/')[1]
		current_SMP_path =  currentLine + "/" + currentLinePost + "/MP_SKUChange"
		current_BMP_path =  currentLine + "/" + currentLinePost + "/MP_BatchChange"
	
		# there will be instances where one MP is true while the other is false 
        # to prevent object finding issues, only run reset on MP that requires it 
		
		current_SMP_status = system.tag.read(current_SMP_path).value 
		if  (current_SMP_status):
			# reset monitor points and stop relative spans via endpoint
			system.tag.write(current_SMP_path, False)
			endpointURL = SERVER + TEST_LINE + LINE_POSTFIX + SIZE_STOP
			system.net.httpGet(endpointURL,username=USER, password=PASS)
			
		current_BMP_status = system.tag.read(current_BMP_path).value 
		if  (current_BMP_status):
			system.tag.write(current_BMP_path, False)
			endpointURL = SERVER + TEST_LINE + LINE_POSTFIX + BATCH_STOP
            system.net.httpGet(endpointURL,username=USER, password=PASS)

I’m hoping a pair of fresh eyes can help resolve the error. Thank you

I don’t see where you are passing a tag path to monitorPtValueReset

1 Like

it is utilised to read the relevant line that triggers the script to subsequently create other relevant tag paths

for example:
within if (running): statement

if (running):				
		#Build corresponding monitor point paths
 	    currentLine = tagPath.split('/')[0]
		currentLinePost = tagPath.split('/')[1]
		current_SMP_path =  currentLine + "/" + currentLinePost + "/MP_SKUChange"
		current_BMP_path =  currentLine + "/" + currentLinePost + "/MP_BatchChange"

Yet:
runScript("shared.ofs.main.monitorPtValueReset()", 5000)

Try something like this;

runScript("shared.ofs.main.monitorPtValueReset", "[default]tag", 5000)
2 Likes

ahhhh
Apologies, I missed your meaning

resolved - thank you!

1 Like