コード例 #1
0
ファイル: SDevice.java プロジェクト: Farades/DataDealer
  private synchronized void updateAlarms() {
    //        activeAlarms.clear();
    for (TagBlankEntity tagBlankEntity : deviceEntity.getTagBlankEntities()) {
      for (AlarmBlank alarmBlank : tagBlankEntity.getAlarmBlanks()) {
        StringBuffer sb = new StringBuffer();

        try {
          sb.append(values.get(tagBlankEntity.getTagDescr()).getRegister());
          sb.append(alarmBlank.getCondition());
          String script = sb.toString();
          Boolean res = (Boolean) AlarmUtil.getInstance().getScriptEngine().eval(script);
          Alarm alarm = new Alarm(alarmBlank);
          if (res == true) {
            if (activeAlarms.contains(alarm)) {
              continue;
            } else {
              activeAlarms.add(alarm);
              AlarmEntity alarmEntity = new AlarmEntity();
              alarmEntity.setAlarmBlank(alarmBlank);
              alarmEntity.setAlarmTime(alarm.getStartTime());
              DataHelper.getInstance().saveAlarm(alarmEntity);
            }
          } else {
            if (activeAlarms.contains(alarm)) {
              activeAlarms.remove(alarm);
            }
          }
        } catch (RuntimeException ex) {
          ex.printStackTrace();
        } catch (ScriptException e) {
          e.printStackTrace();
        }
      }
    }
  }
コード例 #2
0
ファイル: SDevice.java プロジェクト: Farades/DataDealer
 private synchronized void updateValues() {
   for (TagBlankEntity tagBlankEntity : deviceEntity.getTagBlankEntities()) {
     Value value =
         new Value(
             Engine.getInstance()
                 .getHardwareEngine()
                 .getRegisterByID(tagBlankEntity.getTagBinding()),
             tagBlankEntity);
     values.put(tagBlankEntity.getTagDescr(), value);
   }
 }