def wLog(msg):
f = open("C:\\Users\\lucm\\Desktop\\MyLogFile.txt","a")
from time import strftime
timestr = strftime("%Y-%m-%d %H:%M:%S")
m = "[" + timestr + "] " + msg + "\n"
f.write(m)
f.close()
I use many script directly into my tags and all fired great, but this time I want to put it into the gateway event and can’t understand why the event is not fired.
Gateway Event Tag Change scripts (and any other event script in this section) belong to a project, so they need to reference a function defined in the project (or a parent’s) script library.
The tag change scripts defined directly on tags are the ones that do not belong to any project and will use the project designated as “Gateway Scripting Project”.
Also, does user lucm exist on the gateway? And would the gateway service have access to that user’s directory? (Generally not.) A proper test would be to write to a folder that is owned by the Ignition service.
You might have entries in your gateway log showing a failure to open the given file.
I think have different logging methods for testing vs. production is a disaster in the making. Your wLog() function looks pretty fragile to me. Aside from that, you didn’t indicate if there are any messages in your real gateway log. I’ll be out of touch today, but that’s where I would look were I in your shoes.
Look closer at @Kevin.Herron’s comment: Project tag change events have access to the scripts in their inheritence hierarchy, which doesn’t necessarily include the scripts accessible to the Gateway Scripting Project that tag events use.
I don’t want a robust solution, I just use that function as consol to print something to trace my code. When I put it into a tag on quality change event it work fine. My gateway tag change script is in the same project of my _Functions.wLog function and that project is also my Gateway Scripting Project. I think it have no reason to not fired.
It’s an inheritable project. Why inheritable can have Startup/Shutdown event and not Tag, Timer and message event.
I have many projects that I want to base that project and all needs to have same tags event. I want a simple way to configure and update all projects and using an inheritable project semms to be the bes way to do it.
Startup and Shutdown scripts from an inheritable project should not run. If they do, this is most probably a bug.
Are you sure it is not an other, runnable project that is executing those scripts? I am not sure, but i think inherited projects may shutdown and restart when a 'parent' project is changed.
I found why my gateway event tag script in my inheritable project wasn’t publish. The gateway event on my heritate project is overrided. I don’t find on right click a solution to revert it.
hey brother how did you solve your problem? i have the same issue but im using timer,
it seems the event i generated are not showing in status>gateway scripts