コード例 #1
0
  @Override
  protected DataMessageComponent getTransformedMessage(List<DataMessageComponent> cache)
      throws ProcessingException {

    final DataMessageComponent ret = MessageUtils.mergeAll(cache);
    ret.putScalar("message_text", "Hello World");
    return ret;
  }
コード例 #2
0
  protected DataMessageComponent getTransformedMessage(
      List<DataMessageComponent> port1Cache, List<DataMessageComponent> port2Cache)
      throws ProcessingException {

    final List<IDataset> sets1 = MessageUtils.getDatasets(port1Cache);
    final List<IDataset> sets2 = MessageUtils.getDatasets(port2Cache);
    final Collection<IDataset> sets = new HashSet<IDataset>(7);
    if (sets1 != null) sets.addAll(sets1);
    if (sets2 != null) sets.addAll(sets2);
    final AbstractDataset prod = Maths.multiply(sets, isCreateClone());

    try {
      final DataMessageComponent ret = new DataMessageComponent();
      ret.setList(prod);
      setUpstreamValues(ret, port1Cache, port2Cache);
      ret.putScalar("operation_names", MessageUtils.getNames(sets));
      return ret;

    } catch (Exception e) {
      throw createDataMessageException("Cannot generate multiplied data sets", e);
    }
  }
コード例 #3
0
  @Override
  protected DataMessageComponent getTransformedMessage(List<DataMessageComponent> cache)
      throws DataMessageException {

    // get the data out of the message, name of the item should be specified
    final Map<String, Serializable> data = MessageUtils.getList(cache);
    Map<String, AFunction> functions;
    try {
      functions = MessageUtils.getFunctions(cache);
    } catch (Exception e) {
      throw new DataMessageException(
          "Could not parse the Funcitons comming into the FunctionToDatsetActor", null, e);
    }

    // prepare the output message
    DataMessageComponent result = MessageUtils.copy(cache);

    // get the required datasets
    String dataset = datasetName.getExpression();
    String xAxis = xAxisName.getExpression();
    String functionString = functionName.getExpression();

    // Get the actual objects
    Dataset xAxisDS = DatasetFactory.createFromObject(data.get(xAxis)).clone();
    AFunction function = functions.get(functionString);

    populateDataBasedFunctions(data, function);

    // process the data
    // TODO Add Null Protection here.
    DoubleDataset createdDS = function.calculateValues(xAxisDS);
    createdDS.setName(dataset);

    // Add it to the result
    result.addList(createdDS.getName(), createdDS);

    return result;
  }
コード例 #4
0
  @Override
  protected DataMessageComponent getTransformedMessage(List<DataMessageComponent> cache)
      throws ProcessingException {

    try {
      final MotorContainer cont =
          (MotorContainer) motorsParam.getBeanFromValue(MotorContainer.class);
      final DataMessageComponent comp = MessageUtils.mergeAll(cache);

      if (cont == null) {
        comp.putScalar("error_messsage", "No motors configured, '" + getName() + "' did nothing.");
        return comp;
      }

      final Map<String, String> values = setMotors(cont, comp);
      if (values != null) comp.addScalar(values);

      return comp;

    } catch (Exception e) {
      throw createDataMessageException("Cannot set motor values!", e);
    }
  }