Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Batch Management

Event Clients

  • Last UpdatedNov 03, 2021
  • 3 minute read

If Batch Events are enabled on a AVEVA Batch Management Server, those events can be retrieved and used by any ArchestrA Event Services compatible client. ArchestrA scripting using the Event Scripting script library (aaSLIB) is considered a client. This script library is installed with the AVEVA Batch Management Components for ArchestrA IDE feature, which needs to be installed on an ArchestrA IDE node. The file ArchestrA.Events.Scripting.aaSLIB is located in the ...\Batch Management\AppObjects directory and can be imported into the Galaxy. To import a library from within the ArchestrA IDE, on the Galaxy menu, point to Import, and then click Script Function Library.

Note: Other ArchestrA Event Service compatible clients may also be available. These are installed separately from AVEVA Batch Management.

The typical workflow for a client using the Event Scripting script library is described below.

  1. [MonitorEvents.ConnectToEventService method] Connect to AVEVA Batch Management Server Event Service to establish a new event subscription. Receive a ConnectionId, which can be used to interact with subscription. This is often done in an OnScan script.

  2. Specify the filters for the subscription. Without any filter, the client would receive all the events fired from the AVEVA Batch Management Server, which would have performance implications and be unnecessary. Filters should be added right after Connecting (that is, in the same script).

    • [MonitorEvents.AddEventFilter method] Multiple filters can be added to a subscription. These are OR'ed together. For example, a client can request to receive all events where the EventType equals "Batch" OR EventType equals "Phase".

    • [MonitorEvents.NarrowEventFilter method] Each filter can have multiple conditions. These conditions are AND'ed together with the original filter to narrow its scope. For example, a client can request to receive all events where the EventType equals "Batch" AND the EventCodeName equals "Initialize".

  3. [MonitorEvents.StartRequestingEvents method] Activates the subscription. This method must return True before you can get events.

  4. [MonitorEvents.GetNextEvent method] Periodically get the events for the subscription. This should be done fairly frequently (for example, at least every few seconds). It is a very fast check if no events are available. This is typically done in a "periodic" Execute script. The script may also need to be configured to execute asynchronously if processing the events could be time consuming.

    • Multiple events may be waiting to be processed. Therefore, this script will process them one at a time (in a loop). Each event has some system properties, which all events share (ex. EventType). Events also have their own context properties, which vary depending on the value of the EventType system property.

    • The script performs external/custom actions during the processing of each event.

  5. [MonitorEvents.DisconnectFromEventService method] Terminate and cleanup an existing event subscription. This is often done in an OffScan script.

If many different events need to be monitored by client script, this workflow can be repeated many times across many ApplicationObjects. Subscriptions are optimized within each Application Engine (aaEngine.exe), performing only one poll (periodically in the background) for all outstanding subscriptions to a particular AVEVA Batch Management Server. However, performance could still be impacted by increasing the number of subscriptions or having a large number of events being processed.

The connection lifetime of a subscription does not need to be maintained by the client script. If a connection to the AVEVA Batch Management Server Event Service is lost (for example, the server becomes unavailable), it will be reestablished when the AVEVA Batch Management Server becomes available again.

Note: If the AVEVA Batch Management Server is set up for redundancy, two separate subscriptions will need to be set up, with one pointing to each server in the redundant pair. The subscriptions should be configured with the same filters. They will also need separate GetNextEvent loops. While running, the backup server will not send any events until a switchover occurs. After a switchover, the failed master should stop sending events.

For more information on using the event scripting API, see the ArchestrA Events Script Function Library documentation that is installed with the aaSLIB file. For a AVEVA Batch Management example of scripting, see "Example: Subscribe to "Batch Done" and "Custom RecipeMessage" Events".

TitleResults for “How to create a CRG?”Also Available in