Here’s the modifies question -
I have a Memory tag in default tag provider which has a datetime datatype.
The script for the valueChangedEvent of that memory tags looks something like this :
shared.process.advanced.myfunc()
Now, I have a gateway timer script which basically changes the value of that tag once a day so that the scipt can be executed.
The Gateway Event Timer script looks like :
from java.util import Date
import system
lastExecutionPath = "[default]Facility/oee-web/lastExecutionTime"
def checkTrigger(lastExecutionPath):
from java.util import Date
import system
lastExecution = system.tag.read(lastExecutionPath).value
nextExecution = Date(lastExecution.year, lastExecution.month, lastExecution.date, 02, 00, 00)
if nextExecution.time < lastExecution.time :
nextExecution = system.date.addDays(nextExecution, 1)
now = Date()
if nextExecution.time <= now.time:
system.tag.write("[default]Facility/oee-web/lastExecutionTime", now)
logger = system.util.getLogger("SyncOEEMasterData ")
logger.info('In Process !')
checkTrigger(lastExecutionPath)
As per this, the tag gets changed once a day at around 2 AM.
The memory tag has a Value changed - Tag event Script which calls a function !
Now, when I say Manually, the button on the vision changes the datetime value on the tag which makes it perform the same execution as Automatic would do !
button script :
from java.util import Date
import system
now = Date()
system.tag.write("[default]Facility/oee-web/lastExecutionTime", now)
Now, both in auto and manual mode, sometime it gives me an error saying process attribute does not exists.
So, is there any way to run the shared script once a day ? maybe with a gateway timer ?
Thanks