diff --git a/examples/src/SimkitOpenDis7Examples/TwoCraneBerthsOpenDis7.java b/examples/src/SimkitOpenDis7Examples/TwoCraneBerthsOpenDis7.java index 4c1a91a971d4c5e5cf24d879f7b47f2651e1d26f..8299b965fb7c571cab5ca51ca55ff81aa0edd17f 100644 --- a/examples/src/SimkitOpenDis7Examples/TwoCraneBerthsOpenDis7.java +++ b/examples/src/SimkitOpenDis7Examples/TwoCraneBerthsOpenDis7.java @@ -1,5 +1,9 @@ package SimkitOpenDis7Examples; +import edu.nps.moves.dis7.enumerations.DisPduType; +import edu.nps.moves.dis7.pdus.EntityStatePdu; +import edu.nps.moves.dis7.utilities.DisChannel; +import edu.nps.moves.dis7.utilities.PduFactory; import java.util.SortedSet; import java.util.TreeSet; import simkit.Priority; @@ -16,7 +20,9 @@ import simkit.SimEntityBase; * @author abuss@nps.edu@nps.edu * @author brutzman@nps.edu */ -public class TwoCraneBerthsOpenDis7 extends SimEntityBase { +public class TwoCraneBerthsOpenDis7 extends SimEntityBase +{ + private final DisChannel disChannel = new DisChannel(); /** * Queue of Ships waiting to go into the berth @@ -159,7 +165,7 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase { */ public void doStartUnloadingOneCrane() { SortedSet<Ship> oldQueue = getQueue(); - Ship ship = queue.first(); + Ship ship = queue.first(); // TODO rename ship queue queue.remove(ship); firePropertyChange("queue", oldQueue, getQueue()); @@ -171,9 +177,70 @@ public class TwoCraneBerthsOpenDis7 extends SimEntityBase { SortedSet<Ship> oldBerth = getBerth(); berth.add(ship); firePropertyChange("berth", oldBerth, getBerth()); + + performCraneUnloadOperations( 10, // numberOfContainers + 0.0 // initial position + ); // TODO indicate berth waitDelay("EndUnloadingOneCrane", ship.getRemainingUnloadingTime(), ship); } + + PduFactory pduFactory = new PduFactory(); + public void performCraneUnloadOperations( + // which crane + // which berth + int numberOfContainers, + double positionOfCrane + // lenthOfCrane + ) + { + double craneLinearSpeed = 1.0; // m/sec + double craneRotationRate = 10.0; // degrees/second + double containerHookupTime = 60.0; // seconds average + double containerDetachTime = 30.0; // seconds average + + EntityStatePdu espduCrane = (EntityStatePdu) pduFactory.createPdu(DisPduType.ENTITY_STATE); + // 1. Crane at head of pier, operatior present, boom elevated vertically in stow postion + // espduCrane1.setPosition 0 0 0 + + // 2, Ship arrives, tug departs + // shop PDU here or assum it happened earlier + + // 3. Crane moves to position of ship + espduCrane.setEntityLocation(positionOfCrane, 0.0, 0.0); + // TODO compute travel time + // update: travel to positionOfCrane by craneLinearSpeed + + // 4. repeat until done: Crane rotates, lift container, rotates, lower container + for (int containerIndex = 1; containerIndex <= numberOfContainers; containerIndex++) + { + // perform one operation + espduCrane.setEntityOrientation(0, 0, 0); + disChannel.sendSinglePdu(espduCrane); + espduCrane.setEntityOrientation(0, 0, 0); + double rotationDelay = 90.0 / craneRotationRate; + disChannel.sendCommentPdu(disChannel.COMMENTPDU_NARRATIVE, "Hooking up Container " + containerIndex + " to crane"); + disChannel.sendSinglePduDelayed(containerHookupTime, espduCrane); + disChannel.sendCommentPdu(disChannel.COMMENTPDU_NARRATIVE, "Container hooked up"); + disChannel.sendSinglePduDelayed(containerHookupTime, espduCrane); + + espduCrane.setEntityOrientation(90, 0, 0); + disChannel.sendSinglePduDelayed(rotationDelay, espduCrane); + + // unhook + // rotate back + + // if this container is special, meaning on watchlist, report it + } + + // 4. Crane stows boom in vertical position + // espcudCrnet orientation + + // 5. Crane returns to head of pier + // update: travel from positionOfCrane to head by craneLinearSpeed + espduCrane.setEntityLocation(positionOfCrane, 0.0, 0.0); + disChannel.sendSinglePdu(espduCrane); + } /** * Remove given Ship from berth<br>