Use of properties

Properties have the advantage that they enable read and write access. Thus, parameters can be passed to a function block via properties, i.e. states of the function block can also be output.

The Tc3_DALI uses properties mainly to pass parameters to function blocks. Each property has a documented initial value. Thus, it is not necessary to assign a value to each property.

Assignment at runtime

The following sample shows how values are passed to properties at runtime in ST and CFC.

fbDALI102Dimmer1Switch  : FB_DALI102Dimmer1Switch(Communication.fbKL6821Communication);

In ST, the assignment of properties is done separately from the instance call.

fbDALI102Dimmer1Switch.nMaxLevel := 250;
fbDALI102Dimmer1Switch.nMinLevel := 130;
fbDALI102Dimmer1Switch();

The assignment of the properties is done in CFC by input and output elements and also independent of the instance call.

Use of properties 1:

Assignment during declaration

Properties can also be given a value directly when a function block is declared.

fbDALI102Dimmer1Switch : FB_DALI102Dimmer1Switch(Communication.fbKL6821Communication) := 
               (nMaxLevel := 250, nMinLevel := 130);

The values are assigned to the properties before the first PLC cycle.

Use of arrays

If an array is declared by a function block, the properties for each element of the array can be given different values.

aDALI102Dimmer1Switch : ARRAY [1..3] OF FB_DALI102Dimmer1Switch(Communication.fbKL6821Communication) :=
               [(nMaxLevel := 250, nMinLevel := 130), // Element 1
                (nMaxLevel := 240, nMinLevel := 130), // Element 2
                (nMaxLevel := 254, nMinLevel := 125)]; // Element 3

In the following sample, the two properties nMaxLevel and nMinLevel of element 1 and 2 are given individual values. The properties of element 3 remain unchanged and retain their initial values.

aDALI102Dimmer1Switch : ARRAY [1..3] OF FB_DALI102Dimmer1Switch(Communication.fbKL6821Communication) :=
               [(nMaxLevel := 250, nMinLevel := 130), // Element 1
                (nMaxLevel := 240, nMinLevel := 130)]; // Element 2

The short form for multiple initialization can also be used.

aDALI102Dimmer1Switch : ARRAY [1..5] OF FB_DALI102Dimmer1Switch(Communication.fbKL6821Communication) :=
               [2((nMaxLevel := 250, nMinLevel := 130)), // Element 1 and 2
                 (nMaxLevel := 254, nMinLevel := 125), // Element 3
                2((nMaxLevel := 240, nMinLevel := 140))]; // Element 4 and 5