public void addAttributeToDataSet(Long objId, Attribute attribute, Time time) { this.lock(); if (this.dataSets.get(objId) == null) { this.dataSets.put(objId, new AttributeValueList()); this.timeSets.put(objId, new TimeList()); } if (attribute == null) { this.dataSets.get(objId).add(null); this.timeSets.get(objId).add(time); } else { AttributeValue value = new AttributeValue(); value.setValue(attribute); this.dataSets.get(objId).add(value); this.timeSets.get(objId).add(time); } this.unlock(); }
/** * resets samplecounter, latestsampletimelist and the * filtertriggered-variables. this method will be called after each * aggregation-value-update was published * * @param identityId The identity Id. * @return true if it was successful, false if identity not found */ public Boolean resetAggregationSampleHelperVariables(Long identityId) { if (!this.existsIdentity(identityId)) { return false; } AggregationDefinitionDetails definition = this.getAggregationDefinition(identityId); final int paramSetSize = definition.getParameterSets().size(); //reset the latest sample-time and the sample-counter if (paramSetSize != 0) { latestSampleTimeList.get(identityId).clear(); sampleCountList.get(identityId).clear(); } //init the latest sample-time and the sample-counter for (int j = 0; j < paramSetSize; j++) { latestSampleTimeList.get(identityId).add(j, null); sampleCountList.get(identityId).add(j, 0); } this.setFilterTriggered(identityId, false); // Reset the filter state return true; }
public Integer getOldestIndex(Long objId, double oldestTimeInMs) { // get index of oldestTimeInMs (or the next higher index, if oldestTimeInMs not in list) TimeList allTimes = timeSets.get(objId); if (allTimes == null) { return null; } int i = 0; for (; i < allTimes.size() && allTimes.get(i).getValue() < oldestTimeInMs; i++); return i; }
Integer oldestIndex = manager.getDataSets().getOldestIndex(statLinkId, oldestTime); TimeList times = new TimeList(); AttributeValueList values = new AttributeValueList(); TimeList allTimes = manager.getDataSets().getTimeSet(statLinkId); values = allValues; } else { List<Time> timesArr = allTimes.subList(oldestIndex, allTimes.size()); times.addAll(timesArr); List<AttributeValue> valuesArr = allValues.subList(oldestIndex, allValues.size()); values.addAll(valuesArr);
previousSetTimeStamp = new Time(currentTime.getValue() - (long) (updateInterval.getValue() * 1000)); } else { //otherwise its the time of the last value of the previous set previousSetTimeStamp = new Time(this.latestSampleTimeList.get(identityId).get(indexParameterSet - 1).getValue()); Time firstSampleTime = new Time(this.latestSampleTimeList.get(identityId).get(indexParameterSet).getValue() - (long) (sampleInterval.getValue() * 1000) * sampleCountList.get(identityId).get(indexParameterSet));
public void resetDataSet(Long objId) { this.dataSets.put(objId, new AttributeValueList()); this.timeSets.put(objId, new TimeList()); }
/** * this method sets the new samples as the current values. If a Filter is * active, it must have checked already that the filter is triggered. if its * not triggered the samples must not be set. * * @param identityId the id of the aggregation * @param indexOfparameterSet the index of the parameterSet in an * aggregation * @param newParamSample the new values that should be set * @return */ private AggregationParameterValueList setParameterSamplesInternally(Long identityId, int indexOfparameterSet, AggregationParameterValueList newParamSample) { final AggregationParameterValueList currentParamValues = this.periodicAggregationValuesCurrent.get(identityId).getParameterSetValues().get(indexOfparameterSet).getValues(); this.periodicAggregationValuesLast.get(identityId).getParameterSetValues().get(indexOfparameterSet).setValues(currentParamValues); //set the new ones to the current ones this.periodicAggregationValuesCurrent.get(identityId).getParameterSetValues().get(indexOfparameterSet).setValues(newParamSample); //sets the timestamp of the latest value of the set. needed for the calculation of the delta-time this.latestSampleTimeList.get(identityId).set(indexOfparameterSet, HelperTime.getTimestampMillis()); return newParamSample; }
private StatisticValue generateStatisticValueMinimum(long paramIdentityId, TimeList times, AttributeValueList values) { StatisticValue statValue = this.newStatisticValue(paramIdentityId, times, values); if (statValue == null) { return null; } int minimum = 0; // Go through all the data sets and find the maximum value... for (int i = 0; i < values.size(); i++) { if (values.get(i) == null) { continue; } // Comparison must be done here //requirement: 3.6.3.i report first occurance of min value if (HelperCOM.evaluateExpression(values.get(i).getValue(), ExpressionOperator.LESS, values.get(minimum).getValue())) { minimum = i; } } statValue.setValue(values.get(minimum).getValue()); statValue.setValueTime(times.get(minimum)); return statValue; }
/** * Initializes the variables in the manager belonging the updates and * samples of the given aggregation. this method will be called after the * creation of an aggregation-definition * * @param identityIdList The list of identity Ids */ protected void createAggregationValuesList(LongList identityIdList) { for (Long identityId : identityIdList) { periodicAggregationValuesLast.put(identityId, new AggregationValue()); periodicAggregationValuesCurrent.put(identityId, new AggregationValue()); isFilterTriggered.put(identityId, false); //initialize timList with the amount of parameterSets //final int parameterSetsCount = getAggregationDefinition(identityId).getParameterSets().size(); latestSampleTimeList.put(identityId, new TimeList()); sampleCountList.put(identityId, new ArrayList<Integer>()); this.populateAggregationValues(identityId); } }
private StatisticValue newStatisticValue(long paramIdentityId, TimeList times, AttributeValueList values) { if (times == null || values == null) { // Nothing to do here... return null; } // Different list sizes or zero elements? if (times.size() != values.size() || values.size() == 0) { return null; } StatisticValue statValue = new StatisticValue(); statValue.setStartTime(times.get(0)); statValue.setEndTime(times.get(times.size() - 1)); // Last element statValue.setSampleCount(new UInteger(times.size())); long paramDefInstId = parameterManager.getDefinitionId(paramIdentityId); statValue.setParamDefInstId(paramDefInstId); return statValue; }
/** * resets periodicAggregationValuesLast, periodicAggregationValuesCurrent, * sampleCounter, latestSampleTimeList and the filterTriggered-variables. * this method will be called after an aggregation-definition was updated. * * @param identityId The identity Id. */ public void populateAggregationValues(final Long identityId) { AggregationSetValueList aggregationSetValueListLast = new AggregationSetValueList(); AggregationSetValueList aggregationSetValueListCurrent = new AggregationSetValueList(); AggregationDefinitionDetails definition = this.getAggregationDefinition(identityId); final int paramSetSize = definition.getParameterSets().size(); //reset the latest sample-time and the sample-counter if (paramSetSize != 0) { latestSampleTimeList.get(identityId).clear(); sampleCountList.get(identityId).clear(); } //init the latest sample-time and the sample-counter, filtertriggered and latest and current aggregation-values for (int j = 0; j < paramSetSize; j++) { latestSampleTimeList.get(identityId).add(j, null); aggregationSetValueListLast.add(j, new AggregationSetValue()); aggregationSetValueListCurrent.add(j, new AggregationSetValue()); sampleCountList.get(identityId).add(j, 0); } periodicAggregationValuesLast.get(identityId).setParameterSetValues(aggregationSetValueListLast); periodicAggregationValuesCurrent.get(identityId).setParameterSetValues(aggregationSetValueListCurrent); this.setFilterTriggered(identityId, false); // Reset the filter state }
private StatisticValue generateStatisticValueMaximum(long paramIdentityId, TimeList times, AttributeValueList values) { StatisticValue statValue = this.newStatisticValue(paramIdentityId, times, values); if (statValue == null) { return null; } int maximum = 0; // Go through all the data sets and find the maximum value... for (int i = 0; i < values.size(); i++) { if (values.get(i) == null) { continue; } // Comparison must be done here //requirement: 3.6.3.h report first occurance of max value if (HelperCOM.evaluateExpression(values.get(i).getValue(), ExpressionOperator.GREATER, values.get(maximum).getValue())) { maximum = i; } } statValue.setValue(values.get(maximum).getValue()); statValue.setValueTime(times.get(maximum)); return statValue; }