Skip to content
Snippets Groups Projects
Commit 8d109880 authored by J. M. Bailey's avatar J. M. Bailey
Browse files

Fix for most recent release

parent afee964b
No related branches found
No related tags found
No related merge requests found
...@@ -35,15 +35,15 @@ endorsed.classpath= ...@@ -35,15 +35,15 @@ endorsed.classpath=
excludes= excludes=
file.reference.dis-enums-1.3.jar=../lib/dis-enums-1.3.jar file.reference.dis-enums-1.3.jar=../lib/dis-enums-1.3.jar
file.reference.open-dis7-entities-all.jar=../lib/open-dis7-entities-all.jar file.reference.open-dis7-entities-all.jar=../lib/open-dis7-entities-all.jar
file.reference.open-dis7.jar=../lib/open-dis7.jar file.reference.open-dis7-java.jar=../lib/open-dis7-java.jar
file.reference.open-dis_4.16.jar=../lib/open-dis_4.16.jar file.reference.open-dis_4.16.jar=../lib/open-dis_4.16.jar
includes=** includes=**
jar.compress=false jar.compress=false
javac.classpath=\ javac.classpath=\
${file.reference.open-dis7.jar}:\ ${file.reference.open-dis7-java.jar}:\
${file.reference.open-dis7-entities-all.jar}:\ ${file.reference.open-dis7-entities-all.jar}:\
${file.reference.dis-enums-1.3.jar}:\ ${file.reference.open-dis_4.16.jar}:\
${file.reference.open-dis_4.16.jar} ${file.reference.dis-enums-1.3.jar}
# Space-separated list of extra javac options # Space-separated list of extra javac options
javac.compilerargs= javac.compilerargs=
javac.deprecation=false javac.deprecation=false
...@@ -69,6 +69,7 @@ javadoc.noindex=false ...@@ -69,6 +69,7 @@ javadoc.noindex=false
javadoc.nonavbar=false javadoc.nonavbar=false
javadoc.notree=false javadoc.notree=false
javadoc.private=false javadoc.private=false
javadoc.reference.open-dis7-java.jar=../lib/open-dis7-javadoc.jar
javadoc.splitindex=true javadoc.splitindex=true
javadoc.use=true javadoc.use=true
javadoc.version=false javadoc.version=false
...@@ -95,4 +96,5 @@ run.test.classpath=\ ...@@ -95,4 +96,5 @@ run.test.classpath=\
run.test.modulepath=\ run.test.modulepath=\
${javac.test.modulepath} ${javac.test.modulepath}
source.encoding=UTF-8 source.encoding=UTF-8
source.reference.open-dis7-java.jar=../lib/open-dis7-source.jar
src.dir=src src.dir=src
package OpenDis7Examples; package OpenDis7Examples;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
import edu.nps.moves.dis7.*; import edu.nps.moves.dis7.*;
import edu.nps.moves.dis7.util.*; import edu.nps.moves.dis7.util.*;
import edu.nps.moves.disenum.PduType;
/**
/** * Receives PDUs from the network in IEEE DIS format.
* Receives PDUs from the network in IEEE DIS format. * Adapted from OpenDIS library example package edu.nps.moves.examples
* Adapted from OpenDIS library example package edu.nps.moves.examples *
* * @author DMcG
* @author DMcG * @version $Id:$
* @version $Id:$ */
*/ public class EspduReceiver
public class EspduReceiver {
{ /** Max size of a PDU in binary format that we can receive. This is actually
/** 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.
* somewhat outdated--PDUs can be larger--but this is a reasonable starting point. */
*/ public static final int MAX_PDU_SIZE = 8192;
public static final int MAX_PDU_SIZE = 8192;
/** Default multicast group address we send on. */
/** Default multicast group address we send on. */ public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3";
public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3";
/** Default multicast port used, matches Wireshark DIS capture default */
/** Default multicast port used, matches Wireshark DIS capture default */ public static final int DEFAULT_MULTICAST_PORT = 3000;
public static final int DEFAULT_MULTICAST_PORT = 3000;
public static void main(String args[])
public static void main(String args[]) {
{ System.out.println("DisExamplesOpenDis7.EspduReceiver started...");
System.out.println("DisExamplesOpenDis7.EspduReceiver started...");
MulticastSocket socket;
MulticastSocket socket; DatagramPacket packet;
DatagramPacket packet; InetAddress address;
InetAddress address; PduFactory pduFactory = new PduFactory();
PduFactory pduFactory = new PduFactory();
try {
try { // Specify the socket to receive data
// Specify the socket to receive data socket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); socket.setBroadcast(true);
socket.setBroadcast(true);
// address = InetAddress.getByName(EspduSender.DEFAULT_MULTICAST_GROUP);
// address = InetAddress.getByName(EspduSender.DEFAULT_MULTICAST_GROUP); // socket.joinGroup(address);
// socket.joinGroup(address);
while (true) // Loop infinitely, receiving datagrams
while (true) // Loop infinitely, receiving datagrams {
{ byte buffer[] = new byte[MAX_PDU_SIZE];
byte buffer[] = new byte[MAX_PDU_SIZE]; packet = new DatagramPacket(buffer, buffer.length);
packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet);
socket.receive(packet);
List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData(),packet.getLength());
List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData()); if (pduBundle.size() > 1)
if (pduBundle.size() > 1) System.out.println("Bundle size is " + pduBundle.size());
System.out.println("Bundle size is " + pduBundle.size()); Iterator iterator = pduBundle.iterator();
Iterator iterator = pduBundle.iterator();
while(iterator.hasNext())
while(iterator.hasNext()) {
{ Pdu aPdu = (Pdu)iterator.next();
Pdu aPdu = (Pdu)iterator.next();
System.out.println("received PDU " + aPdu.getPduType().getValue() + " " + aPdu.getPduType().name() + " of type " + aPdu.getClass().getName());
System.out.println("received PDU " + aPdu.getPduType().getValue() + " " + aPdu.getPduType().name() + " of type " + aPdu.getClass().getName()); if(aPdu instanceof EntityStatePdu)
if(aPdu instanceof EntityStatePdu) {
{ EntityID eid = ((EntityStatePdu)aPdu).getEntityID();
EntityID eid = ((EntityStatePdu)aPdu).getEntityID(); Vector3Double position = ((EntityStatePdu)aPdu).getEntityLocation();
Vector3Double position = ((EntityStatePdu)aPdu).getEntityLocation(); System.out.println(" ID triplet: [" + eid.getSiteID()+ ", " + eid.getApplicationID()+ ", " + eid.getEntityID()+ "] ");
System.out.println(" ID triplet: [" + eid.getSiteID()+ ", " + eid.getApplicationID()+ ", " + eid.getEntityID()+ "] "); System.out.println(" Location in DIS coordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]");
System.out.println(" Location in DIS coordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]"); }
// TODO fix library! } // end iterator loop through PDU bundle
System.out.println("** TODO error, 'PDU not implemented' is a library bug"); } // end while
} } // End try
} // end iterator loop through PDU bundle catch (IOException e)
} // end while {
} // End try System.out.println("Problem with DisExamplesOpenDis7.EspduReceiver, see exception trace:");
catch (IOException e) System.out.println(e);
{ }
System.out.println("Problem with DisExamplesOpenDis7.EspduReceiver, see exception trace:"); System.out.println("DisExamplesOpenDis7.EspduReceiver complete.");
System.out.println(e); } // end main
} } // end class
System.out.println("DisExamplesOpenDis7.EspduReceiver complete.");
} // end main
} // end class
package OpenDis7Examples; package OpenDis7Examples;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
import edu.nps.moves.dis7.*; import edu.nps.moves.dis7.*;
import edu.nps.moves.dis7.enumerations.*; import edu.nps.moves.dis7.enumerations.*;
/** /**
* This is an example that sends many/most types of PDUs. Useful for testing standards * This is an example that sends many/most types of PDUs. Useful for testing standards
* compliance or getting a full set of PDUs. It also writes the generated PDUs to an XML file. * compliance or getting a full set of PDUs. It also writes the generated PDUs to an XML file.
* Adapted from OpenDIS library example package edu.nps.moves.examples * Adapted from OpenDIS library example package edu.nps.moves.examples
* *
* @author DMcG * @author DMcG
* @version $Id:$ * @version $Id:$
*/ */
public class PduSender public class PduSender
{ {
/** Default multicast group address we send on. */ /** Default multicast group address we send on. */
public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3"; public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3";
/** Default multicast port used, matches Wireshark DIS capture default */ /** Default multicast port used, matches Wireshark DIS capture default */
public static final int DEFAULT_MULTICAST_PORT = 3000; public static final int DEFAULT_MULTICAST_PORT = 3000;
private int port; private int port;
InetAddress multicastAddress; InetAddress multicastAddress;
public PduSender(int port, String multicast) { public PduSender(int port, String multicast) {
try try
{ {
this.port = port; this.port = port;
multicastAddress = InetAddress.getByName(multicast); multicastAddress = InetAddress.getByName(multicast);
if (!multicastAddress.isMulticastAddress()) if (!multicastAddress.isMulticastAddress())
{ {
System.out.println("Not a multicast address: " + multicast); System.out.println("Not a multicast address: " + multicast);
} }
} }
catch (UnknownHostException e) { catch (UnknownHostException e) {
System.out.println("Unable to open socket: " + e); System.out.println("Unable to open socket: " + e);
} }
} }
public void run() public void run()
{ {
System.out.println("DisExamplesOpenDis7.PduSender started..."); System.out.println("DisExamplesOpenDis7.PduSender started...");
try try
{ {
System.out.println("Generate PDUs and note issues (if any)..."); System.out.println("Generate PDUs and note issues (if any)...");
List<Pdu> generatedPdusList = new ArrayList<>(); List<Pdu> generatedPdusList = new ArrayList<>();
// Loop through all the enumerated PDU types, create a PDU for each type, // Loop through all the enumerated PDU types, create a PDU for each type,
// add that PDU to generatedPdusList, and send each one // add that PDU to generatedPdusList, and send each one
for (DISPDUType pdu : DISPDUType.values()) for (DISPDUType pdu : DISPDUType.values())
{ {
// System.out.println("PDU " + pdu.getValue() + " " + pdu.name() + " " + pdu.getDescription()); // diagnostic // System.out.println("PDU " + pdu.getValue() + " " + pdu.name() + " " + pdu.getDescription()); // diagnostic
Pdu aPdu = null; // edu.​nps.​moves7.​dis.PDU superclass for all PDUs, in preparation for custom assignment Pdu aPdu = null; // edu.​nps.​moves7.​dis.PDU superclass for all PDUs, in preparation for custom assignment
try { try {
switch (pdu) // using enumeration values from edu.​nps.​moves.​dis7.​enumerations.​DISPDUType switch (pdu) // using enumeration values from edu.​nps.​moves.​dis7.​enumerations.​DISPDUType
{ {
case OTHER: // 0 case OTHER: // 0
System.out.println ("*** Note: DISPDUType." + pdu.name() + " not supported"); // TODO explain System.out.println ("*** Note: DISPDUType." + pdu.name() + " not supported"); // TODO explain
// nothing to send // nothing to send
break; break;
case ENTITY_STATE: // 1 case ENTITY_STATE: // 1
aPdu = new EntityStatePdu(); aPdu = new EntityStatePdu();
EntityStatePdu espdu = (EntityStatePdu) aPdu; EntityStatePdu espdu = (EntityStatePdu) aPdu;
EntityMarking entityMarking = new EntityMarking (); EntityMarking entityMarking = new EntityMarking ();
entityMarking.setCharacters("PduSender".getBytes()); //entityMarking.setCharacters(Byte.valueOf("0")); // 11 characters max? entityMarking.setCharacters("PduSender".getBytes()); //entityMarking.setCharacters(Byte.valueOf("0")); // 11 characters max?
espdu.setMarking(entityMarking); espdu.setMarking(entityMarking);
Vector3Double espduLocation = new Vector3Double(); Vector3Double espduLocation = new Vector3Double();
espduLocation.setX(1.0); espduLocation.setX(1.0);
espduLocation.setY(2.0); espduLocation.setY(2.0);
espduLocation.setZ(3.0); espduLocation.setZ(3.0);
espdu.setEntityLocation(espduLocation); espdu.setEntityLocation(espduLocation);
// it is important to identify questions as you think of them // it is important to identify questions as you think of them
// TODO how to set azimuth, i.e. course direction over ground? // TODO how to set azimuth, i.e. course direction over ground?
break; break;
case FIRE: // 2 case FIRE: // 2
aPdu = new FirePdu(); aPdu = new FirePdu();
break; break;
case DETONATION: // 3 case DETONATION: // 3
aPdu = new DetonationPdu(); aPdu = new DetonationPdu();
break; break;
case COLLISION: // 4 case COLLISION: // 4
aPdu = new CollisionPdu(); aPdu = new CollisionPdu();
break; break;
case SERVICE_REQUEST: // 5 case SERVICE_REQUEST: // 5
aPdu = new ServiceRequestPdu(); aPdu = new ServiceRequestPdu();
break; break;
case RESUPPLY_OFFER: // 6 case RESUPPLY_OFFER: // 6
aPdu = new ResupplyOfferPdu(); aPdu = new ResupplyOfferPdu();
break; break;
case RESUPPLY_RECEIVED: // 7 case RESUPPLY_RECEIVED: // 7
aPdu = new ResupplyReceivedPdu(); aPdu = new ResupplyReceivedPdu();
break; break;
case RESUPPLY_CANCEL: //8 case RESUPPLY_CANCEL: //8
aPdu = new ResupplyCancelPdu(); aPdu = new ResupplyCancelPdu();
break; break;
case REPAIR_COMPLETE: // 9 case REPAIR_COMPLETE: // 9
aPdu = new RepairCompletePdu(); aPdu = new RepairCompletePdu();
break; break;
case REPAIR_RESPONSE: // 10 case REPAIR_RESPONSE: // 10
aPdu = new RepairResponsePdu(); aPdu = new RepairResponsePdu();
break; break;
case CREATE_ENTITY: // 11 case CREATE_ENTITY: // 11
aPdu = new CreateEntityPdu(); aPdu = new CreateEntityPdu();
break; break;
case REMOVE_ENTITY: // 12 case REMOVE_ENTITY: // 12
aPdu = new RemoveEntityPdu(); aPdu = new RemoveEntityPdu();
break; break;
case START_RESUME: // 13 case START_RESUME: // 13
aPdu = new StartResumePdu(); aPdu = new StartResumePdu();
break; break;
case STOP_FREEZE: // 14 case STOP_FREEZE: // 14
aPdu = new StopFreezePdu(); aPdu = new StopFreezePdu();
break; break;
case ACKNOWLEDGE: // 15 case ACKNOWLEDGE: // 15
aPdu = new AcknowledgePdu(); aPdu = new AcknowledgePdu();
break; break;
case ACTION_REQUEST: // 16 case ACTION_REQUEST: // 16
aPdu = new ActionRequestPdu(); aPdu = new ActionRequestPdu();
break; break;
case ACTION_RESPONSE: // 17 case ACTION_RESPONSE: // 17
aPdu = new ActionResponsePdu(); aPdu = new ActionResponsePdu();
break; break;
case DATA_QUERY: // 18 case DATA_QUERY: // 18
aPdu = new DataQueryPdu(); aPdu = new DataQueryPdu();
break; break;
case SET_DATA: // 19 case SET_DATA: // 19
aPdu = new SetDataPdu(); aPdu = new SetDataPdu();
break; break;
case DATA: // 20 case DATA: // 20
aPdu = new DataPdu(); aPdu = new DataPdu();
break; break;
case EVENT_REPORT: // 21 case EVENT_REPORT: // 21
aPdu = new EventReportPdu(); aPdu = new EventReportPdu();
break; break;
case ELECTROMAGNETIC_EMISSION: // 23 case ELECTROMAGNETIC_EMISSION: // 23
aPdu = new ElectromagneticEmissionPdu(); aPdu = new ElectromagneticEmissionPdu();
break; break;
case DESIGNATOR: // 24 case DESIGNATOR: // 24
aPdu = new DesignatorPdu(); aPdu = new DesignatorPdu();
break; break;
case TRANSMITTER: // 25 case TRANSMITTER: // 25
aPdu = new TransmitterPdu(); aPdu = new TransmitterPdu();
break; break;
case SIGNAL: // 26 case SIGNAL: // 26
aPdu = new SignalPdu(); aPdu = new SignalPdu();
break; break;
case RECEIVER: // 27 case RECEIVER: // 27
aPdu = new ReceiverPdu(); aPdu = new ReceiverPdu();
break; break;
case IDENTIFICATION_FRIEND_OR_FOE: // 28 case IDENTIFICATION_FRIEND_OR_FOE: // 28
aPdu = new IdentificationFriendOrFoePdu(); aPdu = new IdentificationFriendOrFoePdu();
break; break;
case IFF: // 28
// aPdu = new IFFPdu(); // ignore, avoid sending duplicate case UNDERWATER_ACOUSTIC: // 29
break; aPdu = new UnderwaterAcousticPdu();
break;
case UNDERWATER_ACOUSTIC: // 29
aPdu = new UnderwaterAcousticPdu(); case SUPPLEMENTAL_EMISSION_ENTITY_STATE: // 30
break; aPdu = new SupplementalEmissionEntityStatePdu();
break;
case SUPPLEMENTAL_EMISSION_ENTITY_STATE: // 30
aPdu = new SupplementalEmissionEntityStatePdu(); case INTERCOM_SIGNAL: // 31
break; aPdu = new IntercomSignalPdu();
break;
case SEES: // 30
// aPdu = new SEESPdu(); // ignore, avoid sending duplicate case INTERCOM_CONTROL: // 32
break; aPdu = new IntercomControlPdu();
break;
case INTERCOM_SIGNAL: // 31
aPdu = new IntercomSignalPdu(); case AGGREGATE_STATE: // 33
break; aPdu = new AggregateStatePdu();
break;
case INTERCOM_CONTROL: // 32
aPdu = new IntercomControlPdu(); case ISGROUPOF: // 34
break; aPdu = new IsGroupOfPdu();
break;
case AGGREGATE_STATE: // 33
aPdu = new AggregateStatePdu(); case TRANSFER_OWNERSHIP: // 35
break; aPdu = new TransferOwnershipPdu();
break;
case ISGROUPOF: // 34
aPdu = new IsGroupOfPdu(); case ISPARTOF: // 36
break; aPdu = new IsPartOfPdu();
break;
case TRANSFER_OWNERSHIP: // 35
aPdu = new TransferOwnershipPdu(); case MINEFIELD_STATE: // 37
break; aPdu = new MinefieldStatePdu();
break;
case ISPARTOF: // 36
aPdu = new IsPartOfPdu(); case MINEFIELD_QUERY: // 38
break; aPdu = new MinefieldQueryPdu();
break;
case MINEFIELD_STATE: // 37
aPdu = new MinefieldStatePdu(); case MINEFIELD_DATA: // 39
break; aPdu = new MinefieldDataPdu();
break;
case MINEFIELD_QUERY: // 38
aPdu = new MinefieldQueryPdu(); case MINEFIELD_RESPONSE_NACK: // 40
break; aPdu = new MinefieldResponseNACKPdu();
break;
case MINEFIELD_DATA: // 39
aPdu = new MinefieldDataPdu(); case ENVIRONMENTAL_PROCESS: // 41
break; aPdu = new EnvironmentalProcessPdu();
break;
case MINEFIELD_RESPONSE_NACK: // 40
aPdu = new MinefieldResponseNACKPdu(); case GRIDDED_DATA: // 42
break; aPdu = new GriddedDataPdu();
break;
case ENVIRONMENTAL_PROCESS: // 41
aPdu = new EnvironmentalProcessPdu(); case POINT_OBJECT_STATE: // 43
break; aPdu = new PointObjectStatePdu();
break;
case GRIDDED_DATA: // 42
aPdu = new GriddedDataPdu(); case LINEAR_OBJECT_STATE: // 44
break; aPdu = new LinearObjectStatePdu();
break;
case POINT_OBJECT_STATE: // 43
aPdu = new PointObjectStatePdu(); case AREAL_OBJECT_STATE: // 45
break; aPdu = new ArealObjectStatePdu();
break;
case LINEAR_OBJECT_STATE: // 44
aPdu = new LinearObjectStatePdu(); case TIME_SPACE_POSITION_INFORMATION: // 46
break; aPdu = new TimeSpacePositionInformationPdu();
break;
case AREAL_OBJECT_STATE: // 45
aPdu = new ArealObjectStatePdu(); case APPEARANCE: // 47
break; aPdu = new AppearancePdu();
break;
case TIME_SPACE_POSITION_INFORMATION: // 46
aPdu = new TimeSpacePositionInformationPdu(); case ARTICULATED_PARTS: // 48
break; aPdu = new ArticulatedPartsPdu();
case TSPI: // 46 break;
// aPdu = new TSPIPdu(); // ignore, avoid sending duplicate
break; case LIVE_ENTITY_FIRE: // 49
aPdu = new LiveEntityFirePdu();
case APPEARANCE: // 47 break;
aPdu = new AppearancePdu();
break; case LIVE_ENTITY_DETONATION: // 50
aPdu = new LiveEntityDetonationPdu();
case ARTICULATED_PARTS: // 48 break;
aPdu = new ArticulatedPartsPdu();
break; case CREATE_ENTITY_RELIABLE: // 51
aPdu = new CreateEntityReliablePdu();
case LIVE_ENTITY_FIRE: // 49 break;
aPdu = new LiveEntityFirePdu();
break; case REMOVE_ENTITY_RELIABLE: // 52
case LE_FIRE: // 49 aPdu = new RemoveEntityReliablePdu();
// aPdu = new LEFirePdu(); // ignore, avoid sending duplicate break;
break;
case START_RESUME_RELIABLE: // 53
case LIVE_ENTITY_DETONATION: // 50 aPdu = new StartResumeReliablePdu();
aPdu = new LiveEntityDetonationPdu(); break;
break;
case LE_DETONATION: // 50 case STOP_FREEZE_RELIABLE: // 54
// aPdu = new LEDetonationPdu(); // ignore, avoid sending duplicate aPdu = new StopFreezeReliablePdu();
break; break;
case CREATE_ENTITY_RELIABLE: // 51 case ACKNOWLEDGE_RELIABLE: // 55
aPdu = new CreateEntityReliablePdu(); aPdu = new AcknowledgeReliablePdu();
break; break;
case CREATE_ENTITY_R: // 51
// aPdu = new CreateEntityRPdu(); // ignore, avoid sending duplicate case ACTION_REQUEST_RELIABLE: // 56
break; aPdu = new ActionRequestReliablePdu();
break;
case REMOVE_ENTITY_RELIABLE: // 52
aPdu = new RemoveEntityReliablePdu(); case ACTION_RESPONSE_RELIABLE: // 57
break; aPdu = new ActionResponseReliablePdu();
case REMOVE_ENTITY_R: // 52 break;
// aPdu = new RemoveEntityRPdu(); // ignore, avoid sending duplicate
break; case DATA_QUERY_RELIABLE: // 58
aPdu = new DataQueryReliablePdu();
case START_RESUME_RELIABLE: // 53 break;
aPdu = new StartResumeReliablePdu();
break; case SET_DATA_RELIABLE: // 59
case START_RESUME_R: // 53 aPdu = new SetDataReliablePdu();
// aPdu = new StartResumeRPdu(); // ignore, avoid sending duplicate break;
break;
case DATA_RELIABLE: // 60
case STOP_FREEZE_RELIABLE: // 54 aPdu = new DataReliablePdu();
aPdu = new StopFreezeReliablePdu(); break;
break;
case STOP_FREEZE_R: // 54 case EVENT_REPORT_RELIABLE: // 61
// aPdu = new StopFreezeRPdu(); // ignore, avoid sending duplicate aPdu = new EventReportReliablePdu();
break; break;
case ACKNOWLEDGE_RELIABLE: // 55 case COMMENT_RELIABLE: // 62
aPdu = new AcknowledgeReliablePdu(); aPdu = new CommentReliablePdu();
break; break;
case ACKNOWLEDGE_R: // 55
// aPdu = new AcknowledgeRPdu(); // ignore, avoid sending duplicate case RECORD_RELIABLE: // 63
break; aPdu = new RecordReliablePdu();
break;
case ACTION_REQUEST_RELIABLE: // 56
aPdu = new ActionRequestReliablePdu(); case SET_RECORD_RELIABLE: // 64
break; aPdu = new SetRecordReliablePdu();
case ACTION_REQUEST_R: // 56 break;
// aPdu = new ActionRequestRPdu(); // ignore, avoid sending duplicate
break; case RECORD_QUERY_RELIABLE: // 65
aPdu = new RecordQueryReliablePdu();
case ACTION_RESPONSE_RELIABLE: // 57 break;
aPdu = new ActionResponseReliablePdu();
break; case COLLISION_ELASTIC: // 66
case ACTION_RESPONSE_R: // 57 aPdu = new CollisionElasticPdu();
// aPdu = new ActionResponseRPdu(); // ignore, avoid sending duplicate break;
break;
case ENTITY_STATE_UPDATE: // 67
case DATA_QUERY_RELIABLE: // 58 aPdu = new EntityStateUpdatePdu();
aPdu = new DataQueryReliablePdu(); break;
break;
case DATA_QUERY_R: // 58 case DIRECTED_ENERGY_FIRE: // 68
// aPdu = new DataQueryRPdu(); // ignore, avoid sending duplicate aPdu = new DirectedEnergyFirePdu();
break; break;
case SET_DATA_RELIABLE: // 59 case ENTITY_DAMAGE_STATUS: // 69
aPdu = new SetDataReliablePdu(); aPdu = new EntityDamageStatusPdu();
break; break;
case SET_DATA_R: // 59
// aPdu = new SetDataRPdu(); // ignore, avoid sending duplicate case INFORMATION_OPERATIONS_ACTION: // 70
break; aPdu = new InformationOperationsActionPdu();
break;
case DATA_RELIABLE: // 60
aPdu = new DataReliablePdu(); case INFORMATION_OPERATIONS_REPORT: // 71
break; aPdu = new InformationOperationsReportPdu();
case DATA_R: // 60 break;
// aPdu = new DataRPdu(); // ignore, avoid sending duplicate
break; case ATTRIBUTE: // 72
aPdu = new AttributePdu();
case EVENT_REPORT_RELIABLE: // 61 break;
aPdu = new EventReportReliablePdu();
break; case COMMENT:
case EVENT_REPORT_R: // 61 aPdu = new CommentPdu();
// aPdu = new EventReportRPdu(); // ignore, avoid sending duplicate CommentPdu newCommentPdu = (CommentPdu)aPdu;
break; VariableDatum newVariableDatum = new VariableDatum();
// etc. see Garrett and Pete's code
case COMMENT_RELIABLE: // 62 break;
aPdu = new CommentReliablePdu();
break; default:
case COMMENT_R: // 62 System.out.println("*** Warning: PDU " + pdu.getValue() + " " + pdu + " not supported, created or sent ");
// aPdu = new CommentRPdu(); // ignore, avoid sending duplicate
break; // code generation block for this class follows:
// System.out.println(" case " + pdu + ": // " + pdu.getValue());
case RECORD_RELIABLE: // 63 // System.out.println(" aPdu = new " + pdu.getDescription().replace(" ","").replace("-","").replace("/","") +
aPdu = new RecordReliablePdu(); // "Pdu();");
break; // System.out.println(" break;");
case RECORD_R: // 63 // System.out.println();
// aPdu = new RecordRPdu(); // ignore, avoid sending duplicate }
break; if (aPdu != null)
{
case SET_RECORD_RELIABLE: // 64 generatedPdusList.add(aPdu);
aPdu = new SetRecordReliablePdu(); }
break; }
case SET_RECORD_R: // 64 catch (Exception e)
// aPdu = new SetRecordRPdu(); // ignore, avoid sending duplicate {
break; System.out.print("Exception thrown for PDU " + pdu.getValue() + " " + pdu);
System.out.print(Arrays.toString(e.getStackTrace()));
case RECORD_QUERY_RELIABLE: // 65 // continue looping
aPdu = new RecordQueryReliablePdu(); }
break; }
case RECORD_QUERY_R: // 65 // Send the PDUs we created
// aPdu = new RecordQueryRPdu(); // ignore, avoid sending duplicate System.out.println("Send the " + generatedPdusList.size() + " PDUs we created...");
break;
InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS);
case COLLISION_ELASTIC: // 66 MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
aPdu = new CollisionElasticPdu(); socket.joinGroup(localMulticastAddress);
break;
for (int idx = 0; idx < generatedPdusList.size(); idx++)
case ENTITY_STATE_UPDATE: // 67 {
aPdu = new EntityStateUpdatePdu(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
break; DataOutputStream dos = new DataOutputStream(baos);
byte[] buffer;
case DIRECTED_ENERGY_FIRE: // 68
aPdu = new DirectedEnergyFirePdu(); Pdu aPdu = generatedPdusList.get(idx);
break; aPdu.marshal(dos);
case ENTITY_DAMAGE_STATUS: // 69 buffer = baos.toByteArray();
aPdu = new EntityDamageStatusPdu(); DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT);
break; socket.send(packet);
System.out.println("Sent PDU " + aPdu.getPduType().getValue() + " " + aPdu.getPduType() + " of type " + aPdu.getClass().getName());
case INFORMATION_OPERATIONS_ACTION: // 70 }
aPdu = new InformationOperationsActionPdu(); // write the PDUs out to an XML file.
break; //PduContainer container = new PduContainer();
//container.setPdus(generatedPdus);
case INFORMATION_OPERATIONS_REPORT: // 71 //container.marshallToXml("examplePdus.xml");
aPdu = new InformationOperationsReportPdu(); }
break; catch (IOException e)
{
case ATTRIBUTE: // 72 System.out.println(e);
aPdu = new AttributePdu(); }
break; }
case COMMENT: public static void main(String args[])
aPdu = new CommentPdu(); {
CommentPdu newCommentPdu = (CommentPdu)aPdu; if (args.length == 2)
VariableDatum newVariableDatum = new VariableDatum(); {
// etc. see Garrett and Pete's code PduSender sender = new PduSender(Integer.parseInt(args[0]), args[1]);
break; sender.run();
}
default: else
System.out.println("*** Warning: PDU " + pdu.getValue() + " " + pdu + " not supported, created or sent "); {
System.out.println("Usage: PduSender <port> <multicast group>");
// code generation block for this class follows: System.out.println("Default: PduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS);
// System.out.println(" case " + pdu + ": // " + pdu.getValue()); PduSender sender = new PduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS);
// System.out.println(" aPdu = new " + pdu.getDescription().replace(" ","").replace("-","").replace("/","") + sender.run();
// "Pdu();"); }
// System.out.println(" break;"); }
// System.out.println(); }
}
if (aPdu != null)
{
generatedPdusList.add(aPdu);
}
}
catch (Exception e)
{
System.out.print("Exception thrown for PDU " + pdu.getValue() + " " + pdu);
System.out.print(Arrays.toString(e.getStackTrace()));
// continue looping
}
}
// Send the PDUs we created
System.out.println("Send the " + generatedPdusList.size() + " PDUs we created...");
InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS);
MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
socket.joinGroup(localMulticastAddress);
for (int idx = 0; idx < generatedPdusList.size(); idx++)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
byte[] buffer;
Pdu aPdu = generatedPdusList.get(idx);
aPdu.marshal(dos);
buffer = baos.toByteArray();
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT);
socket.send(packet);
System.out.println("Sent PDU " + aPdu.getPduType().getValue() + " " + aPdu.getPduType() + " of type " + aPdu.getClass().getName());
}
// write the PDUs out to an XML file.
//PduContainer container = new PduContainer();
//container.setPdus(generatedPdus);
//container.marshallToXml("examplePdus.xml");
}
catch (IOException e)
{
System.out.println(e);
}
}
public static void main(String args[])
{
if (args.length == 2)
{
PduSender sender = new PduSender(Integer.parseInt(args[0]), args[1]);
sender.run();
}
else
{
System.out.println("Usage: PduSender <port> <multicast group>");
System.out.println("Default: PduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS);
PduSender sender = new PduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS);
sender.run();
}
}
}
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