Software Overview  |  Sitemap  |  Downloads  |  Developers  |  Forums
Small_clear_logo_llc

Customizing Alarm Output Messages

The Alarm Device is doing what you want it to do, but you want to define your own output messages. To create your own messages, we will build a State Machine that re-maps messages from an Alarm Device "trigger" terminal to your own customized ones.

Our State Machine will have two inputs and one output. The inputs are from the Alarm Device "enabled" and "trigger" terminals. The output has our customized Alarm messages. Each time the State Machine sees a message from the "trigger" terminal, it checks its "enabled" signal (to see if the Alarm Device is on). If the Alarm Device is enabled, the State Machine generates a custom Alarm message.

Here is a State Machine table which generates customized Alarm messages for an Alarm Device with two alarm inputs - "alarm1" and "alarm2". The inputs are triggered by an on value. Messages are created when the Alarm Device is enabled.

alarm_messages:
-
  When: {trigger: "\"alarm1=on\""}
  State: {enabled: "on"}
  Then: {new_message: "\"Hey, Alarm1 is on!\""}
-
  When: {trigger: "\"alarm2=on\""}
  State: {enabled: "on"}
  Then: {new_message: "\"Hey, Alarm2 is on!\""}

Create the State Machine and wire the Alarm "enabled" and "trigger" output signals to the State Machine's "enabled" and "trigger" signals. The "new_message" signal has your custom messages.

Some Helper Methods

The Alarm Device has methods for altering its behavior. Both are used when customizing Alarm messages. One, "output_raw_trigger" simplifies the messages on the "trigger" output terminal. The other, "disable_alarm_messages", removes alarm messages from the "messages" terminal.

output_raw_trigger

Messages on an Alarm Device's "trigger" output terminal are of the form "terminal=value". If there are only a few possible trigger values (e.g. off or on), building a state machine is straightforward. However, if there are many possible trigger values (values can also be numeric within a range), building customized messages for each trigger value may be unrealistic.

If you have many possible trigger values, call the "output_raw_trigger" method. The method changes the "trigger" terminal messages from a "terminal=value" format to a "trigger: trigger number" format. Instead of the value which caused a trigger, you will get a trigger number.

Trigger numbers are assigned, on a per Alarm input basis, each time you define a trigger condition. Trigger numbers start at 1. So, for example, if we wanted an input which triggered on a range from 0-10 and on the value 10, we would call the Range InputTypes Script and the Equal Script. If we called the Range Script first and the Equal Script second, a trigger value of 4 would report trigger number 1 (from the Range Script). A trigger value of 10 would report trigger number 2.

With raw triggers, our State Machine might look like:

alarm_messages:
-
  When: {trigger: "\"alarm1: 1\""}
  State: {enabled: "on"}
  Then: {new_message: "\"Hey, Alarm1 is on!\""}
-
  When: {trigger: "\"alarm1: 2\""}
  State: {enabled: "on"}
  Then: {new_message: "\"Hey, Alarm1 is on due to our 2nd trigger condition!\""}
-
  When: {trigger: "\"alarm2: 1\""}
  State: {enabled: "on"}
  Then: {new_message: "\"Hey, Alarm2 is on!\""}

disable_alarm_messages

The "disable_alarm_messages" method is handy when you are defining your own alarm messages. It will keep alarm messages from appearing on the "messages" output terminal. It will allow alarm command responses. If you create your own alarm messages without disabling alarm messages, alarms will generate 2 messages: one of your defined messages and one from your Alarm "messages" terminal. You probably want just one message.

After invoking "disable_alarm_messages" the Alarm Device "messages" terminal will just have responses to your commands. The customized messages terminal and the Alarm "messages" terminal can be wired together (OR'ed) to create a complete set of messages.

Invoking the Methods

To enable raw triggers or disable alarm messages, call them by either typing into the Console or from a Script.

To call the "output_raw_trigger" method for a Device with ID "alarm", type:

run_script("", text:"output_raw_trigger()", on_device:"alarm")

To call the "disable_alarm_messages" method for a Device with ID "alarm", type:

run_script("", text:"disable_alarm_messages()", on_device:"alarm")

Catalina Computing, LLC.

Copyright © Catalina Computing, LLC. (2013-2017)




Page last updated: Tue Mar 22 19:46:19 2016 (UTC)