use of com.infiniteautomation.mango.rest.latest.model.pointValue.DataPointVOPointValueTimeBookend in project ma-modules-public by infiniteautomation.
the class MultiPointSimplifyTimeRangeDatabaseStream method finish.
@Override
public void finish(PointValueTimeWriter writer) throws QueryCancelledException, IOException {
// Write out the values after simplifying
Iterator<Integer> it = voMap.keySet().iterator();
if (info.isSingleArray() && voMap.size() > 1) {
List<DataPointVOPointValueTimeBookend> sorted = new ArrayList<>();
while (it.hasNext()) {
Integer seriesId = it.next();
BookendPair pair = bookendMap.get(seriesId);
if (pair != null && pair.startBookend != null)
sorted.add(pair.startBookend);
List<DataPointVOPointValueTimeBookend> values = valuesMap.get(seriesId);
if (values != null) {
sorted.addAll(SimplifyUtility.simplify(info.simplifyTolerance, info.simplifyTarget, info.simplifyHighQuality, info.simplifyPrePostProcess, values));
}
if (// Can be null bookend if limit is hit
pair != null && pair.endBookend != null)
sorted.add(pair.endBookend);
}
// Sort the Sorted List
Collections.sort(sorted, new Comparator<DataPointVOPointValueTimeBookend>() {
@Override
public int compare(DataPointVOPointValueTimeBookend o1, DataPointVOPointValueTimeBookend o2) {
return o1.getPvt().compareTo(o2.getPvt());
}
});
for (DataPointVOPointValueTimeBookend value : sorted) super.writeValue(value);
} else {
while (it.hasNext()) {
Integer seriesId = it.next();
List<DataPointVOPointValueTimeBookend> simplified;
List<DataPointVOPointValueTimeBookend> values = valuesMap.get(seriesId);
if (values == null) {
simplified = Collections.emptyList();
} else {
simplified = SimplifyUtility.simplify(info.simplifyTolerance, info.simplifyTarget, info.simplifyHighQuality, info.simplifyPrePostProcess, values);
}
BookendPair pair = bookendMap.get(seriesId);
if (pair != null && pair.startBookend != null)
super.writeValue(pair.startBookend);
for (DataPointVOPointValueTimeBookend value : simplified) super.writeValue(value);
if (// Can be null bookend if limit is hit
pair != null && pair.endBookend != null)
super.writeValue(pair.endBookend);
}
}
super.finish(writer);
}
use of com.infiniteautomation.mango.rest.latest.model.pointValue.DataPointVOPointValueTimeBookend in project ma-modules-public by infiniteautomation.
the class MultiDataPointDefaultRollupStatisticsQuantizerStream method process.
/**
* Process the data into lists per data point, simplify if necessary
*/
private Map<DataPointVO, List<DataPointValueTime>> process(Integer limit) {
Map<DataPointVO, List<DataPointValueTime>> processed = new LinkedHashMap<>();
for (DataPointVO vo : voMap.values()) {
List<DataPointStatisticsGenerator> generators = valueMap.get(vo.getId());
List<DataPointValueTime> values = new ArrayList<>();
if (generators.get(0).getGenerator() instanceof NoStatisticsGenerator) {
// Iterate and combine into an array
for (DataPointStatisticsGenerator gen : generators) {
NoStatisticsGenerator noGen = (NoStatisticsGenerator) gen.getGenerator();
for (IValueTime value : noGen.getValues()) {
values.add(new DataPointVOPointValueTimeBookend(vo, (IdPointValueTime) value));
}
}
} else {
for (DataPointStatisticsGenerator generator : generators) {
values.add(new DataPointRollupPeriodValue(generator, RollupEnum.convertTo(vo.getRollup())));
}
}
if (values.size() > 0) {
// As the other endpoints, limit before simplification
if (limit != null)
values = values.subList(0, limit);
if (vo.isSimplifyDataSets()) {
if (vo.getSimplifyType() == DataPointVO.SimplifyTypes.TARGET)
values = SimplifyUtility.simplify(null, vo.getSimplifyTarget(), true, true, values);
else
values = SimplifyUtility.simplify(vo.getSimplifyTolerance(), null, true, true, values);
}
processed.put(vo, values);
}
}
return processed;
}
use of com.infiniteautomation.mango.rest.latest.model.pointValue.DataPointVOPointValueTimeBookend in project ma-modules-public by infiniteautomation.
the class MultiPointSimplifyLatestDatabaseStream method finish.
@Override
public void finish(PointValueTimeWriter writer) throws QueryCancelledException, IOException {
// Write out the values after simplifying
Iterator<Integer> it = valuesMap.keySet().iterator();
if (info.isSingleArray() && voMap.size() > 1) {
List<DataPointVOPointValueTimeBookend> sorted = new ArrayList<>();
while (it.hasNext()) sorted.addAll(SimplifyUtility.simplify(info.simplifyTolerance, info.simplifyTarget, info.simplifyHighQuality, info.simplifyPrePostProcess, valuesMap.get(it.next())));
// Sort the Sorted List
Collections.sort(sorted, new Comparator<DataPointVOPointValueTimeBookend>() {
@Override
public int compare(DataPointVOPointValueTimeBookend o1, DataPointVOPointValueTimeBookend o2) {
return o1.getPvt().compareTo(o2.getPvt());
}
});
for (DataPointVOPointValueTimeBookend value : sorted) super.writeValue(value);
} else {
while (it.hasNext()) {
List<DataPointVOPointValueTimeBookend> values = SimplifyUtility.simplify(info.simplifyTolerance, info.simplifyTarget, info.simplifyHighQuality, info.simplifyPrePostProcess, valuesMap.get(it.next()));
for (DataPointVOPointValueTimeBookend value : values) super.writeValue(value);
}
}
super.finish(writer);
}
Aggregations