Hi,
the Programmers-Guide (section 3.9.6 - Alarming) mentions a seperate API for Alarm Notification. Is there a documentation or even an example for this API aside from the javadocs?
If not, could someone please confirm that i’m on the right way with the following hook class (i used a modified driver module hook here):
package com.chitek.ignition.alarming.notification.ucp;
import org.apache.log4j.Logger;
import com.inductiveautomation.ignition.alarming.AlarmNotificationContext;
import com.inductiveautomation.ignition.common.licensing.LicenseState;
import com.inductiveautomation.ignition.gateway.model.AbstractGatewayModuleHook;
import com.inductiveautomation.ignition.gateway.model.GatewayContext;
import com.inductiveautomation.ignition.gateway.services.ModuleServiceConsumer;
public class ModuleHook extends AbstractGatewayModuleHook implements ModuleServiceConsumer {
private GatewayContext gatewayContext;
private AlarmNotificationContext alarmNotificationContext;
@Override
public void setup(GatewayContext gatewayContext) {
this.gatewayContext = gatewayContext;
}
@Override
public void startup(LicenseState licenseState) {
gatewayContext.getModuleServicesManager().subscribe(AlarmNotificationContext.class, this);
}
@Override
public void shutdown() {
gatewayContext.getModuleServicesManager().unsubscribe(AlarmNotificationContext.class, this);
if (alarmNotificationContext != null) {
try {
alarmNotificationContext.getAlarmNotificationManager().removeAlarmNotificationProfileType(new UcpSmsNotificationProfileType());
} catch (Exception e) {
Logger.getLogger(UcpSmsNotification.loggerName).error("Exception while removing AlarmNotificationProfileType", e);
}
}
}
@Override
public void serviceReady(Class<?> serviceClass) {
if (serviceClass == AlarmNotificationContext.class) {
alarmNotificationContext = (AlarmNotificationContext) gatewayContext.getModuleServicesManager().getService(AlarmNotificationContext.class);
try {
alarmNotificationContext.getAlarmNotificationManager().addAlarmNotificationProfileType(new UcpSmsNotificationProfileType());
} catch (Exception e) {
Logger.getLogger(UcpSmsNotification.loggerName).error("Exception while adding AlarmNotificationProfileType", e);
}
}
}
@Override
public void serviceShutdown(Class<?> serviceClass) {
if (serviceClass == AlarmNotificationContext.class) {
alarmNotificationContext = null;
Logger.getLogger(UcpSmsNotification.loggerName).debug("AlarmNotificationContext has been shut down");
}
}
}
Thanks in advance,
Carsten