Search in sources :

Example 1 with DataType

use of com.serotonin.m2m2.DataType in project ma-modules-public by infiniteautomation.

the class ReportDao method runReportSQL.

/**
 * SQL Database Report
 * @param instance
 * @param points
 * @return
 */
public int runReportSQL(final ReportInstance instance, List<PointInfo> points) {
    PointValueDao pointValueDao = Common.databaseProxy.newPointValueDao();
    int count = 0;
    // The timestamp selection code is used multiple times for different tables
    String timestampSql;
    Object[] timestampParams;
    if (instance.isFromInception() && instance.isToNow()) {
        timestampSql = "";
        timestampParams = new Object[0];
    } else if (instance.isFromInception()) {
        timestampSql = "and ${field}<?";
        timestampParams = new Object[] { instance.getReportEndTime() };
    } else if (instance.isToNow()) {
        timestampSql = "and ${field}>=?";
        timestampParams = new Object[] { instance.getReportStartTime() };
    } else {
        timestampSql = "and ${field}>=? and ${field}<?";
        timestampParams = new Object[] { instance.getReportStartTime(), instance.getReportEndTime() };
    }
    // For each point.
    for (PointInfo pointInfo : points) {
        DataPointVO point = pointInfo.getPoint();
        int dataType = point.getPointLocator().getDataTypeId();
        DataValue startValue = null;
        if (!instance.isFromInception()) {
            // Get the value just before the start of the report
            PointValueTime pvt = pointValueDao.getPointValueBefore(point.getId(), instance.getReportStartTime());
            if (pvt != null)
                startValue = pvt.getValue();
            // Make sure the data types match
            if (DataTypes.getDataType(startValue) != dataType)
                startValue = null;
        }
        // Insert the reportInstancePoints record
        String name = Functions.truncate(point.getName(), 100);
        int reportPointId = doInsert(REPORT_INSTANCE_POINTS_INSERT, new Object[] { instance.getId(), point.getDeviceName(), name, pointInfo.getPoint().getXid(), dataType, DataTypes.valueToString(startValue), SerializationHelper.writeObject(point.getTextRenderer()), pointInfo.getColour(), pointInfo.getWeight(), boolToChar(pointInfo.isConsolidatedChart()), pointInfo.getPlotType() }, new int[] { Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.VARCHAR, Types.BLOB, Types.VARCHAR, Types.FLOAT, Types.CHAR, Types.INTEGER });
        // Insert the reportInstanceData records
        String insertSQL = // 
        "insert into reportInstanceData " + "  select id, " + reportPointId + // 
        ", pointValue, ts from pointValues " + // 
        "    where dataPointId=? and dataType=? " + StringUtils.replaceMacro(timestampSql, "field", "ts");
        count += ejt.update(insertSQL, appendParameters(timestampParams, point.getId(), dataType));
        // Insert the reportInstanceDataAnnotations records
        ejt.update(// 
        "insert into reportInstanceDataAnnotations " + // 
        "  (pointValueId, reportInstancePointId, textPointValueShort, textPointValueLong, sourceMessage) " + // 
        "  select rd.pointValueId, rd.reportInstancePointId, pva.textPointValueShort, " + // 
        "    pva.textPointValueLong, pva.sourceMessage " + // 
        "  from reportInstanceData rd " + // 
        "    join reportInstancePoints rp on rd.reportInstancePointId = rp.id " + // 
        "    join pointValueAnnotations pva on rd.pointValueId = pva.pointValueId " + "  where rp.id = ?", new Object[] { reportPointId });
        // Insert the reportInstanceEvents records for the point.
        if (instance.getIncludeEvents() != ReportVO.EVENTS_NONE) {
            String eventSQL = // 
            "insert into reportInstanceEvents " + // 
            "  (eventId, reportInstanceId, typeName, subtypeName, typeRef1, typeRef2, activeTs, " + // 
            "   rtnApplicable, rtnTs, rtnCause, alarmLevel, message, ackTs, ackUsername, " + // 
            "   alternateAckSource)" + "  select e.id, " + instance.getId() + // 
            ", e.typeName, e.subtypeName, e.typeRef1, " + // 
            "    e.typeRef2, e.activeTs, e.rtnApplicable, e.rtnTs, e.rtnCause, e.alarmLevel, " + // 
            "    e.message, e.ackTs, u.username, e.alternateAckSource " + // 
            "  from events e join userEvents ue on ue.eventId=e.id " + // 
            "    left join users u on e.ackUserId=u.id " + // 
            "  where ue.userId=? " + // 
            "    and e.typeName=? " + "    and e.typeRef1=? ";
            if (instance.getIncludeEvents() == ReportVO.EVENTS_ALARMS)
                eventSQL += "and e.alarmLevel > 0 ";
            eventSQL += StringUtils.replaceMacro(timestampSql, "field", "e.activeTs");
            ejt.update(eventSQL, appendParameters(timestampParams, instance.getUserId(), EventType.EventTypeNames.DATA_POINT, point.getId()));
        }
        // Insert the reportInstanceUserComments records for the point.
        if (instance.isIncludeUserComments()) {
            String commentSQL = // 
            "insert into reportInstanceUserComments " + // 
            "  (reportInstanceId, username, commentType, typeKey, ts, commentText)" + "  select " + instance.getId() + ", u.username, " + UserCommentVO.TYPE_POINT + // 
            ", " + reportPointId + // 
            ", uc.ts, uc.commentText " + // 
            "  from userComments uc " + // 
            "    left join users u on uc.userId=u.id " + "  where uc.commentType=" + // 
            UserCommentVO.TYPE_POINT + "    and uc.typeKey=? ";
            // Only include comments made in the duration of the report.
            commentSQL += StringUtils.replaceMacro(timestampSql, "field", "uc.ts");
            ejt.update(commentSQL, appendParameters(timestampParams, point.getId()));
        }
    }
    // Insert the reportInstanceUserComments records for the selected events
    if (instance.isIncludeUserComments()) {
        String commentSQL = // 
        "insert into reportInstanceUserComments " + // 
        "  (reportInstanceId, username, commentType, typeKey, ts, commentText)" + "  select " + instance.getId() + ", u.username, " + UserCommentVO.TYPE_EVENT + // 
        ", uc.typeKey, " + // 
        "    uc.ts, uc.commentText " + // 
        "  from userComments uc " + // 
        "    left join users u on uc.userId=u.id " + // 
        "    join reportInstanceEvents re on re.eventId=uc.typeKey " + "  where uc.commentType=" + // 
        UserCommentVO.TYPE_EVENT + "    and re.reportInstanceId=? ";
        ejt.update(commentSQL, new Object[] { instance.getId() });
    }
    // If the report had undefined start or end times, update them with values from the data.
    if (instance.isFromInception() || instance.isToNow()) {
        ejt.query(// 
        "select min(rd.ts), max(rd.ts) " + "from reportInstancePoints rp " + "  join reportInstanceData rd on rp.id=rd.reportInstancePointId " + "where rp.reportInstanceId=?", new Object[] { instance.getId() }, new RowCallbackHandler() {

            @Override
            public void processRow(ResultSet rs) throws SQLException {
                if (instance.isFromInception())
                    instance.setReportStartTime(rs.getLong(1));
                if (instance.isToNow())
                    instance.setReportEndTime(rs.getLong(2));
            }
        });
    }
    return count;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) DataValue(com.serotonin.m2m2.rt.dataImage.types.DataValue) ExportDataValue(com.serotonin.m2m2.vo.export.ExportDataValue) SQLException(java.sql.SQLException) ExportPointInfo(com.serotonin.m2m2.vo.export.ExportPointInfo) PointValueDao(com.serotonin.m2m2.db.dao.PointValueDao) IdPointValueTime(com.serotonin.m2m2.rt.dataImage.IdPointValueTime) AnnotatedPointValueTime(com.serotonin.m2m2.rt.dataImage.AnnotatedPointValueTime) PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime) ResultSet(java.sql.ResultSet) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler)

Example 2 with DataType

use of com.serotonin.m2m2.DataType in project ma-modules-public by infiniteautomation.

the class ReportDao method runReportNoSQL.

/**
 * Generate a report using the NoSQL DB for point value storage
 * @param instance
 * @param points
 * @return
 */
public int runReportNoSQL(final ReportInstance instance, List<PointInfo> points) {
    PointValueDao pointValueDao = Common.databaseProxy.newPointValueDao();
    final MappedCallbackCounter count = new MappedCallbackCounter();
    final NoSQLDao dao = Common.databaseProxy.getNoSQLProxy().createNoSQLDao(ReportPointValueTimeSerializer.get(), "reports");
    // The timestamp selection code is used multiple times for different tables
    long startTime, endTime;
    String timestampSql;
    Object[] timestampParams;
    if (instance.isFromInception() && instance.isToNow()) {
        timestampSql = "";
        timestampParams = new Object[0];
        startTime = 0l;
        endTime = Common.timer.currentTimeMillis();
    } else if (instance.isFromInception()) {
        timestampSql = "and ${field}<?";
        timestampParams = new Object[] { instance.getReportEndTime() };
        startTime = 0l;
        endTime = instance.getReportEndTime();
    } else if (instance.isToNow()) {
        timestampSql = "and ${field}>=?";
        timestampParams = new Object[] { instance.getReportStartTime() };
        startTime = instance.getReportStartTime();
        endTime = Common.timer.currentTimeMillis();
    } else {
        timestampSql = "and ${field}>=? and ${field}<?";
        timestampParams = new Object[] { instance.getReportStartTime(), instance.getReportEndTime() };
        startTime = instance.getReportStartTime();
        endTime = instance.getReportEndTime();
    }
    // For each point.
    List<Integer> pointIds = new ArrayList<Integer>();
    // Map the pointId to the Report PointId
    final Map<Integer, Integer> pointIdMap = new HashMap<Integer, Integer>();
    // the reports table/data store
    for (PointInfo pointInfo : points) {
        DataPointVO point = pointInfo.getPoint();
        pointIds.add(point.getId());
        int dataType = point.getPointLocator().getDataTypeId();
        DataValue startValue = null;
        if (!instance.isFromInception()) {
            // Get the value just before the start of the report
            PointValueTime pvt = pointValueDao.getPointValueBefore(point.getId(), instance.getReportStartTime());
            if (pvt != null)
                startValue = pvt.getValue();
            // Make sure the data types match
            if (DataTypes.getDataType(startValue) != dataType)
                startValue = null;
        }
        // Insert the reportInstancePoints record
        String name = Functions.truncate(point.getName(), 100);
        int reportPointId = doInsert(REPORT_INSTANCE_POINTS_INSERT, new Object[] { instance.getId(), point.getDeviceName(), name, pointInfo.getPoint().getXid(), dataType, DataTypes.valueToString(startValue), SerializationHelper.writeObject(point.getTextRenderer()), pointInfo.getColour(), pointInfo.getWeight(), boolToChar(pointInfo.isConsolidatedChart()), pointInfo.getPlotType() }, new int[] { Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.VARCHAR, Types.BLOB, Types.VARCHAR, Types.FLOAT, Types.CHAR, Types.INTEGER });
        // Keep the info in the map
        pointIdMap.put(pointInfo.getPoint().getId(), reportPointId);
        // Insert the reportInstanceDataAnnotations records
        ejt.update(// 
        "insert into reportInstanceDataAnnotations " + // 
        "  (pointValueId, reportInstancePointId, textPointValueShort, textPointValueLong, sourceMessage) " + // 
        "  select rd.pointValueId, rd.reportInstancePointId, pva.textPointValueShort, " + // 
        "    pva.textPointValueLong, pva.sourceMessage " + // 
        "  from reportInstanceData rd " + // 
        "    join reportInstancePoints rp on rd.reportInstancePointId = rp.id " + // 
        "    join pointValueAnnotations pva on rd.pointValueId = pva.pointValueId " + "  where rp.id = ?", new Object[] { reportPointId });
        // Insert the reportInstanceEvents records for the point.
        if (instance.getIncludeEvents() != ReportVO.EVENTS_NONE) {
            String eventSQL = // 
            "insert into reportInstanceEvents " + // 
            "  (eventId, reportInstanceId, typeName, subtypeName, typeRef1, typeRef2, activeTs, " + // 
            "   rtnApplicable, rtnTs, rtnCause, alarmLevel, message, ackTs, ackUsername, " + // 
            "   alternateAckSource)" + "  select e.id, " + instance.getId() + // 
            ", e.typeName, e.subtypeName, e.typeRef1, " + // 
            "    e.typeRef2, e.activeTs, e.rtnApplicable, e.rtnTs, e.rtnCause, e.alarmLevel, " + // 
            "    e.message, e.ackTs, u.username, e.alternateAckSource " + // 
            "  from events e join userEvents ue on ue.eventId=e.id " + // 
            "    left join users u on e.ackUserId=u.id " + // 
            "  where ue.userId=? " + // 
            "    and e.typeName=? " + "    and e.typeRef1=? ";
            if (instance.getIncludeEvents() == ReportVO.EVENTS_ALARMS)
                eventSQL += "and e.alarmLevel > 0 ";
            eventSQL += StringUtils.replaceMacro(timestampSql, "field", "e.activeTs");
            ejt.update(eventSQL, appendParameters(timestampParams, instance.getUserId(), EventType.EventTypeNames.DATA_POINT, point.getId()));
        }
        // Insert the reportInstanceUserComments records for the point.
        if (instance.isIncludeUserComments()) {
            String commentSQL = // 
            "insert into reportInstanceUserComments " + // 
            "  (reportInstanceId, username, commentType, typeKey, ts, commentText)" + "  select " + instance.getId() + ", u.username, " + UserCommentVO.TYPE_POINT + // 
            ", " + reportPointId + // 
            ", uc.ts, uc.commentText " + // 
            "  from userComments uc " + // 
            "    left join users u on uc.userId=u.id " + "  where uc.commentType=" + // 
            UserCommentVO.TYPE_POINT + "    and uc.typeKey=? ";
            // Only include comments made in the duration of the report.
            commentSQL += StringUtils.replaceMacro(timestampSql, "field", "uc.ts");
            ejt.update(commentSQL, appendParameters(timestampParams, point.getId()));
        }
    }
    // end for all points
    // Insert the data into the NoSQL DB and track first/last times
    // The series name is reportInstanceId_reportPointId
    final AtomicLong firstPointTime = new AtomicLong(Long.MAX_VALUE);
    final AtomicLong lastPointTime = new AtomicLong(-1l);
    final String reportId = Integer.toString(instance.getId()) + "_";
    pointValueDao.getPointValuesBetween(pointIds, startTime, endTime, new MappedRowCallback<IdPointValueTime>() {

        @Override
        public void row(final IdPointValueTime ipvt, int rowId) {
            dao.storeData(reportId + Integer.toString(pointIdMap.get(ipvt.getId())), ipvt);
            count.increment();
            if (ipvt.getTime() < firstPointTime.get())
                firstPointTime.set(ipvt.getTime());
            if (ipvt.getTime() > lastPointTime.get())
                lastPointTime.set(ipvt.getTime());
        }
    });
    // Insert the reportInstanceUserComments records for the selected events
    if (instance.isIncludeUserComments()) {
        String commentSQL = // 
        "insert into reportInstanceUserComments " + // 
        "  (reportInstanceId, username, commentType, typeKey, ts, commentText)" + "  select " + instance.getId() + ", u.username, " + UserCommentVO.TYPE_EVENT + // 
        ", uc.typeKey, " + // 
        "    uc.ts, uc.commentText " + // 
        "  from userComments uc " + // 
        "    left join users u on uc.userId=u.id " + // 
        "    join reportInstanceEvents re on re.eventId=uc.typeKey " + "  where uc.commentType=" + // 
        UserCommentVO.TYPE_EVENT + "    and re.reportInstanceId=? ";
        ejt.update(commentSQL, new Object[] { instance.getId() });
    }
    // If the report had undefined start or end times, update them with values from the data.
    if (instance.isFromInception() || instance.isToNow()) {
        if (instance.isFromInception()) {
            if (firstPointTime.get() != Long.MAX_VALUE)
                instance.setReportStartTime(firstPointTime.get());
        }
        if (instance.isToNow()) {
            instance.setReportEndTime(lastPointTime.get());
        }
    }
    return count.getCount();
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DataValue(com.serotonin.m2m2.rt.dataImage.types.DataValue) ExportDataValue(com.serotonin.m2m2.vo.export.ExportDataValue) ArrayList(java.util.ArrayList) IdPointValueTime(com.serotonin.m2m2.rt.dataImage.IdPointValueTime) NoSQLDao(com.serotonin.m2m2.db.dao.nosql.NoSQLDao) ExportPointInfo(com.serotonin.m2m2.vo.export.ExportPointInfo) PointValueDao(com.serotonin.m2m2.db.dao.PointValueDao) AtomicLong(java.util.concurrent.atomic.AtomicLong) IdPointValueTime(com.serotonin.m2m2.rt.dataImage.IdPointValueTime) AnnotatedPointValueTime(com.serotonin.m2m2.rt.dataImage.AnnotatedPointValueTime) PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime)

Example 3 with DataType

use of com.serotonin.m2m2.DataType in project ma-modules-public by infiniteautomation.

the class ReportDao method reportInstanceDataSQL.

public void reportInstanceDataSQL(int instanceId, final ExportDataStreamHandler handler) {
    // Retrieve point information.
    List<ExportPointInfo> pointInfos = query(REPORT_INSTANCE_POINT_SELECT + "where reportInstanceId=?", new Object[] { instanceId }, new RowMapper<ExportPointInfo>() {

        @Override
        public ExportPointInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
            int i = 0;
            ExportPointInfo rp = new ExportPointInfo();
            rp.setReportPointId(rs.getInt(++i));
            rp.setDeviceName(rs.getString(++i));
            rp.setPointName(rs.getString(++i));
            rp.setXid(rs.getString(++i));
            rp.setDataType(rs.getInt(++i));
            String startValue = rs.getString(++i);
            if (startValue != null)
                rp.setStartValue(DataValue.stringToValue(startValue, rp.getDataType()));
            rp.setTextRenderer((TextRenderer) SerializationHelper.readObjectInContext(rs.getBlob(++i).getBinaryStream()));
            rp.setColour(rs.getString(++i));
            rp.setWeight(rs.getFloat(++i));
            rp.setConsolidatedChart(charToBool(rs.getString(++i)));
            rp.setPlotType(rs.getInt(++i));
            return rp;
        }
    });
    final ExportDataValue edv = new ExportDataValue();
    for (final ExportPointInfo point : pointInfos) {
        if (point.getDataType() == DataTypes.IMAGE) {
            DataPointVO vo = DataPointDao.instance.getByXid(point.getXid());
            if (vo != null)
                point.setDataPointId(vo.getId());
            else
                point.setDataPointId(-1);
        }
        handler.startPoint(point);
        edv.setReportPointId(point.getReportPointId());
        final int dataType = point.getDataType();
        ejt.query(REPORT_INSTANCE_DATA_SELECT + "where rd.reportInstancePointId=? order by rd.ts", new Object[] { point.getReportPointId() }, new RowCallbackHandler() {

            @Override
            public void processRow(ResultSet rs) throws SQLException {
                switch(dataType) {
                    case (DataTypes.NUMERIC):
                        edv.setValue(new NumericValue(rs.getDouble(1)));
                        break;
                    case (DataTypes.BINARY):
                        edv.setValue(new BinaryValue(rs.getDouble(1) == 1));
                        break;
                    case (DataTypes.MULTISTATE):
                        edv.setValue(new MultistateValue(rs.getInt(1)));
                        break;
                    case (DataTypes.ALPHANUMERIC):
                        edv.setValue(new AlphanumericValue(rs.getString(2)));
                        if (rs.wasNull())
                            edv.setValue(new AlphanumericValue(rs.getString(3)));
                        break;
                    case (DataTypes.IMAGE):
                        edv.setValue(new ImageValue(Integer.parseInt(rs.getString(2)), rs.getInt(1)));
                        break;
                    default:
                        edv.setValue(null);
                }
                edv.setTime(rs.getLong(4));
                edv.setAnnotation(BaseDao.readTranslatableMessage(rs, 5));
                handler.pointData(edv);
            }
        });
    }
    handler.done();
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) SQLException(java.sql.SQLException) ExportDataValue(com.serotonin.m2m2.vo.export.ExportDataValue) BinaryValue(com.serotonin.m2m2.rt.dataImage.types.BinaryValue) ExportPointInfo(com.serotonin.m2m2.vo.export.ExportPointInfo) MultistateValue(com.serotonin.m2m2.rt.dataImage.types.MultistateValue) AlphanumericValue(com.serotonin.m2m2.rt.dataImage.types.AlphanumericValue) ResultSet(java.sql.ResultSet) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler) NumericValue(com.serotonin.m2m2.rt.dataImage.types.NumericValue) ImageValue(com.serotonin.m2m2.rt.dataImage.types.ImageValue) TextRenderer(com.serotonin.m2m2.view.text.TextRenderer)

Example 4 with DataType

use of com.serotonin.m2m2.DataType in project ma-modules-public by infiniteautomation.

the class PointValueImportResult method saveValue.

public void saveValue(XidPointValueTimeModel model) {
    if (valid) {
        // Validate the model against our point
        long timestamp = model.getTimestamp();
        if (timestamp == 0)
            timestamp = Common.timer.currentTimeMillis();
        int dataTypeId = DataTypeEnum.convertFrom(model.getType());
        if (dataTypeId != vo.getPointLocator().getDataTypeId()) {
            result.addContextualMessage("dataType", "event.ds.dataType");
            return;
        }
        DataValue value;
        switch(model.getType()) {
            case ALPHANUMERIC:
                value = new AlphanumericValue((String) model.getValue());
                break;
            case BINARY:
                value = new BinaryValue((Boolean) model.getValue());
                break;
            case MULTISTATE:
                if (model.getValue() instanceof String) {
                    try {
                        value = vo.getTextRenderer().parseText((String) model.getValue(), dataTypeId);
                    } catch (Exception e) {
                        // Lots can go wrong here so let the user know
                        result.addContextualMessage("value", "event.valueParse.textParse", e.getMessage());
                        return;
                    }
                } else {
                    value = new MultistateValue(((Number) model.getValue()).intValue());
                }
                break;
            case NUMERIC:
                value = new NumericValue(((Number) model.getValue()).doubleValue());
                break;
            case IMAGE:
            default:
                result.addContextualMessage("dataType", "common.default", model.getType() + " data type not supported yet");
                return;
        }
        PointValueTime pvt;
        if (model.getAnnotation() == null) {
            pvt = new PointValueTime(value, timestamp);
        } else {
            pvt = new AnnotatedPointValueTime(value, timestamp, new TranslatableMessage("common.default", model.getAnnotation()));
        }
        if (rt == null) {
            dao.savePointValueAsync(vo.getId(), pvt, null);
        } else {
            rt.savePointValueDirectToCache(pvt, null, true, true);
        }
        total++;
    }
}
Also used : DataValue(com.serotonin.m2m2.rt.dataImage.types.DataValue) BinaryValue(com.serotonin.m2m2.rt.dataImage.types.BinaryValue) MultistateValue(com.serotonin.m2m2.rt.dataImage.types.MultistateValue) AlphanumericValue(com.serotonin.m2m2.rt.dataImage.types.AlphanumericValue) AnnotatedPointValueTime(com.serotonin.m2m2.rt.dataImage.AnnotatedPointValueTime) PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime) AnnotatedPointValueTime(com.serotonin.m2m2.rt.dataImage.AnnotatedPointValueTime) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage) NumericValue(com.serotonin.m2m2.rt.dataImage.types.NumericValue)

