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

Framework UDP tutorial



This tutorial reuse the first tutorial, but the two modules are in two different framework instances.

Overview

In the first tutorial, we had two modules:
  • The PublishModule module increments or decrements a value cyclically
  • The EventModule module allows to click on a toggle to set if the first module should increment or decrement the value, and shows the value
We will put each of these modules in a separate framework instance, and the two instances will communicate through UDP.

Architecture

We won't change anything for the services or types configuration of the first tutorial, but we will separate the modules in two applications configurations. We will:
  • Put the EventModule in one framework instance
  • Put the PublishModule in another framework instance
And specify the Network UDP communication between these two frameworks:
tutonetwork

XML configuration

Only the applications.xml XML files has to be modified. We will define one file for each framework. The code is not impacted.

First framework instance

The first framework instance only has the EventModule:
      <applications>
         <application name="eventAppli">
            <deployment>
               <lib url="samplesEvent.jar" />
            </deployment>
            <modules>
               <module name="EventModule" id="1" > 
                  <implementation path="org.da.samples.protoframework.event.EventModule" >
                     <initEntryPoint method="init" />
                     <defaultReceiveEntryPoint method="subscribe" />
                  </implementation>
                  <interfaces>
                     <eventSend service="event" attach="attach"/>
                     <subscribe service="published" />
                  </interfaces>             
               </module>
            </modules>
         </application>           
      </applications>

tutonetwork2
We will call it from a specific filelist configuration:
      <files>
         <file url="applicationEvent.xml" />
         <file url="services.xml" />
         <file url="types.xml" />
      </files>

Second framework instance

The second framework instance only has the PublishModule:
      <applications>    
         <application name="publishAppli">
            <deployment>
               <lib url="samplesPublish.jar" />
            </deployment>
            <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>

tutonetwork3
We will call it from another specific filelist configuration:
      <files>
         <file url="applicationPublish.xml" />
         <file url="services.xml" />
         <file url="types.xml" />
      </files>

Start the two frameworks

To start the first framework instance, we use our first filelist configuration file for our configuration:
      java -jar protoframework.jar config=filelistEvent.xml
To start the second framework instance, we use our second filelist configuration file for our configuration:
      java -jar protoframework.jar config=filelistPublish.xml
However as the two framework instances do not communicate, nothing happens on the GUI for the moment:
tutonetwork4

Specify the Network configuration between the two framework instances

To allow the two framework instances to communicate, we will define a network configuration for each of the instances.

First framework instance

We will create a network configuration for the first framework instance. We need to create two Channels:
  • One Channel to send the event Service
  • One Channel to receive the publish Service

tutonetwork5
The network configuration will be:
      <network>
         <channel name="event" type="output" port="8080" size="1000">
            <service name="event" />
         </channel>  
         <channel name="publish" type="input" port="8081" size="1000">
            <service name="published" />     
         </channel>  
      </network>
We also need to specify the Network file on our first filelist configuration file:
      <files>
         <file url="applicationEvent.xml" />
         <file url="services.xml" />
         <file url="types.xml" />
         <file url="networkEvent.xml" />
      </files>

Second framework instance

We will create a network configuration for the second framework instance. We need to create two Channels:
  • One Channel to receive the event Service
  • One Channel to send the publish Service

tutonetwork6
The network configuration will be:
      <network>
         <channel name="event" type="input" port="8080" size="1000">
            <service name="event" />
         </channel>  
         <channel name="publish" type="output" port="8081" size="1000">
            <service name="published" />     
         </channel> 
      </network>
We also need to specify the Network file on our second filelist configuration file:
      <files>
         <file url="applicationEvent.xml" />
         <file url="services.xml" />
         <file url="types.xml" />
         <file url="networkPublish.xml" />
      </files>

Start the two frameworks with the Network configuration

To start the first framework instance, we use our first filelist configuration file for our configuration:
      java -jar protoframework.jar config=filelistEvent.xml
To start the second framework instance, we use our second filelist configuration file for our configuration:
      java -jar protoframework.jar config=filelistPublish.xml
Now the two applications are behaving exactly as for the first tutorial.

See also


Categories: tutorials

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