FB_HVACPersistent_Struct

FB_HVACPersistent_Struct 1:

VAR_INPUT

bSetDefault        : BOOL;
dwAdrStruct        : DWORD;
udiSizeOfStruct    : UDINT;
dwAdrStruct_Default: DWORD;                        

bSetDefault: if the variable is TRUE, the default values of the allocated structure instance dwAdrStruct_Default are adopted and copied to the dwAdrStruct address.

dwAdrStruct: address of the declared structure variable to be persistently saved.

udiSizeOfStruct: size of the instantiated structure in bytes.

dwAdrStruct_Default: address of the allocated structure instance with the default values.

VAR_OUTPUT

bInvalidParameter     : BOOL;

bInvalidParameter: TRUE if udiSizeOfStruct > g_udiMaxNoOfBytesInStruct OR dwAdrStruct = 0 OR dwAdrStruct_Default = 0

VAR_GLOBAL CONSTANT

g_udiMaxNoOfBytesInStruct  : UDINT := 16;  (* size in number of bytes *)                       

g_udiMaxNoOfBytesInStruct: this globally declared constant defines the size of the structure in bytes. By default 16 bytes are defined. This constant can be adapted to the requirements.

Sample:

VAR
    fbBackupStruct    : FB_HVACPersistent_STRUCT;
    bSetDefault       : BOOL;            (* default flag *)
    stTemp            : ST_Temp;             (* structure values *)
    stTemp_Default    : ST_Temp;             (* default Values *)
    bInvalidParameter : BOOL;
END_VAR                     

ST_Temp:

TYPE ST_Temp :
STRUCT
       (* total of 8 bytes *)
       byVar1      : BYTE;
       byVar2      : BYTE;
       byVar3      : BYTE;
       byVar4      : BYTE;
       iVar1       : INT;
       iVar2       : INT;
END_STRUCT
END_TYPE
stTemp_Default.byVar1:= 11;    (* one byte *)
stTemp_Default.byVar2:= 22;    (* one byte *)
stTemp_Default.byVar3:= 33;    (* one byte *)
stTemp_Default.byVar4:= 44;    (* one byte *)
stTemp_Default.iVar1:= 55;     (* two bytes *)
stTemp_Default.iVar2:= 66;     (* two bytes *)

FB_HVACPersistent_Struct 2: