亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? udprotcl.c

?? 工業組態軟件modbus驅動源代碼, 包括幫助文件.共享.
?? C
?? 第 1 頁 / 共 5 頁
字號:
/* $Header: "%n Ver=%v  %f  LastEdit=%w  Locker=%l" */
/* "UDPROTCL.C Ver=5  26-Nov-97,9:43:02  LastEdit=JIMV  Locker=***_NOBODY_***" */
/***********************************************************************\
*                                                                       *
*       Copyright Wonderware Software Development Corp. 1992-1997       *
*                                                                       *
*               ThisFileName="L:\ww\dde_serv\src\udsample\udprotcl.c"   *
*               LastEditDate="1997 Nov 26  09:43:00"                    *
*                                                                       *
\***********************************************************************/

#define LINT_ARGS
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "ntconv.h"
#include "hmemcpy.h"
#include "chainmgr.h"
#include "udprot.h"
#include "uddefs.h"
#include "protocol.h"
#include "debug.h"
#include "wwassert.h"
#include "strval.h"
#include "udgetstr.h"
#include "ntsrvr.h"

USES_ASSERT

#define ENSURE_BCD                /* force operands, results to valid BCD */

extern CHAIN PortList;
extern BOOL ShowingSend, ShowingReceive, ShowingEvents, ShowingErrors;
extern WORD tickChange;
extern BOOL bBldSendMsgInBinary, bBldRecvMsgInBinary;
extern int  nBldRecvMsgMinLen;
extern BOOL bFlushOnError;

/***********************************************************************/
/** Data conversion tables **/

/** This table provides a simple way of getting a mask for bit n.
    Note that for this table, bit 0 is the msbit of the word.
    For bit 0 as the lsbit of the word, use bit 15-n to access the table. **/
static WORD     bitMask[] = {
    0x8000, 0x4000, 0x2000, 0x1000,
    0x0800, 0x0400, 0x0200, 0x0100,
    0x0080, 0x0040, 0x0020, 0x0010,
    0x0008, 0x0004, 0x0002, 0x0001
};

/***********************************************************************/
/** local prototypes **/

static void WINAPI UdprotSendQuery(LPPORT lpPort, LPUDMSG lpMsg);
static void WINAPI UdprotDeleteCurWriteMsg(LPPORT lpPort);
static void WINAPI UdprotDeleteWriteMsg(LPUDMSG lpMsg, LPSTAT lpTopic);
static BOOL WINAPI UdprotValidMessage(LPPORT lpPort);
static void WINAPI UdprotCheckAndUpdateStatus (LPSTAT lpTopic);
static void WINAPI UdprotFailStationTopics (LPPORT lpPort);
static BOOL WINAPI UdprotSetTopicStatus (LPPORT lpPort, LPSTAT lpTopic, unsigned bFailed);
static void WINAPI UdprotSetMsgQuality (LPSTAT lpTopic, LPUDMSG lpMsg, PTQUALITY ptQuality);
static void WINAPI UdprotSetTopicQuality (LPSTAT lpTopic, PTQUALITY ptQuality);
static void WINAPI UdprotSetSlowPollMode (LPPORT lpPort, LPSTAT lpTopic);
static LPSTR WINAPI UdprotGetDateTimeString (LPPTTIME lpPtTime, LPSTR szDateTime);

#ifndef WIN32
 #define DbNewVTQFromDevice(hLogDev, hProt, ptValue, lpPtTime, ptQuality) \
         DbNewValueFromDevice(hLogDev, hProt, ptValue)
#endif

/***********************************************************************/
/** have the logger show the contents of the message being sent **/

void
WINAPI
showSendData(LPUDMSG  lpMsg)
{
    BYTE FAR       *rd;
    int             i, n, L;
    int             max_str, max_msg;

    /* get and check message length */
    n = lpMsg->mmSize;
    if (n == 0) {
        /* no message being sent, nothing to display */
        return;
    }

    /* get pointer to message */
    rd = (BYTE FAR *) lpMsg->mmData;

    /* get number of characters that can be stored in display string */
    max_str = DBG_BUF_SIZE - 1;

    /* format message for display */
    strcpy(dbgBuf, GetString(STRUSER + 80) /* "S: " */ );

    /****************************************************************\
        Format the rest of the message and append it to dbgBuf.
        Depending on the protocol, it may be appropriate to
        convert bytes to hex ASCII, or simply copy an ASCII string.
    \****************************************************************/

    L = strlen (dbgBuf);
    if (lpMsg->mmMsgInBinary) {
        /* convert characters to hex ASCII */
        if (!bBldSendMsgInBinary) {
            /* indicate message converted from ASCII to binary */
            strcpy (&dbgBuf[L], "[in binary] ");
            L += strlen (&dbgBuf[L]);
        }
        max_msg = (max_str - L) / 2;
        if (n > max_msg)
            /* make sure message doesn't overflow buffer */
            n = max_msg;
        for (i = 1; i <= n; i++) {
            sprintf (&dbgBuf[L], "%02X", *(rd++));
            L += strlen (&dbgBuf[L]);
        }
    } else {
        /* take characters just as they are */
        max_msg = max_str - L;
        if (n > max_msg)
            /* make sure message doesn't overflow buffer */
            n = max_msg;
        _fstrncpy (&dbgBuf[L], (LPSTR) rd, n);
        dbgBuf[L+n] = '\0';
    }

    /* output display string to logger */
    debug(dbgBuf);
} /* showSendData */

