wHeadHolding:=0;(*写入字首地址*)
WritePoints:=10;(*写入多少个字*)
wSedDateSet[0]:=20;(*写入多少个字节*)
wReHeadHolding:=10;(*读取字首地址*)
ReadPoints:=10;
wReDataSet[0]:=20;
wECPRTCLDateSet[2]:=1; (*指定第1个执行的协议的协议编号 ; *)
wECPRTCLDateSet[3]:=2; (*指定第2个执行的协议的协议编号 ; *)
(*----------------------数据发送部分--------------------------*)
(*端口打开*)
SP_SOCOPEN(bOpenStatus AND NOT bOpenStatusOld AND
NOT SD1282.1 AND(*打开完成信号*)
NOT SD1284.1 AND(*打开请求信号*)
SD1288.A , (*存储内置以太网端口的连接状态 1:与集线器或对象设备连接中*)
U0, k2,wSocOpenSet , bSocOpenComplete);
IF bSocOpenComplete[0] THEN
bOpenNormalComplete:=NOT bSocOpenComplete[1];
bOpenAbnormaComplete:=bSocOpenComplete[1];
ELSIF bCloseStatus THEN
bOpenNormalComplete:=FALSE;
bOpenAbnormaComplete:=FALSE;
END_IF;
(*执行协议发送*)
SP_ECPRTCL(bSedStart AND SD1282.1 , U0 , K2 , K2 , wECPRTCLDateSet,bECPRTCLComplete );
(*执行 SP_ECPRTCL 命令*)
IF bSedStart THEN
IF bECPRTCLComplete[0] THEN
bSedStart :=FALSE;
END_IF;
ELSE
IF SD1282.1 THEN
bSedStart :=TRUE;
END_IF;
END_IF;
(*关闭端口*)
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;