Client API

    1  Creation of the API
       1.1  Referencing extensions
       1.2  Parsing Definition Files options
       1.3  Creation of the API with a Windowing configuration
    2  API runtime
       2.1  Overview
       2.2  Connect to the Server
       2.3  Disconnect to the Server
       2.4  Set a Request for a Layer
       2.5  Set values for widgets parameters
       2.6  Listen to layers or widget events
       2.7  Sending raw byte data for a Channel
       2.8  Sending a BufferOfMapItems
       2.9  Buffer sending frequency cap
       2.10  Locking
    3  Using the API on design−time only
    4  Notes
    5  See also

The Client API allows to create a generic User Application and use it to send Buffers to a CDS. The Client API won't show any Client Interface but will allow to manage the communication wityh the Server, including receiving Server widget or exception events.
This allows to send Buffers and receive events to the Server programmatically.

Creation of the API

The API will use internally a J661 Client. To create the API, you must:
For example:
      APIFactory factory = APIFactory.getInstance();
      StatefullAPI api = factory.newStatefullAPI(properties);

Referencing extensions

Referencing extensions for the API can be performed exactly in the same way it would be done with the J661 Client itself, by referencing the path of the extensions for the extensions property in the configuration properties file. For example:

Parsing Definition Files options

There are two ways to parse Definition Files:
For example:
      List<ARINCLayer> layers = api.getLayersList(df);

Creation of the API with a Windowing configuration

With a properties file specifying a windowing configuration, it is not necessary to parse the Definition Files defined for the cockpit, the API will automatically parse those defined for the cockpit configuration. For example:

API runtime


You must note that the communication will only be possible after the API has been connected. Also sending commands and requests is done in two phases: For example:
      api.setWidgetParameter(LAYER_ID, LABEL_ID_1, ARINC661.A661_VISIBLE, true);

Connect to the Server


Disconnect to the Server


Set a Request for a Layer

Suppose that we want a layer to be visible. For example:
      api.setLayerRequest(LAYER_ID, ARINC661.A661_REQ_LAYER_VISIBLE, true);

Set values for widgets parameters

Suppose that we want a layer to be visible. For example:
      api.setWidgetParameter(APPLI_ID, LAYER_ID, LABEL_ID_1, ARINC661.A661_POS_X, 5000);
      api.setWidgetParameter(LAYER_ID, LABEL_ID_1, ARINC661.A661_VISIBLE, true);
      api.setWidgetParameter(LAYER_ID, LABEL_ID_1, ARINC661.A661_STRING, "CANNIBAL CORPSE");
      api.setWidgetParameter(LAYER_ID, LABEL_ID_1, ARINC661.A661_STYLE_SET, 12);

Listen to layers or widget events

Example when listening for a A661_EVT_SELECTION event on a PushButton:
      api.addWidgetEventListener(LAYER_ID, PUSHBUTTON_ID, new ARINCEventListener() {
      public void eventReceived(ARINCEvent evt) {
      WidgetEvent widgetEvt = (WidgetEvent) evt;
      try {
      System.out.println("Button Pressed");
      } catch (ARINCRuntimeException ex) {

Sending raw byte data for a Channel

It is possible to send directly raw byte data for a Channel rather than setting each widget parameter[1] . For example:
         api.sendBuffer(<Channel ID>, >byte array>, >byte array length>);

Sending a BufferOfMapItems

The API has a helper class which can simplify the sending of BufferOfMapItems to the CDS. See Client API for MapItems.

Buffer sending frequency cap

It is possible to cap the frequency of the Buffers sent by the API to a Server (uncapped by default). This can be set by the configuration though the client.layersUpdateCap property.
This sets the minimum time in ms between two Buffers sent by the Client API. If this value is greater than 0, Buffers sending will be merged until the update cap has been reached. The default value is −1, meaning that there is not update cap at all for Buffers sending.
The usage of this property is not to bother about the Buffer sending rate by the Client API. For example, one could call call the sendAll() method every 2 ms, but only perform the sending every 40 ms to the Server.


The StatefullAPI is optionally lockable, to allow for a safe use by more than one Thread. Clients of the API will block until the lock has been released. This can for example manage safely a Use Case when the UA updates widgets parameters regularly (such as temperature values, or a MapHorz content) in a Thread, and change widgets parameters when answering to user events.

Using the API on design−time only

It is possible to get an API just to get the structure of the Definition Files, without wanting to be able to use it at runtime. In that case, the factory should be specified as silent:
      APIFactory factory = APIFactory.getInstance();
      StatefullAPI api = factory.newStatefullAPI(properties);
Parsing the Layers is still possible. For example:
      List<ARINCLayer> layers = api.getLayersList(df);


  1. It is unlikely that you will need this option though

See Also

Category:dev Category:client Category:user

Copyright 2016 Dassault Aviation. All Rights Reserved. Documentation and source under the GPL v2 licence

Project Web Hosted by SourceForge.net Copyright 1999-2010 - Geeknet, Inc., All Rights Reserved About - Legal - Help