Пример #1
0
  protected Advisory evaluateVital(Vital vital) {

    Advisory a = null;

    if (vital.isNoValueWarning() && vital.isEmpty()) {
      a = new Advisory(State.Warning, vital, null, "no source of");
    } else {
      for (Value val : vital) {
        if (val.isAtOrBelowLow()) {
          a =
              new Advisory(
                  val.isAtOrBelowCriticalLow() ? State.Alarm : State.Warning,
                  vital,
                  val.getValue(),
                  "low");
        }
        if (val.isAtOrAboveHigh()) {
          a =
              new Advisory(
                  val.isAtOrAboveCriticalHigh() ? State.Alarm : State.Warning,
                  vital,
                  val.getValue(),
                  "high");
        }
        if (a != null && a.state == State.Alarm) break;
      }
    }
    return a;
  }
Пример #2
0
 @Override
 public void addNumeric(final NumericFx numeric) {
   final String metric_id = numeric.getMetric_id();
   final String udi = numeric.getUnique_device_identifier();
   final String unit_id = numeric.getUnit_id();
   final int instance_id = numeric.getInstance_id();
   for (Vital v : this) {
     if (v != null) {
       for (String x : v.getMetricIds()) {
         // Change to this vital from a source
         if (x.equals(metric_id)) {
           for (Value va : v) {
             if (va.getInstanceId() == instance_id
                 && va.getMetricId().equals(metric_id)
                 && va.getUniqueDeviceIdentifier().equals(udi)) {
               if (!numeric.equals(va.getNumeric())) {
                 log.warn("duplicate numeric added {} {}", va.getNumeric(), numeric);
               }
               return;
             }
           }
           final Value va = new ValueImpl(numeric, v);
           v.add(va);
         }
       }
     }
   }
 }
Пример #3
0
 @Override
 protected Vital doRemove(int index) {
   Vital v = vitals.remove(index);
   elementObserver.detachListener(v);
   v.removeListener(this);
   if (null != v) {
     v.destroy();
   }
   return v;
 }
Пример #4
0
 @Override
 protected Vital doSet(int index, Vital element) {
   Vital removed = vitals.set(index, element);
   removed.removeListener(this);
   elementObserver.detachListener(removed);
   elementObserver.attachListener(element);
   removed.addListener(this);
   numericList.forEach((fx) -> addNumeric(fx));
   return removed;
 }
Пример #5
0
  protected Map<String, Advisory> evaluateState() {

    int N = size();

    Map<String, Advisory> advisories = new HashMap<>();

    for (int i = 0; i < N; i++) {
      Vital vital = get(i);
      Advisory a = evaluateVital(vital);
      if (a != null) advisories.put(vital.getLabel(), a);
    }

    return advisories;
  }
Пример #6
0
 @Override
 protected void doAdd(int index, Vital element) {
   element.addListener(this);
   elementObserver.attachListener(element);
   vitals.add(index, element);
   numericList.forEach((fx) -> addNumeric(fx));
 }
Пример #7
0
 @Override
 public void removeNumeric(NumericFx numeric) {
   final String metric_id = numeric.getMetric_id();
   for (Vital v : this) {
     if (v != null) {
       for (String x : v.getMetricIds()) {
         if (x.equals(metric_id)) {
           ListIterator<Value> li = v.listIterator();
           while (li.hasNext()) {
             if (numeric.equals(li.next().getNumeric())) {
               li.remove();
             }
           }
         }
       }
     }
   }
 }
Пример #8
0
 @Override
 public Observable[] call(Vital param) {
   return new Observable[] {
     //                    param.anyOutOfBoundsProperty(),
     //                    param.countOutOfBoundsProperty(),
     param.criticalHighProperty(),
     param.criticalLowProperty(),
     param.warningHighProperty(),
     param.warningLowProperty(),
     param.ignoreZeroProperty(),
     param.noValueWarningProperty(),
     param.valueMsWarningHighProperty(),
     param.valueMsWarningLowProperty()
   };
 }