Example #1
0
  @Override
  public Collection<StateVariableValue> readEventedStateVariableValues(boolean isNewSubscription)
      throws Exception {
    lock();
    try {
      Collection<StateVariableValue> values;
      if (isNewSubscription) {
        values = readInitialEventedStateVariableValues();
        if (values != null) {
          log.fine(
              "Obtained initial state variable values for event, skipping individual state variable accessors");
          return values;
        }
      }

      values = new ArrayList();
      for (StateVariable stateVariable : getService().getStateVariables()) {
        if (stateVariable.getEventDetails().isSendEvents()) {

          StateVariableAccessor accessor = getService().getAccessor(stateVariable);
          if (accessor == null)
            throw new IllegalStateException("No accessor for evented state variable");

          values.add(accessor.read(stateVariable, getImplementation()));
        }
      }
      return values;

    } finally {
      unlock();
    }
  }
Example #2
0
  private Collection<StateVariableValue> readEventedStateVariableValues(List<String> variableNames)
      throws Exception {
    lock();
    try {

      Collection<StateVariableValue> values = new ArrayList<StateVariableValue>();

      for (String variableName : variableNames) {

        StateVariable stateVariable = getService().getStateVariable(variableName);
        if (stateVariable == null || !stateVariable.getEventDetails().isSendEvents()) {
          log.warning("ignoring unknown or non-eventing variable: " + variableName);
          continue;
        }

        StateVariableAccessor accessor = getService().getAccessor(stateVariable);
        if (accessor == null) {
          log.warning("ignoring eventing variable without accessor: " + variableName);
          continue;
        }

        values.add(accessor.read(stateVariable, getImplementation()));
      }

      return values;

    } finally {
      unlock();
    }
  }