Exemplo n.º 1
0
  //
  // / Interval logging
  //
  private void initializeIntervalLogging() {
    synchronized (intervalLoggingLock) {
      if (vo.getLoggingType() != DataPointVO.LoggingTypes.INTERVAL) return;

      // Are we using a custom timer?
      if (this.timer == null)
        intervalLoggingTask =
            new TimeoutTask(
                new FixedRateTrigger(
                    0,
                    Common.getMillis(
                        vo.getIntervalLoggingPeriodType(), vo.getIntervalLoggingPeriod())),
                this);
      else
        intervalLoggingTask =
            new TimeoutTask(
                new FixedRateTrigger(
                    0,
                    Common.getMillis(
                        vo.getIntervalLoggingPeriodType(), vo.getIntervalLoggingPeriod())),
                this,
                this.timer);

      intervalValue = pointValue;
      if (vo.getIntervalLoggingType() == DataPointVO.IntervalLoggingTypes.AVERAGE) {
        intervalStartTime = System.currentTimeMillis();
        averagingValues = new ArrayList<IValueTime>();
      }
    }
  }
Exemplo n.º 2
0
  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
          });
  }