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

Functional UA runtime API tutorial



In this tutorial, we will learn about developing a UA (User Application) using the Functional UA runtime API. We will reuse the UA tutorial, and code the UA using the functional UA API rather than the default ARINC 661 API.

Overview

UA tutorial architecture

The UA tutorial has the following architecture, which we will reuse:
  • The first PublishModule had no graphical interface and:
    • Increment or decrement the value
    • Published cyclically the value
    • Listened to the toggle event to set if the value should increment or decrement
  • The second EventModule is our User Application and:
    • 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

uatutorialarchi

Modifying the configuration

We will only need to specify the properties of the UA application.

This time will define our UA configuration using the uaConfig property:
      <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>
For our configuration:
  • We have to define the URL of our jar file, and the path of the class implementing the UA, which will replace the uaImpl and uaPath properties:<ua url="UATutorial2.jar" path="org.da.protoframework.tutorial2.uaappli.UATutorial2">
  • The only Layer which is managed by this UA is the Layer with the Applciation ID 1, and Layer ID 1:<layer appliID="1" layerID="1" />
  • The only service on which this UA subscribes is the published service:<subscribe service="published" >
This leads us to the following uaTutorial.xml file:
      <uas>
         <ua url="UATutorial2.jar" path="org.da.protoframework.tutorial2.uaappli.UATutorial2" defaultSubscribeService="published">
            <layers>
               <layer appliID="1" layerID="1" />
            </layers>
            <subscribe service="published" >
               <entryPoint method="subscribe" />
            </subscribe>
         </ua>
      </uas>

Developing the User Application

We will change our User Application to use the runtimeAPIHelper rather than the api field.

In this case, we don't need any more to use the Application ID? the Layer ID, the WIdget ID, or even the Parameter ID, but:
  • We have only one Layer, so this Layer is the default Layer, which means that we never need to specify the Layer
  • We can use the Widget name rather than it's int ID
  • We can use the parameter name rather than it's int ID
      public class UATutorial2 extends AbstractFunctionalUA {
        private SendEventServiceInstance eventService = null;

        public UATutorial() {
        }

        public void init() {
          this.eventService = (SendEventServiceInstance) module.getService("event");
          // listen to widgets events
          runtimeAPIHelper.addA661WidgetEventListener("toggleButton", 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");
            runtimeAPIHelper.setA661WidgetParameterFromName("label", "LabelString", value);
            runtimeAPIHelper.sendAllA661BufferContent();
          }
      }

Setting the User Application configuration

Now we will need to specify the properties of the UA application:
      <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