$-Parameters in Runtime

$-Parameters in Runtime

Dollar parameters are a powerful feature in WinCC OA that streamline the process of passing parameters between panels during runtime. This page explores how dollar parameters work and how you can use them efficiently in your projects.

Basic Understanding

When a panel is in runtime, dollar parameters are initialized. If a dollar parameter has been set in the panel, it can be accessed and utilized during runtime. The foundation of this concept is crucial for object-oriented programming with exclusive parameters in WinCC OA.

Passing Dollar Parameters

Passing dollar parameters is straightforward. If you have a panel that represents a class or object, you can use the instance of that class and associate it with a dollar parameter. The dollar parameter is then called using the name of the instance or object, allowing you to work with it in runtime.

Nesting Panels and Dollar Parameters

One powerful aspect of dollar parameters is their behavior when panels are nested within each other. When you place a panel inside another panel as a reference, and both panels have the same named dollar parameter, the dollar parameter is automatically passed to all subsequent references inside the nested panels.

Here's an illustration:


    |__[$sReservoir] <- First Reference
    |
    |____[$sPump],[$sPump],[$sMotor],[$sReservoir],[$sMotor] <- Second Reference
    |
    |________[$sPump],[$sMotor],[$sReservoir] <- Final Reference
    

In this example, as long as the dollar parameter is named the same in all panels, it will be passed automatically to all references. This means you don't have to pass the same parameter multiple times and can simplify your panel interactions.

Practical Use Cases

Consider a scenario where you have a symbol representing a pump. You place this symbol inside an array of pumps, and then that array inside a larger panel representing a building full of pumps. If you use the same named dollar parameter in all these panels, it will be propagated automatically throughout the entire hierarchy. You only need to define it once, saving time and effort in parameter passing.

Conclusion

Dollar parameters are a key feature in WinCC OA that allow you to pass parameters efficiently between panels in runtime. By understanding how they work and utilizing them effectively, you can simplify your project's parameter passing, leading to more streamlined and manageable applications.

Caution

While dollar parameters offer convenience, it's essential to remember that as long as you pass that dollar parameter, it will reference the same variable throughout all nested panels. For example, if you have two pumps and two motors within a second reference panel, both pumps and both motors will refer to the same instance.

If you wish to avoid having duplicate instances in a panel or reference panel, it's important to consider your naming scheme or implement additional validation in the second reference panel's main function. This will help ensure that you don't inadvertently create multiple instances of the same object. However, this feature also allows you to pass a dollar parameter once at the very end, and it will propagate throughout all nested panels, streamlining your parameter passing.