Usage of the OnSubscriptionEventSource
One of the class-relationships supported by FESA3 is association.
This relationship will allow you to react on property-updates of other FESA-classes. Whenever a value-update of your subscription is received, the connected RTAction will be triggered.
This small tutorial will guide you through the needed steps.
1. DB-Registartion
First of all, you have to register the device of the class to which you want to subscribe in the Database. (If someone else did not do this already)
Use
This script in order to do so.
2. The association relationship
Define an association relationship in your class by adding the element "relationship" as child-element of "equipment-model". Below you can now add the elemnt "association".
3. The source
Since we will receive property-updates as RT-Events in FESA, we need to specifiy the proper event-source. Add an "on-subscription-event-source" to events/sources and connect it to the logical-event of your choice. The name of the source is fixed "OnSubscription", you can manage any number of subscriptions with this one source.
4. The event-mapping
In the instantiation-file go to "MyClassName/events-mapping", search for your logical-event and add an event-configuration for it. Choose "OnSubscription" and specify the context, the device and the property to which you want to connect.
Attention! In the current version the OnSubscriptionSource does not provide any diagnostics .. there is no possibility to see if a connection was successful.
Besides this, there are two known bugs currently:
- The context is irrelevant ... the subscription is always done for all available cycles.
- Currently it is not possible to subscribe from a non-muxed device to a muxed device.
5. The Data
The data which is received on a subscription is saved as data of the RTEvent, which is received by the RTAction.
Check
this code-snippet for implementation details!
6. Compile + Link everything and Start the Binary
Now your subscription should work. Make sure that the class to which you want to subscribe is as well running, and check that the specified property is reachable via the FESA-Explorer.
For the beginning it is a good idea to produce some output in your RTAction, in order to see if it is triggered from the subscription.