private void generateActionList(Service serviceModel, Document descriptor, Element scpdElement) {

    Element actionListElement = appendNewElement(descriptor, scpdElement, ELEMENT.actionList);

    for (Action action : serviceModel.getActions()) {
      if (!action.getName().equals(QueryStateVariableAction.ACTION_NAME))
        generateAction(action, descriptor, actionListElement);
    }
  }
  private void generateAction(Action action, Document descriptor, Element actionListElement) {

    Element actionElement = appendNewElement(descriptor, actionListElement, ELEMENT.action);

    appendNewElementIfNotNull(descriptor, actionElement, ELEMENT.name, action.getName());

    if (action.hasArguments()) {
      Element argumentListElement =
          appendNewElement(descriptor, actionElement, ELEMENT.argumentList);
      for (ActionArgument actionArgument : action.getArguments()) {
        generateActionArgument(actionArgument, descriptor, argumentListElement);
      }
    }
  }
Пример #3
0
  @Override
  public void onInvoke() {

    ActionInvocation actionInvocation = new ActionInvocation(action, view.getInputValues());

    // Starts background thread
    Workbench.Log.ACTION_INVOCATION.info("Executing action: " + action.getName());
    ActionCallback actionCallback =
        new ControlActionCallback(actionInvocation) {
          @Override
          protected void onSuccess(final ActionArgumentValue[] values) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    view.setCancelEnabled(false);
                    view.setOutputValues(values);
                  }
                });
          }

          @Override
          public void failure(
              ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    view.setCancelEnabled(false);
                  }
                });
            super.failure(invocation, operation, defaultMsg);
          }
        };
    actionExecutionFuture = controlPoint.execute(actionCallback);
    view.setCancelEnabled(true);
  }
Пример #4
0
 @Override
 public void onCancel() {
   view.setCancelEnabled(false);
   if (actionExecutionFuture != null) {
     Workbench.Log.ACTION_INVOCATION.info("Interrupting action execution: " + action.getName());
     actionExecutionFuture.cancel(true);
   }
 }
  @SuppressWarnings({"rawtypes", "unchecked"})
  private ActionArgumentValue[] getArguments(final Action<RemoteService> action) {
    final ActionArgument[] actionArguments = action.getArguments();
    final Map<String, Object> argumentValues = getArgumentValues();
    final List<ActionArgumentValue<RemoteService>> actionArgumentValues =
        new ArrayList<>(actionArguments.length);

    for (final ActionArgument<RemoteService> actionArgument : actionArguments) {
      if (actionArgument.getDirection() == Direction.IN) {
        final Object value = argumentValues.get(actionArgument.getName());
        logger.trace(
            "Action {}: add arg value for {}: {} (expected datatype: {})",
            action.getName(),
            actionArgument,
            value,
            actionArgument.getDatatype().getDisplayString());
        actionArgumentValues.add(new ActionArgumentValue<>(actionArgument, value));
      }
    }
    return actionArgumentValues.toArray(new ActionArgumentValue[actionArgumentValues.size()]);
  }