wHeadHolding:=0;(*寫(xiě)入字首地址*)
WritePoints:=10;(*寫(xiě)入多少個(gè)字*)
wSedDateSet[0]:=20;(*寫(xiě)入多少個(gè)字節(jié)*)
wReHeadHolding:=10;(*讀取字首地址*)
ReadPoints:=10;
wReDataSet[0]:=20;
wECPRTCLDateSet[2]:=1; (*指定第1個(gè)執(zhí)行的協(xié)議的協(xié)議編號(hào) ; *)
wECPRTCLDateSet[3]:=2; (*指定第2個(gè)執(zhí)行的協(xié)議的協(xié)議編號(hào) ; *)
(*----------------------數(shù)據(jù)發(fā)送部分--------------------------*)
(*端口打開(kāi)*)
SP_SOCOPEN(bOpenStatus AND NOT bOpenStatusOld AND
NOT SD1282.1 AND(*打開(kāi)完成信號(hào)*)
NOT SD1284.1 AND(*打開(kāi)請(qǐng)求信號(hào)*)
SD1288.A , (*存儲(chǔ)內(nèi)置以太網(wǎng)端口的連接狀態(tài) 1:與集線器或?qū)ο笤O(shè)備連接中*)
U0, k2,wSocOpenSet , bSocOpenComplete);
IF bSocOpenComplete[0] THEN
bOpenNormalComplete:=NOT bSocOpenComplete[1];
bOpenAbnormaComplete:=bSocOpenComplete[1];
ELSIF bCloseStatus THEN
bOpenNormalComplete:=FALSE;
bOpenAbnormaComplete:=FALSE;
END_IF;
(*執(zhí)行協(xié)議發(fā)送*)
SP_ECPRTCL(bSedStart AND SD1282.1 , U0 , K2 , K2 , wECPRTCLDateSet,bECPRTCLComplete );
(*執(zhí)行 SP_ECPRTCL 命令*)
IF bSedStart THEN
IF bECPRTCLComplete[0] THEN
bSedStart :=FALSE;
END_IF;
ELSE
IF SD1282.1 THEN
bSedStart :=TRUE;
END_IF;
END_IF;
(*關(guān)閉端口*)
SP_SOCCLOSE(bCloseStatus AND NOT bCloseStatusOLD ,"U0", k2,wSocCloseSet,bSocCloseComplete );
IF wECPRTCLDateSet[1]<>0 THEN
wErrorCode:=wECPRTCLDateSet[1];
ELSE
wErrorCode:=0;
END_IF;
bSedStatusOld:=bSedStatus ;
SM413OLD:=SM413;
bOpenStatusOld:=bOpenStatus;
bCloseStatusOLD:=bCloseStatus;