Class PduFactory

java.lang.Object
edu.nps.moves.dis7.utilities.PduFactory

public class PduFactory extends Object
PduFactory.java created on Jun 14, 2019 MOVES Institute Naval Postgraduate School, Monterey, CA, USA www.nps.edu

A class to 1) create new Pdus (for sending purposes) and 2) create Pdus from byte streams received from the net.

For the first use case, pdus will be initialized with country, exerciseId, siteId, applicationId and timestamp format, matching the parameters passed to the constructor. For no arg constructor, the defaults of USA, 1, 2, 3, and absolute timestamp are used.

Author:
Mike Bailey, jmbailey@nps.edu
  • Constructor Details

    • PduFactory

      public PduFactory()
      Create and add initial properties to a new PduFactory using defaults for country (USA), exerciseId (2), application (3) and absolute timestamps.
    • PduFactory

      public PduFactory(DisTime.TimestampStyle newTimestampStyle)
      Create and add initial properties to a new PduFactory using newTimestampStyle.
      Parameters:
      newTimestampStyle - timeStampStyle of interest
    • PduFactory

      public PduFactory(Country country, byte exerciseId, short siteId, short applicationId, DisTime.TimestampStyle timestampStyle)
      Create and add initial properties to a new PduFactory which creates pdus using the specified default values.
      Parameters:
      country - used in EntityType and RadioType objects
      exerciseId - used in standard PDU header
      siteId - used in standard PDU header
      applicationId - used in standard PDU header
      timestampStyle - enum to specify time stamp style (IEEE Std 1278.1-2012, 4.6)
      See Also:
  • Method Details

    • getTimestampStyle

      public DisTime.TimestampStyle getTimestampStyle()
      accessor to report value
      Returns:
      current timestampStyle
    • setTimestampStyle

      public void setTimestampStyle(DisTime.TimestampStyle newTimestampStyle)
      accessor to update value
      Parameters:
      newTimestampStyle - value of interest
    • makeEntityStatePdu

      public EntityStatePdu makeEntityStatePdu()
      Create and add initial properties to an Entity State PDU
      IEEE Std 1278.1-2012, 5.3.2
      Returns:
      the new pdu
    • makeFirePdu

      public FirePdu makeFirePdu()
      Create and add initial properties to a new Fire PDU
      IEEE Std 1278.1-2012, 5.4.3
      Returns:
      the new pdu
    • makeDetonationPdu

      public DetonationPdu makeDetonationPdu()
      Create and add initial properties to a new Detonation PDU
      IEEE Std 1278.1-2012, 5.4.4
      Returns:
      the new pdu
    • makeCollisionPdu

      public CollisionPdu makeCollisionPdu()
      Create and add initial properties to a new Collision PDU
      IEEE Std 1278.1-2012, 5.3.3
      Returns:
      the new pdu
    • makeServiceRequestPdu

      public ServiceRequestPdu makeServiceRequestPdu()
      Create and add initial properties to a new Service Request PDU
      IEEE Std 1278.1-2012, 5.5.5
      Returns:
      the new pdu
    • makeResupplyOfferPdu

      public ResupplyOfferPdu makeResupplyOfferPdu()
      Create and add initial properties to a new Resupply Offer PDU
      IEEE Std 1278.1-2012, 5.5.6
      Returns:
      the new pdu
    • makeResupplyReceivedPdu

      public ResupplyReceivedPdu makeResupplyReceivedPdu()
      Create and add initial properties to a new Resupply Received PDU
      IEEE Std 1278.1-2012, 5.5.7
      Returns:
      the new pdu
    • makeResupplyCancelPdu

      public ResupplyCancelPdu makeResupplyCancelPdu()
      Create and add initial properties to a new Resupply Cancel PDU
      IEEE Std 1278.1-2012, 5.5.8
      Returns:
      the new pdu
    • makeRepairCompletePdu

      public RepairCompletePdu makeRepairCompletePdu()
      Create and add initial properties to a new Repair Complete PDU
      IEEE Std 1278.1-2012, 5.5.10
      Returns:
      the new pdu
    • makeRepairResponsePdu

      public RepairResponsePdu makeRepairResponsePdu()
      Create and add initial properties to a new Repair Response PDU
      IEEE Std 1278.1-2012, 5.5.11
      Returns:
      the new pdu
    • makeCreateEntityPdu

      public CreateEntityPdu makeCreateEntityPdu()
      Create and add initial properties to a new Create Entity PDU
      IEEE Std 1278.1-2012, 5.6.5.2
      Returns:
      the new pdu
    • makeRemoveEntityPdu

      public RemoveEntityPdu makeRemoveEntityPdu()
      Create and add initial properties to a new Remove Entity PDU
      IEEE Std 1278.1-2012, 5.6.5.3
      Returns:
      the new pdu
    • makeStartResumePdu

      public StartResumePdu makeStartResumePdu()
      Create and add initial properties to a new Start Resume PDU
      IEEE Std 1278.1-2012, 5.6.5.4
      Returns:
      the new pdu
    • makeStopFreezePdu

      public StopFreezePdu makeStopFreezePdu()
      Create and add initial properties to a new Stop Freeze PDU
      IEEE Std 1278.1-2012, 5.6.5.5
      Returns:
      the new pdu
    • makeAcknowledgePdu

      public AcknowledgePdu makeAcknowledgePdu()
      Create and add initial properties to an Acknowledge PDU
      IEEE Std 1278.1-2012, 5.6.5.6
      Returns:
      the new pdu
    • makeActionRequestPdu

      public ActionRequestPdu makeActionRequestPdu()
      Create and add initial properties to an Action Request PDU
      IEEE Std 1278.1-2012, 5.6.5.7
      Returns:
      the new pdu
    • makeActionResponsePdu

      public ActionResponsePdu makeActionResponsePdu()
      Create and add initial properties to an Action Response PDU
      IEEE Std 1278.1-2012, 5.6.5.8
      Returns:
      the new pdu
    • makeDataQueryPdu

      public DataQueryPdu makeDataQueryPdu()
      Create and add initial properties to a new Data Query PDU
      IEEE Std 1278.1-2012, 5.6.5.9
      Returns:
      the new pdu
    • makeSetDataPdu

      public SetDataPdu makeSetDataPdu()
      Create and add initial properties to a new Set DataPDU
      IEEE Std 1278.1-2012, 5.6.5.10
      Returns:
      the new pdu
    • makeDataPdu

      public DataPdu makeDataPdu()
      Create and add initial properties to a new Data PDU
      IEEE Std 1278.1-2012, 5.6.5.11
      Returns:
      the new pdu
    • makeEventReportPdu

      public EventReportPdu makeEventReportPdu()
      Create and add initial properties to an Event Report PDU
      IEEE Std 1278.1-2012, 5.6.5.12
      Returns:
      the new pdu
    • makeCommentPdu

      public CommentPdu makeCommentPdu()
      Create and add initial properties to a new Comment PDU
      IEEE Std 1278.1-2012, 5.6.5.13
      Returns:
      the new pdu
    • makeCommentPdu

      public CommentPdu makeCommentPdu(String... comments)
      Create and add initial properties to a new Comment PDU containing the given String(s), variable record type = "OTHER"
      Parameters:
      comments - of interest
      Returns:
      the new pdu
    • makeCommentPdu

      public CommentPdu makeCommentPdu(VariableRecordType typ, String... comments)
      Create and add initial properties to a new Comment PDU containing the given String(s) and variable record type
      Parameters:
      typ - VariableRecordType
      comments - of interest
      Returns:
      the new pdu
    • makeElectronicEmissionsPdu

      public ElectromagneticEmissionPdu makeElectronicEmissionsPdu()
      Create and add initial properties to a new Electromagnetic Emission (EE) PDU
      IEEE Std 1278.1-2012, 5.7.3
      Returns:
      the new pdu
    • makeDesignatorPdu

      public DesignatorPdu makeDesignatorPdu()
      Create and add initial properties to a new Designator PDU
      IEEE Std 1278.1-2012, 5.7.4
      Returns:
      the new pdu
    • makeTransmitterPdu

      public TransmitterPdu makeTransmitterPdu()
      Create and add initial properties to a new Transmitter PDU
      IEEE Std 1278.1-2012, 5.8.3
      Returns:
      the new pdu
    • makeSignalPdu

      public SignalPdu makeSignalPdu()
      Create and add initial properties to a new Signal PDU
      IEEE Std 1278.1-2012, 5.7.4
      Returns:
      the new pdu
    • makeReceiverPdu

      public ReceiverPdu makeReceiverPdu()
      Create and add initial properties to a new Receiver PDU
      IEEE Std 1278.1-2012, 5.8.5
      Returns:
      the new pdu
    • makeIffPdu

      public IFFPdu makeIffPdu()
      Create and add initial properties to a new an Identification Friend or Foe (IFF) PDU
      IEEE Std 1278.1-2012, 5.7.6
      Returns:
      the new pdu
    • makeUnderwaterAcousticPdu

      public UnderwaterAcousticPdu makeUnderwaterAcousticPdu()
      Create and add initial properties to a new Designator PDU
      IEEE Std 1278.1-2012, 5.7.4
      Returns:
      the new pdu
    • makeSeesPdu

      public SEESPdu makeSeesPdu()
      Create and add initial properties to a new Supplemental Emission/Entity State (SEES) PDU
      IEEE Std 1278.1-2012, 5.7.7
      Returns:
      the new pdu
    • makeIntercomSignalPdu

      public IntercomSignalPdu makeIntercomSignalPdu()
      Create and add initial properties to an Intercom Signal PDU
      IEEE Std 1278.1-2012, 5.8.6
      Returns:
      the new pdu
    • makeIntercomControlPdu

      public IntercomControlPdu makeIntercomControlPdu()
      Create and add initial properties to an Intercom Control PDU
      IEEE Std 1278.1-2012, 5.8.7
      Returns:
      the new pdu
    • makeAggregateStatePdu

      public AggregateStatePdu makeAggregateStatePdu()
      Create and add initial properties to a new Designator PDU
      IEEE Std 1278.1-2012, 5.7.4
      Returns:
      the new pdu
    • makeIsGroupOfPdu

      public IsGroupOfPdu makeIsGroupOfPdu()
      Create and add initial properties to an IsGroupOf PDU
      IEEE Std 1278.1-2012, 5.9.3
      Returns:
      the new pdu
    • makeTransferOwnershipPdu

      public TransferOwnershipPdu makeTransferOwnershipPdu()
      Create and add initial properties to a new Transfer Ownership PDU
      IEEE Std 1278.1-2012, 5.9.4
      Returns:
      the new pdu
    • makeIsPartOfPdu

      public IsPartOfPdu makeIsPartOfPdu()
      Create and add initial properties to an IsPartOf PDU
      IEEE Std 1278.1-2012, 5.9.5
      Returns:
      the new pdu
    • makeMinefieldStatePdu

      public MinefieldStatePdu makeMinefieldStatePdu()
      Create and add initial properties to a new Minefield State PDU
      IEEE Std 1278.1-2012, 5.10.2
      Returns:
      the new pdu
    • makeMinefieldQueryPdu

      public MinefieldQueryPdu makeMinefieldQueryPdu()
      Create and add initial properties to a new Minefield Query PDU
      IEEE Std 1278.1-2012, 5.10.3
      Returns:
      the new pdu
    • makeMinefieldDataPdu

      public MinefieldDataPdu makeMinefieldDataPdu()
      Create and add initial properties to a new Minefield Data PDU
      IEEE Std 1278.1-2012, 5.10.4
      Returns:
      the new pdu
    • makeMinefieldResponseNackPdu

      public MinefieldResponseNACKPdu makeMinefieldResponseNackPdu()
      Create and add initial properties to a new Minefield Response Negative Acknowledgment (NACK) PDU
      IEEE Std 1278.1-2012, 5.10.5
      Returns:
      the new pdu
    • makeEnvironmentalProcessPdu

      public EnvironmentalProcessPdu makeEnvironmentalProcessPdu()
      Create and add initial properties to an Environmental Process PDU
      IEEE Std 1278.1-2012, 5.11.2.2
      Returns:
      the new pdu
    • makeGriddedDataPdu

      public GriddedDataPdu makeGriddedDataPdu()
      Create and add initial properties to a new Gridded Data PDU
      IEEE Std 1278.1-2012, 5.11.2.3
      Returns:
      the new pdu
    • makePointObjectStatePdu

      public PointObjectStatePdu makePointObjectStatePdu()
      Create and add initial properties to a new Point Object State PDU
      IEEE Std 1278.1-2012, 5.11.3.2
      Returns:
      the new pdu
    • makeLinearObjectStatePdu

      public LinearObjectStatePdu makeLinearObjectStatePdu()
      Create and add initial properties to a new Linear Object State PDU
      IEEE Std 1278.1-2012, 5.11.3.3
      Returns:
      the new pdu
    • makeArealObjectStatePdu

      public ArealObjectStatePdu makeArealObjectStatePdu()
      Create and add initial properties to an Areal Object State PDU
      IEEE Std 1278.1-2012, 5.11.3.4
      Returns:
      the new pdu
    • makeTspiPdu

      public TSPIPdu makeTspiPdu()
      Create and add initial properties to a new Time Space Position Information (TSPI) PDU
      IEEE Std 1278.1-2012, 9.4.2
      Returns:
      the new pdu
    • makeAppearancePdu

      public AppearancePdu makeAppearancePdu()
      Create and add initial properties to an Appearance PDU
      IEEE Std 1278.1-2012, 9.4.3
      Returns:
      the new pdu
    • makeArticulatedPartsPdu

      public ArticulatedPartsPdu makeArticulatedPartsPdu()
      Create and add initial properties to an Articulated Parts PDU
      IEEE Std 1278.1-2012, 9.4.4
      Returns:
      the new pdu
    • makeLEFirePdu

      public LEFirePdu makeLEFirePdu()
      Create and add initial properties to a new Live Entity (LE) Fire PDU
      IEEE Std 1278.1-2012, 9.4.5
      Returns:
      the new pdu
    • makeLEDetonationPdu

      public LEDetonationPdu makeLEDetonationPdu()
      Create and add initial properties to a new Live Entity (LE) Detonation PDU
      IEEE Std 1278.1-2012, 9.4.6
      Returns:
      the new pdu
    • makeCreateEntityReliablePdu

      public CreateEntityReliablePdu makeCreateEntityReliablePdu()
      Create and add initial properties to a new Create Entity-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.2
      Returns:
      the new pdu
    • makeRemoveEntityReliablePdu

      public RemoveEntityReliablePdu makeRemoveEntityReliablePdu()
      Create and add initial properties to a new Remove Entity-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.3
      Returns:
      the new pdu
    • makeStartResumeReliablePdu

      public StartResumeReliablePdu makeStartResumeReliablePdu()
      Create and add initial properties to a new Start/Resume-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.4
      Returns:
      the new pdu
    • makeStopFreezeReliablePdu

      public StopFreezeReliablePdu makeStopFreezeReliablePdu()
      Create and add initial properties to a new Stop/Freeze-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.5
      Returns:
      the new pdu
    • makeAcknowledgeReliablePdu

      public AcknowledgeReliablePdu makeAcknowledgeReliablePdu()
      Create and add initial properties to an Acknowledge-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.6
      Returns:
      the new pdu
    • makeActionRequestReliablePdu

      public ActionRequestReliablePdu makeActionRequestReliablePdu()
      Create and add initial properties to an Action Request-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.7
      Returns:
      the new pdu
    • makeActionResponseReliablePdu

      public ActionResponseReliablePdu makeActionResponseReliablePdu()
      Create and add initial properties to an Action Response-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.8
      Returns:
      the new pdu
    • makeDataQueryReliablePdu

      public DataQueryReliablePdu makeDataQueryReliablePdu()
      Create and add initial properties to a new Data Query-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.9
      Returns:
      the new pdu
    • makeSetDataReliablePdu

      public SetDataReliablePdu makeSetDataReliablePdu()
      Create and add initial properties to a new Set Data-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.10
      Returns:
      the new pdu
    • makeDataReliablePdu

      public DataReliablePdu makeDataReliablePdu()
      Create and add initial properties to a new Data-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.11
      Returns:
      the new pdu
    • makeEventReportReliablePdu

      public EventReportReliablePdu makeEventReportReliablePdu()
      Create and add initial properties to an Event Report-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.12
      Returns:
      the new pdu
    • makeCommentReliablePdu

      public CommentReliablePdu makeCommentReliablePdu()
      Create and add initial properties to a new Comment-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.13
      Returns:
      the new pdu
    • makeCommentReliablePdu

      public CommentReliablePdu makeCommentReliablePdu(String... comments)
      Create and add initial properties to a new Comment-R PDU containing the given String(s), variable record type = "OTHER"
      Parameters:
      comments - of interest
      Returns:
      the new pdu
    • makeCommentReliablePdu

      public CommentReliablePdu makeCommentReliablePdu(VariableRecordType typ, String... comments)
      Create and add initial properties to a new CommentR PDU containing the given String(s) and variable record type
      Parameters:
      typ - VariableRecordType
      comments - of interest
      Returns:
      the new pdu
    • makeRecordReliablePdu

      public RecordReliablePdu makeRecordReliablePdu()
      Create and add initial properties to a new Record-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.16
      Returns:
      the new pdu
    • makeSetRecordReliablePdu

      public SetRecordReliablePdu makeSetRecordReliablePdu()
      Create and add initial properties to a new Set Record-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.15
      Returns:
      the new pdu
    • makeRecordQueryReliablePdu

      public RecordQueryReliablePdu makeRecordQueryReliablePdu()
      Create and add initial properties to a new Record Query-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.14
      Returns:
      the new pdu
    • makeCollisionElasticPdu

      public CollisionElasticPdu makeCollisionElasticPdu()
      Create and add initial properties to a new Collision-Elastic PDU
      IEEE Std 1278.1-2012, 5.3.4
      Returns:
      the new pdu
    • makeEntityStateUpdatePdu

      public EntityStateUpdatePdu makeEntityStateUpdatePdu()
      Create and add initial properties to a new Entity State Update PDU
      IEEE Std 1278.1-2012, 5.3.5
      Returns:
      the new pdu
    • makeDirectedEnergyFirePdu

      public DirectedEnergyFirePdu makeDirectedEnergyFirePdu()
      Create and add initial properties to a new Directed Energy (DE) Fire PDU
      IEEE Std 1278.1-2012, 5.4.5
      Returns:
      the new pdu
    • makeEntityDamageStatusPdu

      public EntityDamageStatusPdu makeEntityDamageStatusPdu()
      Create and add initial properties to a new Collision-Elastic PDU
      IEEE Std 1278.1-2012, 5.3.3
      Returns:
      the new pdu
    • makeInformationOperationsActionPdu

      public InformationOperationsActionPdu makeInformationOperationsActionPdu()
      Create and add initial properties to an Information Operations (IO) Action PDU
      IEEE Std 1278.1-2012, 5.13.3
      Returns:
      the new pdu
    • makeInformationOperationsReportPdu

      public InformationOperationsReportPdu makeInformationOperationsReportPdu()
      Create and add initial properties to an Information Operations (IO) Report PDU
      IEEE Std 1278.1-2012, 5.13.4
      Returns:
      the new pdu
    • makeAttributePdu

      public AttributePdu makeAttributePdu()
      Create and add initial properties to an Attribute PDU
      IEEE Std 1278.1-2012, 5.3.6
      Returns:
      the new pdu
    • createPdu

      public Pdu createPdu(byte[] data)
      PDU builder. Pass in an array of bytes, get the correct type of pdu back based on the PDU type field contained in the byte array.
      Parameters:
      data - an array of PDU data
      Returns:
      A PDU of the appropriate concrete subclass of PDU or null if there was an error
    • createPdu

      public Pdu createPdu(ByteBuffer byteBuffer)
      PDU builder. Pass in a data buffer, get the correct type of pdu back based on the PDU type field contained in the underlying array.
      Parameters:
      byteBuffer - the buffer containing PDU data to input
      Returns:
      A PDU of the appropriate concrete subclass of PDU or null if there was an error
    • createPdu

      public Pdu createPdu(DisPduType pduType)
      Create and add initial properties to an empty PDU of the given type
      Parameters:
      pduType - PDU type to create
      Returns:
      the empty pdu
    • getPdusFromBundle

      public List<Pdu> getPdusFromBundle(byte[] data, int length)
      Decodes datagram contents with bundled PDUs. As a performance hack DIS may include several PDUs in one datagram. Typically the max datagram size is 8K (above that it runs into some issues with the default incoming socket buffer size) but it may be more. The PDUs may be of multiple types and different lengths, so we have to step through the buffer and depend on the reported PDU length in the header. There's a lot that can go wrong. If something blows up, we return all the decoded PDUs we can.
      Parameters:
      data - a large buffer filled with possible multiple PDUs
      length - the size of the multiple PDU buffer
      Returns:
      List of decoded PDUs
    • main

      public static void main(String[] args)
      If invoked, notify location of unit test (which is located outside of the jar distribution).
      Parameters:
      args - none supported