怎么检测WinCC与PLC的通信状态
问:怎么检测WinCC与PLC的通信状态,当通信断开时在报警中显示“通信中断”,通信再次连接正常时在报警中显示“通信连接”,并计算出中间的间隔时间。
答:可以将信号质量状态取出,进行编程。
#include "apdefap.h"
int gscAction( void )
{
unsigned long status[1];
GetTagBitState("S7$Program(1)_Switch",&status[0]); //Return type :short int printf("%d",*status);
if (*status==1)
SetTagBit("ConnectionBool",1); //Return type :BOOL
else
SetTagBit("ConnectionBool",0); //Return type :BOOL
return(0);
}
答:可以将信号质量状态取出,进行编程。
#include "apdefap.h"
int gscAction( void )
{
unsigned long status[1];
GetTagBitState("S7$Program(1)_Switch",&status[0]); //Return type :short int printf("%d",*status);
if (*status==1)
SetTagBit("ConnectionBool",1); //Return type :BOOL
else
SetTagBit("ConnectionBool",0); //Return type :BOOL
return(0);
}
新闻详情