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

continue efforts on espdu.copyByteBuffer()

parent 0b63fc7e
No related branches found
No related tags found
No related merge requests found
......@@ -186,20 +186,21 @@ public class PduTrack
{
if (newPdu.getPduType() == DisPduType.ENTITY_STATE)
{
// EntityStatePdu deepCopyEspdu = new EntityStatePdu();
EntityStatePdu deepCopyEspdu = pduFactory.makeEntityStatePdu();
deepCopyEspdu.setTimestamp (((EntityStatePdu)newPdu).getTimestamp());
deepCopyEspdu.setMarking (((EntityStatePdu)newPdu).getMarking());
deepCopyEspdu.setEntityID (((EntityStatePdu)newPdu).getEntityID());
deepCopyEspdu.setForceId (((EntityStatePdu)newPdu).getForceId());
deepCopyEspdu.setEntityType (((EntityStatePdu)newPdu).getEntityType());
deepCopyEspdu.setEntityLocation (((EntityStatePdu)newPdu).getEntityLocation());
deepCopyEspdu.setEntityOrientation(((EntityStatePdu)newPdu).getEntityOrientation());
// TODO apparently not working
// EntityStatePdu deepCopyEspdu = ((EntityStatePdu)newPdu).copy();
//// EntityStatePdu deepCopyEspdu = new EntityStatePdu();
// EntityStatePdu deepCopyEspdu = pduFactory.makeEntityStatePdu();
// deepCopyEspdu.setTimestamp (((EntityStatePdu)newPdu).getTimestamp());
// deepCopyEspdu.setMarking (((EntityStatePdu)newPdu).getMarking());
// deepCopyEspdu.setEntityID (((EntityStatePdu)newPdu).getEntityID());
// deepCopyEspdu.setForceId (((EntityStatePdu)newPdu).getForceId());
// deepCopyEspdu.setEntityType (((EntityStatePdu)newPdu).getEntityType());
// deepCopyEspdu.setEntityLocation (((EntityStatePdu)newPdu).getEntityLocation());
// deepCopyEspdu.setEntityOrientation(((EntityStatePdu)newPdu).getEntityOrientation());
EntityStatePdu deepCopyEspdu = ((EntityStatePdu)newPdu).copy();
pduList.add(deepCopyEspdu);
// alternative trials:
// pduList.add(((EntityStatePdu)newPdu).copyDataOutputStream());
// pduList.add(((EntityStatePdu)newPdu).copy());
if (initialLocation == null)
{
......@@ -858,7 +859,7 @@ public class PduTrack
espdu.setEntityID(entityID_123);
espdu.setForceId(ForceID.FRIENDLY);
espdu.setEntityType(new _001Poseidon()); // note import statement above
pduTrack.addPdu(espdu);
pduTrack.addPdu(espdu); // create copy
reportPdu(espdu);
}
// System.out.println(TRACE_PREFIX + "reversePdus() then sortPdus() to test track operations");
......@@ -885,17 +886,17 @@ public class PduTrack
System.out.println("espdu from pduTrack pduList");
reportPdu(espdu);
byte[] byteArray = espdu.marshal();
System.out.println("espdu.marshal() byteArray: " + bytesToHex(byteArray));
System.out.println("espdu.marshal() byteArray: " + bytesToHex(byteArray));
flushBuffers();
ByteBuffer byteBuffer = ByteBuffer.allocate(byteArray.length);
espdu.marshal(byteBuffer);
System.out.println("espdu.marshal(byteBuffer): " + bytesToHex(byteBuffer.array()));
System.out.println("espdu.marshal(byteBuffer): " + bytesToHex(byteBuffer.array()));
flushBuffers();
espdu.marshal(dataOutputStream);
byte[] byteArrayDOS = byteArrayOutputStream.toByteArray();
System.out.println("espdu.marshal(dataOutputStream): " + bytesToHex(byteArrayDOS));
System.out.println("espdu.marshal(dataOutputStream): " + bytesToHex(byteArrayDOS));
flushBuffers();
System.out.println(); // - - - - - - - - - - - - - - - - -
......@@ -903,35 +904,35 @@ public class PduTrack
System.out.println("espdu.copyByteBuffer()");
reportPdu(espdu.copyByteBuffer());
byte[] byteArrayCopy = espdu.copyByteBuffer().marshal();
System.out.println("espdu.copyByteBuffer().marshal() byteArray: " + bytesToHex(byteArrayCopy));
System.out.println("espdu.copyByteBuffer().marshal() byteArray: " + bytesToHex(byteArrayCopy));
flushBuffers();
ByteBuffer byteBufferCopy = ByteBuffer.allocate(byteArray.length); // TODO is there a better way to reset?
espdu.copyByteBuffer().marshal(byteBufferCopy);
System.out.println("espdu.copyByteBuffer().marshal(byteBufferCopy): " + bytesToHex(byteBufferCopy.array()));
System.out.println("espdu.copyByteBuffer().marshal(byteBufferCopy): " + bytesToHex(byteBufferCopy.array()));
flushBuffers();
espdu.copyByteBuffer().marshal(dataOutputStream);
byte[] byteArrayDosCopy = byteArrayOutputStream.toByteArray();
System.out.println("espdu.copyByteBuffer().marshal(dataOutputStream): " + bytesToHex(byteArrayDosCopy));
System.out.println("espdu.copyByteBuffer().marshal(dataOutputStream): " + bytesToHex(byteArrayDosCopy));
flushBuffers();
System.out.println(); // - - - - - - - - - - - - - - - - -
System.out.println("espdu.copyDataOutputStream()");
reportPdu(espdu.copyDataOutputStream());
byteArrayCopy = espdu.copyDataOutputStream().marshal();
System.out.println("espdu.copyDataOutputStream().marshal() byteArray: " + bytesToHex(byteArrayCopy));
byte[] byteArrayCopyDOS = espdu.copyDataOutputStream().marshal();
System.out.println("espdu.copyDataOutputStream().marshal() byteArray: " + bytesToHex(byteArrayCopyDOS));
flushBuffers();
byteBufferCopy = ByteBuffer.allocate(byteArray.length); // TODO is there a better way to reset?
espdu.copyDataOutputStream().marshal(byteBufferCopy);
System.out.println("espdu.copyDataOutputStream().marshal(byteBufferCopy): " + bytesToHex(byteBufferCopy.array()));
ByteBuffer byteBufferCopyDOS = ByteBuffer.allocate(byteArray.length); // TODO is there a better way to reset?
espdu.copyDataOutputStream().marshal(byteBufferCopyDOS);
System.out.println("espdu.copyDataOutputStream().marshal(byteBufferCopy): " + bytesToHex(byteBufferCopyDOS.array()));
flushBuffers();
espdu.copyDataOutputStream().marshal(dataOutputStream);
byteArrayDosCopy = byteArrayOutputStream.toByteArray();
System.out.println("espdu.copyDataOutputStream().marshal(dataOutputStream): " + bytesToHex(byteArrayDosCopy));
byte[] byteArrayDosCopy2 = byteArrayOutputStream.toByteArray();
System.out.println("espdu.copyDataOutputStream().marshal(dataOutputStream): " + bytesToHex(byteArrayDosCopy2));
flushBuffers();
System.out.println();
......
This diff is collapsed.
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