Phoenix Contact PLCNext Eth ZPL
Connect, Send, Disconnect
Variables:
Group,Name,DataType,Usage,IsTranslate,Comment,InitValue,IsRetain,IsConstant,IsOpc,IsHmi,IsProficloud,Address
,baSocket0_SendBuffer,ByteArray1000,Local,False,,,False,False,False,False,False,
,bDoIt,BOOL,Local,False,,,False,False,False,False,False,
,tcpSocket0,TLS_SOCKET_2,Local,False,,,False,False,False,False,False,
,tcpSend0,TLS_SEND_2,Local,False,,,False,False,False,False,False,
,bSock0_Connect,BOOL,Local,False,,,False,False,False,False,False,
,dwSock0_Handle,DWORD,Local,False,,,False,False,False,False,False,
,bConnectedOK,BOOL,Local,False,,,False,False,False,False,False,
,iStepNum,INT,Local,False,,,False,False,False,False,False,
,bSock0_SendData,BOOL,Local,False,,,False,False,False,False,False,
,sSendText,STRING512,Local,False,,,False,False,False,False,False,
,iLines,INT,Local,False,,,False,False,False,False,False,
,xx,INT,Local,False,,,False,False,False,False,False,
,STR_TO_BUF_0,STRING_TO_BUF,Local,False,,,False,False,False,False,False,
,STRING_TO_BUF1,STRING_TO_BUF,Local,False,,,False,False,False,False,False,
,bString_to_buf,BOOL,Local,False,,,False,False,False,False,False,
,sCrLf,STRING,Local,False,,,False,False,False,False,False,
,sTitle,STRING,Local,False,,,False,False,False,False,False,
,sBarcode,STRING,Local,False,,,False,False,False,False,False,
Code:
tcpSocket0(ACTIVATE := bSock0_Connect, DEST_IP := '192.168.1.207', DEST_PORT := UINT#5000, HANDLE => dwSock0_Handle);
bConnectedOK := tcpSocket0.ACTIVE;
tcpSend0(REQ := bSock0_SendData, HANDLE := dwSock0_Handle, DATA_CNT := INT_TO_UINT(len(sSendText)), DATA := baSocket0_SendBuffer);
sCrLf := CONCAT(TO_STRING(BYTE#10,'{0:C}'), TO_STRING(BYTE#13,'{0:C}'));
sTitle := 'Best Griddle';
sBarcode := '1234ABC';
sSendText := '';
sSendText := CONCAT(sSendText, '^XA');
sSendText := CONCAT(sSendText, sCrLf);
sSendText := CONCAT(sSendText, '^FO50,60^A0,40^FD');
sSendText := CONCAT(sSendText, sTitle);
sSendText := CONCAT(sSendText, '^FS');
sSendText := CONCAT(sSendText, sCrLf);
sSendText := CONCAT(sSendText, '^FO60,120^BY3^BCN,60,,,,A^FD');
sSendText := CONCAT(sSendText, sBarcode);
sSendText := CONCAT(sSendText, '^FS');
sSendText := CONCAT(sSendText, sCrLf);
sSendText := CONCAT(sSendText, '^FO25,25^GB380,200,2^FS');
sSendText := CONCAT(sSendText, sCrLf);
sSendText := CONCAT(sSendText, '^XZ');
sSendText := CONCAT(sSendText, sCrLf);
STRING_TO_BUF1(REQ := bString_to_buf, BUF_FORMAT := False, BUF_OFFS := 0, BUF_CNT := len(sSendText), SRC := sSendText, BUFFER := baSocket0_SendBuffer);
CASE iStepNum OF
1 : bSock0_Connect := True;
If bConnectedOK THEN
iStepNum := 2;
End_if;
2: bString_to_buf := True;
If STRING_TO_BUF1.DONE THEN
iStepNum := 3;
End_if;
3: bSock0_SendData := True;
if tcpSend0.DONE THEN
iStepNum := 4;
End_if;
4: bSock0_Connect := False;
bString_to_buf := false;
bSock0_SendData := false;
iStepNum := 7;
END_CASE