Example 5 with DataType

use of com.serotonin.m2m2.DataType in project ma-core-public by infiniteautomation.

the class PointEventDetectorVO method getImplementations.

public static List<ImplDefinition> getImplementations(int dataType) {
    if (definitions == null) {
        List<ImplDefinition> d = new ArrayList<>();
        d.add(new ImplDefinition(TYPE_ANALOG_HIGH_LIMIT, null, "pointEdit.detectors.highLimit", new int[] { DataTypes.NUMERIC }));
        d.add(new ImplDefinition(TYPE_ANALOG_LOW_LIMIT, null, "pointEdit.detectors.lowLimit", new int[] { DataTypes.NUMERIC }));
        d.add(new ImplDefinition(TYPE_POINT_CHANGE, null, "pointEdit.detectors.change", new int[] { DataTypes.BINARY, DataTypes.MULTISTATE, DataTypes.NUMERIC, DataTypes.ALPHANUMERIC }));
        d.add(new ImplDefinition(TYPE_BINARY_STATE, null, "pointEdit.detectors.state", new int[] { DataTypes.BINARY }));
        d.add(new ImplDefinition(TYPE_MULTISTATE_STATE, null, "pointEdit.detectors.state", new int[] { DataTypes.MULTISTATE }));
        d.add(new ImplDefinition(TYPE_ALPHANUMERIC_STATE, null, "pointEdit.detectors.state", new int[] { DataTypes.ALPHANUMERIC }));
        d.add(new ImplDefinition(TYPE_ALPHANUMERIC_REGEX_STATE, null, "pointEdit.detectors.regexState", new int[] { DataTypes.ALPHANUMERIC }));
        d.add(new ImplDefinition(TYPE_STATE_CHANGE_COUNT, null, "pointEdit.detectors.changeCount", new int[] { DataTypes.BINARY, DataTypes.MULTISTATE, DataTypes.ALPHANUMERIC }));
        d.add(new ImplDefinition(TYPE_NO_CHANGE, null, "pointEdit.detectors.noChange", new int[] { DataTypes.BINARY, DataTypes.MULTISTATE, DataTypes.NUMERIC, DataTypes.ALPHANUMERIC }));
        d.add(new ImplDefinition(TYPE_NO_UPDATE, null, "pointEdit.detectors.noUpdate", new int[] { DataTypes.BINARY, DataTypes.MULTISTATE, DataTypes.NUMERIC, DataTypes.ALPHANUMERIC, DataTypes.IMAGE }));
        d.add(new ImplDefinition(TYPE_POSITIVE_CUSUM, null, "pointEdit.detectors.posCusum", new int[] { DataTypes.NUMERIC }));
        d.add(new ImplDefinition(TYPE_NEGATIVE_CUSUM, null, "pointEdit.detectors.negCusum", new int[] { DataTypes.NUMERIC }));
        d.add(new ImplDefinition(TYPE_ANALOG_RANGE, null, "pointEdit.detectors.range", new int[] { DataTypes.NUMERIC }));
        // d.add(new ImplDefinition(TYPE_ANALOG_CHANGE, null, "pointEdit.detectors.analogChange",
        // new int[] { DataTypes.NUMERIC }));
        d.add(new ImplDefinition(TYPE_SMOOTHNESS, null, "pointEdit.detectors.smoothness", new int[] { DataTypes.NUMERIC }));
        definitions = d;
    }
    List<ImplDefinition> impls = new ArrayList<>();
    for (ImplDefinition def : definitions) {
        if (def.supports(dataType))
            impls.add(def);
    }
    return impls;
}
Also used : ImplDefinition(com.serotonin.m2m2.view.ImplDefinition) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)17 DataValue (com.serotonin.m2m2.rt.dataImage.types.DataValue)16 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)11 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)9 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)8 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)8 AlphanumericValue (com.serotonin.m2m2.rt.dataImage.types.AlphanumericValue)8 MultistateValue (com.serotonin.m2m2.rt.dataImage.types.MultistateValue)8 NumericValue (com.serotonin.m2m2.rt.dataImage.types.NumericValue)8 DataType (ucar.ma2.DataType)8 DataType (com.serotonin.m2m2.DataType)7 BinaryValue (com.serotonin.m2m2.rt.dataImage.types.BinaryValue)7 IOException (java.io.IOException)7 HashMap (java.util.HashMap)7 AnnotatedPointValueTime (com.serotonin.m2m2.rt.dataImage.AnnotatedPointValueTime)6 File (java.io.File)6 ImageValue (com.serotonin.m2m2.rt.dataImage.types.ImageValue)5 Array (ucar.ma2.Array)5 Dimension (ucar.nc2.Dimension)5 Variable (ucar.nc2.Variable)5