예제 #1
0
 public void setNextDestination() {
   Floor location = car.getLocation();
   Assignment newAssignment = assignments.getCurrentAssignment();
   if (location != null && !location.getCallPanel().isDown() && !location.getCallPanel().isUp()) {
     while (newAssignment != null && newAssignment.getDestination() == location) {
       assignments.removeAssignment(newAssignment);
       newAssignment = assignments.getCurrentAssignment();
     }
   }
   if (newAssignment != null) car.setDestination(newAssignment.getDestination());
 }
예제 #2
0
 public boolean arrive(HashSet<Assignment> RequestAssignments) {
   // TODO Auto-generated method stub
   Floor location = car.getLocation();
   List serviceFloors = car.getFloorRequestPanel().getServicedFloors();
   Floor topFloor = (Floor) serviceFloors.get(serviceFloors.size() - 1);
   Floor bottomFloor = (Floor) serviceFloors.get(0);
   // remove from up/down list
   Assignment currentAssignment = assignments.getCurrentAssignment();
   if (RequestAssignments.contains(currentAssignment))
     RequestAssignments.remove(currentAssignment);
   assignments.removeAssignment(currentAssignment);
   // If the next assignment is on the same floor but going the other way
   // the doors would close and re-open.
   // To prevent this, we can remove that assignment and indicate that
   // we're at the "extreme" position, ready to go the other direction.
   Assignment newAssignment = assignments.getCurrentAssignment();
   while (newAssignment != null && newAssignment.getDestination() == location) {
     assignments.removeAssignment(newAssignment);
     if (RequestAssignments.contains(newAssignment)) RequestAssignments.remove(newAssignment);
     if (currentAssignment.getDirection() == Direction.UP) topFloor = location;
     else bottomFloor = location;
     newAssignment = assignments.getCurrentAssignment();
   }
   /*if (newAssignment!=null){
   	Floor floor=newAssignment.getDestination();
   	if (!serviceFloors.contains(floor)){
   		if (newAssignment.getDirection().isUp()){
   			if (!floor.getCallPanel().isUp())
   				assignments.removeAssignment(newAssignment);
   		}else{
   			if (!floor.getCallPanel().isDown())
   				assignments.removeAssignment(newAssignment);
   		}
   	}
   }*/
   boolean wasUp = currentAssignment.getDirection().isUp();
   boolean atExtreme = (wasUp && location == topFloor) || (!wasUp && location == bottomFloor);
   boolean isUp = atExtreme ? !wasUp : wasUp;
   return isUp;
 }