Perspective Map Icon change on Alarm

I'm trying to change the color of an icon on a map component based on whether or not an alarm is active at a site associated with the icon. I have a tagging strategy that lets me easily identify where an alarm is happening, but it seems to me like the only way to change the icons on a map is to have a script run on EVERY icon's style.classes property that looks for alarms for the location with an expression function that looks something like this.

Obviously the script would need to output some string associated with a class that is meant for alarms, but it seems to me like this approach is not very scalable with a lot of sites (which I have). Any ideas on another approach?

You could send a gateway-scoped message using system.util.sendMessage() from within a script on your alarm notification pipeline and have it handled in your project as a gateway-scoped message handler. You would then send a session-scoped message from there using system.perspective.sendMessage() and add a handler for it on your view. The handler would index into whatever site is specified by the message payload and change its color. You'd send the message whenever the alarm is triggered, acked, cleared, etc.

You'd probably still want to run an onLoad script on your view that calls system.alarm.queryStatus and colors all of your icons so that things look right when you load the page.

2 Likes