How to reference a Complex Graphical Object from a different Panel

Find and share HowTos to various installations / configurations!
7 posts • Page 1 of 1
vince2e
Posts:39
Joined: Tue Aug 02, 2016 4:19 pm

How to reference a Complex Graphical Object from a different Panel

Post by vince2e »

Hello all,

I am having trouble referencing a complex graphical object (Bar Trend) from a child panel. I have a button ('Clear Data') on my parent panel that opens up a child panel (Clear_Data.pnl). The chid panel asks the user if they are sure they want to clear the data and then the user will select the 'Ok' or 'Cancel' buttons on the child panel. If Ok is selected than the function defined in the library is called.

The problem is when the 'Ok' button is pressed I receive the following error:


WCCOAui (1), 2016.09.05 08:55:50.330, CTRL, WARNING, 13/uim,
Module: Vision_2
Panel: C:\\Siemens\\Automation\\WinCC_OA\\3.14\\Gill_Corp\\panels\\objects\\Clear_Data.pnl []
Object: 13 named: "PUSH_BUTTON1" of type: PUSH_BUTTON
Script: Clicked
Library: C:\\Siemens\\Automation\\WinCC_OA\\3.14\\Gill_Corp\\scripts\\libs\\LIB.ctl
Line: 573, In "getShape()": Object "BAR_TREND3" does not exist


I believe the object can't be located from the child panel so I would have to reference it, which I think is done by $ parameters, but I'm not sure how to set an object to a dollar parameter.

fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

Re: How to reference a Complex Graphical Object from a different Panel

Post by fmulder »

Your approach is wrong. There are various ChildPanel... functions with the postfix 'Return'. Example: ChildPanelOnCentralReturn(). These panels will typically present some choices to the user (example: an 'Yes' or a 'No' button). When they click the 'Yes' button then you do PanelOffReturn( makeDynFloat(), makeDynString( "yes" ))

The calling function receives the answer.When the dyn_string contains the value "yes" then you modify your bar.

Please look in the help file for 'ChildPanelOnCentralReturn'

So the normal procedure is:
1) You have a panel with a bar
2) The panel opens a child via ChildpanelOnCentralReturn
3) A popup shows. The user makes a choice
4) The popup returns his value via PanelOffreturn( dyn_float, dyn_string )
5) Your panel that opened up the popup receives the answer and acts accordingly

good luck

Frenk
Share the fun !

mkoller
Posts:741
Joined: Fri Sep 17, 2010 9:03 am

Re: How to reference a Complex Graphical Object from a different Panel

Post by mkoller »

Altough Frenk is right, there might be the wish to have a non modal dialog (child panel) which does more things to the root panel and therefore should be able to directly interact with it without being closed.
That is also possible.
To address a shape in another module and panel, just use the following extended addressing schema in setValue()/getValue():
"moduleName.panelName:shapeName"
instead of just "shapeName".

"moduleName.panelName:" both must be given

vince2e
Posts:39
Joined: Tue Aug 02, 2016 4:19 pm

Re: How to reference a Complex Graphical Object from a different Panel

Post by vince2e »

Thanks guys,

I would like to use getValue();

But I'm having trouble determining what "moduleName" is. I have made several attempts to define "moduleName" and all of them continue to give me the same error.

RudiKreiner
Posts:198
Joined: Mon May 16, 2011 2:10 pm

Re: How to reference a Complex Graphical Object from a different Panel

Post by RudiKreiner »

Using the function myModuleName() should work.
If not then put
DebugN(myModuleName());
into the init script of the panel that you want to manipulate, then you should get the name output to the log viewer when you open that panel.
That would be my pragmatic approach ;)

vince2e
Posts:39
Joined: Tue Aug 02, 2016 4:19 pm

Re: How to reference a Complex Graphical Object from a different Panel

Post by vince2e »

Thanks Rudi,

I've tried that approach and DebugN(myModuleName()); returns either "_QuickTest_" or "objects//" depending on where I place the function. I've tried to input both of those and the same error pops up.

I've also tried

//FROM Help Pages - Access shapes in other panels and modules
main()
{
setValue( myModuleName() + "." + myPanelName() + ":PANEL_REF1.DPname", "text", myDPE);
}

but I keep getting the same error. :unsure:

fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

Re: How to reference a Complex Graphical Object from a different Panel

Post by fmulder »

You have to use the modulename and the panelname of the panel where you want to adddress the shape. So in your case : you need myModuleName() and myPanelName() on the panel that opened the popup. There are two scenarios:

1) You know the module and the panelname. When you build your own basepanel or you use a standard panel, then the modulename and the name of the panel that you(!) open is probably fixed
2) You want it to be more dynamic (for example: you open a popup panel and give the name of a datapoint)

What you can do is pass the modulename and the panelname of the parent to your popup via a dollar code:

Code: Select all

ChildPanelOnCentral( "yourpanel.pnl", "Name of your popup", makeDynString( "$PARENTMODULE:" + myModuleName(), "$PARENTPANELNAME:" + myPanelName() );
Now, when the child wants to change a field in its parent panel then you do:

Code: Select all

setValue( $PARENTMODULE + "." + $PARENTPANELNAME + ":" + "NameOfShape", "text", "Just a test. Share the fun" );
Hope that this helps

Share the fun
Frenk Mulder

7 posts • Page 1 of 1