if not initialChange:
var_Furnace = '1W'
tempReached = system.tag.read('somePath').value
tempReachedAck = system.tag.read('somePath').value
if tempReachedAck == 1:
pairID = system.tag.read('somePath).value
id1 = system.tag.read('somePath').value
id2 = system.tag.read('somePath').value
if pairID > 0:
#THIS LINE SOMETIMES RUNS
project.functions.tempReached(var_Furnace, id1, id2)
#THIS LINE ALWAYS RUNS
Sometimes the second the second to last line of code doesn’t run though (it appears to not run). I am doing a few database queries and updates but nothing too intensive. I use an info logger but nothing appears on my console log.
furnaceLogger = system.util.getLogger("Furnaces")
Is there a way to log some steps taking place during that function call? What should I check in my gateway to see if that function is actually executing?
I don’t have a complete answer based on the code as I have never used Gateway Event Tag Change Scripts, but I do know that the furnaceLogger.info() will log to the Gateway Status page rather than the console log.
I’ve looked at the logs around the time I ran the last test and the function was indeed “skipped” from what I can tell. There are several furnaces. Furnace #1 ran correctly, furnace #2 skipped the function, and furnace #3 ran correctly. I know the function was “skipped” because in the function being called the first thing I do is log that I am accessing that function.
furnaceLogger.info('Executing function project.functions.tempReached(var_furnace, id1, id2)')
I then triggered the same tag manually after #1 and #3 ran and the logs show #2 correctly running.
I don’t see how your project script would run. With how your code looks I’m assuming your not using 8.0. On 7.9 a project script runs for a specific project but you stated you are running this on a gateway script. A gateway script can not call a project script because it is running on the gateway and is not linked to a specific project. It would need to be a global shared script. You would need to move the script to your global shared scripts and then change your path to call the script to reflect it.
My mistake, I was grouping all the gateway stuff into one in my head.
Even though it may be able to call a project script, how are the queries set up since he said its running queries. Some places you don’t call out the project name when calling a query, others you do. Calling it from a gateway timer script it does have to be called but he should also see an error in his logs if the script is failing unless he did something in the project script to prevent it.
You would think that but I tested it before I replied because I knew I was bit by it before. If I do a simple project query that just calls a named query and leave the project out of the runNamedQuery function it works fine calling it from the script console but the gateway timer script will fail on the line that calls the project script. If I add in the project name then it will fail in the script console but the gateway timer script will run.
Yes runNamedQuery will require the project name, but runPrepQuery doesn’t.
This makes sense since runPrepQuery is a talking directly to a database where the named query is a project resource. So at the gateway level the project name makes sense here.
Have to love consistency. Personally I would prefer it if I could just put in the project name everywhere and have it run everywhere. There would be less chances of accidentally doing it the wrong way for where you call it.
runNamedQuery()'s function signature was mis-designed, and in a way that prevents it from being fixed in any backward-compatible form. The ‘project’ argument should have been after path and parameters, and optional in project contexts. I’d love to see it deprecated, with the replacement as above. Shortened to .namedQuery(), perhaps. (I also think clients should be able to call Named Queries in other projects. Not currently possible, though it can be worked around with sendRequest.)
This is not true from what I’ve seen this morning. I’m still investigating the first issue I had with a gateway script but on a separate tag change gateway script the code can most definitely not call a project script.