수신 버퍼 읽기 여부 평가
이 명령은 지정된 통신 포트에서 수신 버퍼 읽기 플래그 값을 반환합니다.
입력
PLC 기종에 따라 통신 포트를 지정합니다.
COM 포트(예: SYS_COM0_PORT)
MCU/SCU(예: COM01의 16#xx01(xx = 슬롯 번호))
출력
수신 버퍼를 읽은 경우 TRUE로 설정합니다.
이 펑션 프로그램 시 사용한 모든 입력과 출력 변수는 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
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
ReceiveData 커맨드가 실행된 후에는 IsReceiveBufferRead만 직접 활성화(=TRUE)됩니다.
다음 PLC 주기에서 IsReceiveBufferRead는 활성화되지 않습니다(=FALSE).
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;