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

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

?? udldcfg.c

?? 工業組態軟件modbus驅動源代碼, 包括幫助文件.共享.
?? C
?? 第 1 頁 / 共 5 頁
字號:
    }               /* end - else (not first entry in table) */
} /* UdprotAddSymbol */

/***********************************************************************/
/** prepare WRITE message for indicated item and new value
    The client has sent data to be written to a point in the logical device.
    The message header and the new data are formatted and placed in the write
    buffer.  The message will be sent the next time UdprotPoll() is called by
    ProtTimerEvent().
    returns TRUE if successful **/

BOOL
WINAPI
UdprotPrepareWriteMsg (LPSTAT lpTopic,
                       SYMPTR lpSymEnt,
                       PTVALUE ptValue)
{
    SYMPTR          lpSymOld;
    LPSTR           lpData;
    LPUDMSG         lpMsg, lpFirstMsg;
    LPUDMSG         lpFoundMsg, lpAppendMsg;
    unsigned long   SymHandle;
    INTG            tmp, given_value;
    INTG            RegMin, RegMax;
    PTQUALITY       ptQuality;
    WORD            w[2];
    volatile REAL  *rp;
    volatile WORD  *wp;
    volatile INTG  *ip;
    BOOL            bIsStr = FALSE;
    int             iStrLen, iOutLen;
    LPSTR           lpszInStr;
    BYTE            pOutData[UD_MAX_WRITE_LENGTH];
    BOOL            ok, discrete, can_extend, changed;
    BOOL            folding, found, new_symbol;
    WORD            count, count_limit, numBytes, msgSize, allocSize;
    WORD            myAddr, endAddr;
    WORD            length, myOff;
    BYTE            plcDataType, subType;
    BYTE            msgType;
    BYTE            DDEType;
    int             numFound, found_index;
    BYTE FAR       *pByte;
    WORD            blockSize, extSize, message_limit;
    CHAINSCANNER    message_scanner;
	BYTE			plcAddr;

#ifdef DEBUG_CALL_TRAFFIC
    if (Verbose)
        debug("UdprotPrepareWriteMsg( %04lX, %04lX, %04lX )",
                (long) lpTopic, (long) lpSymEnt, (long) ptValue.intg);
#endif

    /* initialize return value */
    ok = TRUE;

    /* initialize default quality */
    ptQuality = WW_SQ_GOOD;

    /* get handle for symbol table entry */
    assert(lpSymEnt);
    SymHandle = lpSymEnt->msIndex + SYM_OFFSET;

    /* set type of data message, data from symbol table entry */
    plcDataType = (BYTE) lpSymEnt->msPlcDataType;
    DDEType     = (BYTE) lpSymEnt->msDdeType;
    subType     = (BYTE) lpSymEnt->msSubType;
    myAddr      = lpSymEnt->msAddr1;
    count       = lpSymEnt->msCount;
    endAddr     = (WORD) (myAddr + count - 1);
    numBytes    = (WORD) lpSymEnt->msNumBytes;
    discrete    = FALSE;
    msgType     = (BYTE) (plcDataType | 0x80);    /* device-specific */

    /* check whether write is possible */
    if (subType == PLCS_BITP) {
        /* cannot write bits in integer memory */
        return (FALSE);
    }

    /** ensure that data is correct for appropriate plcDataType, subType
        Note:  this depends on device, protocol defined point types, etc. **/

    switch (subType) {
        case PLCS_NONE:
        case PLCS_WORD:
        case PLCS_SIGNED:
        case PLCS_BCD:
            /* determine valid range */
            switch (subType) {
                case PLCS_SIGNED:
                    RegMin = -32768;
                    RegMax =  32767;
                    break;
                case PLCS_BCD:
                    RegMin = 0;
                    RegMax = 9999;
                    break;
                default:
                    RegMin = 0;
                    RegMax = 65535;
                    break;
            } /* switch */
            /* force new values to valid range */
            tmp = ptValue.intg;
            given_value = tmp;
            if (tmp < RegMin) {
                tmp = RegMin;
                ptQuality = WW_SQ_CLAMPLO;
            }
            if (tmp > RegMax) {
                tmp = RegMax;
                ptQuality = WW_SQ_CLAMPHI;
            }
            if (tmp != given_value) {
                if (ShowingErrors) {
                    /* have logger show error */
                    debug ("%s value %ld out of range for PlcDataType=%d, "
                               "Addr=0x%04lX, clamped to %ld.",
                           ((subType==PLCS_BCD) ? "BCD write" : "Write"),
                           (long) given_value, (int) plcDataType,
                           (long) myAddr, (long) tmp);
                }
            }
            if (subType == PLCS_BCD) {
                /* convert clamped binary value to BCD */
                ptValue.intg = (INTG) UdprotCvtBinToBCD ((WORD) tmp);
            } else {
                /* use clamped binary value */
                ptValue.intg = tmp;
            }
            if (ptQuality != WW_SQ_GOOD) {
                /* indicate data has been clamped at high or low end */
                DbNewVQFromDevice (lpTopic->statIdLogDev, lpSymEnt->msDbHnd,
                                   ptValue, ptQuality);
            }
            break;
        case PLCS_DWORD:
            /* swap words so they get output in the right order */
            ip = (INTG *) w;
            wp = (WORD *) &ptValue;
            w[1] = *(wp++);
            w[0] = *wp;
			// 3/10/2000 modify by Chen jun 
			{
			long dValue = w[0] * 65536 + w[1];
			w[0] = dValue%10000;
			w[1] = dValue/10000;
			}
			// modify end
            ptValue.intg = *ip;
            break;
        case PLCS_REAL:
            /* swap words so they get output in the right order */
            rp = (REAL *) w;
            wp = (WORD *) &ptValue;
			// 3/10/2000 modify by Chen jun 
            //w[1] = *(wp++);
            //w[0] = *wp;
            w[0] = *(wp++);
            w[1] = *wp;
			// modify end
            ptValue.real = *rp;
            break;
        case PLCS_STRC:
        case PLCS_STRP:
        case PLCS_STRB:
        case PLCS_STR_:
            /* indicate item is a string, get pointer to string buffer */
            bIsStr = TRUE;
            lpszInStr = StrValStringLock (ptValue);
            if (lpszInStr == (LPSTR) NULL)
            {
                return (FALSE);
            }
            /* ensure string is no longer than what we can transmit in one message */
            count_limit = LimitStringLength (myAddr, count, numBytes, FALSE);
            if (count_limit < count)
            {
                /* too long, truncate string to manageable length */
                count = count_limit;
                endAddr = (WORD) (myAddr + count - 1);
            }
            /* set up string data according to type */
            iStrLen = min (numBytes * count,
                           (WORD) (UD_MAX_WRITE_LENGTH - 1));
            /* check length of resulting string */
            if (iStrLen < (int) _fstrlen (lpszInStr)) {
                /* indicate string is truncated */
                ptQuality = WW_SQ_CLAMPHI;
                _fstrncpy ((LPSTR) pOutData, lpszInStr, (size_t) iStrLen);
                pOutData[iStrLen] = '\0';
                ptValue = StrValInitialString ((LPSTR) &pOutData[0]);
                DbNewVQFromDevice (lpTopic->statIdLogDev, lpSymEnt->msDbHnd,
                                   ptValue, ptQuality);
            }
            switch (subType)
            {
                case PLCS_STRC:
                    _fstrncpy ((LPSTR) pOutData, lpszInStr, (size_t) iStrLen);
                    pOutData[iStrLen - 1] = '\0';
                    break;
                case PLCS_STRP:
                    _fstrncpy ((LPSTR) &pOutData[1], lpszInStr,
                               (size_t) iStrLen - 1);
                    pOutData[iStrLen] = '\0';
                    pOutData[0] = (BYTE) strlen ((char *) &pOutData[1]);
                    break;
                case PLCS_STRB:
                case PLCS_STR_:
                    _fstrncpy ((LPSTR) pOutData, lpszInStr, (size_t) iStrLen);
                    iOutLen = strlen ((char *) pOutData);
                    if (iOutLen < iStrLen)
                    {
                        memset (&pOutData[iOutLen], ' ',
                                (size_t) (iStrLen - iOutLen));
                    }
                    break;
            } /* switch */
            /* Now swap the bytes so that when the message is built as words
               the chars will be in the right order */
            swab ((char *) pOutData, (char *) pOutData, (iStrLen + 1) & ~1);
            StrValStringUnlock (ptValue);
            break;
        default:
            /* no checking of data */
            break;
    } /* switch */

    /* copy ptValue to pOutData if data type was other than string */
    if (!bIsStr)
    {
        memcpy (pOutData, &ptValue, (size_t) sizeof (PTVALUE));
    }

    /*********************************************************************\
       There are two main ways write traffic may be reduced:
         1. Folded writes.
            When multiple writes to one particular data point have
            accumulated, send only the most recent data.
            Since the client may be toggling the point between two
            values, be sure that at least two values are sent.
            This is accomplished by replacing the data for an existing
            message with a more recent value for the point and then
            regenerating the message.
         2. Optimized writes.
            Instead of generating a new write message for each point
            extend a compatible existing message, if any.  This is
            accomplished by extending the data for an existing message
            with data for a new point and then regenerating the message.
       Note:  Optimized writes may or may not be possible, depending on
              the communication protocol for the device.  How to make
              the extension depends on such things as addressing modes
              and the partitioning of device memory.  Also, it is
              important to make sure that the extended message is not
              too long for the device protocol.

            Take care when locking and unlocking symbol table entries,
            especially if the protocol supports writes to multiple
            non-contiguous memory locations.  For example, if the message
            is only writing to points 1, 3, and 5 you should lock those
            points, but NOT points 2 and 4.  The same goes for unlocking
            when the message is deleted.

       The example code below is for a simulated device that permits
       reading and writing up to 22 consecutive memory locations of the
       same data type.  So a point is included if it is of the same
       plcDataType and falls within the address range mmStartAddr..mmEndAddr.
       And the message can be extended if it is of the same plcDataType and
       the point is just before or after the range mmStartAddr..mmEndAddr.
    \*********************************************************************/

    /* get lengths needed to write and extend a message for this point */
    GetBldMsgWriteBlockSizes (&blockSize, &extSize,
                              msgType, plcDataType, myAddr, count);

    /* get max length for message */
    message_limit = UD_MAX_MESSAGE_SIZE;

    /* get pointer to first message in write list */
    lpFirstMsg = (LPUDMSG) FindFirstItem (&lpTopic->statWriteMsgList,
                                          SCAN_FROM_HEAD,
                                          NULL, NULL, &message_scanner);

    /* initialize search variables */
    found = FALSE;
    lpFoundMsg = (LPUDMSG) NULL;
    lpAppendMsg = (LPUDMSG) NULL;
    numFound = 0;
    folding = FALSE;
    found_index = 0;

    /* try to find an existing message into which the write can be placed */
    lpMsg = lpFirstMsg;
    while ((lpMsg != (LPUDMSG) NULL) && (!found)) {
        /*********************************************************\
          We never modify the first message in the queue to
          prevent hanging up all of the write messages because
          of one point that is being written too frequently.
        \*********************************************************/
        /* check whether message includes the symbol of interest */
        if ((lpMsg->mmMsgType == msgType) &&
            (lpMsg->mmStartAddr <= myAddr) && (endAddr <= lpMsg->mmEndAddr)) {
            /* message includes this symbol, count number of matches found */
            /** There must be at least the minimum number of writes
                pending, so a point won't get stuck at one value
                when the client is trying to alternate values **/
            numFound++;
            /* check whether we can fold into this message */
            if ((lpMsg != lpFirstMsg) &&
                (numFound >= FOLDMIN)) {
                /* not first message, and we have found enough matches */
                /* indicate message found for folded write */
                found = TRUE;
                lpFoundMsg = lpMsg;
                folding = TRUE;
                found_index = myAddr - lpMsg->mmStartAddr;
            }
        }
        /* check for optimized write only if we haven't already found one */
        if ((!found) && (lpAppendMsg == (LPUDMSG) NULL) &&
            (lpMsg != lpFirstMsg)) {
            /* check whether we can append to this message */
            can_extend = (lpMsg->mmMsgType == msgType) &&
                         ((lpMsg->mmEndAddr+1 == myAddr) ||
                          (endAddr+1 == lpMsg->mmStartAddr));
            if (can_extend && (lpMsg->mmSize + extSize <= message_limit)) {
                /* save pointer to message for later */
                lpAppendMsg = lpMsg;
            }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品久久久久一区二区三区| 欧美一区二区三区电影| 国产精品情趣视频| thepron国产精品| |精品福利一区二区三区| 91麻豆免费看| 亚洲午夜视频在线观看| 欧美日韩日日夜夜| 美腿丝袜在线亚洲一区 | 91国偷自产一区二区开放时间 | 99久久精品国产麻豆演员表| 国产精品少妇自拍| 91亚洲大成网污www| 亚洲一区在线看| 日韩一区国产二区欧美三区| 九一九一国产精品| 中文字幕一区在线| 在线观看91av| 国产精品一二三四五| 日韩美女视频一区二区| 91精品在线免费观看| 国产精品亚洲第一区在线暖暖韩国 | 在线看不卡av| 麻豆成人91精品二区三区| 中文字幕第一页久久| 欧美日韩一区二区欧美激情| 国产久卡久卡久卡久卡视频精品| 自拍偷自拍亚洲精品播放| 欧美一区二区三区系列电影| 国产91高潮流白浆在线麻豆| 亚洲一区在线观看视频| 久久久精品一品道一区| 色94色欧美sute亚洲线路二 | 亚洲午夜精品17c| 精品国内二区三区| 91美女蜜桃在线| 精品伊人久久久久7777人| 日韩伦理av电影| 亚洲欧美日韩在线不卡| 91精品国产福利| 9人人澡人人爽人人精品| 美女国产一区二区| 亚洲综合无码一区二区| 中文字幕欧美三区| 欧美一级免费观看| 91久久线看在观草草青青| 国产一区二区三区在线观看精品| 亚洲尤物视频在线| 国产精品毛片大码女人| 日韩欧美国产综合在线一区二区三区| 9色porny自拍视频一区二区| 国产综合久久久久久久久久久久| 日韩一区欧美二区| 一区二区三区四区激情| 国产欧美日韩另类一区| 欧美tickling网站挠脚心| 欧美男人的天堂一二区| 色婷婷久久久综合中文字幕| 高清不卡一区二区| 国内外成人在线| 麻豆精品一二三| 日本成人中文字幕在线视频| 一级特黄大欧美久久久| 亚洲欧洲美洲综合色网| 国产三级一区二区三区| 久久久高清一区二区三区| 日韩精品一区二区三区在线| 欧美人动与zoxxxx乱| 欧美日韩一卡二卡三卡| 色综合天天综合色综合av| 国产成人免费视频网站| 黑人巨大精品欧美黑白配亚洲| 亚洲国产人成综合网站| 亚洲图片自拍偷拍| 亚洲自拍偷拍九九九| 亚洲免费毛片网站| 亚洲欧美欧美一区二区三区| 亚洲一卡二卡三卡四卡五卡| 亚洲黄色片在线观看| 中文字幕日韩一区| 亚洲免费观看在线视频| 亚洲一级在线观看| 婷婷成人激情在线网| 日韩av不卡一区二区| 日产精品久久久久久久性色| 日韩av一区二| 国内精品免费**视频| 狠狠色狠狠色综合| 国产永久精品大片wwwapp| 国产麻豆成人精品| 丁香网亚洲国际| 99热这里都是精品| 欧洲一区在线观看| 7777精品久久久大香线蕉 | 欧美一区二区三区免费视频| 欧美日韩三级视频| 久久综合一区二区| 26uuu欧美日本| 国产清纯在线一区二区www| 中文字幕中文在线不卡住| 亚洲自拍偷拍欧美| 美女视频免费一区| 成人综合婷婷国产精品久久蜜臀| www.久久精品| 色婷婷久久久久swag精品 | 亚洲国产成人午夜在线一区| 中文字幕一区二区三区不卡 | 久久精品国产在热久久| 国产大陆亚洲精品国产| 色av综合在线| 精品国产制服丝袜高跟| 亚洲欧洲精品天堂一级 | 国产欧美一区二区精品婷婷| 中文字幕亚洲在| 五月婷婷综合网| 国产成人精品1024| 欧美日韩高清影院| 国产亚洲女人久久久久毛片| 亚洲视频一区二区在线| 秋霞成人午夜伦在线观看| 国产91清纯白嫩初高中在线观看| 在线精品视频免费播放| 亚洲男人的天堂网| 日本免费新一区视频| 99精品国产视频| 精品少妇一区二区| 亚洲精品成人a在线观看| 久久精品国产第一区二区三区| 国产成人午夜电影网| 欧美精品九九99久久| 一区二区中文视频| 久久国产尿小便嘘嘘| 色呦呦国产精品| 久久午夜色播影院免费高清| 亚洲va在线va天堂| av电影在线不卡| 2欧美一区二区三区在线观看视频| 亚洲一区二区三区四区的| 成人激情黄色小说| 久久综合中文字幕| 另类中文字幕网| 欧美日韩免费在线视频| 亚洲精选在线视频| 成人一区二区视频| www国产亚洲精品久久麻豆| 午夜a成v人精品| 欧美私人免费视频| 1024成人网| 99久久国产综合色|国产精品| 欧美一区二区三区日韩视频| 性感美女极品91精品| 91视频免费播放| 中文字幕久久午夜不卡| 精品一区二区三区免费毛片爱| 欧美蜜桃一区二区三区| 亚洲永久精品大片| 在线精品视频免费播放| 亚洲精品水蜜桃| 97精品国产97久久久久久久久久久久| 中文字幕成人在线观看| 国产精品自产自拍| 国产亚洲精品精华液| 国产一区三区三区| 久久久91精品国产一区二区精品 | 精品日韩一区二区| 蜜臀久久99精品久久久画质超高清| 欧美在线free| 一区二区三区在线视频免费观看| 色综合天天在线| 亚洲男女一区二区三区| 99久久精品免费看国产免费软件| 国产精品私房写真福利视频| 顶级嫩模精品视频在线看| 中文字幕精品—区二区四季| a亚洲天堂av| 一区二区免费看| 欧美日韩免费观看一区二区三区| 亚洲妇熟xx妇色黄| 制服丝袜日韩国产| 国产一区二区伦理片| 国产视频视频一区| 91免费看片在线观看| 亚洲主播在线观看| 日韩你懂的在线播放| 国产成人一区在线| 国产精品传媒入口麻豆| 欧亚一区二区三区| 日本在线播放一区二区三区| 精品久久久久香蕉网| 成人免费观看视频| 亚洲精品高清在线| 欧美一区二区三区视频在线| 国产麻豆一精品一av一免费| 国产精品少妇自拍| 欧美日韩国产不卡| 国产一区二区三区免费播放| 国产精品欧美久久久久一区二区| 91视频在线观看| 理论片日本一区| 亚洲女同一区二区|