private void calculateAndDeliverAggregationValue(final AggregationVariableSet variables) { final double aggregationValue; final NamedDoubleTimeSeriesPoint tsPoint; synchronized (this) { final int listSize = variables.getAggregationList().size(); final double[] a = new double[listSize]; for (int i = 0; i < listSize; i++) { a[i] = variables.getAggregationList().get(i).getValue(); } aggregationValue = this.aggregationMethod.getAggregationValue(a); tsPoint = new NamedDoubleTimeSeriesPoint(variables.getLastTimestampInCurrentInterval(), aggregationValue, variables.getAggregationList().get(0).getName()); // use name of first element (any will do) variables.getAggregationList().clear(); } super.deliver(OUTPUT_PORT_NAME_AGGREGATED_TSPOINT, tsPoint); }
@Override public Configuration getCurrentConfiguration() { final Configuration configuration = new Configuration(); configuration.setProperty(CONFIG_PROPERTY_NAME_AGGREGATION_SPAN, Long.toString(this.aggregationSpan)); configuration.setProperty(CONFIG_PROPERTY_NAME_AGGREGATION_TIMEUNIT, this.timeunit.name()); configuration.setProperty(CONFIG_PROPERTY_NAME_AGGREGATION_METHOD, this.aggregationMethod.name()); if (this.aggregationTimescopeGlobal) { configuration.setProperty(CONFIG_PROPERTY_NAME_AGGREGATION_TIMESCOPE, CONFIG_PROPERTY_VALUE_AGGREGATION_TIMESCOPE_GLOBAL); } else { configuration.setProperty(CONFIG_PROPERTY_NAME_AGGREGATION_TIMESCOPE, CONFIG_PROPERTY_VALUE_AGGREGATION_TIMESCOPE_PER_VARIABLE); } return configuration; }
@Override public Configuration getCurrentConfiguration() { final Configuration configuration = new Configuration(); configuration.setProperty(CONFIG_PROPERTY_NAME_AGGREGATION_SPAN, Long.toString(this.aggregationSpan)); configuration.setProperty(CONFIG_PROPERTY_NAME_AGGREGATION_TIMEUNIT, this.timeunit.name()); configuration.setProperty(CONFIG_PROPERTY_NAME_AGGREGATION_METHOD, this.aggregationMethod.name()); if (this.aggregationTimescopeGlobal) { configuration.setProperty(CONFIG_PROPERTY_NAME_AGGREGATION_TIMESCOPE, CONFIG_PROPERTY_VALUE_AGGREGATION_TIMESCOPE_GLOBAL); } else { configuration.setProperty(CONFIG_PROPERTY_NAME_AGGREGATION_TIMESCOPE, CONFIG_PROPERTY_VALUE_AGGREGATION_TIMESCOPE_PER_VARIABLE); } return configuration; }
private void calculateAndDeliverAggregationValue(final AggregationVariableSet variables) { final double aggregationValue; final NamedDoubleTimeSeriesPoint tsPoint; synchronized (this) { final int listSize = variables.getAggregationList().size(); final double[] a = new double[listSize]; for (int i = 0; i < listSize; i++) { a[i] = variables.getAggregationList().get(i).getValue(); } aggregationValue = this.aggregationMethod.getAggregationValue(a); tsPoint = new NamedDoubleTimeSeriesPoint(variables.getLastTimestampInCurrentInterval(), aggregationValue, variables.getAggregationList().get(0).getName()); // use name of first element (any will do) variables.getAggregationList().clear(); } super.deliver(OUTPUT_PORT_NAME_AGGREGATED_TSPOINT, tsPoint); }
private NamedDoubleTimeSeriesPoint calculateAggregationValueOfCurrentInterval(final AggregationVariableSet variables, final String name) { final double aggregationValue; final NamedDoubleTimeSeriesPoint tsPoint; final long firstTimestampInCurrentInterval = variables.getFirstTimestampInCurrentInterval(); final long lastTimestampInCurrentInterval = variables.getLastTimestampInCurrentInterval(); synchronized (this) { final int listSize = variables.getAggregationList().size(); if (listSize <= 0) { tsPoint = new NamedDoubleTimeSeriesPoint(lastTimestampInCurrentInterval, Double.NaN, name); } else { final double[] a = new double[listSize]; for (int i = 0; i < listSize; i++) { a[i] = variables.getAggregationList().get(i).getValue(); } aggregationValue = this.aggregationMethod.getAggregationValue(a); tsPoint = new NamedDoubleTimeSeriesPoint(lastTimestampInCurrentInterval, aggregationValue, name); variables.getAggregationList().clear(); } variables.setFirstTimestampInCurrentInterval(firstTimestampInCurrentInterval + this.aggregationSpan); variables.setLastTimestampInCurrentInterval(lastTimestampInCurrentInterval + this.aggregationSpan); } return tsPoint; }
private NamedDoubleTimeSeriesPoint calculateAggregationValueOfCurrentInterval(final AggregationVariableSet variables, final String name) { final double aggregationValue; final NamedDoubleTimeSeriesPoint tsPoint; final long firstTimestampInCurrentInterval = variables.getFirstTimestampInCurrentInterval(); final long lastTimestampInCurrentInterval = variables.getLastTimestampInCurrentInterval(); synchronized (this) { final int listSize = variables.getAggregationList().size(); if (listSize <= 0) { tsPoint = new NamedDoubleTimeSeriesPoint(lastTimestampInCurrentInterval, Double.NaN, name); } else { final double[] a = new double[listSize]; for (int i = 0; i < listSize; i++) { a[i] = variables.getAggregationList().get(i).getValue(); } aggregationValue = this.aggregationMethod.getAggregationValue(a); tsPoint = new NamedDoubleTimeSeriesPoint(lastTimestampInCurrentInterval, aggregationValue, name); variables.getAggregationList().clear(); } variables.setFirstTimestampInCurrentInterval(firstTimestampInCurrentInterval + this.aggregationSpan); variables.setLastTimestampInCurrentInterval(lastTimestampInCurrentInterval + this.aggregationSpan); } return tsPoint; }