The UI has to find the correct shape everytime when the function is called. Finding the correct shape might take some time, especially when there are a lot of objects in the panel.
The performance can be increased by using the getShape() function in the script where the object attributes are set/read. The function to find the correct shape is called only once. Afterwards the result of the getShape() function is used which leads to a better performance and decreased CPU usage.
There is no need to modify all scriipts in your panels. It can be used in objects with scripts that are called very often. A common use case are objects displaying values updated in a short interval (e.g. a measured value from the PLC with 1 value change / second).
script without getShape()
=============
Code: Select all
main()
{
s_dp = $dpe + ".in.value";
if (dpExists(s_dp))
dpConnect("show_value", 1, s_dp);
}
show_value(string s_dp, float f_val)
{
// everytime when when the work function is called and the attribute is set the correct shape must be identified
setValue("value", "text", f_val);
}script with getShape()
=============
Code: Select all
shape s_shape;
main()
{
// the shape information is read when the script is started
s_shape = getShape("value");
s_dp = $dpe + ".in.value";
if (dpExists(s_dp))
dpConnect("show_value", 1, s_dp);
}
show_value(string s_dp, float f_val)
{
// the shape information is used when the attribute is set
setValue(s_shape, "text", f_val);
}Best Regards
Leopold Knipp
Senior Support Specialist