Home
Categories
Dictionary
Glossary
Download
Project Details
Changes Log
What Links Here
FAQ
License

UA tutorial



In this tutorial, we will learn about developing a UA (User Application). We will reuse the first tutorial, and replace the eventAppli with a User application.

Note that a UA application module is just an empty shell which is able to wire the notifications and invocations of the services to one or several ARINC 661 Clients. We will then need to develop the UA Client which will replace the eventAppli of the first tutorial.

Overview

First tutorial architecture

The first tutorial defined two services:
  • One Service published a value
  • Another Service published the state of a toggle button in case of a click event


And two applications:
  • The first PublishModule had no graphical interface and:
    • Incremented or decremented the value
    • Published cyclically the value
    • Listened to the toggle event to set if the value should increment or decrement
  • The second EventModule had a graphical interface and:
    • Subscribed to the published value and show this value
    • Showed a toggle and sends an event when the user clicks on this toggle

tuto1archi

UA Application tutorial architecture

We will replace the EventModule module by a User Application. It will be embedded in a built-in UA application. This module will:
  • Subscribe to the published value and show this value on an ARINC 661 Layer
  • Show a ToggleButton on the ARINC 661 Layer and sends an event when the user clicks on this toggle

uatutorial
The new architecture is:
uatutorialarchi

Modifying the configuration

We won't modify the types.xml or the services.xml configuration files, because we will use the same services as in the first tutorial. But we will replace the eventAppli by a User Application:
         <applications>
            <application name="uaappli">
               <deployment>
                  <lib url="UAApplication.jar" />
               </deployment>
               <modules>
                  <module name="uaappli">
                     <interfaces>
                        <eventSend service="event" attach="attach"/>
                        <subscribe service="published" />
                     </interfaces>
                  </module>
               </modules>
            </application>
            <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>
         </applications>

Specifying the Definition File

The Definition File will contain:
  • One ToggleButton
  • One Label
See the tutorial.xml for the Definition File.

We will also specify the Windowing Configuration (in our case, we will only have one Window):
      <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=50
The result will be:
uatutorial

Developing the User Application

Now we will develop our User Application:
  • The init() method will be used to add the listener which will listen to the click on the ToggleButton and invoke the event Service
  • The subscribe(ServiceInstance) method will be fired when the User Application module is notified from the publish Service
      public class UATutorial extends AbstractFunctionalUA {
        private static final int LAYER = 1;
        private static final int TOGGLE_BUTTON = 1;
        private static final int LABEL = 2;
        private SendEventServiceInstance eventService = null;

        public UATutorial() {
        }

        public void init() {
          this.eventService = (SendEventServiceInstance) module.getService("event");
          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());
              }
            }
          });
        }

        public void subscribe(ServiceInstance service) {
          if (hasChanged("value")) {
            String value = getStringValue("value");
            api.setWidgetParameter(LAYER, LABEL, ARINC661.A661_STRING, value);
            api.sendAll();
          }
        }
      }

Using the Functional UA runtime API

It is possible to use the Functional UA runtime API rather than the built-in api in the UA. In our example:
      public class UATutorial extends AbstractFunctionalUA {
      ...
        public void subscribe(ServiceInstance service) {
          if (hasChanged("value")) {
            String value = getStringValue("value");
      
               runtimeAPIHelper.setA661WidgetParameter(LAYER, LABEL, ARINC661.A661_STRING, value);
               runtimeAPIHelper.sendAllA661BufferContent();
          }
        }
      }
We can use the parrameter namer rather than its ID:
      public class UATutorial extends AbstractFunctionalUA {
      ...
        public void subscribe(ServiceInstance service) {
          if (hasChanged("value")) {
            String value = getStringValue("value");
      
               runtimeAPIHelper.setA661WidgetParameter(LAYER, LABEL, "LabelString", value);
               runtimeAPIHelper.sendAllA661BufferContent();
          }
        }
      }
or even with using the names of the Layer and the Widget:
      public class UATutorial extends AbstractFunctionalUA {
      ...
        public void subscribe(ServiceInstance service) {
          if (hasChanged("value")) {
            String value = getStringValue("value");
      
               runtimeAPIHelper.setA661WidgetParameterFromName("MyLayer", "label", "LabelString", value);
               runtimeAPIHelper.sendAllA661BufferContent();
          }
        }
      }

Setting the User Application configuration

Now we will need to specify the properties of the UA application.

We will define our UA configuration using the uaImpl and uaPath properties:
      <properties>
         <application name="uaappli" >
            <module name="uaappli" >
               <moduleProperty key="uaImpl" value="UATutorial.jar" />
               <moduleProperty key="uaPath" value="org.da.protoframework.tutorial.uaappli.UATutorial" />
               <moduleProperty key="a661Config" value="a661/tutorial.properties" />
               <moduleProperty key="includeServer" value="true" />
            </module>
         </application>
      </properties>

See also


Categories: builtin-applis | tutorials | uaappli

Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence