Public Method in ScopeLib hides references to other Panels

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
14 posts • Page 1 of 2
ChristianGoehring
Posts:14
Joined: Fri Feb 24, 2017 9:29 am

Public Method in ScopeLib hides references to other Panels

Post by ChristianGoehring »

Hi!

I have a panel containing several types of reference panels. Within the panels, functions access graphical objects of other reference panels via the nomenclature described in the documentation. The problem is that any function declared as "public" within the ref panel's ScopeLib "hides" these other objects and causes a warning message and I cannot access the shape object:

WCCOAui (1), 2017.11.24 13:17:09.151, CTRL, WARNING, 13/uim,
Module: _QuickTest_
Panel: D:\\Projects\\local\\Playground\\panels\\ref_parent.pnl []
Object: 1 named: "RECT" of type: RECTANGLE
In reference: ref1.pnl Group: 0 named: "ref1"
Script: Initialize
Line: 3, In "setValue()": Object "ref2.RECT" does not exist

If you declare all methods in the ScopeLib as private, the problem dissappears.

You can recreate the problem following these steps:

1. Create a panel "ref1.pnl".
2. Add a rectangle and name it "RECT".
3. Within the rectangle's Initialize script, define the following:

Code: Select all

main()
{
  setValue("ref2.RECT", "backCol", "SiemensPetrol");
}
4. Within the re1.pnl panel's ScopeLib, define something public like the following method:

Code: Select all

public void extra()
{
  DebugTN("I am public");
}
5. Create another panel "ref2.pnl"
6. Similar to the first panel, add a rectangle and name it "RECT".
7. Within this rectangle's "Initialize" script, implement the following:

Code: Select all

main()
{
  setValue("ref1.RECT", "backCol", "SiemensPetrol");
}
8. Create another panel where you include both panels "ref1.pnl" and "ref2.pnl".
9. Launch it in Quicktest and observe the warning message and the fact that only one rectangle changes color.

I am using WinCC OA 3.15 P05

siemens_dva
Posts:11
Joined: Tue May 03, 2016 10:23 am

Re: Public Method in ScopeLib hides references to other Panels

Post by siemens_dva »

Hi!

I have the same problem. When declaring properties and public functions it is not possible anymore to directly invoke the setValue() function on objects inside the reference.
Interestlingly enough, if you put this reference inside another panel and insert this panel next to the original panel it works again.

I'm using WinCC OA 3.15 P06

Greetings
Don von Allwörden

leoknipp
Posts:2928
Joined: Tue Aug 24, 2010 7:28 pm

Re: Public Method in ScopeLib hides references to other Panels

Post by leoknipp »

If a panel is using object oriented scripts/functions you cannot access the objects any more directly by their name. To be able change an object from another script/object you have to define a function which can then be called from outside of the reference.

Best Regards
Leopold Knipp
Senior Support Specialist

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

Re: Public Method in ScopeLib hides references to other Panels

Post by mkoller »

This is by design. The idea behind it is: when you have public functions and therefore make the panel to an object-oriented panel, everything inside this panel is private, therefore should not be accessible from outside, else one could change internals behind the public interface's back.
This is the same as when you create a Ctrl++ class: you can only access the class by its public interface, the rest is private implementation detail.

ChristianGoehring
Posts:14
Joined: Fri Feb 24, 2017 9:29 am

Re: Public Method in ScopeLib hides references to other Panels

Post by ChristianGoehring »

Thank you for the clarification, this makes sense.

siemens_dva
Posts:11
Joined: Tue May 03, 2016 10:23 am

Re: Public Method in ScopeLib hides references to other Panels

Post by siemens_dva »

This functionality makes sense, I still have to points that need to be clarified:

1. Try including the third panel (that contains both references) into another panel as a reference. Suddenly the private shapes become public again.
2. In my case, I try to call setValue in a library function, that is called from within the panel that has scopelib functions. From my understanding if I call functions from within the panel I should be able to access the shapes directly.

Greetings
Don von Allwörden

leoknipp
Posts:2928
Joined: Tue Aug 24, 2010 7:28 pm

Re: Public Method in ScopeLib hides references to other Panels

Post by leoknipp »

When using reference in reference the check for the access of shapes in object oriented panels will be improved in the future. Our developement department has scheduled some tasks for this topic for changes in one of the next releases.

If you are using object oriented panels you should always use the functions (you have defined on your own) to access graphical objects.
Then your panels will be compatible to changes in the user interface if the access to shapes in references (even if reference in reference is used) is restricted by changes in the UI.

Best Regards
Leopold Knipp
Senior Support Specialist

siemens_dva
Posts:11
Joined: Tue May 03, 2016 10:23 am

Re: Public Method in ScopeLib hides references to other Panels

Post by siemens_dva »

Not being able to use library functions in object oriented panels would render them essentially useless.
But I think i finally made sense of the library functionality in OO-panels and how to access shapes in them.

The setValue() function can be used in two ways:

1. setValue(shapeName)
2. setValue(moduleName.panelName:refName.shapeName)

Note: If you call a library function from a panel, the function stays inside the panel scope. So using option 1 on shapes directly works just fine. Even in OO-panels.
BUT: If you use option 2 you lose you scope and OA handles this like an external shape access. Which is of course blocked for OO-panels.

So keep in mind: never use module or panel names in the setValue function if you want to stay inside your current panel scope when using libraries!

emaddocks
Posts:83
Joined: Tue Sep 04, 2018 12:50 am

Re: Public Method in ScopeLib hides references to other Panels

Post by emaddocks »

Hi All,

Further to what has been discussed here is it possible to determine through scripting what public functions are available for an embedded panel reference?

What I'm trying to do is only run a given public function if the reference panel has it defined.

Currently I'm getting all shapes off the the parent panel, determining which are reference panels by detecting the 'PANEL_REF' prefix, then running my public function which works but where the reference panel doesn't have the required function I obviously get an error come up in the log saying function not defined.


Cheers
Eric

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

Re: Public Method in ScopeLib hides references to other Panels

Post by mkoller »

There is a ctrl function for this: bool hasMethod(string|shape object[, string methodName])

14 posts • Page 1 of 2