Skip to content
Snippets Groups Projects
Commit 8958ae7f authored by jonathanboron's avatar jonathanboron
Browse files

HW4 update 2, javadocs added

parent 3313ec2e
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,15 @@ public class BoronEntityStatePduCreator { ...@@ -15,6 +15,15 @@ public class BoronEntityStatePduCreator {
*/ */
public BoronEntityStatePduCreator(){} public BoronEntityStatePduCreator(){}
/**
* Creates and returns a new Entity State PDU
* @param s is a 16 bit ID
* @param fid is a force ID enumeration
* @param l is a double array containing position x,y,z coordinates
* @param v is a float array containing x,y,z velocity values
* @param o is a float array containing phi, psi, and theta orientation values
* @returns a new EntityStatePdu with minimal information
*/
public EntityStatePdu newPDU(short s, ForceID fid, double [] l, float[] v, float[] o) public EntityStatePdu newPDU(short s, ForceID fid, double [] l, float[] v, float[] o)
{ {
//Create new entity state PDU and set ID and Force ID //Create new entity state PDU and set ID and Force ID
......
...@@ -95,21 +95,27 @@ public class BoronPduSender ...@@ -95,21 +95,27 @@ public class BoronPduSender
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
//For demonstration purposes, ID is a random short. A larger program would
//have a more elaborate ID assignment system to prevent duplication.
short id = (short)rand.nextInt(10000); short id = (short)rand.nextInt(10000);
//Generate random x,y,z coordinates between 0 and 10
double[] l = new double[] double[] l = new double[]
{ {
rand.nextInt(10) + rand.nextDouble(), rand.nextInt(10) + rand.nextDouble(),
rand.nextInt(10) + rand.nextDouble(), rand.nextInt(10) + rand.nextDouble(),
rand.nextInt(10) + rand.nextDouble() rand.nextInt(10) + rand.nextDouble()
}; };
//Generate random velocity
float[] v = new float[] float[] v = new float[]
{ {
rand.nextFloat(), rand.nextFloat(),
rand.nextFloat(), rand.nextFloat(),
rand.nextFloat() rand.nextFloat()
}; };
//Generate random orientation
float[] o = new float[] float[] o = new float[]
{ {
rand.nextFloat(), rand.nextFloat(),
...@@ -117,11 +123,13 @@ public class BoronPduSender ...@@ -117,11 +123,13 @@ public class BoronPduSender
rand.nextFloat() rand.nextFloat()
}; };
//Add entity PDUs to the list to send out
generatedPdusList.add(espduCreator.newPDU(id, ForceID.FRIENDLY, l, v, o)); generatedPdusList.add(espduCreator.newPDU(id, ForceID.FRIENDLY, l, v, o));
} }
System.out.println("Send the " + generatedPdusList.size() + " PDUs we created..."); System.out.println("Send the " + generatedPdusList.size() + " PDUs we created...");
//Send the PDUs
if (args.length == 2) if (args.length == 2)
{ {
BoronPduSender sender = new BoronPduSender(Integer.parseInt(args[0]), args[1]); BoronPduSender sender = new BoronPduSender(Integer.parseInt(args[0]), args[1]);
......
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