PublishModule
by setting the step by using a factor
property.
applications.xml
XML file will be modified to specify an init EntryPoint. We will also define an int property for the factor.
applications.xml
XML file, by adding a factor
property:<applications> <application name="eventAppli" id="1"> <deployment> <lib url="samples1Event.jar" /> </deployment> <modules> <module name="EventModule" id="1" > <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" id="2"> <deployment> <lib url="samples1Publish.jar" /> </deployment> <modules> <module name="PublishModule" id="1" > <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> <properties> <property key="factor" type="int" /> </properties> </module> </modules> </application> </applications>
<properties> <application name="publishAppli" > <module name="PublishModule" > <moduleProperty key="factor" value="10" /> </module> </application> </properties>This file must be specified in the filelist configuration:
<files> <file url="applications.xml" /> <file url="services.xml" /> <file url="types.xml" /> <file url="properties.xml" /> </files>
PublishModule
to get a factor
from the module property.public class PublishModule { private ServiceInstance eventService = null; private ServiceInstance publishService = null; private int count = 1; private int step = 1; - private factor = 1; public void init(Module module) { eventService = module.getService("event"); publishService = module.getService("published"); factor = module.getPropertyIntValue("factor"); step = factor; } public void subscribe(ServiceInstance service) { boolean evt = eventService.getData("event").getValueAsBoolean(); if (evt) { step = -factor; } else { step = factor; } } public void publish(ServiceInstance service) { publishService.setDataIntValue("value", count); count += step; publishService.invoke(); } }
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence