Example #1
0
  @Override
  public void run() {

    while (!_shutDown
        || _futureOrders.size()
            > 0) { // Procceed if there's no shut down request OR there are still orders being
                   // cooked.

      try {
        Future<Order> futureOrder =
            _superExecutor.take(); // Waiting until the future object is done, then take it.

        _futureOrders.remove(futureOrder); // remove the future order from the vector.

        try {
          releaseOrder(futureOrder.get()); // Release the order back to the management.
        } catch (ExecutionException e) {
          e.printStackTrace();
        }
        _management.notifyThis(); // notify Management, so he knows a chef has done his work.

      } catch (InterruptedException e) {
      }
    }
    _executor.shutdown(); // shut down the Callable Cook Whole Order.

    // }
  }
 /** Run method is used for acoustic signals and reboot after 10s */
 public void run() {
   // generate acoustic error signal if property is enabled
   if ("true".equals(Management.getProperty("buzzer.systembeep"))) {
     // we use PWM to bypass the property "buzzer.enable"
     PWM.setFrequency(400);
     PWM.setDuty(Buzzer.BUZZERCHANNEL, 128);
     PWM.setActive(Buzzer.BUZZERCHANNEL, true);
     try {
       ThreadExt.sleep(500);
       PWM.setFrequency(200);
       ThreadExt.sleep(250);
     } catch (InterruptedException e) {
     }
     PWM.setActive(Buzzer.BUZZERCHANNEL, false);
   }
   try {
     // wait for 10 sek.
     ThreadExt.sleep(10000);
     // reboot device
     Management.reboot(true);
   } catch (InterruptedException e) {
   }
 }
Example #3
0
 public void releaseOrder(Order order) { // Release the order back to the management.
   _management.getOrder(order);
   decreasePressure(order.getDifficultyRating());
   // Logger message for completing an order.
   logger.info(" ORDER {} IS COMPLETED", order.getID());
 }
Example #4
0
  public static void main(String[] args) {
    Management m = new Management();

    int input = 0;
    m.init();
    while (true) {
      m.showList();

      switch (input = m.selectList()) {
        case 1:
          m.insertInfo();
          break;

        case 2:
          m.sortByRank();
          m.showGradeByRank();
          break;

        case 3:
          m.sortByNum();
          m.showGradeByNum();
          break;

        case 4:
          m.showGradeInDetail();
          break;

        case 5:
          m.changePeople();
          break;

        case 6:
          m.showSelectDelete();
          m.deleteInfo();
          break;

        case 7:
          System.exit(0);
      }
    }
  }
  /**
   * Display the error message.
   *
   * @param code the error code.
   * @param message the error message (textual error description).
   * @param jpc points to the last bytecode to be executed when the error occured.
   * @param npc points to the machine instruction that was producing the error.
   * @param jpcext set if jpc points to external memory (e.g. flash).
   * @see onError(int code, int jpc, int npc, boolean jpcext).
   */
  public static void onError(int code, String message, int jpc, int npc, boolean jpcext) {

    // set current flash bank where error occured
    String jpcbank;
    if (jpcext) {
      jpcbank = Management.getProperty("system.userbank");
      if (jpcbank == null) jpcbank = "0";
    } else {
      // when jpcext is set, error was caused by ROM code
      jpcbank = "f";
    }

    // Print the error message to the RS232 port, using standard
    // communication parameters.
    // When the RS232-Terminal of the JControl/IDE is opened, this message
    // is used to
    // back-trace the error automatically.
    try {
      RS232 rs232 = new RS232();
      String errorString =
          "\nJControl/ErrorHandler: Code="
              .concat(String.valueOf(code))
              .concat(" NPC=0xf")
              .concat(Integer.toHexString(npc))
              .concat(" JPC=0x")
              .concat(jpcbank)
              .concat(Integer.toHexString(jpc))
              .concat("\n");
      rs232.write(errorString.getBytes(), 0, errorString.length());
      rs232.close();
    } catch (IOException e) {
    }

    // create keyboard instance
    m_keyboard = new Keyboard();

    // start timing thread to control buzzer signals and reboot
    Thread t = new Thread(new ErrorHandler());
    t.setDaemon(true);
    t.start();

    // generate error message string when not passed by caller
    if (message == null) {
      if ((code < 0) || (code >= ERROR_MESSAGES.length)) {
        message = "ErrorCode 0x".concat(Integer.toHexString(code));
      } else {
        message = ERROR_MESSAGES[code];
      }
    }

    // Print the error message to the RS232 port, using standard
    // communication parameters.
    // When the RS232-Terminal of the JControl/IDE is opened, this message
    // is used to
    // back-trace the error automatically.
    try {
      RS232 rs232 = new RS232();
      String errorString =
          "\nJControl/ErrorHandler: Code="
              .concat(String.valueOf(code))
              .concat(" NPC=0xf")
              .concat(Integer.toHexString(npc))
              .concat(" JPC=0x")
              .concat(jpcbank)
              .concat(Integer.toHexString(jpc))
              .concat("\n");
      rs232.write(errorString.getBytes(), 0, errorString.length());
      rs232.close();
    } catch (IOException e) {
    }

    // wait for keypress
    m_keyboard.read();
  }
 @Override
 public void onBlockBurn(BlockBurnEvent event) {
   manager.burnBlock(event.getBlock());
 }
 @Override
 public void onBlockBreak(BlockBreakEvent event) {
   manager.removeBlock(event.getBlock(), event.getPlayer());
 }
 @Override
 public void onBlockPlace(BlockPlaceEvent event) {
   manager.placeBlock(event.getBlockPlaced(), event.getPlayer());
 }