Troubleshooting
Why a WinCC connection alarm cannot hand its text to a script
Short answer
WinCC Advanced V13 has no documented VBScript interface that hands the resolved text of system event 220006 to a script, and that event reports a restored connection, not a lost one. GMsgFunction, the Horn tag and the AlgView database belong to other editions. Keep system events for the operator, identify the failed Modbus RTU slave from per-device status tags, and trigger the script from those.
On this page
The event exists; the text never reaches your code. In WinCC Advanced V13, SystemEvent_220006 displays as Connection to PLC %1 (%2) is established, and this runtime documents no VBScript interface that returns the resolved string — %1 already substituted — to a script. Two facts settle the design: the event is the recovery half of a connection transition, not the failure half, and every proposed text channel (the C-side GMsgFunction, the Horn's internal tag, the @DataSourceNameRT/AMT/AlgView database) belongs to a different WinCC edition. Keep system events for the operator, trigger the script from per-device status tags, and prove what %1 resolves to before you treat it as a slave address.
The event reports recovery, not loss #
A system event reports system status, including errors in the communication between the HMI device and the connected system, and the set of events depends on the HMI device — Siemens documents them for Advanced V13.0 SP1 in support entry 109091876. SystemEvent_220006 sits on the established side of the transition: it fires when the link comes back, not when it drops. A script that raises a "slave lost" flag from this event inverts the indication — recovery clears a fault, it does not create one.
If the action must handle the failure, capture the loss-side event of the same transition. At each step of a controlled pull test, record:
- the event number as displayed
- the full resolved text, exactly as shown
- the timestamp of the transition
Repeat for the pull and for the restore, one device at a time. Do not lift the whole serial trunk to test: several slaves failing together blur which message belongs to which endpoint — and whichever device you disconnect is unmonitored for the duration, so run the test with operations aware.
A trigger is not a payload #
An event trigger starts an action; the payload is the substituted text of that occurrence. They are separate objects, and configuring one does not hand you the other. A VBScript that fires when the Horn tag changes receives the tag's value, not the message that caused the change.
For this runtime family, the published scripting examples cover configuring the alarm view on RT Professional — none shows a call that returns a system event's resolved text to Advanced V13 code. Treat the payload as unreachable: build the script on data you can read by name, and check the installed help of your exact version only to confirm nothing new appeared. Reading the displayed alarm row after a generic trigger is a race — another event can arrive, the view can be filtered, the selection can move — so the alarm display is not a data channel.
Why each proposed route fails on this runtime #
| Proposed route | What it actually is | Decision |
|---|---|---|
| GMsgFunction with the Alarm Logging "triggers an action" flag | A C-function mechanism from classic alarm logging; Advanced V13 scripts in VBScript only, and C scripting belongs to the Professional edition | It never loads here — drop it |
| Horn filtered by Message Class and Event, tied to an internal tag | A Boolean: occurrence without identity | Keep it as a lamp or a horn |
| SQL query against @DataSourceNameRT, the AMT table and the AlgView views | The alarm-segment structure of WinCC 7 | Do not port it to Advanced V13 |
| Per-device status as process data | The component that talks to each slave reports it directly | The resolving branch |
The database route deserves its own sentence, because the steps sound complete: create a SQL user, read the database name from @DataSourceNameRT, list the segments in AMT, read the message fields from the AlgView views. That is a WinCC 7 alarm-logging walkthrough. Advanced V13 does not document that structure, so porting it assumes an architecture the runtime does not have.
What %1 resolves to, and how to pin it #
The runtime fills %1 and %2 with connection-specific values at display time. In the installation that raised the question, %1 reads as the number of the slave whose link changed. That mapping lives in the connection configuration, not in the event, so prove it on your line with the pull test above and write the result into the project documentation.
What the identity means depends on the topology:
| Topology | What the connection event tells you | Where device identity comes from |
|---|---|---|
| One HMI connection per RTU device | One connection, one candidate device | Verified mapping of the resolved %1 to the address |
| One connection to a controller or gateway serving several slaves | Upstream path status only | Per-device status read from that gateway |
| %1 matches a connection name, not an address | An identifier that must be translated | A project-level name-to-address table |
Worked example: naming the failed slave on a four-slave RTU line #
Inputs:
- Runtime: WinCC Advanced V13, VBScript only — the system from the question.
- Event under test: SystemEvent_220006, text Connection to PLC %1 (%2) is established, as observed in the project.
- Line: four Modbus RTU slaves at addresses 1, 2, 3 and 4, each with its own HMI connection — example inputs for a typical line; substitute your own count.
- Retry behavior: the runtime re-attempts a failed connection every 30 s, documented in the RT Advanced communication notes.
Rule in words: one Boolean carries 2 states. It can say that some connection changed, but it cannot select one identity out of N. N independent per-device Booleans carry 2^N states.
Arithmetic:
- One Horn Boolean: 2^1 = 2 states. Two slaves already need the set {none, slave 1, slave 2, both} = 4 states; 2 < 4. Four slaves need 16.
- A shared tag also stops triggering on overlap: the first failure holds it at 1, and a second failure produces no new edge.
- Per device: 4 tags give 2^4 = 16 combinations, so every overlap — including all four down — has its own state.
- Timing: restore the cable at t = 60 s. With a 30 s retry cycle, SystemEvent_220006 lands between 60 s and 90 s, up to 30 s after the physical restoration.
Decision: one Boolean per line is enough only when exactly one device sits behind it. At two or more slaves, run one status tag per device and let the script read that set by name.
Running the script from status tags #
Build the resolving branch like this:
- One status tag per slave — a Boolean communication flag or a heartbeat value that must keep changing.
- The writer is whatever actually talks to that slave: the HMI connection where each device has its own, or the PLC or gateway in front of the slaves where one connection serves several.
- The script fires on the tag's change event, reads the tag set by name, and selects the action for the failed address from the verified name-to-address table.
- System events stay enabled for the operator in parallel — they are the diagnostic record the status tags are not, and why extending HMI system event display time reveals comms faults shows how much of the story their display time controls.
If the goal later shifts from scripting to a cleaner operator view of link faults, how to show only a PLC connection alarm in WinCC Flexible covers the filtering pattern in the Flexible toolset.
Questions asked
Does SystemEvent_220006 mean a slave lost communication?
No. 220006 is the established side — it fires when the link returns. The loss half of the same transition is a different event with its own number; find yours by recording the event numbers during a controlled pull and restore of one device, then wire the failure action to the loss-side number.
How late can the established event arrive after the cable is repaired?
Up to one retry cycle. The runtime re-attempts a failed connection every 30 s, so a cable restored at any moment t produces SystemEvent_220006 between t and t + 30 s. Set the operator's expectation to that window when the message is used as restoration confirmation.
Why was the SQL database query suggested if it cannot work here?
Because it is a real technique — for WinCC 7. The steps name that edition's alarm-logging structure: @DataSourceNameRT for the database, AMT for the segment list, AlgView for the message fields. Advanced V13 does not document those objects, so the first check is simply which runtime you are on, and on Advanced the design stays with status tags.
Can the Horn internal tag carry the slave number instead of just on/off?
No. The tag holds an active or inactive state for the filtered message class — one Boolean, two states. Selecting among four slaves needs sixteen combinations, and once the tag sits active, a second failed slave gives it no new edge to trigger on. Use it for a lamp or a horn.
How do I confirm that %1 equals the slave address on my line?
Disconnect one slave at a time, with operations informed since that device is unmonitored meanwhile, and record the resolved %1 for both the loss event and SystemEvent_220006. Repeat per device and keep the result as a name-to-address table; where %1 matches a connection name rather than an address, translate through that table.