I'm trying to do a very basic division operation within a Gateway Tag Change Script and I'm getting an error saying the tag change script cannot be executed.
#both tags called below are floats:
scrapQuantity = system.tag.readBlocking('[edge]Line1/scrap_quantity')
completedQuantity = system.tag.readBlocking('[edge]Line1/completed_quantity')
scrapRate = scrapQuantity/completedQuantity
system.tag.writeBlocking('[edge]Line1/scrap_rate', scrapRate)
The script is set to run whenever
'[edge]Line1/scrap_quantity'
or
'[edge]Line1/completed_quantity'
change value.
The script runs succesfully upon changing either tag if lines are commented out as follows:
#both tags called below are floats:
scrapQuantity = system.tag.readBlocking('[edge]Line1/scrap_quantity')
completedQuantity = system.tag.readBlocking('[edge]Line1/completed_quantity')
#scrapRate = scrapQuantity/completedQuantity
#system.tag.writeBlocking('[edge]Line1/scrap_rate', scrapRate)
But the script does not run (and shows that is is errored out in the Gateway interface) when I leave the third line uncommented as follows:
#both tags called below are floats:
scrapQuantity = system.tag.readBlocking('[edge]Line1/scrap_quantity')
completedQuantity = system.tag.readBlocking('[edge]Line1/completed_quantity')
scrapRate = scrapQuantity/completedQuantity
#system.tag.writeBlocking('[edge]Line1/scrap_rate', scrapRate)
which leads me to believe that there's an issue with my divsion operation. I had originally designated my two tags as integers instead of floats and thought that was the root cause, but even after changing them to floats I'm still getting an error when the script tries to run.
Any idea what I'm doing wrong?