I’m trying to create a script that runs every second to populate variables with various time information. Here is a snippet that I cannot get to work. I’m trying to use the Python Datetime module or if this module isn’t supported than similiar functionality.
Have you tried using tags and dynamic properties? Bind a property to the following expression and you'll get a property that updates automatically (from events firing) without the worry of getting a script to run at the right times.
Nathan - Thanks for your help. I really need alot of the datetime, period, block, dayyear information updated continously. These values will be used to fire events for other activities.
I tried to use the [System]Client/System/CurrentDateTime in a 1 sec timer script and I cannot get it to work. I also notice that dateextract function doesn’t support day of year. When ever there is change in tags period or block I need to perform tasks.
Maybe I’m still approaching this problem incorrectly. I’m definitly open to suggestions. I’m familiar with the Python datetime library.
datetime doesn’t appear to be a supported module. This post lists supported python modules. It may be dated.
My first suggestion used Dynamic Properties. It’s a powerful tool, but probably not relevant since it would require that some window be open (you want this to run continually).
You could take a similar approach with “DB SQLTags”. You could derive your period and block values from SQL Queries, then run your scripts as “Gateway Tag Script Changes” on value changes.
Could you provide a higher level description of the things you want the script to do and when?
The list of supported modules is in the user manual. Datetime is not among them. Conveniently, Java has capable date handling. Here is a re-written version of your script that should work: