Supported platforms: CODESYS 2.3, CODESYS 3.5

 

SaveOdBlockActions (FUN)

Description

In case that file system data is stored to flash memory, the file system operations must be blocked during flash operations. When using MRAM or similar fast non-volatile memory, blocking of actions is not necessary.

 

 

This function is used to block all actions which are implemented in this library by setting global variable G_OdSave_BlockActions. After enabling this flag all POUs which use FileSystem functions are blocked.

 

Inputs

Input variable name

Data type

Range

Description

i_StateForActions

BOOL

TRUE/FALSE

Value to be set for variable G_OdSave_BlockActions

Return value

Data type

Range

Description

BOOL

TRUE/FALSE

Value set for variable G_OdSave_BlockActions

Example code

Code:

 

VAR_GLOBAL

    G_3606_OldImageChanged:DWORD;  (* Counter which is used to store latest counter value for RAM image. *)

    G_3606_CommsSaveOldCnt:WORD;   (* Variable contains latest value for number od comms save commands. *)

    G_3606_CommsRestoreOldCnt:WORD;(* Variable contains latest value for number od comms restore commands. *)        

    G_3606_CopyNvRam:NVRAMCOPY;    (* Function block instance which is used to copy data to/from NVRAM *)

 

    OD_G_CAN1_Comms:ARRAY[1..10] OF WORD:= 10(0); (* Coomunication parameters *)

    

END_VAR

 

VAR_GLOBAL CONSTANT

    G_3606_FAST_PARAM_SIZE:WORD := 256;  (* Size for the fast parameters. *)

    G_3606_PARAM_SIZE:WORD := 1792;      (* Size for parameter image. size is always 4 bytes bigger than size     

                                            available for actual data because there is header and footer which  

                                            is used to check healty of the image. *)

    G_3606_BLOCK_SIZE_FILE_SYS:WORD := 128;   (* Used block size for filesystem. *)

    G_3606_NVRAM_LOAD_MAX_TIME:TIME:=T#200ms;  (* Maximum time which is waited for nvram load. *)

    G_3606_NVRAM_SAVE_MAX_TIME:TIME:=T#50ms;  (* Maximum time for saving actions to NvRAM. *)

    G_3606_DELAYTIME:TIME:=T#10ms;  (* Delay time which is waited until NvRam status is asked. *)

    G_3606_MAX_RE_TRIES_PARAM_SAVE:BYTE:=5;  (* Maximum number of retries for NVRAM *)

    G_3606_SAVE_BLOCK_SIZE_PARAMS:WORD:=2048;  (* Size for max data saved in one loop for normal parameters. *)

    G_3606_MAX_PIN_NBR:WORD := 35;  (* Maximum pin number *)

    G_3606_MAX_CON_NBR:WORD := 1;  (* Maximum connector number *)

 

END_VAR

 

 

Code:

 

 

NvRam_3606_Save();

IF NvRam_3606_Save.o_Busy = FALSE THEN

    SaveOdBlockActions(i_StateForActions := FALSE); (* Flashing done, stop blocking *)

END_IF

 

(* Check reset request only if there is no data store going on.

   Exception is if error counter is bigger than 10 *)

IF G_RESET_MODULE AND NvRam_3606_Save.o_Busy = FALSE THEN

    (* Reset control unit *)

    SYSTEM_RESTART_PLCOPEN_APP(0);

END_IF

 

(* Check if fast parameters are necessary to save *)

IF G_3606_FastParamsSave = TRUE AND NvRam_3606_Save.o_Busy = FALSE THEN

    G_3606_FastParamsSave := FALSE;

    NvRam_3606_Save( i_SaveFastParamsStart:= TRUE,

                     i_TimeOutValue:= G_3606_NVRAM_SAVE_MAX_TIME,

                     i_SizeOfParams := G_3606_PARAM_SIZE,

                     i_SizeOfFastParams := G_3606_FAST_PARAM_SIZE);

END_IF

 

(* If RAM image is changed nvram copying is always started again from begin. *)

IF G_3606_OldImageChanged <> G_FileSysFileSystem.RamImageChanged AND G_3606_CopyNvRam.o_Busy = FALSE THEN

    SaveOdBlockActions(i_StateForActions := TRUE); (*  *)

    G_3606_OldImageChanged := G_FileSysFileSystem.RamImageChanged;

    NvRam_3606_Save( i_SaveParamsStart:= TRUE,

                     i_TimeOutValue:= G_3606_NVRAM_SAVE_MAX_TIME,

                     i_SizeOfParams := G_3606_PARAM_SIZE,

                     i_SizeOfFastParams := G_3606_FAST_PARAM_SIZE);

END_IF

 

 

 

See also

-

 

Source file topic000654.htm

Last updated 4-Sep-2025