PublishModule
, which:EventModule
, which:EventModule
will be an UA application scripted in groovyPublishModule
will be an application scripted in groovyservices.xml
XML file:event
service carries the state of the toggle button. It is an event Service because the service should only be invoked when the state of the toggle button changespublished
service carries the value. It is a publish Service because the service should be invoked cyclically<services> <event name="event" id="1" > <data name="event" type="bool" /> </event> <publish name="published" id="2" > <data name="value" type="int" /> </publish> </services>
bool
type is a booleanint
type is an inttypes.xml
XML file:<types> <simpleType name="bool" baseType="boolean" /> <simpleType name="int" baseType="int" /> </types>
applications.xml
XML file:eventAppli
only contains the EventModule
. This Module:event
servicepublished
servicepublishAppli
only contains the PublishModule
. This Module is coded in groovy and:published
serviceevent
service<applications> <application name="eventAppli" id="1"> <deployment> <lib url="UAApplication.jar" /> </deployment> <modules> <module name="EventModule" id="1" > <interfaces> <eventSend service="event" attach="attach"/> <subscribe service="published" /> </interfaces> </module> </modules> </application> <application name="publishAppli" id="2"> <modules> <groovyModule name="PublishModule" id="1" > <interfaces> <eventReceived service="event"/> <cyclic service="published" frequency="200ms" attach="attach"/> </interfaces> </groovyModule> </modules> </application> </applications>For now we did not bridge our services to any implementation for our two applications. This will be done in the next step.
published
serviceevent
servicepublished
service to be invoked cyclically every 200 milliseconds in the module XML specification:<cyclic service="published" frequency="200ms" attach="attach"/>We will create a
publish.groovy
script to implement the behavior of this Module:subscribe
method will be notified of the event
Service. Depending on the value of the event
data, a step
variable will have a 1 or -1 valuepublish
method will be invoked cyclically for the published
Service. The current value will be incremented or decremented, and the Service will be notified with this current valueint step = 1; int count = 1; public void subscribe(ServiceInstance service) { boolean evt = service.getData("event").getValueAsBoolean(); if (evt) { step = -1; } else { step = 1; } } public void publish(ServiceInstance service) { service.setDataIntValue("value", count); count += step; service.invoke(); }
PublishModule
, we must specify in the applications.xml
XML file the bridge between this module and its implementation:PublishModule
<application name="publishAppli" id="2"> <modules> <groovyModule name="PublishModule" id="1" > <groovyImplementation path="publish.groovy" > <defaultSendEntryPoint method="publish" /> </groovyImplementation> <interfaces> <eventReceived service="event"/> <cyclic service="published" frequency="200ms" attach="attach"/> </interfaces> </groovyModule> </modules> </application>
<cockpit> <DFFiles> <df path="tutorial.xml" /> </DFFiles> <windows> <windowDef name="Window" width="8000" height="3000" x="0" y="0" /> </windows> <configs border="255,255,255" borderWidth="3"> <display id="1" name="simple" width="8000" height="3000" defaultLayout="1"> <layout name="layout" id="1"> <window name="Window"> <layer layerID="1" /> </window> </layout> </display> </configs> </cockpit>Now we will specify the ARINC 661 configuration for both the ARINC 661 Client and the ARINC 661 Server:
graphics=DefGraphics.xml ui=LookAndFeel.xml pictures=DefPictures.xml lf=JavaFX supplement=6 warnForUndefAttrs=false serverInputPort=8080 serverOutputPort=8081 serverInputSize=50000 serverOutputSize=200 server.autoVisible=true logServerArea=true windowManager=windows server.windows=tutorialWindow.xml server.computeLayerSize=false server.menus=true server.uiCombo=true maximumQueueSize=50The result will be:
init()
method will be used to add the listener which will listen to the click on the ToggleButton and invoke the event Servicesubscribe(ServiceInstance)
method will be fired when the User Application module is notified from the publish
Serviceint LAYER = 1; int TOGGLE_BUTTON = 1; int LABEL = 2; SendEventServiceInstance eventService = null; public void init() { this.eventService = (SendEventServiceInstance) context.getModule().getService("event"); // listen to widgets events api.addWidgetEventListener(LAYER, TOGGLE_BUTTON, new ARINCEventListener() { public void eventReceived(ARINCEvent evt) { WidgetEvent widgetEvt = (WidgetEvent) evt; try { boolean isSelected = ((Boolean) widgetEvt.getValues().get(0)); eventService.setDataBooleanValue("event", isSelected); eventService.invoke(); } catch (ARINCRuntimeException ex) { context.error(ex.getMessage()); } } }); } public void subscribe(ServiceInstance service) { if (helper.hasChanged("value")) { String value = helper.getStringValue("value"); api.setWidgetParameter(LAYER, LABEL, ARINC661.A661_STRING, value); api.sendAll(); } }
<properties> <application name="uaappli" > <module name="uaappli" > <moduleProperty key="script" value="uaScript.groovy" /> <moduleProperty key="a661Config" value="a661/tutorial.properties" /> <moduleProperty key="includeServer" value="true" /> </module> </application> </properties>
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence