FB_BinaryWriter

 

FB_BinaryWriter - General Information

Overview

Type:

Function block

Available as of:

V1.0.3.0

Inherits from:

-

Implements:

-

Versions:

Current version

Task

Efficient writing of any data structures into a binary file.

Description

The function writes the number of bytes specified in i_diBufferSize from the memory at address i_dwBufferAdr into a file. Sufficient memory must be reserved at the position of i_dwBufferAdr. If i_etMode ET_WriteMode.Create mode is chosen, the file will be created anew. If a file with the same name already exists, it will be overwritten. If ET_WriteMode.Append mode is chosen, the new data will be appended to the existing file.

Writing is started with a positive edge at i_xExecute and stopped after an error is detected or after all data has been written successfully. During writing, no parameter (other than i_xExecute) may be changed. Also, that memory area which i_dwBufferAdr points to may not be written to.

Interface

Input

Data type

Description

i_xExecute

BOOL

FALSE -> TRUE: POU is activated. The writing procedure begins.

i_sFileName

STRING[80]

Name of the text file where the variable should be written to.

i_diBufferSize

DINT

Number of bytes to be written

i_dwBufferAdr

DWORD

Address of the array where the data is read. The respective amount of memory must be reserved.

i_etMode

ET_WriteMode

If ET_WriteMode.Create mode is chosen, the file will be created anew. If a file with the same name already exists, it will be overwritten.

If ET_WriteMode.Append mode is chosen, the new data will be appended to the existing file.

Output

Data type

Description

q_xBusy

BOOL

TRUE: The POU is active and has to be executed further.

FALSE: The POU is inactive.

q_xDone

BOOL

TRUE: The POU is ready to operate and can accept user commands.

FALSE: The POU is not ready to accept user commands.

q_etDiag

GD.ET_Diag

General library-independent statement on the diagnostic.

A value not equal to ET_Diag.Ok corresponds to an diagnostic message.

q_etDiagExt

ET_DiagExt

POU-specific output on the diagnostic.

q_etDiag = ET_Diag.Ok -> Status message

q_etDiag <> ET_Diag.Ok -> Diagnostic message

Diagnostic Messages

q_etDiag

q_etDiagExt

Enumeration value

Description

OK

Executing

128

Version

OK

WaitForExecute

180

Wait for execution.

FileHandlingInvalid

CanNotOpenFile

112

The file cannot be opened.

FileHandlingInvalid

TooManyFilesOpen

105

Too many files are opened.

InputParameterInvalid

UnknownMode

111

The Mode is indeterminable.

UnexpectedProgramBehavior

UnexpectedFeedback

1

An unintended detected error occurred during execution.

CanNotOpenFile

Enumeration name:

CanNotOpenFile

Enumeration value:

112

Description:

The file cannot be opened.

Issue

Cause

Solution

-

The file i_sFileName could not be opened.

Verify whether the file called i_sFileName is stored on the data carrier.

Verify data carrier for defects.

Executing

Enumeration name:

Executing

Enumeration value:

128

Description:

Version

Data are being written.

TooManyFilesOpen

Enumeration name:

TooManyFilesOpen

Enumeration value:

105

Description:

Too many files are opened.

Issue

Cause

Solution

-

Too many files are opened.

Close files that are no longer needed using SystemInterface.FC_CloseFile.

UnexpectedFeedback

Enumeration name:

UnexpectedFeedback

Enumeration value:

1

Description:

An unintended detected error occurred during execution.

Issue

Cause

Solution

-

An error occurred in the internal execution.

An error occurred in the internal execution.

UnknownMode

Enumeration name:

UnknownMode

Enumeration value:

111

Description:

The Mode is indeterminable.

Issue

Cause

Solution

-

At the input i_etMode, an invalid value has been applied.

At the input i_etMode, an element of the enumeration ET_WriteMode must be applied.

WaitForExecute

Enumeration name:

WaitForExecute

Enumeration value:

180

Description:

Wait for execution.

The function block is ready. As reaction to a positive edge from i_xExecute, the data is written.