eventAppli
by two different scripts.
PublishModule
had no graphical interface and:types.xml
services.xml
applications.xml
, because we will keep the same UA Application. It's only the configuration of the UA Application itself which will changesubscribe(ServiceInstance)
method will be fired when the User Application module is notified from the publish
Servicepublic class UATutorial extends AbstractFunctionalUA { private static final int LAYER = 1; private static final int TOGGLE_BUTTON = 1; private static final int LABEL = 2; public UATutorial() { } public void subscribe(ServiceInstance service) { if (hasChanged("value")) { String value = getStringValue("value"); api.setWidgetParameter(LAYER, LABEL, ARINC661.A661_STRING, value); api.sendAll(); } } }
init()
method will be used to add the listener which will listen to the click on the ToggleButton and invoke the event Servicepublic class UATutorial2 extends AbstractFunctionalUA { private static final int LAYER = 1; private static final int TOGGLE_BUTTON = 1; private SendEventServiceInstance eventService = null; public UATutorial2() { } public void init() { this.eventService = (SendEventServiceInstance) module.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) { logger.error(module, ex.getMessage()); } } }); } }
<properties> <application name="uaappli" > <module name="uaappli" > <moduleProperty key="uaConfig" value="uaTutorial.xml" /> <moduleProperty key="a661Config" value="a661/tutorial.properties" /> <moduleProperty key="includeServer" value="true" /> </module> </application> </properties>The "uaTutorial.xml" specifies the two UA Applications, each coded as a Java module:
<uas> <ua url="UATutorial.jar" path="org.da.protoframework.tutorial.uaappli.UATutorial" defaultSubscribeService="published"> <layers> <layer appliID="1" layerID="1" /> </layers> <subscribe service="published" > <entryPoint method="subscribe" /> </subscribe> </ua> <ua url="UATutorial.jar" path="org.da.protoframework.tutorial.uaappli.UATutorial2"> <layers> <layer appliID="1" layerID="1" /> </layers> </ua> </uas>
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence