From 9139dfa3f1ff46bec87208cc7310157856d70c3a Mon Sep 17 00:00:00 2001
From: terry-norbraten <tnorb@comcast.net>
Date: Thu, 29 Jul 2021 17:26:32 -0700
Subject: [PATCH] [Terry N.] If we use the factory to create PDUs, and we most
 always should, then use it's inner timestamp in the style set at factory
 instantiation time

---
 src/edu/nps/moves/dis7/utilities/PduFactory.java | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/edu/nps/moves/dis7/utilities/PduFactory.java b/src/edu/nps/moves/dis7/utilities/PduFactory.java
index cc132764f8..290671b308 100644
--- a/src/edu/nps/moves/dis7/utilities/PduFactory.java
+++ b/src/edu/nps/moves/dis7/utilities/PduFactory.java
@@ -39,7 +39,6 @@ public class PduFactory
   private byte defaultExerciseId = 1;
   private short defaultSiteId = 2;
   private short defaultAppId = 3;
-  private boolean useAbsoluteTimestamp = true;
   private final DisTime disTime;
 
   private Method getTime;
@@ -128,9 +127,12 @@ public class PduFactory
     useFastPdu = tf;
   }
 
-  /* ***************************************************/
- /* utility methods*/
-  private int doTime()
+  /** Retrieve the current timestamp in the time stamp style set at factory 
+   * instantiation.
+   * @return the current timestamp in the time stamp style set at factory 
+   * instantiation
+   */
+  public int getTimestamp()
   {
     try {
       return (int) getTime.invoke(disTime, (Object[]) null);
@@ -140,11 +142,13 @@ public class PduFactory
     }
   }
 
+  /* ***************************************************/
+ /* utility methods*/
   private PduBase addBoilerPlate(PduBase pdu)
   {
     pdu.getPduStatus().setValue((byte) (PduStatus.AII_ACTIVE | PduStatus.CEI_COUPLED));
     pdu.setExerciseID(defaultExerciseId)
-      .setTimestamp(doTime())
+      .setTimestamp(getTimestamp())
       .setLength((short) pdu.getMarshalledSize());  //todo check if should be done in Pdu class
 
     return pdu;
@@ -153,7 +157,7 @@ public class PduFactory
   private LiveEntityFamilyPdu addBoilerPlate(LiveEntityFamilyPdu pdu)
   {
     pdu.setExerciseID(defaultExerciseId)
-      .setTimestamp(doTime())
+      .setTimestamp(getTimestamp())
       .setLength((short) pdu.getMarshalledSize());  //todo check if should be done in Pdu class
 
     return pdu;
-- 
GitLab