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

updated marshal() method in opendis7-java library returns ByteBuffer, handle accordingly

parent 1587f645
No related branches found
No related tags found
No related merge requests found
......@@ -104,7 +104,7 @@ public class DisDemonstration
// Marshall it, send it
espdu.setTimestamp(DisTime.getCurrentDisTimestamp());
buffer = ByteBuffer.wrap(espdu.marshal());
buffer = espdu.marshal();
for(InetAddress aBcast: allBcasts)
{
......
......@@ -114,10 +114,12 @@ public class NetworkComms implements Runnable
{
aPdu.setTimestamp(DisTime.getCurrentDisTimestamp());
try {
sendPacket.setData(aPdu.marshal());
if (!socket.isClosed())
if (!socket.isClosed() && (aPdu.marshal() != null))
{
sendPacket.setData(aPdu.marshal().array());
socket.send(sendPacket);
} catch (IOException ex) {
}
} catch (Exception ex) {
Logger.getLogger(NetworkComms.class.getName()).log(Level.SEVERE, null, ex);
} finally {
buffSend.clear();
......
......@@ -90,4 +90,4 @@ Sent packet #70, DisPduType 70 INFORMATION_OPERATIONS_ACTION (packet.getLen
Sent packet #71, DisPduType 71 INFORMATION_OPERATIONS_REPORT (packet.getLength()= 40) of type InformationOperationsReportPdu
Sent packet #72, DisPduType 72 ATTRIBUTE (packet.getLength()= 32) of type AttributePdu
OpenDis7Examples.AllPduSender complete, sent 72 PDUs total.
BUILD SUCCESSFUL (total time: 4 seconds)
BUILD SUCCESSFUL (total time: 2 seconds)
......@@ -317,7 +317,7 @@ public class EspduSender
FirePdu firePdu = new FirePdu();
firePdu.setLocationInWorldCoordinates(espdu.getEntityLocation());
byte[] fireArray = firePdu.marshal();
byte[] fireArray = firePdu.marshal().array(); // can also use ByteBuffer
System.out.println("FirePdu #" + index + " firePdu=[FireMissionIndex=" + firePdu.getFireMissionIndex() + ", descriptor=" + firePdu.getDescriptor()+ "]");
......
......@@ -26,11 +26,11 @@ Create new PDUs
Espdu #1 entityID=[1,2,3]
FirePdu #1 firePdu=[FireMissionIndex=0, descriptor=MunitionDescriptor munitionType:EntityType entityKind:EntityKind 0 OTHER domain:Other country:Country 0 OTHER category:0 subCategory:0 specific:0 extra:0 warhead:MunitionDescriptorWarhead 0 OTHER fuse:MunitionDescriptorFuse 0 OTHER quantity:0 rate:0]
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 10.0.0.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 10.0.0.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 10.0.0.255 port 3000
===============
Create new PDUs
latitude, longitude: [36.595517, -121.877]
......@@ -38,11 +38,11 @@ Create new PDUs
Espdu #2 entityID=[1,2,3]
FirePdu #2 firePdu=[FireMissionIndex=0, descriptor=MunitionDescriptor munitionType:EntityType entityKind:EntityKind 0 OTHER domain:Other country:Country 0 OTHER category:0 subCategory:0 specific:0 extra:0 warhead:MunitionDescriptorWarhead 0 OTHER fuse:MunitionDescriptorFuse 0 OTHER quantity:0 rate:0]
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 10.0.0.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 10.0.0.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 10.0.0.255 port 3000
===============
Create new PDUs
latitude, longitude: [36.595517, -121.87706]
......@@ -50,11 +50,11 @@ Create new PDUs
Espdu #3 entityID=[1,2,3]
FirePdu #3 firePdu=[FireMissionIndex=0, descriptor=MunitionDescriptor munitionType:EntityType entityKind:EntityKind 0 OTHER domain:Other country:Country 0 OTHER category:0 subCategory:0 specific:0 extra:0 warhead:MunitionDescriptorWarhead 0 OTHER fuse:MunitionDescriptorFuse 0 OTHER quantity:0 rate:0]
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 10.0.0.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 10.0.0.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 10.0.0.255 port 3000
===============
Create new PDUs
latitude, longitude: [36.595517, -121.877]
......@@ -62,11 +62,11 @@ Create new PDUs
Espdu #4 entityID=[1,2,3]
FirePdu #4 firePdu=[FireMissionIndex=0, descriptor=MunitionDescriptor munitionType:EntityType entityKind:EntityKind 0 OTHER domain:Other country:Country 0 OTHER category:0 subCategory:0 specific:0 extra:0 warhead:MunitionDescriptorWarhead 0 OTHER fuse:MunitionDescriptorFuse 0 OTHER quantity:0 rate:0]
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 10.0.0.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 10.0.0.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 10.0.0.255 port 3000
===============
Create new PDUs
latitude, longitude: [36.595517, -121.87706]
......@@ -74,11 +74,11 @@ Create new PDUs
Espdu #5 entityID=[1,2,3]
FirePdu #5 firePdu=[FireMissionIndex=0, descriptor=MunitionDescriptor munitionType:EntityType entityKind:EntityKind 0 OTHER domain:Other country:Country 0 OTHER category:0 subCategory:0 specific:0 extra:0 warhead:MunitionDescriptorWarhead 0 OTHER fuse:MunitionDescriptorFuse 0 OTHER quantity:0 rate:0]
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 127.255.255.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 172.20.209.15 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 01 ENTITY_STATE] packet.getLength()=144, to 10.0.0.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 96, to 10.0.0.255 port 3000
[OpenDis7Examples.EspduSender] sending datagram packet [DisPduType 02 FIRE ] packet.getLength()= 1500, to 10.0.0.255 port 3000
===============
[OpenDis7Examples.EspduSender] complete.
BUILD SUCCESSFUL (total time: 8 seconds)
......@@ -15,7 +15,7 @@ run-single:
[DisThreadedNetworkInterface] createThreads() receiveThread.isAlive()=true
[DisChannel ExampleSimulationProgram] Network confirmation: address=239.1.2.3 port=3000
[DisChannel ExampleSimulationProgram] Beginning pdu save to directory ./pduLog
[PduRecorder] Recorder log file open: C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog.dislog
[PduRecorder] Recorder log file open: C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog3.dislog
[DisThreadedNetworkInterface] using network interface PANGP Virtual Ethernet Adapter Secure
[DisThreadedNetworkInterface] datagramSocket.joinGroup address=239.1.2.3 port=3000 isConnected()=false createDatagramSocket() complete.
[DisThreadedNetworkInterface] createThreads() sendingThread.isAlive()=true
......@@ -23,8 +23,8 @@ run-single:
[PduRecorder PduRecorder] listening to IP address 239.1.2.3 on port 3000
[DisChannel ExampleSimulationProgram] just checking: disChannel.getNetworkAddress()=239.1.2.3, getNetworkPort()=3000
[DisChannel ExampleSimulationProgram] just checking: hasVerboseSending()=true, hasVerboseReceipt()=true
[DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 1] DisPduType 11 CREATE_ENTITY, size 28 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [sending 1] DisPduType 11 CREATE_ENTITY, size 28 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 1] DisPduType 11 CREATE_ENTITY, size 28 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [sending 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 80 bytes)
......@@ -37,13 +37,13 @@ run-single:
[DisThreadedNetworkInterface ExampleSimulationProgram] [sending 4] DisPduType 22 COMMENT, size 112 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 4] DisPduType 22 COMMENT, size 112 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 4] DisPduType 22 COMMENT, size 112 bytes)
[DisChannel ExampleSimulationProgram] *** [CommentPdu TIME] [Simulation time 0.0 at LocalDateTime 2023-12-18T21:40:29.203159300]
[DisChannel ExampleSimulationProgram] *** [CommentPdu TIME] [Simulation time 0.0 at LocalDateTime 2023-12-19T21:27:41.865637800]
... My simulation just did something, no really...
... [Pausing for 1.0 seconds]
... sending PDUs of interest for simulation step 1, monitor loopback to confirm sent
[DisThreadedNetworkInterface ExampleSimulationProgram] [sending 5] DisPduType 01 ENTITY_STATE Entity #53, size 144 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 5] DisPduType 01 ENTITY_STATE Entity #53, size 144 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 5] DisPduType 01 ENTITY_STATE Entity #53, size 144 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [sending 5] DisPduType 01 ENTITY_STATE Entity #53, size 144 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [sending 6] DisPduType 02 FIRE, size 96 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 6] DisPduType 02 FIRE, size 96 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 6] DisPduType 02 FIRE, size 96 bytes)
......@@ -85,9 +85,9 @@ run-single:
[DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 15] DisPduType 22 COMMENT, size 104 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 15] DisPduType 22 COMMENT, size 104 bytes)
[DisChannel ExampleSimulationProgram] *** [CommentPdu APPLICATION_STATUS] [MV3500 ExampleSimulationProgram, runSimulation() loop 3]
[DisThreadedNetworkInterface ExampleSimulationProgram] [sending 16] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [receipt 16] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes)
[DisThreadedNetworkInterface PduRecorder] [receipt 16] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes)
[DisThreadedNetworkInterface ExampleSimulationProgram] [sending 16] DisPduType 01 ENTITY_STATE Entity #2, size 144 bytes)
... [PDUs of interest successfully sent for this loop]
... My simulation just did something, no really...
... [Pausing for 1.0 seconds]
......@@ -136,6 +136,6 @@ run-single:
*** Thread close status: sendingThread.isAlive()=false receiveThread.isAlive()=false
PduRecorder.stop() closing recorder log file:
C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog.dislog
C:\x3d-nps-gitlab\NetworkedGraphicsMV3500\examples\pduLog\PduCaptureLog3.dislog
[DisChannel ExampleSimulationProgram] complete.
BUILD SUCCESSFUL (total time: 14 seconds)
BUILD SUCCESSFUL (total time: 13 seconds)
......@@ -23,8 +23,8 @@ run-single:
[PduRecorder PduRecorder] listening to IP address 239.1.2.3 on port 3000
[DisChannel ExampleTrackInterpolation] just checking: disChannel.getNetworkAddress()=239.1.2.3, getNetworkPort()=3000
[DisChannel ExampleTrackInterpolation] just checking: hasVerboseSending()=true, hasVerboseReceipt()=true
[DisThreadedNetworkInterface ExampleTrackInterpolation] [sending 1] DisPduType 11 CREATE_ENTITY, size 28 bytes)
[DisThreadedNetworkInterface ExampleTrackInterpolation] [receipt 1] DisPduType 11 CREATE_ENTITY, size 28 bytes)
[DisThreadedNetworkInterface ExampleTrackInterpolation] [sending 1] DisPduType 11 CREATE_ENTITY, size 28 bytes)
[DisThreadedNetworkInterface ExampleTrackInterpolation] [sending 2] DisPduType 11 CREATE_ENTITY, size 28 bytes)
[DisThreadedNetworkInterface ExampleTrackInterpolation] [sending 3] DisPduType 22 COMMENT, size 80 bytes)
[DisThreadedNetworkInterface ExampleTrackInterpolation] [receipt 2] DisPduType 11 CREATE_ENTITY, size 28 bytes)
......@@ -130,7 +130,7 @@ pduTrack_1 duration = 42.0 seconds = 0 ticks
<meta content='ExampleTrackInterpolation.x3d' name='title'/>
<meta content='Conversion of ESPDU track into X3D animation interpolators and LineSet.' name='description'/>
<meta content='1 January 2022' name='created'/>
<meta content='18 December 2023' name='modified'/>
<meta content='19 December 2023' name='modified'/>
<meta content='Don Brutzman' name='creator'/>
<meta content='https://gitlab.nps.edu/Savage/NetworkedGraphicsMV3500/-/blob/master/examples/src/OpenDis7Examples/ExampleTrackInterpolation.x3d' name='identifier'/>
<meta content='PduTrack utility, opendis7-java Library https://github.com/open-dis/opendis7-java' name='generator'/>
......
......@@ -954,7 +954,7 @@ public class PduTrack
EntityStatePdu espdu = (EntityStatePdu) pdu;
System.out.println("espdu from pduTrack pduList");
reportPdu(espdu);
byte[] byteArray = espdu.marshal();
byte[] byteArray = espdu.marshal().array(); // can also use ByteBuffer
System.out.println("espdu.marshal() byteArray: " + bytesToHex(byteArray));
flushBuffers();
......@@ -972,7 +972,7 @@ public class PduTrack
System.out.println("espdu.copyByteBuffer()");
reportPdu(espdu.copyByteBuffer());
byte[] byteArrayCopy = espdu.copyByteBuffer().marshal();
byte[] byteArrayCopy = espdu.copyByteBuffer().marshal().array(); // can also use ByteBuffer
System.out.println("espdu.copyByteBuffer().marshal() byteArray: " + bytesToHex(byteArrayCopy));
flushBuffers();
......@@ -990,7 +990,7 @@ public class PduTrack
System.out.println("espdu.copyDataOutputStream()");
reportPdu(espdu.copyDataOutputStream());
byte[] byteArrayCopyDOS = espdu.copyDataOutputStream().marshal();
byte[] byteArrayCopyDOS = espdu.copyDataOutputStream().marshal().array(); // can also use ByteBuffer
System.out.println("espdu.copyDataOutputStream().marshal() byteArray: " + bytesToHex(byteArrayCopyDOS));
flushBuffers();
......
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