Skip to content
Snippets Groups Projects
Commit 9c2fa692 authored by Brutzman, Don's avatar Brutzman, Don
Browse files

updated build mostly working, need further scrutiny of timestamps and duration intervals

parent b46b8875
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,10 @@ public class ExampleSimulationProgram ...@@ -37,7 +37,10 @@ public class ExampleSimulationProgram
/** initial simulation time */ /** initial simulation time */
double initialTime = 0.0; double initialTime = 0.0;
/** current simulation time */ /** current simulation time */
double simulationTime; double simulationTime = initialTime;
/** Maximum number of simulation loops */
int MAX_LOOP_COUNT = 4;
String narrativeMessage1 = new String(); String narrativeMessage1 = new String();
String narrativeMessage2 = new String(); String narrativeMessage2 = new String();
String narrativeMessage3 = new String(); String narrativeMessage3 = new String();
...@@ -97,8 +100,9 @@ public class ExampleSimulationProgram ...@@ -97,8 +100,9 @@ public class ExampleSimulationProgram
disChannel.join(); // TODO further functionality expected disChannel.join(); // TODO further functionality expected
String timeStepMessage = "Simulation timestep " + getTimeStepDuration() + " seconds"; String timeStepMessage = "Simulation timestep duration " + getTimeStepDuration() + " seconds";
disChannel.sendCommentPdu(disChannel.COMMENTPDU_SIMULATION_TIMESTEP, timeStepMessage); int simulationTimeMsec = 0;
disChannel.sendCommentPdu(simulationTimeMsec, disChannel.COMMENTPDU_SIMULATION_TIMESTEP, timeStepMessage);
// additional constructor initialization goes here // additional constructor initialization goes here
} }
...@@ -225,7 +229,7 @@ public class ExampleSimulationProgram ...@@ -225,7 +229,7 @@ public class ExampleSimulationProgram
narrativeMessage3 = ""; // intentionally blank for testing narrativeMessage3 = ""; // intentionally blank for testing
// your loop termination condition goes here // your loop termination condition goes here
if (simulationLoopCount > 4) // for example if (simulationLoopCount > MAX_LOOP_COUNT) // for example
{ {
simulationComplete = true; simulationComplete = true;
} }
...@@ -244,11 +248,12 @@ public class ExampleSimulationProgram ...@@ -244,11 +248,12 @@ public class ExampleSimulationProgram
// TODO set timesteps in PDUs // TODO set timesteps in PDUs
sendAllPdusForLoopTimestep(entityStatePdu_1, sendAllPdusForLoopTimestep(simulationTime,
firePdu_1a, entityStatePdu_1,
disChannel.COMMENTPDU_APPLICATION_STATUS, firePdu_1a,
disChannel.COMMENTPDU_APPLICATION_STATUS,
narrativeMessage1, narrativeMessage2, narrativeMessage3); narrativeMessage1, narrativeMessage2, narrativeMessage3);
disChannel.sendSinglePdu(entityStatePdu_2); // me too i.e. 2! disChannel.sendSinglePdu(simulationTime, entityStatePdu_2); // me too i.e. 2!
System.out.println ("... [PDUs of interest successfully sent for this loop]"); System.out.println ("... [PDUs of interest successfully sent for this loop]");
System.out.flush(); System.out.flush();
...@@ -261,6 +266,8 @@ public class ExampleSimulationProgram ...@@ -261,6 +266,8 @@ public class ExampleSimulationProgram
System.out.flush(); System.out.flush();
break; break;
} }
simulationTime += getTimeStepDuration();
} // end of simulation loop } // end of simulation loop
// ===================================================================================================// =================================================================================================== // ===================================================================================================// ===================================================================================================
...@@ -279,26 +286,29 @@ public class ExampleSimulationProgram ...@@ -279,26 +286,29 @@ public class ExampleSimulationProgram
/** /**
* Send EntityState, Fire, Comment PDUs that got updated for this loop, reflecting state of current simulation timestep. * Send EntityState, Fire, Comment PDUs that got updated for this loop, reflecting state of current simulation timestep.
* @see <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing Information to a Method or a Constructor</a> Arbitrary Number of Arguments * @param simulationTimeSeconds simulation time, applied as PDU timestamp
* @param entityStatePdu the ESPDU to send, if any * @param entityStatePdu the ESPDU to send, if any
* @param firePdu the FirePDU to send, if any * @param firePdu the FirePDU to send, if any
* @param commentType enumeration value describing purpose of the narrative comment * @param commentType enumeration value describing purpose of the narrative comment
* @param comments String array of narrative comments * @param comments String array of narrative comments
* @see DisChannel * @see DisChannel
* @see <a href="https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html">Passing Information to a Method or a Constructor</a> Arbitrary Number of Arguments
*/ */
public void sendAllPdusForLoopTimestep(EntityStatePdu entityStatePdu, public void sendAllPdusForLoopTimestep(double simulationTimeSeconds,
EntityStatePdu entityStatePdu,
FirePdu firePdu, FirePdu firePdu,
VariableRecordType commentType, VariableRecordType commentType,
// vararg... variable-length set of String comments can optionally follow // vararg... variable-length set of String comments can optionally follow
String... comments) String... comments)
{ {
int simulationTimeMsec = (int)(simulationTimeSeconds * 1000.0);
if (entityStatePdu != null) if (entityStatePdu != null)
disChannel.sendSinglePdu(entityStatePdu); disChannel.sendSinglePdu(simulationTimeMsec, entityStatePdu);
if (firePdu != null) if (firePdu != null)
disChannel.sendSinglePdu(firePdu); // bang disChannel.sendSinglePdu(simulationTimeMsec, firePdu); // bang
disChannel.sendCommentPdu(commentType, comments); // empty comments are filtered disChannel.sendCommentPdu(simulationTimeMsec, commentType, comments); // empty comments are filtered
} }
/** /**
......
...@@ -13,7 +13,7 @@ run-single: ...@@ -13,7 +13,7 @@ run-single:
[DisThreadedNetworkInterface] createThreads() sendingThread.isAlive()=true [DisThreadedNetworkInterface] createThreads() sendingThread.isAlive()=true
[DisChannel ExampleSimulationProgram] Network confirmation: address=239.1.2.3 port=3000 [DisChannel ExampleSimulationProgram] Network confirmation: address=239.1.2.3 port=3000
[DisChannel ExampleSimulationProgram] Beginning pdu save to directory ./pduLog [DisChannel ExampleSimulationProgram] Beginning pdu save to directory ./pduLog
[PduRecorder] Recorder log file open: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog.dislog [PduRecorder] Recorder log file open: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog3.dislog
[DisThreadedNetworkInterface] using network interface PANGP Virtual Ethernet Adapter [DisThreadedNetworkInterface] using network interface PANGP Virtual Ethernet Adapter
[DisThreadedNetworkInterface] datagramSocket.joinGroup address=239.1.2.3 port=3000 isConnected()=false createDatagramSocket() complete. [DisThreadedNetworkInterface] datagramSocket.joinGroup address=239.1.2.3 port=3000 isConnected()=false createDatagramSocket() complete.
[DisThreadedNetworkInterface] createThreads() receiveThread.isAlive()=true [DisThreadedNetworkInterface] createThreads() receiveThread.isAlive()=true
...@@ -24,17 +24,17 @@ run-single: ...@@ -24,17 +24,17 @@ run-single:
[DisThreadedNetworkInterface ExampleSimulationProgram] [sending 2] DisPduType 11 CREATE_ENTITY, size 28 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram] [sending 2] DisPduType 11 CREATE_ENTITY, size 28 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 1] DisPduType 11 CREATE_ENTITY, size 28 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 1] DisPduType 11 CREATE_ENTITY, size 28 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 2] DisPduType 11 CREATE_ENTITY, size 28 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 2] DisPduType 11 CREATE_ENTITY, size 28 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [sending 3] DisPduType 22 COMMENT, size 72 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram] [sending 3] DisPduType 22 COMMENT, size 80 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 3] DisPduType 22 COMMENT, size 72 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 3] DisPduType 22 COMMENT, size 80 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 1] DisPduType 11 CREATE_ENTITY, size 28 bytes) [DisThreadedNetworkInterface PduRecorder] [receipt 1] DisPduType 11 CREATE_ENTITY, size 28 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 2] DisPduType 11 CREATE_ENTITY, size 28 bytes) [DisThreadedNetworkInterface PduRecorder] [receipt 2] DisPduType 11 CREATE_ENTITY, size 28 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 3] DisPduType 22 COMMENT, size 72 bytes) [DisThreadedNetworkInterface PduRecorder] [receipt 3] DisPduType 22 COMMENT, size 80 bytes)
[DisChannel ExampleSimulationProgram] *** [CommentPdu APPLICATION_TIMESTEP] [Simulation timestep 1.0 seconds] [DisChannel ExampleSimulationProgram] *** [CommentPdu APPLICATION_TIMESTEP] [Simulation timestep duration 1.0 seconds]
[DisChannel ExampleSimulationProgram] main() started... [DisChannel ExampleSimulationProgram] main() started...
[DisThreadedNetworkInterface ExampleSimulationProgram] [sending 4] DisPduType 22 COMMENT, size 112 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram] [sending 4] DisPduType 22 COMMENT, size 104 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 4] DisPduType 22 COMMENT, size 112 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 4] DisPduType 22 COMMENT, size 104 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 4] DisPduType 22 COMMENT, size 112 bytes) [DisThreadedNetworkInterface PduRecorder] [receipt 4] DisPduType 22 COMMENT, size 104 bytes)
[DisChannel ExampleSimulationProgram] *** [CommentPdu TIME] [Simulation time 0.0 at LocalDateTime 2022-06-20T13:15:46.976897900] [DisChannel ExampleSimulationProgram] *** [CommentPdu TIME] [Simulation time 0.0 at LocalDateTime 2022-06-22T23:05:10.475145]
... My simulation just did something, no really... ... My simulation just did something, no really...
... [Pausing for 1.0 seconds] ... [Pausing for 1.0 seconds]
... sending PDUs of interest for simulation step 1, monitor loopback to confirm sent ... sending PDUs of interest for simulation step 1, monitor loopback to confirm sent
...@@ -49,8 +49,8 @@ run-single: ...@@ -49,8 +49,8 @@ run-single:
[DisThreadedNetworkInterface PduRecorder] [receipt 7] DisPduType 22 COMMENT, size 104 bytes) [DisThreadedNetworkInterface PduRecorder] [receipt 7] DisPduType 22 COMMENT, size 104 bytes)
[DisChannel ExampleSimulationProgram] *** [CommentPdu APPLICATION_STATUS] [MV3500 ExampleSimulationProgram, runSimulation() loop 1] [DisChannel ExampleSimulationProgram] *** [CommentPdu APPLICATION_STATUS] [MV3500 ExampleSimulationProgram, runSimulation() loop 1]
[DisThreadedNetworkInterface ExampleSimulationProgram] [sending 8] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram] [sending 8] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 8] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 8] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 8] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 8] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes)
... [PDUs of interest successfully sent for this loop] ... [PDUs of interest successfully sent for this loop]
... My simulation just did something, no really... ... My simulation just did something, no really...
... [Pausing for 1.0 seconds] ... [Pausing for 1.0 seconds]
...@@ -66,8 +66,8 @@ run-single: ...@@ -66,8 +66,8 @@ run-single:
[DisThreadedNetworkInterface PduRecorder] [receipt 11] DisPduType 22 COMMENT, size 104 bytes) [DisThreadedNetworkInterface PduRecorder] [receipt 11] DisPduType 22 COMMENT, size 104 bytes)
[DisChannel ExampleSimulationProgram] *** [CommentPdu APPLICATION_STATUS] [MV3500 ExampleSimulationProgram, runSimulation() loop 2] [DisChannel ExampleSimulationProgram] *** [CommentPdu APPLICATION_STATUS] [MV3500 ExampleSimulationProgram, runSimulation() loop 2]
[DisThreadedNetworkInterface ExampleSimulationProgram] [sending 12] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram] [sending 12] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 12] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 12] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes) [DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 12] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 12] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes)
... [PDUs of interest successfully sent for this loop] ... [PDUs of interest successfully sent for this loop]
... My simulation just did something, no really... ... My simulation just did something, no really...
... [Pausing for 1.0 seconds] ... [Pausing for 1.0 seconds]
...@@ -133,7 +133,7 @@ run-single: ...@@ -133,7 +133,7 @@ run-single:
*** killThread() status: receiveThread.isAlive()=false receiveThread.isInterrupted()=true *** killThread() status: receiveThread.isAlive()=false receiveThread.isInterrupted()=true
*** Thread close status: sendingThread.isAlive()=false receiveThread.isAlive()=false *** Thread close status: sendingThread.isAlive()=false receiveThread.isAlive()=false
PduRecorder.stop() closing recorder log file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog.dislog PduRecorder.stop() closing recorder log file: C:\x-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog3.dislog
*** setKillSentinelAndInterrupts() killed=true sendingThread.isInterrupted()=true receiveThread.isInterrupted()=true *** setKillSentinelAndInterrupts() killed=true sendingThread.isInterrupted()=true receiveThread.isInterrupted()=true
[DisThreadedNetworkInterface ExampleSimulationProgram] close(): pdus2send.size()=0 baos.size()=0 dos.size()=2800 [DisThreadedNetworkInterface ExampleSimulationProgram] close(): pdus2send.size()=0 baos.size()=0 dos.size()=2800
[DisThreadedNetworkInterface ExampleSimulationProgram] datagramSocket.leaveGroup address=239.1.2.3 port=3000 isClosed()=true close() complete. [DisThreadedNetworkInterface ExampleSimulationProgram] datagramSocket.leaveGroup address=239.1.2.3 port=3000 isClosed()=true close() complete.
...@@ -141,4 +141,4 @@ PduRecorder.stop() closing recorder log file: C:\x-nps-gitlab\NetworkedGraphicsM ...@@ -141,4 +141,4 @@ PduRecorder.stop() closing recorder log file: C:\x-nps-gitlab\NetworkedGraphicsM
*** killThread() status: receiveThread.isAlive()=false receiveThread.isInterrupted()=true *** killThread() status: receiveThread.isAlive()=false receiveThread.isInterrupted()=true
*** Thread close status: sendingThread.isAlive()=false receiveThread.isAlive()=false *** Thread close status: sendingThread.isAlive()=false receiveThread.isAlive()=false
[DisChannel ExampleSimulationProgram] complete. [DisChannel ExampleSimulationProgram] complete.
BUILD SUCCESSFUL (total time: 11 seconds) BUILD SUCCESSFUL (total time: 13 seconds)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment