We are very close, but noticed an odd problem. Can I get someone else’s thoughts?
The Alarm Log looks correct in regards to DisplayPath and Label
However, that is not translating to the Alarm Journal
Any input would be appreciated.
public void raiseAlarm(String code, String message, AlarmPriority priority, String displayPath, String label, String notes) {
var alarmDefinition = new BasicAlarmDefinition();
UUID id = UUID.randomUUID();
alarmDefinition.setName(code + "/" + id);
// AnyChange means this will fire whenever the evaluator's evaluate method is called.
// Because there's no value source to evaluate against, the state will always be cleared.
// If, in the future, we want to set an Active alarm state rather than cleared, we can use AlarmMode.Equality
// or similar with a setpoint property, and the active state can be driven by the value passed into the evaluate function.
// For now, we've kept this simple, with the thinking that the alarm state would be cleared in these cases,
// since the driving event (a code exception / processing error condition) will be fired and require a manual intervention.
// It might be especially interesting to consider using the active state in a case where a failure may be able to
// be resolved through automation. For example, a failed message to do an inventory move could allow for automated retries,
// and in the event that a retry succeeds, the alarm could clear.
// Here's an example of an equality config, looking for a 1 as SetpointA
alarmDefinition.set(AlarmModeProperties.Mode, AlarmMode.Equality);
alarmDefinition.set(AlarmModeProperties.SetpointA, 1d);
//alarmDefinition.set(AlarmModeProperties.Mode, AlarmMode.AnyChange);
//alarmDefinition.set(AlarmModeProperties.OnEachEvaluation, Boolean.TRUE);
alarmDefinition.set(CommonAlarmProperties.NotifyInitialEvent, Boolean.TRUE);
alarmDefinition.set(CommonAlarmProperties.EventId, id);
alarmDefinition.set(CommonAlarmProperties.Label, label);
alarmDefinition.set(CommonAlarmProperties.DisplayPath, displayPath);
alarmDefinition.set(CommonAlarmProperties.Priority, priority);
alarmDefinition.set(CommonAlarmProperties.Notes, notes);
QualifiedPath path = QualifiedPath.of(
WellKnownPathTypes.Source, "LIFT Module",
WellKnownPathTypes.Alarm, code
);
var configuration = new BasicAlarmConfiguration(Collections.singletonList(alarmDefinition));
var evaluator = this.getGatewayContext().getAlarmManager().registerAlarm(
path,
null,
configuration,
null
);
evaluator.setAlarmObserver(this);
evaluators.put(id, evaluator);
evaluator.evaluate(new BasicQualifiedValue(Boolean.TRUE));
}