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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4205|回復: 0
打印 上一主題 下一主題
收起左側

wincc 冗余連接的代碼

[復制鏈接]
跳轉到指定樓層
樓主
ID:140343 發表于 2016-9-24 20:18 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
#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;
}
}



分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表