Exemplo n.º 1
0
  /**
   * @param objPath
   * @param ifaceMask
   * @throws ControlPanelException
   */
  Unit addControlPanel(String objPath, int ifaceMask) throws ControlPanelException {
    Log.d(
        TAG,
        "Creating ControlPanelCollection object for objPath: '"
            + objPath
            + "', device: '"
            + deviceId
            + "'");

    // parse the received object path
    String[] segments = CommunicationUtil.parseObjPath(objPath);
    String unitId = segments[0];
    String panelId = segments[1];

    Unit unit = unitMap.get(unitId);

    if (unit == null) {
      Log.v(TAG, "Found new functional unit: '" + unitId + "', panel: '" + panelId + "'");
      unit = new Unit(this, unitId);
      unitMap.put(unitId, unit); // Store the new unit object
    } else {
      Log.v(TAG, "Found an existent functional unit: '" + unitId + "', panel: '" + panelId + "'");
    }

    if (CommunicationUtil.maskIncludes(ifaceMask, HTTPControl.ID_MASK)) {
      Log.d(TAG, "The objPath: '" + objPath + "' belongs to the HTTPControl interface, setting");
      unit.setHttpControlObjPath(objPath);
    } else {
      unit.createControlPanelCollection(objPath, panelId);
    }

    return unit;
  } // createUnit
Exemplo n.º 2
0
  /**
   * Creates a NotificationAction control panel for the given objectPath <br>
   * The method should be used after establishment a session with a controllable device
   *
   * @param objectPath The object path to the created control panel
   * @return {@link ControlPanelCollection}
   * @throws ControlPanelException
   */
  public ControlPanelCollection createNotificationAction(String objectPath)
      throws ControlPanelException {

    if (sessionId == null) {
      throw new ControlPanelException(
          "The session wasn't established, can't create a ControlPanelCollection");
    }

    if (objectPath == null) {
      throw new ControlPanelException("Received an undefined objectPath");
    }

    Log.i(TAG, "Creating a NotificationAction control panel, objectPath: '" + objectPath + "'");

    String[] segments = CommunicationUtil.parseObjPath(objectPath);
    String unitId = segments[0];
    String panelName = segments[1];

    Unit unit = new Unit(this, unitId);
    ControlPanelCollection coll = unit.createControlPanelCollection(objectPath, panelName);
    coll.retrievePanels();
    coll.handleNotificationAction();

    return coll;
  } // addNotificationAction