PublishModule
module increments or decrements a value cyclicallyEventModule
module allows to click on a toggle to set if the first module should increment or decrement the value, and shows the valuePublishModule
as an autodescripted module.
PublishModule
in the applications definition, we will point to a jar file specifying the module implementation in its manifest.PublishModule
module was:<applications> ... <application name="publishAppli"> <deployment> <lib url="samplesPublish.jar" /> </deployment> <modules> <module name="PublishModule" > <implementation path="org.da.samples.protoframework.publish.PublishModule" > <initEntryPoint method="init" /> <defaultReceiveEntryPoint method="subscribe" /> <defaultSendEntryPoint method="publish" /> </implementation> <interfaces> <eventReceived service="event"/> <cyclic service="published" frequency="200ms" attach="attach"/> </interfaces> </module> </modules> </application> <applications>We will keep the same definition, but:
PublishModule
module, because an autodescripted module only cotnains one module<application name="publishAppli"> <modules> <module name="PublishModule" > <implementation path="org.da.samples.protoframework.publish.PublishModule" > <initEntryPoint method="init" /> <defaultReceiveEntryPoint method="subscribe" /> <defaultSendEntryPoint method="publish" /> </implementation> <interfaces> <eventReceived service="event"/> <cyclic service="published" frequency="200ms" attach="attach"/> </interfaces> </module> </modules> </application>
<services> <event name="event" id="1" > <data name="event" type="bool" /> </event> <publish name="published" id="2" > <data name="value" type="int" /> </publish> </services>The Types:
<types> <simpleType name="bool" baseType="boolean" /> <simpleType name="int" baseType="int" /> </types>
public class PublishModule { private ServiceInstance eventService = null; private ServiceInstance publishService = null; private int count = 1; private int step = 1; public void init(Module module) { eventService = module.getService("event"); publishService = module.getService("published"); } public void subscribe(ServiceInstance service) { boolean evt = eventService.getData("event").getValueAsBoolean(); if (evt) { step = -1; } else { step = 1; } } public void publish(ServiceInstance service) { publishService.setDataIntValue("value", count); count += step; publishService.invoke(); } }
samplesPublish.jar
jar file:Modules: applications.xml Services: services.xml Types: types.xml
<applications> <application name="eventAppli" > <deployment> <lib url="samplesEvent.jar" /> </deployment> <modules> <module name="EventModule" > <implementation path="org.da.samples.protoframework.event.EventModule" > <initEntryPoint method="init" /> <defaultReceiveEntryPoint method="subscribe" /> </implementation> <interfaces> <eventSend service="event" attach="attach"/> <subscribe service="published" /> </interfaces> </module> </modules> </application> <application name="publishAppli" > <deployment> <lib url="samplesPublish.jar" /> </deployment> <modules> <module name="PublishModule" > <implementation path="org.da.samples.protoframework.publish.PublishModule" > <initEntryPoint method="init" /> <defaultReceiveEntryPoint method="subscribe" /> <defaultSendEntryPoint method="publish" /> </implementation> <interfaces> <eventReceived service="event"/> <cyclic service="published" frequency="200ms" attach="attach"/> </interfaces> </module> </modules> </application> </applications>To use our newly created autodescripted module, we now have a much more simple description for the
PublishModule
module:<applications> <application name="eventAppli" > <deployment> <lib url="samplesEvent.jar" /> </deployment> <modules> <module name="EventModule" > <implementation path="org.da.samples.protoframework.event.EventModule" > <initEntryPoint method="init" /> <defaultReceiveEntryPoint method="subscribe" /> </implementation> <interfaces> <eventSend service="event" attach="attach"/> <subscribe service="published" /> </interfaces> </module> </modules> </application> <application name="publishAppli" > <deployment> <lib url="samplesPublish.jar" /> </deployment> </application > </applications>
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence