You are on page 1of 29

WinCC Unified – V18

Scripting

Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Table of contents
Index / Agenda

Time Topic Presenter

1 Scripting editor & handling improvements


2 Scripting functionality & Code snippets

Page 2 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Scripting – Cross Reference
SIMATIC WinCC Unified

Screen objects

Alarming

Logging

Global Script context

Scheduled Tasks

Improvement of the cross Reference

Page 3 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Scripting – Global Search in Scripts
SIMATIC WinCC Unified

Search context

Displays the Script Wildcards * and ? can be used


context

Find script code in global scripts and screens via search in project

Page 4 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Scripting
Copy & paste of the import statement together with the screen items

Screen_3 Screen_4

1. Copy & Paste


screen item

2. Import statement in global


definiton area will be
automatically copied

Import statement will be copied automatically by copying a screen item

Page 5 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Scripting
Toggle of Global Definition Area

Hide or unhide
the GDA

Scripting editor is split


in GDA and local script

Have a quick overview of the GDA during the editing of the local scripts without switching the GDA on/off.

Page 6 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Scripting
Global Definition Area – Reference handling of aliases

Alias in GDA

Updated reference
in script

Handle easily the renaming of aliases of the imported modules.


Change the alias in the GDA and all the usages in scripts using the same GDA will be updated.

Page 7 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Scripting
Reference handling of global script functions

Updated reference in
script
Definition of
global script
function Select the global
script function by the
autocompletion

Handle easily the renaming of global script functions of the imported modules.
Change the global function name and all the usages in scripts will be updated.

Page 8 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Script improvements (automatic tag trigger, search, xref,) Local search in global
scripts

List of trigger tags are


filled automatically

XRef for global modules


/ functions

Trigger tags are evaluated automatically

Page 9 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Table of contents
Index / Agenda

Time Topic Presenter

1 Scripting editor & handling improvements


2 Scripting functionality & Code snippets

Page 10 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Change screen by number
SIMATIC WinCC Unified

Use case:
The customer wants to change the screen triggered by a PLC tag which contains the screen
number. The screen number refers to a particular state of the plant.

Tag dynamization New system


of screen window functions

PLC tag triggers the screen change via number

Page 11 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


ChangeScreenByNumber and ChangeScreenAsyncByNumber
SIMATIC WinCC Unified

ChangeScreen(Async)ByNumber function to switch between screens (include the base screen)


using the screen number instead of the screen name

Page 12 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


ChangeScreenByNumber and ChangeScreenAsyncByNumber
SIMATIC WinCC Unified

WARNING: Screen Number must be non-zero and unique

Page 13 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Scripting – New Snippets
SIMATIC WinCC Unified

Also works with deactivated script debugger

Change properties of all items depending on


the object type

Displays all alarm information Get all names of the current screen
in the trace viewer elements. Can be used for mass
operation like change color

Page 14 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Scripting – Object type access
SIMATIC WinCC Unified

Also works with deactivated script debugger

Change properties of all items depending on


the object type

Screen.Items('Circle_1').constructor.name returns the type of the screen object

Page 15 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Unified Comfort Panel (1) PC
Role dependent dynamization

Scripting snippet

(1) Planned with V18 UPD1

Dynamize screen objects depending on the role of the logged in user

Page 16 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Scripting
Code snippet – Change style of many screen items upon authorization in faceplates

E.g. use the


loaded event of
the faceplate
Select the new
snippet

Back color of the faceplate


Use also other items changes to light grey
properties like visibility, if authorization is insufficient
opacity etc.

Use the new code snippet also in faceplates to change the appearance of the screen items to your needs
depending on the authorization of the logged-in user for specific screen items.

Page 17 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Scripting – JavaScript Command ListFiles
SIMATIC WinCC Unified

list recursive
files and
folders
filter

New Script function “HMIRuntime.FileSystem.Browse” lists folders and files in a specific directory

Page 18 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Tag Subscription in WinCC Unified Runtime per Scripting
SIMATIC WinCC Unified

Subscribe to multiple
tags

Snippet available

Dynamically subscribe to tags

Page 19 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Change Offset of RootWindow
SIMATIC WinCC Unified

Access to RootWindow left and top properties


via script

Display a side or top popup without


overlapping elements on the screen

Possibility to change Left and


Top offset of root window

Root window will be moved according to offset

Show a popup without overlapping screen content

Page 20 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Change Offset of RootWindow
SIMATIC WinCC Unified
Initial screen in Runtime Screen with opened popup

Popup is opened at 0,0 and


Open a side popup on
screen is moved to the
position 0,0 and set
right by configured amount
UI.RootWindow.Left
of pixels
property accordingly

Show a popup without overlapping screen content


when scrolling the screen the popup stays consistent at its position
Page 21 Unrestricted | © Siemens 2022 | DI FA S SUP HMI
Scripting
Live Demo

LIVE DEMO

• HMIRuntime.FileSystem.Browse

Page 22 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Scripting
Live Demo

H A N D S O N in 10 min

• HMIRuntime.FileSystem.Browse

Page 23 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Hands On: Scripting
SIMATIC WinCC Unified

H A N D S O N in 10 min
• Change the style of the “start button” upon
authorization in the faceplate in faceplate created at
the hands-on

Page 24 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Scripting
Live Demo

LIVE DEMO

• Get Roles from the User and display them in a text


list
• Get Roles from the user and lock buttons regarding
to which user has logged in

Page 25 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Scripting
Live Demo

H A N D S O N in 15 min

• Get Roles from the User and display them in a text


list
• Get Roles from the user and lock buttons regarding
to which user has logged in

Page 26 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Open Source Software License Information

The products shown in this presentation include:


• Software developed by the University of California, Berkeley and its contributors.
• Software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)
• Cryptographic software written by Eric Young (eay@cryptsoft.com)
• Portions were derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm

Page 27 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Disclaimer

© Siemens 2022

Subject to changes and errors. The information given in this document


only contains general descriptions and/or performance features which
may not always specifically reflect those described, or which may
undergo modification in the course of further development of the
products. The requested performance features are binding only when
they are expressly agreed upon in the concluded contract.

All product designations may be trademarks or other rights of


Siemens AG, its affiliated companies or other companies whose use by
third parties for their own purposes could violate the rights of the
respective owner.

Page 28 Unrestricted | © Siemens 2022 | DI FA S SUP HMI


Thank you for your attention!
Siemens AG
DI FA S SUP HMI
Gleiwitzer Str. 555
90475 Nuremberg, Germany

Unrestricted | © Siemens 2022 | DI FA S SUP HMI

You might also like