diff --git a/buban101.h b/buban101.h index 268b6a4..6622dda 100644 --- a/buban101.h +++ b/buban101.h @@ -79,7 +79,7 @@ //ת·¢¸÷ÖÖÀàÐ͵ÄÊý¾ÝµÄ×î´óÊýÁ¿ #define MAX_AINUM 120 -#define MAX_FLOATAINUM 48 +#define MAX_FLOATAINUM 9 #define MAX_DINUM 127 #define MAX_PINUM 35 @@ -237,7 +237,7 @@ void Buban101ProvMakeYkYtCommand(int commid, u_char *buf, int len); /////////////////////////ͨÓú¯ÊýÖ§³Ö½Ó¿Ú½áÊø/////////////////////////// ///////////////////////////ÒÔÏÂΪָÁîÉú³Éº¯Êý/////////////////////////// -//Éú³É Buban101 ÃüÁîë +//Éú³É Buban101 ÃüÁî? void MakeBuban101Command(u_32 commid, u_char cmdidx); //Éú³ÉÒ£¿ØÒ£µ÷Ö¸Áî void MakeBuBan101YkYtCommand(u_32 commid, u_char *buf, int len); diff --git a/buban104.cpp b/buban104.cpp index 7561e35..caca5eb 100644 --- a/buban104.cpp +++ b/buban104.cpp @@ -1215,7 +1215,7 @@ void Buban104FindNextProvCmd(int commid) //====================================================== if(pPortParam->lTimeOutSendTest) { - MakeBuban104Command(commid, FORMAT_U_TEST_ACT); + ;//MakeBuban104Command(commid, FORMAT_U_TEST_ACT); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++ pPortParam->lTimeOutCnt = 0; @@ -1247,7 +1247,7 @@ void Buban104FindNextProvCmd(int commid) if(pPortParam->Initdata) { // Ò»ÀàÊý¾Ý( Ò£Ðűäλ ) - ProvBuban104SendClass1(commid); + //ProvBuban104SendClass1(commid); if(CheckPollCmdBufEmpty(commid) <= 0) { pPortParam->m_lNoDataCnt = 0; @@ -1255,7 +1255,7 @@ void Buban104FindNextProvCmd(int commid) } // ת·¢soeÊý¾Ý - ProvBuban104SendSoe(commid); + //ProvBuban104SendSoe(commid); if(CheckPollCmdBufEmpty(commid) <= 0) { pPortParam->m_lNoDataCnt = 0; @@ -1267,14 +1267,14 @@ void Buban104FindNextProvCmd(int commid) // wen 2006.03.23 Ö§³Ö¸¡µãÊýÒ£²âµÄ´«ËÍ //ProvBuban104SendClass2(commid); //==================================================================== - if(pPortParam->m_bProvAiType == 13) + /*if(pPortParam->m_bProvAiType == 13) { ProvBuban104SendClass2withFloat(commid); } else { ProvBuban104SendClass2(commid); - } + }*/ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ if(CheckPollCmdBufEmpty(commid) <= 0) @@ -1298,7 +1298,7 @@ void Buban104FindNextProvCmd(int commid) if(pPortParam->m_lNoDataCnt >= pPortParam->lTimeOutConst) { pPortParam->m_lNoDataCnt = 0; - MakeBuban104Command(commid, FORMAT_U_TEST_ACT); + //MakeBuban104Command(commid, FORMAT_U_TEST_ACT); } } //++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -3068,7 +3068,7 @@ void ProvBuban104FormatI(int commid, RTUMSG *rtumsg) break; case 103: // ʱ¼äͬ²½È·ÈÏÖ¡ - ProvBuban104ProcessTime(commid, rtumsg); + //ProvBuban104ProcessTime(commid, rtumsg); break; } } @@ -3189,7 +3189,7 @@ void ProvBuban104SendAllData(int commid, RTUMSG * rtumsg) iCmdType = FAST_POLL_CMD; //×ÜÕÙ»½Ó¦´ð - commandbuf[0] = 0x68; + /*commandbuf[0] = 0x68; iLen = 2; commandbuf[iLen++] = 0; commandbuf[iLen++] = 0; @@ -3204,27 +3204,44 @@ void ProvBuban104SendAllData(int commid, RTUMSG * rtumsg) commandbuf[iLen++] = 0; // ÐÅÏ¢ÐòºÅINF commandbuf[iLen++] = 0; // ɨÃèÐòºÅSCN commandbuf[1] = (BYTE)(iLen - 2); - PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLen); + PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLen);*/ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // wen 2006.03.23 Ö§³Ö¸¡µãÊýÒ£²âµÄ´«ËÍ //ProvBuban104SendAI(commid, rtumsg, 0); //==================================================================== - if(pPortParam->m_bProvAiType == 13) + //if(pPortParam->m_bProvAiType == 13) { ProvBuban104SendAIwithFloat(commid, rtumsg, 0); } - else + /*else { ProvBuban104SendAI(commid, rtumsg, 0); - } + }*/ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - ProvBuban104SendDI(commid, rtumsg, 0); - + //ProvBuban104SendDI(commid, rtumsg, 0); + memset(&commandbuf, 0, sizeof(commandbuf)); //×ÜÕÙ»½½áÊø - ProvMakeBuban104Command(commid, ASK_ALLDATA_END); + commandbuf[0] = 0x68; + iLen = 2; + commandbuf[iLen++] = 0; + commandbuf[iLen++] = 0; + commandbuf[iLen++] = 0; + commandbuf[iLen++] = 0; + commandbuf[iLen++] = 8; // Ó¦´ð×ÜÕÙ½áÊø + commandbuf[iLen++] = 0x81; // ÏÞ¶¨´ÊVSQ + commandbuf[iLen++] = 9; // ´«ËÍÔ­Òò + commandbuf[iLen++] = 0; // Ó¦Ó÷þÎñµ¥Ôª¹«¹²µØÖ· + commandbuf[iLen++] = 0; // Ó¦Ó÷þÎñµ¥Ôª¹«¹²µØÖ· + commandbuf[iLen++] = 0xFF; // ¹¦ÄÜÀàÐÍFUN + commandbuf[iLen++] = 0; // ÐÅÏ¢ÐòºÅINF + commandbuf[iLen++] = 0; // ɨÃèÐòºÅSCN + commandbuf[1] = (BYTE)(iLen - 2); + PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLen); + + //ProvMakeBuban104Command(commid, ASK_ALLDATA_END); pPortParam->m_psBaoHu->DiChange = FALSE; pPortParam->Initdata = TRUE; } @@ -4574,10 +4591,11 @@ typedef struct } DAY_TIME; ·µ»ØÖµ1£º³É¹¦È¡Öµ -1£ºÈ¡ÖµÊ§°Ü */ -int GetAIPntMsg(int j, int *igno, int* iItemNo, DAY_TIME* sCurTime, float* pfValue) +int GetAIPntMsg(int j, int *igno, int* iItemNo, DAY_TIME* sCurTime, float* pfValue, int *iaddr) { *igno = 1; *iItemNo = 1; + *iaddr = 1; sCurTime->Hour = 12; sCurTime->Min = 30; sCurTime->Month = 11; @@ -4592,8 +4610,8 @@ int GetAIPntMsg(int j, int *igno, int* iItemNo, DAY_TIME* sCurTime, float* pfVal void ProvBuban104SendAIwithFloat(int commid, RTUMSG *rtumsg, int iGroupNo) { char commandbuf[MAX_POLLCMD_BUF_LEN]; - DWORD dwStartAddr; - int iLenth, iSendCount=1; + //DWORD dwStartAddr; + int iLenth, iSendCount=1, iaddr0=1, iaddr1=1; int i, j, iAllDataCount, iSendNum,flag; int iNo, iCmdType, igno,iItemNo; float *pfValue; @@ -4608,13 +4626,13 @@ void ProvBuban104SendAIwithFloat(int commid, RTUMSG *rtumsg, int iGroupNo) if( iGroupNo == 0 )//×ÜÕÙ»½ { - dwStartAddr = MAX_GROUP_AINUM*iGroupNo + pPortParam->iAiBaseAddr; + //dwStartAddr = MAX_GROUP_AINUM*iGroupNo + pPortParam->iAiBaseAddr; iAllDataCount = pPortParam->m_psBaoHu->AiNum; iCmdType = FAST_POLL_CMD; } - aiprovptr = (PROV_AI_PNT *)pPortParam->m_psBaoHu->AiPtr; + //aiprovptr = (PROV_AI_PNT *)pPortParam->m_psBaoHu->AiPtr; for( i = 0; i < iAllDataCount; i++ ) { memset(commandbuf, 0, sizeof(commandbuf)); @@ -4633,23 +4651,35 @@ void ProvBuban104SendAIwithFloat(int commid, RTUMSG *rtumsg, int iGroupNo) commandbuf[13] = 0; // ·µ»ØÐÅÏ¢±êʶÂëRII //Ò£²âÖµ - if(iAllDataCount > MAX_FLOATAINUM) + if(iAllDataCount-i > MAX_FLOATAINUM) { iSendNum = MAX_FLOATAINUM; commandbuf[14] = (iSendNum & 0x80); // ͨÓ÷ÖÀàÊý¾Ý¼¯ÊýÄ¿NGD } else { - iSendNum = iAllDataCount; + iSendNum = iAllDataCount-i; commandbuf[14] = iSendNum; // ͨÓ÷ÖÀàÊý¾Ý¼¯ÊýÄ¿NGD } iNo = i; iLenth = 15; - for( j = iNo; j < iNo+iSendNum; j++ ) + for( j = 0; j < iSendNum; j++ ) { pfValue = (float *)&commandbuf[iLenth+14]; - flag = GetAIPntMsg(j, &igno, &iItemNo, &sCurTime, pfValue); + flag = GetAIPntMsg(j+iNo, &igno, &iItemNo, &sCurTime, pfValue, &iaddr1); + if (0 == flag) + break; + if (iaddr1 == iaddr0) + ; + else + { + iaddr0 = iaddr1; + if (15 == iLenth) + ; + else + break; + } commandbuf[iLenth] = igno; commandbuf[iLenth++] = iItemNo; commandbuf[iLenth++] = 1; // ÃèÊöÀà±ðKOD£¨Êµ¼ÊÖµ£© @@ -4669,11 +4699,23 @@ void ProvBuban104SendAIwithFloat(int commid, RTUMSG *rtumsg, int iGroupNo) //iLenth += sizeof(float); //commandbuf[iLenth++] = 0; } + if (15 == iLenth) + break; + commandbuf[9] = (u_char)iaddr0; // + commandbuf[10] = (u_char)(iaddr0 >> 8); // Ó¦Ó÷þÎñÊý¾Ýµ¥Ôª¹«¹²µØÖ· + i += j; if (flag = -1) + { i = iAllDataCount; + } + if(i >= iAllDataCount) + { + commandbuf[14] = j; // ͨÓ÷ÖÀàÊý¾Ý¼¯ÊýÄ¿NGD + } else - i += iSendNum; + commandbuf[14] = (j & 0x80); // ͨÓ÷ÖÀàÊý¾Ý¼¯ÊýÄ¿NGD + commandbuf[1] = (char)(iLenth-2); PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLenth);