FB_BARShadingObjectsEntry

FB_BARShadingObjectsEntry 1:

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 illustration of the objects with description of the coordinates is given in Shading correction: principles and definitions.
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 ball) 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 ball the center (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.

Note: The fact that the square 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;

This limits the input options for a rectangle such that the side edges are perpendicular to the floor (lrP2x = lrP1x and lrP4x = lrP3x), that the rectangle is not tilted (lrP2z = lrP1z and lrP4z = lrP3z), and that it can only have a positive height (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. This concerns the input values lrP1x, lrP1y, lrP1z, lrP2y, lrP3x, lrP3y, lrP3z, lrMx, lrMy, lrMz and lrRadius and 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 visualisation.

Change

In a next program step the listed input values can then be changed. If the use of a square is preselected via the value "eObjectTypeTetragon" at the input eType, then the output values lrP2x, lrP2z, lrP4x, lrP4y and lrP4z result from the square coordinates 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 output udiErrorId.
If a square is defined, then only the inputs lrP1x, lrP1y, lrP1z, lrP2y, lrP3x, lrP3y and lrP3z need to be described; the inputs lrMx, lrMy, lrMz and lrRadius do not need to be linked. In case of a ball definition, only lrMx, lrMy, lrMz and lrRadius need to be described and the square coordinates can remain unlinked.

The parameterised data are written to the list element with the index iId upon a rising 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 parameterise 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 saved 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: With a rising edge on this input the information of the selected element, arrShadingObject [iId], is read into the function block and assigned to the input variables lrP1x to eType as well as the output variables lrP2x to lrP4z. If data are already present on the inputs lrP1x to eType at this time, then the data previously read are immediately overwritten with these data.

bWrite: A positive edge writes the values on the inputs rP1x to eType as well as the values determined and assigned to the outputs lrP2x to lrP4z into the selected field element arrShadingObject[iId].

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

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

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

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

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

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

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

lrMx: X-coordinate of the center of the shading element (ball) in meters.

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

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

lrRadius: Radius of the shading element (ball) in meters.

usiBeginMonth: Beginning of the shading period (month).

usiEndMonth: End of the shading period (month).

eType: Selected type of element: Rectangle or ball. See E_BARShadingObjectType.

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

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 (square) in metres. See "Note" above.

lrP2z: determined Z-coordinate of point 2 of the shading element (square) in metres. See "Note" above.

lrP4x: determined X-coordinate of point 4 of the shading element (square) in metres. See "Note" above.

lrP4y: determined Y-coordinate of point 4 of the shading element (square) in metres. See "Note" above.

lrP4z: determined Z-coordinate of point 4 of the shading element (square) in metres. See "Note" 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 ball the centre 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 criteria mentioned. See Error codes.

VAR_IN_OUT

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

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

Requirements

Development environment

required library

required function

TwinCAT 3.1 build 4022.16 or higher

Tc2_HVAC V3.3.1.0

TF8000 | TC3 HVAC V1.0.0.0