Alarms are saved as Msg-objects in an internal Dictionary<string, Msg>. The entry is removed again in the event of alarm acknowledgments.
The key value of this dictionary is a property name of any network-enabled property that belongs to the class. This means that you can activate a separate alarm message for each property.
Usually an additional property of the type enum gip.core.autocomponent.PANotifyState is declared. This property serves not only as a name index for the internal alarm dictionary, but also for signaling the presence of an alarm on the user interface. i.e. a WPF-Control element is bound to this alarm property via WPF data binding.
If you want to display several alarms for an instance at the same time, you need several alarm properties. Otherwise, the previous alarm from the alarm dictionary is replaced with each new alarm. This means that only the last message can be displayed.
Such an alarm property was defined in the following example:
You get the ID that you pass to the Msg instance so that a translated text is displayed by adding an alarm to your class in the development environment:
Use the OnNewAlarmOccurred() method to add a new entry to the alarm list. If an unacknowledged alarm with the same message text already exists, no new entry is created. If the message text is different, the existing acknowledged alarm is replaced by the new message.
If you also want to write the alarm message to the log file, call the IsAlarmActive() method beforehand to check whether the same message is still pending. This prevents the same message from being output to the log file unnecessarily and multiple times.
You must explicitly set and reset the value of the alarm property yourself so that the bound WPF control indicates the presence of the alarm. You reset it in the overridden AcknowledgeAlarms() method. Don't forget to call base.AcknowledgeAlarms()! Otherwise you will prevent alarms from being acknowledged.
AcknowledgeAlarms() acknowledges all messages that belong to this ACComponent instance. With OnAlarmDisappeared() you can specifically acknowledge a specific alarm message while the others remain unaffected.
An alarm is displayed in the status bar as a flashing warning triangle. Double-click to open the alarm list and then navigate to the component that triggered the alarm - provided you have also added it to the visualization.
Alternatively, you can also acknowledge the alarm using the context menu.
You can find the example code here on gitHub.