Ejemplo n.º 1
0
  private void SetModeCommand(String command, String modeButton) throws IOException {
    System.out.println(command);
    out.write(ConversionUtils.stringToBytes(command + "\n"));

    checkMessageReceived();

    System.out.println(modeButton);
    out.write(ConversionUtils.stringToBytes(modeButton + "\n"));

    checkMessageReceived();
  }
Ejemplo n.º 2
0
        public void receiveData(byte[] data) {
          SetBusyEvent();
          selectedGame = ConversionUtils.stringFromBytes(data).toUpperCase();

          if (games == null
              || games.isEmpty()
              || portController == null
              || selectedConsole == null
              || selectedGame == null) return;

          int index = games.get(selectedConsole).indexOf(selectedGame);
          if (index < 0) {
            selectedGame = games.get(selectedConsole).get(0);
            SetReadyEvent();
            return;
          }

          if (games.get(selectedConsole).get(index) != null) {
            setMode(selectedConsole, games.get(selectedConsole).get(index));
            selectedGame = games.get(selectedConsole).get(index);
          } else if (games.get(selectedConsole).get(0) != null) {
            setMode(selectedConsole, games.get(selectedConsole).get(0));
            selectedGame = games.get(selectedConsole).get(0);
          }

          OutputGame(selectedGame);
          SetReadyEvent();
        }
Ejemplo n.º 3
0
  private void switchModeForSaving(int modeToLoad) {
    try {
      out.write(ConversionUtils.stringToBytes("AT NEXT\n"));

      checkMessageReceived();
      checkMessageReceived();

      out.write(ConversionUtils.stringToBytes("AT LOAD " + modeToLoad + "\n"));

      checkMessageReceived();
      checkMessageReceived();

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Ejemplo n.º 4
0
 public void SetCommand(String command) throws IOException {
   System.out.println(command);
   out.write(ConversionUtils.stringToBytes(command + "\n"));
   String message = checkMessageReceived();
   //		System.out.println(message);
   if (message.contains("2.0")) {
     System.out.println("Fabi2.0 is detected!");
   } else {
     System.out.println("#ERROR: Only Fabi2.0 is supported!");
   }
 }
Ejemplo n.º 5
0
  private void saveToEEPROM(int modeToLoad) {
    try {
      System.out.println("save mode to EEPROM");
      out.write(ConversionUtils.stringToBytes("AT SAVE " + modeToLoad + "\n"));

      checkMessageReceived();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Ejemplo n.º 6
0
        public void receiveEvent(final String data) {
          SetBusyEvent();
          deleteEEPROM();

          if (selectedConsole == null) {
            selectedConsole = consoles.get(0);
            OutputConsole(selectedConsole);
            SetReadyEvent();
            return;
          }

          int index = consoles.indexOf(selectedConsole);

          if (index < 0) {
            selectedConsole = consoles.get(0);
            OutputConsole(selectedConsole);
            SetReadyEvent();
            return;
          }

          if ((consoles.size() - 1) >= (index + 1)) {
            if (consoles.get(index + 1) != null) {
              selectedConsole = consoles.get(index + 1);

              // setMode(consoles.get(index+1),
              // games.get(index+1).get(0));
            }
          } else if (consoles.get(0) != null) {
            selectedConsole = consoles.get(0);
            // setMode(consoles.get(0), games.get(consoles.get(0)).get(0));
          }

          OutputConsole(selectedConsole);
          opOutGame.sendData(ConversionUtils.stringToBytes(""));
          opOutMode.sendData(ConversionUtils.stringToBytes(""));
          SetReadyEvent();

          loadNewModel(selectedConsole);
        }
Ejemplo n.º 7
0
        public void receiveData(byte[] data) {
          String text = ConversionUtils.stringFromBytes(data);
          // Logger.getAnonymousLogger().info("KNX received: " + text);

          if (text.startsWith("@KNX:")) {
            try {

              StringTokenizer st = new StringTokenizer(text.substring(5), "#");
              // Logger.getAnonymousLogger().info("Tokenizing: " + text.substring(5));
              sendKNX(st.nextToken(), st.nextToken(), st.nextToken());
            } catch (Exception e) {
              Logger.getAnonymousLogger().severe(e.toString());
            }
          }
        }
Ejemplo n.º 8
0
  private void deleteEEPROM() {

    try {
      if (out == null) {
        System.out.println("Problem with COM Port!");
        return;
      }
      System.out.println("AT CLEAR");
      out.write(ConversionUtils.stringToBytes("AT CLEAR\n"));
      checkMessageReceived();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Ejemplo n.º 9
0
  private void switchMode(int modeToLoad) {
    ShowButtons(modeToLoad);
    ShowButtons(modeToLoad);
    try {
      OutputMode(modeToLoad);
      System.out.println("switch Mode");

      out.write(ConversionUtils.stringToBytes("AT LOAD " + modeToLoad + "\n"));

      checkMessageReceived();
      checkMessageReceived();

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Ejemplo n.º 10
0
        public void receiveData(byte[] data) {
          selectedConsole = ConversionUtils.stringFromBytes(data).toUpperCase();

          if (consoles == null
              || consoles.isEmpty()
              || portController == null
              || selectedConsole == null) return;

          if (consoles.indexOf(selectedConsole) < 0) {
            System.out.println("Console " + selectedConsole + " does not exist in config file!");
            if (consoles.get(0) != null) {
              selectedConsole = consoles.get(0);
            }
          }
          OutputConsole(selectedConsole);

          loadNewModel(selectedConsole);
        }
Ejemplo n.º 11
0
  public void ShowButtons(int modeToLoad) {
    String buttons = "";
    ArrayList<ArrayList<String>> eachMode;
    Map<String, ArrayList<ArrayList<String>>> gameMode;

    gameMode = modes.get(selectedConsole.toUpperCase());
    eachMode = gameMode.get(selectedGame.toUpperCase());

    ArrayList<String> mode = eachMode.get(modeToLoad - 1);
    for (String config : mode) {
      if (config.contains("KEY_CTRL KEY_ESC")) {
        config = "Modus/Zurueck";
      } else if (config.contains("KEY_")) {
        config = config.replace("KEY_", "");
      }
      buttons += config + ",";
    }
    System.out.println("Buttons : " + buttons);
    opOutButtons.sendData(ConversionUtils.stringToBytes(buttons));
  }
Ejemplo n.º 12
0
 /** Called with input data, transfer it to the corresponding output */
 public void receiveData(byte[] data) {
   int value = ConversionUtils.byteArrayToInt(data);
   owner.processInput(value, index);
 }
Ejemplo n.º 13
0
 public void receiveData(byte[] data) {
   in6 = ConversionUtils.doubleFromBytes(data);
   sendKNX(propGroupAddressSlider6, new String("int"), Integer.toString((int) (in6)));
 }
Ejemplo n.º 14
0
 public void loadNewModel(String model) {
   opOutModel.sendData(ConversionUtils.stringToBytes(model + ".acs"));
   etploadModel.raiseEvent();
 }
Ejemplo n.º 15
0
 public void OutputGame(String text) {
   System.out.print(
       "################################################################################");
   System.out.println("Load Game " + text);
   opOutGame.sendData(ConversionUtils.stringToBytes(text));
 }