FB_HVACPersistentDataFileCopy

FB_HVACPersistentDataFileCopy 1:

Application

This function block can be used, for instance, to copy binary files on the local TwinCAT PC or from a remote TwinCAT PC to the local TwinCAT PC. The function block cannot be used to access network drives. The following steps are executed upon a rising edge at the input bExecute:

a) Open the source and destination files;

b) Read the source file into a buffer;

c) Write the bytes that have been read from the buffer into the destination file;

d) Check whether the end of the source file has been reached. If not, then repeat b) and c). If yes, then jump to e);

e) Close the source and destination files;

The file is copied one segment at a time. In this function block, the size of the buffer has been specified as 100 bytes, but this can be modified.

Application example

Download

Required library

TcHVAC.pro

TcHVAC.lib

VAR_INPUT

srcNETID    : T_AmsNetId;      
srcFileName : T_MaxString;           
destNETID   : T_AmsNetId;         
destFileName: T_MaxString;           
bExecute    : BOOL;        
tAdsTimeOut : TIME;            

srcNETID: AmsNetId of the TwinCAT computer on which the function should be executed. If it is to be run on the local computer, an empty string can be entered.

srcFileName: contains the path and file name of the file to be opened.

The path can only point to the local computer’s file system! This means that network paths cannot be used here!

destNETID: AmsNetId of the TwinCAT computer on which the file should be copied.

destFileName: contains the path and file name of the destination file. Note: the path can only point to the local computer’s file system! This means that network paths cannot be used here!

bExecute : the steps listed above are executed upon a rising edge at the input bExecute.

tAdsTimeOut : states the length of the timeout that may not be exceeded by execution of the ADS command.

VAR_OUTPUT

bDone            : BOOL;         
bBusy            : BOOL;            
bError           : BOOL;
udiErrorID       : UDINT;                           

bDone: will be set to TRUE if the function block is executed.

bBusy: when the function block is activated the output is set, and it remains active until execution of the command has been completed.

bError: this output is switched to TRUE if an error occurs during the execution of a command.

udiErrorID: contains the command-specific error code. Please see ADS Return Codes.