public void forcePointRead(int dataPointId) {
    DataPointRT dataPoint = dataPoints.get(dataPointId);
    if (dataPoint == null) throw new RTException("Point is not enabled");

    // Tell the data source to read the point value;
    DataSourceRT ds = getRunningDataSource(dataPoint.getDataSourceId());
    if (ds != null)
      // The data source may have been disabled. Just make sure.
      ds.forcePointRead(dataPoint);
  }
  public void setDataPointValue(int dataPointId, PointValueTime valueTime, SetPointSource source) {
    DataPointRT dataPoint = dataPoints.get(dataPointId);
    if (dataPoint == null) throw new RTException("Point is not enabled");

    if (!dataPoint.getPointLocator().isSettable()) throw new RTException("Point is not settable");

    // Tell the data source to set the value of the point.
    DataSourceRT ds = getRunningDataSource(dataPoint.getDataSourceId());
    // The data source may have been disabled. Just make sure.
    if (ds != null) ds.setPointValue(dataPoint, valueTime, source);
  }
  public void relinquish(int dataPointId) {
    DataPointRT dataPoint = dataPoints.get(dataPointId);
    if (dataPoint == null) throw new RTException("Point is not enabled");

    if (!dataPoint.getPointLocator().isSettable()) throw new RTException("Point is not settable");
    if (!dataPoint.getPointLocator().isRelinquishable())
      throw new RTException("Point is not relinquishable");

    // Tell the data source to relinquish value of the point.
    DataSourceRT ds = getRunningDataSource(dataPoint.getDataSourceId());
    // The data source may have been disabled. Just make sure.
    if (ds != null) ds.relinquish(dataPoint);
  }
  private void stopDataPoint(int dataPointId) {
    synchronized (dataPoints) {
      // Remove this point from the data image if it is there. If not, just quit.
      DataPointRT p = dataPoints.remove(dataPointId);

      // Remove it from the data source, and terminate it.
      if (p != null) {
        getRunningDataSource(p.getDataSourceId()).removeDataPoint(p);
        DataPointListener l = getDataPointListeners(dataPointId);
        if (l != null) l.pointTerminated();
        p.terminate();
      }
    }
  }
  private void stopDataSource(int id) {
    synchronized (runningDataSources) {
      DataSourceRT dataSource = getRunningDataSource(id);
      if (dataSource == null) return;

      // Stop the data points.
      for (DataPointRT p : dataPoints.values()) {
        if (p.getDataSourceId() == id) stopDataPoint(p.getId());
      }

      runningDataSources.remove(dataSource);
      dataSource.terminate();

      dataSource.joinTermination();
      LOG.info("Data source '" + dataSource.getName() + "' stopped");
    }
  }
示例#6
0
 protected void createStateImpl(
     RuntimeManager rtm, HttpServletRequest request, JspComponentState state) {
   DataPointRT dataPointRT = rtm.getDataPoint(this.dataPointVO.getId());
   String value;
   if (dataPointRT == null) {
     value = this.disabledValue;
   } else {
     PointValueTime pvt = dataPointRT.getPointValue();
     if ((pvt != null) && ((pvt.getValue() instanceof ImageValue))) {
       Map model = new HashMap();
       model.put("point", this.dataPointVO);
       model.put("pointValue", pvt);
       value = BaseDwr.generateContent(request, "imageValueThumbnail.jsp", model);
     } else {
       int hint = this.raw ? 1 : 2;
       value = this.dataPointVO.getTextRenderer().getText(pvt, hint);
       if ((pvt != null) && (this.time)) state.setTime(Long.valueOf(pvt.getTime()));
     }
   }
   state.setValue(value);
 }
  @Override
  protected void createStateImpl(
      RuntimeManager rtm, HttpServletRequest request, JspComponentState state) {
    String value;
    DataPointRT dataPointRT = rtm.getDataPoint(dataPointVO.getId());
    if (dataPointRT == null) value = disabledValue;
    else {
      PointValueTime pvt = dataPointRT.getPointValue();

      if (pvt != null && pvt.getValue() instanceof ImageValue) {
        // Text renderers don't help here. Create a thumbnail.
        Map<String, Object> model = new HashMap<String, Object>();
        model.put("point", dataPointVO);
        model.put("pointValue", pvt);
        value = BaseDwr.generateContent(request, "imageValueThumbnail.jsp", model);
      } else {
        int hint = raw ? TextRenderer.HINT_RAW : TextRenderer.HINT_FULL;
        value = dataPointVO.getTextRenderer().getText(pvt, hint);
        if (pvt != null && time) state.setTime(pvt.getTime());
      }
    }
    state.setValue(value);
  }
  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);
      }
    }
  }
 private void updateDataPointValuesRT(int dataPointId) {
   DataPointRT dataPoint = dataPoints.get(dataPointId);
   if (dataPoint != null)
     // Enabled. Reset the point's cache.
     dataPoint.resetValues();
 }