IsReceiveBufferRead

评估是否已读取接收缓冲区

此指令返回指定通信端口中接收缓冲区读取标志的值。

参数

输入

Port (WORD, INT, UINT)

根据PLC的类型指定通信端口:

  • COM端口,例如SYS_COM0_PORT

  • MCU/SCU,例如COM01中的16#xx01(xx = 插槽编号)

输出

IsRead (BOOL)

如果接收缓冲区已被读取,将设置为TRUE

示例

POU头

所有用于编程此函数的输入和输出变量已在POU头中声明。 所有编程语言使用相同的POU头。

	VAR
		iPort: INT:=0;
		bIsReceptionDone: BOOL:=FALSE;
		awDataBuffer: ARRAY [0..2] OF WORD:=[3(0)];
		bIsReceiverBufferRead: BOOL:=FALSE;
		bReadReceiveBuffer: BOOL:=FALSE;
	END_VAR

LD本体

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 3 ;
        NETWORK_BODY
B(B_F,IsReceptionDone!,,14,0,23,3,,?DPort?CIsDone);
B(B_VARIN,,iPort,12,1,14,3,);
B(B_VAROUT,,bIsReceptionDone,23,1,25,3,);
L(1,0,1,3);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 3 ;
        NETWORK_BODY
B(B_CONTACT,,bIsReceptionDone,5,1,7,3,);
B(B_CONTACT,,bReadReceiveBuffer,14,1,16,3,N);
B(B_COIL,,bReadReceiveBuffer,40,1,42,3,S);
L(1,2,5,2);
L(16,2,40,2);
L(7,2,14,2);
L(1,0,1,3);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 4 ;
        NETWORK_BODY
B(B_F,E_ReceiveData!,,14,0,23,4,,?DEN?DPort?AENO?CReceiveData);
B(B_VARIN,,iPort,12,2,14,4,);
B(B_VAROUT,,awDataBuffer,23,2,25,4,);
B(B_CONTACT,,bReadReceiveBuffer,5,1,7,3,);
L(1,2,5,2);
L(7,2,14,2);
L(1,0,1,4);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 3 ;
        NETWORK_BODY
B(B_VARIN,,iPort,12,1,14,3,);
B(B_VAROUT,,bIsReceiverBufferRead,30,1,32,3,);
B(B_F,IsReceiveBufferRead!,,14,0,25,3,,?DPort?CIsRead);
L(25,2,30,2);
L(1,0,1,3);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 3 ;
        NETWORK_BODY
B(B_CONTACT,,bIsReceiverBufferRead,5,1,7,3,);
B(B_COIL,,bReadReceiveBuffer,40,1,42,3,E);
L(7,2,40,2);
L(1,2,5,2);
L(1,0,1,3);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY
注释

IsReceiveBufferRead仅在刚执行完ReceiveData命令之后处于激活状态(=TRUE)。

在下一个PLC循环中,IsReceiveBufferRead并不会处于激活状态(=FALSE)。

ST本体

bIsReceptionDone := IsReceptionDone(Port := iPort);
If (bIsReceptionDone) AND NOT (bReadReceiveBuffer) then
    bReadReceiveBuffer := TRUE;
End_if;

If (bIsReceiverBufferRead) then
    awDataBuffer := ReceiveData(iPort);
End_if;

bIsReceiverBufferRead := IsReceiveBufferRead(Port := iPort);

If (bIsReceptionDone) then
    bReadReceiveBuffer := FALSE;
End_if;

最后更新日期: 此页面上的反馈松下热线