Download the Solution Example here: https://partners.tatsoft.com/dl/QkxlpsZ0Zy
Name: AlarmEmailAndSMS
Software Version: 10.1
Summary
Alarms can be connected to scripts to run customized code whenever they are triggered. This solution example shows how to use scripts to voice an Alarm message.
Technical Information
Every AlarmItem belongs to an AlarmGroup that specifies how Alarms are supposed to be presented and acknowledged. This example has two AlarmItems, both belonging to AlarmGroup Critical. To see how this AlarmGroup is configured, go to the Alarms → Groups table.
We can define a custom message to better describe the meaning of an AlarmItem. To do so, go to the Alarms → Items table and change the values in the Message column. In order to audibly play the custom message whenever an AlarmItem is triggered, we first need to create a method with our custom text-to-speech code. To do this, go to Scripts → Classes and create a new class with the desired method. In this example, we have class ATSNotification set up with the following code:
Code Block | ||
---|---|---|
| ||
//Pay attention to the function's parameter. //It has to be like this to correctly connect with the AlarmGroup. public void AlarmCustom(AlarmEventInfo[] items) { if (items[0].State == 1) { SpeechSynthesizer synth = new SpeechSynthesizer(); // Configure the audio output. synth.SetOutputToDefaultAudioDevice(); // Speak the message associated with the AlarmItem. synth.Speak(items[0].Message); } } |
To make this method run whenever one of the AlarmItems is triggered, you can go to the Alarms → Groups table, right-click the column titles and enable the NotificationMethod column. Then, change its value to ATSNotification.AlarmCustom.
In this section:
Page Tree | ||||
---|---|---|---|---|
|