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

Added further model detail. TODO fix sendSinglePduDelayed thread handling since it is blocking...

parent 175b8d19
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,8 @@ package SimkitOpenDis7Examples; ...@@ -2,6 +2,8 @@ package SimkitOpenDis7Examples;
import edu.nps.moves.dis7.enumerations.DisPduType; import edu.nps.moves.dis7.enumerations.DisPduType;
import edu.nps.moves.dis7.pdus.EntityStatePdu; import edu.nps.moves.dis7.pdus.EntityStatePdu;
import edu.nps.moves.dis7.pdus.EulerAngles;
import edu.nps.moves.dis7.pdus.Vector3Double;
import edu.nps.moves.dis7.utilities.DisChannel; import edu.nps.moves.dis7.utilities.DisChannel;
import edu.nps.moves.dis7.utilities.PduFactory; import edu.nps.moves.dis7.utilities.PduFactory;
import java.util.SortedSet; import java.util.SortedSet;
...@@ -22,7 +24,8 @@ import simkit.SimEntityBase; ...@@ -22,7 +24,8 @@ import simkit.SimEntityBase;
*/ */
public class TwoCraneBerthsOpenDis7 extends SimEntityBase public class TwoCraneBerthsOpenDis7 extends SimEntityBase
{ {
private final DisChannel disChannel = new DisChannel(); // Utility constructor method: initial descriptor and verboseness of disNetworkInterface, pduRecorder
private final DisChannel disChannel = new DisChannel("TwoCraneBerthsOpenDis7", false, true);
/** /**
* Queue of Ships waiting to go into the berth * Queue of Ships waiting to go into the berth
...@@ -185,52 +188,82 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase ...@@ -185,52 +188,82 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase
waitDelay("EndUnloadingOneCrane", ship.getRemainingUnloadingTime(), ship); waitDelay("EndUnloadingOneCrane", ship.getRemainingUnloadingTime(), ship);
} }
PduFactory pduFactory = new PduFactory(); // can be member variables (for efficiency, move above) or else embdedded within method (move below)
PduFactory pduFactory = new PduFactory();
EntityStatePdu espduCrane = (EntityStatePdu) pduFactory.createPdu(DisPduType.ENTITY_STATE);
/**
* Perform crane unloading operations and send PDUs to report progress
* @param numberContainers how many containers to offload
* @param positionOfCrane Y coordinate down pier across from ship's berth, aligned with cargo
*/
public void performCraneUnloadOperations( public void performCraneUnloadOperations(
// which crane // which crane
// which berth // which berth
int numberOfContainers, int numberContainers,
double positionOfCrane double positionOfCrane
// lenthOfCrane // lengthOfCrane
) )
{ {
// Pier coordinate system follows, Right-Hand Rule (RHR) throughout:
// +X axis to right with X=0 on centerline of pier (train tracks
// +Y axis down pier with Y=0 at head of pier,
// +Z axis vertical with Z=0 at level of pier
// phi is rotation about +X axis, radians
// theta is rotation about +Y axis, radians
// psi is rotation about +X axis, radians
double craneLinearSpeed = 1.0; // m/sec double craneLinearSpeed = 1.0; // m/sec
double craneRotationRate = 10.0; // degrees/second double craneRotationRate = 10.0; // degrees/second
double containerHookupTime = 60.0; // seconds average double containerHookupTime = 60.0; // seconds average
double containerDetachTime = 30.0; // seconds average double containerDetachTime = 30.0; // seconds average
Vector3Double positionPierHead = new Vector3Double();
// Vector3Double positionPierHead = new Vector3Double(0.0, 0.0, 0.0); // TODO needs utility constructor
EntityStatePdu espduCrane = (EntityStatePdu) pduFactory.createPdu(DisPduType.ENTITY_STATE); // not modeling crane elevation angle, only orientation of crane cab and gantry
// 1. Crane at head of pier, operatior present, boom elevated vertically in stow postion EulerAngles orientationToShip = (new EulerAngles()).setPsi((float) (90.0 * Math.PI/180.0)); // TODO utility methods needed
// espduCrane1.setPosition 0 0 0 EulerAngles orientationToPier = (new EulerAngles()).setPsi((float) ( 0.0 * Math.PI/180.0)); // TODO utility methods needed
// espduCrane.reset(); // TODO intialization utility method
// espduCrane.setEntityAppearance(TODO); // highlight active crane?
// 1. Crane at head of pier, operator present, boom elevated vertically in stow postion
// espduCrane.setEntityLocation(0.0, 0.0, 0.0); // ambiguous, error prone
espduCrane.setEntityLocation(positionPierHead); // preferred
// 2, Ship arrives, tug departs // 2, Ship arrives, tug departs
// shop PDU here or assum it happened earlier // ship PDU could be sent here, or probably more logical to ensure it happened earlier
// 3. Crane moves to position of ship // 3. Crane moves to position of ship
espduCrane.setEntityLocation(positionOfCrane, 0.0, 0.0); espduCrane.setEntityLocation(positionOfCrane, 0.0, 0.0); // head of pier, ambiguous
// TODO compute travel time // TODO compute travel time
// update: travel to positionOfCrane by craneLinearSpeed // update: travel to positionOfCrane by craneLinearSpeed
// 4. repeat until done: Crane rotates, lift container, rotates, lower container // 4. repeat until done: Crane rotates, lift container, rotates, lower container
for (int containerIndex = 1; containerIndex <= numberOfContainers; containerIndex++) for (int containerIndex = 1; containerIndex <= numberContainers; containerIndex++)
{ {
// perform one operation // perform one operation
espduCrane.setEntityOrientation(0, 0, 0); espduCrane.setEntityOrientation(orientationToShip);
disChannel.sendSinglePdu(espduCrane); disChannel.sendSinglePdu(espduCrane);
espduCrane.setEntityOrientation(0, 0, 0); espduCrane.setEntityOrientation(orientationToPier);
double rotationDelay = 90.0 / craneRotationRate; double rotationDelay = 90.0 / craneRotationRate; // units analysis: degrees / (degrees/second) = seconds
disChannel.sendCommentPdu(disChannel.COMMENTPDU_NARRATIVE, "Hooking up Container " + containerIndex + " to crane"); disChannel.sendCommentPdu(disChannel.COMMENTPDU_NARRATIVE, "Hooking up Container " + containerIndex + " to crane");
disChannel.sendSinglePduDelayed(containerHookupTime, espduCrane);
// TODO fix sendSinglePduDelayed thread handling since it is blocking...
// disChannel.sendSinglePduDelayed(containerHookupTime, espduCrane);
disChannel.sendCommentPdu(disChannel.COMMENTPDU_NARRATIVE, "Container hooked up"); disChannel.sendCommentPdu(disChannel.COMMENTPDU_NARRATIVE, "Container hooked up");
disChannel.sendSinglePduDelayed(containerHookupTime, espduCrane);
espduCrane.setEntityOrientation(90, 0, 0); // espduCrane.setEntityOrientation(0, 0, 90); // ambiguous, degrees or radians? TODO javadoc
disChannel.sendSinglePduDelayed(rotationDelay, espduCrane); espduCrane.setEntityOrientation(orientationToPier);
// TODO fix sendSinglePduDelayed thread handling since it is blocking...
// disChannel.sendSinglePduDelayed(containerHookupTime + rotationDelay, espduCrane);
// unhook // unhook
// rotate back // rotate back
// send PDUs accordingly
// if this container is special, meaning on watchlist, report it // Future work: if this container is special, meaning on watchlist, report it
} }
// 4. Crane stows boom in vertical position // 4. Crane stows boom in vertical position
......
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