The MapViewer Federate : Part 2

Go to Part 1.

This post I’ll cover the FOM and SOM creation of our Federation. First, we must to plan the FOM module structures.

As I said, we’ll have one basic military unit and some descendant units, like tank and aircraft. I think the following picture must describe the structure.

Class Hierarchy

Class Hierarchy

This is because the MapViewer must to know any kind of unit, so it will subscribe to the BasicUnit attributes  Of course this situation will not allow us to access the unit details like model and maxRange. If it is important to you then you must subscribe to each child unit individually.

Let’s see the FOM XML file. This file will be common to all Federation ( It’s the FOM ! ), so it will describe the BasicUnit. You can put your Interactions here too, if any exists. File unit.xml:

<objects>
    <objectClass>
        <name>HLAobjectRoot</name>
  
        <objectClass>
            <name>BasicUnit</name>
            <sharing>PublishSubscribe</sharing>
            <semantics>A Basic Unit</semantics>
            <attribute>
                <name>Name</name>
                <dataType>HLAunicodeString</dataType>
                <updateType>Static</updateType>
                <updateCondition>NA</updateCondition>
                <ownership>NoTransfer</ownership>
                <sharing>PublishSubscribe</sharing>
                <dimensions/>
                <transportation>HLAreliable</transportation>
                <order>Receive</order>
                <semantics>Name of the Unit</semantics>
            </attribute>
            
            <attribute>
                <name>Serial</name>
                <dataType>HLAunicodeString</dataType>
                <updateType>Static</updateType>
                <updateCondition>NA</updateCondition>
                <ownership>NoTransfer</ownership>
                <sharing>PublishSubscribe</sharing>
                <dimensions/>
                <transportation>HLAreliable</transportation>
                <order>Receive</order>
                <semantics>Serial ID of the Unit</semantics>
            </attribute>                
            
            <attribute>
                <name>ImageName</name>
                <dataType>HLAunicodeString</dataType>
                <updateType>Static</updateType>
                <updateCondition>NA</updateCondition>
                <ownership>NoTransfer</ownership>
                <sharing>PublishSubscribe</sharing>
                <dimensions/>
                <transportation>HLAreliable</transportation>
                <order>Receive</order>
                <semantics>PNG Image to show on the Map Viewer.</semantics>
            </attribute>                

            <attribute>
                <name>Position</name>
                <dataType>Position</dataType>
                <updateType>Conditional</updateType>
                <updateCondition>On Change</updateCondition>
                <ownership>NoTransfer</ownership>
                <sharing>PublishSubscribe</sharing>
                <transportation>HLAreliable</transportation>
                <order>Receive</order>
                <semantics>Coordinates of the Unit</semantics>
            </attribute>     

            <attribute>
                <name>UnitType</name>
                <dataType>UnitType</dataType>
                <updateType>Static</updateType>
                <updateCondition>NA</updateCondition>
                <ownership>NoTransfer</ownership>
                <sharing>PublishSubscribe</sharing>
                <transportation>HLAreliable</transportation>
                <order>Receive</order>
                <semantics>Type of the Unit</semantics>
            </attribute>     
    
        </objectClass>
  
    </objectClass>
</objects>

You will find some other attributes beyond those that I showed in the model: ImageName and UnitType. The MapViewer can not distinguish between the types of unit, so the Federate must set your own image name to show on the Map. The type of the unit will help us to discover if it is a friend, a foe, our own army or a unknown unit. The UnitType is a enumerated data type. Enumerated types may be new to you, but it is not hard to understand. It is treated as an integer with a constraint. Here is the UnitType enumerated data and the Position fixed record:

<dataTypes>

    <enumeratedDataTypes>
        <enumeratedData>
            <name>UnitType</name>
            <representation>HLAinteger32BE</representation>
            <semantics>Friend, foe or what</semantics>
            <enumerator>
                <name>Me</name>
                <value>100</value>
            </enumerator>
            <enumerator>
                <name>Friend</name>
                <value>101</value>
            </enumerator>
            <enumerator>
                <name>Foe</name>
                <value>102</value>
            </enumerator>
            <enumerator>
                <name>Unknown</name>
                <value>103</value>
            </enumerator>
        </enumeratedData>
    </enumeratedDataTypes>


    <fixedRecordDataTypes>
        <fixedRecordData>
            <name>Position</name>
            <encoding>HLAfixedRecord</encoding>
            <semantics>Position in geographic coordinates.</semantics>
            <field>
                <name>longitude</name>
                <dataType>HLAfloat64BE</dataType>
                <semantics>Longitude</semantics>
            </field>
            <field>
                <name>latitude</name>
                <dataType>HLAfloat64BE</dataType>
                <semantics>Latitude</semantics>
            </field>
        </fixedRecordData>
    </fixedRecordDataTypes>    
   
</dataTypes>	

You will subscribe to the UnitType attribute as usual, and read it as an Integer. Is your responsibility convert the integer to a Java enum or anything else. The constraint is: if you try to update this attribute with a value not declared ( 100 to 103 ) it will raise an exception.

Done. You have a FOM with a basic unit. Now, we must to create the two SOMs to the Tank and the Aircraft Federates. I’ll show only the tank.xml SOM here because the aircraft.xml SOM is very similar.

<objects>
    <objectClass>
        <name>HLAobjectRoot</name>
        <objectClass>
            <name>BasicUnit</name>
            <objectClass>
                <name>Tank</name>
                <sharing>PublishSubscribe</sharing>
                <semantics>The Tank Unit</semantics>
                <attribute>
                    <name>Model</name>
                    <dataType>HLAunicodeString</dataType>
                    <updateType>Static</updateType>
                    <updateCondition>NA</updateCondition>
                    <ownership>NoTransfer</ownership>
                    <sharing>PublishSubscribe</sharing>
                    <dimensions/>
                    <transportation>HLAreliable</transportation>
                    <order>Receive</order>
                    <semantics>The Tank Model</semantics>
                </attribute>  
            </objectClass>
        </objectClass>
    </objectClass>
</objects>

Since all we need is in unit.xml FOM, you will see here only the tank model attribute. All tank specific attributes must be here.

My project will not have true simulations so the Tank do not care about the Map or with the Aircraft. Aircraft do not care about the map or with the tank. The Map only cares about basic units. Having said that, you must keep the unit.xml file with all Federates, the tank.xml with the Tank Federate and the aircraft.xml file with the Aircraft Federate. Why do unit.xml must be with all Federates? because it is the FOM. You can see the scaffolding definition of BasicUnit in tank.xml and aircraft.xml and you must keep your promisse.

That’s it! You have your FOM and SOMs of your Federation.  In the next post I’ll show the web interface engine.

Add Comment