Ejemplo n.º 1
0
  /**
   * Update JMS clients and RDB
   *
   * @param pv Alarm PV
   * @param current_severity Current channel severity
   * @param current_message Current message
   * @param severity Alarm severity (highest, latched)
   * @param message Alarm message
   * @param value Value that triggered
   * @param timestamp Time of last alarm update
   */
  public void sendStateUpdate(
      final AlarmPV pv,
      final SeverityLevel current_severity,
      final String current_message,
      final SeverityLevel severity,
      final String message,
      final String value,
      final Timestamp timestamp) {
    messenger.sendStateUpdate(
        pv, current_severity, current_message, severity, message, value, timestamp);
    // Move the persistence of states into separate queue & thread
    // so that it won't delay the alarm server from updating.

    // ReplacableRunnable:
    // If there is already an update request for this PV on the queue,
    // replace it with the new one because it's out of date and no
    // longer needs to be writting to the RDB anyway.
    work_queue.executeReplacable(
        new ReplacableRunnable<AlarmPV>(pv) {
          @Override
          public void run() {
            try {
              rdb.writeStateUpdate(
                  pv, current_severity, current_message, severity, message, value, timestamp);
              recoverFromRDBErrors();
            } catch (Exception ex) {
              // Remember that there was an error
              had_RDB_error = true;
              Activator.getLogger().log(Level.SEVERE, "Exception during alarm state update", ex);
            }
          }
        });
  }