FB_BA_FcdElemEntry
This function block serves the administration of all facade elements (windows) in a facade, which are saved globally in a list of facade elements. It is intended to facilitate the input of the element information - also about the use of the target visualisation. A schematic representation of the objects with description of the coordinates is shown in Shading correction: principles and definitions.
Function description
The facade elements are declared in the global variables as a two-dimensional field above the window columns and rows:
VAR_GLOBAL
arrFcdElem : ARRAY[1..gBA_cMaxColumnFcd, 1..gBA_cMaxRowFcd] OF ST_BA_FcdElem;
END_VAR
Each individual element arrFcdElem[x,y] carries the information for one facade element (ST_BA_FcdElem). The information includes the group membership, the dimensions (width, height) and the coordinates of the corners. The function block thereby accesses this field directly via the IN-OUT variable arrFcdElem.
Note: The fact that the coordinates of corners C2 to C4 are output values arises from the fact that they are formed from the input parameters and are to be available for use in a visualization:
All data in [m]!
lrCnr2X = lrCnr1X
lrCnr2Y = lrCnr1Y + lrWdwHght (window height)
lrCnr3X = lrCnr1X + lrWdwWdth (window width)
lrCnr3Y = lrCnr2Y
lrCnr4X = lrCnr1X + lrWdwWdth (window width)
lrCnr4Y = lrCnr1Y
The function block is used in three steps:
- Read
- Change
- Write
Read
With the entries in iColumn and iRow the corresponding element is selected from the list arrFcdElem[iColumn,iRow]. A rising edge on bRd reads the following data from the list element:
- usiGrp group membership,
- lrCnr1X X-coordinate of corner point 1 [m]
- lrCnr1Y Y-coordinate of corner point 1 [m]
- lrWdwWdth window width [m]
- lrWdwHght window height [m]
These are then assigned to the corresponding input variables of the function block, which uses them to calculate the coordinates of corners C2-C4 as output variables in accordance with the correlation described above. 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. The values entered are constantly checked for plausibility. The output bErr indicates whether the values are valid (bErr=FALSE). If this is not the case, a corresponding error code is output at udiErrId/udiErrArg. See also "Error (bErr=TRUE)" below.
Write
The parameterised data are written to the list element with the index nId upon a rising edge on bWrt, regardless of whether they represent valid values or not. The element structure ST_BA_FcdElem therefore also 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 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 bWrt.
Error (bErr=TRUE)
The function block FB_BA_ShdCorr, which judges whether all windows in a group are shaded, will only perform its task if all windows in the examined group have valid entries.
This means:
- usiGrp must be greater than 0
- lrCnr1X must be greater than or equal to 0.0
- lrCnr1Y must be greater than or equal to 0.0
- lrWdwWdth must be greater than 0
- lrWdwHght must be greater than 0
If one of these criteria is not met, it is interpreted as incorrect input, and the error output bErr is set at the function block output of FB_BA_FcdElemEntry. Within the window element ST_BA_FcdElem, the plausibility bit bVld is set to FALSE.
If on the other hand all entries of a facade element are zero, it is regarded as a valid, deliberately omitted facade element:
In the case of a facade of 6x4 windows, the elements window (2,1), window (3,5) and window (4,4) would be empty elements here.
Inputs/outputs
VAR_INPUT
iColumn : INT;
iRow : INT;
bWrt : BOOL;
bRd : BOOL;
usiGrp : USINT;
lrCnr1X : LREAL;
lrCnr1Y : LREAL;
lrWdwWdth : LREAL;
lrWdwHght : LREAL;
iColumn: column index of the selected component on the facade. This refers to the selection of a field element of the array stored in the IN-OUT variable arrFcdElem.
iRow: ditto Row index. and may not be zero!iRowiColumn This is due to the field definition, which always starts with 1; see above.
bRd: A positive edge at this input causes the information of selected element, arrFcdElem[iColumn,iRow], to be read into the function block and assigned to the input variables usiGrp to lrWdwHght. The resulting output variables are lrCnr2X to lrCnr4Y. If data are already present on the inputs usiGrp to lrWdwHght at time of reading, then the data previously read are immediately overwritten with these data.
bWrt: A rising edge writes both the entered values and the calculated values into the selected field element arrFcdElem[iColumn,iRow].
usiGrp: Association with a group.
lrCnr1X: X-coordinate of corner point 1 [m].
lrCnr1Y: Y-coordinate of corner point 1 [m].
lrWdwWdth: Window width [m].
lrWdwHght: Window height [m].
Inputs/outputs
VAR_OUTPUT
lrCnr2X : LREAL;
lrCnr2Y : LREAL;
lrCnr3X : LREAL;
lrCnr3Y : LREAL;
lrCnr4X : LREAL;
lrCnr4Y : LREAL;
bErr : BOOL;
udiErrId : UDINT;
udiErrArg : UDINT;
lrCnr2X: Calculated X-coordinate of corner point 2 of the window [m]. See "Note" above.
lrCnr2Y: Calculated Y-coordinate of corner point 2 of the window [m]. See "Note" above.
lrCnr3X: Calculated X-coordinate of corner point 3 of the window [m]. See "Note" above.
lrCnr3Y: Calculated Y-coordinate of corner point 3 of the window [m]. See "Note" above.
lrCnr4X: Calculated X-coordinate of corner point 4 of the window [m]. See "Note" above.
lrCnr4Y: Calculated Y-coordinate of corner point 4 of the window [m]. See "Note" above.
bErr : Result check for the entered values.
udiErrId / udiErrArg: Contains the error number and the error argument. See Error codes.
VAR_IN_OUT
arrFcdElem : ARRAY[1..gBA_cMaxColumnFcd, 1..gBA_cMaxRowFcd] OF ST_BA_FcdElem;
arrFcdElem: List of facade elements.
Requirements
Development environment | Target system | required library | required supplement |
---|---|---|---|
TwinCAT 2.11 R3/x64 | PC/CX | TcBA library from V1.0.0 | TS8040 | TwinCAT Building Automation from V1.0.0 |