A small piece of software that runs as a windows service that executes an OpenPipe script (SendEmailScript.js) that subscribe to some variables in the locally running WinCC Unified PC RT application.
I based my script on the example provided in DVD2 of the TIA Portal V20 installation, with the OpenPipe SDK Comfort API SendEmailSampleViaComfortLayer.js and adapted the Tags it subscribes to, to fit my example.
I also provide in this example how we can leverage the npm module node-windows to run a JavaScript file "as a service" in a Windows environment.
graph LR
A["Unified Email<br>Listener Service"] --> B[OpenPipe script<br>SendEmailScript.js]
B --> C((Unified<br>PC RT))
C --> B
- Download the file package
Unified-EmailListenerService.zipfrom this repository. - Unzip the files to any location on the WinCC Unified PC RT station.
- Run the
install.batfile to install the service. - Run Windows
services.mscand search for the UnifiedEmailListener service.- Access the Recovery tab in the service properties.
- Set the first, second, and subsequent failures values to Restart the Service.
- Set the value of Restart service after to 0 minutes.
- Click Apply.
- Access the General tab in the service properties.
- Make sure the service Startup type is set to Automatic.
- Start the service.
- Click OK.
- Run the
uninstall.batfile to install the service. *Will delete the service even if it's currently running.
- Download the file
Unified-EmailListenerLibrary.zal20from this repository and open it in the Global libraries (compressed) area of TIA Portal.
- UDT types:
udtSmtpthat contains the elements for the SMTP configuration.udtEmailthat contains the email parameters (to, from, subject, and content), as well as the trigger bit.
- Master copies that contain:
- Example tag table
emailthat contains two tags with the UDTs. - Example of usage (
BasicExample&AlarmToEmailExample).
- Example tag table
- Simply create two internal tags named:
_SMTP_of datatype UdtSmtp._EMAIL_of datatype UdtEmail.
If you link directly the _EMAIL.trigger to a PLC variable, this tag will be refresh X amount of time in the OpenPipe code, because of acquisition mechanism. This means that the email trigger will be read multiple time and that will send multiple emails.
To achieve it from the PLC, you must create a structure/udt in the PLC and map it to the internal _EMAIL.x, using scheduled tasks.
- Bring the PLC tag to Unified HMI tags:

- Create a scheduled task on PLC trigger, that check from PLC.trigger being 'true' and mapping the email elements to the internal variables
_EMAIL_.x:

- Create another scheduled task, to reset the PLC trigger variable, upon the internal trigger being false:

This has only be tested with WinCC Unified PC RT V20 and PLC S7-1511 fw 2.9.
The examples are non-committal and do not lay any claim to completeness with regard to configuration and equipment as well as any eventualities. The examples do not represent any custom-designed solutions but shall offer only support at typical tasks. You are accountable for the proper mode of the described products yourself.
These examples do not discharge you from the obligation to safe dealing for application, installation, business and maintenance. By use of these examples, you appreciate that Siemens cannot be made liable for possible damages beyond the provisions regarding described above. We reserve us the right to carry out changes at these examples without announcement at any time. The contents of the other documentation have priority at deviations between the suggestions in these examples and other Siemens publications, such as catalogues and manuals.
Use at your own risk.


