Search in sources :

Example 11 with LogStopWatch

use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.

the class PointValueDaoMetrics method deleteOrphanedPointValuesWithoutCount.

/* (non-Javadoc)
	 * @see com.serotonin.m2m2.db.dao.PointValueDao#deleteOrphanedPointValuesWithoutCount()
	 */
@Override
public void deleteOrphanedPointValuesWithoutCount() {
    LogStopWatch LogStopWatch = new LogStopWatch();
    dao.deleteOrphanedPointValuesWithoutCount();
    LogStopWatch.stop("deleteOrphanedPointValuesWithoutCount()", this.metricsThreshold);
}
Also used : LogStopWatch(com.serotonin.log.LogStopWatch)

Example 12 with LogStopWatch

use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.

the class PointValueDaoMetrics method getLatestPointValues.

/*
	 * (non-Javadoc)
	 * @see com.serotonin.m2m2.db.dao.PointValueDao#getLatestPointValues(java.util.List, java.lang.Integer, long, boolean, com.infiniteautomation.mango.db.query.PVTQueryCallback)
	 */
public void getLatestPointValues(List<Integer> ids, long before, boolean orderById, Integer limit, PVTQueryCallback<IdPointValueTime> callback) {
    LogStopWatch LogStopWatch = new LogStopWatch();
    dao.getLatestPointValues(ids, before, orderById, limit, callback);
    LogStopWatch.stop("getLatestPointValues(pointId,limit,before, orderById, callback) (" + ids + ", " + limit + ", " + before + "," + orderById + ", callback)", this.metricsThreshold);
}
Also used : LogStopWatch(com.serotonin.log.LogStopWatch)

Example 13 with LogStopWatch

use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.

the class PointValueDaoMetrics method deleteOrphanedPointValues.

/* (non-Javadoc)
	 * @see com.serotonin.m2m2.db.dao.PointValueDao#deleteOrphanedPointValues()
	 */
@Override
public long deleteOrphanedPointValues() {
    LogStopWatch LogStopWatch = new LogStopWatch();
    long value = dao.deleteOrphanedPointValues();
    LogStopWatch.stop("deleteOrphanedPointValues()", this.metricsThreshold);
    return value;
}
Also used : LogStopWatch(com.serotonin.log.LogStopWatch)

Example 14 with LogStopWatch

use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.

the class PointValueDaoMetrics method getLatestPointValues.

/* (non-Javadoc)
	 * @see com.serotonin.m2m2.db.dao.PointValueDao#getLatestPointValues(int, int)
	 */
@Override
public List<PointValueTime> getLatestPointValues(int pointId, int limit) {
    LogStopWatch LogStopWatch = new LogStopWatch();
    List<PointValueTime> values = dao.getLatestPointValues(pointId, limit);
    LogStopWatch.stop("getLatestPointValues(pointId,limit) (" + pointId + ", " + limit + "){" + values.size() + "}", this.metricsThreshold);
    return values;
}
Also used : PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime) IdPointValueTime(com.serotonin.m2m2.rt.dataImage.IdPointValueTime) LogStopWatch(com.serotonin.log.LogStopWatch)

Example 15 with LogStopWatch

use of com.serotonin.log.LogStopWatch in project ma-modules-public by infiniteautomation.

the class MultiPointLatestDatabaseStream method simplify.

/**
 * Simplify according to our requirements
 *
 * TODO This currently only works for Numeric Points
 *
 * @param list
 * @return
 */
