Exemplo n.º 1
0
  /**
   * Feed the bytes from the EEPROM file to the editor blocks one after another with an updated bit
   * offset. The block objects are responsible for further feeding the bits and bytes to their
   * contained editor components.
   *
   * @param data
   */
  private void readFromEepromArray(byte[] eeprom) {
    int offset = 0;

    // Switch all blocks of so no blocks are displayed that are not used for the device if anything
    // goes wrong reading the bytes from the file (e.g. file too short).
    for (Block b : blocks) {
      b.setVisible(false);
    }

    for (Block b : blocks) {
      boolean match = true;

      // If a block has a condition set, check it and override
      // using this block if it is not matched.
      if (b.restrictionRefID != null) {
        String val = findValue(b.restrictionRefID, false);
        match = val.equals(b.restrictionValue);
      }

      b.setVisible(match);

      if (match) {
        int bitsProcessed = b.readFromEepromArray(eeprom, offset);
        offset += bitsProcessed;
      }
    }

    length = offset;
  }
Exemplo n.º 2
0
  /**
   * Assume that blocks are restricted by the DeviceType only (as true for smarthomatic) and switch
   * the blocks on/off using the given deviceTypeID. This is for use for the Firmware source code
   * creation process ONLY!
   *
   * @param deviceTypeID
   */
  public void enableEditorsForDeviceType(int deviceTypeID) {
    byte[] dummy = new byte[1024];
    int offset = 0;

    for (Block b : blocks) {
      boolean match = true;

      // If a block has a condition set, check it and override
      // using this block if it is not matched.
      if ((b.restrictionRefID != null) && b.restrictionRefID.equals("DeviceType")) {
        match = b.restrictionValue.equals("" + deviceTypeID);
      }

      b.setVisible(match);

      if (match) {
        int bitsProcessed = b.readFromEepromArray(dummy, offset);
        offset += bitsProcessed;
      }
    }
  }