Hi,
I wanted to understand what does Dollar parameter does???? I went through the help but its still not clear to me. Can someone please help me with that.
We also have function called isDollarDefined();
Thank You.
Dollar Parameter
- jmad
- Posts:14
- Joined: Fri Sep 29, 2017 8:37 am
Re: Dollar Parameter
Hi,
$-Parameters allow the creation of graphical library objects (in WinCC OA we call this a graphical reference). Imagine you have a project representing a street with many cars on it. Typically you make then an icon for a car (car library) but the color should be different for each car.
Instead of making a library object for red car and green car and other cars you just define one reference with a variable parameter defining the color. This dynamic parameter is called a $-Parameter.
E.g. Your car icon is a rectangle then you can define a $-Parameter called $color which takes over the color name (e.g. red) during runtime, when the car enters the street you have on screen.
Technically speeking:
In the initialize event of the rectangle the background color of the rectangel becomes updated.
Engineering in GEDI for the rectangle:
main()
{
this.color($color);
}
Runtime:
$color=red // Rectangle becomes red on screen
$-Parameters allow the creation of graphical library objects (in WinCC OA we call this a graphical reference). Imagine you have a project representing a street with many cars on it. Typically you make then an icon for a car (car library) but the color should be different for each car.
Instead of making a library object for red car and green car and other cars you just define one reference with a variable parameter defining the color. This dynamic parameter is called a $-Parameter.
E.g. Your car icon is a rectangle then you can define a $-Parameter called $color which takes over the color name (e.g. red) during runtime, when the car enters the street you have on screen.
Technically speeking:
In the initialize event of the rectangle the background color of the rectangel becomes updated.
Engineering in GEDI for the rectangle:
main()
{
this.color($color);
}
Runtime:
$color=red // Rectangle becomes red on screen
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
Re: Dollar Parameter
What also might be helpful to know is that you need to assign values to the dollar parameters of your references in the panel that you added the references too.
The property editor of GEDI shows the dollar parameters required by each reference panel when you select it.
It does this somehow by parsing the reference panels to see which dollar parameters it is using.
There is no need to explicitly declare dollar parameters in your reference panels.
The property editor of GEDI shows the dollar parameters required by each reference panel when you select it.
It does this somehow by parsing the reference panels to see which dollar parameters it is using.
There is no need to explicitly declare dollar parameters in your reference panels.
- kilianvp
- Posts:443
- Joined: Fri Jan 16, 2015 10:29 am
Re: Dollar Parameter
you cannot assign/modify a dollar parameter durring runtime in CTRL codeRuntime:
$color=red // Rectangle becomes red on screen
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
Re: Dollar Parameter
Kilian is right, but if you want the color of your reference panel to change in runtime, here is an example of how to do it.
You can pass the name of a datapoint and, if desired, colors to the reference panel and have the init script set the color.
Here is a simple example with a boolean datapoint
main()
{
dpConnect("work", $DP_NAME);
}
work(string dp_name, bool state)
{
if (state)
this.color = $ON_COLOR;
else
this.color = $OFF_COLOR;
}
You can pass the name of a datapoint and, if desired, colors to the reference panel and have the init script set the color.
Here is a simple example with a boolean datapoint
main()
{
dpConnect("work", $DP_NAME);
}
work(string dp_name, bool state)
{
if (state)
this.color = $ON_COLOR;
else
this.color = $OFF_COLOR;
}
- adaneau
- Posts:310
- Joined: Tue Feb 21, 2012 9:49 am
Re: Dollar Parameter
Hi Avinash,
basically a $param is a code placeholder which will be replaced by some value at parsing of your panel.
BR
Alexandre
basically a $param is a code placeholder which will be replaced by some value at parsing of your panel.
BR
Alexandre
- lakefalos
- Posts:27
- Joined: Thu Feb 01, 2018 3:13 pm
Re: Dollar Parameter
Can't I use dollarSubstitute to modify the dollar parameter. I want to change a dollar parameter $mydp to "$mydp:valve10" I am trying to use it as follows
string groupdp="valve10"
string replaceDollarPar="$mydp:"+groupdp;
dollarSubstitute($mydp, replaceDollarPar);//this subsitutes group back as dollar Parameter.
But it is not working.
string groupdp="valve10"
string replaceDollarPar="$mydp:"+groupdp;
dollarSubstitute($mydp, replaceDollarPar);//this subsitutes group back as dollar Parameter.
But it is not working.
- adaneau
- Posts:310
- Joined: Tue Feb 21, 2012 9:49 am
Re: Dollar Parameter
Hi,
dollarSubstitute works only in GEDI as far as I remember.
This is impossible to change value of a $param in a panel already displayed, you will need to open it again with new value ($param are placeholders, not variables).
BR
Alex
dollarSubstitute works only in GEDI as far as I remember.
This is impossible to change value of a $param in a panel already displayed, you will need to open it again with new value ($param are placeholders, not variables).
BR
Alex
- mkerk
- Posts:75
- Joined: Wed Oct 20, 2010 12:25 pm
Re: Dollar Parameter
Hi,
dollarSubstitute() works in runtime UI!
You can use dollarSubstitute() to replace the $-Parameter in an expression. BUT you can NOT use this function to replace the value of the $-Parameter itself. This is not possible!!
Below the example from the help:
main()
{
start_motor(makeDynString("$motor:motor17"));
}
start_motor(dyn_string dollars)
{
string dp = dollarSubstitute("$motor + \\".start:_original.._value\\"", dollars);
dpSet(dp, true);
}
As Alexander wrote: the value of the $-Parameter can´t be changed without reloading the Object-Reference!.
Why do you want to change the value of the $-Parameter? what is the use case?
BR;
Mousser.
dollarSubstitute() works in runtime UI!
You can use dollarSubstitute() to replace the $-Parameter in an expression. BUT you can NOT use this function to replace the value of the $-Parameter itself. This is not possible!!
Below the example from the help:
main()
{
start_motor(makeDynString("$motor:motor17"));
}
start_motor(dyn_string dollars)
{
string dp = dollarSubstitute("$motor + \\".start:_original.._value\\"", dollars);
dpSet(dp, true);
}
As Alexander wrote: the value of the $-Parameter can´t be changed without reloading the Object-Reference!.
Why do you want to change the value of the $-Parameter? what is the use case?
BR;
Mousser.