Hello community,
I am working on a routine that is fired through a tag change in the gateway scripts.
1.- Saves information to a database
2.- If save process fails, it saves values to memory tags and another gateway time script is in charge to retry saving data to database
3.- If retry fails in 'N' attempts, an error is registered in Ignition's log (getLogger) and an alarm is being fired as well.
Now, the customer wants a popup (a messagebox) to all the clients connected if that error ocurres.
Since this is running in gateway scope, I cannot use system.gui.messageBox am I right?
Tried using the sendMessage but maybe this doesn't work for what the customer needs?
Example
Thank you for pointing me in the right direction pturmel. Is it possible to send one message to all projects in ignition?
Or do I need to send multiple messages to all projects?
Project appears to be a required parameter. But, you can make a loop to handle the separate projects:
### Example 1: send to all running sessions
# Get information for all running sessions
sessions = system.util.getSessionInfo()
# Extract project names
projectSet = set([s['project'] for s in sessions if not s['isDesigner']])
# Send messages
for p in projectSet:
system.util.sendMessage(project=p, messageHandler='SCIAHandler',payload={'msg':"Hello world"}, scope='C')
############################################################################################
### Example 2: Send to specific projects
# Make a list of projects
projectList = ['X', 'Y', 'Z']
# Send messages
for p in projectList:
system.util.sendMessage(project=p, messageHandler='SCIAHandler',payload={'msg':"Hello world"}, scope='C')
Hi Pturmel, I am trying to do something quite similar using sendMessage as well but honestly, this is new for me, do you have any example about it? everything than I have to do for a successful process.
Regards
Jorge
Hi Jordan
I have try the code, it works in vision.
Just one more question, if I want to these message popup out in perspective module that running on a mobile end point(ZEBRA TC21), and also make the device vibrate, can this realize?
Untried, I’d say the scope of the message would need to include an ‘S’, with a session message event having a script to containing your vibrate and popup commands.