FB_BARShadingObjectsEntry

This function block serves for the administration of all shading elements in a facade, which is globally saved in a list of shading elements. It is intended to facilitate the input of the element information - also with regard to the use of the target visualization. A schematic representation of the objects with description of the coordinates is shown in Shading correction: principles and definitions.

FB_BARShadingObjectsEntry 1:


The shading elements are declared in the global variables:

VAR_GLOBAL
     arrShadingObject : ARRAY[1..iShadingObjects] OF ST_BARShadingObject;
END_VAR

Each individual element arrShadingObject[1] to arrShadingObject[iShadingObjects] carries the information for one shading element (ST_BARShadingObject). This information consists of the selected type of shading (rectangle or sphere) and the respectively associated coordinates. For a rectangle, these are the corner points (lrP1x, lrP1y, lrP1z), (lrP2x, lrP2y, lrP2z),(lrP3x, lrP3y, lrP3z) and (lrP4x, lrP4y, lrP4z), for a sphere this are the center point (lrMx, lrMy, lrMz) and the radius lrRadius. In addition, the phase of the shading can be defined via the inputs usiBeginMonth and usiEndMonth, which is important in the case of objects such as trees that bear no foliage in winter.

The function block thereby directly accesses the field of this information via the IN-OUT variable arrShadingObject.

FB_BARShadingObjectsEntry 2:

The fact that the rectangle coordinates lrP2x, lrP2z, lrP4x, lrP4y and lrP4z are output values arises from the fact that they are formed from the input parameters.

lrP2x = lrP1x; lrP2z = lrP1z; lrP4x = lrP3x; lrP4y = lrP1y; lrP4z = lrP3z;

That limits the input of a rectangle to the extent that the lateral edges stand vertically on the floor (lrP2x = lrP1x and lrP4x = lrP3x), that the rectangle has no inclination (lrP2z = lrP1z and lrP4z = lrP3z) and can only have a different height "upwards", i.e. in the positive y-direction (lrP4y = lrP1y).

The function block is used in three steps:

Read

With the entry to iId the appropriate element is selected from the list arrShadingObject[iId]. A rising edge on bRead reads the data. These values are assigned to the input and output variables of the function block. These are the input values lrP1x, lrP1y, lrP1z, lrP2y, lrP3x, lrP3y, lrP3z, lrMx, lrMy, lrMz, rRadius, the object enumerator eType and the output values lrP2x, lrP2z, lrP4x, lrP4y and lrP4z. It is important here that the input values are not overwritten in the reading step. Hence, all values can initially be displayed in a visualization.

Change

In a next program step the listed input values can then be changed. If a rectangle is preselected at input eType via the value "eObjectTypeTetragon", the output values rP2x, rP2z, rP4x, rP4y and rP4z result from the rectangle coordinates that were entered (see above).

The values entered are constantly checked for plausibility. The output bValid indicates whether the values are valid (bValid=TRUE). If this is not the case, a corresponding error code is output at the udiErrorId output.
If a rectangle is defined, only the inputs lrP1x, lrP1y, lrP1z, lrP2y, lrP3x, lrP3y and lrP3z have to be described; the inputs lrMx, lrMy, lrMz and lrRadius do not have to be linked. For a sphere definition, only lrMx, lrMy, lrMz and lrRadius have to be described; the rectangle coordinates can remain unlinked

The parameterized data are written to the list element with the index iId upon a positive edge on bWrite, regardless of whether they represent valid values or not. Therefore the element structure ST_BARShadingObject also contains a plausibility bit, bValid, that relays precisely this information to the function block FB_BARShadingCorrection / FB_BARShadingCorrectionSouth and prevents incorrect calculations there.


This approach is to be regarded only as a proposal. It is naturally also possible to parameterize the function block quite normally in one step and to write the values entered to the corresponding list element with a rising edge on bWrite.

VAR_INPUT

