您现在所在的是:

PLC论坛

回帖:1个,阅读:1070 [上一页] [1] [下一页]
1497
netcookie
文章数:108
年度积分:50
历史总积分:1497
注册时间:2001/4/7
发站内信
发表于:2009/1/7 13:38:40
#0楼
[size=4][face=黑体]  工程实践发现,好多人喜欢用wincc的name connect连接方法,对于单卡来讲,可以用C脚本实现即可;
#include "apdefap.h"
int gscAction( void )
{
#define TAG_0 "@aa@AlternateConnectionAddress"
#define TAG_1 "@aa@ConnectionEstablishMode"
#define TAG_2 "@aa@ConnectionState"
#define TAG_3 "@aa@ForceConnectionAddress"
#pragma code("msrtcli.dll")
#include "msrtapi.h"
#pragma code()
#pragma code( "kernel32.dll" )
VOID GetLocalTime(LPSYSTEMTIME lpSystemTime);
#pragma code()
static int Mld_Main = 0;
static int Mld_Res = 0;
DWORD ServiceID = 0;
static BOOL InitFirst = TRUE;
static MSG_RTCREATE_STRUCT  MsgCreate;
CMN_ERROR Error;
if ( InitFirst == TRUE )
{ memset( &MsgCreate, 0, sizeof (MSG_RTCREATE_STRUCT) );
MsgCreate.dwMsgState = MSG_STATE_COME;
MsgCreate.wTextValueUsed = 1;
sprintf( MsgCreate.mtTextValue[0].szText, "sg" );
SetTagChar( TAG_0, "H1,08 00 06 71 88 06,,0,3,02" );
InitFirst = FALSE;
}

if (  GetTagDWordWait( TAG_1 ) == 0  )
{
Mld_Main = 0;
Mld_Res = 0;
return 0;
}
else
{
GetLocalTime( &MsgCreate.stMsgTime );
MSRTStartMsgService ( &ServiceID, NULL, NULL, MSG_NOTIFY_MASK_ARCHIV, NULL, &Error );

if (  GetTagDWordWait( TAG_2 ) == 0  )
{
    if (  GetTagDWordWait( TAG_3 ) == 0  )
{
if ( Mld_Main == 0 )
{
MsgCreate.dwMsgNr = 1012222;
MSRTCreateMsg( ServiceID, &MsgCreate, &Error );
Mld_Main = 1;
SetTagBit("10KA",1);
}
}
else
{
if ( Mld_Res == 0 )
{
MsgCreate.dwMsgNr = 1012224;
MSRTCreateMsg( ServiceID, &MsgCreate, &Error );
Mld_Res = 1;  
SetTagBit("10KA",1);
}
}

  if (  GetTagDWordWait( TAG_2 ) == 0  )
{
if (  GetTagDWordWait( TAG_3 ) == 0  )
{
  SetTagDWord( TAG_3, 1 );
}
else
{
SetTagDWord( TAG_3, 0 );
}
}
}
else
{
if (  ( Mld_Main != 0 )  ||  ( Mld_Res != 0 )  )
{
Mld_Main = 0;
Mld_Res = 0;

if (  GetTagDWordWait( TAG_3 ) == 0  )
{
MsgCreate.dwMsgNr = 1012223;
MSRTCreateMsg( ServiceID, &MsgCreate, &Error );
}
else
{
MsgCreate.dwMsgNr = 1012225;
MSRTCreateMsg( ServiceID, &MsgCreate, &Error );
}
}
}
if ( ServiceID != 0 )
{
MSRTStopMsgService ( ServiceID, &Error );
}
return 1;
}
}

[/face][/size]
4377
lhw982117910
文章数:2204
年度积分:50
历史总积分:4377
注册时间:2004/2/11
发站内信
发表于:2009/1/7 13:43:44
#1楼
很高深,现在才开始学习S7-300PLC,400的属于大型系统的,等以后再学习。
rocky

关于我们 | 联系我们 | 广告服务 | 本站动态 | 友情链接 | 法律声明 | 非法和不良信息举报

工控网客服热线:0755-86369299
版权所有 工控网 Copyright©2025 Gkong.com, All Rights Reserved

31.2002