Getters and Setters for Properties in Panels

Creating Getters and Setters for Properties

In WinCC OA, you can easily create getters and setters for properties that allow you to read and modify values within your panels or reference panels. This simple trick simplifies the process of working with properties and enhances code organization.

Example: String Property

Let's start with an example of creating a getter and setter for a string property named 'Hour':


    #property string Hour

    string g_Hour;

    public string getHour()
    {
        return g_Hour;
    }

    public void setHour(string Hour)
    {
        g_Hour = Hour;
    }
    

In this example, we've defined a string property 'Hour' and created a getter and setter for it. The getter retrieves the current value of 'Hour,' while the setter allows you to update it.

Generate Getters and Setters

Now, you can use the following form to generate getters and setters for your properties. Simply enter the desired data type, property name, and click the "Generate Command" button:

Generated Getter and Setter: