1. The Multi-Instance Alarm Filtering Problem
Template faceplates in TIA Portal are designed for reuse: a single graphic is instantiated multiple times on a process screen, each instance bound to a different PLC tag prefix. Motor faceplates in the Siemens LBP demo project follow this pattern - one faceplate type is instanced for every drive, conveyor, or pump. Each instance opens its own popup alarm view when the operator requests diagnostic information.
The non-trivial requirement is that the alarm popup must show only the alarms for the motor that opened it. Without filtering, the WinCC Alarm Control shows the full plant alarm buffer, which is operationally useless when 30 motors are on screen and the operator is inspecting motor M_17. The expected behavior is:
- Operator clicks the alarm icon on the M_17 faceplate.
- The popup faceplate opens with an embedded alarm view.
- The alarm view automatically scopes its SQL/text filter to the M_17 tag-prefix namespace.
- When the operator closes the popup, the alarm view either clears or retains last filter for audit.
The LBP reference implementation solves this elegantly, but the dynamization that drives it is hidden inside a property event that is not obvious to engineers inspecting the project for the first time. The filtering is not performed by a script attached to the alarm control itself - it is performed by a script attached to the Modified event of a Name object that is dynamically rewritten when each faceplate instance is opened.
2. Prerequisites: TIA Portal, LBP Library, and WinCC Versions
Before implementing per-instance alarm filtering, confirm the engineering environment matches the LBP reference design.
| Component | Minimum Version | Notes |
|---|---|---|
| TIA Portal | V17 Update 4 or later | LBP library demo project distributed for V17/V18. Earlier versions lack the unified JavaScript API surface. |
| STEP 7 / PLC | S7-1500 FW 2.9 or later | Multi-instance FB support required. |
| WinCC Unified | V17 or later | Recommended runtime. JavaScript-based dynamization. |
| WinCC Professional / Comfort | V17 or later | VBScript-based alternative path; uses HMIRuntime API. |
| LBP Library | Latest add-on package | Distributed via Siemens SiePortal / Support entry 109814706. |
Reference documentation that should be on hand during implementation:
- SIMATIC WinCC Unified - Programming and Operating Manual (Siemens Support entry)
- SIMATIC TIA Portal - WinCC Professional V18 Function Manual
- TIA Portal - LBP Reference Library Description and Demo Project
3. How the LBP Library Achieves Instance-Specific Filtering
The LBP motor faceplate is structured in three nested layers:
- Base faceplate - the visible motor graphic, with TagPrefix interface property.
- Alarm popup faceplate - a modal screen opened via SiVARc and the Screenhandling script.
- Embedded alarm control - a WinCC Alarm Control inside the popup that displays the message buffer.
The TagPrefix property is propagated from the HMI tag to the popup faceplate's interface. When the popup is opened, the LBP code rewrites the Name property of a hidden auxiliary object so that the new value embeds the TagPrefix string. Because the Name property changed, its Modified event fires. The script handler attached to Modified reads the new name, extracts the tag prefix, and pushes that prefix into the alarm control's MsgFilterSQL property (WinCC Unified) or MsgFilter collection (WinCC Professional).
The full chain is therefore:
- PLC FB multi-instance data block tag prefix flows into faceplate TagPrefix interface property.
- SiVARc + Screenhandling script opens the popup and assigns a unique, instance-scoped string to the Name property.
- WinCC fires the Modified event on the Name object.
- Script handler on Modified event computes the alarm filter expression and assigns it to the alarm control.
- Alarm control refreshes, now scoped to the motor instance.
4. The Modified Property Event Mechanism Explained
Every dynamizable object in WinCC Unified and WinCC Professional exposes a Modified event on its string and variant properties. The event fires whenever the property value changes from one value to a different value at runtime - it does not fire on the initial assignment unless the value differs from the configured default.
| Property | Runtime Type | Modified Event Fires When |
|---|---|---|
| Name (String) | WinCC Unified + Professional | The string content changes from value A to value B at runtime. |
| Caption (String) | WinCC Unified + Professional | The visible caption text changes. |
| Tag (String) | WinCC Unified + Professional | The connected tag is rebound at runtime. |
| Value (Variant) | WinCC Unified | Bound process value updates with a new content. |
The Modified event on Name is preferred for alarm filtering because:
- The Name property is purely textual and not visually used by the alarm control logic.
- It is guaranteed to change once per popup open when the TagPrefix is concatenated into the new value.
- It avoids triggering the event on background process updates that would re-fire the filter script unnecessarily.
OnOpen event for popup faceplates. The Modified-on-Name technique is the canonical workaround documented in the LBP demo project and in the Siemens WinCC Unified engineering FAQ.5. Implementing the Tag Prefix and Name Dynamization
Step 1 - expose the TagPrefix to the popup faceplate interface:
- Open the popup faceplate in the TIA Portal editor.
- Right-click the faceplate root and select Interface > Properties.
- Add a new property of type
StringnamedTagPrefix. - Set the property's Visible in HMI flag so it can be assigned when the popup is instantiated.
Step 2 - add a hidden auxiliary object:
- Inside the popup faceplate, place a Text field with the Visible property set to
false(so the operator never sees it). - Name this object
AlarmFilterTrigger. Its default Name property must be set to a placeholder such as_UNSET_.
Step 3 - dynamize the Name property to include the TagPrefix:
- Select
AlarmFilterTrigger. - Open Properties > Properties > Name.
- Create a script dynamization that returns:
"ALARM_FILTER_" + Faceplate.Properties.TagPrefix.
For WinCC Unified JavaScript the dynamization body is:
return "ALARM_FILTER_" + Faceplate.Properties.TagPrefix;
For WinCC Professional VBScript use:
Dim sPrefix
sPrefix = SmartTags("Faceplate.Properties.TagPrefix")
Item.Name = "ALARM_FILTER_" & sPrefix
Every time the popup is opened with a different TagPrefix the Name changes, so the Modified event fires.
6. Script Code for Alarm Filter Application
6.1 WinCC Unified (JavaScript)
Attach the following script to the Modified event of the Name property of AlarmFilterTrigger:
// Triggered when AlarmFilterTrigger.Name changes
(function() {
// Resolve the alarm control by name (assume control is named "MotorAlarmControl")
var alarmControl = Screen.Items("MotorAlarmControl");
var prefix = Faceplate.Properties.TagPrefix;
// Build a SQL filter expression that matches alarms raised
// with Area = 'MOTOR' and the tag-prefix specific source.
var filterSQL =
"(AREA = 'MOTOR') AND " +
"(SOURCE LIKE '" + prefix + \\%.\\%' )";
// Apply the filter to the alarm control
alarmControl.MsgFilterSQL = filterSQL;
// Optional: log for diagnostics
HMIRuntime.Trace("Alarm filter applied for prefix: " + prefix);
})();
6.2 WinCC Professional / Comfort (VBScript)
For Comfort Panel runtime, attach the equivalent VBScript to the Modified event of the Name property:
' --- Modified event handler on AlarmFilterTrigger.Name ---
Dim oScreen
Dim oAlarm
Dim sPrefix
Dim sFilter
Set oScreen = HMIRuntime.Screens(HMIRuntime.BaseScreenName)
Set oAlarm = oScreen.ScreenItems("MotorAlarmControl")
sPrefix = SmartTags("TagPrefix")
sFilter = "AREA = 'MOTOR' AND SOURCE LIKE '" & sPrefix & ".%'"
oAlarm.MsgFilterSQL = sFilter
7. Wiring the Popup Alarm View into the Faceplate
Step-by-step wiring using the LBP Screenhandling script conventions:
- Create a new screen
FP_Alarm_Motor. Place the popup faceplate as the root. - Place the WinCC Alarm Control inside the popup, name it
MotorAlarmControl. - Configure the alarm source under Alarm Control > Properties > Message Selection: enable System-defined messages and User-defined messages; set the message class filter to your
MOTORclass. - Open the parent motor faceplate, find the alarm icon button, and assign the click event to call the LBP Screenhandling macro. Typical call form:
Screenhandling.OpenPopup("FP_Alarm_Motor", Faceplate.Properties.TagPrefix); - Inside
Screenhandling.OpenPopup, ensure the TagPrefix interface parameter of the popup faceplate is assigned from the call argument.
8. Configuring the Alarm Control Filter Source
The alarm control filter relies on the WinCC message configuration having a source naming convention that the script can match. Recommended convention:
| Field | Convention | Example |
|---|---|---|
| AREA | Functional group | MOTOR |
| SOURCE | Tag-prefix of the raising block, dot-separated | DB17_HMI.DB_Motor_17.M1 |
| EVENT | Discrete alarm category | Overload, Trip, Warning |
When the operator opens the M_17 popup, TagPrefix = DB17_HMI.DB_Motor_17. The filter SOURCE LIKE 'DB17_HMI.DB_Motor_17.%' returns only alarms raised by that data block. The wildcard % matches sub-elements such as M1 inside the block.
9. Verification and Runtime Testing Procedure
- Compile the project to the WinCC Unified RT or the Comfort Panel.
- Start runtime. Confirm that the plant screen shows several motor faceplates, each with a distinct TagPrefix.
- Trigger an alarm on motor M_17 (force the overload bit in the PLC, or use the alarm simulator).
- Trigger an alarm on motor M_22.
- Click the alarm icon on M_17 faceplate.
- Verify the popup opens and the alarm list contains the M_17 alarm only.
- Close the popup and open the M_22 alarm view. Confirm the M_22 alarm appears and the M_17 alarm is absent.
- Inspect the WinCC Unified trace output (HMIRuntime.Trace) to confirm the filter expression logged matches the expected TagPrefix.
- Close the popup and re-open the M_17 view. Confirm the filter still applies - because the Name property changes again on each open, the Modified event re-fires.
Pass criterion: the alarm control shows only alarms whose SOURCE matches the active TagPrefix, regardless of popup open/close cycles.
10. Troubleshooting Matrix
| Symptom | Likely Root Cause | Diagnostic | Remediation |
|---|---|---|---|
| Alarm popup shows all plant alarms | Modified event never fired | Enable HMIRuntime.Trace; verify Name property changes | Ensure Name dynamization returns a value that differs from default each time |
| Alarm popup shows alarms from neighbor motors | Wildcard prefix too permissive | Inspect MsgFilterSQL in Trace | Tighten the LIKE pattern to prefix.% or use full DB path |
| Alarm popup is empty even though the motor has alarms | PLC alarm source field does not match the TagPrefix | Cross-check HMI alarm configuration SOURCE field with PLC instance DB name | Align naming convention between STEP 7 instance DB names and the HMI message SOURCE field |
| Modified event fires only once across multiple opens | Same TagPrefix passed to Name; identical string does not retrigger | Inspect the concatenated string returned by the dynamization | Append a monotonically changing element (timestamp or GUID) to the Name |
| JavaScript error "Faceplate.Properties.TagPrefix is undefined" | Popup faceplate interface property missing or hidden | Open popup interface definition | Add the String property and re-compile |
| VBScript error "Object variable not set" | MotorAlarmControl not present in the popup screen | Inspect the popup screen layout | Add the WinCC Alarm Control and re-compile |
| Filter applied, then alarm control resets after a few seconds | AlarmControl configured with cyclic SQL filter refresh that overwrites MsgFilterSQL | Inspect the Alarm Control > Properties > Filter configuration | Disable cyclic filter refresh, or set the same expression |
| Alarm popup visible but the alarm view itself is blank | Alarm control's message classes deselected | Inspect Message Selection dialog | Enable MOTOR class, recompile |
11. Practical Notes and Field-Commissioning Caveats
-
Filter syntax differs by runtime. WinCC Unified uses standard SQL syntax with
LIKEand%. WinCC Professional supports a SQL subset; do not assume portability without testing. -
Multi-user ES stations. When several engineers edit the same project, the
AlarmFilterTriggerplaceholder Name must remain unique per project; do not duplicate the object name across popups, because the alarm control references it by name. -
Performance. The Modified event triggers once per popup open. Avoid assigning the dynamization to a frequently updated property such as
Caption; the filter recompute is cheap but the alarm query can be expensive on large plant buffers. -
Audit traceability. Pair the
HMIRuntime.Tracelog with the WinCC Unified audit option so each filter change is recorded with operator ID, timestamp, and TagPrefix. - Tag-prefix uniqueness. The LBP library assumes every motor instance has a unique TagPrefix. If two motors share a prefix, their alarms will be visible in both popups. Verify by inspecting the HMI tag table.
-
Scriptable alternative. If your version of WinCC Unified supports scheduled functions, the Modified-on-Name trick can be replaced by a scheduled function that polls
Faceplate.Properties.TagPrefixand updates the filter every 500 ms. The Modified-on-Name approach is preferred because it is event-driven and lighter on the runtime.
12. Frequently Asked Questions
Where exactly is the alarm-filtering dynamization hidden in the LBP demo project?
It is attached to the Modified event of the Name property of a hidden auxiliary text object inside the popup faceplate, not to the alarm control itself. Inspect the faceplate, locate a hidden text field with a default Name of _UNSET_, and open its Name property events to find the script that calls MsgFilterSQL.
Does WinCC Unified expose an OnOpen event for popup faceplates?
No - WinCC Unified popup faceplates do not provide a dedicated OnOpen event. The LBP project uses the Modified-on-Name trick as the canonical workaround. WinCC Professional / Comfort has a screen-level OnOpen event, but if you want the script inside the faceplate, the same Modified-on-Name pattern applies.
Why does the Modified event stop firing after the first popup open?
The event only fires when the property value transitions to a different string. If the same TagPrefix is reused on a second open, the concatenated Name is identical and the event is suppressed. Append a unique suffix (timestamp, GUID, or an incrementing counter) to the Name string to force the transition.
Can I use the same script to filter multiple alarm classes at once?
Yes. Extend the MsgFilterSQL expression with an OR clause on the CLASS field, for example (AREA = 'MOTOR') AND (CLASS IN ('WARNING','TRIP')) AND (SOURCE LIKE 'prefix.%'). Verify the SQL dialect supported by your runtime before using IN in WinCC Professional panels.
Which Siemens manuals document the Modified event behavior?
The SIMATIC WinCC Unified - Programming and Operating Manual documents the event model for screen objects and properties. The LBP reference demo project entry on Siemens Support (entry 109814706) shows the exact implementation pattern. Cross-check against your installed TIA Portal version because event semantics were extended in V17 and again in V18.