The script reads alarms from global variables and types and generates tmx texts, Set/Reset functions and MpAlarmXCore alarm list.
The script is run in the prebuild part with the -prebuild argument. When it is double-clicked in AS, the GUI of its configuration is shown.
How does the script work?
- Alarms from global variables are read
- All possible paths to alarm structures are determined
- The detected alarms are written to a tmx file (there you then have to write the texts by yourself)
- In the Alarms program are generated Set/Reset functions in the section marked for automatic generation
- In the selected configuration, alarms in AlarmsCfg.mpalarmxcore are generated
User settings
User settings are stored in folder AppData\Roaming\BR\Scripts\CreateAlarms
Supported properties
Properties are key=value pairs in Description[2]. Multiple properties are separated by comma or semicolon.
Values are used to create Alarm List configuration in mpalarmxcore file.
Properties Name and Message are generated automatically.
Key | Value |
---|---|
Code | unsigned integer |
Severity | unsigned integer |
Behavior | EdgeAlarm, PersistentAlarm, UserDefined |
Behavior.AutoReset | FALSE, TRUE |
Behavior.Acknowledge | Disabled, Required, RequiredAfterActive, RequiredAndResettable |
Behavior.MultipleInstances | FALSE, TRUE |
Behavior.ReactionUntilAcknowledged | FALSE, TRUE |
Behavior.Retain | FALSE, TRUE |
Behavior.Asynchronous | FALSE, TRUE |
Behavior.DataUpdate.Activation.Timestamp | FALSE, TRUE |
Behavior.DataUpdate.Activation.Snippets | FALSE, TRUE |
Behavior.HistoryReport.InactiveToActive | FALSE, TRUE |
Behavior.HistoryReport.ActiveToInactive | FALSE, TRUE |
Behavior.HistoryReport.UnacknowledgedToAcknowledge | FALSE, TRUE |
Behavior.HistoryReport.AcknowledgedToUnacknowledge | FALSE, TRUE |
Behavior.HistoryReport.Update | FALSE, TRUE |
Disable | FALSE, TRUE |
AdditionalInformation1 | string |
AdditionalInformation2 | string |
Advantages
- Faster creation of new alarms
- All necessary alarm configurations are done by this script
- Prevention of copying errors
- Better code clarity and robustness
- Easy to add many alarms at one time
- Follows B&R Coding guidelines
Limitations
- Just C and ST languages
- Only Edge, Persistent and UserDefined alarms behavior (monitoring behaviors do not need set/reset in task)
- Currently only for AS4
Requirements
- Python (https://www.python.org/)
- Python library PyQt5 (PyQt5 · PyPI)
- Alarms are divided into Error, Warning and Info groups (each data type containing the word “Error”, “Warning” or “Info” is taken as an alarm data type and is taken into account when generating the code (keywords can be changed in script configuration))
- Alarms have to be BOOL types
- Properties of alarms must be written into the Description[2] column and separated by semicolon or comma (supported properties see above)
Implementation to your project
- Add the CreateAlarms.py script to the Logical View in your project (can also be in subfolders)
- Add script to prebuild events with “-prebuild” argument
$(AS_PROJECT_PATH)/Logical/Scripts/CreateAlarms.py -prebuild
- Run script by double-click in AS and setup script configuration, then press OK (this step is not mandatory, if you skip it, the default configuration will be used)
- Task Alarms with Alarms.c (or Alarms.st), Alarms.typ, Alarms.var and Alarms.tmx must be inserted into Logical View (can be also in subfolders)
- In Alarms.c (or Alarms.st) and Alarms.typ must be defined section for automatic code generation
// START OF AUTOMATIC CODE GENERATION //
// END OF AUTOMATIC CODE GENERATION //
- Alarms.tmx must has namespace “Alarms”
- In the configuration selected in the script configuration, there must be AlarmsCfg.mpalarmxcore file
Video tutorial / demonstration
Version info
Version 2.2.0
- Possibility of choosing keywords for alarms (Error, Warning, Info)
- Behavior.Acknowledge replacing bug fixed
- GUI style changed
Version 2.1.0
- Python GUI template implemented
- Tmx encoding improved
- Alarms sorting by code and variable name
- Not resetting of Edge alarms (its automatic)
Version 2.0.2
- Changes according to B&R Coding guidelines
Version 2.0.1
- Once nested alarms path bug fixed
- Supported properties change
- Print of used configuration
- Invalid property name bug fixed
Version 2.0.0
- New system of finding alarm paths
- Support of arrays (also defined by constants)
Version 1.2.0
- Configuration of sections to update
- Configuration of TMX, MpConfig and program name
- Properties validity
- Strings must be in quotation marks
Version 1.1.0
- Bug with default alarm behavior fixed
- Behavior.Monitoring.MonitoredPV bug fixed
- Tags are taken from the graphics editor
- Monitoring alarm types have no longer Set and Reset in the Alarms program
- Path to user data changed to AppData\Roaming\BR\Scripts\CreateAlarms\
Version 1.0.0
- Script creation
- Basic functions implemented
Download
CreateAlarms_v2.2.0.zip (16.1 KB)
GitHub repo
Create alarms