发布于 2011-05-21 08:58:01
1楼
1、可以利用WINCC脚本函数判断通讯状态,例如WINCC和PLC之间做一个通讯检测的“心跳”程序,即200侧对一个BOOL变量利用SM0.5(一秒)脉冲进行置位、复位,WINCC中做相应判断,并在WINCC界面上显示出来,还可以在WINCC及PLC中做报警输出。
2、WINCC内部函数GetTagBitState编程,可以将变量“质量”状态取出,。
#include "apdefap.h"
int gscAction( void )
{
unsigned long status;
GetTagBitState("val",&status); //Return type :short int printf("%d",*status);
if (*status==1)
SetTagBit("Connection",1); //Return type :BOOL
else
SetTagBit("Connection",0); //Return type :BOOL
return(0);
}
返回值:
0 0x0000 No error
1 0x0001 Connection to partner not established
2 0x0002 Handshake error
4 0x0004 Network module defective
8 0x0008 Configured upper limit exceeded
16 0x0010 Configured lower limit exceeded
32 0x0020 Format upper limit exceeded
64 0x0040 Format lower limit exceeded
128 0x0080 Conversion error
256 0x0100 Tag initialization value
512 0x0200 Tag replacement value
1024 0x0400 Channel addressing error
2048 0x0800 Tag not found or not available
4096 0x1000 Access to tag not permitted
8192 0x2000 Timeout, no check-back message from the channel
16384 0x4000 Server not available.