Hey Everyone,
I'm working with some tag scripting and a named query for the first time. The tag is part of a UDT (probably not important but you never know)
Idea is this: An operator selects a program to run in a furnace. If that value has changed, the value changed script kicks off
The point of the script is to run a named query which will grab the total run time of the program they just picked, the last time it was run in this particular furnace, and then store that time in a memory tag so that we can display on the HMI. The query works fine on it's own when tested.
In the DB, the program number is an integer, the furnace number is an integer, and the run time is set as "numeric" (PostgreSQL) but it's basically a float as it's in minutes (so 35.25 for example represents 35 minutes 15 seconds)
The Program tag is a float (just because that's how the PLC sends it even though its an integer), the Furnace tag is an integer, and the LastRunTime tag is a float.
When I run the script I get" Error trying to coerce '[.]../Furnace' to a number". Here's my script:
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
if currentValue.value != previousValue.value and initialChange == False:
projectName = "Test_IgnitionSystem"
namedQuery = "QryLastRunTime"
programNo = "[.]Program"
furnaceNo = "[.]../Furnace"
parameters = {"Furnace_No":furnaceNo, "Program_No":programNo}
lastRunTimeVal = (system.db.runNamedQuery(projectName, namedQuery, parameters))
tagPath = "[.]LastRunTime"
system.tag.writeBlocking(tagPath, lastRunTimeVal)
I feel like I'm not understanding some key piece of information here. Anyone got any ideas?
Thanks much!