I have a scheduled script configured to run every minute (as test) in the Ignition gateway, but it is not triggering. I have verified the script schedule settings, enabled the script, and confirmed the gateway scheduler is running. However, the script does not execute.
Just a simple sanity check but Schedule Scripts and editing of all gateway objects in designer, you should always press control+s a few times to make sure it saved. If your Gateway Events looks like Gateway Events it has not saved. I have found reports/Named queries/gateway events to be a bit "stickier" and double save out of habit to make sure they really go through.
Nothing on your script looks odd or obviously wrong. You're able to successfully write to system.tag.writeBlocking(["[Solingen]Solingen/BDE/TimeInterval"], [interval]) via script console? FWIW script console executes in a different scope than gateway scripts which a scheduled script is, but I don't really see that being the issue here.
I would say you should examine the results of your write, but you're saying logger.info("Is working interval: %s start: %s"%(interval,shiftStart)) does not come up at all in your gateway logs?
I have. Ive been struggling with it for 2 days now, saving and creating new ones as I go.
Yes. Just to check if maybe something in the script was making it not trigger or raise errors. Except the logs of course
Yes, It does not come up at all. Logs or anything for that matter. I try writing a regular integer to the tag, without functions, and even so it does not work
I don't see anything obviously wrong. This may have to do with a default tag group or something but I don't think so since you're explicit in your naming.
You don't see Errors popping up in your gateway log every minute do you? If so could be the stack trace of this if there is something wrong with your script that I can't tell (like mixing tabs and spaces or something).
If you don't though and there really is nothing in your gateway logs - no errors every minute, no logs every minute, then I think it might be time to call support.
Whenever I am testing new gateway scripts, I always look for that Project Restarting Gateway Scripts... thing to make sure it actually took.
Feels weird that it would still exist in your project when you closed and re-opened designer but wasn't running until you spammed S but whatever. Can't post mortem it now if its working lol.
You can search your gateway logs by Logger name - what do you see if you serach for ShiftCountScriptLogger? Just curious how far back it goes.
Just a small clarification. I copy pasted the logger from my other script (which runs every 8 hours and messed up the string formatting) so, the first 4 will account for this script. it was set on a every minute trigger basis, but not anymore
Just for future reference (and maybe optimization advice?)
start = system.date.now()
#Here I tried to check if it would work like that and test a random integer
#system.tag.writeBlocking(["[Solingen]Solingen/BDE/TimeInterval"], [55])
logger = system.util.getLogger("ShiftCountScriptLogger")
MachineGroup1= system.tag.browse('Path/to/machine1', filter={'name': '*MC*'}).getResults()
MachineGroup2= system.tag.browse('Path/to/machine2', filter={'name': '*MC*'}).getResults()
MachineGroup3= system.tag.browse('Path/to/machine3', filter={'name': '*MC*'}).getResults()
MachineGroup4= system.tag.browse('Path/to/machine4', filter={'name': '*MC*'}).getResults()
MachineGroup5 = system.tag.browse('Path/to/machine5', filter={'name': '*MC*'}).getResults()
tagPaths = [str(result['fullPath'])+"/BDE/partsHour/goodPartsShift" for result in MachineGroup1] + [str(result['fullPath'])+"/BDE/partsHour/goodPartsShift" for result in MachineGroup2]+ [str(result['fullPath'])+"/BDE/partsHour/goodPartsShift" for result in MachineGroup3] + [str(result['fullPath'])+"/BDE/partsHour/goodPartsShift" for result in MachineGroup4] + [str(result['fullPath'])+"/BDE/partsHour/goodPartsShift" for result in MachineGroup5]
tagPaths += [str(result['fullPath'])+"/BDE/partsHour/cyclesShift" for result in MachineGroup1] + [str(result['fullPath'])+"/BDE/partsHour/cyclesShift" for result in MachineGroup2] + [str(result['fullPath'])+"/BDE/partsHour/cyclesShift" for result in MachineGroup3]+ [str(result['fullPath'])+"/BDE/partsHour/cyclesShift" for result in MachineGroup4] + [str(result['fullPath'])+"/BDE/partsHour/cyclesShift" for result in MachineGroup5]
values = [[0,0,0,0,0,0,0,0]]*len(tagPaths)
system.tag.writeBlocking(tagPaths, values)
end = system.date.now()
timeElapsed = system.date.millisBetween(start, end)
logger.info("reset at %s for all counts took: %s ms"%(start,timeElapsed))
Ewww! Runtime use of system.tag.browse(). Not a good idea. You should move the whole thing to a project library script, and move the browsing to a separate function. Run that separate function from the library's top level and assign the result to a top level list (cache). Use that top level cache in your regularly executing function.
Arrange to re-run the browsing function from a user triggered event (if you add/or remove tags).
I'm a firm believer that events should be one-liners, calling library scripts to do the actual work.
Much more maintainable, and offers the option to persist constants and class definitions to boost performance. And pseudo-constants like cached tagpath lists.