Skip to content
Snippets Groups Projects
Commit 8a922454 authored by ctsfi's avatar ctsfi
Browse files

FINAL PROJECT WHITE BRITT CANNON

parent 47ea32be
No related branches found
No related tags found
No related merge requests found
Showing
with 247 additions and 788 deletions
package MV3500Cohort2020JulySeptember.homework4.White;
import MV3500Cohort2020JulySeptember.homework4.White.working.*;
import java.io.*;
import java.net.*;
import java.util.*;
import edu.nps.moves.dis7.pdus.*;
import edu.nps.moves.dis7.utilities.*;
/**
* Receives PDUs from GermanyEspduReceiverEspduVPNSender in IEEE DIS format.
*
* @date 09/05/2020
* @author Bernd/Stefan
* @version 0.1
*/
public class PDUReciever {
/**
* Max size of a PDU in binary format that we can receive. This is actually
* somewhat outdated--PDUs can be larger--but this is a reasonable starting
* point.
*/
public static final int MAX_PDU_SIZE = 8192;
/**
* Default port used, matches Wireshark DIS capture default
*/
public static final int DEFAULT_PORT = 2317;
public static final int SECOND_PORT = 3000;
public static final int THIRD_PORT = 2318;
/**
* Output prefix to identify this class
*/
private final static String TRACE_PREFIX = "[" + PDUReciever.class.getName() + "] ";
public static void main(String args[]) {
System.out.println(TRACE_PREFIX + "started...");
MulticastSocket socket1;
MulticastSocket socket2;
MulticastSocket socket3;
DatagramPacket packet;
DatagramPacket packet2;
DatagramPacket packet3;
PduFactory pduFactory = new PduFactory();
ArrayList<EntityID> knownEntities = new ArrayList<EntityID>();
int pduCount = 0;
try {
// Specify the socket to receive data
socket1 = new MulticastSocket(DEFAULT_PORT);
socket2 = new MulticastSocket(SECOND_PORT);
socket3 = new MulticastSocket(THIRD_PORT);
System.out.println(TRACE_PREFIX + "listening for PDU packets on port " + DEFAULT_PORT );//+ " " + SECOND_PORT + " " + THIRD_PORT);
System.out.println("====================================================");
while (true) // Loop infinitely, receiving datagrams
{
byte buffer[] = new byte[MAX_PDU_SIZE];
packet = new DatagramPacket(buffer, buffer.length);
socket1.receive(packet);
List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData(), packet.getLength());
if (pduBundle.size() > 1) { // should be 1 for this project
System.out.println("Bundle size is " + pduBundle.size());
}
// end iterator loop through PDU bundle
for (Pdu aPdu : pduBundle) {
pduCount++;
String receiptMessage = String.format("%3s", pduCount) // right justify, 3 characters
+ ". received PDU type " + aPdu.getPduType().getValue() + "=" + aPdu.getPduType().name() + " " + aPdu.getClass().getName() + " from " + packet.getAddress();
if (aPdu instanceof EntityStatePdu) {
System.out.println(receiptMessage);
EntityID entityID = ((EntityStatePdu) aPdu).getEntityID();
Vector3Double position = ((EntityStatePdu) aPdu).getEntityLocation();
System.out.println(" entityID triplet: [" + entityID.getSiteID() + ", " + entityID.getApplicationID() + ", " + entityID.getEntityID() + "] ");
if (!knownEntities.contains(entityID)){
knownEntities.add(entityID);
EntityType entityType = ((EntityStatePdu) aPdu).getEntityType();
System.out.println(" New Entity: " +entityType.getEntityKind() + " "+ entityType.getDomain() + " "+ entityType.getCountry() + " "+ entityType.getCategory() + " "+ entityType.getSubCategory() + " "+ entityType.getSpecific() );
}
System.out.println(" Location in DIS coordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]");
}
else if (aPdu instanceof FirePdu){
System.out.println(receiptMessage);
EntityID firingEntityID = ((FirePdu) aPdu).getFiringEntityID();
EntityID targetEntityID = ((FirePdu) aPdu).getTargetEntityID();
MunitionDescriptor munitionDescriptor = ((FirePdu) aPdu).getDescriptor();
System.out.println(" firingEntityID triplet: [" + firingEntityID.getSiteID() + ", " + firingEntityID.getApplicationID() + ", " + firingEntityID.getEntityID() + "] ");
System.out.println(" targetEntityID triplet: [" + targetEntityID.getSiteID() + ", " + targetEntityID.getApplicationID() + ", " + targetEntityID.getEntityID() + "] ");
System.out.println(" Munition Information: [" + munitionDescriptor.getMunitionType().getDomain() + "."+munitionDescriptor.getMunitionType().getCountry() + "." + munitionDescriptor.getMunitionType().getCategory() + "."+ munitionDescriptor.getMunitionType().getSubCategory() + "." + munitionDescriptor.getMunitionType().getSpecific() + "]");
}
else if (aPdu instanceof CommentReliablePdu){
System.out.println(receiptMessage);
ArrayList<VariableDatum> payloadList = (ArrayList)((CommentReliablePdu) aPdu).getVariableDatumRecords();
if (!payloadList.isEmpty())
System.out.print (" messages: ");
for (VariableDatum variableDatum : payloadList)
{
String nextComment = new String(variableDatum.getVariableDatumValue()); // convert byte[] to String
System.out.print (" \"" + nextComment + "\"");
System.out.println();
}
} //OTHER PDU TYPES
else {
System.out.println(receiptMessage);
}
} // end of bundle loop
} // end of while loop
} // end try block // end try block // end try block // end try block
catch (IOException ioe) {
System.out.println(TRACE_PREFIX + "Problem with input/output, see exception trace:");
System.out.println(ioe);
}
System.out.println(TRACE_PREFIX + "complete.");
} // end main
} // end class
## Homework 2: Multicast Networking
Modify this file to describe your project work.
Typical deliverables include properly packages source, execution log, and screen shots as appropriate.
References include
* [README.md](../README.md) for this homework project.
* [README.md](../../../../README.md) for course assignments execution instructions.
* [assignments source subdirectories](../../../../../assignments/src) show examples from previous cohorts.
Questions and innovation are always welcome, good luck!
[MV3500Cohort2020JulySeptember.homework4.White.working.PDUReciever] started... [MV3500Cohort2020JulySeptember.homework4.White.working.PDUReciever] started...
[MV3500Cohort2020JulySeptember.homework4.White.working.PDUReciever] listening for PDU packets on port 2317 [MV3500Cohort2020JulySeptember.homework4.White.working.PDUReciever] listening for PDU packets on port 2317
==================================================== ====================================================
1. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7 1. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 26]
New Entity: EntityKind 1 PLATFORM Land Country 225 UNITED_STATES_OF_AMERICA_USA 7 39 3
Location in DIS coordinates: [-2707501.7340396782, -4353408.810297934, 3781834.0645668795]
2. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 26]
Location in DIS coordinates: [-2707521.7340396782, -4353483.810297934, 3781834.0645668795]
3. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 25]
New Entity: EntityKind 1 PLATFORM Land Country 225 UNITED_STATES_OF_AMERICA_USA 2 41 3
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
4. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 26]
Location in DIS coordinates: [-2707541.7340396782, -4353558.810297934, 3781834.0645668795]
5. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
6. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.11
messages: "LAV25-A2 IS WITHIN DISTANCE OF RESUPPLY"
7. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 26]
Location in DIS coordinates: [-2707561.7340396782, -4353633.810297934, 3781834.0645668795]
8. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
9. received PDU type 6=RESUPPLY_OFFER edu.nps.moves.dis7.pdus.ResupplyOfferPdu from /10.1.105.11
Resupply Offer from Entity [1, 13, 26] to resupply Entity [1, 13, 25]
Supplies Offered: [Quantity: 500.0, Type: EntityKind 2 MUNITION Air Country 225 UNITED_STATES_OF_AMERICA_USA 2 2 1 ]
10. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 26]
Location in DIS coordinates: [-2707581.7340396782, -4353708.810297934, 3781834.0645668795]
11. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
12. received PDU type 6=RESUPPLY_OFFER edu.nps.moves.dis7.pdus.ResupplyOfferPdu from /10.1.105.11
Resupply Offer from Entity [1, 13, 26] to resupply Entity [1, 13, 25]
Supplies Offered: [Quantity: 500.0, Type: EntityKind 2 MUNITION Air Country 225 UNITED_STATES_OF_AMERICA_USA 2 2 1 ]
13. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.11
messages: "Britt Simulation Completed"
14. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [2, 10, 3]
New Entity: EntityKind 1 PLATFORM Land Country 225 UNITED_STATES_OF_AMERICA_USA 4 3 7
Location in DIS coordinates: [-2709702.5301454174, -4349384.2159421, 3784766.9772485564]
15. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [1, 13, 2]
New Entity: EntityKind 1 PLATFORM Land Country 260 RUSSIA 2 41 3
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
16. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.8
firingEntityID triplet: [2, 10, 3]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.14.1]
17. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [2, 10, 3]
Location in DIS coordinates: [-2709702.5301454174, -4349384.2159421, 3784766.9772485564]
18. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
19. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.8
firingEntityID triplet: [2, 10, 3]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.14.1]
20. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [2, 10, 3]
Location in DIS coordinates: [-2709702.5301454174, -4349384.2159421, 3784766.9772485564]
21. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
22. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.8
firingEntityID triplet: [2, 10, 3]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.14.1]
23. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [2, 10, 3]
Location in DIS coordinates: [-2709702.5301454174, -4349384.2159421, 3784766.9772485564]
24. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
25. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.8
firingEntityID triplet: [2, 10, 3]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.14.1]
26. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [2, 10, 3]
Location in DIS coordinates: [-2709702.5301454174, -4349384.2159421, 3784766.9772485564]
27. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
28. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.8
firingEntityID triplet: [2, 10, 3]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.14.1]
29. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [2, 10, 3]
Location in DIS coordinates: [-2709702.5301454174, -4349384.2159421, 3784766.9772485564]
30. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
31. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.8
firingEntityID triplet: [2, 10, 3]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.14.1]
32. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.8
messages: "BMP2 DESTROYED BY M109A6 AFTER SIX VOLLEYS OF HE/PD ON TARGET"
33. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.8
messages: "Cannon Simulation Completed"
34. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 25] entityID triplet: [1, 13, 25]
New Entity: EntityKind 1 PLATFORM Land Country 225 UNITED_STATES_OF_AMERICA_USA 2 41 3
Location in DIS coordinates: [-2707501.7340396782, -4353408.810297934, 3781834.0645668795] Location in DIS coordinates: [-2707501.7340396782, -4353408.810297934, 3781834.0645668795]
2. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7 35. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 25] entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707521.7340396782, -4353483.810297934, 3781834.0645668795] Location in DIS coordinates: [-2707521.7340396782, -4353483.810297934, 3781834.0645668795]
3. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7 36. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 2] entityID triplet: [1, 13, 2]
New Entity: EntityKind 1 PLATFORM Land Country 260 RUSSIA 2 41 3
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432] Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
4. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7 37. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 25] entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707541.7340396782, -4353558.810297934, 3781834.0645668795] Location in DIS coordinates: [-2707541.7340396782, -4353558.810297934, 3781834.0645668795]
5. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7 38. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 2] entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432] Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
6. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.7 39. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.7
messages: "LAV25-A2 ACQUIRES TARGET BMP2 WITHIN FIRING DISTANCE" messages: "LAV25-A2 ACQUIRES TARGET BMP2 WITHIN FIRING DISTANCE"
7. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7 40. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 25] entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707561.7340396782, -4353633.810297934, 3781834.0645668795] Location in DIS coordinates: [-2707561.7340396782, -4353633.810297934, 3781834.0645668795]
8. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7 41. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 2] entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432] Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
9. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.7 42. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.7
firingEntityID triplet: [1, 13, 25] firingEntityID triplet: [1, 13, 25]
targetEntityID triplet: [1, 13, 2] targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.2.1] Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.2.1]
10. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7 43. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 25] entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707581.7340396782, -4353708.810297934, 3781834.0645668795] Location in DIS coordinates: [-2707581.7340396782, -4353708.810297934, 3781834.0645668795]
11. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7 44. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 2] entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432] Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
12. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.7 45. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.7
firingEntityID triplet: [1, 13, 25] firingEntityID triplet: [1, 13, 25]
targetEntityID triplet: [1, 13, 2] targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.2.1] Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.2.1]
13. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.7 46. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.7
messages: "BMP2 DESTROYED BY LAV25-A2 AFTER TWO BURSTS OF 25mm HEI-T ON TARGET" messages: "BMP2 DESTROYED BY LAV25-A2 AFTER TWO BURSTS OF 25mm HEI-T ON TARGET"
14. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.7 47. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.7
messages: "White Simulation Completed" messages: "White Simulation Completed"
\ No newline at end of file
File added
...@@ -31,7 +31,7 @@ public class WhiteSimulation ...@@ -31,7 +31,7 @@ public class WhiteSimulation
Pdu receivedPdu; Pdu receivedPdu;
private String networkAddress = "10.1.105.7"; private String networkAddress = "10.1.105.7";
private int networkPort = 2317; private int networkPort = 3000;
/** /**
* Constructor design goal: additional built-in initialization conveniences can go here * Constructor design goal: additional built-in initialization conveniences can go here
...@@ -235,6 +235,10 @@ public class WhiteSimulation ...@@ -235,6 +235,10 @@ public class WhiteSimulation
EntityStatePdu entityStatePdu = pduFactory.makeEntityStatePdu(); EntityStatePdu entityStatePdu = pduFactory.makeEntityStatePdu();
entityStatePdu.setEntityID(entityID_1); entityStatePdu.setEntityID(entityID_1);
// EntityMarking entityMarking = new EntityMarking ();
// entityMarking.setCharacters("WhiteSimulation".getBytes()); //entityMarking.setCharacters(Byte.valueOf("0")); // 11 characters max?
// entityStatePdu.setMarking(entityMarking);
EntityID lavID = new EntityID(); EntityID lavID = new EntityID();
...@@ -335,9 +339,9 @@ public class WhiteSimulation ...@@ -335,9 +339,9 @@ public class WhiteSimulation
CommentReliablePdu bmpDestroyedComment = pduFactory.makeCommentReliablePdu("BMP2 DESTROYED BY LAV25-A2 AFTER TWO BURSTS OF 25mm HEI-T ON TARGET"); CommentReliablePdu bmpDestroyedComment = pduFactory.makeCommentReliablePdu("BMP2 DESTROYED BY LAV25-A2 AFTER TWO BURSTS OF 25mm HEI-T ON TARGET");
CommentReliablePdu bmpSightedComment = pduFactory.makeCommentReliablePdu("LAV25-A2 ACQUIRES TARGET BMP2 WITHIN FIRING DISTANCE"); CommentReliablePdu bmpSightedComment = pduFactory.makeCommentReliablePdu("LAV25-A2 ACQUIRES TARGET BMP2 WITHIN FIRING DISTANCE");
//if(eloc1.getX()) //if(eloc1.getX())
EntityID MTVRID = new EntityID();
ResupplyOfferPdu resupplyOfferPdu = pduFactory.makeResupplyOfferPdu();
ResupplyOfferPdu resupplyOfferPdu = pduFactory.makeResupplyOfferPdu();
ArrayList<SupplyQuantity> pSupplies = new ArrayList<SupplyQuantity>(); ArrayList<SupplyQuantity> pSupplies = new ArrayList<SupplyQuantity>();
SupplyQuantity ammoSupplyQ = new SupplyQuantity(); SupplyQuantity ammoSupplyQ = new SupplyQuantity();
ammoSupplyQ.setSupplyType(HEType); ammoSupplyQ.setSupplyType(HEType);
...@@ -348,9 +352,9 @@ public class WhiteSimulation ...@@ -348,9 +352,9 @@ public class WhiteSimulation
//ammoSupply.setDomain(Entity) //ammoSupply.setDomain(Entity)
//ammoSupplyQ.setSupplyType(EntityType.) //ammoSupplyQ.setSupplyType(EntityType.)
pSupplies.add(ammoSupplyQ); pSupplies.add(ammoSupplyQ);
resupplyOfferPdu.setSupplies(pSupplies); resupplyOfferPdu.setSupplies(pSupplies);
resupplyOfferPdu.setReceivingEntityID(lavID); resupplyOfferPdu.setReceivingEntityID(lavID);
resupplyOfferPdu.setSupplyingEntityID(bmpID); resupplyOfferPdu.setSupplyingEntityID(MTVRID);
// should we customize this munition? what is it for your simulation? // should we customize this munition? what is it for your simulation?
...@@ -456,7 +460,7 @@ public class WhiteSimulation ...@@ -456,7 +460,7 @@ public class WhiteSimulation
} }
try { try {
// Set up a socket to send information // Set up a socket to send information
socket = new MulticastSocket(2317); socket = new MulticastSocket(3000);
} catch (IOException ex) { } catch (IOException ex) {
Logger.getLogger(WhiteSimulation.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(WhiteSimulation.class.getName()).log(Level.SEVERE, null, ex);
} }
...@@ -469,7 +473,7 @@ public class WhiteSimulation ...@@ -469,7 +473,7 @@ public class WhiteSimulation
pdu.marshal(dos); pdu.marshal(dos);
byte[] data = baos.toByteArray(); byte[] data = baos.toByteArray();
DatagramPacket packet = new DatagramPacket(data, data.length, destinationIp, 2317); DatagramPacket packet = new DatagramPacket(data, data.length, destinationIp, 3000);
socket.send(packet); socket.send(packet);
socket.close(); socket.close();
} catch (Exception ex) { } catch (Exception ex) {
......
...@@ -26,7 +26,7 @@ public class PDUReciever { ...@@ -26,7 +26,7 @@ public class PDUReciever {
/** /**
* Default port used, matches Wireshark DIS capture default * Default port used, matches Wireshark DIS capture default
*/ */
public static final int DEFAULT_PORT = 2317; public static final int DEFAULT_PORT = 3000;
public static final int SECOND_PORT = 3000; public static final int SECOND_PORT = 3000;
public static final int THIRD_PORT = 2318; public static final int THIRD_PORT = 2318;
......
/**
* Copyright (c) 2008-2020, MOVES Institute, Naval Postgraduate School (NPS). All rights reserved.
* This work is provided under a BSD open-source license, see project license.html and license.txt
*/
package MV3500Cohort2020JulySeptember.homework4.White.working;
import edu.nps.moves.dis7.utilities.stream.PduRecorder;
import java.io.IOException;
import java.util.Scanner;
/** Class to leverage the {@link edu.nps.moves.dis7.utilities.stream.PduRecorder}
* with PDU log saving console controls for resume, pause and quit.
*
* PduSaver.java created on Aug 21, 2019
* Renamed PduListenerSaver
* MOVES Institute Naval Postgraduate School, Monterey, CA, USA www.nps.edu
*
* @author Mike Bailey, jmbailey@nps.edu
* @version $Id$
*/
public class PduListenerSaver
{
private final static String DEFAULT_OUTPUT_DIRECTORY = "pduLog";
public static final String DEFAULT_MULTICAST_ADDRESS = "localhost";
public static final int DEFAULT_MULTICAST_PORT = 2137;
private enum mystate
{
RUNNING,
PAUSED;
}
public static void main(String[] args)
{
String outputDirectory = DEFAULT_OUTPUT_DIRECTORY;
String multicastAddress = DEFAULT_MULTICAST_ADDRESS;
int multicastPort = DEFAULT_MULTICAST_PORT;
System.out.println("OpenDis7Examples.PduListenerSaver started...");
switch (args.length) {
case 0:
break;
case 1:
outputDirectory = args[0];
break;
case 3:
outputDirectory = args[0];
multicastAddress = args[1];
multicastPort = Integer.parseInt(args[2]);
break;
default:
// Common-sense practice is to print help message if invocation is problematic
System.err.println("Usage: PduListenerSaver() or PduListenerSaver(\"outputdir\") or PduListenerSaver(\"outputDirectory\",\"multicastAddress\", multicastPort");
System.exit(1);
}
System.out.println("Beginning PduListenerSaver (" + multicastAddress + ":" + multicastPort + ") to directory " + outputDirectory);
try {
PduRecorder recorder = new PduRecorder(outputDirectory, multicastAddress, multicastPort); // assumes save
mystate state = mystate.RUNNING;
Scanner scan = new Scanner(System.in);
while (true) {
System.out.println("Type p/enter to pause, r/enter to resume, q/enter to quit");
String line = scan.nextLine();
if (line.equalsIgnoreCase("p") && state == mystate.RUNNING) {
recorder.stopPause();
state = mystate.PAUSED;
System.out.println("... now PAUSED");
}
else if (line.equalsIgnoreCase("p")) {
System.out.println("... still PAUSED");
}
else if (line.equalsIgnoreCase("r") && state == mystate.PAUSED) {
recorder.startResume();
state = mystate.RUNNING;
System.out.println("... now RUNNING");
}
else if (line.equalsIgnoreCase("r")) {
System.out.println("... still RUNNING");
}
else if (line.equalsIgnoreCase("q")) {
System.out.println("... QUIT");
recorder.end();
break;
}
}
System.out.println("Ending PduListenerSaver pdu recording, saved to file:");
System.out.println(recorder.getLogFilePath());
}
catch (IOException ex) {
System.err.println("Exception: " + ex.getClass().getSimpleName() + ": " + ex.getLocalizedMessage());
}
}
}
[MV3500Cohort2020JulySeptember.homework4.White.working.PDUReciever] started...
[MV3500Cohort2020JulySeptember.homework4.White.working.PDUReciever] listening for PDU packets on port 2317
====================================================
1. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 26]
New Entity: EntityKind 1 PLATFORM Land Country 225 UNITED_STATES_OF_AMERICA_USA 7 39 3
Location in DIS coordinates: [-2707501.7340396782, -4353408.810297934, 3781834.0645668795]
2. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 26]
Location in DIS coordinates: [-2707521.7340396782, -4353483.810297934, 3781834.0645668795]
3. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 25]
New Entity: EntityKind 1 PLATFORM Land Country 225 UNITED_STATES_OF_AMERICA_USA 2 41 3
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
4. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 26]
Location in DIS coordinates: [-2707541.7340396782, -4353558.810297934, 3781834.0645668795]
5. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
6. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.11
messages: "LAV25-A2 IS WITHIN DISTANCE OF RESUPPLY"
7. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 26]
Location in DIS coordinates: [-2707561.7340396782, -4353633.810297934, 3781834.0645668795]
8. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
9. received PDU type 6=RESUPPLY_OFFER edu.nps.moves.dis7.pdus.ResupplyOfferPdu from /10.1.105.11
Resupply Offer from Entity [1, 13, 26] to resupply Entity [1, 13, 25]
Supplies Offered: [Quantity: 500.0, Type: EntityKind 2 MUNITION Air Country 225 UNITED_STATES_OF_AMERICA_USA 2 2 1 ]
10. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 26]
Location in DIS coordinates: [-2707581.7340396782, -4353708.810297934, 3781834.0645668795]
11. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.11
entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
12. received PDU type 6=RESUPPLY_OFFER edu.nps.moves.dis7.pdus.ResupplyOfferPdu from /10.1.105.11
Resupply Offer from Entity [1, 13, 26] to resupply Entity [1, 13, 25]
Supplies Offered: [Quantity: 500.0, Type: EntityKind 2 MUNITION Air Country 225 UNITED_STATES_OF_AMERICA_USA 2 2 1 ]
13. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.11
messages: "Britt Simulation Completed"
14. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [2, 10, 3]
New Entity: EntityKind 1 PLATFORM Land Country 225 UNITED_STATES_OF_AMERICA_USA 4 3 7
Location in DIS coordinates: [-2709702.5301454174, -4349384.2159421, 3784766.9772485564]
15. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [1, 13, 2]
New Entity: EntityKind 1 PLATFORM Land Country 260 RUSSIA 2 41 3
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
16. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.8
firingEntityID triplet: [2, 10, 3]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.14.1]
17. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [2, 10, 3]
Location in DIS coordinates: [-2709702.5301454174, -4349384.2159421, 3784766.9772485564]
18. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
19. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.8
firingEntityID triplet: [2, 10, 3]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.14.1]
20. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [2, 10, 3]
Location in DIS coordinates: [-2709702.5301454174, -4349384.2159421, 3784766.9772485564]
21. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
22. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.8
firingEntityID triplet: [2, 10, 3]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.14.1]
23. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [2, 10, 3]
Location in DIS coordinates: [-2709702.5301454174, -4349384.2159421, 3784766.9772485564]
24. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
25. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.8
firingEntityID triplet: [2, 10, 3]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.14.1]
26. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [2, 10, 3]
Location in DIS coordinates: [-2709702.5301454174, -4349384.2159421, 3784766.9772485564]
27. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
28. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.8
firingEntityID triplet: [2, 10, 3]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.14.1]
29. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [2, 10, 3]
Location in DIS coordinates: [-2709702.5301454174, -4349384.2159421, 3784766.9772485564]
30. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.8
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
31. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.8
firingEntityID triplet: [2, 10, 3]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.14.1]
32. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.8
messages: "BMP2 DESTROYED BY M109A6 AFTER SIX VOLLEYS OF HE/PD ON TARGET"
33. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.8
messages: "Cannon Simulation Completed"
34. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707501.7340396782, -4353408.810297934, 3781834.0645668795]
35. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707521.7340396782, -4353483.810297934, 3781834.0645668795]
36. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
37. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707541.7340396782, -4353558.810297934, 3781834.0645668795]
38. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
39. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.7
messages: "LAV25-A2 ACQUIRES TARGET BMP2 WITHIN FIRING DISTANCE"
40. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707561.7340396782, -4353633.810297934, 3781834.0645668795]
41. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
42. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.7
firingEntityID triplet: [1, 13, 25]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.2.1]
43. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 25]
Location in DIS coordinates: [-2707581.7340396782, -4353708.810297934, 3781834.0645668795]
44. received PDU type 1=ENTITY_STATE edu.nps.moves.dis7.pdus.EntityStatePdu from /10.1.105.7
entityID triplet: [1, 13, 2]
Location in DIS coordinates: [-2707576.630668249, -4353720.04383471, 3781324.902449432]
45. received PDU type 2=FIRE edu.nps.moves.dis7.pdus.FirePdu from /10.1.105.7
firingEntityID triplet: [1, 13, 25]
targetEntityID triplet: [1, 13, 2]
Munition Information: [Air.Country 225 UNITED_STATES_OF_AMERICA_USA.2.2.1]
46. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.7
messages: "BMP2 DESTROYED BY LAV25-A2 AFTER TWO BURSTS OF 25mm HEI-T ON TARGET"
47. received PDU type 6=RESUPPLY_OFFER edu.nps.moves.dis7.pdus.ResupplyOfferPdu from /10.1.105.7
Resupply Offer from Entity [1, 13, 2] to resupply Entity [1, 13, 25]
Supplies Offered: [Quantity: 500.0, Type: EntityKind 2 MUNITION Air Country 225 UNITED_STATES_OF_AMERICA_USA 2 2 1 ]
48. received PDU type 62=COMMENT_RELIABLE edu.nps.moves.dis7.pdus.CommentReliablePdu from /10.1.105.7
messages: "White Simulation Completed"
\ No newline at end of file
...@@ -233,13 +233,14 @@ public class WhiteSimulation ...@@ -233,13 +233,14 @@ public class WhiteSimulation
EntityStatePdu entityStatePdu = pduFactory.makeEntityStatePdu(); EntityStatePdu entityStatePdu = pduFactory.makeEntityStatePdu();
entityStatePdu.setEntityID(entityID_1); entityStatePdu.setEntityID(entityID_1);
EntityID lavID = new EntityID(); EntityID lavID = new EntityID();
lavID.setSiteID(1); lavID.setSiteID(1);
lavID.setApplicationID(13); lavID.setApplicationID(13);
lavID.setEntityID(25); lavID.setEntityID(25);
entityStatePdu.setEntityID(lavID); entityStatePdu.setEntityID(lavID);
EntityType lavType = new EntityType(); //1.1.225.2.41.3 Platform,Ground,USA,ArmoredFightingVehicle,LAV,LAV25A2 EntityType lavType = new EntityType(); //1.1.225.2.41.3 Platform,Ground,USA,ArmoredFightingVehicle,LAV,LAV25A2
lavType.setEntityKind(EntityKind.PLATFORM); lavType.setEntityKind(EntityKind.PLATFORM);
...@@ -256,6 +257,7 @@ public class WhiteSimulation ...@@ -256,6 +257,7 @@ public class WhiteSimulation
eloc2.setY(loc2[1]); eloc2.setY(loc2[1]);
eloc2.setZ(loc2[2]); eloc2.setZ(loc2[2]);
entityStatePdu.setEntityLocation(eloc2); entityStatePdu.setEntityLocation(eloc2);
EulerAngles orient2 = new EulerAngles(); EulerAngles orient2 = new EulerAngles();
orient2.setPhi((float) 0.0); orient2.setPhi((float) 0.0);
orient2.setPsi((float) 0.0); orient2.setPsi((float) 0.0);
...@@ -298,10 +300,11 @@ public class WhiteSimulation ...@@ -298,10 +300,11 @@ public class WhiteSimulation
//FirePdu firePduNull = new FirePdu(); //FirePdu firePduNull = new FirePdu();
FirePdu firePdu = pduFactory.makeFirePdu(); FirePdu firePdu = pduFactory.makeFirePdu();
EntityID fireID = new EntityID(); EntityID fireID = new EntityID();
fireID.setSiteID(1); fireID.setSiteID(1);
fireID.setApplicationID(13); fireID.setApplicationID(13);
fireID.setEntityID(25); fireID.setEntityID(25);
EntityID targetID = new EntityID(); EntityID targetID = new EntityID();
targetID.setSiteID(1); targetID.setSiteID(1);
targetID.setApplicationID(13); targetID.setApplicationID(13);
...@@ -310,13 +313,14 @@ public class WhiteSimulation ...@@ -310,13 +313,14 @@ public class WhiteSimulation
firePdu.setFiringEntityID(fireID); firePdu.setFiringEntityID(fireID);
firePdu.setTargetEntityID(targetID); firePdu.setTargetEntityID(targetID);
EntityType HEType = new EntityType(); //2.9.225.2.2.1 EntityType HEType = new EntityType(); //2.9.225.2.2.1 MUNITION AIR USA BALLISTIC 25MM HEI-T
HEType.setEntityKind(EntityKind.MUNITION); HEType.setEntityKind(EntityKind.MUNITION);
HEType.setDomain(Domain.inst(PlatformDomain.AIR)); HEType.setDomain(Domain.inst(PlatformDomain.AIR));
HEType.setCountry(Country.UNITED_STATES_OF_AMERICA_USA); HEType.setCountry(Country.UNITED_STATES_OF_AMERICA_USA);
HEType.setCategory(2); HEType.setCategory(2);
HEType.setSubCategory(2); HEType.setSubCategory(2);
HEType.setSpecific(1); HEType.setSpecific(1);
MunitionDescriptor HEIT = new MunitionDescriptor(); MunitionDescriptor HEIT = new MunitionDescriptor();
HEIT.setMunitionType(HEType); HEIT.setMunitionType(HEType);
HEIT.setQuantity(3); HEIT.setQuantity(3);
...@@ -354,21 +358,19 @@ public class WhiteSimulation ...@@ -354,21 +358,19 @@ public class WhiteSimulation
// Where is my entity? // Where is my entity?
entityStatePdu.getEntityLocation().setX(entityStatePdu.getEntityLocation().getX() - 20); // 1m per timestep entityStatePdu.getEntityLocation().setX(entityStatePdu.getEntityLocation().getX() - 20); // 1m per timestep
entityStatePdu.getEntityLocation().setY(entityStatePdu.getEntityLocation().getY() - 75); entityStatePdu.getEntityLocation().setY(entityStatePdu.getEntityLocation().getY() - 75);
// decide whether to fire, and then update the firePdu. Hmmm, you might want a target to shoort at!
Double dx = eloc2.getX() - eloc1.getX(); Double dx = eloc2.getX() - eloc1.getX();
Double dy = eloc2.getY() - eloc1.getY(); Double dy = eloc2.getY() - eloc1.getY();
Double dz = eloc2.getZ() - eloc1.getZ(); Double dz = eloc2.getZ() - eloc1.getZ();
Double range = Math.sqrt(dx*dx + dy*dy); Double range = Math.sqrt(dx*dx + dy*dy);
System.out.println("range" + range + " dx:" +dx + " dy:"+ dy); System.out.println("range" + range + " dx:" +dx + " dy:"+ dy);
// etc. etc. your code goes here
if(range < 100){ if(range < 100){
if (!fireBool) if (!fireBool)
sendPDU(bmpSightedComment); sendPDU(bmpSightedComment);
fireBool = true; fireBool = true;
System.out.println("Entity#" + firePdu.getFiringEntityID().getEntityID() + " is firing " + firePdu.getDescriptor().getMunitionType().getDomain() + "."+firePdu.getDescriptor().getMunitionType().getCountry() + "." + firePdu.getDescriptor().getMunitionType().getCategory() + "."+ firePdu.getDescriptor().getMunitionType().getSubCategory() + "." + firePdu.getDescriptor().getMunitionType().getSpecific() + "."+ " at Entity#"+ firePdu.getTargetEntityID().getEntityID()); System.out.println("Entity#" + firePdu.getFiringEntityID().getEntityID() + " is firing " + firePdu.getDescriptor().getMunitionType().getDomain() + "."+firePdu.getDescriptor().getMunitionType().getCountry() + "." + firePdu.getDescriptor().getMunitionType().getCategory() + "."+ firePdu.getDescriptor().getMunitionType().getSubCategory() + "." + firePdu.getDescriptor().getMunitionType().getSpecific() + "."+ " at Entity#"+ firePdu.getTargetEntityID().getEntityID());
if(firePdu.getTargetEntityID().getEntityID() == 2){ if(firePdu.getTargetEntityID().getEntityID() == 2){
BMPHitsReceived += 1; BMPHitsReceived += 1;
if (BMPHitsReceived > 1) { if (BMPHitsReceived > 1) {
...@@ -449,12 +451,20 @@ public class WhiteSimulation ...@@ -449,12 +451,20 @@ public class WhiteSimulation
// Loop through sending one ESPDUs // Loop through sending one ESPDUs
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos); DataOutputStream dos = new DataOutputStream(baos);
DatagramPacket packet = new DatagramPacket(baos.toByteArray(), baos.size(), destinationIp, 2317);//trying new things
try { try {
pdu.marshal(dos); pdu.marshal(dos);
byte[] data = baos.toByteArray(); //byte[] data = baos.toByteArray();
DatagramPacket packet = new DatagramPacket(data, data.length, destinationIp, 2317); //DatagramPacket packet = new DatagramPacket(data, data.length, destinationIp, 2317);
packet.setData(baos.toByteArray());//
socket.send(packet); socket.send(packet);
dos.flush(); // immediately force pdu write
baos.reset();//
socket.close(); socket.close();
} catch (Exception ex) { } catch (Exception ex) {
Logger.getLogger(WhiteSimulation.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(WhiteSimulation.class.getName()).log(Level.SEVERE, null, ex);
......
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