欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: wincc 冗余連接的代碼 [打印本頁]

作者: 51hei小林    時間: 2016-9-24 20:18
標題: wincc 冗余連接的代碼
#include "apdefap.h"

int gscAction( void )
{

#pragma option(mbcs)

// WINCC:TAGNAME_SECTION_START
// syntax: #define TagNameInAction "DMTagName"
// next TagID : 1
#define TAG_0 "@S7-Programm(1)@AlternateConnectionAddress"
#define TAG_1 "@S7-Programm(1)@ConnectionEstablishMode"
#define TAG_2 "@S7-Programm(1)@ConnectionState"
#define TAG_3 "@S7-Programm(1)@ForceConnectionAddress"
// WINCC:TAGNAME_SECTION_END

// WINCC:PICNAME_SECTION_START
// syntax: #define PicNameInAction "PictureName"
// next PicID : 1
// WINCC:PICNAME_SECTION_END


#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, "S7-Programm(1)" );
    SetTagChar( TAG_0, "MPI,3 0,,1,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;
            }
         }
        else
        {
            if ( Mld_Res == 0 )
            {
                MsgCreate.dwMsgNr = 1012224;
                MSRTCreateMsg( ServiceID, &MsgCreate, &Error );
                Mld_Res = 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;
}
}








歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1