FB_FileClose
The function block FB_FileClose closes the file, thereby putting it in a defined state for further processing by other programs.
This function block is only suitable for logging in real-time to a limited extent. |
Inputs
VAR_INPUT
sNetId : T_AmsNetId;
hFile : UINT;
bExecute : BOOL;
tTimeout : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR
Name | Type | Description |
---|---|---|
sNetId | T_AmsNetId | String containing the AMS network ID of the target device to which the ADS command is addressed (type: T_AmsNetId). |
hFile | UINT | Handle of the file to be closed. |
bExecute | BOOL | The function block is activated by a rising edge at this input. |
tTimeout | TIME | States the length of the timeout that may not be exceeded by execution of the ADS command. |
Outputs
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
END_VAR
Name | Type | Description |
---|---|---|
bBusy | BOOL | When the function block is activated, this output is set to TRUE and remains set until feedback is received. As long as bBusy is TRUE, no new command can be executed. |
bError | BOOL | If an error occurs during command execution, this output is set, once the bBusy output has been reset. |
nErrId | UDINT | Returns the ADS error code or the command-specific error code when the bError output is set. |
Command specific error code for nErrId
Returns the ADS error code or the command-specific error code when the bError output is set.
Command-specific error code | Possible cause |
---|---|
0x703 | Invalid or unknown file handle. |
0x70E | File was opened with wrong method (e.g. with obsolete FILEOPEN function block). |
Example of calling the block in FBD:
PROGRAM Test
VAR
fbFileClose : FB_FileClose;
hFile : UINT;
bFileClose : BOOL;
bFileCloseBusy : BOOL;
bFileCloseError : BOOL;
nFileCloseErrorId : UDINT;
END_VAR
Here the file associated with the file handle (which was itself generated by FB_FileOpen) is closed again.
Requirements
Development environment |
Target system type |
PLC libraries to include (Category group) |
---|---|---|
TwinCAT v3.1.0 |
PC or CX (x86, x64, ARM) |
Tc2_System (System) |