iId          : INT;
bRead        : BOOL;
bWrite       : BOOL;
lrP1x        : LREAL;
lrP1y        : LREAL;
lrP1z        : LREAL;
lrP2y        : LREAL;
lrP3x        : LREAL;
lrP3y        : LREAL;
lrP3z        : LREAL;
lrMx         : LREAL;
lrMy         : LREAL;
lrMz         : LREAL;
lrRadius     : LREAL;
usiBeginMonth: USINT;
usiEndMonth  : USINT;
eType        : E_BARShadingObjectType;

iId: index of the selected element. This refers to the selection of a field element of the array stored in the IN-OUT variable arrShadingObject. iId may not be zero! This results from the field definition, arrShadingObject : ARRAY[1..iShadingObjects] OF ST_BARShadingObject

bRead: the information of the selected element, arrShadingObject[iId], is read into the function block with a positive edge at this input and assigned to the input variables lrP1x to eType and the output variables lrP2x to lrP4z. If at this time data have already been applied to the inputs lrP1x to eType, the previously read data are immediately overwritten with these.

bWrite: a positive edge writes the values applied to inputs rP1x to eType and the values determined and assigned to outputs lrP2x to lrP4z to the selected field element arrShadingObject[iId].

lrP1x: X-coordinate of point 1 of the shading element (rectangle) in meters.

lrP1y: Y-coordinate of point 1 of the shading element (rectangle) in meters.

lrP1z: Z-coordinate of point 1 of the shading element (rectangle) in meters.

lrP2y: Y-coordinate of point 2 of the shading element (rectangle) in meters.

lrP3x: X-coordinate of point 3 of the shading element (rectangle) in meters.

lrP3y: Y-coordinate of point 3 of the shading element (rectangle) in meters.

lrP3z: Z-coordinate of point 3 of the shading element (rectangle) in meters.

lrMx: X-coordinate of the center of the shading element (sphere) [m].

lrMy: Y-coordinate of the center of the shading element (sphere) in meters.

lrMz: Z-coordinate of the center of the shading element (sphere) in meters.

lrRadius: radius of the shading element (sphere) in meters.

usiBeginMonth: beginning of the shading period (month).

usiEndMonth: end of the shading period (month).

eType: selected element type: rectangle or sphere. See E_BARShadingObjectType.

Comment on shading period:

The month entries must not be 0 and not be greater than 12, all other combinations are possible.
Examples:
Start=1, End=1: shading in January.
Start=1, End=5: shading from the beginning of January to the end of May.
Start=11, End=5: shading from the beginning of November to the end of May (of the following year).

VAR_OUTPUT

lrP2x      : LREAL;
lrP2z      : LREAL;
lrP4x      : LREAL;
lrP4y      : LREAL;
lrP4z      : LREAL;
bValid     : BOOL;
udiErrorId : UDINT;

lrP2x: determined X-coordinate of point 2 of the shading element (rectangle) in meters. See "Info" above.

lrP2z: determined Z-coordinate of point 2 of the shading element (rectangle) in meters. See "Info" above.

lrP4x: determined X-coordinate of point 4 of the shading element (rectangle) in meters. See "Info" above.

lrP4y: determined Y-coordinate of point 4 of the shading element (rectangle) in meters. See "Info" above.

lrP4z: determined Z-coordinate of point 4 of the shading element (rectangle) in meters. See "Info" above.

bValid: result of the plausibility check for the values entered. With respect to a square it is required that the internal angle is 360° and that the points lie in one plane and in front of the facade regarded. In the case of a sphere the center must likewise lie in front of the facade and the radius must be greater than zero.

udiErrorId: contains the error code, if the entries should not correspond to the mentioned criteria. See error codes.

VAR_IN_OUT

arrShadingObject : ARRAY[1..iShadingObjects] OF ST_BARShadingObject;

arrShadingObject: list of shading objects. Values are persistently saved.