/***********************************************************************/
/** have the logger show the contents of the message received **/

void
WINAPI
showReceivedData(LPPORT    lpPort)
{
    BYTE FAR       *rd;
    int             i, n, L;
    int             max_str, max_msg;

    /* get and check message length */
    n = lpPort->mbRspIndex;
    if (n == 0) {
        /* message length is zero, indicate nothing received */
        debug(GetString(STRUSER + 84) /* "R: <nothing>" */ );
        return;
    }

    /* get pointer to message */
    rd = lpPort->mbRspBuffer;

    /* get number of characters that can be stored in display string */
    max_str = DBG_BUF_SIZE - 1;

    /* format message for display */
    strcpy(dbgBuf, GetString(STRUSER + 85) /* "R: " */ );

    /****************************************************************\
        Format the rest of the message and append it to dbgBuf.
        Depending on the protocol, it may be appropriate to
        convert bytes to hex ASCII, or simply copy an ASCII string.
    \****************************************************************/

    L = strlen (dbgBuf);
    if (lpPort->mbMsgInBinary) {
        /* convert characters to hex ASCII */
        if (!bBldRecvMsgInBinary) {
            /* indicate message converted from ASCII to binary */
            strcpy (&dbgBuf[L], "[in binary] ");
            L += strlen (&dbgBuf[L]);
        }
        max_msg = (max_str - L) / 2;
        if (n > max_msg)
            /* make sure message doesn't overflow buffer */
            n = max_msg;
        for (i = 1; i <= n; i++) {
            sprintf (&dbgBuf[L], "%02X", *(rd++));
            L += strlen (&dbgBuf[L]);
        }
    } else {
        /* take characters just as they are */
        max_msg = max_str - L;
        if (n > max_msg)
            /* make sure message doesn't overflow buffer */
            n = max_msg;
        _fstrncpy (&dbgBuf[L], (LPSTR) rd, n);
        dbgBuf[L+n] = '\0';
    }

    /* output display string to logger */
    debug(dbgBuf);
} /* showReceivedData */

/***********************************************************************/
/** Initiate the transmission of a message out of the communication port.
    The message may be a poll for new data or a write of data from the client.
    The status from the last sent message will have to be checked
    during the next time slice. **/

static
void
WINAPI
UdprotSendQuery(LPPORT   lpPort,
                LPUDMSG  lpMsg)
{
    int  iWCRet;

    /* indicate error if pointers are null or there is no current message */
    assert(lpPort);
    assert(lpMsg);
    assert(lpPort->mbCurMsg);

    if (lpMsg == (LPUDMSG) NULL) {
        /* no message, just return */
        return;
    }

    if (lpMsg->mmActiveCt == 0) {
        /* active count is zero, indicate port is idle */
        lpPort->mbState = PROT_IDLE;
        return;
    }

    /* flush port buffers, indicate if residual received data is present */
    FlushPort (lpPort, (LPSTR) "Port has data at command send time:");

    /* attempt to write message to port */
    iWCRet = WritePortMsg (lpPort, lpMsg);
    if (iWCRet <= 0) {
        /* error occurred on write, identify and display if appropriate */
        /* set up port for error delay */
        lpPort->mbTimer = (WORD) GetDeltaTime () + lpPort->mbReplyTime;
        lpPort->mbState = PROT_PROTERRORDELAY;
    } else {
        /* message output successfully, set up to handle response */
        if (ShowingSend)
            /* output send message to logger */
            showSendData(lpMsg);

        /*
         * Set the appropriate state, timeout, and initialize the
         * response buffer
         */
        lpPort->mbState = PROT_WAITHDR;         /* wait state */
        lpPort->mbTimer = (WORD) GetDeltaTime () +
                          lpPort->mbReplyTime;  /* timeout */
        lpPort->mbRspIndex = 0;                 /* bytes received */

        /***************************************************************\
            Setup the number of bytes to wait for in the PROT_WAITHDR
            state.  It can be any length up to the total length of the
            expected response.  If the length of the response is not
            known at this time, then wait for enough bytes to arrive
            so that the length of the response can be determined.
            See the function GetResponse for further details.

        lpPort->mbRspExpLen = length of the message header;

            The example code below assumes the receive message will
            contain a header or be one of a fixed set of error messages,
            so that by the time a certain number of characters
                    nBldRecvMsgMinLen
            have been received, we know how many are coming.
            This value should be at least 1 so that even if the entire
            message will be coming at once, we'll be able to recognize
            that more than zero characters have arrived.
            The BOOL variable bBldRecvMsgInBinary indicates whether
            the incoming message is expected in binary or ASCII.
        \***************************************************************/
        //lpPort->mbRspExpLen   = nBldRecvMsgMinLen;
		lpPort->mbRspExpLen = INQSIZE;
        lpPort->mbMsgInBinary = bBldRecvMsgInBinary;
    }
} /* UdprotSendQuery */

/***********************************************************************/
/** Set up protocol poll:
    If the communication port is clear,
    see if an unacknowledged write message needs to be retransmitted.
    If nothing was sent,
    see if messages are now in the queue and send one of them. **/

void
WINAPI
UdprotPoll(LPPORT  lpPort)
{
    LPSTAT          lpTopic, startTopic;
    LPUDMSG         lpMsg, startMsg, wMsg, rMsg;
    BOOL            found, done;
    CHAINSCANNER    station_scanner;
    CHAINSCANNER    message_scanner;

    /* indicate error if pointer is null */
    assert(lpPort);

    /* get pointer to current station, if any */
    startTopic = lpPort->mbCurTopic;

    /* Set up scanner, find the current station on this port, if any
       If no current station, find the first station on this port, if any */
    lpTopic = (LPSTAT) FindItemStartingAt ((LPCHAINLINK) startTopic,
                                           &lpPort->mbTopicList, SCAN_FROM_HEAD,
                                           NULL, NULL, &station_scanner);
    if (lpTopic == (LPSTAT) NULL)
        /* no stations, just return */
        return;

    if (startTopic == (LPSTAT) NULL) {
        /* no current station, set current station to first station */
        lpPort->mbCurTopic = startTopic = lpTopic;
    }

    /** search through the stations on this port,
        starting with the one AFTER the current station **/
    found = FALSE;
    do {
        /*******************************/
        /* get pointer to next station */
        /*******************************/

        /* check for end of list */
        if (GetScannerNextItem (&station_scanner) != NULL) {
            /* get next item from station list */
            lpTopic = (LPSTAT) FindNextItem (&station_scanner);
        } else {
            /* end of list reached, wrap around to beginning of list */
            lpTopic = (LPSTAT) FindFirstItem (&lpPort->mbTopicList,
                                              SCAN_FROM_HEAD,

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91网址在线看| 中文字幕av不卡| 欧美一级高清大全免费观看| 在线观看免费视频综合| 色综合久久66| 在线一区二区三区四区五区| 在线看不卡av| 在线不卡免费av| 日韩一区二区精品葵司在线| 日韩女优制服丝袜电影| 精品久久国产老人久久综合| 日韩视频免费观看高清完整版在线观看 | 国产露脸91国语对白| 麻豆精品精品国产自在97香蕉| 麻豆成人免费电影| 国模大尺度一区二区三区| 国产老妇另类xxxxx| 成人自拍视频在线观看| 97精品久久久午夜一区二区三区| 日本高清无吗v一区| 欧美精品免费视频| 日韩情涩欧美日韩视频| 久久免费电影网| 国产精品家庭影院| 亚洲国产日日夜夜| 日精品一区二区| 国产在线视频一区二区| 成人黄页毛片网站| 在线观看成人免费视频| 日韩一区二区影院| 国产欧美日韩综合| 一区二区三区中文在线观看| 五月激情丁香一区二区三区| 美女视频网站久久| 国产98色在线|日韩| 91丨porny丨中文| 91精品国产一区二区三区| 精品久久久久久久一区二区蜜臀| 国产精品不卡在线观看| 亚洲成人黄色影院| 国产精品综合一区二区| 色婷婷综合久久久| 日韩午夜激情av| 亚洲欧洲日韩在线| 日韩国产欧美视频| 国产成人免费网站| 一本到不卡免费一区二区| 日韩欧美一区二区免费| 国产精品嫩草影院com| 天天综合色天天综合色h| 国产91丝袜在线观看| 欧美日韩亚洲综合一区二区三区| 精品国产污污免费网站入口 | 国内成人自拍视频| 在线看国产一区| 国产夜色精品一区二区av| 亚洲国产日日夜夜| 成人av集中营| 欧美成人精精品一区二区频| 亚洲欧美一区二区三区孕妇| 精品一区二区三区免费播放| 色噜噜偷拍精品综合在线| 久久久久久影视| 午夜av一区二区| 91玉足脚交白嫩脚丫在线播放| 欧美一区二区三区在线电影| 亚洲美女屁股眼交| 国产成人精品综合在线观看| 欧美日本国产一区| 亚洲天堂2016| 国产成人精品三级| 日韩一区二区在线免费观看| 一区二区三区不卡在线观看 | aaa欧美日韩| 精品国产免费人成电影在线观看四季 | 色久优优欧美色久优优| 久久久99免费| 六月婷婷色综合| 欧美日韩国产一级| 亚洲自拍另类综合| 不卡大黄网站免费看| 26uuu色噜噜精品一区二区| 亚洲高清免费在线| 91成人免费在线| 亚洲精品国久久99热| 成人午夜看片网址| 欧美韩国一区二区| 国产精品综合二区| 欧美精品一区在线观看| 久久精品国产99国产精品| 91精品在线免费观看| 午夜电影一区二区三区| 91久久精品一区二区三区| 亚洲私人黄色宅男| av亚洲精华国产精华| 18成人在线视频| 波多野结衣一区二区三区 | 三级影片在线观看欧美日韩一区二区| 91麻豆精品秘密| 亚洲欧美综合在线精品| av在线综合网| 日韩毛片高清在线播放| 一本久久精品一区二区| 一区二区三区高清不卡| 欧美亚洲国产怡红院影院| 一区二区在线电影| 欧美偷拍一区二区| 亚洲成人在线网站| 欧美高清你懂得| 免费成人在线观看视频| 欧美xxxx在线观看| 国产精品亚洲专一区二区三区 | 久久一夜天堂av一区二区三区 | 日韩午夜激情电影| 国产呦萝稀缺另类资源| 亚洲精品在线电影| 国产成人综合在线| 国产精品国产三级国产三级人妇| 成人av网站在线| 亚洲一区二区欧美日韩| 777精品伊人久久久久大香线蕉| 日韩国产精品久久| 久久尤物电影视频在线观看| 国产**成人网毛片九色| 亚洲色图欧美偷拍| 欧美群妇大交群中文字幕| 免费观看一级特黄欧美大片| 337p日本欧洲亚洲大胆精品| 成人高清视频免费观看| 亚洲一区自拍偷拍| 日韩一区二区在线观看视频| 成人性生交大片免费看在线播放| 亚洲私人影院在线观看| 在线播放日韩导航| 国产呦精品一区二区三区网站| 中文字幕亚洲电影| 欧美丰满高潮xxxx喷水动漫| 国产又黄又大久久| 一区二区高清视频在线观看| 6080亚洲精品一区二区| 国产精品亚洲第一| 一区二区三区丝袜| 精品精品国产高清a毛片牛牛 | 欧美xxx久久| aaa欧美日韩| 另类小说色综合网站| 1024精品合集| 日韩欧美久久一区| 不卡av在线免费观看| 青青草成人在线观看| 国产精品天美传媒| 7777精品伊人久久久大香线蕉完整版 | 久久精品亚洲麻豆av一区二区| 91在线一区二区| 蜜臀国产一区二区三区在线播放| 亚洲国产精品av| 欧美一区二区在线免费观看| jlzzjlzz欧美大全| 免费成人结看片| 亚洲精品高清视频在线观看| 久久久www成人免费毛片麻豆| 欧美性生活影院| 国产不卡在线播放| 日本伊人色综合网| 亚洲精品成人在线| 久久久精品欧美丰满| 91精品国产一区二区三区香蕉| 91丝袜美女网| 国产一区不卡在线| 肉色丝袜一区二区| 亚洲天堂网中文字| 国产欧美精品一区二区色综合朱莉| 欧美高清你懂得| 欧美影视一区在线| 丁香亚洲综合激情啪啪综合| 开心九九激情九九欧美日韩精美视频电影 | 国产精品每日更新在线播放网址| 欧美一区二区在线看| 91久久精品午夜一区二区| 国产99精品国产| 激情久久五月天| 免费在线观看成人| 午夜久久久久久久久| 自拍偷拍国产精品| 国产精品网站在线播放| 精品国免费一区二区三区| 在线不卡免费av| 欧美日韩美少妇| 91福利视频在线| 欧美做爰猛烈大尺度电影无法无天| 成人理论电影网| 国产91综合一区在线观看| 国产一区二区福利| 韩国在线一区二区| 精品制服美女丁香| 久久精品久久99精品久久| 日韩不卡在线观看日韩不卡视频| 婷婷综合久久一区二区三区| 亚洲影视在线播放| 亚洲一区二区av电影|