protected List<DataPointVOPointValueTimeBookend> simplify(List<DataPointVOPointValueTimeBookend> list) {
    LogStopWatch logStopWatch = new LogStopWatch();
    if (info.simplifyTolerance != null) {
        // TODO improve Simplify code to return a list
        Simplify<DataPointVOPointValueTimeBookend> simplify = new Simplify<DataPointVOPointValueTimeBookend>(new DataPointVOPointValueTimeBookend[0], SimplifyPointValueExtractor.extractor);
        DataPointVOPointValueTimeBookend[] simplified = simplify.simplify(list.toArray(new DataPointVOPointValueTimeBookend[list.size()]), info.simplifyTolerance, info.simplifyHighQuality);
        logStopWatch.stop("Finished Simplify, tolerance: " + info.simplifyTolerance);
        return Arrays.asList(simplified);
    } else {
        if (list.size() < info.simplifyTarget)
            return list;
        // Compute target bounds as 10% of target
        int lowerTarget = info.simplifyTarget - (int) (info.simplifyTarget * 0.1);
        int upperTarget = info.simplifyTarget + (int) (info.simplifyTarget * 0.1);
        // Compute tolerance bounds and initial tolerance
        Double max = Double.MIN_VALUE;
        Double min = Double.MAX_VALUE;
        for (DataPointVOPointValueTimeBookend value : list) {
            if (value.getPvt().getDoubleValue() > max)
                max = value.getPvt().getDoubleValue();
            if (value.getPvt().getDoubleValue() < min)
                min = value.getPvt().getDoubleValue();
        }
        double difference = max - min;
        double tolerance = difference / 20d;
        double topBound = difference;
        double bottomBound = 0;
        // Determine max iterations we can allow
        int maxIterations = 100;
        int iteration = 1;
        Simplify<DataPointVOPointValueTimeBookend> simplify = new Simplify<DataPointVOPointValueTimeBookend>(new DataPointVOPointValueTimeBookend[0], SimplifyPointValueExtractor.extractor);
        DataPointVOPointValueTimeBookend[] simplified = simplify.simplify(list.toArray(new DataPointVOPointValueTimeBookend[list.size()]), tolerance, info.simplifyHighQuality);
        DataPointVOPointValueTimeBookend[] best = simplified;
        while (simplified.length < lowerTarget || simplified.length > upperTarget) {
            if (simplified.length > info.simplifyTarget) {
                bottomBound = tolerance;
            } else {
                topBound = tolerance;
            }
            // Adjust tolerance
            tolerance = bottomBound + (topBound - bottomBound) / 2.0d;
            simplify = new Simplify<DataPointVOPointValueTimeBookend>(new DataPointVOPointValueTimeBookend[0], SimplifyPointValueExtractor.extractor);
            simplified = simplify.simplify(list.toArray(new DataPointVOPointValueTimeBookend[list.size()]), tolerance, info.simplifyHighQuality);
            // Keep our best effort
            if (Math.abs(info.simplifyTarget - simplified.length) < Math.abs(info.simplifyTarget - best.length))
                best = simplified;
            if (iteration > maxIterations) {
                simplified = best;
                break;
            }
            iteration++;
        }
        logStopWatch.stop("Finished Simplify, target: " + info.simplifyTarget + " actual " + simplified.length);
        return Arrays.asList(simplified);
    }
}
Also used : Simplify(com.goebl.simplify.Simplify) DataPointVOPointValueTimeBookend(com.infiniteautomation.mango.rest.v2.model.pointValue.DataPointVOPointValueTimeBookend) LogStopWatch(com.serotonin.log.LogStopWatch)

Aggregations

LogStopWatch (com.serotonin.log.LogStopWatch)45 IdPointValueTime (com.serotonin.m2m2.rt.dataImage.IdPointValueTime)9 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)9 ResultSet (java.sql.ResultSet)3 LogEvent (com.serotonin.m2m2.rt.console.LogEvent)2 IOException (java.io.IOException)2 PreparedStatement (java.sql.PreparedStatement)2 Simplify (com.goebl.simplify.Simplify)1 DataPointVOPointValueTimeBookend (com.infiniteautomation.mango.rest.v2.model.pointValue.DataPointVOPointValueTimeBookend)1 ModuleNotLoadedException (com.serotonin.ModuleNotLoadedException)1 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)1 UserEventCache (com.serotonin.m2m2.rt.event.UserEventCache)1 LongPair (com.serotonin.m2m2.vo.pair.LongPair)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Record (org.jooq.Record)1 Record1 (org.jooq.Record1)1 DataAccessException (org.springframework.dao.DataAccessException)1 RowMapper (org.springframework.jdbc.core.RowMapper)1