In MAPS, a component or interested party can be notified of a change in a Data Element (for example a Tag in Adroit) through a process called Subscribing.
Once a value has been subscribed to, the interested party will be notified of any value change, without having to poll the value periodically. This process happens automatically in the background, for example, when a Graphic Form is opened in the Operator for any behavior linked to a Data Element.
To subscribe to Data Elements programmatically, the Subscribe and Desubscribe functions, available in the MyConnection object, can be used.
Example of Subscribing:
private void SubscribeToElement(string elementName)
DataElementCollection dec = DataElementEngine.NewDataElementCollection();
//This needs to be a fully qualified name i.e. in the format "Datasource.Element.SubElement"
DataElement de = DataElementEngine.NewDataElement(elementName);
//Add this element to the collection
//NOTE: Off-course, this collection can also contain multiple elements
if (_subscriptionCallBack == null)
_subscriptionCallBack += new Shared.Events.DataElementUpdateEvent(DataElementUpdate);
MethodReturnInfo info = MyConnection.Subscribe(dec, _subscriptionCallBack);
//Pop up a message for now if the request failed (normally this should rather be handled in a different way, for example to log it to the event log
MessageBox.Show("An error occurred during the MyConnection.Subscribe request. The error was: " + info.ReturnInformation);
Example of Desubscribing:
An example graphic form with this functionality can also be downloaded here:
Data Element Subscribe Example.viz (23.7 KB)