A very basic Federation : Lesson 1

I will show how to build a complete very basic Federation with just one Federate called Tank.

To illustrate the relations of the used classes, I created a simple diagram. For clarity, all attributes and methods were removed from diagram.


Basic Federation

Basic Federation

The Main class ( program start point ) will act as the Federate itself. You may want to call it “TankFerate.java”. I prefer “Main” to tell you it is the entry point.

The main class will use the “TankClass” class, wich will act as a kind of object manager. Its function is to manage all Tank objects, hold the Tank class handle given by the RTI and all attributes handles. It will publish the Tank attributes or, if used by other Federate, subscribe to the Tank attributes changes.

The “TankObject” will represent all Tanks created by our simulation. It will hold the object handle given by the RTI.

These two classes can be used by other Federates. In this case, “TankClass” will just subscribe to Tank attribues and each “TankObject” will represent a Tank discovered by the Federate.

This approach is of my preference and there are no rules about this ( as I can remember ). Some may find more confortable not to delegate so much and write all code in the Federate class.

To keep the basic, I created a SOM file with just one class and one attribute, nothing more ( well, I kept the modelIdentification tag too ). For the FOM, we will use the Standard MOM and Initialization Module.

You can download all Java project, a compiled runnable JAR and the SOM file from here.

If you want to compile the sources, you will need the Portico RTI library. You can download a compiled JAR from here ( v2.0.0 ) .

Here is the class definition of our Tank object. You can see the complete SOM file here.

    <semantics>A Tank</semantics>
      <semantics>The Tank Model</semantics>

Here you can see our Tank class and its “Model” attribute.

In the next post I will start creating the Main class.


Add Comment