|
|
|
|
//***************************************************************
|
|
|
|
|
//* buban104.cpp *
|
|
|
|
|
//* aaawen 2005.09.14 *
|
|
|
|
|
//***************************************************************
|
|
|
|
|
//_DEBUG_MSG_,_OS_WINDOWS_DEBUG_
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include "commport.h"
|
|
|
|
|
// #include "baohulib/serialport.h"
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
#include "commport.h"
|
|
|
|
|
#include "udpcomm.h"
|
|
|
|
|
#include "display.h"
|
|
|
|
|
#endif
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include "buban101.h"
|
|
|
|
|
#include "buban104.h"
|
|
|
|
|
#include "scadaprotect.h"
|
|
|
|
|
|
|
|
|
|
extern SIO_PARAM_DEF SioParam[];
|
|
|
|
|
extern FUNCTION_CALL *FunCallPtr;
|
|
|
|
|
extern void *pvconf_handle;
|
|
|
|
|
extern void *pvportconf_handle;
|
|
|
|
|
extern void *pvdataconf_handle;
|
|
|
|
|
extern char pvDataFileName[256];
|
|
|
|
|
extern char IniFilePath[256];
|
|
|
|
|
|
|
|
|
|
const char *gpStrBuban104Cmd[BUBAN104_TIMER_CMD_NUM] =
|
|
|
|
|
{
|
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|
|
|
|
"<EFBFBD>ٻ<EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|
|
|
|
"֡<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
<EFBFBD><EFBFBD>֯<EFBFBD>ṹ:<EFBFBD><EFBFBD>·(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>)+װ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
const char *gpStrBuban104ConfigInfo[] =
|
|
|
|
|
{
|
|
|
|
|
" ; ***** <20><><EFBFBD><EFBFBD>104<30><34>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *****",
|
|
|
|
|
" ",
|
|
|
|
|
" ; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>λ,<2C><><EFBFBD><EFBFBD>Ϊxx.xxx<78>롣",
|
|
|
|
|
" ; ע<><D7A2>:104<30><34>Լֻ֧<D6BB><D6A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨѶ,<2C><>Ϊ<EFBFBD><CEAA>վʱ<D5BE>ǿͻ<C7BF><CDBB><EFBFBD>ʽ,<2C><>Ϊ<EFBFBD><CEAA>վʱ<D5BE>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>",
|
|
|
|
|
" ; <20><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD> = 2404<30><34>",
|
|
|
|
|
" վ<><D5BE>ַ = 1 ; ȱʡ= 0 <20><>",
|
|
|
|
|
" <20><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = 120",
|
|
|
|
|
" <20>ٻ<EFBFBD><D9BB><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = 300",
|
|
|
|
|
" ֡<><D6A1>Ӧ<EFBFBD><D3A6> = 20",
|
|
|
|
|
" ; <20>ڶԷ<DAB6><D4B7><EFBFBD>ʱʱ<CAB1><CAB1>֮<EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD>֡<EFBFBD><D6A1>Ӧ<EFBFBD><D3A6>֡<EFBFBD><D6A1>",
|
|
|
|
|
" <20><>ʱʱ<CAB1><CAB1> = 3.0",
|
|
|
|
|
//" ת<><D7AA><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ʱʱ<CAB1><CAB1> = 10.0",
|
|
|
|
|
" ת<><D7AA><EFBFBD>Ƿ<EFBFBD>Ҫ<EFBFBD><D2AA>Ӧ<EFBFBD><D3A6> = 0",
|
|
|
|
|
" <20><>ʱ<EFBFBD><CAB1><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>֡ = 0",
|
|
|
|
|
" ; =0<><30><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2>Ա<EFBFBD><D4B1>Ķ<EFBFBD><C4B6><EFBFBD>֡<EFBFBD><D6A1>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(ȱʡֵ)<29><>=1<><31><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2>Ա<EFBFBD><D4B1><EFBFBD>",
|
|
|
|
|
" ң<>ط<EFBFBD>ʽ=0",
|
|
|
|
|
" ; =0<><30>˫<EFBFBD><CBAB>ң<EFBFBD><D2A3>(ȱʡ)<29><>=1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD>ء<EFBFBD>",
|
|
|
|
|
" ",
|
|
|
|
|
" ң<><D2A3><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ=0x701",
|
|
|
|
|
" ң<><D2A3><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ=0x001",
|
|
|
|
|
" ң<><D2A3><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ=0xC01",
|
|
|
|
|
" ң<><D2A3><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ=0xB01",
|
|
|
|
|
" ;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ȱʡֵΪ97<39>沿<EFBFBD><E6B2BF>104<30><34><EFBFBD>涨ֵ",
|
|
|
|
|
" ",
|
|
|
|
|
" ֡<><D6A1>Ӧ<EFBFBD><D3A6><EFBFBD>ߴ<EFBFBD>=2",
|
|
|
|
|
" ",
|
|
|
|
|
" <20>汾<EFBFBD><E6B1BE> = 1",
|
|
|
|
|
" ;=0 <20><>buban104(ȱʡֵ); =1 <20><>IEC_870_5_104<30><34>Լ",
|
|
|
|
|
" <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>=2000",
|
|
|
|
|
" ;=1997; =2000(ȱʡֵ)",
|
|
|
|
|
" ת<><D7AA>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD>ʶ = 21",
|
|
|
|
|
" ",
|
|
|
|
|
"*******<2A><><EFBFBD><EFBFBD>104<30><34>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>*******",
|
|
|
|
|
"", // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־(<28>м䲻<D0BC>ܺ<EFBFBD><DCBA>иÿ<D0B8><C3BF>ַ<EFBFBD><D6B7><EFBFBD>)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//********************************************************************
|
|
|
|
|
//* <20><>ȡ<EFBFBD><C8A1><EFBFBD>ú<EFBFBD><C3BA><EFBFBD> *
|
|
|
|
|
//*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>int commid : <20>˿ں<CBBF> *
|
|
|
|
|
//********************************************************************
|
|
|
|
|
void Buban104ReadConfig(int commid)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
char szSection[128], szbuf[128];
|
|
|
|
|
char szPortConfig[256];
|
|
|
|
|
pBUBAN104PORTPARAM pPortParam;
|
|
|
|
|
|
|
|
|
|
#ifdef OS_LINUX
|
|
|
|
|
strcpy(szPortConfig, "portconfig.ini");
|
|
|
|
|
#else
|
|
|
|
|
//GetCurrentDirectory(sizeof(szDir), szDir);
|
|
|
|
|
sprintf(szPortConfig, "%s/portconfig.ini", IniFilePath);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
SioParam[commid].ExtInfo = HEAP_MALLOC(sizeof(BUBAN104PORTPARAM));
|
|
|
|
|
|
|
|
|
|
if(!SioParam[commid].ExtInfo)
|
|
|
|
|
{
|
|
|
|
|
sprintf(szbuf, "WARN(%04d): commid_%02d ExtInfo=malloc(%d) failed.\n",
|
|
|
|
|
_getpid(), commid, sizeof(BUBAN104PORTPARAM));
|
|
|
|
|
DebugPrint(szbuf);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset(SioParam[commid].ExtInfo, 0, sizeof(BUBAN104PORTPARAM));
|
|
|
|
|
|
|
|
|
|
pPortParam = (pBUBAN104PORTPARAM)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
/* ֻ<><D6BB><EFBFBD><EFBFBD>SioParam[commid].m_psBaoHu<48>ǿ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
pPortParam->m_psBaoHu = SioParam[commid].m_psBaoHu;
|
|
|
|
|
|
|
|
|
|
sprintf(szSection, "Port%d", commid+1);
|
|
|
|
|
|
|
|
|
|
if(GetPrivateProString(szSection, "վ<EFBFBD><EFBFBD>ַ", "0", szbuf, 120, szPortConfig) > 0)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->wLinkAddr = atoi(szbuf);
|
|
|
|
|
}
|
|
|
|
|
// <20><>ѯָ<D1AF><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
for(i=0; i<BUBAN104_TIMER_CMD_NUM; i++)
|
|
|
|
|
{
|
|
|
|
|
GetPrivateProString(szSection, (char *)gpStrBuban104Cmd[i], "0", szbuf, 120, szPortConfig);
|
|
|
|
|
pPortParam->CmdTime[i].CmdTimerConst = (long)(atof(szbuf)*1000/TIMER_CNT);
|
|
|
|
|
if(pPortParam->CmdTime[i].CmdTimerConst > 5)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->CmdTime[i].CmdTimerCnt = pPortParam->CmdTime[i].CmdTimerConst - 5;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(GetPrivateProString(szSection, "<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD>", "20.0", szbuf, 120, szPortConfig) > 0)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->lTimeOutConst = (long)(atof(szbuf)*1000/TIMER_CNT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortParam->ProvAckOrNot = GetPrivateProInt(szSection, "ת<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ҫ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>", 0, szPortConfig);
|
|
|
|
|
if(pPortParam->ProvAckOrNot > 0)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->ProvAckOrNot = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pPortParam->ProvAckOrNot = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// wen 2005.10.28 <20>ij<DEB8>ʱʱ<CAB1>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2>Ա<EFBFBD><D4B1><EFBFBD>
|
|
|
|
|
pPortParam->lTimeOutSendTest = GetPrivateProInt(szSection, "<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><EFBFBD><EFBFBD>֡", 0, szPortConfig);
|
|
|
|
|
|
|
|
|
|
if(GetPrivateProString(szSection, "ң<EFBFBD>ط<EFBFBD>ʽ", "0", szbuf, 120, szPortConfig) > 0)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->YkMode = atoi(szbuf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortParam->iAiBaseAddr = GetPrivateProInt(szSection, "ң<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ", INFO_AI_BASEADDR, szPortConfig);
|
|
|
|
|
pPortParam->iDiBaseAddr = GetPrivateProInt(szSection, "ң<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ", INFO_DI_BASEADDR, szPortConfig);
|
|
|
|
|
pPortParam->iPiBaseAddr = GetPrivateProInt(szSection, "ң<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ", INFO_PI_BASEADDR, szPortConfig);
|
|
|
|
|
pPortParam->iYkBaseAddr = GetPrivateProInt(szSection, "ң<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ", INFO_YKYT_BASEADDR, szPortConfig);
|
|
|
|
|
|
|
|
|
|
pPortParam->m_iFrameSize = GetPrivateProInt(szSection, "֡<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD>", MAX_FRAMEMATCHING_SIZE, szPortConfig);
|
|
|
|
|
|
|
|
|
|
pPortParam->RtuVersion = GetPrivateProInt(szSection, "<EFBFBD>汾<EFBFBD><EFBFBD>", 0, szPortConfig);
|
|
|
|
|
pPortParam->m_iPublishYear = GetPrivateProInt(szSection, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>", 2000, szPortConfig);
|
|
|
|
|
|
|
|
|
|
pPortParam->m_bProvAiType = GetPrivateProInt(szSection, "ת<EFBFBD><EFBFBD>ң<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD>ʶ", 13, szPortConfig);
|
|
|
|
|
|
|
|
|
|
InitBuban104CommandBuffer(commid);
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//********************************************************************
|
|
|
|
|
//* <20><>ȡ<EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD>ݺ<EFBFBD><DDBA><EFBFBD> *
|
|
|
|
|
//*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>int commid : <20>˿ں<CBBF> *
|
|
|
|
|
//* u_char buf : <20><><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8> *
|
|
|
|
|
//* int len : <20><><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD> *
|
|
|
|
|
//********************************************************************
|
|
|
|
|
void Buban104RecvData(int commid, u_char *buf, int len)// <20><>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
pBUBAN104PORTPARAM pPortParam;
|
|
|
|
|
#ifdef _DEBUG_MSG_
|
|
|
|
|
char szbuf[256];
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if(!IsExtInfoPtr(commid))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
pPortParam = (pBUBAN104PORTPARAM)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
for(i=0; i<len; i++)
|
|
|
|
|
{
|
|
|
|
|
switch(pPortParam->m_psBaoHu->m_iRevStatus)
|
|
|
|
|
{
|
|
|
|
|
case 0:// 0x10 / 0x68
|
|
|
|
|
pPortParam->m_iRecvLen = 0;
|
|
|
|
|
if(buf[i] == 0x68)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_psBaoHu->m_iRevStatus++;
|
|
|
|
|
pPortParam->m_au8RecvBuf[pPortParam->m_iRecvLen++] = buf[i];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_psBaoHu->m_iRevStatus = 100;
|
|
|
|
|
pPortParam->m_au8RecvBuf[pPortParam->m_iRecvLen++] = buf[i];
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 1:// length
|
|
|
|
|
pPortParam->m_au8RecvBuf[pPortParam->m_iRecvLen++] = buf[i];
|
|
|
|
|
pPortParam->m_psBaoHu->m_iNeedRevLength = buf[i];
|
|
|
|
|
if(pPortParam->m_psBaoHu->m_iNeedRevLength <= 0)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_psBaoHu->m_iRevStatus = 100;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_psBaoHu->m_iRevStatus++;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:// <20><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
pPortParam->m_psBaoHu->m_iNeedRevLength--;
|
|
|
|
|
pPortParam->m_au8RecvBuf[pPortParam->m_iRecvLen++] = buf[i];
|
|
|
|
|
if(pPortParam->m_psBaoHu->m_iNeedRevLength > 0)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
Buban104ProcessData(commid, pPortParam, TRUE);
|
|
|
|
|
pPortParam->m_psBaoHu->m_iRevStatus = 0;
|
|
|
|
|
pPortParam->m_psBaoHu->RevCmdFlag = 1;
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
if((GetCurPort() == commid) && IsRealDataDisp())
|
|
|
|
|
{
|
|
|
|
|
WatchDataPutDispBuf(commid, SDS_SIO_RECV_DATA,
|
|
|
|
|
(BYTE *)pPortParam->m_au8RecvBuf, pPortParam->m_iRecvLen);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
//pPortParam->LinkOkCnt = 0;
|
|
|
|
|
break;
|
|
|
|
|
case 100:// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
default:
|
|
|
|
|
if(buf[i] == 0x68)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
// wen 2004.11.22 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
if((GetCurPort() == commid) && IsRealDataDisp())
|
|
|
|
|
{
|
|
|
|
|
WatchDataPutDispBuf(commid, SDS_SIO_RECV_DATA,
|
|
|
|
|
(BYTE *)pPortParam->m_au8RecvBuf, pPortParam->m_iRecvLen);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
Buban104ProcessData(commid, pPortParam, FALSE);
|
|
|
|
|
SioParam[commid].ErrMsgNum += pPortParam->m_iRecvLen;
|
|
|
|
|
pPortParam->m_psBaoHu->m_iRevStatus = 1;
|
|
|
|
|
pPortParam->m_iRecvLen = 1;
|
|
|
|
|
pPortParam->m_au8RecvBuf[0] = buf[i];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_au8RecvBuf[pPortParam->m_iRecvLen++] = buf[i];
|
|
|
|
|
if(pPortParam->m_iRecvLen > 200)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
// wen 2004.11.22 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
if((GetCurPort() == commid) && IsRealDataDisp())
|
|
|
|
|
{
|
|
|
|
|
WatchDataPutDispBuf(commid, SDS_SIO_RECV_DATA,
|
|
|
|
|
(BYTE *)pPortParam->m_au8RecvBuf, pPortParam->m_iRecvLen);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
Buban104ProcessData(commid, pPortParam, FALSE);
|
|
|
|
|
SioParam[commid].ErrMsgNum += pPortParam->m_iRecvLen;
|
|
|
|
|
pPortParam->m_iRecvLen = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG_MSG_
|
|
|
|
|
sprintf(szbuf, "wen: commid = %d, send=%d, recv=%d, error=%d, lost=%d\n", commid,
|
|
|
|
|
SioParam[commid].SendCharNum, SioParam[commid].RecvCharNum,
|
|
|
|
|
SioParam[commid].ErrMsgNum, SioParam[commid].LostSyncCnt);
|
|
|
|
|
DebugPrint(szbuf);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//********************************************************************
|
|
|
|
|
//* <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *
|
|
|
|
|
//*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>int commid : <20>˿ں<CBBF> *
|
|
|
|
|
//********************************************************************
|
|
|
|
|
void Buban104Timer(int commid)
|
|
|
|
|
{
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
if(IsExtInfoPtr(commid) == FALSE)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortParam = (pBUBAN104PORTPARAM)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(pPortParam->LinkOk)
|
|
|
|
|
{
|
|
|
|
|
// <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|
|
|
|
pPortParam->lTimeOutCnt++;
|
|
|
|
|
}
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>Ϊת<CEAA><D7AA><EFBFBD>˿ڣ<CBBF><DAA3><EFBFBD><F2B2BBBD><EFBFBD><EFBFBD><EFBFBD>ѯָ<D1AF><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɡ<EFBFBD>
|
|
|
|
|
if(PROTOCOL_SLAVE != pPortParam->m_psBaoHu->PortType)
|
|
|
|
|
{
|
|
|
|
|
Buban104FindNextCmd(commid);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Buban104FindNextProvCmd(commid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Buban104SendCmdFormPollCmdBuf(commid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//********************************************************************
|
|
|
|
|
//* ң<><D2A3>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *
|
|
|
|
|
//*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>int commid : <20>˿ں<CBBF> *
|
|
|
|
|
//* u_char buf : <20><><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8> *
|
|
|
|
|
//* int len : <20><><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD> *
|
|
|
|
|
//********************************************************************
|
|
|
|
|
void Buban104YkYtProcess(int commid, u_char *buf, int len) // ң<><D2A3>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int portno, ykytpnt;
|
|
|
|
|
int iDirect;
|
|
|
|
|
|
|
|
|
|
// buf[0] --- <20>˿ں<CBBF>(=commid)
|
|
|
|
|
// buf[1]
|
|
|
|
|
// buf[2]
|
|
|
|
|
// buf[3]
|
|
|
|
|
// buf[4] --- <20>ص<EFBFBD><D8B5><EFBFBD>
|
|
|
|
|
// buf[5]
|
|
|
|
|
// buf[6]
|
|
|
|
|
// buf[7]
|
|
|
|
|
// buf[8] --- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(ң<><D2A3>:1=ѡ<><D1A1>,2=ִ<><D6B4>,3=ȡ<><C8A1>,7=ֱ<><D6B1>;
|
|
|
|
|
// ң<><D2A3>:4=ѡ<><D1A1>,5=ִ<><D6B4>,6=ȡ<><C8A1>,8=<3D><>ͣ)
|
|
|
|
|
// buf[9] --- <20><><EFBFBD><EFBFBD>״̬(1=<3D>ֵ<EFBFBD><D6B5>ϣ<EFBFBD>2=<3D>ϵ<EFBFBD><CFB5><EFBFBD>)
|
|
|
|
|
// (<28><><EFBFBD><EFBFBD>λΪ1ʱ<31><CAB1>Ϊ<EFBFBD><CEAA>У<EFBFBD><D0A3><EFBFBD><EFBFBD>, 1=<3D>غ<EFBFBD>, 2=<3D>ط<EFBFBD>, 3=ʧ<><CAA7>)
|
|
|
|
|
// <20><>ת<EFBFBD><D7AA>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>У<EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫת<D2AA><D7AA><EFBFBD>Ŀص<C4BF><D8B5>ţ<EFBFBD>ʵ<EFBFBD>ʵĶ˿ں<CBBF>Ӧ<EFBFBD><D3A6><EFBFBD>Ǹ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>Ķ˿<C4B6>
|
|
|
|
|
// <20><>ת<EFBFBD><D7AA><EFBFBD>㲢û<E3B2A2><C3BB>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ص㣬<D8B5><E3A3AC><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>һ<EFBFBD>¡<EFBFBD>
|
|
|
|
|
|
|
|
|
|
if(IsExtInfoPtr(commid) == FALSE)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iDirect = buf[9] & 0x80;
|
|
|
|
|
portno = buf[0]+buf[1]*256+buf[2]*65536+buf[3]*16777216;
|
|
|
|
|
ykytpnt = buf[4]+buf[5]*256+buf[6]*65536+buf[7]*16777216;
|
|
|
|
|
|
|
|
|
|
// <20><>У<EFBFBD><D0A3>Ϣ(<28><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>)
|
|
|
|
|
if(iDirect)
|
|
|
|
|
{
|
|
|
|
|
Buban104ProvMakeYkYtCommand(commid, buf, len);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MakeBuBan104YkYtCommand(commid, buf, len);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//********************************************************************
|
|
|
|
|
//* ϵͳ<CFB5>·<EFBFBD><C2B7><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> *
|
|
|
|
|
//*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>int commid : <20>˿ں<CBBF> *
|
|
|
|
|
//********************************************************************
|
|
|
|
|
void Buban104SendSystemTime(int commid) // ϵͳ<CFB5><CDB3>ʱ
|
|
|
|
|
{
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
if(IsExtInfoPtr(commid) == FALSE)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(2 != pPortParam->m_psBaoHu->CheckTime)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(pPortParam->Initdata)
|
|
|
|
|
{
|
|
|
|
|
if(PROTOCOL_SLAVE != pPortParam->m_psBaoHu->PortType)
|
|
|
|
|
{
|
|
|
|
|
MakeBuban104Command(commid, RTU_TIME);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//********************************************************************
|
|
|
|
|
//* ϵͳ<CFB5>˳<EFBFBD>ʱ<EFBFBD><CAB1>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *
|
|
|
|
|
//*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>int commid : <20>˿ں<CBBF> *
|
|
|
|
|
//********************************************************************
|
|
|
|
|
void Buban104Exit(int commid)
|
|
|
|
|
{
|
|
|
|
|
// <20>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>˿<EFBFBD><CBBF>·<EFBFBD><C2B7><EFBFBD>ʵ<EFBFBD><CAB5>װ<EFBFBD>õı<C3B5><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void Buban104BaoHuCmdProcess(int commid, RTUMSG *rtumsg, BOOL bUpData)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Buban104GetBaohuDataBase(int commid, int iProvAddr, GROUPDEF **ppBaoHuDB)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
/////////////////////////ͨ<>ú<EFBFBD><C3BA><EFBFBD><EFBFBD>ӿڽ<D3BF><DABD><EFBFBD>///////////////////////////////
|
|
|
|
|
|
|
|
|
|
/////////////////////////buban104<30><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>///////////////////////////
|
|
|
|
|
//ָ<><EFBFBD><EEBBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
void InitBuban104CommandBuffer(int commid)
|
|
|
|
|
{
|
|
|
|
|
pBUBAN104PORTPARAM pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (pBUBAN104PORTPARAM)SioParam[commid].ExtInfo;
|
|
|
|
|
pPortParam->LinkOk = false;
|
|
|
|
|
|
|
|
|
|
// wen 2005.09.15 <20><><EFBFBD>ñ<EFBFBD>ʶ<EFBFBD><EFBFBD>Ϊtrue<75><65><EFBFBD><EFBFBD>
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>վ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٵ<EFBFBD><D9B5>ȺὫ<F3A3ACBB><E1BDAB><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6>Ϊfalse<73><65>
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>վ<EFBFBD>˲<EFBFBD><CBB2><EFBFBD><EFBFBD>ܴ˱<DCB4>ʶ<EFBFBD><CAB6>Ӱ<EFBFBD>죬<EFBFBD><ECA3AC>ʶΪfalse<73><65><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ݡ<EFBFBD>
|
|
|
|
|
//pPortParam->Initdata = false;
|
|
|
|
|
pPortParam->Initdata = true;
|
|
|
|
|
|
|
|
|
|
pPortParam->bAckRight = true;
|
|
|
|
|
pPortParam->bStopComm = false;
|
|
|
|
|
pPortParam->bCloseSocket = false;
|
|
|
|
|
pPortParam->CurCmdIdx = 0;
|
|
|
|
|
pPortParam->wRecvSequence = 0;
|
|
|
|
|
pPortParam->wSendSequence = 0;
|
|
|
|
|
pPortParam->wAckSequence = 0;
|
|
|
|
|
pPortParam->lTimeOutCnt = 0;
|
|
|
|
|
ClearAllCmdFromPollCmdBuf(commid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F>ر<EFBFBD>socketͨѶ
|
|
|
|
|
void Buban104CloseSocket(u_32 commid)
|
|
|
|
|
{
|
|
|
|
|
#ifdef OS_LINUX
|
|
|
|
|
CloseNetPort(commid);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
/////////////////////////buban104<30><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿڽ<D3BF><DABD><EFBFBD>///////////////////////
|
|
|
|
|
|
|
|
|
|
void Buban104ProvMakeYkYtCommand(int commid, u_char *buf, int len)
|
|
|
|
|
{
|
|
|
|
|
// buf[0] --- <20>˿ں<CBBF>(=commid)
|
|
|
|
|
// buf[1]
|
|
|
|
|
// buf[2]
|
|
|
|
|
// buf[3]
|
|
|
|
|
// buf[4] --- <20>ص<EFBFBD><D8B5><EFBFBD>
|
|
|
|
|
// buf[5]
|
|
|
|
|
// buf[6]
|
|
|
|
|
// buf[7]
|
|
|
|
|
// buf[8] --- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(ң<><D2A3>:1=ѡ<><D1A1>,2=ִ<><D6B4>,3=ȡ<><C8A1>,7=ֱ<><D6B1>;
|
|
|
|
|
// ң<><D2A3>:4=ѡ<><D1A1>,5=ִ<><D6B4>,6=ȡ<><C8A1>,8=<3D><>ͣ)
|
|
|
|
|
// buf[9] --- <20><><EFBFBD><EFBFBD>״̬(1=<3D>ֵ<EFBFBD><D6B5>ϣ<EFBFBD>2=<3D>ϵ<EFBFBD><CFB5><EFBFBD>)
|
|
|
|
|
// (<28><><EFBFBD><EFBFBD>λΪ1ʱ<31><CAB1>Ϊ<EFBFBD><CEAA>У<EFBFBD><D0A3><EFBFBD><EFBFBD>, 1=<3D>غ<EFBFBD>, 2=<3D>ط<EFBFBD>, 3=ʧ<><CAA7>)
|
|
|
|
|
// <20><>ת<EFBFBD><D7AA>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>У<EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫת<D2AA><D7AA><EFBFBD>Ŀص<C4BF><D8B5>ţ<EFBFBD>ʵ<EFBFBD>ʵĶ˿ں<CBBF>Ӧ<EFBFBD><D3A6><EFBFBD>Ǹ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>Ķ˿<C4B6>
|
|
|
|
|
// <20><>ת<EFBFBD><D7AA><EFBFBD>㲢û<E3B2A2><C3BB>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ص㣬<D8B5><E3A3AC><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>һ<EFBFBD>¡<EFBFBD>
|
|
|
|
|
|
|
|
|
|
int ykpoint, iLen;
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
BOOL bHaveOrder = FALSE;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
if(IsExtInfoPtr(commid) == FALSE)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if((buf[9] & 0x80) == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortParam = (pBUBAN104PORTPARAM)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
memset( (char*)commandbuf, 0x00, MAX_POLLCMD_BUF_LEN );
|
|
|
|
|
|
|
|
|
|
ykpoint = buf[4]+buf[5]*256+buf[6]*65536+buf[7]*16777216;
|
|
|
|
|
ykpoint += pPortParam->iYkBaseAddr - 1;
|
|
|
|
|
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[1] = 14;
|
|
|
|
|
switch(pPortParam->YkMode)
|
|
|
|
|
{
|
|
|
|
|
case CONTROL_SINGAL: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[6] = 45;
|
|
|
|
|
break;
|
|
|
|
|
case CONTROL_DOUBLE: // ˫<><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
case CONTROL_DIRECT: // ֱ<>ӿ<EFBFBD><D3BF><EFBFBD>
|
|
|
|
|
commandbuf[6] = 46;//(rtumsg->MsgData[3] == 1) ? 46 : 47;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[7] = 1;
|
|
|
|
|
//commandbuf[8] <20><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>
|
|
|
|
|
iLen = 9;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(LOWORD(ykpoint));
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(LOWORD(ykpoint));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(LOWORD(ykpoint));
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(LOWORD(ykpoint));
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(HIWORD(ykpoint));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch(buf[8])
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
case 4: // ѡ<><D1A1>
|
|
|
|
|
bHaveOrder = TRUE;
|
|
|
|
|
commandbuf[8] = 7;
|
|
|
|
|
commandbuf[iLen] = 0xfc;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
case 5: // ִ<><D6B4>
|
|
|
|
|
bHaveOrder = TRUE;
|
|
|
|
|
commandbuf[8] = 7;
|
|
|
|
|
commandbuf[iLen] = 0x7c;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
case 6:
|
|
|
|
|
bHaveOrder = TRUE;
|
|
|
|
|
commandbuf[8] = 9;
|
|
|
|
|
commandbuf[iLen] = 0xfc;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( bHaveOrder )
|
|
|
|
|
{
|
|
|
|
|
if((buf[9] & 0x03) == 0x03)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[8] |= 0x40;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// <20>طֻ<D8B7><D6BB>ǿغ<C7BF>
|
|
|
|
|
if((buf[9] & 0x03) == 0x01)// <20>غ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(CONTROL_SINGAL == pPortParam->YkMode)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] |= 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] |= 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else// <20>ط<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(CONTROL_SINGAL != pPortParam->YkMode)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] |= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PutPollCmdToBuf(commid, INSERT_POLL_CMD, 0, (char *)commandbuf, iLen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ShmGetDispYkYtFlag())
|
|
|
|
|
{
|
|
|
|
|
printf("TIP_(%04d): commid =%d ykytpnt=%d, op=%d checked.\n",
|
|
|
|
|
_getpid(), commid, ykpoint, (buf[9] & 0x7F));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//===========================<3D><><EFBFBD><EFBFBD>Ϊָ<CEAA><D6B8><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD>=======================
|
|
|
|
|
/*!
|
|
|
|
|
\brief Ѱ<EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
\param u_32 portno : RTU<EFBFBD>˿ں<EFBFBD>
|
|
|
|
|
\param i_32 iBuIdx : <EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void MakeBuban104Command(u_32 commid, u_char cmdidx)
|
|
|
|
|
{
|
|
|
|
|
int i, iLen;
|
|
|
|
|
DAY_TIME sCurTime;
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
memset( commandbuf, 0, sizeof( commandbuf ) );
|
|
|
|
|
|
|
|
|
|
pPortParam = (pBUBAN104PORTPARAM)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
iLen = 0;
|
|
|
|
|
switch ( cmdidx )
|
|
|
|
|
{
|
|
|
|
|
// format-i
|
|
|
|
|
case RTU_TIME: // ʱ<><CAB1>ͬ<EFBFBD><CDAC>
|
|
|
|
|
GetLocalTimeEx(&sCurTime);
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
iLen = 6;
|
|
|
|
|
commandbuf[iLen++] = 103;
|
|
|
|
|
commandbuf[iLen++] = 1;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 6;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 6;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
sCurTime.mSec = sCurTime.Sec * 1000 + sCurTime.mSec;
|
|
|
|
|
commandbuf[iLen++] = sCurTime.mSec % 256;
|
|
|
|
|
commandbuf[iLen++] = sCurTime.mSec / 256;
|
|
|
|
|
commandbuf[iLen++] = (u_char)sCurTime.Min;
|
|
|
|
|
commandbuf[iLen++] = (u_char)sCurTime.Hour;
|
|
|
|
|
commandbuf[iLen++] = (u_char)sCurTime.Day;
|
|
|
|
|
commandbuf[iLen++] = (u_char)sCurTime.Month;
|
|
|
|
|
commandbuf[iLen++] = (u_char)(sCurTime.Year%100);
|
|
|
|
|
commandbuf[1] = (BYTE)(iLen - 2);
|
|
|
|
|
PutPollCmdToBuf(commid, INSERT_POLL_CMD, 0, commandbuf, iLen);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ASK_DI_DATA: // <20>ٻ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>YX
|
|
|
|
|
for ( i = 0; i < (pPortParam->m_psBaoHu->DiNum+MAX_GROUP_DINUM-1)/MAX_GROUP_DINUM; i++)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
//commandbuf[1] = 14;
|
|
|
|
|
iLen = 6;
|
|
|
|
|
commandbuf[iLen++] = 100;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 5;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 5;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[iLen++] = 21 + i;
|
|
|
|
|
commandbuf[1] = (BYTE)(iLen - 2);
|
|
|
|
|
PutPollCmdToBuf(commid, NORMAL_POLL_CMD, 0, commandbuf, iLen);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ASK_AI_DATA: // <20>ٻ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>YC
|
|
|
|
|
for ( i = 0; i < (pPortParam->m_psBaoHu->AiNum+MAX_GROUP_AINUM-1)/MAX_GROUP_AINUM; i++)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
//commandbuf[1] = 14;
|
|
|
|
|
iLen = 6;
|
|
|
|
|
commandbuf[iLen++] = 100;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 5;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 5;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[iLen++] = 29 + i;
|
|
|
|
|
commandbuf[1] = (BYTE)(iLen - 2);
|
|
|
|
|
PutPollCmdToBuf(commid, NORMAL_POLL_CMD, 0, commandbuf, iLen);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ASK_PI_DATA: // <20>ٻ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>YM
|
|
|
|
|
for ( i = 0; i < (pPortParam->m_psBaoHu->PiNum+MAX_GROUP_PINUM-1)/MAX_GROUP_PINUM; i++)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
//commandbuf[1] = 14;
|
|
|
|
|
iLen = 6;
|
|
|
|
|
commandbuf[iLen++] = 101;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 6;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 6;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[iLen++] = 2 + i;
|
|
|
|
|
commandbuf[1] = (BYTE)(iLen - 2);
|
|
|
|
|
PutPollCmdToBuf(commid, NORMAL_POLL_CMD, 0, commandbuf, iLen);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ASK_PI: //<2F>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
//commandbuf[1] = 14;
|
|
|
|
|
iLen = 6;
|
|
|
|
|
commandbuf[iLen++] = 101;
|
|
|
|
|
commandbuf[iLen++] = 1;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 6;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 6;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
// wen 2006.04.03 <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>97<39><37><EFBFBD><EFBFBD>2000<30><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䲻ͬ
|
|
|
|
|
if(pPortParam->m_iPublishYear == 1997)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 0x41;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 0x45;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commandbuf[1] = (BYTE)(iLen - 2);
|
|
|
|
|
PutPollCmdToBuf(commid, NORMAL_POLL_CMD, 0, commandbuf, iLen);
|
|
|
|
|
pPortParam->Initdata = false;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ASK_ALL_DATA:// <20>ٻ<EFBFBD><D9BB><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
//commandbuf[1] = 14;
|
|
|
|
|
iLen = 6;
|
|
|
|
|
commandbuf[iLen++] = 100;
|
|
|
|
|
commandbuf[iLen++] = 1;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 6;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 6;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[iLen++] = 20;
|
|
|
|
|
commandbuf[1] = (BYTE)(iLen - 2);
|
|
|
|
|
PutPollCmdToBuf(commid, NORMAL_POLL_CMD, 0, commandbuf, iLen);
|
|
|
|
|
pPortParam->Initdata = false;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// format-s
|
|
|
|
|
case FORMAT_S: // S-<2D><>ʽ
|
|
|
|
|
// wen 2005.09.21 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>S֡
|
|
|
|
|
if(CheckPollCmdBufEmpty(commid) <= 0)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[iLen++] = 0x68;
|
|
|
|
|
commandbuf[iLen++] = 4;
|
|
|
|
|
commandbuf[iLen++] = 0x01;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
PutPollCmdToBuf(commid, FAST_POLL_CMD, 0, commandbuf, iLen);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// format-u
|
|
|
|
|
case FORMAT_U_START_ACT: // U-<2D><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[iLen++] = 0x68;
|
|
|
|
|
commandbuf[iLen++] = 4;
|
|
|
|
|
commandbuf[iLen++] = 0x07;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
PutPollCmdToBuf(commid, INSERT_POLL_CMD, 0, commandbuf, iLen);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FORMAT_U_START_CON: // U-<2D><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>
|
|
|
|
|
commandbuf[iLen++] = 0x68;
|
|
|
|
|
commandbuf[iLen++] = 4;
|
|
|
|
|
commandbuf[iLen++] = 0x0b;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
PutPollCmdToBuf(commid, FAST_POLL_CMD, 0, commandbuf, iLen);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FORMAT_U_STOP_ACT: // U-<2D><>ʽֹͣ
|
|
|
|
|
commandbuf[iLen++] = 0x68;
|
|
|
|
|
commandbuf[iLen++] = 4;
|
|
|
|
|
commandbuf[iLen++] = 0x13;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
PutPollCmdToBuf(commid, INSERT_POLL_CMD, 0, commandbuf, iLen);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FORMAT_U_STOP_CON: // U-<2D><>ʽֹͣӦ<D6B9><D3A6>
|
|
|
|
|
commandbuf[iLen++] = 0x68;
|
|
|
|
|
commandbuf[iLen++] = 4;
|
|
|
|
|
commandbuf[iLen++] = 0x23;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
PutPollCmdToBuf(commid, FAST_POLL_CMD, 0, commandbuf, iLen);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FORMAT_U_TEST_ACT: // U-<2D><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[iLen++] = 0x68;
|
|
|
|
|
commandbuf[iLen++] = 4;
|
|
|
|
|
commandbuf[iLen++] = 0x43;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
PutPollCmdToBuf(commid, INSERT_POLL_CMD, 0, commandbuf, iLen);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FORMAT_U_TEST_CON: // U-<2D><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>
|
|
|
|
|
commandbuf[iLen++] = 0x68;
|
|
|
|
|
commandbuf[iLen++] = 4;
|
|
|
|
|
commandbuf[iLen++] = (char)0x83;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
commandbuf[iLen++] = 0x00;
|
|
|
|
|
PutPollCmdToBuf(commid, FAST_POLL_CMD, 0, commandbuf, iLen);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ң<EFBFBD><D2A3>ң<EFBFBD><D2A3>ָ<EFBFBD><D6B8>
|
|
|
|
|
void MakeBuBan104YkYtCommand( u_32 commid, u_char *buf, int len )
|
|
|
|
|
{
|
|
|
|
|
// buf[0] --- <20>˿ں<CBBF>(=commid)
|
|
|
|
|
// buf[1]
|
|
|
|
|
// buf[2]
|
|
|
|
|
// buf[3]
|
|
|
|
|
// buf[4] --- <20>ص<EFBFBD><D8B5><EFBFBD>
|
|
|
|
|
// buf[5]
|
|
|
|
|
// buf[6]
|
|
|
|
|
// buf[7]
|
|
|
|
|
// buf[8] --- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(ң<><D2A3>:1=ѡ<><D1A1>,2=ִ<><D6B4>,3=ȡ<><C8A1>,7=ֱ<><D6B1>;
|
|
|
|
|
// ң<><D2A3>:4=ѡ<><D1A1>,5=ִ<><D6B4>,6=ȡ<><C8A1>,8=<3D><>ͣ)
|
|
|
|
|
// buf[9] --- <20><><EFBFBD><EFBFBD>״̬(1=<3D>ֵ<EFBFBD><D6B5>ϣ<EFBFBD>2=<3D>ϵ<EFBFBD><CFB5><EFBFBD>)
|
|
|
|
|
// (<28><><EFBFBD><EFBFBD>λΪ1ʱ<31><CAB1>Ϊ<EFBFBD><CEAA>У<EFBFBD><D0A3><EFBFBD><EFBFBD>, 1=<3D>ɹ<EFBFBD>, 0=ʧ<><CAA7>)
|
|
|
|
|
// <20><>ת<EFBFBD><D7AA>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>У<EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫת<D2AA><D7AA><EFBFBD>Ŀص<C4BF><D8B5>ţ<EFBFBD>ʵ<EFBFBD>ʵĶ˿ں<CBBF>Ӧ<EFBFBD><D3A6><EFBFBD>Ǹ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>Ķ˿<C4B6>
|
|
|
|
|
// <20><>ת<EFBFBD><D7AA><EFBFBD>㲢û<E3B2A2><C3BB>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ص㣬<D8B5><E3A3AC><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>һ<EFBFBD>¡<EFBFBD>
|
|
|
|
|
|
|
|
|
|
int ykpoint, iLen;
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
static int iYkStatus = 0;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (pBUBAN104PORTPARAM)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
memset( (char*)commandbuf, 0x00, MAX_POLLCMD_BUF_LEN );
|
|
|
|
|
|
|
|
|
|
ykpoint = buf[4]+buf[5]*256+buf[6]*65536+buf[7]*16777216;
|
|
|
|
|
ykpoint += pPortParam->iYkBaseAddr - 1;
|
|
|
|
|
|
|
|
|
|
iLen = 9;
|
|
|
|
|
switch(buf[8])
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
case 4: // ѡ<><D1A1>
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[1] = 14;
|
|
|
|
|
switch(pPortParam->YkMode)
|
|
|
|
|
{
|
|
|
|
|
case CONTROL_SINGAL: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[6] = 45;
|
|
|
|
|
break;
|
|
|
|
|
case CONTROL_DOUBLE: // ˫<><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
case CONTROL_DIRECT: // ֱ<>ӿ<EFBFBD><D3BF><EFBFBD>
|
|
|
|
|
commandbuf[6] = 46;//(rtumsg->MsgData[3] == 1) ? 46 : 47;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[7] = 1;
|
|
|
|
|
commandbuf[8] = 6;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = (char)(ykpoint & 0x00ff);
|
|
|
|
|
commandbuf[iLen++] = (char)((ykpoint & 0xff00)>>8);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
|
|
|
|
|
// wen 2002.11.18 <20>ֽ<EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[iLen++] = (char)(ykpoint & 0x00ff);
|
|
|
|
|
commandbuf[iLen++] = (char)((ykpoint & 0xff00)>>8);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(buf[9] == 1)
|
|
|
|
|
{
|
|
|
|
|
if(CONTROL_SINGAL == pPortParam->YkMode)
|
|
|
|
|
{
|
|
|
|
|
iYkStatus = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iYkStatus = 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(CONTROL_SINGAL == pPortParam->YkMode)
|
|
|
|
|
{
|
|
|
|
|
iYkStatus = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iYkStatus = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
commandbuf[iLen++] = (BYTE)(0xfc + iYkStatus);
|
|
|
|
|
PutPollCmdToBuf(commid, INSERT_POLL_CMD, 0, (char *)commandbuf, iLen);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
case 5: // ִ<><D6B4>
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[1] = 14;
|
|
|
|
|
switch(pPortParam->YkMode)
|
|
|
|
|
{
|
|
|
|
|
case CONTROL_SINGAL: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[6] = 45;
|
|
|
|
|
break;
|
|
|
|
|
case CONTROL_DOUBLE: // ˫<><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
case CONTROL_DIRECT: // ֱ<>ӿ<EFBFBD><D3BF><EFBFBD>
|
|
|
|
|
commandbuf[6] = 46;//(rtumsg->MsgData[3] == 1) ? 46 : 47;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[7] = 1;
|
|
|
|
|
commandbuf[8] = 6;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
// wen 2002.11.18 <20>ֽ<EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[iLen++] = (char)(ykpoint & 0x00ff);
|
|
|
|
|
commandbuf[iLen++] = (char)((ykpoint & 0xff00)>>8);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
|
|
|
|
|
// wen 2002.11.18 <20>ֽ<EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[iLen++] = (char)(ykpoint & 0x00ff);
|
|
|
|
|
commandbuf[iLen++] = (char)((ykpoint & 0xff00)>>8);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commandbuf[iLen++] = 0x7c + iYkStatus;
|
|
|
|
|
PutPollCmdToBuf(commid, INSERT_POLL_CMD, 0, (char *)commandbuf, iLen);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
case 6:
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[1] = 14;
|
|
|
|
|
switch(pPortParam->YkMode)
|
|
|
|
|
{
|
|
|
|
|
case CONTROL_SINGAL: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[6] = 45;
|
|
|
|
|
break;
|
|
|
|
|
case CONTROL_DOUBLE: // ˫<><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
case CONTROL_DIRECT: // ֱ<>ӿ<EFBFBD><D3BF><EFBFBD>
|
|
|
|
|
commandbuf[6] = 46;//(rtumsg->MsgData[3] == 1) ? 46 : 47;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[7] = 1;
|
|
|
|
|
commandbuf[8] = 8;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
|
|
|
|
|
// wen 2002.11.18 <20>ֽ<EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[iLen++] = (char)(ykpoint & 0x00ff);
|
|
|
|
|
commandbuf[iLen++] = (char)((ykpoint & 0xff00)>>8);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
|
|
|
|
|
// wen 2002.11.18 <20>ֽ<EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[iLen++] = (char)(ykpoint & 0x00ff);
|
|
|
|
|
commandbuf[iLen++] = (char)((ykpoint & 0xff00)>>8);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commandbuf[iLen++] = 0xfc + iYkStatus;
|
|
|
|
|
PutPollCmdToBuf(commid, INSERT_POLL_CMD, 0, (char *)commandbuf, iLen);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ShmGetDispYkYtFlag())
|
|
|
|
|
{
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
printf("TIP_(%04d): commid =%d ykytpnt=%d, op=%d checked.\n",
|
|
|
|
|
_getpid(), commid, ykpoint, (buf[9] & 0x7F));
|
|
|
|
|
#else
|
|
|
|
|
printf("TIP_(%04d): commid =%d ykytpnt=%d, op=%d checked.\n",
|
|
|
|
|
getpid(), commid, ykpoint, (buf[9] & 0x7F));
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//===================<3D><><EFBFBD><EFBFBD>ΪPOLLING<4E><47>Լ<EFBFBD><D4BC><EFBFBD>溯<EFBFBD><E6BAAF><EFBFBD>ӿ<EFBFBD>======================
|
|
|
|
|
/*!
|
|
|
|
|
\brief Ѱ<EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
\param u_32 portno : RTU<EFBFBD>˿ں<EFBFBD>
|
|
|
|
|
\param i_32 iBuIdx : <EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
void Buban104FindNextCmd(int commid)
|
|
|
|
|
{
|
|
|
|
|
int i, iCurCmdIdx;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
int framename[BUBAN104_TIMER_CMD_NUM] =
|
|
|
|
|
{
|
|
|
|
|
ASK_PI,
|
|
|
|
|
ASK_ALL_DATA,
|
|
|
|
|
FORMAT_S
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if((commid < 0) || (commid >= GetMaxPort()))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!ShmGetPortFlag(commid, FLAG_OPEN))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(!pPortParam->LinkOk)
|
|
|
|
|
{
|
|
|
|
|
if(CheckPollCmdBufEmpty(commid) <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MakeBuban104Command(commid, FORMAT_U_START_ACT);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i=0; i<BUBAN104_TIMER_CMD_NUM; i++)
|
|
|
|
|
{
|
|
|
|
|
if(pPortParam->CmdTime[i].CmdTimerConst )
|
|
|
|
|
pPortParam->CmdTime[i].CmdTimerCnt++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(CheckPollCmdBufEmpty(commid) <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iCurCmdIdx = pPortParam->CurCmdIdx;
|
|
|
|
|
for ( i = 0; i < BUBAN104_TIMER_CMD_NUM; i++ )
|
|
|
|
|
{
|
|
|
|
|
if(!pPortParam->bAckRight)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// wen 2005.09.16 <20>ڳ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯָ<D1AF><D6B8>
|
|
|
|
|
if(!pPortParam->Initdata)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iCurCmdIdx = (iCurCmdIdx+1) % BUBAN104_TIMER_CMD_NUM;
|
|
|
|
|
if ( (pPortParam->CmdTime[iCurCmdIdx].CmdTimerCnt
|
|
|
|
|
>= pPortParam->CmdTime[iCurCmdIdx].CmdTimerConst)
|
|
|
|
|
&& ( pPortParam->CmdTime[iCurCmdIdx].CmdTimerConst > 0 ))
|
|
|
|
|
{
|
|
|
|
|
pPortParam->CurCmdIdx = iCurCmdIdx;
|
|
|
|
|
MakeBuban104Command(commid, framename[iCurCmdIdx]);
|
|
|
|
|
pPortParam->CmdTime[iCurCmdIdx].CmdTimerCnt = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// wen (<28><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
|
|
|
|
if(CheckPollCmdBufEmpty(commid) > 0)
|
|
|
|
|
{
|
|
|
|
|
if(pPortParam->lTimeOutCnt >= pPortParam->lTimeOutConst)
|
|
|
|
|
{
|
|
|
|
|
if(!pPortParam->bCloseSocket)
|
|
|
|
|
{
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
// wen 2005.10.28 <20>ij<DEB8>ʱʱ<CAB1>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2>Ա<EFBFBD><D4B1><EFBFBD>
|
|
|
|
|
//MakeBuban104Command(commid, FORMAT_S);
|
|
|
|
|
//======================================================
|
|
|
|
|
if(pPortParam->lTimeOutSendTest)
|
|
|
|
|
{
|
|
|
|
|
MakeBuban104Command(commid, FORMAT_U_TEST_ACT);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MakeBuban104Command(commid, FORMAT_S);
|
|
|
|
|
}
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
pPortParam->lTimeOutCnt = 0;
|
|
|
|
|
pPortParam->bCloseSocket = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
InitBuban104CommandBuffer(commid);
|
|
|
|
|
// <20>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|
|
|
|
Buban104CloseSocket(commid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104FindNextProvCmd(int commid)
|
|
|
|
|
{
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
if((commid < 0) || (commid >= GetMaxPort()))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!ShmGetPortFlag(commid, FLAG_OPEN))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(!pPortParam->LinkOk)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(CheckPollCmdBufEmpty(commid) <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// wen (<28><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
|
|
|
|
if(pPortParam->lTimeOutCnt >= pPortParam->lTimeOutConst)
|
|
|
|
|
{
|
|
|
|
|
if(!pPortParam->bCloseSocket)
|
|
|
|
|
{
|
|
|
|
|
if(pPortParam->bAckRight)
|
|
|
|
|
{
|
|
|
|
|
if(pPortParam->Initdata)
|
|
|
|
|
{
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
// wen 2006.03.23 <20>ij<DEB8>ʱʱ<CAB1>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2>Ա<EFBFBD><D4B1><EFBFBD>
|
|
|
|
|
//MakeBuban104Command(commid, FORMAT_U_TEST_ACT);
|
|
|
|
|
//======================================================
|
|
|
|
|
if(pPortParam->lTimeOutSendTest)
|
|
|
|
|
{
|
|
|
|
|
MakeBuban104Command(commid, FORMAT_U_TEST_ACT);
|
|
|
|
|
}
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
pPortParam->lTimeOutCnt = 0;
|
|
|
|
|
pPortParam->bCloseSocket = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
InitBuban104CommandBuffer(commid);
|
|
|
|
|
// <20>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|
|
|
|
Buban104CloseSocket(commid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
InitBuban104CommandBuffer(commid);
|
|
|
|
|
// <20>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
|
|
|
|
Buban104CloseSocket(commid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(CheckPollCmdBufEmpty(commid) <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(pPortParam->bAckRight)
|
|
|
|
|
{
|
|
|
|
|
if(pPortParam->Initdata)
|
|
|
|
|
{
|
|
|
|
|
// һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>( ң<>ű<EFBFBD>λ )
|
|
|
|
|
ProvBuban104SendClass1(commid);
|
|
|
|
|
if(CheckPollCmdBufEmpty(commid) <= 0)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_lNoDataCnt = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ת<><D7AA>soe<6F><65><EFBFBD><EFBFBD>
|
|
|
|
|
ProvBuban104SendSoe(commid);
|
|
|
|
|
if(CheckPollCmdBufEmpty(commid) <= 0)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_lNoDataCnt = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>( ң<><D2A3><EFBFBD>仯)
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
// wen 2006.03.23 ֧<>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|
|
|
|
//ProvBuban104SendClass2(commid);
|
|
|
|
|
//====================================================================
|
|
|
|
|
if(pPortParam->m_bProvAiType == 13)
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104SendClass2withFloat(commid);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104SendClass2(commid);
|
|
|
|
|
}
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
|
|
if(CheckPollCmdBufEmpty(commid) <= 0)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_lNoDataCnt = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
// wen 2006.03.23 <20>ij<DEB8>ʱʱ<CAB1>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2>Ա<EFBFBD><D4B1><EFBFBD>
|
|
|
|
|
//pPortParam->m_lNoDataCnt++;
|
|
|
|
|
//if(pPortParam->m_lNoDataCnt >= pPortParam->lTimeOutConst)
|
|
|
|
|
//{
|
|
|
|
|
// pPortParam->m_lNoDataCnt = 0;
|
|
|
|
|
// MakeBuban104Command(commid, FORMAT_U_TEST_ACT);
|
|
|
|
|
//}
|
|
|
|
|
//======================================================
|
|
|
|
|
if(pPortParam->lTimeOutSendTest)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_lNoDataCnt++;
|
|
|
|
|
if(pPortParam->m_lNoDataCnt >= pPortParam->lTimeOutConst)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_lNoDataCnt = 0;
|
|
|
|
|
MakeBuban104Command(commid, FORMAT_U_TEST_ACT);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104SendCmdFormPollCmdBuf(int commid)
|
|
|
|
|
{
|
|
|
|
|
BYTE fcb = 0x20;
|
|
|
|
|
BYTE buf[MAX_MSG_BUF_SIZE];
|
|
|
|
|
i_32 len;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
if((commid < 0) || (commid >= GetMaxPort()))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!ShmGetPortFlag(commid, FLAG_OPEN))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(pPortParam->m_psBaoHu->ForceWaitFlag
|
|
|
|
|
&& pPortParam->m_psBaoHu->ForceWaitCnt)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_psBaoHu->ForceWaitCnt--;
|
|
|
|
|
if(pPortParam->m_psBaoHu->ForceWaitCnt == 0)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|
|
|
|
ClearCmdFormPollCmdBuf(commid);
|
|
|
|
|
//ClearCmdAllFlag(commid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(pPortParam->m_psBaoHu->SendCmdFlag
|
|
|
|
|
&& (pPortParam->m_psBaoHu->RevCmdFlag == 0))
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_psBaoHu->RetryTimeCnt++;
|
|
|
|
|
if(pPortParam->m_psBaoHu->RetryTimeCnt < pPortParam->m_psBaoHu->RetryTime)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortParam->m_psBaoHu->RetryTimeCnt = 0;
|
|
|
|
|
|
|
|
|
|
pPortParam->m_psBaoHu->RetryCnt++;
|
|
|
|
|
if(pPortParam->m_psBaoHu->RetryCnt > pPortParam->m_psBaoHu->Retry)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|
|
|
|
ClearCmdFormPollCmdBuf(commid);
|
|
|
|
|
//ClearCmdAllFlag(commid);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_psBaoHu->SendCmdFlag = 0;
|
|
|
|
|
pPortParam->m_psBaoHu->RevCmdFlag = 0;
|
|
|
|
|
pPortParam->m_psBaoHu->ReSendCmdFlag = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(pPortParam->m_psBaoHu->SendCmdFlag
|
|
|
|
|
&& pPortParam->m_psBaoHu->RevCmdFlag)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|
|
|
|
ClearCmdFormPollCmdBuf(commid);
|
|
|
|
|
//ClearCmdAllFlag(commid);
|
|
|
|
|
if(pPortParam->bSendFormatI)
|
|
|
|
|
{
|
|
|
|
|
//pPortParam->wSendSequence++;
|
|
|
|
|
//pPortParam->wSendSequence %= MAX_SEQUENCE;
|
|
|
|
|
pPortParam->bSendFormatI = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(pPortParam->m_psBaoHu->WaitTime)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_psBaoHu->WaitTimeCnt++;
|
|
|
|
|
if(pPortParam->m_psBaoHu->WaitTimeCnt
|
|
|
|
|
< pPortParam->m_psBaoHu->WaitTime)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pPortParam->m_psBaoHu->WaitTimeCnt = 0;
|
|
|
|
|
|
|
|
|
|
if(pPortParam->m_psBaoHu->ReSendCmdFlag)
|
|
|
|
|
{
|
|
|
|
|
len = ReGetCmdFormPollCmdBuf(commid, buf, sizeof(buf));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
len = GetCmdFormPollCmdBuf(commid, buf, sizeof(buf));
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD>ǰ<EFBFBD><C7B0> ClearCmdAllFlag(commid)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//pPortParam->m_psBaoHu->RetryCnt = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(len < 3)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
if(isUdpSocketExist() == TRUE)
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
if(buf[4] & 0x01 )
|
|
|
|
|
{
|
|
|
|
|
// format_s
|
|
|
|
|
if((buf[4] & 0x02) == 0 )
|
|
|
|
|
{
|
|
|
|
|
buf[6] = LOBYTE(pPortParam->wRecvSequence << 1);
|
|
|
|
|
buf[7] = HIBYTE(pPortParam->wRecvSequence << 1);
|
|
|
|
|
}
|
|
|
|
|
// else format_u
|
|
|
|
|
}
|
|
|
|
|
// format_i
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
buf[4] = LOBYTE(pPortParam->wSendSequence << 1);
|
|
|
|
|
buf[5] = HIBYTE(pPortParam->wSendSequence << 1);
|
|
|
|
|
buf[6] = LOBYTE(pPortParam->wRecvSequence << 1);
|
|
|
|
|
buf[7] = HIBYTE(pPortParam->wRecvSequence << 1);
|
|
|
|
|
pPortParam->bSendFormatI = TRUE;
|
|
|
|
|
//4.bug_1.2.3_20060807_3/bug_2.0.1_20060807_4 104<30><34>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD>˿ڵ<CBBF>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>1
|
|
|
|
|
pPortParam->wSendSequence++;
|
|
|
|
|
pPortParam->wSendSequence %= MAX_SEQUENCE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SendDataToPort(commid, (char *)&buf[2], len-2);
|
|
|
|
|
|
|
|
|
|
pPortParam->m_psBaoHu->SendCmdFlag = 1;
|
|
|
|
|
pPortParam->m_psBaoHu->ReSendCmdFlag = 0;
|
|
|
|
|
pPortParam->m_psBaoHu->RevCmdFlag = 0;
|
|
|
|
|
pPortParam->m_psBaoHu->RetryTimeCnt = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
if(pPortParam->m_psBaoHu->LastGetCmdBuf == FAST_CMD_TYPE)
|
|
|
|
|
#else
|
|
|
|
|
if((pPortParam->m_psBaoHu->LastGetCmdBuf == FAST_CMD_TYPE)
|
|
|
|
|
|| !isUdpSocketExist())
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_psBaoHu->ForceWaitCnt = BYTE1(buf[0])+BYTE0(buf[1])+TIMER_CNT-1;
|
|
|
|
|
pPortParam->m_psBaoHu->ForceWaitCnt /= TIMER_CNT;
|
|
|
|
|
if(pPortParam->m_psBaoHu->ForceWaitCnt)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_psBaoHu->ForceWaitFlag = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ClearCmdFormPollCmdBuf(commid); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|
|
|
|
//ClearCmdAllFlag(commid); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|
|
|
|
if(pPortParam->bSendFormatI)
|
|
|
|
|
{
|
|
|
|
|
//pPortParam->wSendSequence++;
|
|
|
|
|
//pPortParam->wSendSequence %= MAX_SEQUENCE;
|
|
|
|
|
pPortParam->bSendFormatI = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//===========================ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=========================
|
|
|
|
|
|
|
|
|
|
//===========================<3D><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=======================
|
|
|
|
|
void Buban104ProcessData(u_32 commid, BUBAN104PORTPARAM *psPortParam, BOOL bProcess)
|
|
|
|
|
{
|
|
|
|
|
RTUMSG msg;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = psPortParam;
|
|
|
|
|
|
|
|
|
|
if(TRUE == bProcess)
|
|
|
|
|
{
|
|
|
|
|
msg.PortIdx = (BYTE)commid;
|
|
|
|
|
msg.MsgLen = psPortParam->m_iRecvLen;
|
|
|
|
|
memcpy(msg.MsgData, psPortParam->m_au8RecvBuf, msg.MsgLen);
|
|
|
|
|
msg.MsgData[msg.MsgLen] = CHECK_WHOLE;
|
|
|
|
|
msg.MsgData[msg.MsgLen+1] = 0;
|
|
|
|
|
|
|
|
|
|
// <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
pPortParam->lTimeOutCnt = 0;
|
|
|
|
|
pPortParam->bCloseSocket = FALSE;
|
|
|
|
|
|
|
|
|
|
// <20><>վ<EFBFBD><D5BE><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
|
|
|
|
|
if(PROTOCOL_SLAVE == pPortParam->m_psBaoHu->PortType)
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104dataProcess(commid, &msg);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// format-i
|
|
|
|
|
if((msg.MsgData[2] & 0x01) == 0)
|
|
|
|
|
{
|
|
|
|
|
Buban104FormatI(&msg);
|
|
|
|
|
}
|
|
|
|
|
// format-s,format-u
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// format-u
|
|
|
|
|
if((msg.MsgData[2] & 0x02) != 0 )
|
|
|
|
|
{
|
|
|
|
|
Buban104FormatU(&msg);
|
|
|
|
|
}
|
|
|
|
|
// format-s( <20><>վ<EFBFBD><D5BE><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>'s'֡<><D6A1>ʽ)
|
|
|
|
|
//else Buban104FormatS(&msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//***************************************************************
|
|
|
|
|
//* I֡<49><D6A1><EFBFBD>ݵĴ<DDB5><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//*<2A><><EFBFBD><EFBFBD> RTUMSG* rtumsg:<3A><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
//***************************************************************
|
|
|
|
|
void Buban104FormatI(RTUMSG *rtumsg)
|
|
|
|
|
{
|
|
|
|
|
int commid, iSequenceInc;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
#ifdef _DEBUG_MSG_
|
|
|
|
|
char szbuf[256];
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// length
|
|
|
|
|
if(rtumsg->MsgData[1] < 4)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
pPortParam->wAckSequence = (rtumsg->MsgData[4]+(rtumsg->MsgData[5] << 8)) >> 1;
|
|
|
|
|
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
|
|
|
|
|
// wen 2005.09.19 ֡<><D6A1>ƥ<EFBFBD><C6A5><EFBFBD>㷨<EFBFBD><EFBFBD>
|
|
|
|
|
/*
|
|
|
|
|
if(pPortParam->wSendSequence != pPortParam->wAckSequence )
|
|
|
|
|
{
|
|
|
|
|
pPortParam->bAckRight = FALSE;
|
|
|
|
|
}
|
|
|
|
|
//??? WEN 2002.09.17 WHY
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pPortParam->bAckRight = TRUE;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
iSequenceInc = pPortParam->wSendSequence - pPortParam->wAckSequence;
|
|
|
|
|
if(iSequenceInc < 0)
|
|
|
|
|
{
|
|
|
|
|
iSequenceInc += MAX_SEQUENCE;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1>Ӧ<EFBFBD><D3A6><EFBFBD>ߴ<EFBFBD>(ȱʡֵ=MAX_FRAMEMATCHING_SIZE)
|
|
|
|
|
if((pPortParam->wSendSequence != pPortParam->wAckSequence )
|
|
|
|
|
&& (iSequenceInc > pPortParam->m_iFrameSize))
|
|
|
|
|
{
|
|
|
|
|
pPortParam->bAckRight = FALSE;
|
|
|
|
|
}
|
|
|
|
|
//??? WEN 2002.09.17 WHY
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pPortParam->bAckRight = TRUE;
|
|
|
|
|
}
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
|
|
|
|
|
|
|
|
|
|
pPortParam->wRecvSequence = (rtumsg->MsgData[2]+(rtumsg->MsgData[3] << 8)) >> 1;
|
|
|
|
|
pPortParam->wRecvSequence += 1;
|
|
|
|
|
pPortParam->wRecvSequence %= MAX_SEQUENCE;
|
|
|
|
|
|
|
|
|
|
switch (rtumsg->MsgData[6])
|
|
|
|
|
{
|
|
|
|
|
case 1: // <20><><EFBFBD><EFBFBD>ң<EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>
|
|
|
|
|
Buban104DiDataProcess( rtumsg, 0 );
|
|
|
|
|
// wen 2004.09.02 <20><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ң<EFBFBD>ű<EFBFBD>λ<EFBFBD><CEBB>soe<6F><65><EFBFBD><EFBFBD>֡ȷ<D6A1><C8B7>,<2C><>ʹ<EFBFBD>Է<EFBFBD><D4B7><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>(<28>ذ˾<EEB9AB><CBBE>)
|
|
|
|
|
MakeBuban104Command(commid, FORMAT_S );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2: // <20><><EFBFBD><EFBFBD>ң<EFBFBD><D2A3>SOE<4F><45><EFBFBD><EFBFBD>
|
|
|
|
|
Buban104SoeDataProcess( rtumsg, 0 );
|
|
|
|
|
// wen 2004.09.02 <20><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ң<EFBFBD>ű<EFBFBD>λ<EFBFBD><CEBB>soe<6F><65><EFBFBD><EFBFBD>֡ȷ<D6A1><C8B7>,<2C><>ʹ<EFBFBD>Է<EFBFBD><D4B7><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>(<28>ذ˾<EEB9AB><CBBE>)
|
|
|
|
|
MakeBuban104Command(commid, FORMAT_S);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3: // ˫<><CBAB>ң<EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>
|
|
|
|
|
Buban104DiDataProcess( rtumsg, 1 );
|
|
|
|
|
// wen 2004.09.02 <20><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ң<EFBFBD>ű<EFBFBD>λ<EFBFBD><CEBB>soe<6F><65><EFBFBD><EFBFBD>֡ȷ<D6A1><C8B7>,<2C><>ʹ<EFBFBD>Է<EFBFBD><D4B7><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>(<28>ذ˾<EEB9AB><CBBE>)
|
|
|
|
|
MakeBuban104Command(commid, FORMAT_S);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 4: // ˫<><CBAB>ң<EFBFBD><D2A3>SOE<4F><45><EFBFBD><EFBFBD>
|
|
|
|
|
Buban104SoeDataProcess( rtumsg, 1 );
|
|
|
|
|
// wen 2004.09.02 <20><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ң<EFBFBD>ű<EFBFBD>λ<EFBFBD><CEBB>soe<6F><65><EFBFBD><EFBFBD>֡ȷ<D6A1><C8B7>,<2C><>ʹ<EFBFBD>Է<EFBFBD><D4B7><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>(<28>ذ˾<EEB9AB><CBBE>)
|
|
|
|
|
MakeBuban104Command(commid, FORMAT_S);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 5: // <20><>ѹ<EFBFBD><D1B9><EFBFBD>ֽ<EFBFBD>ͷλ<CDB7><CEBB>
|
|
|
|
|
break;
|
|
|
|
|
case 6: // <20><>ѹ<EFBFBD><D1B9><EFBFBD>ֽ<EFBFBD>ͷλ<CDB7>ô<EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
break;
|
|
|
|
|
case 7: // <20><>վԶ<D5BE><D4B6><EFBFBD>ն<EFBFBD>״̬
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 9: // <20><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ң<EFBFBD><D2A3>
|
|
|
|
|
Buban104AiWithPzDataProcess( rtumsg, 0 );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 10: // <20><>Ʒ<EFBFBD>ʴ<EFBFBD>ʱ<EFBFBD><CAB1>ң<EFBFBD><D2A3>
|
|
|
|
|
Buban104AiWithPzDataProcess( rtumsg, 1 );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 13:
|
|
|
|
|
Buban104AllFloatAiDataProcess( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 20: // <20><>վ<EFBFBD><D5BE><EFBFBD><EFBFBD>ң<EFBFBD>ű<EFBFBD>λ֡
|
|
|
|
|
Buban104AutoSendDiProcess( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 21: // ȫң<C8AB><D2A3><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD> <20><><EFBFBD>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD>
|
|
|
|
|
Buban104AllAiDataProcess( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 15: // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Buban104PiDataProcess( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
case 16: // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Buban104PiWithTimeDataProcess( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 17: // <20>̵籣<CCB5><E7B1A3>װ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>¼<EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>¼֡
|
|
|
|
|
case 18: // <20>̵籣<CCB5><E7B1A3>װ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>˳<EFBFBD><CBB3>
|
|
|
|
|
case 19: // <20>̵籣<CCB5><E7B1A3>װ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>¼<EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>¼
|
|
|
|
|
Buban104BaoHuDataProcess( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// wen 2004.05.27 <20><><EFBFBD><EFBFBD>104<30><34>Լ<EFBFBD>ĵ<DEB8>(???)
|
|
|
|
|
case 30: // <20><>CP56Time2aʱ<61><CAB1><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>Ϣ M_SP_TB_1
|
|
|
|
|
Buban104SoeDataProcessWithCP56Time2a( rtumsg, 0 );
|
|
|
|
|
// wen 2004.09.02 <20><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ң<EFBFBD>ű<EFBFBD>λ<EFBFBD><CEBB>soe<6F><65><EFBFBD><EFBFBD>֡ȷ<D6A1><C8B7>,<2C><>ʹ<EFBFBD>Է<EFBFBD><D4B7><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>(<28>ذ˾<EEB9AB><CBBE>)
|
|
|
|
|
MakeBuban104Command( commid, FORMAT_S );
|
|
|
|
|
break;
|
|
|
|
|
case 31: // <20><>CP56Time2aʱ<61><CAB1><EFBFBD><EFBFBD>˫<EFBFBD><CBAB><EFBFBD><EFBFBD>Ϣ M_DP_TB_1
|
|
|
|
|
Buban104SoeDataProcessWithCP56Time2a( rtumsg, 1 );
|
|
|
|
|
// wen 2004.09.02 <20><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ң<EFBFBD>ű<EFBFBD>λ<EFBFBD><CEBB>soe<6F><65><EFBFBD><EFBFBD>֡ȷ<D6A1><C8B7>,<2C><>ʹ<EFBFBD>Է<EFBFBD><D4B7><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>(<28>ذ˾<EEB9AB><CBBE>)
|
|
|
|
|
MakeBuban104Command( commid, FORMAT_S );
|
|
|
|
|
break;
|
|
|
|
|
case 32: // <20><>CP56Time2aʱ<61><CAB1><EFBFBD>IJ<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ϣ M_ST_TB_1
|
|
|
|
|
break;
|
|
|
|
|
case 33: // <20><>CP56Time2aʱ<61><CAB1><EFBFBD><EFBFBD>32<33><32><EFBFBD>ش<EFBFBD> M_BO_TB_1
|
|
|
|
|
break;
|
|
|
|
|
case 34: // <20><>CP56Time2aʱ<61><CAB1><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>ֵ, <20><>һ<EFBFBD><D2BB>ֵ M_ME_TD_1
|
|
|
|
|
Buban104AiWithDataProcessWithM_ME_TD_1( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
case 35: // <20><>CP56Time2aʱ<61><CAB1><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>ֵ, <20><><EFBFBD>Ȼ<EFBFBD>ֵ M_ME_TE_1
|
|
|
|
|
Buban104AiWithDataProcessWithM_ME_TE_1( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
case 36: // <20><>CP56Time2aʱ<61><CAB1><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>ֵ, <20≯<EFBFBD><CCB8><EFBFBD><EFBFBD><EFBFBD> M_ME_TF_1
|
|
|
|
|
Buban104AiWithDataProcessWithM_ME_TF_1( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
case 37: // <20><>CP56Time2aʱ<61><CAB1><EFBFBD><EFBFBD><EFBFBD>ۼ<EFBFBD><DBBC><EFBFBD> M_IT_TB_1
|
|
|
|
|
Buban104PiWithTimeDataProcessWithM_IT_TB_1( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
case 38: // <20><>CP56Time2aʱ<61><CAB1><EFBFBD>ļ̵籣<CCB5><E7B1A3>װ<EFBFBD><D7B0><EFBFBD>¼<EFBFBD> M_EP_TD_1
|
|
|
|
|
break;
|
|
|
|
|
case 39: // <20><>CP56Time2aʱ<61><CAB1><EFBFBD>ļ̵籣<CCB5><E7B1A3>װ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD> M_EP_TE_1
|
|
|
|
|
break;
|
|
|
|
|
case 40: // <20><>CP56Time2aʱ<61><CAB1><EFBFBD>ļ̵籣<CCB5><E7B1A3>װ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>ϢM_EP_TF_1
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 45:
|
|
|
|
|
case 46: // ң<>ط<EFBFBD>У
|
|
|
|
|
case 47: // ң<><D2A3><EFBFBD><EFBFBD>У
|
|
|
|
|
Buban104YkYtAck( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
case 48: // <20>趨ȷ<E8B6A8><C8B7>
|
|
|
|
|
Buban104SetAck( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
case 100: // <20><><EFBFBD>ٻ<EFBFBD>ȷ<EFBFBD><C8B7>
|
|
|
|
|
Buban104InitdataProecss( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 101: // <20><><EFBFBD>Ƚ<EFBFBD><C8BD><EFBFBD>֡
|
|
|
|
|
Buban104PidataEnd( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
case 103: // ʱ<><CAB1>ͬ<EFBFBD><CDAC>ȷ<EFBFBD><C8B7>֡
|
|
|
|
|
Buban104SynTime( rtumsg );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
#ifdef _DEBUG_MSG_
|
|
|
|
|
DebugPrint("<EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n");
|
|
|
|
|
#endif
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104FormatU(RTUMSG *rtumsg)
|
|
|
|
|
{
|
|
|
|
|
int commid;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
// length
|
|
|
|
|
if(rtumsg->MsgData[1] < 4)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
switch(rtumsg->MsgData[2] & 0xfc)
|
|
|
|
|
{
|
|
|
|
|
case 0x08: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|
|
|
|
InitBuban104CommandBuffer(commid);
|
|
|
|
|
pPortParam->bAckRight = TRUE;
|
|
|
|
|
pPortParam->LinkOk = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case 0x20: // ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|
|
|
|
pPortParam->bAckRight = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case 0x40: // <20><><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>
|
|
|
|
|
//pPortParam->bAckRight = TRUE;
|
|
|
|
|
MakeBuban104Command(commid, FORMAT_U_TEST_CON);
|
|
|
|
|
if( !pPortParam->bAckRight )
|
|
|
|
|
{
|
|
|
|
|
pPortParam->bAckRight = TRUE;
|
|
|
|
|
pPortParam->wSendSequence = pPortParam->wAckSequence;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
// wen 2005.11.02 <20><><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
|
|
|
|
|
case 0x80: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|
|
|
|
if(!pPortParam->bAckRight)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->bAckRight = TRUE;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|
|
|
|
pPortParam->bAckRight = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Buban104 <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD> */
|
|
|
|
|
void Buban104InitdataProecss(RTUMSG * rtumsg)
|
|
|
|
|
{
|
|
|
|
|
int commid;
|
|
|
|
|
WORD wTransCause;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
wTransCause = rtumsg->MsgData[8];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wTransCause = rtumsg->MsgData[8] + (rtumsg->MsgData[9] << 8);
|
|
|
|
|
}
|
|
|
|
|
switch(wTransCause)
|
|
|
|
|
{
|
|
|
|
|
case 7:
|
|
|
|
|
case 9://<2F><><EFBFBD>ٻ<EFBFBD>ȷ<EFBFBD><C8B7>
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 10://<2F><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
pPortParam->Initdata = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD>Ƚ<EFBFBD><C8BD><EFBFBD>֡ */
|
|
|
|
|
void Buban104PidataEnd(RTUMSG * rtumsg)
|
|
|
|
|
{
|
|
|
|
|
int commid;
|
|
|
|
|
WORD wTransCause;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
wTransCause = rtumsg->MsgData[8];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wTransCause = rtumsg->MsgData[8] + (rtumsg->MsgData[9] << 8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(wTransCause & 0x0040)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->Initdata = TRUE;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch(wTransCause)
|
|
|
|
|
{
|
|
|
|
|
case 7://<2F><><EFBFBD>ٻ<EFBFBD>ȷ<EFBFBD><C8B7>
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 10://<2F><><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
pPortParam->Initdata = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F>趨ȷ<E8B6A8><C8B7>
|
|
|
|
|
void Buban104SetAck( RTUMSG *rtumsg)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Buban104 ң<><D2A3>ң<EFBFBD><D2A3><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD>
|
|
|
|
|
void Buban104YkYtAck(RTUMSG * rtumsg)
|
|
|
|
|
{
|
|
|
|
|
int commid;
|
|
|
|
|
BYTE bYkOperate;
|
|
|
|
|
WORD wTransCause;
|
|
|
|
|
YKYT_PARAM YkYtParam;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
YkYtParam.m_iYkYtPnt = (rtumsg->MsgData[11]<<8) + rtumsg->MsgData[10];
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
// wen 2006.03.24
|
|
|
|
|
//YkYtParam.m_iYkYtPnt -= pPortParam->iYkBaseAddr;
|
|
|
|
|
//=======================================================================
|
|
|
|
|
YkYtParam.m_iYkYtPnt -= (pPortParam->iYkBaseAddr-1);
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
YkYtParam.m_iYkYtPnt %= 256;
|
|
|
|
|
|
|
|
|
|
wTransCause = rtumsg->MsgData[8];
|
|
|
|
|
bYkOperate = rtumsg->MsgData[12];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
YkYtParam.m_iYkYtPnt = (rtumsg->MsgData[14] << 16)
|
|
|
|
|
+ (rtumsg->MsgData[13]<<8) + rtumsg->MsgData[12];
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
// wen 2006.03.24
|
|
|
|
|
//YkYtParam.m_iYkYtPnt -= pPortParam->iYkBaseAddr;
|
|
|
|
|
//=======================================================================
|
|
|
|
|
YkYtParam.m_iYkYtPnt -= (pPortParam->iYkBaseAddr-1);
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
YkYtParam.m_iYkYtPnt %= 256;
|
|
|
|
|
|
|
|
|
|
wTransCause = (rtumsg->MsgData[9]<<8) + rtumsg->MsgData[8];
|
|
|
|
|
bYkOperate = rtumsg->MsgData[15];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(bYkOperate & 0x80) //ѡ<><D1A1><EFBFBD><EFBFBD>У
|
|
|
|
|
{
|
|
|
|
|
YkYtParam.m_iYkYtStep = STEP_YKYT_SELECT;
|
|
|
|
|
|
|
|
|
|
//<2F><>λΪ<CEBB>϶<EFBFBD><CFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>λ || <20><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>
|
|
|
|
|
if((wTransCause & 0x0040) || (wTransCause == 0x0009))
|
|
|
|
|
{
|
|
|
|
|
YkYtParam.m_iYkYtOperate = 3;
|
|
|
|
|
}
|
|
|
|
|
else if(wTransCause == 0x0007)
|
|
|
|
|
{
|
|
|
|
|
if(rtumsg->MsgData[6] != 45)
|
|
|
|
|
{
|
|
|
|
|
switch(bYkOperate & 0x03)
|
|
|
|
|
{
|
|
|
|
|
case 1://<2F>ط<EFBFBD>
|
|
|
|
|
if(pPortParam->m_psBaoHu->ProvYkYtMsg.m_iYkYtOperate == 2)
|
|
|
|
|
{
|
|
|
|
|
YkYtParam.m_iYkYtOperate = pPortParam->m_psBaoHu->ProvYkYtMsg.m_iYkYtOperate;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
YkYtParam.m_iYkYtOperate = 3;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2://<2F>غ<EFBFBD>
|
|
|
|
|
if(pPortParam->m_psBaoHu->ProvYkYtMsg.m_iYkYtOperate == 1)
|
|
|
|
|
{
|
|
|
|
|
YkYtParam.m_iYkYtOperate = pPortParam->m_psBaoHu->ProvYkYtMsg.m_iYkYtOperate;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
YkYtParam.m_iYkYtOperate = 3;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
YkYtParam.m_iYkYtOperate = 3;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// <20>غ<EFBFBD>
|
|
|
|
|
if( bYkOperate & 0x01 )
|
|
|
|
|
{
|
|
|
|
|
if(pPortParam->m_psBaoHu->ProvYkYtMsg.m_iYkYtOperate == 1)
|
|
|
|
|
{
|
|
|
|
|
YkYtParam.m_iYkYtOperate = pPortParam->m_psBaoHu->ProvYkYtMsg.m_iYkYtOperate;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
YkYtParam.m_iYkYtOperate = 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// <20>ط<EFBFBD>
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(pPortParam->m_psBaoHu->ProvYkYtMsg.m_iYkYtOperate == 2)
|
|
|
|
|
{
|
|
|
|
|
YkYtParam.m_iYkYtOperate = pPortParam->m_psBaoHu->ProvYkYtMsg.m_iYkYtOperate;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
YkYtParam.m_iYkYtOperate = 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
YkYtParam.m_iYkYtUpDown = YKYT_SEND_UP;
|
|
|
|
|
SendYkYtCommand2(commid, &YkYtParam);
|
|
|
|
|
}
|
|
|
|
|
else //ִ<>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
//<2F><>λΪ<CEBB>϶<EFBFBD><CFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>λ
|
|
|
|
|
if((wTransCause & 0x0040) == 0)
|
|
|
|
|
{
|
|
|
|
|
switch(wTransCause)
|
|
|
|
|
{
|
|
|
|
|
case 0x0007://ִ<><D6B4>ȷ<EFBFBD><C8B7>
|
|
|
|
|
break;
|
|
|
|
|
case 0x000a://ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Buban104 <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> */
|
|
|
|
|
void Buban104SynTime(RTUMSG * rtumsg)
|
|
|
|
|
{
|
|
|
|
|
int commid;
|
|
|
|
|
WORD wTransCause;
|
|
|
|
|
DAY_TIME stime;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(1 != pPortParam->m_psBaoHu->CheckTime)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
wTransCause = rtumsg->MsgData[8];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wTransCause = rtumsg->MsgData[8] + (rtumsg->MsgData[9]<<8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(wTransCause != 0x0007)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
stime.mSec = (rtumsg->MsgData[13]<<8) + rtumsg->MsgData[12];
|
|
|
|
|
stime.Sec = stime.mSec / 1000;
|
|
|
|
|
stime.mSec %= 1000;
|
|
|
|
|
stime.Min = rtumsg->MsgData[14] & 0x3F;
|
|
|
|
|
stime.Hour = rtumsg->MsgData[15] & 0x1F;
|
|
|
|
|
stime.Day = rtumsg->MsgData[16] & 0x1F;
|
|
|
|
|
stime.Month= rtumsg->MsgData[17] & 0x0F;
|
|
|
|
|
stime.Year = (rtumsg->MsgData[18] & 0x7F)+2000;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
stime.mSec = (rtumsg->MsgData[16]<<8) + rtumsg->MsgData[15];
|
|
|
|
|
stime.Sec = stime.mSec / 1000;
|
|
|
|
|
stime.mSec %= 1000;
|
|
|
|
|
stime.Min = rtumsg->MsgData[17] & 0x3F;
|
|
|
|
|
stime.Hour = rtumsg->MsgData[18] & 0x1F;
|
|
|
|
|
stime.Day = rtumsg->MsgData[19] & 0x1F;
|
|
|
|
|
stime.Month= rtumsg->MsgData[20] & 0x0F;
|
|
|
|
|
stime.Year = (rtumsg->MsgData[21] & 0x7F)+2000;
|
|
|
|
|
}
|
|
|
|
|
SetLocalTimeEx(&stime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><>վ<EFBFBD><D5BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD>ű<EFBFBD>λ֡ */
|
|
|
|
|
void Buban104AutoSendDiProcess(RTUMSG *rtumsg)
|
|
|
|
|
{
|
|
|
|
|
int i, j, dipnt, len, istart;
|
|
|
|
|
DI_DEF pntmsg;
|
|
|
|
|
WORD wStatus, wStatusBit, wTransCause;
|
|
|
|
|
|
|
|
|
|
int commid;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
len = (int)rtumsg->MsgData[1];
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
wTransCause = rtumsg->MsgData[8];
|
|
|
|
|
istart = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wTransCause = rtumsg->MsgData[8] + (rtumsg->MsgData[9]<<8);
|
|
|
|
|
istart = 12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(wTransCause == 0x0003)
|
|
|
|
|
{
|
|
|
|
|
for(i = istart; i < (2 + len); )
|
|
|
|
|
{
|
|
|
|
|
dipnt = rtumsg->MsgData[i++];
|
|
|
|
|
dipnt += (rtumsg->MsgData[i++]<<8);
|
|
|
|
|
if(VER_IEC870_5_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
dipnt += (rtumsg->MsgData[i++]<<16);
|
|
|
|
|
}
|
|
|
|
|
dipnt -= pPortParam->iDiBaseAddr;
|
|
|
|
|
|
|
|
|
|
wStatus = rtumsg->MsgData[i++];
|
|
|
|
|
wStatus = (wStatus<<8) + rtumsg->MsgData[i++];
|
|
|
|
|
wStatusBit = rtumsg->MsgData[i++];
|
|
|
|
|
wStatusBit = (wStatusBit<<8) + rtumsg->MsgData[i++];
|
|
|
|
|
|
|
|
|
|
for( j = 0; j < 16; j++ )
|
|
|
|
|
{
|
|
|
|
|
if( wStatusBit & (0x0001 << j) )
|
|
|
|
|
{
|
|
|
|
|
if( wStatus & (0x0001 << j) )
|
|
|
|
|
pntmsg.Status = 1;
|
|
|
|
|
else
|
|
|
|
|
pntmsg.Status = 0;
|
|
|
|
|
SetPntMsg(commid, dipnt+j, (void *)&pntmsg, DI_PNT_TYPE, PNT_STATUS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Buban104 <20><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
|
|
|
|
|
void Buban104AiWithPzDataProcess(RTUMSG * rtumsg, int flag)
|
|
|
|
|
{
|
|
|
|
|
int i, aipnt, len;
|
|
|
|
|
AI_DEF pntmsg;
|
|
|
|
|
int commid, istart;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
len = (int)rtumsg->MsgData[1];
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>仯ң<E4BBAF><D2A3>
|
|
|
|
|
for(i = istart; i < (2 + len);)
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
aipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8);
|
|
|
|
|
i += 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
aipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8)+(rtumsg->MsgData[i+2]<<16);
|
|
|
|
|
i += 3;
|
|
|
|
|
}
|
|
|
|
|
aipnt -= pPortParam->iAiBaseAddr;
|
|
|
|
|
|
|
|
|
|
pntmsg.RawValue = (short)(rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8));
|
|
|
|
|
// Ʒ<><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// rtumsg->MsgData[i+2];
|
|
|
|
|
i += 3;
|
|
|
|
|
|
|
|
|
|
SetPntMsg(commid, aipnt, (void *)&pntmsg, AI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
|
|
|
|
|
// ʱ<><CAB1>
|
|
|
|
|
if(flag)
|
|
|
|
|
{
|
|
|
|
|
i += 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104AllAiDataProcess(RTUMSG *rtumsg)
|
|
|
|
|
{
|
|
|
|
|
int i, aipnt, len;
|
|
|
|
|
AI_DEF pntmsg;
|
|
|
|
|
int commid, istart;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
len = (int)rtumsg->MsgData[1];
|
|
|
|
|
|
|
|
|
|
if(len <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aipnt = 0;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>仯ң<E4BBAF><D2A3>
|
|
|
|
|
if((rtumsg->MsgData[7] & 0x80)==0)
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i = istart; i < len + 2;)
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
aipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8);
|
|
|
|
|
i += 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
aipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8)+(rtumsg->MsgData[i+2]<<16);
|
|
|
|
|
i += 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aipnt -= pPortParam->iAiBaseAddr;
|
|
|
|
|
|
|
|
|
|
pntmsg.RawValue = (short)((rtumsg->MsgData[i+1]<<8) + rtumsg->MsgData[i]);
|
|
|
|
|
i += 2;
|
|
|
|
|
|
|
|
|
|
SetPntMsg(commid, aipnt, (void *)&pntmsg, AI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ȫң<C8AB><D2A3>
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
aipnt = rtumsg->MsgData[10]+(rtumsg->MsgData[11]<<8);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 15;
|
|
|
|
|
aipnt = rtumsg->MsgData[12]+(rtumsg->MsgData[13]<<8)+(rtumsg->MsgData[14]<<16);
|
|
|
|
|
}
|
|
|
|
|
aipnt -= pPortParam->iAiBaseAddr;
|
|
|
|
|
|
|
|
|
|
for(i=istart; i < (len+2); i+=2)
|
|
|
|
|
{
|
|
|
|
|
pntmsg.RawValue = (short)(rtumsg->MsgData[i] + (rtumsg->MsgData[i+1]<<8));
|
|
|
|
|
SetPntMsg(commid, aipnt, (void *)&pntmsg, AI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
aipnt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104AllFloatAiDataProcess(RTUMSG *rtumsg)
|
|
|
|
|
{
|
|
|
|
|
int i, aipnt, len;
|
|
|
|
|
float fValue;
|
|
|
|
|
AI_DEF pntmsg;
|
|
|
|
|
int commid, istart;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
len = (int)rtumsg->MsgData[1];
|
|
|
|
|
|
|
|
|
|
if(len <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aipnt = 0;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>仯ң<E4BBAF><D2A3>
|
|
|
|
|
if((rtumsg->MsgData[7] & 0x80)==0)
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i = istart; i < len + 4;)
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
aipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8);
|
|
|
|
|
i += 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
aipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8)+(rtumsg->MsgData[i+2]<<16);
|
|
|
|
|
i += 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aipnt -= pPortParam->iAiBaseAddr;
|
|
|
|
|
|
|
|
|
|
fValue = SequenceRtuToHostfloat((*((float *)&rtumsg->MsgData[i])));
|
|
|
|
|
pntmsg.RawValue = (unsigned long)fValue;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽڵ<D6BD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
i += sizeof(float)+1;
|
|
|
|
|
|
|
|
|
|
SetPntMsg(commid, aipnt, (void *)&pntmsg, AI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ȫң<C8AB><D2A3>
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
aipnt = rtumsg->MsgData[10]+(rtumsg->MsgData[11]<<8);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 15;
|
|
|
|
|
aipnt = rtumsg->MsgData[12]+(rtumsg->MsgData[13]<<8)+(rtumsg->MsgData[14]<<16);
|
|
|
|
|
}
|
|
|
|
|
aipnt -= pPortParam->iAiBaseAddr;
|
|
|
|
|
|
|
|
|
|
for(i=istart; i < (len+2); i+=5)
|
|
|
|
|
{
|
|
|
|
|
fValue = SequenceRtuToHostfloat((*((float *)&rtumsg->MsgData[i])));
|
|
|
|
|
pntmsg.RawValue = (unsigned long)fValue;
|
|
|
|
|
SetPntMsg(commid, aipnt, (void *)&pntmsg, AI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
aipnt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104DiDataProcess(RTUMSG *rtumsg, int flag)
|
|
|
|
|
{
|
|
|
|
|
int i, dipnt, len;
|
|
|
|
|
DI_DEF pntmsg;
|
|
|
|
|
WORD wTransCause;
|
|
|
|
|
int commid, istart;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
len = (int)rtumsg->MsgData[1];
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
wTransCause = rtumsg->MsgData[8];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wTransCause = rtumsg->MsgData[8] + (rtumsg->MsgData[9]<<8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><>վ<EFBFBD><D5BE><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD> <20>仯ң<E4BBAF><D2A3>
|
|
|
|
|
if(wTransCause == 0x0003)
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
}
|
|
|
|
|
for ( i = istart; i < 2 + len; )
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
dipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8);
|
|
|
|
|
i += 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8)+(rtumsg->MsgData[i+2]<<16);
|
|
|
|
|
i += 3;
|
|
|
|
|
}
|
|
|
|
|
dipnt -= pPortParam->iDiBaseAddr;
|
|
|
|
|
|
|
|
|
|
if ( flag == 0 )
|
|
|
|
|
pntmsg.Status = rtumsg->MsgData[i++] & 0x1;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch ( rtumsg->MsgData[i++] & 0x3 )
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
pntmsg.Status = 1;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
pntmsg.Status = 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
pntmsg.Status = 0xff;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( pntmsg.Status != 0xff )
|
|
|
|
|
{
|
|
|
|
|
SetPntMsg(commid, dipnt, (void *)&pntmsg, DI_PNT_TYPE, PNT_STATUS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(rtumsg->MsgData[7] & 0x80)
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
dipnt = rtumsg->MsgData[10]+(rtumsg->MsgData[11]<<8);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 15;
|
|
|
|
|
dipnt = rtumsg->MsgData[12]+(rtumsg->MsgData[13]<<8)+(rtumsg->MsgData[14]<<16);
|
|
|
|
|
}
|
|
|
|
|
dipnt -= pPortParam->iDiBaseAddr;
|
|
|
|
|
|
|
|
|
|
for ( i = istart; i < 2 + len; i++,dipnt++ )
|
|
|
|
|
{
|
|
|
|
|
if ( flag == 0 )
|
|
|
|
|
pntmsg.Status = rtumsg->MsgData[i] & 0x1;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch ( rtumsg->MsgData[i] & 0x3 )
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
pntmsg.Status = 1;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
pntmsg.Status = 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
pntmsg.Status = 0xff;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(pntmsg.Status != 0xff)
|
|
|
|
|
{
|
|
|
|
|
SetPntMsg(commid, dipnt, (void *)&pntmsg, DI_PNT_TYPE, PNT_STATUS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
}
|
|
|
|
|
for ( i = istart; i < 2 + len; )
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
dipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8);
|
|
|
|
|
i += 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8)+(rtumsg->MsgData[i+2]<<16);
|
|
|
|
|
i += 3;
|
|
|
|
|
}
|
|
|
|
|
dipnt -= pPortParam->iDiBaseAddr;
|
|
|
|
|
|
|
|
|
|
if ( flag == 0 )
|
|
|
|
|
pntmsg.Status = rtumsg->MsgData[i++] & 0x1;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch ( rtumsg->MsgData[i++] & 0x3 )
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
pntmsg.Status = 1;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
pntmsg.Status = 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
pntmsg.Status = 0xff;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(pntmsg.Status != 0xff)
|
|
|
|
|
{
|
|
|
|
|
SetPntMsg(commid, dipnt, (void *)&pntmsg, DI_PNT_TYPE, PNT_STATUS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104SoeDataProcess(RTUMSG *rtumsg, int flag)
|
|
|
|
|
{
|
|
|
|
|
_int64 i64Millseconds;
|
|
|
|
|
time_t iTime;
|
|
|
|
|
int i, pnt, len;
|
|
|
|
|
char st;
|
|
|
|
|
int sec;
|
|
|
|
|
DI_DEF pntmsg;
|
|
|
|
|
DAY_TIME sm;
|
|
|
|
|
struct tm *testtm;
|
|
|
|
|
int commid, istart;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
len = (int)rtumsg->MsgData[1];
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
}
|
|
|
|
|
for ( i = istart; i < len + 2;)
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
pnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8);
|
|
|
|
|
i += 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8)+(rtumsg->MsgData[i+2]<<16);
|
|
|
|
|
i += 3;
|
|
|
|
|
}
|
|
|
|
|
pnt -= pPortParam->iDiBaseAddr;
|
|
|
|
|
|
|
|
|
|
if ( flag == 0 )
|
|
|
|
|
st = rtumsg->MsgData[i++] & 0x01;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch ( rtumsg->MsgData[i++] & 0x3 )
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
st = 1;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
st = 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
st = 0x0f;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( st == 0x0f )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
sec = rtumsg->MsgData[i] + ( rtumsg->MsgData[i+1] << 8 );
|
|
|
|
|
pntmsg.SoeTime.mSec = sec % 1000;
|
|
|
|
|
pntmsg.SoeTime.Sec = sec / 1000;
|
|
|
|
|
pntmsg.SoeTime.Min = (rtumsg->MsgData[i+2] & 0x3f); // <20><>
|
|
|
|
|
i += 3;
|
|
|
|
|
GetLocalTimeEx(&sm);
|
|
|
|
|
if(abs(pntmsg.SoeTime.Min-sm.Min) > 50)
|
|
|
|
|
{
|
|
|
|
|
i64Millseconds = SystemTimeToMillseconds(&sm, 0);
|
|
|
|
|
if(i64Millseconds > 0)
|
|
|
|
|
{
|
|
|
|
|
// <20><>ȥһСʱ
|
|
|
|
|
iTime = (long)(i64Millseconds/1000) - 3600;
|
|
|
|
|
testtm = localtime(&iTime);
|
|
|
|
|
sm.Year = testtm->tm_year + 1900;
|
|
|
|
|
sm.Month = testtm->tm_mon + 1;
|
|
|
|
|
sm.Day = testtm->tm_mday;
|
|
|
|
|
sm.Hour = testtm->tm_hour;
|
|
|
|
|
sm.Min = testtm->tm_min;
|
|
|
|
|
sm.Sec = testtm->tm_sec;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pntmsg.SoeTime.Hour = sm.Hour;
|
|
|
|
|
pntmsg.SoeTime.Day = sm.Day;
|
|
|
|
|
pntmsg.SoeTime.Month = sm.Month;
|
|
|
|
|
pntmsg.SoeTime.Year = sm.Year;
|
|
|
|
|
pntmsg.Status = st;
|
|
|
|
|
|
|
|
|
|
SetPntMsg(commid, pnt, (void *)&pntmsg, DI_PNT_TYPE, PNT_SOE_TIME);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104PiDataProcess( RTUMSG * rtumsg )
|
|
|
|
|
{
|
|
|
|
|
int i, point, len;
|
|
|
|
|
PI_DEF pntmsg;
|
|
|
|
|
int commid, istart;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
len = (int)rtumsg->MsgData[1];
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
}
|
|
|
|
|
for ( i = istart; i < 2 + len; )
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
point = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8);
|
|
|
|
|
i += 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
point = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8)+(rtumsg->MsgData[i+2]<<16);
|
|
|
|
|
i += 3;
|
|
|
|
|
}
|
|
|
|
|
point -= pPortParam->iPiBaseAddr;
|
|
|
|
|
|
|
|
|
|
pntmsg.RawValue = (rtumsg->MsgData[i+3]<<24) + (rtumsg->MsgData[i+2]<<16)
|
|
|
|
|
+ (rtumsg->MsgData[i+1]<<8) + rtumsg->MsgData[i];
|
|
|
|
|
//rtumsg->MsgData[i+4]; // ˳<><CBB3><EFBFBD>Ǻ<EFBFBD>
|
|
|
|
|
i += 5;
|
|
|
|
|
|
|
|
|
|
SetPntMsg(commid, point, (void *)&pntmsg, PI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104PiWithTimeDataProcess( RTUMSG *rtumsg )
|
|
|
|
|
{
|
|
|
|
|
int i, point, len;
|
|
|
|
|
PI_DEF pntmsg;
|
|
|
|
|
int commid, istart;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
len = (int)rtumsg->MsgData[1];
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
}
|
|
|
|
|
for ( i = istart; i < 2 + len; )
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
point = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8);
|
|
|
|
|
i += 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
point = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8)+(rtumsg->MsgData[i+2]<<16);
|
|
|
|
|
i += 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
point -= pPortParam->iPiBaseAddr;
|
|
|
|
|
|
|
|
|
|
pntmsg.RawValue = (rtumsg->MsgData[i+3]<<24) + (rtumsg->MsgData[i+2]<<16)
|
|
|
|
|
+ (rtumsg->MsgData[i+1]<<8) + rtumsg->MsgData[i];
|
|
|
|
|
//rtumsg->MsgData[i+4]; // ˳<><CBB3><EFBFBD>Ǻ<EFBFBD>
|
|
|
|
|
// 3bytes ʱ<><CAB1>
|
|
|
|
|
i += 8;
|
|
|
|
|
|
|
|
|
|
SetPntMsg(commid, point, (void *)&pntmsg, PI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104BaoHuDataProcess( RTUMSG *rtumsg )
|
|
|
|
|
{
|
|
|
|
|
// <20>ù<EFBFBD><C3B9>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104DefaultBaoHuDataProcess( RTUMSG *rtumsg )
|
|
|
|
|
{
|
|
|
|
|
// <20>ù<EFBFBD><C3B9>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 7 BYTE <20><>ʱ<EFBFBD><CAB1>
|
|
|
|
|
//***************************************************************
|
|
|
|
|
//* Buban104 SOE <20><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>(7 bytes ʱ<><CAB1>) *
|
|
|
|
|
//***************************************************************
|
|
|
|
|
void Buban104SoeDataProcessWithCP56Time2a( RTUMSG *rtumsg, int flag )
|
|
|
|
|
{
|
|
|
|
|
_int64 i64Millseconds;
|
|
|
|
|
time_t iTime;
|
|
|
|
|
int i, pnt, len;
|
|
|
|
|
char st;
|
|
|
|
|
int sec;
|
|
|
|
|
DI_DEF pntmsg;
|
|
|
|
|
DAY_TIME sm;
|
|
|
|
|
struct tm *testtm;
|
|
|
|
|
int commid, istart;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
len = (int)rtumsg->MsgData[1];
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
}
|
|
|
|
|
for ( i = istart; i < len + 2; )
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
pnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8);
|
|
|
|
|
i += 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8)+(rtumsg->MsgData[i+2]<<16);
|
|
|
|
|
i += 3;
|
|
|
|
|
}
|
|
|
|
|
pnt -= pPortParam->iDiBaseAddr;
|
|
|
|
|
|
|
|
|
|
if(flag == 0)
|
|
|
|
|
{
|
|
|
|
|
st = rtumsg->MsgData[i++] & 0x01;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch ( rtumsg->MsgData[i++] & 0x3 )
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
st = 1;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
st = 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
st = 0x0f;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(st == 0x0f)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sec = rtumsg->MsgData[i] + (rtumsg->MsgData[i+1] << 8);
|
|
|
|
|
pntmsg.SoeTime.mSec = sec % 1000;
|
|
|
|
|
pntmsg.SoeTime.Sec = sec / 1000;
|
|
|
|
|
pntmsg.SoeTime.Min = (char)(rtumsg->MsgData[i+2] & 0x3f);
|
|
|
|
|
pntmsg.SoeTime.Hour = (char)(rtumsg->MsgData[i+3] & 0x1f);
|
|
|
|
|
pntmsg.SoeTime.Day = (char)(rtumsg->MsgData[i+4] & 0x1f);
|
|
|
|
|
//rtumsg->MsgData[i+5]; // month
|
|
|
|
|
//rtumsg->MsgData[i+6]; // year
|
|
|
|
|
i += 7;
|
|
|
|
|
|
|
|
|
|
GetLocalTimeEx(&sm);
|
|
|
|
|
if((pntmsg.SoeTime.Day-sm.Day) < 0)
|
|
|
|
|
{
|
|
|
|
|
i64Millseconds = SystemTimeToMillseconds(&sm, 0);
|
|
|
|
|
if(i64Millseconds > 0)
|
|
|
|
|
{
|
|
|
|
|
// <20><>ȥһСʱ
|
|
|
|
|
iTime = (long)(i64Millseconds/1000) - 3600;
|
|
|
|
|
testtm = localtime(&iTime);
|
|
|
|
|
sm.Year = testtm->tm_year + 1900;
|
|
|
|
|
sm.Month = testtm->tm_mon + 1;
|
|
|
|
|
sm.Day = testtm->tm_mday;
|
|
|
|
|
sm.Hour = testtm->tm_hour;
|
|
|
|
|
sm.Min = testtm->tm_min;
|
|
|
|
|
sm.Sec = testtm->tm_sec;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pntmsg.SoeTime.Month = sm.Month;
|
|
|
|
|
pntmsg.SoeTime.Year = sm.Year;
|
|
|
|
|
pntmsg.Status = st;
|
|
|
|
|
SetPntMsg(commid, pnt, (void *)&pntmsg, DI_PNT_TYPE, PNT_SOE_TIME);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104AiWithDataProcessWithM_ME_TD_1(RTUMSG * rtumsg)
|
|
|
|
|
{
|
|
|
|
|
int i, aipnt, len;
|
|
|
|
|
AI_DEF pntmsg;
|
|
|
|
|
char szbuf[256];
|
|
|
|
|
int commid, istart, istep;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
len = (int)rtumsg->MsgData[1];
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 10;
|
|
|
|
|
istep = 11;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
istep = 12;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>仯ң<E4BBAF><D2A3>
|
|
|
|
|
for ( i = istart; i < 2 + len; )
|
|
|
|
|
{
|
|
|
|
|
if( ( i + istep ) > (2 + len))
|
|
|
|
|
{
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
sprintf(szbuf, ">>>>>WARN(%04d): Commid_%02d (iLen=%d) is not enough in Buban104AiWithDataProcessWithM_ME_TD_1",
|
|
|
|
|
_getpid(), commid, len);
|
|
|
|
|
#else
|
|
|
|
|
sprintf(szbuf, ">>>>>WARN(%04d): Commid_%02d (iLen=%d) is not enough in Buban104AiWithDataProcessWithM_ME_TD_1",
|
|
|
|
|
getpid(), commid, len);
|
|
|
|
|
#endif
|
|
|
|
|
DebugPrint(szbuf);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
aipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8);
|
|
|
|
|
i += 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
aipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8)+(rtumsg->MsgData[i+2]<<16);
|
|
|
|
|
i += 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aipnt -= pPortParam->iAiBaseAddr;
|
|
|
|
|
|
|
|
|
|
pntmsg.RawValue = (short)((rtumsg->MsgData[i+1]<<8) + rtumsg->MsgData[i]);
|
|
|
|
|
|
|
|
|
|
SetPntMsg(commid, aipnt, (void *)&pntmsg, AI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
|
|
|
|
|
// 7<>ֽ<EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
i += 9;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104AiWithDataProcessWithM_ME_TE_1(RTUMSG * rtumsg)
|
|
|
|
|
{
|
|
|
|
|
Buban104AiWithDataProcessWithM_ME_TD_1(rtumsg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Buban104AiWithDataProcessWithM_ME_TF_1(RTUMSG * rtumsg)
|
|
|
|
|
{
|
|
|
|
|
int i, aipnt, len;
|
|
|
|
|
AI_DEF pntmsg;
|
|
|
|
|
char szbuf[256];
|
|
|
|
|
float fValue;
|
|
|
|
|
int commid, istart, istep;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
len = (int)rtumsg->MsgData[1];
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 10;
|
|
|
|
|
istep = 14;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
istep = 15;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>仯ң<E4BBAF><D2A3>
|
|
|
|
|
for ( i = istart; i < 2 + len; )
|
|
|
|
|
{
|
|
|
|
|
if( ( i + istep ) > (2 + len))
|
|
|
|
|
{
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
sprintf(szbuf, ">>>>>WARN(%04d): Commid_%02d (iLen=%d) is not enough in Buban104AiWithDataProcessWithM_ME_TF_1",
|
|
|
|
|
_getpid(), commid, len);
|
|
|
|
|
#else
|
|
|
|
|
sprintf(szbuf, ">>>>>WARN(%04d): Commid_%02d (iLen=%d) is not enough in Buban104AiWithDataProcessWithM_ME_TF_1",
|
|
|
|
|
getpid(), commid, len);
|
|
|
|
|
#endif
|
|
|
|
|
DebugPrint(szbuf);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
aipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8);
|
|
|
|
|
i += 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
aipnt = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8)+(rtumsg->MsgData[i+2]<<16);
|
|
|
|
|
i += 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aipnt -= pPortParam->iAiBaseAddr;
|
|
|
|
|
|
|
|
|
|
fValue = *((float *)&rtumsg->MsgData[i]);
|
|
|
|
|
SequenceRtuToHost((char *)&fValue, sizeof(float));
|
|
|
|
|
|
|
|
|
|
// Ʒ<><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// rtumsg->MsgData[i+1];
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>2λС<CEBB><D0A1>
|
|
|
|
|
pntmsg.RawValue = (int)(fValue * 100);
|
|
|
|
|
SetPntMsg(commid, aipnt, (void *)&pntmsg, AI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
|
|
|
|
|
// 7<>ֽ<EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
i += 12;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Buban104 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>with time
|
|
|
|
|
void Buban104PiWithTimeDataProcessWithM_IT_TB_1(RTUMSG *rtumsg)
|
|
|
|
|
{
|
|
|
|
|
int i, point, len;
|
|
|
|
|
AI_DEF pntmsg;
|
|
|
|
|
char szbuf[256];
|
|
|
|
|
int commid, istart, istep;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
commid = rtumsg->PortIdx;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
istart = 10;
|
|
|
|
|
istep = 14;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
istart = 12;
|
|
|
|
|
istep = 15;
|
|
|
|
|
}
|
|
|
|
|
len = (int)rtumsg->MsgData[1];
|
|
|
|
|
for ( i = istart; i < 2 + len; )
|
|
|
|
|
{
|
|
|
|
|
if( ( i + istep ) > (2 + len))
|
|
|
|
|
{
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
sprintf(szbuf, ">>>>>WARN(%04d): Commid_%02d (iLen=%d) is not enough in Buban104PiWithTimeDataProcessWithM_IT_TB_1",
|
|
|
|
|
_getpid(), commid, len);
|
|
|
|
|
#else
|
|
|
|
|
sprintf(szbuf, ">>>>>WARN(%04d): Commid_%02d (iLen=%d) is not enough in Buban104PiWithTimeDataProcessWithM_IT_TB_1",
|
|
|
|
|
getpid(), commid, len);
|
|
|
|
|
#endif
|
|
|
|
|
DebugPrint(szbuf);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
point = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8);
|
|
|
|
|
i += 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
point = rtumsg->MsgData[i]+(rtumsg->MsgData[i+1]<<8)+(rtumsg->MsgData[i+2]<<16);
|
|
|
|
|
i += 3;
|
|
|
|
|
}
|
|
|
|
|
point -= pPortParam->iPiBaseAddr;
|
|
|
|
|
|
|
|
|
|
pntmsg.RawValue = (rtumsg->MsgData[i+3]<<24) + (rtumsg->MsgData[i+2]<<16)
|
|
|
|
|
+ (rtumsg->MsgData[i+1]<<8) + rtumsg->MsgData[i];
|
|
|
|
|
|
|
|
|
|
SetPntMsg(commid, point, (void *)&pntmsg, PI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
|
|
|
|
|
// 1 BYTE (IV CA CY ˳<><CBB3><EFBFBD><EFBFBD>)
|
|
|
|
|
// 7 BYTE ʱ<><CAB1>
|
|
|
|
|
i += 12;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//=========================<3D><><EFBFBD><EFBFBD>ΪBuban104ת<34><D7AA><EFBFBD><EFBFBD><EFBFBD>ݹ<EFBFBD><DDB9><EFBFBD>=======================//
|
|
|
|
|
void ProvBuban104dataProcess(int commid, RTUMSG *rtumsg)
|
|
|
|
|
{
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>( <20><><EFBFBD><EFBFBD><EFBFBD>ֽڵĵڶ<C4B5><DAB6><EFBFBD><EFBFBD>ֽ<EFBFBD>)
|
|
|
|
|
if(rtumsg->MsgData[rtumsg->MsgLen+1] > 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// format-i
|
|
|
|
|
if((rtumsg->MsgData[2] & 0x01) == 0)
|
|
|
|
|
{
|
|
|
|
|
if(pPortParam->LinkOk)
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104FormatI(commid, rtumsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// format-s,format-u
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// format-u
|
|
|
|
|
if((rtumsg->MsgData[2] & 0x02) != 0)
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104FormatU( commid, rtumsg );
|
|
|
|
|
}
|
|
|
|
|
// format-s
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104FormatS( commid, rtumsg );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProvBuban104FormatI(int commid, RTUMSG *rtumsg)
|
|
|
|
|
{
|
|
|
|
|
//WORD wLastSequence;
|
|
|
|
|
int iSequenceInc;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
// length
|
|
|
|
|
if( rtumsg->MsgData[1] < 4 )
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
// <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
pPortParam->lTimeOutCnt = 0;
|
|
|
|
|
|
|
|
|
|
pPortParam->wAckSequence = (rtumsg->MsgData[4] + (rtumsg->MsgData[5]<<8)) >> 1;
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
|
|
|
|
|
// wen 2005.09.19 ֡<><D6A1>ƥ<EFBFBD><C6A5><EFBFBD>㷨<EFBFBD><EFBFBD>
|
|
|
|
|
/*
|
|
|
|
|
if(pPortParam->wAckSequence == 0 )
|
|
|
|
|
{
|
|
|
|
|
wLastSequence = MAX_SEQUENCE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wLastSequence = pPortParam->wAckSequence-1;
|
|
|
|
|
}
|
|
|
|
|
if((pPortParam->wSendSequence != pPortParam->wAckSequence)
|
|
|
|
|
&& (pPortParam->wSendSequence != wLastSequence))
|
|
|
|
|
{
|
|
|
|
|
pPortParam->bAckRight = FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pPortParam->bCloseSocket = FALSE;
|
|
|
|
|
pPortParam->bAckRight = TRUE;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
iSequenceInc = pPortParam->wSendSequence - pPortParam->wAckSequence;
|
|
|
|
|
if(iSequenceInc < 0)
|
|
|
|
|
{
|
|
|
|
|
iSequenceInc += MAX_SEQUENCE;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1>Ӧ<EFBFBD><D3A6><EFBFBD>ߴ<EFBFBD>(ȱʡֵ=MAX_FRAMEMATCHING_SIZE)
|
|
|
|
|
if((pPortParam->wSendSequence != pPortParam->wAckSequence )
|
|
|
|
|
&& (iSequenceInc > pPortParam->m_iFrameSize))
|
|
|
|
|
{
|
|
|
|
|
pPortParam->bAckRight = FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pPortParam->bCloseSocket = FALSE;
|
|
|
|
|
pPortParam->bAckRight = TRUE;
|
|
|
|
|
}
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
|
|
|
|
|
|
|
|
|
|
pPortParam->wRecvSequence = ((rtumsg->MsgData[2] + (rtumsg->MsgData[3]<<8)) >> 1)+1;
|
|
|
|
|
pPortParam->wRecvSequence %= MAX_SEQUENCE;
|
|
|
|
|
|
|
|
|
|
switch(rtumsg->MsgData[6])
|
|
|
|
|
{
|
|
|
|
|
case 1: // <20><><EFBFBD><EFBFBD>ң<EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2: // <20><><EFBFBD><EFBFBD>ң<EFBFBD><D2A3>SOE<4F><45><EFBFBD><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3: // ˫<><CBAB>ң<EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 4: // <20><><EFBFBD><EFBFBD>ң<EFBFBD><D2A3>SOE<4F><45><EFBFBD><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 5: // <20><>ѹ<EFBFBD><D1B9><EFBFBD>ֽ<EFBFBD>ͷλ<CDB7><CEBB>
|
|
|
|
|
break;
|
|
|
|
|
case 6: // <20><>ѹ<EFBFBD><D1B9><EFBFBD>ֽ<EFBFBD>ͷλ<CDB7>ô<EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
break;
|
|
|
|
|
case 7: // <20><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ProvBuban104SendAllData(commid, rtumsg);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 9: // <20><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ң<EFBFBD><D2A3>
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 10: // <20><>Ʒ<EFBFBD>ʴ<EFBFBD>ʱ<EFBFBD><CAB1>ң<EFBFBD><D2A3>
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 21: // ȫң<C8AB><D2A3><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD> <20><><EFBFBD>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 15: // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
case 16: // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 17:
|
|
|
|
|
case 18:
|
|
|
|
|
case 19: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 45: // wen 2006.07.11
|
|
|
|
|
case 46: // ң<>ط<EFBFBD>У
|
|
|
|
|
case 47: // ң<><D2A3><EFBFBD><EFBFBD>У
|
|
|
|
|
//ProvBuban104YkYtData(commid, rtumsg);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 100: // <20>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//ProvBuban104SendAllData(commid, rtumsg);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 101: // <20>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//ProvBuban104SendPIData(commid, rtumsg);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 103: // ʱ<><CAB1>ͬ<EFBFBD><CDAC>ȷ<EFBFBD><C8B7>֡
|
|
|
|
|
ProvBuban104ProcessTime(commid, rtumsg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProvBuban104FormatU(int commid, RTUMSG *rtumsg)
|
|
|
|
|
{
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
// length
|
|
|
|
|
if( rtumsg->MsgData[1] != 4 )
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
switch(rtumsg->MsgData[2] & 0xfc)
|
|
|
|
|
{
|
|
|
|
|
case 0x04: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
InitBuban104CommandBuffer(commid);
|
|
|
|
|
pPortParam->LinkOk = TRUE;
|
|
|
|
|
MakeBuban104Command(commid, FORMAT_U_START_CON);
|
|
|
|
|
break;
|
|
|
|
|
case 0x10: // ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|
|
|
|
pPortParam->LinkOk = FALSE;
|
|
|
|
|
MakeBuban104Command(commid, FORMAT_U_STOP_CON);
|
|
|
|
|
break;
|
|
|
|
|
case 0x80: // <20><><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|
|
|
|
pPortParam->bAckRight = TRUE;
|
|
|
|
|
// <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
pPortParam->lTimeOutCnt = 0;
|
|
|
|
|
pPortParam->bCloseSocket = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 0x40: // <20><><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>
|
|
|
|
|
if(!pPortParam->LinkOk)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MakeBuban104Command(commid, FORMAT_U_TEST_CON);
|
|
|
|
|
pPortParam->lTimeOutCnt = 0;
|
|
|
|
|
pPortParam->bCloseSocket = FALSE;
|
|
|
|
|
pPortParam->bAckRight = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
default: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
|
|
|
|
pPortParam->bAckRight = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProvBuban104FormatS(int commid, RTUMSG *rtumsg)
|
|
|
|
|
{
|
|
|
|
|
//WORD wLastSequence;
|
|
|
|
|
int iSequenceInc;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
// length
|
|
|
|
|
if( rtumsg->MsgData[1] != 4 )
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
pPortParam->wAckSequence = (rtumsg->MsgData[4] + (rtumsg->MsgData[5]<<8)) >> 1;
|
|
|
|
|
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
|
|
|
|
|
// wen 2005.09.19 ֡<><D6A1>ƥ<EFBFBD><C6A5><EFBFBD>㷨<EFBFBD><EFBFBD>
|
|
|
|
|
/*
|
|
|
|
|
if(pPortParam->wAckSequence == 0)
|
|
|
|
|
{
|
|
|
|
|
wLastSequence = MAX_SEQUENCE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wLastSequence = pPortParam->wAckSequence-1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if((pPortParam->wSendSequence == (pPortParam->wAckSequence + 1) )
|
|
|
|
|
|| (pPortParam->wSendSequence == wLastSequence))
|
|
|
|
|
{
|
|
|
|
|
pPortParam->bAckRight = TRUE;
|
|
|
|
|
pPortParam->lTimeOutCnt = 0;
|
|
|
|
|
pPortParam->bCloseSocket = FALSE;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
iSequenceInc = pPortParam->wSendSequence - pPortParam->wAckSequence;
|
|
|
|
|
if(iSequenceInc < 0)
|
|
|
|
|
{
|
|
|
|
|
iSequenceInc += MAX_SEQUENCE;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1>Ӧ<EFBFBD><D3A6><EFBFBD>ߴ<EFBFBD>(ȱʡֵ=MAX_FRAMEMATCHING_SIZE)
|
|
|
|
|
if((pPortParam->wSendSequence == pPortParam->wAckSequence)
|
|
|
|
|
|| (iSequenceInc < pPortParam->m_iFrameSize))
|
|
|
|
|
{
|
|
|
|
|
pPortParam->bAckRight = TRUE;
|
|
|
|
|
pPortParam->lTimeOutCnt = 0;
|
|
|
|
|
pPortParam->bCloseSocket = FALSE;
|
|
|
|
|
}
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
//<2F><><EFBFBD>ٻ<EFBFBD>ȷ<EFBFBD><C8B7>(<28><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>[8]=0x07,0x09ȷ<39><C8B7>; =0x0a <20><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>)
|
|
|
|
|
void ProvBuban104SendAllData(int commid, RTUMSG * rtumsg)
|
|
|
|
|
{
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
int iGroup, iCmdType, iLen=0;
|
|
|
|
|
WORD wTransCause;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
iGroup = rtumsg->MsgData[12];
|
|
|
|
|
wTransCause = rtumsg->MsgData[8];
|
|
|
|
|
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>ٻ<EFBFBD>Ӧ<EFBFBD><D3A6>
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
iLen = 2;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 8; // Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>ٽ<EFBFBD><D9BD><EFBFBD>
|
|
|
|
|
commandbuf[iLen++] = 0x81; // <20><EFBFBD><DEB6><EFBFBD>VSQ
|
|
|
|
|
commandbuf[iLen++] = 9; // <20><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>
|
|
|
|
|
commandbuf[iLen++] = 0; // Ӧ<>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
commandbuf[iLen++] = 0; // Ӧ<>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
commandbuf[iLen++] = 0xFF; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FUN
|
|
|
|
|
commandbuf[iLen++] = 0; // <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>INF
|
|
|
|
|
commandbuf[iLen++] = 0; // ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SCN
|
|
|
|
|
commandbuf[1] = (BYTE)(iLen - 2);
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLen);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
// wen 2006.03.23 ֧<>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|
|
|
|
//ProvBuban104SendAI(commid, rtumsg, 0);
|
|
|
|
|
//====================================================================
|
|
|
|
|
if(pPortParam->m_bProvAiType == 13)
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104SendAIwithFloat(commid, rtumsg, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104SendAI(commid, rtumsg, 0);
|
|
|
|
|
}
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
|
|
ProvBuban104SendDI(commid, rtumsg, 0);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ProvMakeBuban104Command(commid, ASK_ALLDATA_END);
|
|
|
|
|
pPortParam->m_psBaoHu->DiChange = FALSE;
|
|
|
|
|
pPortParam->Initdata = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
void ProvBuban104SendAllData(int commid, RTUMSG * rtumsg)
|
|
|
|
|
{
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
int iGroup, iCmdType, iLen = 0;
|
|
|
|
|
WORD wTransCause;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if (VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
iGroup = rtumsg->MsgData[12];
|
|
|
|
|
wTransCause = rtumsg->MsgData[8];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iGroup = rtumsg->MsgData[15];
|
|
|
|
|
wTransCause = rtumsg->MsgData[8] + (rtumsg->MsgData[9] << 8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
if (iGroup != 20)
|
|
|
|
|
{
|
|
|
|
|
iGroup -= 20;
|
|
|
|
|
//<2F><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
|
|
|
|
|
if ((iGroup <= 0) || (iGroup > 12))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (iGroup > 8)
|
|
|
|
|
{
|
|
|
|
|
iGroup -= 8;
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
// wen 2006.03.23 ֧<>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|
|
|
|
//ProvBuban104SendAI(commid, rtumsg, iGroup);
|
|
|
|
|
//====================================================================
|
|
|
|
|
if (pPortParam->m_bProvAiType == 13)
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104SendAIwithFloat(commid, rtumsg, iGroup);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104SendAI(commid, rtumsg, iGroup);
|
|
|
|
|
}
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ProvBuban104SendDI(commid, rtumsg, iGroup);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pPortParam->ProvAckOrNot)
|
|
|
|
|
{
|
|
|
|
|
iCmdType = NORMAL_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
iLen = 2;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 100;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
if (VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
switch (wTransCause)
|
|
|
|
|
{
|
|
|
|
|
case 0x0006://<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[iLen++] = 7;
|
|
|
|
|
break;
|
|
|
|
|
case 0x0008://ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|
|
|
|
default:
|
|
|
|
|
commandbuf[iLen++] = 9;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (wTransCause)
|
|
|
|
|
{
|
|
|
|
|
case 0x0006://<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[iLen++] = 7;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
break;
|
|
|
|
|
case 0x0008://ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|
|
|
|
default:
|
|
|
|
|
commandbuf[iLen++] = 9;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[iLen++] = 0x14;
|
|
|
|
|
commandbuf[1] = (BYTE)(iLen - 2);
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLen);
|
|
|
|
|
|
|
|
|
|
if (wTransCause != 0x0006)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
// wen 2006.03.23 ֧<>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|
|
|
|
//ProvBuban104SendAI(commid, rtumsg, 0);
|
|
|
|
|
//====================================================================
|
|
|
|
|
if (pPortParam->m_bProvAiType == 13)
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104SendAIwithFloat(commid, rtumsg, 0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104SendAI(commid, rtumsg, 0);
|
|
|
|
|
}
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
|
|
ProvBuban104SendDI(commid, rtumsg, 0);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ProvMakeBuban104Command(commid, ASK_ALLDATA_END);
|
|
|
|
|
pPortParam->m_psBaoHu->DiChange = FALSE;
|
|
|
|
|
pPortParam->Initdata = TRUE;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void ProvBuban104SendPIData(int commid, RTUMSG * rtumsg)
|
|
|
|
|
{
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
int iLen, iCmdType, iGroup;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
iGroup = rtumsg->MsgData[12] & 0x3F;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iGroup = rtumsg->MsgData[15] & 0x3F;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// wen 2006.04.03 <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>97<39><37><EFBFBD><EFBFBD>2000<30><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䲻ͬ
|
|
|
|
|
if(pPortParam->m_iPublishYear == 1997)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
if( iGroup != 1 )
|
|
|
|
|
{
|
|
|
|
|
//<2F><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9><EFBFBD><EFBFBD>
|
|
|
|
|
if(( iGroup <= 0 ) || ( iGroup > 5 ))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProvBuban104SendPI(commid, rtumsg, iGroup-1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
if( iGroup != 5 )
|
|
|
|
|
{
|
|
|
|
|
//<2F><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9><EFBFBD><EFBFBD>
|
|
|
|
|
if(( iGroup <= 0 ) || ( iGroup > 5 ))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProvBuban104SendPI(commid, rtumsg, iGroup);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(pPortParam->ProvAckOrNot)
|
|
|
|
|
{
|
|
|
|
|
iCmdType = NORMAL_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>ٻ<EFBFBD>ȷ<EFBFBD><C8B7>
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
iLen = 2;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 101;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 7;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = rtumsg->MsgData[12];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 7;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = rtumsg->MsgData[15];
|
|
|
|
|
}
|
|
|
|
|
commandbuf[1] = (BYTE)(iLen - 2);
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLen);
|
|
|
|
|
|
|
|
|
|
ProvBuban104SendPI(commid, rtumsg, 0);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
iLen = 2;
|
|
|
|
|
//commandbuf[1] = 14;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 101;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 10;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = rtumsg->MsgData[12];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 10;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = rtumsg->MsgData[15];
|
|
|
|
|
}
|
|
|
|
|
commandbuf[1] = (BYTE)(iLen - 2);
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLen);
|
|
|
|
|
|
|
|
|
|
pPortParam->Initdata = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProvBuban104ProcessTime(int commid, RTUMSG *rtumsg)
|
|
|
|
|
{
|
|
|
|
|
int iLen, iCmdType;
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
WORD wTransCause;
|
|
|
|
|
DAY_TIME sCurTime;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
wTransCause = rtumsg->MsgData[8];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
wTransCause = rtumsg->MsgData[8] + (rtumsg->MsgData[9]<<8);
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>
|
|
|
|
|
switch(wTransCause)
|
|
|
|
|
{
|
|
|
|
|
case 0x0006://<2F><><EFBFBD><EFBFBD>(<28><>ʱ)
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
//commandbuf[1] = 20;
|
|
|
|
|
iLen = 2;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 103;
|
|
|
|
|
commandbuf[iLen++] = 1;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 7;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 7;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
GetLocalTimeEx(&sCurTime);
|
|
|
|
|
sCurTime.mSec = sCurTime.Sec * 1000 + sCurTime.mSec;
|
|
|
|
|
commandbuf[iLen++] = sCurTime.mSec % 256;
|
|
|
|
|
commandbuf[iLen++] = sCurTime.mSec / 256;
|
|
|
|
|
commandbuf[iLen++] = (u_char)sCurTime.Min;
|
|
|
|
|
commandbuf[iLen++] = (u_char)sCurTime.Hour;
|
|
|
|
|
commandbuf[iLen++] = (u_char)sCurTime.Day;
|
|
|
|
|
commandbuf[iLen++] = (u_char)sCurTime.Month;
|
|
|
|
|
commandbuf[iLen++] = (u_char)(sCurTime.Year%100);
|
|
|
|
|
commandbuf[1] = (BYTE)(iLen - 2);
|
|
|
|
|
if(pPortParam->ProvAckOrNot)
|
|
|
|
|
{
|
|
|
|
|
iCmdType = INSERT_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
PutPollCmdToBuf(commid, FAST_POLL_CMD, 0, (char *)commandbuf, iLen);
|
|
|
|
|
|
|
|
|
|
// <20><>ʱ
|
|
|
|
|
if(1 == pPortParam->m_psBaoHu->CheckTime)
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
sCurTime.mSec = rtumsg->MsgData[12] + (rtumsg->MsgData[13] << 8);
|
|
|
|
|
sCurTime.Sec = sCurTime.mSec/1000;
|
|
|
|
|
sCurTime.mSec = sCurTime.mSec % 1000;
|
|
|
|
|
sCurTime.Min = rtumsg->MsgData[14] & 0x3F;
|
|
|
|
|
sCurTime.Hour = rtumsg->MsgData[15] & 0x1F;
|
|
|
|
|
sCurTime.Day = rtumsg->MsgData[16] & 0x1F;
|
|
|
|
|
sCurTime.Month= rtumsg->MsgData[17] & 0x0F;
|
|
|
|
|
sCurTime.Year = (rtumsg->MsgData[18] & 0x7F)+2000;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sCurTime.mSec = rtumsg->MsgData[15] + (rtumsg->MsgData[16] << 8);
|
|
|
|
|
sCurTime.Sec = sCurTime.mSec/1000;
|
|
|
|
|
sCurTime.mSec = sCurTime.mSec % 1000;
|
|
|
|
|
sCurTime.Min = rtumsg->MsgData[17] & 0x3F;
|
|
|
|
|
sCurTime.Hour = rtumsg->MsgData[18] & 0x1F;
|
|
|
|
|
sCurTime.Day = rtumsg->MsgData[19] & 0x1F;
|
|
|
|
|
sCurTime.Month= rtumsg->MsgData[20] & 0x0F;
|
|
|
|
|
sCurTime.Year = (rtumsg->MsgData[21] & 0x7F)+2000;
|
|
|
|
|
}
|
|
|
|
|
SetLocalTimeEx(&sCurTime);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x07://<2F><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProvBuban104SendPI(int commid, RTUMSG *rtumsg, int iGroupNo)
|
|
|
|
|
{
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
DWORD dwStartAddr;
|
|
|
|
|
int iLenth, iSendCount=1;
|
|
|
|
|
int i, j, iAllDataCount, iSendNum;
|
|
|
|
|
int iNo;
|
|
|
|
|
int iCmdType;
|
|
|
|
|
PI_DEF pntmsg;
|
|
|
|
|
PROV_PI_PNT *piprovptr;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(pPortParam->ProvAckOrNot)
|
|
|
|
|
{
|
|
|
|
|
iCmdType = NORMAL_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(iGroupNo == 0)//<2F><><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
dwStartAddr = MAX_GROUP_PINUM*iGroupNo + pPortParam->iPiBaseAddr;
|
|
|
|
|
|
|
|
|
|
iAllDataCount = pPortParam->m_psBaoHu->PiNum;
|
|
|
|
|
iSendCount = (iAllDataCount+MAX_104_PINUM-1)/MAX_104_PINUM;
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else//<2F><><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
dwStartAddr = MAX_GROUP_PINUM*(iGroupNo-1);
|
|
|
|
|
iAllDataCount = pPortParam->m_psBaoHu->PiNum - dwStartAddr;
|
|
|
|
|
|
|
|
|
|
dwStartAddr += pPortParam->iPiBaseAddr;
|
|
|
|
|
|
|
|
|
|
if( iAllDataCount > MAX_GROUP_PINUM)
|
|
|
|
|
{
|
|
|
|
|
iSendCount = 2;
|
|
|
|
|
if((iAllDataCount - MAX_GROUP_PINUM)>0)
|
|
|
|
|
iAllDataCount = MAX_GROUP_PINUM;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
piprovptr = (PROV_PI_PNT *)pPortParam->m_psBaoHu->PiPtr;
|
|
|
|
|
for(i = 0; i < iSendCount; i++)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[2] = 0;
|
|
|
|
|
commandbuf[3] = 0;
|
|
|
|
|
commandbuf[4] = 0;
|
|
|
|
|
commandbuf[5] = 0;
|
|
|
|
|
commandbuf[6] = 15;
|
|
|
|
|
commandbuf[8] = 37+iGroupNo;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
iLenth = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = 0;
|
|
|
|
|
commandbuf[10] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[11] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
iLenth = 12;
|
|
|
|
|
}
|
|
|
|
|
//ң<><D2A3>ֵ
|
|
|
|
|
if(iAllDataCount>MAX_104_PINUM)
|
|
|
|
|
{
|
|
|
|
|
iAllDataCount -= MAX_104_PINUM;
|
|
|
|
|
iSendNum = MAX_104_PINUM;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iSendNum = iAllDataCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(j = 0; j < iSendNum; j++, dwStartAddr++)
|
|
|
|
|
{
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLenth++] = (char)(dwStartAddr & 0x00ff);
|
|
|
|
|
commandbuf[iLenth++] = (char)((dwStartAddr & 0xff00)>>8);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLenth++] = (char)(dwStartAddr & 0x00ff);
|
|
|
|
|
commandbuf[iLenth++] = (char)((dwStartAddr & 0xff00)>>8);
|
|
|
|
|
commandbuf[iLenth++] = (char)((dwStartAddr & 0xff0000)>>16);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iNo = dwStartAddr - pPortParam->iPiBaseAddr;
|
|
|
|
|
|
|
|
|
|
pntmsg.RawValue = 0;
|
|
|
|
|
GetPntMsg(piprovptr[iNo].PortNo, piprovptr[iNo].PntNo,
|
|
|
|
|
(void *)&pntmsg, PI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
piprovptr[iNo].ChangeFlag = FALSE;
|
|
|
|
|
|
|
|
|
|
commandbuf[iLenth++] = (char)(pntmsg.RawValue & 0x000000ff);
|
|
|
|
|
commandbuf[iLenth++] = (char)((pntmsg.RawValue & 0x0000ff00)>>8);
|
|
|
|
|
commandbuf[iLenth++] = (char)((pntmsg.RawValue & 0x00ff0000)>>16);
|
|
|
|
|
commandbuf[iLenth++] = (char)((pntmsg.RawValue & 0xff000000)>>24);
|
|
|
|
|
commandbuf[iLenth++] = (char)(j+1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commandbuf[7] = (BYTE)j;
|
|
|
|
|
commandbuf[1] = (char)(iLenth-2);
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLenth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProvBuban104SendAI(int commid, RTUMSG *rtumsg, int iGroupNo)
|
|
|
|
|
{
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
DWORD dwStartAddr;
|
|
|
|
|
int iLenth, iSendCount=1;
|
|
|
|
|
int i, j, iAllDataCount, iSendNum;
|
|
|
|
|
int iNo, iCmdType;
|
|
|
|
|
AI_DEF pntmsg;
|
|
|
|
|
PROV_AI_PNT *aiprovptr;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(pPortParam->ProvAckOrNot)
|
|
|
|
|
{
|
|
|
|
|
iCmdType = NORMAL_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( iGroupNo == 0 )//<2F><><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
dwStartAddr = MAX_GROUP_AINUM*iGroupNo + pPortParam->iAiBaseAddr;
|
|
|
|
|
|
|
|
|
|
iAllDataCount = pPortParam->m_psBaoHu->AiNum;
|
|
|
|
|
iSendCount = (iAllDataCount+MAX_AINUM-1)/MAX_AINUM;
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else//<2F><><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
dwStartAddr = MAX_GROUP_AINUM*(iGroupNo-1);
|
|
|
|
|
iAllDataCount = pPortParam->m_psBaoHu->AiNum - dwStartAddr;
|
|
|
|
|
dwStartAddr += pPortParam->iAiBaseAddr;
|
|
|
|
|
|
|
|
|
|
if(iAllDataCount > MAX_AINUM)
|
|
|
|
|
{
|
|
|
|
|
iSendCount = 2;
|
|
|
|
|
if((iAllDataCount - MAX_GROUP_AINUM) > 0)
|
|
|
|
|
{
|
|
|
|
|
iAllDataCount = MAX_GROUP_AINUM;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aiprovptr = (PROV_AI_PNT *)pPortParam->m_psBaoHu->AiPtr;
|
|
|
|
|
for( i = 0; i < iSendCount; i++ )
|
|
|
|
|
{
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[2] = 0;
|
|
|
|
|
commandbuf[3] = 0;
|
|
|
|
|
commandbuf[4] = 0;
|
|
|
|
|
commandbuf[5] = 0;
|
|
|
|
|
commandbuf[6] = 21;
|
|
|
|
|
//commandbuf[8] = rtumsg->MsgData[15];
|
|
|
|
|
commandbuf[8] = rtumsg->MsgData[8];
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
// <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ַΪ2<CEAA><32><EFBFBD>ֽ<EFBFBD>
|
|
|
|
|
//*((DWORD*)(&commandbuf[12])) = dwStartAddr;
|
|
|
|
|
commandbuf[10] = LOBYTE(LOWORD(dwStartAddr));
|
|
|
|
|
commandbuf[11] = HIBYTE(LOWORD(dwStartAddr));
|
|
|
|
|
iLenth = 12;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = 0;
|
|
|
|
|
commandbuf[10] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[11] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
// <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ַΪ3<CEAA><33><EFBFBD>ֽ<EFBFBD>
|
|
|
|
|
//*((DWORD*)(&commandbuf[12])) = dwStartAddr;
|
|
|
|
|
commandbuf[12] = LOBYTE(LOWORD(dwStartAddr));
|
|
|
|
|
commandbuf[13] = HIBYTE(LOWORD(dwStartAddr));
|
|
|
|
|
commandbuf[14] = LOBYTE(HIWORD(dwStartAddr));
|
|
|
|
|
iLenth = 15;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ң<><D2A3>ֵ
|
|
|
|
|
if(iAllDataCount > MAX_AINUM)
|
|
|
|
|
{
|
|
|
|
|
iAllDataCount -= MAX_AINUM;
|
|
|
|
|
iSendNum = MAX_AINUM;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iSendNum = iAllDataCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iNo = dwStartAddr - pPortParam->iAiBaseAddr;
|
|
|
|
|
for( j = 0; j < iSendNum; j++ )
|
|
|
|
|
{
|
|
|
|
|
GetPntMsg(aiprovptr[iNo+j].PortNo, aiprovptr[iNo+j].PntNo,
|
|
|
|
|
&pntmsg, AI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
aiprovptr[iNo+j].ChangeFlag = FALSE;
|
|
|
|
|
commandbuf[iLenth++] = (char)(pntmsg.RawValue);
|
|
|
|
|
commandbuf[iLenth++] = (char)((pntmsg.RawValue&0xff00)>>8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commandbuf[7] = (BYTE)j;
|
|
|
|
|
commandbuf[7] |= 0x80;
|
|
|
|
|
commandbuf[1] = (char)(iLenth-2);
|
|
|
|
|
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLenth);
|
|
|
|
|
|
|
|
|
|
dwStartAddr += MAX_AINUM;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProvBuban104SendDI(int commid, RTUMSG *rtumsg, int iGroupNo)
|
|
|
|
|
{
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
|
|
|
|
|
DWORD dwStartAddr;
|
|
|
|
|
int iLenth, iSendCount=1;
|
|
|
|
|
int i, j, iAllDataCount, iSendNum;
|
|
|
|
|
int iNo, iCmdType;
|
|
|
|
|
DI_DEF pntmsg;
|
|
|
|
|
PROV_DI_PNT *diprovptr;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(pPortParam->ProvAckOrNot)
|
|
|
|
|
{
|
|
|
|
|
iCmdType = NORMAL_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(iGroupNo == 0)//<2F><><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
dwStartAddr = MAX_GROUP_DINUM*iGroupNo + pPortParam->iDiBaseAddr;
|
|
|
|
|
|
|
|
|
|
iAllDataCount = pPortParam->m_psBaoHu->DiNum;
|
|
|
|
|
iSendCount = (iAllDataCount+MAX_DINUM-1)/MAX_DINUM;
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else//<2F><><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
dwStartAddr = MAX_GROUP_DINUM*(iGroupNo-1);
|
|
|
|
|
iAllDataCount = pPortParam->m_psBaoHu->DiNum - dwStartAddr;
|
|
|
|
|
|
|
|
|
|
dwStartAddr += pPortParam->iDiBaseAddr;
|
|
|
|
|
|
|
|
|
|
if( iAllDataCount > MAX_GROUP_DINUM)
|
|
|
|
|
{
|
|
|
|
|
iAllDataCount = MAX_GROUP_DINUM;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diprovptr = (PROV_DI_PNT *)pPortParam->m_psBaoHu->DiPtr;
|
|
|
|
|
for(i=0; i<iSendCount; i++)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[2] = 0;
|
|
|
|
|
commandbuf[3] = 0;
|
|
|
|
|
commandbuf[4] = 0;
|
|
|
|
|
commandbuf[5] = 0;
|
|
|
|
|
commandbuf[6] = 1;//=3,Ϊ˫<CEAA><CBAB>
|
|
|
|
|
commandbuf[8] = rtumsg->MsgData[12];
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[10] = LOBYTE(LOWORD(dwStartAddr));
|
|
|
|
|
commandbuf[11] = HIBYTE(LOWORD(dwStartAddr));
|
|
|
|
|
iLenth = 12;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = 0;
|
|
|
|
|
commandbuf[10] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[11] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
// <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ַΪ3<CEAA><33><EFBFBD>ֽ<EFBFBD>
|
|
|
|
|
//*((DWORD*)(&commandbuf[12])) = dwStartAddr;
|
|
|
|
|
commandbuf[12] = LOBYTE(LOWORD(dwStartAddr));
|
|
|
|
|
commandbuf[13] = HIBYTE(LOWORD(dwStartAddr));
|
|
|
|
|
commandbuf[14] = LOBYTE(HIWORD(dwStartAddr));
|
|
|
|
|
iLenth = 15;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(iAllDataCount > MAX_DINUM)
|
|
|
|
|
{
|
|
|
|
|
iAllDataCount -= MAX_DINUM;
|
|
|
|
|
iSendNum = MAX_DINUM;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iSendNum = iAllDataCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iNo = dwStartAddr - pPortParam->iDiBaseAddr;
|
|
|
|
|
for( j = 0; j < iSendNum; j++ )
|
|
|
|
|
{
|
|
|
|
|
GetPntMsg(diprovptr[iNo+j].PortNo, diprovptr[iNo+j].PntNo,
|
|
|
|
|
&pntmsg, DI_PNT_TYPE, PNT_STATUS);
|
|
|
|
|
diprovptr[iNo+j].ChangeFlag = FALSE;
|
|
|
|
|
commandbuf[iLenth++] = pntmsg.Status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commandbuf[7] = (char)j;
|
|
|
|
|
commandbuf[7] |= 0x80;
|
|
|
|
|
commandbuf[1] = (char)(iLenth-2);
|
|
|
|
|
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLenth);
|
|
|
|
|
|
|
|
|
|
dwStartAddr += MAX_DINUM;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProvBuban104SendSoe(int commid)
|
|
|
|
|
{
|
|
|
|
|
u_char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
|
|
|
|
|
BOOL bHaveData = FALSE;
|
|
|
|
|
WORD wmSec;
|
|
|
|
|
DWORD dwAddr;
|
|
|
|
|
int iLenth, iSendCount=1;
|
|
|
|
|
int iDataNum, iCmdType;
|
|
|
|
|
SOE_DEF soemsg;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(ProvHaveSoeData(commid) <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(pPortParam->ProvAckOrNot)
|
|
|
|
|
{
|
|
|
|
|
iCmdType = NORMAL_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[2] = 0;
|
|
|
|
|
commandbuf[3] = 0;
|
|
|
|
|
commandbuf[4] = 0;
|
|
|
|
|
commandbuf[5] = 0;
|
|
|
|
|
commandbuf[6] = 2;//<2F><><EFBFBD><EFBFBD>soe
|
|
|
|
|
commandbuf[8] = 3;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = 0;
|
|
|
|
|
commandbuf[10] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[11] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bHaveData = TRUE;
|
|
|
|
|
iLenth = 12;
|
|
|
|
|
iDataNum = 0;
|
|
|
|
|
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
// wen 2006.07.12 <20><EFBFBD>soeΪ<65><CEAA><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|
|
|
|
/*while(ProvAndDelGetSoeData(commid, &soemsg) > 0)
|
|
|
|
|
{
|
|
|
|
|
iDataNum++;
|
|
|
|
|
dwAddr = (DWORD)(pPortParam->iDiBaseAddr+soemsg.iPntNo);
|
|
|
|
|
|
|
|
|
|
commandbuf[iLenth++] = LOBYTE(LOWORD(dwAddr));
|
|
|
|
|
commandbuf[iLenth++] = HIBYTE(LOWORD(dwAddr));
|
|
|
|
|
if(VER_IEC870_5_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLenth++] = LOBYTE(HIWORD(dwAddr));
|
|
|
|
|
}
|
|
|
|
|
commandbuf[iLenth++] = soemsg.bStatus;
|
|
|
|
|
wmSec = soemsg.SoeTime.mSec + soemsg.SoeTime.Sec*1000;
|
|
|
|
|
commandbuf[iLenth++] = LOBYTE(wmSec);
|
|
|
|
|
commandbuf[iLenth++] = HIBYTE(wmSec);
|
|
|
|
|
commandbuf[iLenth++] = soemsg.SoeTime.Min & 0x3f;
|
|
|
|
|
if(iLenth >= 251)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
//===========================================================
|
|
|
|
|
while(ProvHaveSoeData(commid) > 0)
|
|
|
|
|
{
|
|
|
|
|
ProvAndDelGetSoeData(commid, &soemsg);
|
|
|
|
|
iDataNum++;
|
|
|
|
|
dwAddr = (DWORD)(pPortParam->iDiBaseAddr+soemsg.iPntNo);
|
|
|
|
|
|
|
|
|
|
commandbuf[iLenth++] = LOBYTE(LOWORD(dwAddr));
|
|
|
|
|
commandbuf[iLenth++] = HIBYTE(LOWORD(dwAddr));
|
|
|
|
|
if(VER_IEC870_5_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLenth++] = LOBYTE(HIWORD(dwAddr));
|
|
|
|
|
}
|
|
|
|
|
commandbuf[iLenth++] = soemsg.bStatus;
|
|
|
|
|
wmSec = soemsg.SoeTime.mSec + soemsg.SoeTime.Sec*1000;
|
|
|
|
|
commandbuf[iLenth++] = LOBYTE(wmSec);
|
|
|
|
|
commandbuf[iLenth++] = HIBYTE(wmSec);
|
|
|
|
|
commandbuf[iLenth++] = soemsg.SoeTime.Min & 0x3f;
|
|
|
|
|
if(iLenth >= 248)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
|
|
commandbuf[7] = (BYTE)iDataNum;
|
|
|
|
|
commandbuf[1] = (BYTE)(iLenth-2);
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLenth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProvBuban104YkYtData(int commid, RTUMSG *rtumsg)
|
|
|
|
|
{
|
|
|
|
|
PROV_DI_PNT *diprovptr;
|
|
|
|
|
DI_DEF *diptr;
|
|
|
|
|
int ykytcommid, provpnt;
|
|
|
|
|
int ykytpnt, ykytop, step;
|
|
|
|
|
BYTE bYkOperate;
|
|
|
|
|
YKYT_PARAM YkYtParam;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
char szbuf[128];
|
|
|
|
|
|
|
|
|
|
ykytpnt = 0;
|
|
|
|
|
ykytop = 3;
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
bYkOperate = rtumsg->MsgData[12];
|
|
|
|
|
ykytpnt = rtumsg->MsgData[10] + (rtumsg->MsgData[11]<<8);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bYkOperate = rtumsg->MsgData[15];
|
|
|
|
|
// wen 2005.11.27 <20><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|
|
|
|
//ykytpnt = rtumsg->MsgData[12] + (rtumsg->MsgData[13]<<8) + (rtumsg->MsgData[14]<<16);
|
|
|
|
|
ykytpnt = rtumsg->MsgData[12] + (rtumsg->MsgData[13]<<8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(rtumsg->MsgData[8] == 8)
|
|
|
|
|
{
|
|
|
|
|
step = STEP_YKYT_CANCEL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(bYkOperate & 0x80) //ѡ<><D1A1><EFBFBD><EFBFBD>У
|
|
|
|
|
{
|
|
|
|
|
step = STEP_YKYT_SELECT;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
step = STEP_YKYT_EXEC;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ShmGetDispYkYtFlag())
|
|
|
|
|
{
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
printf("TIP_(%04d): commid =%d recv ykyt select.\n", _getpid(), commid);
|
|
|
|
|
#else
|
|
|
|
|
printf("TIP_(%04d): commid =%d recv ykyt select.\n", getpid(), commid);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ykytpnt -= pPortParam->iYkBaseAddr;
|
|
|
|
|
ykytpnt += 1;
|
|
|
|
|
|
|
|
|
|
if(rtumsg->MsgData[6] == 45)
|
|
|
|
|
{
|
|
|
|
|
// ykytop == 1 <20>غ<EFBFBD>, == 2 <20>ط<EFBFBD>
|
|
|
|
|
ykytop = ((bYkOperate & 0x03) == 1) ? 1 : 2;
|
|
|
|
|
}
|
|
|
|
|
else if(rtumsg->MsgData[6] == 46)
|
|
|
|
|
{
|
|
|
|
|
ykytop = ((bYkOperate & 0x03) == 2) ? 1 : 2;
|
|
|
|
|
}
|
|
|
|
|
else // == 47
|
|
|
|
|
{
|
|
|
|
|
//step = STEP_YKYT_CANCEL;
|
|
|
|
|
MakeProvBuban104YkYtAckMsg(commid, ykytpnt, 3, step);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
provpnt = FindProvPntFromYkYtPnt(commid, ykytpnt, pPortParam->m_psBaoHu);
|
|
|
|
|
if(provpnt < 0) // <20>ص<EFBFBD><D8B5>Ŵ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
sprintf(szbuf, "WARN(%04d): <20>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>.\n", _getpid());
|
|
|
|
|
DebugPrint(szbuf);
|
|
|
|
|
MakeProvBuban104YkYtAckMsg(commid, ykytpnt, 3, step);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
diprovptr = (PROV_DI_PNT *)pPortParam->m_psBaoHu->DiPtr;
|
|
|
|
|
ykytcommid = diprovptr[provpnt].PortNo;
|
|
|
|
|
if(!SioParam[ykytcommid].m_psBaoHu)
|
|
|
|
|
{
|
|
|
|
|
MakeProvBuban104YkYtAckMsg(commid, ykytpnt, 3, step);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!SioParam[ykytcommid].m_psBaoHu->DiPtr)
|
|
|
|
|
{
|
|
|
|
|
sprintf(szbuf, "WARN(%04d): û<>пص<D0BF>m_psBaoHu->DiPtr=NULL.\n", _getpid());
|
|
|
|
|
DebugPrint(szbuf);
|
|
|
|
|
MakeProvBuban104YkYtAckMsg(commid, ykytpnt, 3, step);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diptr = (DI_DEF *)SioParam[ykytcommid].m_psBaoHu->DiPtr;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>û<EFBFBD>пص<D0BF><D8B5><EFBFBD><EFBFBD>߿ص㲻<D8B5><E3B2BB><EFBFBD><EFBFBD>
|
|
|
|
|
if(!diptr[diprovptr[provpnt].PntNo].CtrlEnable)
|
|
|
|
|
{
|
|
|
|
|
sprintf(szbuf, "WARN(%04d): <20><>Ӧ<EFBFBD><D3A6>û<EFBFBD>пص<D0BF><D8B5><EFBFBD><EFBFBD>߿ص㲻<D8B5><E3B2BB><EFBFBD><EFBFBD>.\n", _getpid());
|
|
|
|
|
DebugPrint(szbuf);
|
|
|
|
|
MakeProvBuban104YkYtAckMsg(commid, ykytpnt, 3, step);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(STEP_YKYT_SELECT == step)
|
|
|
|
|
{
|
|
|
|
|
if(STEP_YKYT_SELECT == SioParam[ykytcommid].m_psBaoHu->ProvYkYtMsg.m_iYkYtStep)
|
|
|
|
|
{
|
|
|
|
|
if(!ProvPortYkYtIsTimeOut(ykytcommid, &SioParam[ykytcommid].m_psBaoHu->ProvYkYtMsg))
|
|
|
|
|
{
|
|
|
|
|
sprintf(szbuf, "WARN(%04d): <20><>ʱ failed.\n", _getpid());
|
|
|
|
|
DebugPrint(szbuf);
|
|
|
|
|
MakeProvBuban104YkYtAckMsg(commid, ykytpnt, 3, step);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SioParam[ykytcommid].m_psBaoHu->ProvYkYtMsg.m_iProvPntIdx = provpnt;
|
|
|
|
|
SioParam[ykytcommid].m_psBaoHu->ProvYkYtMsg.m_iProvPortIdx = commid;
|
|
|
|
|
SioParam[ykytcommid].m_psBaoHu->ProvYkYtMsg.m_iProvYkYtPointIdx = ykytpnt;
|
|
|
|
|
SioParam[ykytcommid].m_psBaoHu->ProvYkYtMsg.m_iYkYtPointIdx = diptr[diprovptr[provpnt].PntNo].ControlNo;
|
|
|
|
|
SioParam[ykytcommid].m_psBaoHu->ProvYkYtMsg.m_iYkYtOperate = ykytop;
|
|
|
|
|
|
|
|
|
|
// buf[0] --- <20>˿ں<CBBF>(=commid)
|
|
|
|
|
// buf[1]
|
|
|
|
|
// buf[2]
|
|
|
|
|
// buf[3]
|
|
|
|
|
// buf[4] --- <20>ص<EFBFBD><D8B5><EFBFBD>
|
|
|
|
|
// buf[5]
|
|
|
|
|
// buf[6]
|
|
|
|
|
// buf[7]
|
|
|
|
|
// buf[8] --- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(ң<><D2A3>:1=ѡ<><D1A1>,2=ִ<><D6B4>,3=ȡ<><C8A1>,7=ֱ<><D6B1>;
|
|
|
|
|
// ң<><D2A3>:4=ѡ<><D1A1>,5=ִ<><D6B4>,6=ȡ<><C8A1>,8=<3D><>ͣ)
|
|
|
|
|
// buf[9] --- <20><><EFBFBD><EFBFBD>״̬(1=<3D>ֵ<EFBFBD><D6B5>ϣ<EFBFBD>2=<3D>ϵ<EFBFBD><CFB5><EFBFBD>)
|
|
|
|
|
// (<28><><EFBFBD><EFBFBD>λΪ1ʱ<31><CAB1>Ϊ<EFBFBD><CEAA>У<EFBFBD><D0A3><EFBFBD><EFBFBD>, 1=<3D>ɹ<EFBFBD>, 0=ʧ<><CAA7>)
|
|
|
|
|
//buf[0] = ykytcommid & 0xFF;
|
|
|
|
|
//buf[1] = (ykytcommid & 0xFF00) >> 8;
|
|
|
|
|
//buf[2] = (ykytcommid & 0xFF0000) >> 16;
|
|
|
|
|
//buf[3] = (ykytcommid & 0xFF000000) >> 24;
|
|
|
|
|
//buf[4] = diptr[diprovptr[provpnt].PntNo].ControlNo & 0xFF;
|
|
|
|
|
//buf[5] = (diptr[diprovptr[provpnt].PntNo].ControlNo & 0xFF00) >> 8;
|
|
|
|
|
//buf[6] = (diptr[diprovptr[provpnt].PntNo].ControlNo & 0xFF0000) >> 16;
|
|
|
|
|
//buf[7] = (diptr[diprovptr[provpnt].PntNo].ControlNo & 0xFF000000) >> 24;
|
|
|
|
|
//buf[8] = STEP_YKYT_SELECT;
|
|
|
|
|
//buf[9] = ykytop;
|
|
|
|
|
//SendYkYtCommand(ykytcommid, (char *)buf, 10); // <20><><EFBFBD><EFBFBD>ң<EFBFBD><D2A3>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
YkYtParam.m_iYkYtOperate = ykytop;
|
|
|
|
|
YkYtParam.m_iYkYtPnt = diptr[diprovptr[provpnt].PntNo].ControlNo;
|
|
|
|
|
YkYtParam.m_iYkYtStep = step;
|
|
|
|
|
YkYtParam.m_iYkYtUpDown = YKYT_SEND_DOWN;
|
|
|
|
|
SendYkYtCommand2(ykytcommid, &YkYtParam);
|
|
|
|
|
|
|
|
|
|
if(STEP_YKYT_EXEC == step)
|
|
|
|
|
{
|
|
|
|
|
MakeProvBuban104YkYtAckMsg(commid, ykytpnt, ykytop, step);
|
|
|
|
|
MakeProvBuban104YkYtAckMsg(commid, ykytpnt, ykytop, STEP_YKYT_NOEXEC);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeProvBuban104YkYtAckMsg(int commid, int pnt, int op, int step)
|
|
|
|
|
{
|
|
|
|
|
int iCount, ykpoint, iLen;
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
memset(commandbuf, 0, sizeof(commandbuf));
|
|
|
|
|
iCount = 4;
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[1] = 14;
|
|
|
|
|
switch(pPortParam->YkMode)
|
|
|
|
|
{
|
|
|
|
|
case CONTROL_SINGAL: // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[6] = 45;
|
|
|
|
|
break;
|
|
|
|
|
case CONTROL_DOUBLE: // ˫<><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
case CONTROL_DIRECT: // ֱ<>ӿ<EFBFBD><D3BF><EFBFBD>
|
|
|
|
|
commandbuf[6] = 46; // 47;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[7] = 1;
|
|
|
|
|
//commandbuf[8];// <20><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>
|
|
|
|
|
|
|
|
|
|
iLen = 9;
|
|
|
|
|
ykpoint = (pnt-1) + pPortParam->iYkBaseAddr;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(LOWORD(ykpoint));
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(LOWORD(ykpoint));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(LOWORD(ykpoint));
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(LOWORD(ykpoint));
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(HIWORD(ykpoint));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch(step)
|
|
|
|
|
{
|
|
|
|
|
case STEP_YKYT_SELECT: // ѡ<><D1A1>
|
|
|
|
|
commandbuf[8] = 7;
|
|
|
|
|
commandbuf[iLen] = 0xfc;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case STEP_YKYT_EXEC: // ִ<><D6B4>
|
|
|
|
|
commandbuf[8] = 7;
|
|
|
|
|
commandbuf[iLen] = 0x7c;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case STEP_YKYT_CANCEL: // <20><><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[8] = 9;
|
|
|
|
|
commandbuf[iLen] = 0xfc;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:// <20><><EFBFBD><EFBFBD>֡
|
|
|
|
|
commandbuf[8] = 10;
|
|
|
|
|
commandbuf[iLen] = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DCS/RCS
|
|
|
|
|
switch(op)
|
|
|
|
|
{
|
|
|
|
|
case 1: // ѡ<><D1A1><EFBFBD><EFBFBD>
|
|
|
|
|
if(CONTROL_SINGAL == pPortParam->YkMode)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen] |= 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen] |= 2;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2: // ѡ<><D1A1><EFBFBD><EFBFBD>
|
|
|
|
|
if(CONTROL_SINGAL != pPortParam->YkMode)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen] |= 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 3: // ѡ<><D1A1>ʧ<EFBFBD><CAA7>
|
|
|
|
|
default:
|
|
|
|
|
commandbuf[8] |= 0x40;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iLen++;
|
|
|
|
|
PutPollCmdToBuf(commid, INSERT_POLL_CMD, 0, (char *)commandbuf, iLen);
|
|
|
|
|
|
|
|
|
|
if(ShmGetDispYkYtFlag())
|
|
|
|
|
{
|
|
|
|
|
printf("TIP_(%04d): commid =%d ykytpnt=%d, op=%d checked.\n", _getpid(), commid, pnt, op);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProvBuban104SendClass1(int commid)
|
|
|
|
|
{
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
DWORD dwStartAddr;
|
|
|
|
|
int iLenth, iSendCount=1;
|
|
|
|
|
int j, iDataNum, iCmdType;
|
|
|
|
|
DI_DEF pntmsg;
|
|
|
|
|
PROV_DI_PNT *diprovptr;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(!pPortParam->m_psBaoHu->DiChange)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(pPortParam->ProvAckOrNot)
|
|
|
|
|
{
|
|
|
|
|
iCmdType = NORMAL_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// wen 2005.01.15 <20><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
|
|
|
|
|
dwStartAddr = pPortParam->iDiBaseAddr;
|
|
|
|
|
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[2] = 0;
|
|
|
|
|
commandbuf[3] = 0;
|
|
|
|
|
commandbuf[4] = 0;
|
|
|
|
|
commandbuf[5] = 0;
|
|
|
|
|
commandbuf[6] = 1;//=3,Ϊ˫<CEAA><CBAB>
|
|
|
|
|
commandbuf[8] = 3;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
iLenth = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = 0;
|
|
|
|
|
commandbuf[10] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[11] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
iLenth = 12;
|
|
|
|
|
}
|
|
|
|
|
diprovptr = (PROV_DI_PNT *)pPortParam->m_psBaoHu->DiPtr;
|
|
|
|
|
for(j = 0, iDataNum = 0; j<pPortParam->m_psBaoHu->DiNum; j++)
|
|
|
|
|
{
|
|
|
|
|
if(diprovptr[j].ChangeFlag)
|
|
|
|
|
{
|
|
|
|
|
iDataNum++;
|
|
|
|
|
commandbuf[iLenth++] = LOBYTE(LOWORD(dwStartAddr+j));
|
|
|
|
|
commandbuf[iLenth++] = HIBYTE(LOWORD(dwStartAddr+j));
|
|
|
|
|
if(VER_IEC870_5_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLenth++] = LOBYTE(HIWORD(dwStartAddr+j));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GetPntMsg(diprovptr[j].PortNo, diprovptr[j].PntNo,
|
|
|
|
|
&pntmsg, DI_PNT_TYPE, PNT_STATUS);
|
|
|
|
|
diprovptr[j].ChangeFlag = FALSE;
|
|
|
|
|
commandbuf[iLenth++] = pntmsg.Status;
|
|
|
|
|
if(iLenth > 256)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(j >= pPortParam->m_psBaoHu->DiNum)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_psBaoHu->DiChange = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commandbuf[7] = (char)iDataNum;
|
|
|
|
|
commandbuf[1] = (char)(iLenth-2);
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLenth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProvBuban104SendClass2(int commid)
|
|
|
|
|
{
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
|
|
|
|
|
BOOL bHaveData = FALSE;
|
|
|
|
|
DWORD dwStartAddr;
|
|
|
|
|
int iLenth, iSendCount=1;
|
|
|
|
|
int j, iDataNum, iCmdType;
|
|
|
|
|
AI_DEF pntmsg;
|
|
|
|
|
PROV_AI_PNT *aiprovptr;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(!pPortParam->m_psBaoHu->AiChange)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(pPortParam->ProvAckOrNot)
|
|
|
|
|
{
|
|
|
|
|
iCmdType = NORMAL_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[2] = 0;
|
|
|
|
|
commandbuf[3] = 0;
|
|
|
|
|
commandbuf[4] = 0;
|
|
|
|
|
commandbuf[5] = 0;
|
|
|
|
|
commandbuf[6] = 21;
|
|
|
|
|
commandbuf[8] = 3;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
iLenth = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = 0;
|
|
|
|
|
commandbuf[10] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[11] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
iLenth = 12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// wen 2005.01.15 <20><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
|
|
|
|
|
dwStartAddr = pPortParam->iAiBaseAddr;
|
|
|
|
|
commandbuf[6] = 21;
|
|
|
|
|
//ң<><D2A3>ֵ
|
|
|
|
|
aiprovptr = (PROV_AI_PNT *)pPortParam->m_psBaoHu->AiPtr;
|
|
|
|
|
for(j = 0, iDataNum = 0; j < pPortParam->m_psBaoHu->AiNum; j++)
|
|
|
|
|
{
|
|
|
|
|
if(aiprovptr[j].ChangeFlag)
|
|
|
|
|
{
|
|
|
|
|
iDataNum++;
|
|
|
|
|
bHaveData = TRUE;
|
|
|
|
|
|
|
|
|
|
commandbuf[iLenth++] = LOBYTE(LOWORD(dwStartAddr+j));
|
|
|
|
|
commandbuf[iLenth++] = HIBYTE(LOWORD(dwStartAddr+j));
|
|
|
|
|
if(VER_IEC870_5_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLenth++] = LOBYTE(HIWORD(dwStartAddr+j));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GetPntMsg(aiprovptr[j].PortNo, aiprovptr[j].PntNo,
|
|
|
|
|
&pntmsg, AI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
aiprovptr[j].ChangeFlag = FALSE;
|
|
|
|
|
commandbuf[iLenth++] = (char)(pntmsg.RawValue);
|
|
|
|
|
commandbuf[iLenth++] = (char)((pntmsg.RawValue&0xff00)>>8);
|
|
|
|
|
|
|
|
|
|
if(iLenth >= 251)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(j >= pPortParam->m_psBaoHu->AiNum)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_psBaoHu->AiChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(bHaveData)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[7] = (char)iDataNum;
|
|
|
|
|
commandbuf[1] = (char)(iLenth-2);
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLenth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProvMakeBuban104Command(int commid, u_char cmdidx)
|
|
|
|
|
{
|
|
|
|
|
int iLen;
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
switch(cmdidx)
|
|
|
|
|
{
|
|
|
|
|
case ASK_SECOND_DATA: // <20>ٻ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
// wen 2006.03.23 ֧<>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD><D2A3><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|
|
|
|
//ProvBuban104SendClass2(commid);
|
|
|
|
|
//====================================================================
|
|
|
|
|
if(pPortParam->m_bProvAiType == 13)
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104SendClass2withFloat(commid);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ProvBuban104SendClass2(commid);
|
|
|
|
|
}
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ASK_FIRST_DATA: // <20>ٻ<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ProvBuban104SendClass1(commid);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ASK_ALLDATA_END: // <20><><EFBFBD>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD>֡
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
//commandbuf[iLen++] = 14;
|
|
|
|
|
iLen = 2;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 100;
|
|
|
|
|
commandbuf[iLen++] = 1;
|
|
|
|
|
commandbuf[iLen++] = 10;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
commandbuf[iLen++] = 0;
|
|
|
|
|
}
|
|
|
|
|
commandbuf[iLen++] = 0x14;
|
|
|
|
|
commandbuf[1] = (BYTE)(iLen - 2);
|
|
|
|
|
if(pPortParam->ProvAckOrNot)
|
|
|
|
|
{
|
|
|
|
|
PutPollCmdToBuf(commid, NORMAL_POLL_CMD, 0, (char *)commandbuf, iLen);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PutPollCmdToBuf(commid, FAST_POLL_CMD, 0, (char *)commandbuf, iLen);
|
|
|
|
|
}
|
|
|
|
|
pPortParam->Initdata = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case RTU_TIME: // ʱ<><CAB1>ͬ<EFBFBD><CDAC>
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ASK_DI_DATA: // <20>ٻ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>YX
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ASK_AI_DATA: // <20>ٻ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>YC
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ASK_PI_DATA: // <20>ٻ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>YM
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ASK_PI: //<2F>ٻ<EFBFBD><D9BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ASK_ALL_DATA: // <20>ٻ<EFBFBD><D9BB><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
int j // <20><>Ӧ<EFBFBD><D3A6><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD>
|
|
|
|
|
int *igno // <20><><EFBFBD><EFBFBD>
|
|
|
|
|
int* iItemNo <EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD>
|
|
|
|
|
DAY_TIME* sCurTime ʱ<EFBFBD><EFBFBD>
|
|
|
|
|
float* pfValue <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
WORD Year;
|
|
|
|
|
u_char Month;
|
|
|
|
|
u_char Day;
|
|
|
|
|
u_char WeekDay;
|
|
|
|
|
u_char MonthDay;
|
|
|
|
|
u_char Hour;
|
|
|
|
|
u_char Min;
|
|
|
|
|
u_char Sec;
|
|
|
|
|
u_char reserved;
|
|
|
|
|
WORD mSec;
|
|
|
|
|
} DAY_TIME;
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ1<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>ȡֵ -1<EFBFBD><EFBFBD>ȡֵʧ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
int GetAIPntMsg(int j, int *igno, int* iItemNo, DAY_TIME* sCurTime, float* pfValue)
|
|
|
|
|
{
|
|
|
|
|
*igno = 1;
|
|
|
|
|
*iItemNo = 1;
|
|
|
|
|
sCurTime->Hour = 12;
|
|
|
|
|
sCurTime->Min = 30;
|
|
|
|
|
sCurTime->Month = 11;
|
|
|
|
|
sCurTime->MonthDay = 1;
|
|
|
|
|
sCurTime->mSec = 600;
|
|
|
|
|
sCurTime->Sec = 26;
|
|
|
|
|
sCurTime->Year = 2023;
|
|
|
|
|
*pfValue = 36.6;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProvBuban104SendAIwithFloat(int commid, RTUMSG *rtumsg, int iGroupNo)
|
|
|
|
|
{
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
DWORD dwStartAddr;
|
|
|
|
|
int iLenth, iSendCount=1;
|
|
|
|
|
int i, j, iAllDataCount, iSendNum,flag;
|
|
|
|
|
int iNo, iCmdType, igno,iItemNo;
|
|
|
|
|
float *pfValue;
|
|
|
|
|
DAY_TIME sCurTime;
|
|
|
|
|
AI_DEF pntmsg;
|
|
|
|
|
PROV_AI_PNT *aiprovptr;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
|
|
|
|
|
if( iGroupNo == 0 )//<2F><><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
dwStartAddr = MAX_GROUP_AINUM*iGroupNo + pPortParam->iAiBaseAddr;
|
|
|
|
|
|
|
|
|
|
iAllDataCount = pPortParam->m_psBaoHu->AiNum;
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aiprovptr = (PROV_AI_PNT *)pPortParam->m_psBaoHu->AiPtr;
|
|
|
|
|
for( i = 0; i < iAllDataCount; i++ )
|
|
|
|
|
{
|
|
|
|
|
memset(commandbuf, 0, sizeof(commandbuf));
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[2] = 0;
|
|
|
|
|
commandbuf[3] = 0;
|
|
|
|
|
commandbuf[4] = 0;
|
|
|
|
|
commandbuf[5] = 0;
|
|
|
|
|
commandbuf[6] = 10; // <20><><EFBFBD>ͱ<EFBFBD>ʶTYP
|
|
|
|
|
commandbuf[7] = 0x81; // <20>ɱ<EFBFBD><C9B1>ṹ<EFBFBD><EFBFBD><DEB6><EFBFBD>VSQ
|
|
|
|
|
commandbuf[8] = 0x2A; // <20><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>COT
|
|
|
|
|
commandbuf[9] = 0; //
|
|
|
|
|
commandbuf[10] = 0; // Ӧ<>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
commandbuf[11] = 254; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FUN
|
|
|
|
|
commandbuf[12] = 241; // <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>INF
|
|
|
|
|
commandbuf[13] = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ʶ<EFBFBD><CAB6>RII
|
|
|
|
|
|
|
|
|
|
//ң<><D2A3>ֵ
|
|
|
|
|
if(iAllDataCount > MAX_FLOATAINUM)
|
|
|
|
|
{
|
|
|
|
|
iSendNum = MAX_FLOATAINUM;
|
|
|
|
|
commandbuf[14] = (iSendNum & 0x80); // ͨ<>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD>ĿNGD
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iSendNum = iAllDataCount;
|
|
|
|
|
commandbuf[14] = iSendNum; // ͨ<>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD>ĿNGD
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iNo = i;
|
|
|
|
|
iLenth = 15;
|
|
|
|
|
for( j = iNo; j < iNo+iSendNum; j++ )
|
|
|
|
|
{
|
|
|
|
|
pfValue = (float *)&commandbuf[iLenth+14];
|
|
|
|
|
flag = GetAIPntMsg(j, &igno, &iItemNo, &sCurTime, pfValue);
|
|
|
|
|
commandbuf[iLenth] = igno;
|
|
|
|
|
commandbuf[iLenth++] = iItemNo;
|
|
|
|
|
commandbuf[iLenth++] = 1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>KOD<4F><44>ʵ<EFBFBD><CAB5>ֵ<EFBFBD><D6B5>
|
|
|
|
|
commandbuf[iLenth++] = 7; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
commandbuf[iLenth++] = 4; // <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>
|
|
|
|
|
commandbuf[iLenth++] = 4; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
commandbuf[iLenth++] = sCurTime.mSec % 256;
|
|
|
|
|
commandbuf[iLenth++] = sCurTime.mSec / 256;
|
|
|
|
|
commandbuf[iLenth++] = (u_char)sCurTime.Min;
|
|
|
|
|
commandbuf[iLenth++] = (u_char)sCurTime.Hour;
|
|
|
|
|
commandbuf[iLenth++] = (u_char)sCurTime.Day;
|
|
|
|
|
commandbuf[iLenth++] = (u_char)sCurTime.Month;
|
|
|
|
|
commandbuf[iLenth++] = (u_char)(sCurTime.Year % 100);
|
|
|
|
|
iLenth += 12;
|
|
|
|
|
//*pfValue = SequenceHostToRtufloat((float)((int)pntmsg.RawValue));
|
|
|
|
|
|
|
|
|
|
//iLenth += sizeof(float);
|
|
|
|
|
//commandbuf[iLenth++] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flag = -1)
|
|
|
|
|
i = iAllDataCount;
|
|
|
|
|
else
|
|
|
|
|
i += iSendNum;
|
|
|
|
|
commandbuf[1] = (char)(iLenth-2);
|
|
|
|
|
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLenth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*void ProvBuban104SendAIwithFloat(int commid, RTUMSG *rtumsg, int iGroupNo)
|
|
|
|
|
{
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
DWORD dwStartAddr;
|
|
|
|
|
int iLenth, iSendCount=1;
|
|
|
|
|
int i, j, iAllDataCount, iSendNum;
|
|
|
|
|
int iNo, iCmdType;
|
|
|
|
|
float *pfValue;
|
|
|
|
|
AI_DEF pntmsg;
|
|
|
|
|
PROV_AI_PNT *aiprovptr;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(pPortParam->ProvAckOrNot)
|
|
|
|
|
{
|
|
|
|
|
iCmdType = NORMAL_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( iGroupNo == 0 )//<2F><><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
dwStartAddr = MAX_GROUP_AINUM*iGroupNo + pPortParam->iAiBaseAddr;
|
|
|
|
|
|
|
|
|
|
iAllDataCount = pPortParam->m_psBaoHu->AiNum;
|
|
|
|
|
iSendCount = (iAllDataCount+MAX_FLOATAINUM-1)/MAX_FLOATAINUM;
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else//<2F><><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
dwStartAddr = MAX_GROUP_AINUM*(iGroupNo-1);
|
|
|
|
|
iAllDataCount = pPortParam->m_psBaoHu->AiNum - dwStartAddr;
|
|
|
|
|
dwStartAddr += pPortParam->iAiBaseAddr;
|
|
|
|
|
|
|
|
|
|
if(iAllDataCount > MAX_FLOATAINUM)
|
|
|
|
|
{
|
|
|
|
|
iSendCount = 2;
|
|
|
|
|
if((iAllDataCount - MAX_GROUP_AINUM) > 0)
|
|
|
|
|
{
|
|
|
|
|
iAllDataCount = MAX_GROUP_AINUM;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aiprovptr = (PROV_AI_PNT *)pPortParam->m_psBaoHu->AiPtr;
|
|
|
|
|
for( i = 0; i < iSendCount; i++ )
|
|
|
|
|
{
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[2] = 0;
|
|
|
|
|
commandbuf[3] = 0;
|
|
|
|
|
commandbuf[4] = 0;
|
|
|
|
|
commandbuf[5] = 0;
|
|
|
|
|
commandbuf[6] = 13;
|
|
|
|
|
//commandbuf[8] = rtumsg->MsgData[15];
|
|
|
|
|
commandbuf[8] = rtumsg->MsgData[8];
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
// <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ַΪ2<CEAA><32><EFBFBD>ֽ<EFBFBD>
|
|
|
|
|
//*((DWORD*)(&commandbuf[12])) = dwStartAddr;
|
|
|
|
|
commandbuf[10] = LOBYTE(LOWORD(dwStartAddr));
|
|
|
|
|
commandbuf[11] = HIBYTE(LOWORD(dwStartAddr));
|
|
|
|
|
iLenth = 12;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = 0;
|
|
|
|
|
commandbuf[10] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[11] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
// <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ַΪ3<CEAA><33><EFBFBD>ֽ<EFBFBD>
|
|
|
|
|
//*((DWORD*)(&commandbuf[12])) = dwStartAddr;
|
|
|
|
|
commandbuf[12] = LOBYTE(LOWORD(dwStartAddr));
|
|
|
|
|
commandbuf[13] = HIBYTE(LOWORD(dwStartAddr));
|
|
|
|
|
commandbuf[14] = LOBYTE(HIWORD(dwStartAddr));
|
|
|
|
|
iLenth = 15;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ң<><D2A3>ֵ
|
|
|
|
|
if(iAllDataCount > MAX_FLOATAINUM)
|
|
|
|
|
{
|
|
|
|
|
iAllDataCount -= MAX_FLOATAINUM;
|
|
|
|
|
iSendNum = MAX_FLOATAINUM;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iSendNum = iAllDataCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iNo = dwStartAddr - pPortParam->iAiBaseAddr;
|
|
|
|
|
for( j = 0; j < iSendNum; j++ )
|
|
|
|
|
{
|
|
|
|
|
GetPntMsg(aiprovptr[iNo+j].PortNo, aiprovptr[iNo+j].PntNo,
|
|
|
|
|
&pntmsg, AI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
aiprovptr[iNo+j].ChangeFlag = FALSE;
|
|
|
|
|
pfValue = (float *)&commandbuf[iLenth];
|
|
|
|
|
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
// wen 2006.07.13 <20>ĸ<DEB8><C4B8><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|
|
|
|
//*pfValue = SequenceHostToRtufloat((float)pntmsg.RawValue);
|
|
|
|
|
//============================================================
|
|
|
|
|
*pfValue = SequenceHostToRtufloat((float)((int)pntmsg.RawValue));
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
|
|
iLenth += sizeof(float);
|
|
|
|
|
commandbuf[iLenth++] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commandbuf[7] = (BYTE)j;
|
|
|
|
|
commandbuf[7] |= 0x80;
|
|
|
|
|
commandbuf[1] = (char)(iLenth-2);
|
|
|
|
|
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLenth);
|
|
|
|
|
|
|
|
|
|
dwStartAddr += MAX_FLOATAINUM;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void ProvBuban104SendClass2withFloat(int commid)
|
|
|
|
|
{
|
|
|
|
|
char commandbuf[MAX_POLLCMD_BUF_LEN];
|
|
|
|
|
|
|
|
|
|
BOOL bHaveData = FALSE;
|
|
|
|
|
DWORD dwStartAddr;
|
|
|
|
|
int iLenth, iSendCount=1;
|
|
|
|
|
int j, iDataNum, iCmdType;
|
|
|
|
|
float *pfValue;
|
|
|
|
|
AI_DEF pntmsg;
|
|
|
|
|
PROV_AI_PNT *aiprovptr;
|
|
|
|
|
BUBAN104PORTPARAM *pPortParam;
|
|
|
|
|
|
|
|
|
|
pPortParam = (BUBAN104PORTPARAM *)SioParam[commid].ExtInfo;
|
|
|
|
|
|
|
|
|
|
if(!pPortParam->m_psBaoHu->AiChange)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(pPortParam->ProvAckOrNot)
|
|
|
|
|
{
|
|
|
|
|
iCmdType = NORMAL_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iCmdType = FAST_POLL_CMD;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commandbuf[0] = 0x68;
|
|
|
|
|
commandbuf[2] = 0;
|
|
|
|
|
commandbuf[3] = 0;
|
|
|
|
|
commandbuf[4] = 0;
|
|
|
|
|
commandbuf[5] = 0;
|
|
|
|
|
commandbuf[6] = 21;
|
|
|
|
|
commandbuf[8] = 3;
|
|
|
|
|
if(VER_BUBAN_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
iLenth = 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
commandbuf[9] = 0;
|
|
|
|
|
commandbuf[10] = LOBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
commandbuf[11] = HIBYTE(pPortParam->wLinkAddr);
|
|
|
|
|
iLenth = 12;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// wen 2005.01.15 <20><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
|
|
|
|
|
dwStartAddr = pPortParam->iAiBaseAddr;
|
|
|
|
|
commandbuf[6] = 13;
|
|
|
|
|
//ң<><D2A3>ֵ
|
|
|
|
|
aiprovptr = (PROV_AI_PNT *)pPortParam->m_psBaoHu->AiPtr;
|
|
|
|
|
for(j = 0, iDataNum = 0; j < pPortParam->m_psBaoHu->AiNum; j++)
|
|
|
|
|
{
|
|
|
|
|
if(aiprovptr[j].ChangeFlag)
|
|
|
|
|
{
|
|
|
|
|
iDataNum++;
|
|
|
|
|
bHaveData = TRUE;
|
|
|
|
|
|
|
|
|
|
commandbuf[iLenth++] = LOBYTE(LOWORD(dwStartAddr+j));
|
|
|
|
|
commandbuf[iLenth++] = HIBYTE(LOWORD(dwStartAddr+j));
|
|
|
|
|
if(VER_IEC870_5_104 == pPortParam->RtuVersion)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[iLenth++] = LOBYTE(HIWORD(dwStartAddr+j));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GetPntMsg(aiprovptr[j].PortNo, aiprovptr[j].PntNo,
|
|
|
|
|
&pntmsg, AI_PNT_TYPE, PNT_RAWVALUE);
|
|
|
|
|
aiprovptr[j].ChangeFlag = FALSE;
|
|
|
|
|
|
|
|
|
|
pfValue = (float *)&commandbuf[iLenth];
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
// wen 2006.07.13 <20>ĸ<DEB8><C4B8><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|
|
|
|
//*pfValue = SequenceHostToRtufloat((float)pntmsg.RawValue);
|
|
|
|
|
//============================================================
|
|
|
|
|
*pfValue = SequenceHostToRtufloat((float)((int)pntmsg.RawValue));
|
|
|
|
|
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
iLenth += sizeof(float);
|
|
|
|
|
commandbuf[iLenth++] = 0;
|
|
|
|
|
|
|
|
|
|
//4.bug_1.2.3_20060807_3/bug_2.0.1_20060807_4 104<30><34>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD>˿ڵ<CBBF>ң<EFBFBD><D2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD>251(ԭ<><D4AD>ʹ<EFBFBD><CAB9>255<35><35><EFBFBD>ܵ<EFBFBD><DCB5>·<EFBFBD><C2B7>ͱ<EFBFBD><CDB1>ij<EFBFBD><C4B3>ȳ<EFBFBD><C8B3><EFBFBD>255<35><35>һ<EFBFBD><D2BB><EFBFBD>ֽڲ<D6BD><DAB2>ܱ<EFBFBD><DCB1><EFBFBD>)
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEBBBA><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>ʹ<EFBFBD><CAB9>char<61><72><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>ʹ<EFBFBD><CAB9>u_char
|
|
|
|
|
if(iLenth >= 251)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(j >= pPortParam->m_psBaoHu->AiNum)
|
|
|
|
|
{
|
|
|
|
|
pPortParam->m_psBaoHu->AiChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(bHaveData)
|
|
|
|
|
{
|
|
|
|
|
commandbuf[7] = (char)iDataNum;
|
|
|
|
|
commandbuf[1] = (char)(iLenth-2);
|
|
|
|
|
PutPollCmdToBuf(commid, iCmdType, 0, (char *)commandbuf, iLenth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//===========================ת<><D7AA><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>===============================//
|
|
|
|
|
|
|
|
|
|
//===========================<3D><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>===============================//
|