Exemple #1
0
  @Override
  public void execute(ChipState chip, boolean[] state, WithLineInfo<String>[] code)
      throws PlcException {

    boolean[] tt = new boolean[32];
    boolean a = chip.getInputCount() > 0 && chip.getInput(0);
    boolean b = chip.getInputCount() > 1 && chip.getInput(1);
    boolean c = chip.getInputCount() > 2 && chip.getInput(2);

    for (int i = 0; i < chip.getOutputCount(); i++)
      if (i < code.length) {
        Boolean r = executeFunction(i, state, tt, code, a, b, c, new boolean[0], new int[1], 0);
        if (r == null) {
          chip.setOutput(i, false);
        } else {
          chip.setOutput(i, r);
        }
      } else {
        chip.setOutput(i, false);
      }
  }
Exemple #2
0
  @Override
  public void trigger(ChipState chip) {

    int on = 0, valid = 0;
    for (int i = 0; i < chip.getInputCount(); i++) {

      if (chip.isValid(i)) {
        valid++;

        if (chip.getInput(i)) on++;
      }
    }

    // Condition; all valid must be ON, at least one valid.
    chip.setOutput(0, (on == valid && valid > 0));
  }