FB_Connect

This function block enables to establish or terminate a TCP connection.

FB_Connect 1:

Syntax

FUNCTION_BLOCK FB_Connect IMPLEMENTS I_Connect
VAR_OUTPUT
    bBusy                        : BOOL;
    bError                       : BOOL;
    eState                       : E_SocketConnectionState;
    ipResultMessage              : I_TcMessage;
END_VAR

FB_Connect 2: Outputs

Name

Type

Description

bBusy

BOOL

Is TRUE as long as the asynchronous request is still active. Is FALSE if the request was completed or an error occurs.

bBusy

BOOL

Is set if an error occurs during the execution of the function block. Error details are located in the "Error List" window.

eState

E_SocketConnectionState

Returns the current connection state.

  • eSOCKET_DISCONNECTED: disconnected
  • eSOCKET_SUSPENDED: state between connected and disconnected
  • eSOCKET_CONNECTED: connected

ipResult
Message

I_TcMessage

Enables error handling with the Tc3_EventLogger.

FB_Connect 3: Methods

Name

Description

FB_init

Initialization method

Connect

Establish a TCP connection.

Disconnect

Terminate a TCP connection.

Send

Send the QRC frame.

Receive

Receive the QRC frame.

FB_exit

Online Change method

FB_Connect 4:

Because all methods are asynchronous and they need more than one cycle to finish working, only one method could be invoked at the same time. Therefore, check the output parameter bBusy when one of these methods is being called.

FB_Connect 5: Properties

Properties

Type

Access

Description

aRxFrame

ARRAY[0..QRC_NUMBER_OF_CONTROL] OF T_MaxString

Get

As soon as the falling edge of bBusy occurs and bError is FALSE, the received QRC response frame can be get with this property.

sTxFrame

STRING(QRC_BUFFER_SIZE)

Set

As soon as the falling edge of bBusy occurs and bError is FALSE, the QRC frame to be sent can be set with this property.

FB_Connect 6: Interface

Name

Description

I_Connect

The interface that defines communication related methods.