Trigger Messages Using Property Variables (Dynamic Messages)
In the previous step, we learned how to trigger messages by using structured objects.
In some scenarios we also want to provide dynamic message data from the PLC in a similar way, but we cannot follow the structured object approach.
For example, because the variables that provide the message metadata are different in another way. They could, for example, not be provided by an object but a flat list of variables.
In such situations you can use the Dynamic Message
trigger and simply connect
a bunch of variables to provide the metadata of your message.
1. Import Variables From Your PLC
- Locate the
Examples/Concrete/Messaging/DynamicMessages
Variables
Locate the Dynamic Message objects in the Data Source Explorer.
You should spot them in this directory:
Examples/Concrete/Messaging/DynamicMessages
.
- Import the Variables
Let's import the variables and method into the project so that we can use it in our HMI.
- First of all import the whole
DynamicMessages
folder as it contains our dynamic objects. - We're also going to use the two methods
AcknowledgeMessageByCode
andSimulateMessage
. Make sure you import those, too.
Why Do We Need Those Methods?
Both methods are only needed for simulation purposes:
SimulateMessage
tells our Playground PLC to fill one of our message code variables, so we can simulate a message appearing on our PLC.AcknowledgeMessageByCode
tells our Playground PLC to remove an active message.
- Set Restrictions
2. Set Up Your Triggers
Now that we've got some data, let's define the triggers that will make sure changes to this data will actually trigger a message.
- Define Your First Trigger
Switch to the Message Triggers View, click
the Add Type
action and choose Dynamic Message
as a trigger type.
- Link the Code Variable
As with structured object triggers, we do not hardcode a specific message code for each trigger.
But instead of mapping the message fields to a structured object, we'll
link each message field to a variable that supplies the metadata.
We start with the required Code Variable
property and link it to:
DynamicMessages/MessageList/Message 0/Code
When Will Messages Appear?
Once this variable changes from an empty to a non-empty string e.g. WARN-001
.
- Link Additional Variables
Yor are free to link additional message fields to other variables. As with structured object triggers, there are some rules that apply to the message fields that the PLC must respect:
Code
(required)
Code
(required)- Its value represents the Message Code of the message that shall be displayed.
- Must be of type String. But can of course be used to represent numerical values as well.
- Signals HELIO to display a message, if the variable is set to a non-empty string e.g.
WARN-001
. - Signals HELIO to remove the message, if the variable is set to an empty string again.
- Should best be called
Code
, but you can actually call it however you like.
Level
(optional)
Level
(optional)- Is used by HELIO to determine the level of the message. See Messaging Basics: Storage, Codes and Levels for more details…
- Must be of type String.
- Allowed values:
Info
,Warn
, orError
.
Title
(optional)
Title
(optional)- Is displayed by HELIO in the Message Dialog as the title of this message.
- Must be of type String.
- Can be a Translation Key. HELIO will translate it automatically.
Description
(optional)
Description
(optional)- Is displayed by HELIO in the Message Dialog as the description of this message.
- Must be of type String.
- Can be a Translation Key. HELIO will translate it automatically.
After connecting all the message field your trigger should look like this:
- Add Additional Triggers
Repeat this procedure for every message object by duplicating the message trigger and simply adjusting the variables.
You've used all sorts of Message Trigger and Trigger Sources now.
Ready to learn about displaying active and archived messages within your HMI?