Gateway MessageHandler

Automating in gateway events is a very good idea, as critical operations can be made to run reliably, in one spot, regardless what is happening with client connections. However, including client UIs in the control loop is a very bad idea.

Instead, make the event script self-contained, working directly with the tags that control the process, tags and/or database entries that your UI sets to provide guidance, and tags that your script updates to provide UI feedback. The latter would often be dataset tags or document tags to deliver chunks of fresh data conveniently.

With this arrangement, you need few, if any, message handlers. Your UI would include tag bindings to display the process and feedback tags, and entry fields and/or command scripts that would update the guidance tags and database entries. Treat the gateway event as if it were an extra task running alongside your PLC's realtime tasks. Run it fast enough so that guidance is acted upon with reasonably low latency.

If you still think you need to send messages from gateway scope into your perspective sessions, see this topic for the nuances:

1 Like