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(DisTime.TimestampStyle newTimestampStyle)
      Create a PduFactory using newTimestampStyle.
      Parameters:
      newTimestampStyle - timeStampStyle of interest
    • PduFactory

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

      public PduFactory(Country country, byte exerciseId, short siteId, short applicationId, DisTime.TimestampStyle timestampStyle)
      Create a 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 an Entity State PDU
      IEEE Std 1278.1-2012, 5.3.2
      Returns:
      the new pdu
    • makeFirePdu

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public CommentPdu makeCommentPdu(String... comments)
      Create a 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 a 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 a Electromagnetic Emission (EE) PDU
      IEEE Std 1278.1-2012, 5.7.3
      Returns:
      the new pdu
    • makeDesignatorPdu

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public CommentReliablePdu makeCommentReliablePdu(String... comments)
      Create a 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 a 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 a Record-R (Reliable) PDU
      IEEE Std 1278.1-2012, 5.12.4.16
      Returns:
      the new pdu
    • makeSetRecordReliablePdu

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

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

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

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

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

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

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

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

      public AttributePdu makeAttributePdu()
      Create 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 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