示例#1
0
  public boolean pickAndExecuteAnAction() {
    if (conveyorBroken || sensorBroken) {
      stopConveyor();
      return false;
    } else if (partGroupCount < partGroupEndOfConveyor) {
      System.err.println(getName() + " has an unexpected number of sensor events");
      System.err.println(getName() + " is now stopping");
      Object[] args = new Object[1];
      args[0] = myIndex * 2;
      transducer.fireEvent(TChannel.GUI, TEvent.SENSOR_BROKEN, args);
      sensorBroken = true;
      stopConveyor();
      return false;
    } else if (partsLoaded > partGroupEndOfConveyor) {
      System.err.println("Truck loaded untracked part\n" + getName() + " is now stopping");
      Object[] args = new Object[1];
      args[0] = myIndex * 2 + 1;
      transducer.fireEvent(TChannel.GUI, TEvent.SENSOR_BROKEN, args);
      sensorBroken = true;
      stopConveyor();
      return false;
    } else if (!parts.isEmpty()) {
      if (isRunning) {
        if (followSensorDepressed && myState != MyState.Normal) {
          stopConveyor();
        }
      } else if (myState == MyState.Normal || !followSensorDepressed) {
        startConveyor();
      }
    }

    if (myState == MyState.DoneLoading && !truckBroken) emptyTruck();

    return false;
  }
示例#2
0
 private void emptyTruck() {
   partsLoaded = 0;
   myState = MyState.Unloading;
   cfLead.msgConveyorReady(this);
   partGroupCount = partGroupEndOfConveyor = 0;
   transducer.fireEvent(TChannel.TRUCK, TEvent.TRUCK_DO_EMPTY, null);
 }
示例#3
0
  private void startConveyor() {
    if (!isRunning) {
      isRunning = true;
      startConveyorTimer.restart();
      conveyorRestart = true;

      Object[] args = new Object[1];
      args[0] = myIndex;
      transducer.fireEvent(TChannel.CONVEYOR, TEvent.CONVEYOR_DO_START, args);
      stateChanged();
    }
  }
示例#4
0
  private void stopConveyor() {
    if (isRunning) {
      isRunning = false;
      if (!parts.isEmpty()) {
        readyMessageTimer.stop();
        startConveyorTimer.stop();
      }

      Object[] args = new Object[1];
      args[0] = myIndex;
      transducer.fireEvent(TChannel.CONVEYOR, TEvent.CONVEYOR_DO_STOP, args);

      stateChanged();
    }
  }