// // // Data points // public void saveDataPoint(DataPointVO point) { stopDataPoint(point.getId()); // Since the point's data type may have changed, we must ensure that the other attrtibutes are // still ok with // it. int dataType = point.getPointLocator().getDataTypeId(); // Chart renderer if (point.getChartRenderer() != null && !point.getChartRenderer().getDef().supports(dataType)) // Return to a default renderer point.setChartRenderer(null); // Text renderer if (point.getTextRenderer() != null && !point.getTextRenderer().getDef().supports(dataType)) // Return to a default renderer point.defaultTextRenderer(); // Event detectors Iterator<PointEventDetectorVO> peds = point.getEventDetectors().iterator(); while (peds.hasNext()) { PointEventDetectorVO ped = peds.next(); if (!ped.getDef().supports(dataType)) // Remove the detector. peds.remove(); } new DataPointDao().saveDataPoint(point); if (point.isEnabled()) startDataPoint(point); }
private boolean initializeDataSource(DataSourceVO<?> vo) { synchronized (runningDataSources) { // If the data source is already running, just quit. if (isDataSourceRunning(vo.getId())) return false; // Ensure that the data source is enabled. Assert.isTrue(vo.isEnabled()); // Create and initialize the runtime version of the data source. DataSourceRT dataSource = vo.createDataSourceRT(); dataSource.initialize(); // Add it to the list of running data sources. runningDataSources.add(dataSource); // Add the enabled points to the data source. List<DataPointVO> dataSourcePoints = new DataPointDao().getDataPoints(vo.getId(), null); for (DataPointVO dataPoint : dataSourcePoints) { if (dataPoint.isEnabled()) startDataPoint(dataPoint); } LOG.info("Data source '" + vo.getName() + "' initialized"); return true; } }
private void updatePoints() { // Get the points List<DataPointVO> dps = query( "select dp.id, dp.xid, dp.dataSourceId, dp.data, ds.name, " // + "ds.xid, ds.dataSourceType " // + "from dataPoints dp join dataSources ds on ds.id = dp.dataSourceId ", new DataPointRowMapper()); // Resave for (DataPointVO dp : dps) ejt.update( "update dataPoints set xid=?, name=?, deviceName=?, enabled=?, loggingType=?, " // + "intervalLoggingPeriodType=?, intervalLoggingPeriod=?, intervalLoggingType=?, " // + "tolerance=?, purgeType=?, purgePeriod=?, defaultCacheSize=?, discardExtremeValues=?, " // + "engineeringUnits=?, data=? where id=?", // new Object[] { dp.getXid(), dp.getName(), dp.getDeviceName(), boolToChar(dp.isEnabled()), dp.getLoggingType(), dp.getIntervalLoggingPeriodType(), dp.getIntervalLoggingPeriod(), dp.getIntervalLoggingType(), dp.getTolerance(), dp.getPurgeType(), dp.getPurgePeriod(), dp.getDefaultCacheSize(), boolToChar(dp.isDiscardExtremeValues()), dp.getEngineeringUnits(), SerializationHelper.writeObject(dp), dp.getId() }, // new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.CHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.DOUBLE, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.CHAR, Types.INTEGER, Types.BLOB, Types.INTEGER }); }
private void startDataPoint(DataPointVO vo) { synchronized (dataPoints) { Assert.isTrue(vo.isEnabled()); // Only add the data point if its data source is enabled. DataSourceRT ds = getRunningDataSource(vo.getDataSourceId()); if (ds != null) { // Change the VO into a data point implementation. DataPointRT dataPoint = new DataPointRT(vo, vo.getPointLocator().createRuntime()); // Add/update it in the data image. dataPoints.put(dataPoint.getId(), dataPoint); // Initialize it. dataPoint.initialize(); DataPointListener l = getDataPointListeners(vo.getId()); if (l != null) l.pointInitialized(); // Add/update it in the data source. ds.addDataPoint(dataPoint); } } }
public void deleteDataPoint(DataPointVO point) { if (point.isEnabled()) stopDataPoint(point.getId()); new DataPointDao().deleteDataPoint(point.getId()); Common.eventManager.cancelEventsForDataPoint(point.getId()); }