FILECLOSE
With this function block the file can be closed, and thereby placed into a defined state for further processing by other programs.
VAR_INPUT
VAR_INPUT
NETID : T_AmsNetId; (* ams net id *)
HFILE : UINT; (* file handle obtained through 'FILEOPEN' *)
CLOSE : BOOL; (* close control input *)
TMOUT : TIME;
END_VAR
NETID : is a string containing the AMS network identifier of the target device to which the ADS command is directed.
HFILE : is occupied by the file handle already created by FILEOPEN.
CLOSE : the ADS command is triggered by a rising edge at this input.
TMOUT : specifies the time until the abortion of the function.
VAR_OUTPUT
VAR_OUTPUT
BUSY : BOOL;
ERR : BOOL;
ERRID : UDINT;
END_VAR
BUSY : this output remains TRUE until the function block has executed a command, but at the longest for the duration supplied to the 'Timeout' input. While Busy = TRUE, no new command will be accepted at the inputs. Please note that it is not the execution of the service but its acceptance whose time is monitored.
ERR : this output is switched to TRUE if an error occurs during the execution of a command. The command-specific error code is contained in ‘ErrorId’. If the function block has a timeout error, 'Error' is TRUE and 'ErrorId' is 1861 (hexadecimal 0x745). Is reset to FALSE by the execution of a command at the inputs.
ERRID : contains the instruction-specific error code of the most recently executed command. Is reset to 0 by the execution of a command at the inputs.
Sample of calling the function block in FBD:

Here the file associated with the file handle (which was itself generated by ”File1Open") is closed again.
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v2.7.0 | PC or CX (x86) | PLCSystem.Lib |
TwinCAT v2.8.0 | PC or CX (x86) | TcSystem.Lib |
TwinCAT v2.10.0 Build >= 1301 | CX (ARM) | TcSystem.Lib |