interfaces
element. For example:<module name="FlightManagementSystem"> <interfaces> <subscribe service="position" /> <eventReceived service="directTo"/> </interfaces> </module>
<module name="FlightManagementSystem" id="1" > <interfaces> <subscribe service="position" uri="http://mydomain.com/aircraft" /> <eventReceived service="directTo"/> <requestReceived service="computeFlightPlan"/> </interfaces> </module>
<publish service="position" />
<cyclic service="position" frequency="100ms" />
<subscribe service="position" />
<listen service="position" />
. See also listening to a Service<listenAll />
. See also listening to all Services.cyclic
interface not to call the invocation automatically by setting the autoInvoke
attribute to false
:<interfaces> <cyclic service="myService" autoInvoke="false" frequency="100ms" /> </interfaces>In that case the
invoke()
will have to be called in the method.
cyclic
interface not to be activated at start by setting the activated
attribute to false
:<interfaces> <cyclic service="myService" activated="false" frequency="100ms" /> </interfaces>It is possible to activate or deactivate the cyclic invocation of the service by using the PublishCyclicServiceInstance.setActivated(boolean) method
<module name="MyModule" > <implementation path="org.PublishModule" > <initEntryPoint method="init" /> <defaultSendEntryPoint method="publish" /> </implementation> <interfaces> <cyclic service="myService" frequency="100ms" /> </interfaces> </module>and:
<services> <publish name="myService"> <data name="value" type="int" /> </publish> </services>We can have the following code for the
publish
method:public class PublishModule { private int count = 0; public void init(Module module) { } public void publish(ServiceInstance service) { publishService.setDataIntValue("value", count); count++; } }
<eventSend service="position" />
<eventReceived service="position" />
<listen service="position" />
. See also listening to a Service<listenAll />
. See also listening to all Services.resetAfterSend
attribute. For example:<eventSend service="position" resetAfterSend="true" />
cyclicEvent
interface not to call the invocation by setting the autoInvoke
attribute to false
:<interfaces> <cyclicEvent service="tick" autoInvoke="false" frequency="1s" /> </interfaces>
cyclicEvent
interface not to be activated at start by setting the activated
attribute to false
:<interfaces> <cyclicEvent service="myService" activated="false" frequency="100ms" /> </interfaces>It is possible to activate or deactivate the cyclic invocation of the service by using the SendEventCyclicServiceInstance.setActivated(boolean) method
<module name="MyModule" > <implementation path="org.PublishModule" > <initEntryPoint method="init" /> <defaultSendEntryPoint method="publish" /> </implementation> <interfaces> <cyclicEvent service="tick" frequency="1s" /> </interfaces> </module>and:
<services> <event name="tick"> <data name="time" type="int" /> </event> </services>We can have the following code for the
publish
method:public class PublishModule { private int time = 0; public void init(Module module) { } public void publish(ServiceInstance service) { publishService.setDataIntValue("time", count); time++; } }
<requestSend service="position" />
<requestReceived service="position" />
<listen service="position" />
. See also listening to a Service<listenAll />
. See also listening to all Services.timeOut
attribute specified how long (in ms) the subscriber must wait before the response is declared as timed out. The default value is 300ms. For example:<requestSend service="position" timeOut="500ms" />A value of "none" for the
timeOut
attribute specifies that there is no timeOut specified for the request, which means that the response will never *be decklared as time out regardless of the time used by the perovider to return the response.
RequestServiceInstance.invokeBlocking()
method allows to send a request and wait in the sender thread until the response has been received or the timeout has elapsed. For example:requestService.invokeBlocking(); Data<?> data = requestService.getData("result"); ...
computeFlightPlan
Service:<applications> <application name="aircraft" id="1"> <modules> <module name="Display" id="1" > <interfaces> <requestSend service="computeFlightPlan"/> </interfaces> </module> <module name="FlightManagementSystem" id="2" > <interfaces> <requestReceived service="computeFlightPlan"/> </interfaces> </module> <module name="debugModule" id="2" > <interfaces> <listen service="computeFlightPlan"/> </interfaces> </module> </modules> </application> </applications>
listen
element which declares that the module is listening to a particular service, the listenAll
element declares that the module is listening to all services defined for the framework.<applications> <application name="aircraft" > <modules> <module name="debugModule" > <interfaces> <listenAll/> </interfaces> </module> </modules> ... </application> </applications>
<applications> <application name="application" id="1"> <modules> <module name="myModule" id="1" > <interfaces> <publish service="publish" /> <subscribe service="publish" /> </interfaces> </module> </application> </applications>In this example, the module will be notified of its own invocation of the
publish
service.
attach
attributereceive
entryPoint, with the receive(ServiceInstance service)
signature is used for the "directTo" service notificationreceivePosition
entryPoint, with the receivePosition(ServiceInstance service)
signature is used for the "position" service notificationreceiveRequest
entryPoint, with the receiveRequest(ServiceInstance service)
signature is used when receiving the "computeFlightPlan" service request<module name="FlightManagementSystem" id="1" > <implementation path="org.da.aircraft.fms.FMS" > <initEntryPoint method="init" /> <startEntryPoint method="start" /> <defaultReceiveEntryPoint method="receive" /> </implementation> <interfaces> <subscribe service="position" > <entryPoint="receivePosition"/> </subscribe> <eventReceived service="directTo"/> <requestReceived service="computeFlightPlan" > <entryPoint="receiveRequest"/> </requestReceived> </interfaces> </module>
triggerEntryPoint
element. For example:<module name="module1"> ... <interfaces> <eventReceived service="service1" > <triggerEntryPoint method="trigger" /> </eventReceived> <eventSend service="service2" /> </interfaces> </module>The signature of this method must be:
<method_name>(ServiceInstance service, ServiceInstance service)
. The method will be called after the notification if the service is triggering another one. The first argument is the triggering service (which must be a subscribed event service), the second is the triggered service (which must be a provided event service).
eventService = module.getService("event"); eventService.setDataBooleanValue("event", true); eventService.invoke();The method will return true if the invocation has been successful, and false in the following cases:
entryPoint
defined for a Service subscriber, the associated method will be called upon notification of this Service.public void subscribe(ServiceInstance service) { int count = publishService.getData("value").getValueAsInt(); }
public class MyModule { private ServiceInstance initService = null; public void init(Module module) { initService = module.getService("initService"); } public void subscribe(ServiceInstance service) { if (initService.isNotified()) { // do something } } }
<module name="MyModule" > <implementation path="org.da.MyModule" > <initEntryPoint method="init" /> <initEntryPoint method="start" /> <defaultReceiveEntryPoint method="receive" /> </implementation> <interfaces> <eventSend service="sendEvent" /> <eventReceived service="sendEvent"/> </interfaces> </module>and the following code for this module. In this case the module invoke the
sendEvent
service at start, and it is also notified from this service:public class MyModule { private ServiceInstance sendEventService = null; public void init(Module module) { sendEventService = module.getService("sendEvent"); } public void start() { sendEventService.invoke(); } public void subscribe(ServiceInstance service) { if (service.invokedByMe()) { System.out.println("The MyModule module invoked the sendEvent service"); } } }
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence