Exemple #1
0
  /** die wichtigsten (zeitkritischen) Cmds, die in jedem State gelten */
  static boolean handleMsg(int val) {

    int data;

    if (val == BBSys.CMD_STATUS) {
      Msg.write(state);
      return true;
    }

    if (val == BBSys.CMD_STOP) {
      state = BBSys.MS_RDY;
      Triac.stop();
      Msg.write(0);
      return true;
    }
    if (val == BBSys.CMD_UP) {
      if (state == BBSys.MS_RDY) {
        state = BBSys.MS_UP;
        Triac.rauf();
        Msg.write(0);
      } else {
        Msg.err(1);
      }
      return true;
    }
    if (val == BBSys.CMD_DOWN) {
      if (state == BBSys.MS_RDY) {
        state = BBSys.MS_DOWN;
        Triac.runter();
        Msg.write(0);
      } else {
        Msg.err(1);
      }
      return true;
    }
    if (val == BBSys.CMD_PAUSE) {
      if (state == BBSys.MS_UP || state == BBSys.MS_DOWN) {
        Triac.pause();
        Msg.write(0);
      } else {
        Msg.err(1);
      }
      return true;
    }

    if (val == BBSys.CMD_INP) {
      Msg.write((JopSys.rd(BBSys.IO_SENSOR) << 4) + JopSys.rd(BBSys.IO_TAST));
      return true;
    }
    if (val == BBSys.CMD_OPTO) {
      Msg.write(Triac.getOpto());
      return true;
    }
    if (val == BBSys.CMD_CNT) {
      Msg.write(Triac.getCnt());
      return true;
    }
    return false;
  }
Exemple #2
0
  //
  //	Service loop:
  //		local control of triacs.
  //		never return => switch power off to resume from service
  //
  private static void doService() {

    // we need this to avoid a simple goto in the CFG
    boolean exit = false;

    JopSys.wr(0x01, BBSys.IO_LED);

    for (; exit; ) { // @WCA loop=1
      Msg.loop(); // only for replay to set state
      Triac.loop();

      int val = JopSys.rd(BBSys.IO_TAST);
      if (val == BBSys.BIT_TAB) {
        Triac.runter();
      } else if (val == BBSys.BIT_TAUF) {
        Triac.rauf();
      } else {
        Triac.stop();
      }
      KflTimer.wd();
      KflTimer.waitForNextInterval();
    }
  }