plc.myforum.ro Forum Index plc.myforum.ro
PLCs users www.plc.myforum.ro!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How can you display/hide a layer in a screen depending on a

 
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> SIEMENS SIMATIC HMI
View previous topic :: View next topic  
Author Message
maersk
Member 3
Member 3
maersk

Joined: 17 Aug 2014
Posts: 891

PostPosted: 05/06/2015 18:20    Post subject: How can you display/hide a layer in a screen depending on a Reply with quote

How can you display/hide a layer in a screen depending on a tag?

You can use the VBS script below, in which you only have to change the screen name, the layer, the tag and its value (for example, in a global VBS script or in a VBS action of an event of a button etc.).

This script functions only if the relevant screen is also open.
Code:
Dim Tag
Dim scrObj

Set scrObj = HMIRuntime.Screens("@Screen.@win12:@1001.@Desk:screen_name")
Set Tag = HMIRuntime.Tags("Tag")

Tag.Read

If Tag.Value = 0 Then
scrObj.Layers(screen_layer).Visible = False
Else
scrObj.Layers(screen_layer).Visible = True
End If


Note (taken from the WinCC Online Help)
Upon access, the layers are counted in VBS starting with 1. Thus layer "0" in the WinCC Graphics Designer must be addressed with layers(1).

For example, if you want to address screen layer 10 in a screen, you must enter 11 for
Code:
 scrObj.Layers(...).Visible.


If you have opened a screen on anther monitor, you must address it accordingly, "@Screen.@win22:@1001.@Desk:screen_name", for example.

What should I watch out for with actions when using a Multi VGA card?
One problem with actions is that when using a function (e.g. SetBackColor) only the picture name (lpszPictureName) and the object name (lpszObjectName) are specified. Thus, if you are using numeroase screens, there is no unambiguous assignment of the function and therefore the picture to a specific monitor screen.
Code:
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
SetBackColor("system.pdl","storage_tank",CO_RED); // background color
}

Now, if you want the action to be executed on all the screens, you must enter the following C action:

Code:
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
SetBackColor("@SCREEN.@WIN12:@1001.@DESK:system.pdl","storage_tank",CO_RED); // background color
SetBackColor("@SCREEN.@WIN22:@1001.@DESK: system.pdl","storage_tank",CO_RED); // background color
}


By entering the two lines (for 2 screens) you ensure that the function SetBackColor is executed on both screens. @WIN12 stands for Monitor1 and @WIN22 stands for Monitor2.
In this way the image "system.pdl" and thus the function is assigned to a specific monitor.

If you want to use more than two screens in WinCC Runtime and want to have the same pictures open on two screens, it might happen that C actions that you trigger, e.g. by mouse click, on one screen are executed on the other screen.

If, for example, you execute the C function SetVisible and transfer the picture name absolutely (e.g. "Picture1.PDL",...), the function will always refer to the picture that was opened first in the case of multiple screens. If you wish to address the current picture, then you must use the pointer on the current picture:
Code:

SetVisible(IpszPictureName,...);

If you wish to close a picture window yourself by pressing an Exit button in the picture, then you must program the following C action:
Code:

SetVisible(GetParentPicture(IpszPictureName), "picture_window_xyz", 0);


You will find the GetParentPicture function under STANDARD functions\GRAPHICS\GetParentPicture in the GlobalScript.
Back to top
View user's profile Send private message
tecnoplc
Junior 2
Junior 2


Joined: 03 Feb 2016
Posts: 40
Location: Spain

PostPosted: 09/02/2016 07:35    Post subject: Reply with quote

Hi: Good information. And is this available in the WinCC Flexible ScriptS??? Could I use this same functions? Or are this only available in the WICC Scada??
Thank you...
_________________
_______________________________________
Programming PLC and HMI
www.tecnoplc.com
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> SIEMENS SIMATIC HMI All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro