发表于: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]
#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]