Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

(http://www.siemens.

com)
Industry Online Support
Product Support

 Home (start)
 Product Support
 ...
 ...
 Automation software
 TIA Portal
 Visualization
 SIMATIC WinCC Unified (TIA Portal)

Entry type:
FAQ
Entry ID:
109810540,
Entry date:
07/11/2022





)1(
 Rate

How do you control pop-up windows in WinCC Unified PC RT and Comfort Panels via
script (JavaScript examples)?
Entry
Associated product(s)

With the help of JavaScript, numerous properties of pop-ups can be adapted to the specific Runtime requirements in WinCC Unified. All
functions presented in the following use the UI.PopupScreenWindows object (UI object). This object contains all open pop-up instances of
faceplates or screen windows.
1. Prevent a pop-up from opening multiple times (#chapter_5605916_0)
  1.1 List open pop-up windows (#chapter_5605916_1)
  1.2 Access the instance of a pop-up via its title  (#chapter_5605916_2)
  1.3 Close all open pop-up windows simultaneously (#chapter_5605916_3)
2. Properties of Pop-up Windows (#chapter_5605916_4)
  2.1 Change the properties of the open pop-ups (#chapter_5605916_5)
  2.2 Overview: Properties and methods of pop-up windows (#chapter_5605916_6)
3. Implement an operation lock when the pop-up is open (#chapter_5605916_7)

Description

To script pop-ups that are active in Runtime, list their open instances using the "PopUpScreenWindows" subobject of the UI object. In the following you will also find script examples based on this, with the help of which you can program the following functions:

Prevent a pop-up from opening multiple times

Read out the system name of an open pop-up


Close all open pop-up windows simultaneously
Change the properties of the open pop-ups
Implement an operation lock when the pop-up is open

Here you can download the associated sample project with all the functions described in the following:

      109810540_WinCC_Unfied_Popups.zip (8.0 MB) (/cs/attachments/109810540/109810540_WinCC_Unfied_Popups.zip) (SHA-256)

Here you will find further information in the manuals:

SIMATIC HMI WinCC Unified Runtime 


 Pop-up Window (https://support.industry.siemens.com/cs/de/en/view/109803796/126166836363)
SIMATIC HMI WinCC Unified Engineering V17 
 Configure faceplate as pop-up (https://support.industry.siemens.com/cs/ww/en/view/109794204/136045517323)
 OpenScreenInPopup (https://support.industry.siemens.com/cs/ww/en/view/109794204/130553805451)

Script functions

© Siemens AG 2009-2022 - Imprint (http://www.siemens.com/corporate_info) Privacy policy (http://www.siemens.com/privacy) Cookie policy (http://www.siemens.com/cookie-policy-en) Terms of use (http://www.siemens.com/terms_of_use)
Digital ID (http://www.siemens.com/digital_id_en) 0.0.0.0
1. Prevent a pop-up from opening multiple times
  1.1 List open pop-up windows

Application case

With WinCC Unified you can configure several pop-up windows in one screen.

In Runtime, in principle, several instances of one and the same pop-up can be opened.

If you do not want this behavior, you can prevent it as described in the following example.

Description of the script

Notes
The instances of all opened pop-ups are contained in the UI object together with their properties, as already described at the beginning.
In the WinCC Unified property "Name", the instances of pop-ups contain a name generated dynamically by the system at Runtime.
The value of a pop-up instance located in the "Name" property is clearly different from its title ( see Fig. 03).

The following function counts the open pop-ups in a loop and queries which pop-ups are currently open in Runtime.
One after the other, it compares the title of a pop-up to be opened (in the example "Popup_1") with the titles of the pop-ups that are already open.
This way, it checks whether a pop-up has been opened before.

If this is not the case, it opens the pop-up at the defined position with "Visible".
To be able to access the instance of the pop-up at a later time, the name of the pop-up is stored in a tag.  

In the example shown in Fig. 01,the functionis assigned to the "Release" event of the corresponding "Open PopUp"button. 

© Siemens AG 2009-2022 - Imprint (http://www.siemens.com/corporate_info) Privacy policy (http://www.siemens.com/privacy) Cookie policy (http://www.siemens.com/cookie-policy-en) Terms of use (http://www.siemens.com/terms_of_use)
Digital ID (http://www.siemens.com/digital_id_en) 0.0.0.0

Fig. 01

Example of a script for the "Open PopUp" button:

© Siemens AG 2009-2022 - Imprint (http://www.siemens.com/corporate_info) Privacy policy (http://www.siemens.com/privacy) Cookie policy (http://www.siemens.com/cookie-policy-en) Terms of use (http://www.siemens.com/terms_of_use)
Digital ID (http://www.siemens.com/digital_id_en)
03  let title = "Chosen_popup_title";                                                    // 0.0.0.0
title name for search whether pop-up exist

04

05  let ui = UI;                                                                                            // get the ui object

06  let count = ui.PopupScreenWindows.Count;                                  // count all existing pop-up windows

07  let popup_exist = false;

08  

09  for (let i = 0; i < count; i++) {                                                              // loop through all existing pop-ups
10        let popup_title = ui.PopupScreenWindows(i).Caption.Text;

11        if (popup_title == title) {                                                                // compare title

12           popup_exist = true;

13        }

14   }

15

16   if (popup_exist == false) {                                                                  // if popup with specific title wasn't found, create

17        let data = {PopupInterfaceTagName:{Tag:"TaglistTagName"}};

18        let po = UI.OpenFaceplateInPopup("Faceplate_1_V_0_0_1", title, data);

19        po.Left = 200;

20        po.Top = 200;

21        po.Visible = true;

22

23        Tags("Popup_Name_1").Write(po.Name);                                   // save system name of the pop-up instance in a tag

24   }

  1.2 Access the instance of a pop-up via its title 

Application case

You want to read the system name assigned at Runtime of an open pop-up window. In the example, the
ScreenWindowName ( Fig. 02) of an instance of "Faceplate_1_V_0_0_1" (Fig. 01) is read:

© Siemens AG 2009-2022 - Imprint (http://www.siemens.com/corporate_info) Privacy policy (http://www.siemens.com/privacy) Cookie policy (http://www.siemens.com/cookie-policy-en) Terms of use (http://www.siemens.com/terms_of_use)
Digital ID (http://www.siemens.com/digital_id_en) 0.0.0.0

Fig. 02

Description of the script

Like the script in Fig. 01, this uses an instance of the UI object to compare all pop-ups listed there with the previously defined title. If the searched pop-up is found, the system name of the pop-up instance is passed to the "value" tag and returned as a
process value.

The script in Fig. 03 is stored directly in the "Process value" property of the corresponding IO field.

© Siemens AG 2009-2022 - Imprint (http://www.siemens.com/corporate_info) Privacy policy (http://www.siemens.com/privacy) Cookie policy (http://www.siemens.com/cookie-policy-en) Terms of use (http://www.siemens.com/terms_of_use)
Digital ID (http://www.siemens.com/digital_id_en) 0.0.0.0

Fig. 03

Behavior in Runtime

Figure 04 shows as soon as you press and release a button, for example "Open PopUp 1", the script in Fig. 02 updates the process value linked there after the specified cycle with the current system nameof the open pop-up instance (in the example
"FaceplatePopupWindow_51"). When you close PopUp 1, the script does not find a corresponding faceplate/pop-up instance and indicates that this pop-up is closed ("Open PopUp 2").

© Siemens AG 2009-2022 - Imprint (http://www.siemens.com/corporate_info) Privacy policy (http://www.siemens.com/privacy) Cookie policy (http://www.siemens.com/cookie-policy-en) Terms of use (http://www.siemens.com/terms_of_use)
Digital ID (http://www.siemens.com/digital_id_en) 0.0.0.0

Fig. 04

  1.3 Close all open pop-up windows simultaneously


To allow all pop-ups to be closed at once, the script in Fig. 05 counts all listed pop-ups and closes them
in a loop.

Here you have to start with the highest index number, because with every "close" the still open windows are renumbered. The Count PopUps field in Fig. 06 shows the number of pop-ups currently open.

The function in Fig. 05 is stored in the "Release" event of the "Close all" button.

Fig. 05

2. Properties of Pop-up Windows


  2.1 Change the properties of the open pop-ups
© Siemens
The script AG 2009-2022
in Fig. 06 shows Imprint
- how you(http://www.siemens.com/corporate_info) Privacy
can change the CaptionColor property of policy
all open (http://www.siemens.com/privacy)
pop-ups at the same time.  Cookie policy (http://www.siemens.com/cookie-policy-en) Terms of use (http://www.siemens.com/terms_of_use)
All active pop-ups are listed Digital
via an ID
instance of the UI object. A loop is then0.0.0.0
(http://www.siemens.com/digital_id_en) used to access the desired property of the pop-ups via the individual list elements.

Fig. 07 shows how the script changes the color of the title bar in Runtime at the push of a button.

The function is stored in the "Release" event of the "Change Caption Color..." button.

Fig. 06

Sample script for the "Change Caption Color..." button:

03    let ui = UI;

04    let count = ui.PopupScreenWindows.Count;

 
05    let color = HMIRuntime.Math.RGB(233,200,150)

06

07    for (let i = 0; i < count; i++) {

08        ui.PopupScreenWindows(i).CaptionColor = color;

09    }

© Siemens AG 2009-2022 - Imprint (http://www.siemens.com/corporate_info) Privacy policy (http://www.siemens.com/privacy) Cookie policy (http://www.siemens.com/cookie-policy-en) Terms of use (http://www.siemens.com/terms_of_use)
Digital ID (http://www.siemens.com/digital_id_en) 0.0.0.0

Fig. 07

  2.2 Overview: Properties and methods of pop-up windows

© Siemens AG 2009-2022 - Imprint (http://www.siemens.com/corporate_info) Privacy policy (http://www.siemens.com/privacy) Cookie policy (http://www.siemens.com/cookie-policy-en) Terms of use (http://www.siemens.com/terms_of_use)
Use the debugger to get a complete
Digital ID overview of the properties and methods
(http://www.siemens.com/digital_id_en) of a pop-up.
0.0.0.0

Fig. 08 shows an example of various properties of a pop-up window using the debugger:

Fig. 08

Further information about this is available in the entry entitled 

 How do you use the Script Debugger with WinCC Unified and the Chrome browser? (/cs/document/109779192/how-do-i-use-the-script-debugger-with-wincc-unified-and-the-chrome-browser-?lc=en-ww)

© Siemens AG 2009-2022 - Imprint (http://www.siemens.com/corporate_info) Privacy policy (http://www.siemens.com/privacy) Cookie policy (http://www.siemens.com/cookie-policy-en) Terms of use (http://www.siemens.com/terms_of_use)
3. Implement an operation lock Digital
whenIDthe pop-up is open

(http://www.siemens.com/digital_id_en) 0.0.0.0

You want to block the operation of UI elements as long as pop-ups are open.

The script in Fig. 09 implements an operation lock on the button "Show/Hide Circle" as long as pop-up windows are open in Runtime.

To start with, the opened pop-ups are counted.

If the number of opened pop-ups is 0, the button operation is allowed. Otherwise, operation is locked.

The script is implemented in the "Allow operator control" property of the button mentioned above.

Fig. 09

Additional Keywords

Independent screen windows, Behavior, Handling, Useful, Code examples

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to
implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions
constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration. (https://www.siemens.com/cybersecurity#Ouraspiration)
© Siemens AG 2009-2022 - Imprint (http://www.siemens.com/corporate_info) Privacy policy (http://www.siemens.com/privacy) Cookie policy (http://www.siemens.com/cookie-policy-en) Terms of use (http://www.siemens.com/terms_of_use)
Also available in the followingDigital
languages:
ID (http://www.siemens.com/digital_id_en) 0.0.0.0
 German
 Spanish

Entry belongs to product tree folder(s):


 Automation Technology
 Operator control and monitoring systems
 Operator devices
 Advanced HMI Panel-based
 Unified Comfort
Panels
 Unified Comfort Panels Standard
(products?pnid=26033)
 Automation Technology
 Industry software
 Automation software
 TIA Portal
 Visualization
 SIMATIC WinCC Unified (TIA Portal)
(products?pnid=26034)
 Automation Technology
 Industry software
 Automation software
 TIA Portal
 Visualization
 SIMATIC WinCC Unified (TIA Portal)
 SIMATIC WinCC Unified Engineering
(products?pnid=26035)
 Automation Technology
 Industry software
 Automation software
 TIA Portal
 Visualization
 SIMATIC WinCC Unified (TIA Portal)
 SIMATIC WinCC Unified Runtime
(products?pnid=26036)

Rate entry





no rating Submit rating

Requests and feedback

What do you want to do?

You have a technical question / problem: Ask the Technical Support


 Create support request

You want to discuss in our forum and exchange experiences with other users
 Go to the Forum (/forum/ww/en)

You want to create CAx data for one or more products


 Go to the CAx download manager

You would like to send us feedback on this Entry


 Provide feedback

Note: The feedback always relates to the current entry / product. Your message will be forwarded to our technical editors working in the Online Support. In a few days, you will receive a response if your feedback requires one. If we
have no further questions, you will not hear from us.

© Siemens AG 2009-2022 - Imprint (http://www.siemens.com/corporate_info) Privacy policy (http://www.siemens.com/privacy) Cookie policy (http://www.siemens.com/cookie-policy-en) Terms of use (http://www.siemens.com/terms_of_use)

You might also like