Class EntityStateEntityIdExampleUse

java.lang.Object
edu.nps.moves.dis7.examples.EntityStateEntityIdExampleUse

public class EntityStateEntityIdExampleUse extends Object

The Entity Type record, described in section 6.2.30 of IEEE Std 1278.1-2012, IEEE Standard for Distributed Interactive Simulation—Application Protocols, is implemented in this library as edu.nps.moves.dis.EntityType.java. There are 8 fields in the record: kind, domain, country, category, subcategory, specific and extra. For describing a particular entity in DIS, such as a vehicle, munition, or other, the values for each of these fields are enumerated in the SISO specification, SISO-REF-010-v25, 2018-08-29.

The code generator in the open-dis7-source-generator project produces a class for each entity described in the SISO specification. Each of these classes is a subclass of EntityType, so may be used in PDUs requiring EntityType instances. The source for each of these classes is trivial. As an example, here is the source to Hawk102.java, which is described in the SISO specification under uid 28585

 package edu.nps.moves.dis.entities.are.platform.air;

 import edu.nps.moves.dis.*;
 import edu.nps.moves.dis.enumerations.*;

 //SISO-REF-010-v25, 2018-08-29

 //Country: United Arab Emirates (ARE)
 //Entity kind: Platform
 //Domain: AIR

 //Entity uid: 28578

 public class Hawk102 extends EntityType
 {
   public Hawk102()
   {
      setCountry(Country.UNITED_ARAB_EMIRATES_ARE);
      setEntityKind(EntityKind.PLATFORM);
      setDomain(Domain.inst(PlatformDomain.AIR));

      setCategory((byte)40); // uid 28579, Trainer
      setSubCategory((byte)1); // uid 28580, BAE Systems Hawk
      setSpecific((byte)3); // uid 28585, Hawk 102
   }
 }
 

Entity classes are found in several jars included in this project. They are typically separated into countries and/or platforms. Assuming one or more are in the application classpath, individual entity types may be used/instantiated in either of 2 ways:

1. By name, including package. For example, you may include the following statements in your application:

import edu.nps.moves.dis.entities.are.platform.air.Hawk102;
 EntityType et = new Hawk102();

2. By SISO uid. Included in the edu.nps.moves.dis.entities package is the EntityTypeFactory class. It has a static method with a makeEntity method. You would do:

import edu.nps.moves.dis.entities.EntityFactory;
 EntityType et = EntityTypeFactory.makeEntity(28585);

Importantly, if you pass a legal uid to the makeEntity method, but do not have the appropriate entity jar in your classpath, the method returns null, and displays a message on System.err.

The code in this class illustrates EntityStatePDU and EntityType use.
  • Constructor Details

    • EntityStateEntityIdExampleUse

      public EntityStateEntityIdExampleUse()
      default constructor
  • Method Details

    • exampleUse

      public static void exampleUse() throws Exception
      Using two methods, create and sendPDU an EntityStatePDU, describing an AD44 Shenandoah destroyer tender, uid 11963.
      Throws:
      IOException - report if problem occurs
      Exception
    • main

      public static void main(String[] args) throws Exception
      Command-line invocation (CLI)
      Parameters:
      args - command-line arguments
      Throws:
      Exception - if fails