FB_BA_ShdObjEntry

FB_BA_ShdObjEntry 1:

This function block serves for the administration of all shading elements in a facade, which are 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 visualization. A schematic representation of the objects with description of the coordinates is shown in Shading correction: Principles and definitions.

The shading elements are declared in the global variables:

VAR_GLOBAL
     arrShdObj : ARRAY[1..Param.uiMaxShdObj] OF ST_BA_ShdObj;
END_VAR

Each individual element arrShdObj[1] to arrShdObj [uiMaxShdObj] carries the information for one shading element (ST_BA_ShdObj). 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 (rP1x, rP1y, rP1z), (rP2x, rP2y, rP2z), (rP3x, rP3y, rP3z) and (rP4x, rP4y, rP4z) for a sphere this are the center point (rMx, rMy, rMz) and the radius rRads. In addition, the phase of the shading can be defined via the inputs udiBegMth and udiEndMth, 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 arrShdObj.

Note: The fact that the rectangle coordinates rP2x, rP2z, rP4x, rP4y, and rP4z are output values results from the fact that they are formed from the input parameters:

rP2x = rP1x; rP2z = rP1z; rP4x = rP3x; rP4y = rP1y; rP4z = rP3z;

That limits the input of a rectangle to the extent that the lateral edges stand vertically on the floor (rP2x = rP1x and rP4x = rP3x), that the rectangle has no inclination (rP2z = rP1z and rP4z = rP3z) and can only have a different height "upwards", i.e. in the positive y-direction (rP4y = rP1y).

The function block is used in three steps:

Read

Selection of the element from the list arrShdObj[iId] is based on the entry at udiId. A rising edge on bRd reads the data. These values are assigned to the input and output variables of the function block. These are the input values rP1x, rP1y, rP1z, rP2y, rP3x, rP3y, rP3z, rMx, rMy, rMz, rRads and the object enumerator eType and the output values rP2x, rP2z, rP4x, rP4y and rP4z. 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 bErr indicates whether the values are valid (bErr=FALSE). If the value is invalid, a corresponding error message is issued at output sErrDescr.
If a rectangle is defined, only the inputs rP1x, rP1y, rP1z, rP2y, rP3x, rP3y and rP3z have to be described; the inputs rMx, rMy, rMz and rRads do not have to be linked. For a sphere definition, only rMx, rMy, rMz and rRads have to be described; the rectangle coordinates can remain unlinked

Write

The parameterized data are written to the list element with the index udiId upon a rising edge on bWrt, regardless of whether they represent valid values or not. The element structure ST_BA_ShdObj therefore contains a plausibility bit bVld, which forwards precisely this information to the function block FB_BA_ShdCorr to prevent miscalculations.

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 bWrt.

VAR_INPUT

udiId       : UDINT;
bRd         : BOOL;
bWrt        : BOOL;
rP1x        : REAL;
rP1y        : REAL;
rP1z        : REAL;
rP2y        : REAL;
rP3x        : REAL;
rP3y        : REAL;
rP3z        : REAL;
rMx         : REAL;
rMy         : REAL;
rMz         : REAL;
rRads       : REAL;
udiBegMth   : UDINT;
udiEndMth   : UDINT;
eType       : E_BA_ShdObjType;

udiId: Index of the selected element. This refers to the selection of a field element of the array saved in the IN-OUT variable arrShdObj. The variable udiId must not be zero! This is due to the field definition, which starts with 1. However, an incorrect input is recognized and displayed as such at bErr/sErrDescr.

bRd: The information of the selected element, arrShdObj[udiId], is read into the function block with a positive edge at this input and assigned to the input variables rP1x to eType and the output variables rP2x to rP4z. If data are already present on the inputs rP1x to eType at this time, then the data previously read are immediately overwritten with these data.

bWrt: A positive edge writes the values applied to the inputs rP1x to eType and the values determined and assigned to the outputs rP2x to rP4z to the selected field element arrShdObj[udiId].

rP1x: X-coordinate of point 1 of the shading element (rectangle) [m].

rP1y: Y-coordinate of point 1 of the shading element (rectangle) [m].

rP1z: Z-coordinate of point 1 of the shading element (rectangle) [m].

rP2y: Y-coordinate of point 2 of the shading element (rectangle) [m].

rP3x: X-coordinate of point 3 of the shading element (rectangle) [m].

rP3y: Y-coordinate of point 3 of the shading element (rectangle) [m].

rP3z: Z-coordinate of point 3 of the shading element (rectangle) [m].

rMx: X-coordinate of the center of the shading element (ball) [m].

rMy: Y-coordinate of the center of the shading element (ball) [m].

rMz: Z-coordinate of the center of the shading element (ball) [m].

rRads: Radius of the shading element (ball) [m].

udiBegMth: Beginning of the shading period (month).

udiEndMth: End of the shading period (month).

eType: Selected type of element: Rectangle or sphere (see E_BA_ShdObjType).

Remark about the shading period:

The entries for the months may not be 0 or greater than 12, otherwise all 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 (the following year).

VAR_OUTPUT

rP2x       : REAL;
rP2z       : REAL;
rP4x       : REAL;
rP4y       : REAL;
rP4z       : REAL;
bErr       : BOOL;
sErrDescr  : T_MAXSTRING;

rP2x: Calculated X-coordinate of point 2 of the shading element (rectangle) [m]. See "Note" above.

rP2z: Calculated Z-coordinate of point 2 of the shading element (rectangle) [m]. See "Note" above.

rP4x: Calculated X-coordinate of point 4 of the shading element (rectangle) [m]. See "Note" above.

rP4y: Calculated Y-coordinate of point 4 of the shading element (rectangle) [m]. See "Note" above.

rP4z: Calculated Z-coordinate of point 4 of the shading element (rectangle) [m]. See "Note" above.

bErr: Result of the plausibility check for the values entered. For a rectangle, the internal angle is 360° and the points are in a plane in front of the facade under consideration. In the case of a ball the center must likewise lie in front of the facade and the radius must be greater than zero.

sErrDescr: Contains the error description.

Error description

01: Error: The input udiId is outside the permissible limits 1..uiMaxShdObj.

02 Error: The sum of the angles of the rectangle is not 360°. This means that the corners are not in the order P1, P2, P3 and P4 but rather P1, P3, P2 and P4. This results in a crossed-over rectangle.

03: Error: The corners of the square are not on the same level.

04: Error: The z-component of P1 is less than zero. This corner would thus lie behind the facade.

05: Error: The z-component of P3 is less than zero. This corner would thus lie behind the facade.

06: Error: P1 is equal to P2. The object entered is thus not a rectangle.

07: Error: P1 is equal to P3. The object entered is thus not a rectangle.

08: Error: P1 is equal to P4. The object entered is thus not a rectangle.

09: Error: P2 is equal to P3. The object entered is thus not a rectangle.

10: Error: P2 is equal to P4. The object entered is thus not a rectangle.

11: Error: P3 is equal to P4. The object entered is thus not a rectangle.

12: Error: The radius entered is zero.

13: Error: The z-component of the ball center is less than zero. This point would thus lie behind the facade.

14: Error: Error object type eType - neither rectangle nor ball.

15: Error: Month input error.

VAR_IN_OUT

arrShdObj : ARRAY[1..Param.uiMaxShdObj] OF ST_BA_ShdObj;

arrShdObj: List of shading objects.

Requirements

Development environment

Required PLC library

TwinCAT from v3.1.4024.7

Tc3_BA from v1.1.6.0