//***************************************************************
//* buban103.cpp *
//* aaawen 2004.10.19 *
//***************************************************************
//_DEBUG_MSG_,_OS_WINDOWS_DEBUG_
/*#ifdef OS_LINUX
# include "baohulib/commport.h"
# include "baohulib/serialport.h"
# else* /
# include "common.h"
# include "commport.h"
# include "udpcomm.h"
# include "display.h"
//#endif
# include <math.h>
# include <time.h>
# include <stdlib.h>
# ifndef _WIN32
# include <sys/types.h>
# include <unistd.h>
# endif
# include "buban103.h"
# include "scadaprotect.h"
//typedef int i_32;
//typedef unsigned long u_32;
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 ] ;
/*!
\ brief <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> · <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*/
const int MAX_LINK_NUM = 30 ;
/*!
\ brief ÿ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> · <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> װ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*/
const int MAX_DEV_NUM_EACH_LINK = 12 ;
/*
enum Param_Type
{
PARAM_NO = 0 ,
PARAM_LINK ,
PARAM_DEV ,
PARAM_YC ,
PARAM_YX ,
PARAM_YM ,
PARAM_YK ,
PARAM_SYNCTIME ,
PARAM_ASDU10
} ;
*/
const char * gpStrBuban103Cmd [ BUBAN103_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> ÷<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ״̬<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ѯ "
} ;
/*!
<EFBFBD> <EFBFBD> ֯ <EFBFBD> ṹ : <EFBFBD> <EFBFBD> · ( <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ) + װ <EFBFBD> <EFBFBD>
*/
const char * gpStrBuban103ConfigInfo [ ] =
{
" *******<2A> <> <EFBFBD> <EFBFBD> 103<30> <33> Լ<EFBFBD> <D4BC> ʼ ******* " ,
" " ,
" ; <20> <> ѯָ<D1AF> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> ã<EFBFBD> <C3A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> ھ <EFBFBD> <DABE> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <CEAA> λ<EFBFBD> <CEBB> " ,
" ʱ<> <CAB1> ͬ<EFBFBD> <CDAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> = 0 " ,
" <20> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> = 0 " ,
" <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ѯ = 0 " ,
" ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ģ<EFBFBD> <C4A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ѯ = 0 " ,
" ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ״̬<D7B4> <CCAC> <EFBFBD> <EFBFBD> ѯ = 0 " ,
" " ,
" <20> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> =1 " ,
" ; ȱʡֵ=1,ֻ֧<D6BB> <D6A7> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> ·,<2C> <> <EFBFBD> <EFBFBD> Ϊʵ<CEAA> ʵ<EFBFBD> <CAB5> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> " ,
" " ,
" <20> <> ·1ģ<31> <C4A3> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> = 103template.csv " ,
" ... ... " ,
" <20> <> ·nģ<6E> <C4A3> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> = 103template.csv " ,
" ; <20> <> <EFBFBD> У <EFBFBD> n=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> е <EFBFBD> (<28> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> )<29> <> Ӧ<EFBFBD> <D3A6> ֵ " ,
" " ,
" <20> <> <EFBFBD> <EFBFBD> ң<EFBFBD> ű<EFBFBD> λ=0 " ,
" ;<3B> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ת<EFBFBD> <D7AA> ,ȱʡ<C8B1> <CAA1> <EFBFBD> <EFBFBD> <EFBFBD> ²<EFBFBD> <C2B2> <EFBFBD> <EFBFBD> <EFBFBD> " ,
" " ,
" *******<2A> <> <EFBFBD> <EFBFBD> 103<30> <33> Լ<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 Buban103ReadConfig ( int commid )
{
int i , j , iDevId ;
char szSection [ 128 ] , entry [ 256 ] , szbuf [ 128 ] ;
char szPortConfig [ 256 ] , szDir [ 256 ] , szTemplate [ 256 ] ;
pBUBAN103PORTPARAM 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 ( BUBAN103PORTPARAM ) ) ;
Buban103DispMalloc ( commid , sizeof ( BUBAN103PORTPARAM ) ) ;
if ( ! SioParam [ commid ] . ExtInfo )
{
# ifdef _WIN32
sprintf ( szbuf , " WARN(%04d): commid_%02d ExtInfo=malloc(%d) failed. \n " ,
_getpid ( ) , commid , sizeof ( BUBAN103PORTPARAM ) ) ;
# else
sprintf ( szbuf , " WARN(%04d): commid_%02d ExtInfo=malloc(%d) failed. \n " ,
getpid ( ) , commid , sizeof ( BUBAN103PORTPARAM ) ) ;
# endif
DebugPrint ( szbuf ) ;
return ;
}
memset ( SioParam [ commid ] . ExtInfo , 0 , sizeof ( BUBAN103PORTPARAM ) ) ;
pPortParam = ( pBUBAN103PORTPARAM ) 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> <EFBFBD> <EFBFBD> ң<EFBFBD> ű<EFBFBD> λ" , " 0 " , szbuf , 120 , szPortConfig ) > 0 )
{
if ( atoi ( szbuf ) = = 0 )
{
pPortParam - > m_bSendChangeDi = FALSE ;
}
else
{
pPortParam - > m_bSendChangeDi = TRUE ;
}
}
// wen 2004.07.26 <20> <> <EFBFBD> ӱ<EFBFBD> <D3B1> <EFBFBD> װ<EFBFBD> õ<EFBFBD> ״̬<D7B4> <CCAC> <EFBFBD> <EFBFBD>
if ( GetPrivateProString ( szSection , " <EFBFBD> <EFBFBD> ·<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " , " 1 " , szbuf , 120 , szPortConfig ) > 0 )
{
pPortParam - > m_iLinkNum = atoi ( szbuf ) ;
}
if ( pPortParam - > m_iLinkNum < = 1 )
{
pPortParam - > m_iLinkNum = 1 ;
}
if ( pPortParam - > m_iLinkNum > MAX_LINK_NUM )
{
pPortParam - > m_iLinkNum = MAX_LINK_NUM ;
}
pPortParam - > m_psLink
= ( BUBAN103LINKDEF * ) HEAP_MALLOC ( sizeof ( BUBAN103LINKDEF ) * pPortParam - > m_iLinkNum ) ;
Buban103DispMalloc ( commid , sizeof ( BUBAN103LINKDEF ) * pPortParam - > m_iLinkNum ) ;
memset ( ( void * ) pPortParam - > m_psLink , 0 , sizeof ( BUBAN103LINKDEF ) * pPortParam - > m_iLinkNum ) ;
// <20> ٶ<EFBFBD> <D9B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͬ
//for(i=0; i<pPortParam->m_iLinkNum; i++)
i = 0 ;
{
// <20> <> ѯָ<D1AF> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
for ( j = 0 ; j < BUBAN103_TIMER_CMD_NUM ; j + + )
{
GetPrivateProString ( szSection , ( char * ) gpStrBuban103Cmd [ j ] , " 0 " , szbuf , 120 , szPortConfig ) ;
pPortParam - > m_psLink [ i ] . m_sArrayCmdTime [ j ] . m_iCmdTimerConst
= ( int ) ( atof ( szbuf ) * 1000 / TIMER_CNT ) ;
if ( pPortParam - > m_psLink [ i ] . m_sArrayCmdTime [ j ] . m_iCmdTimerConst > 5 )
{
pPortParam - > m_psLink [ i ] . m_sArrayCmdTime [ j ] . m_iCmdTimerCnt
= pPortParam - > m_psLink [ i ] . m_sArrayCmdTime [ j ] . m_iCmdTimerConst - 5 ;
}
}
//GetPrivateProString(szSection, "<22> <> ʱʱ<CAB1> <CAB1> ", "20", szbuf, 120, szPortConfig);
//pPortParam->m_psLink[i].m_u32TimeOutConst = (int)(atof(szbuf)*1000/TIMER_CNT);
pPortParam - > m_psLink [ i ] . m_u32TimeOutConst = pPortParam - > m_psBaoHu - > RetryTime ;
}
for ( i = 1 ; i < pPortParam - > m_iLinkNum ; i + + )
{
for ( j = 0 ; j < BUBAN103_TIMER_CMD_NUM ; j + + )
{
pPortParam - > m_psLink [ i ] . m_sArrayCmdTime [ j ] . m_iCmdTimerConst
= pPortParam - > m_psLink [ 0 ] . m_sArrayCmdTime [ j ] . m_iCmdTimerConst ;
pPortParam - > m_psLink [ i ] . m_sArrayCmdTime [ j ] . m_iCmdTimerCnt
= pPortParam - > m_psLink [ 0 ] . m_sArrayCmdTime [ j ] . m_iCmdTimerCnt ;
}
pPortParam - > m_psLink [ i ] . m_u32TimeOutConst = pPortParam - > m_psLink [ 0 ] . m_u32TimeOutConst ;
}
for ( i = 0 ; i < pPortParam - > m_iLinkNum ; i + + )
{
sprintf ( entry , " <EFBFBD> <EFBFBD> ·%dģ<64> <C4A3> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> " , i + 1 ) ;
GetPrivateProString ( szSection , entry , " 103template.csv " , pPortParam - > m_psLink [ i ] . m_chArrayTempletFileName ,
sizeof ( pPortParam - > m_psLink [ i ] . m_chArrayTempletFileName ) - 1 , szPortConfig ) ;
# ifdef OS_LINUX
sprintf ( szTemplate , " inf/%s " , pPortParam - > m_psLink [ i ] . m_chArrayTempletFileName ) ;
# else
sprintf ( szTemplate , " %s/inf/%s " , IniFilePath , pPortParam - > m_psLink [ i ] . m_chArrayTempletFileName ) ;
# endif
// <20> ж<EFBFBD> <D0B6> <EFBFBD> <EFBFBD> <EFBFBD> վ<EFBFBD> <D5BE> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> վ
//InitBuban103InfoFromTempletFile(commid, szTemplate, &pPortParam->m_psLink[i]);
//InitBuban103InfoFromDat(commid, &pPortParam->m_psLink[i]);
if ( PROTOCOL_SLAVE = = pPortParam - > m_psBaoHu - > PortType )
{
// wen 2005.06.22 <20> <> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˳<EFBFBD> ,<2C> <> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> Ȼ<EFBFBD> <C8BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȷ<EFBFBD> <C8B7> <EFBFBD> <EFBFBD>
//InitBuban103InfoFromTempletFileEx(commid, szTemplate, &pPortParam->m_psLink[i], FALSE);
if ( FALSE = = InitBuban103InfoFromTempletFileEx ( commid , szTemplate , & pPortParam - > m_psLink [ i ] , FALSE ) )
{
pPortParam - > m_iLinkNum = i ;
break ;
}
}
else
{
// wen 2005.06.22 <20> <> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˳<EFBFBD> ,<2C> <> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> Ȼ<EFBFBD> <C8BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȷ<EFBFBD> <C8B7> <EFBFBD> <EFBFBD>
//InitBuban103InfoFromTempletFileEx(commid, szTemplate, &pPortParam->m_psLink[i], TRUE);
//InitBuban103InfoFromDat(commid, &pPortParam->m_psLink[i]);
if ( FALSE = = InitBuban103InfoFromTempletFileEx ( commid , szTemplate , & pPortParam - > m_psLink [ i ] , TRUE ) )
{
pPortParam - > m_iLinkNum = i ;
break ;
}
else
{
InitBuban103InfoFromDat ( commid , & pPortParam - > m_psLink [ i ] ) ;
}
}
}
// wen 2005.05.17 <20> <> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> <DDBF> <EFBFBD> <EFBFBD> <EFBFBD> λ<EFBFBD> <CEBB>
ReCalcDevPntStart ( commid , pPortParam ) ;
InitBuban103CmdBuf ( commid , pPortParam ) ;
// <20> <> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ10<31> <30>
for ( i = 0 ; i < pPortParam - > m_iLinkNum ; i + + )
{
if ( pPortParam - > m_psLink [ i ] . m_psProvDev = = NULL )
{
break ;
}
for ( j = 0 ; j < pPortParam - > m_psLink [ i ] . m_iDevNum ; j + + )
{
iDevId = ( commid < < 16 ) + ( i < < 8 ) + j ;
SingleListInitEx ( & pPortParam - > m_psLink [ i ] . m_psProvDev [ j ] . m_sBaoHuData , 10 , iDevId ) ;
}
}
//Buban103DispConfig(commid, pPortParam);
}
//********************************************************************
//* <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 Buban103RecvData ( int commid , u_char * buf , int len ) // <20> <> Լ<EFBFBD> <D4BC> <EFBFBD> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD>
{
int i ;
pBUBAN103PORTPARAM pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
if ( ! IsExtInfoPtr ( commid ) )
return ;
pPortParam = ( pBUBAN103PORTPARAM ) 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 ] = = 0x10 )
{
pPortParam - > m_psBaoHu - > m_iRevStatus = 4 ;
pPortParam - > m_psBaoHu - > m_iNeedRevLength = 4 ;
pPortParam - > m_achRecvBuf [ pPortParam - > m_iRecvLen + + ] = buf [ i ] ;
}
else if ( buf [ i ] = = 0x68 )
{
pPortParam - > m_psBaoHu - > m_iRevStatus + + ;
pPortParam - > m_achRecvBuf [ pPortParam - > m_iRecvLen + + ] = buf [ i ] ;
}
else
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
SioParam [ commid ] . ErrMsgNum + + ;
}
break ;
case 1 :
case 2 :
pPortParam - > m_psBaoHu - > m_iRevStatus + + ;
pPortParam - > m_achRecvBuf [ pPortParam - > m_iRecvLen + + ] = buf [ i ] ;
break ;
case 3 : // <20> <> <EFBFBD> ȼ<EFBFBD> <C8BC> <EFBFBD>
if ( buf [ i ] = = 0x68 )
{
if ( pPortParam - > m_achRecvBuf [ 1 ] ! = pPortParam - > m_achRecvBuf [ 2 ] )
{
pPortParam - > m_psBaoHu - > m_iRevStatus = 1 ;
SioParam [ commid ] . ErrMsgNum + = pPortParam - > m_iRecvLen ;
Buban103ProcessData ( commid , pPortParam , FALSE ) ;
pPortParam - > m_iRecvLen = 0 ;
pPortParam - > m_achRecvBuf [ pPortParam - > m_iRecvLen + + ] = buf [ i ] ;
}
else
{
pPortParam - > m_psBaoHu - > m_iRevStatus + + ;
pPortParam - > m_achRecvBuf [ pPortParam - > m_iRecvLen + + ] = buf [ i ] ;
pPortParam - > m_psBaoHu - > m_iNeedRevLength = ( BYTE ) ( pPortParam - > m_achRecvBuf [ 1 ] ) + 2 ;
}
}
else
{
pPortParam - > m_achRecvBuf [ pPortParam - > m_iRecvLen + + ] = buf [ i ] ;
pPortParam - > m_psBaoHu - > m_iRevStatus = 5 ;
}
break ;
case 4 : // <20> <> ȷ<EFBFBD> <C8B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pPortParam - > m_psBaoHu - > m_iNeedRevLength - - ;
pPortParam - > m_achRecvBuf [ pPortParam - > m_iRecvLen + + ] = buf [ i ] ;
if ( pPortParam - > m_psBaoHu - > m_iNeedRevLength > 0 )
break ;
if ( buf [ i ] ! = 0x16 )
{
pPortParam - > m_psBaoHu - > m_iRevStatus = 5 ;
break ;
}
if ( Buban103Check ( pPortParam - > m_achRecvBuf , pPortParam - > m_iRecvLen ) = = TRUE )
{
Buban103ProcessData ( commid , pPortParam , TRUE ) ;
pPortParam - > m_psBaoHu - > m_iRevStatus = 0 ;
pPortParam - > m_psBaoHu - > RevCmdFlag = 1 ;
}
else
{
SioParam [ commid ] . ErrMsgNum + = pPortParam - > m_iRecvLen ;
SioParam [ commid ] . LostSyncCnt + + ;
pPortParam - > m_psBaoHu - > m_iRevStatus = 5 ;
}
# ifndef OS_LINUX
if ( ( GetCurPort ( ) = = commid ) & & IsRealDataDisp ( ) )
{
WatchDataPutDispBuf ( commid , SDS_SIO_RECV_DATA ,
( BYTE * ) pPortParam - > m_achRecvBuf , pPortParam - > m_iRecvLen ) ;
}
# endif
break ;
case 5 : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
default :
pPortParam - > m_achRecvBuf [ pPortParam - > m_iRecvLen + + ] = buf [ i ] ;
if ( buf [ i ] = = 0x16 )
{
# ifndef OS_LINUX
// wen 2004.11.22 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʾ
if ( ( GetCurPort ( ) = = commid ) & & IsRealDataDisp ( ) )
{
WatchDataPutDispBuf ( commid , SDS_SIO_RECV_DATA ,
( BYTE * ) pPortParam - > m_achRecvBuf , pPortParam - > m_iRecvLen ) ;
}
# endif
Buban103ProcessData ( commid , pPortParam , FALSE ) ;
SioParam [ commid ] . ErrMsgNum + = pPortParam - > m_iRecvLen ;
pPortParam - > m_psBaoHu - > m_iRevStatus = 0 ;
pPortParam - > m_iRecvLen = 0 ;
}
else
{
if ( pPortParam - > m_iRecvLen > 200 )
{
# ifndef OS_LINUX
// wen 2004.11.22 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʾ
if ( ( GetCurPort ( ) = = commid ) & & IsRealDataDisp ( ) )
{
WatchDataPutDispBuf ( commid , SDS_SIO_RECV_DATA ,
( BYTE * ) pPortParam - > m_achRecvBuf , pPortParam - > m_iRecvLen ) ;
}
# endif
Buban103ProcessData ( 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 Buban103Timer ( int commid )
{
BUBAN103PORTPARAM * pPortParam ;
BUBAN103LINKDEF * pLinkParam ;
if ( IsExtInfoPtr ( commid ) = = FALSE )
{
return ;
}
pPortParam = ( pBUBAN103PORTPARAM ) SioParam [ commid ] . ExtInfo ;
// wen 2005.06.22 <20> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> Ϊ0ֱ<30> <D6B1> <EFBFBD> ˳<EFBFBD>
if ( pPortParam - > m_iLinkNum < = 0 )
{
return ;
}
// <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 )
{
pLinkParam = & pPortParam - > m_psLink [ pPortParam - > m_iLinkIdx ] ;
if ( IsDevLinkOk ( pLinkParam , pPortParam - > m_iLinkIdx ) = = TRUE )
{
if ( pLinkParam - > m_uchLinkAddr ! = 0xFF )
{
if ( IsLinkTimeOut ( pLinkParam , 0 ) = = TRUE )
{
InitBuban103CmdBuf ( commid , pPortParam ) ;
}
}
else
{
if ( IsLinkTimeOut ( pLinkParam , pPortParam - > m_iLinkIdx ) = = TRUE )
{
InitBuban103DevCmdBuf ( pLinkParam , pLinkParam - > m_iDevIdx ) ;
}
}
}
//Buban103FindNextCmd(commid);
if ( TRUE = = Buban103FindNextCmdEx ( commid ) )
{
Buban103CalcNextDev ( commid , FALSE ) ;
}
}
Buban103SendCmdFormPollCmdBuf ( 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 Buban103YkYtProcess ( int commid , u_char * buf , int len ) // ң<> <D2A3> ң<EFBFBD> <D2A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
int iDirect , portno , ykytpnt ;
u_char asdu , dco ;
CASDU20 bCAsdu20 ;
YKYT_PARAM YkYtParam ;
DEVDEF * pDevParam ;
DEVADDRPARAM sAddrParam ;
BUBAN103PORTPARAM * pPortParam ;
char szbuf [ 128 ] ;
// 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 ;
//ykytpnt--;
// <20> <> У <EFBFBD> <D0A3> Ϣ(<28> <> <EFBFBD> <EFBFBD> <EFBFBD> ź<EFBFBD> )
if ( iDirect )
{
if ( ( buf [ 8 ] = = STEP_YKYT_SELECT ) | | ( buf [ 8 ] = = STEP_YKYT_SELECT + 3 ) )
{
YkYtParam . m_iYkYtPnt = ykytpnt ;
YkYtParam . m_iYkYtStep = buf [ 8 ] ;
YkYtParam . m_iYkYtUpDown = YKYT_SEND_UP ;
YkYtParam . m_iYkYtOperate = buf [ 9 ] ;
SendYkYtCommand2 ( commid , & YkYtParam ) ;
# ifdef _WIN32
sprintf ( szbuf , " WARN(%04d): ת<> <D7AA> ң<EFBFBD> <D2A3> Ԥ<EFBFBD> У <EEB7B4> ɹ<EFBFBD> . \n " , _getpid ( ) ) ;
# else
sprintf ( szbuf , " WARN(%04d): ת<> <D7AA> ң<EFBFBD> <D2A3> Ԥ<EFBFBD> У <EEB7B4> ɹ<EFBFBD> . \n " , getpid ( ) ) ;
# endif
DebugPrint ( szbuf ) ;
return ;
}
Buban103ProvMakeYkYtCommand ( commid , buf , len ) ;
return ;
}
pPortParam = ( pBUBAN103PORTPARAM ) SioParam [ commid ] . ExtInfo ;
// <20> <> У ʧ<D0A3> <CAA7>
// <20> <> <EFBFBD> <EFBFBD> : <20> ˿<EFBFBD> <CBBF> <EFBFBD> ·״̬Ϊ<CCAC> ٻ<EFBFBD> <D9BB> <EFBFBD> δ<EFBFBD> ҵ<EFBFBD> <D2B5> <EFBFBD> <EFBFBD> ʵĿص<C4BF>
if ( FALSE = = FindProtectDevFromYkYtPnt ( pPortParam , & sAddrParam , ykytpnt ) )
{
YkYtParam . m_iYkYtPnt = ykytpnt ;
YkYtParam . m_iYkYtStep = buf [ 8 ] ;
YkYtParam . m_iYkYtUpDown = YKYT_SEND_UP ;
YkYtParam . m_iYkYtOperate = 3 ;
SendYkYtCommand2 ( commid , & YkYtParam ) ;
return ;
}
else if ( FALSE = = IsDevLinkOk ( & pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] , sAddrParam . m_iDevIdx ) )
{
YkYtParam . m_iYkYtPnt = ykytpnt ;
YkYtParam . m_iYkYtStep = buf [ 8 ] ;
YkYtParam . m_iYkYtUpDown = YKYT_SEND_UP ;
YkYtParam . m_iYkYtOperate = 3 ;
SendYkYtCommand2 ( commid , & YkYtParam ) ;
return ;
}
pDevParam = & pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_psDev [ sAddrParam . m_iDevIdx ] ;
asdu = pDevParam - > m_sDevParam . m_sYkDBOrientation . m_psDataInfo [ ykytpnt ] . m_u8Asdu ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
switch ( buf [ 8 ] )
{
case STEP_YKYT_SELECT :
case STEP_YKYT_SELECT + 3 : //ѡ <> <D1A1>
if ( ( C_DC_NA_3 ! = asdu ) & & ( C_RC_NA_3 ! = asdu ) )
{ // ֱ<> ط<EFBFBD> ʽ
YkYtParam . m_iYkYtPnt = ykytpnt ;
YkYtParam . m_iYkYtStep = buf [ 8 ] ;
YkYtParam . m_iYkYtUpDown = YKYT_SEND_UP ;
YkYtParam . m_iYkYtOperate = buf [ 9 ] ;
SendYkYtCommand2 ( commid , & YkYtParam ) ;
}
else
{
ykytpnt - = pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iStartPntNo ;
bCAsdu20 . nTYP = asdu ; //<2F> <> <EFBFBD> ͱ<EFBFBD> ʶ
bCAsdu20 . nVSQ = 0x01 ; //<2F> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD>
bCAsdu20 . nCOT = 0x0c ; //<2F> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD>
bCAsdu20 . nADDR = pDevParam - > m_sDevParam . m_u8DevAddr ; //Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
bCAsdu20 . nFUN = ( u_char ) pDevParam - > m_sDevParam . m_sYkDBOrientation . m_psDataInfo [ ykytpnt ] . m_u8Fun ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
bCAsdu20 . nINF = ( u_char ) pDevParam - > m_sDevParam . m_sYkDBOrientation . m_psDataInfo [ ykytpnt ] . m_u8Inf ; //<2F> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD>
if ( buf [ 9 ] = = 2 )
{
bCAsdu20 . nDCO = 0x81 ; //<2F> <> <EFBFBD> ƶ<EFBFBD> ·<EFBFBD> <C2B7> (<28> ط<EFBFBD> )
}
else
{
bCAsdu20 . nDCO = 0x82 ; //<2F> <> <EFBFBD> ƶ<EFBFBD> ·<EFBFBD> <C2B7> (<28> غ<EFBFBD> )
}
bCAsdu20 . nRII = ( BYTE ) sAddrParam . m_iLinkIdx ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> ʶ<EFBFBD> <CAB6>
if ( pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_uchLinkAddr = = 255 )
{
MakeBuban103LinkCommand ( commid , pDevParam - > m_sDevParam . m_u8DevAddr , \
C_SD1_NA_3 , ( u_char * ) & bCAsdu20 , sizeof ( CASDU20 ) , INSERT_POLL_CMD ) ;
}
else
{
MakeBuban103LinkCommand ( commid , \
pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_uchLinkAddr , \
C_SD1_NA_3 , ( u_char * ) & bCAsdu20 , sizeof ( CASDU20 ) , INSERT_POLL_CMD ) ;
}
YkYtParam . m_iYkYtPnt = ykytpnt ;
YkYtParam . m_iYkYtStep = buf [ 8 ] ;
YkYtParam . m_iYkYtUpDown = YKYT_SEND_UP ;
YkYtParam . m_iYkYtOperate = buf [ 9 ] ;
SendYkYtCommand2 ( commid , & YkYtParam ) ;
}
break ;
case STEP_YKYT_EXEC :
case STEP_YKYT_EXEC + 3 : //ִ<> <D6B4>
//pDevParam = &pPortParam->m_psLink[sAddrParam.m_iLinkIdx].m_psDev[sAddrParam.m_iDevIdx];
ykytpnt - = pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iStartPntNo ;
// ң<> <D2A3> ң<EFBFBD> <D2A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֻ<EFBFBD> <D6BB> asdu20,<2C> <> <EFBFBD> <EFBFBD> asdu64/65<36> <35> yizhonghu 20060803
//bCAsdu20.nTYP = 20; //<2F> <> <EFBFBD> ͱ<EFBFBD> ʶ
bCAsdu20 . nTYP = asdu ; //<2F> <> <EFBFBD> ͱ<EFBFBD> ʶ
bCAsdu20 . nVSQ = 0x81 ; //<2F> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD>
if ( asdu = = 20 )
{
bCAsdu20 . nCOT = 0x14 ; //<2F> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD>
bCAsdu20 . nVSQ = 0x81 ; //<2F> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD>
}
else
{
bCAsdu20 . nCOT = 0x0c ; //<2F> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD>
bCAsdu20 . nVSQ = 0x01 ; //<2F> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD>
}
bCAsdu20 . nADDR = pDevParam - > m_sDevParam . m_u8DevAddr ; //Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
bCAsdu20 . nFUN = ( u_char ) pDevParam - > m_sDevParam . m_sYkDBOrientation . m_psDataInfo [ ykytpnt ] . m_u8Fun ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
bCAsdu20 . nINF = ( u_char ) pDevParam - > m_sDevParam . m_sYkDBOrientation . m_psDataInfo [ ykytpnt ] . m_u8Inf ; //<2F> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD>
dco = 0 ;
if ( buf [ 9 ] = = 2 )
{
bCAsdu20 . nDCO = ( 1 | dco ) ; //<2F> <> <EFBFBD> ƶ<EFBFBD> ·<EFBFBD> <C2B7> (<28> ط<EFBFBD> )
}
else
{
bCAsdu20 . nDCO = ( 2 | dco ) ; //<2F> <> <EFBFBD> ƶ<EFBFBD> ·<EFBFBD> <C2B7> (<28> غ<EFBFBD> )
}
bCAsdu20 . nRII = ( BYTE ) sAddrParam . m_iLinkIdx ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> ʶ<EFBFBD> <CAB6>
if ( pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_uchLinkAddr = = 255 )
{
MakeBuban103LinkCommand ( commid , pDevParam - > m_sDevParam . m_u8DevAddr , \
C_SD1_NA_3 , ( u_char * ) & bCAsdu20 , sizeof ( CASDU20 ) , INSERT_POLL_CMD ) ;
}
else
{
MakeBuban103LinkCommand ( commid , \
pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_uchLinkAddr , \
C_SD1_NA_3 , ( u_char * ) & bCAsdu20 , sizeof ( CASDU20 ) , INSERT_POLL_CMD ) ;
}
break ;
case STEP_YKYT_CANCEL :
case STEP_YKYT_CANCEL + 3 : //ȡ<> <C8A1>
//pDevParam = &pPortParam->m_psLink[sAddrParam.m_iLinkIdx].m_psDev[sAddrParam.m_iDevIdx];
ykytpnt - = pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iStartPntNo ;
bCAsdu20 . nTYP = asdu ; //<2F> <> <EFBFBD> ͱ<EFBFBD> ʶ
bCAsdu20 . nVSQ = 0x01 ; //<2F> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD>
bCAsdu20 . nCOT = 0x0c ; //<2F> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD>
bCAsdu20 . nADDR = pDevParam - > m_sDevParam . m_u8DevAddr ; //Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
bCAsdu20 . nFUN = ( u_char ) pDevParam - > m_sDevParam . m_sYkDBOrientation . m_psDataInfo [ ykytpnt ] . m_u8Fun ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
bCAsdu20 . nINF = ( u_char ) pDevParam - > m_sDevParam . m_sYkDBOrientation . m_psDataInfo [ ykytpnt ] . m_u8Inf ; //<2F> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD>
dco = 0xc0 ;
if ( buf [ 9 ] = = 2 )
{
bCAsdu20 . nDCO = ( 1 | dco ) ; //<2F> <> <EFBFBD> ƶ<EFBFBD> ·<EFBFBD> <C2B7> (<28> ط<EFBFBD> )
}
else
{
bCAsdu20 . nDCO = ( 2 | dco ) ; //<2F> <> <EFBFBD> ƶ<EFBFBD> ·<EFBFBD> <C2B7> (<28> غ<EFBFBD> )
}
bCAsdu20 . nRII = ( BYTE ) sAddrParam . m_iLinkIdx ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> ʶ<EFBFBD> <CAB6>
if ( pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_uchLinkAddr = = 255 )
{
MakeBuban103LinkCommand ( commid , pDevParam - > m_sDevParam . m_u8DevAddr , \
C_SD1_NA_3 , ( u_char * ) & bCAsdu20 , sizeof ( CASDU20 ) , INSERT_POLL_CMD ) ;
}
else
{
MakeBuban103LinkCommand ( commid , \
pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_uchLinkAddr , \
C_SD1_NA_3 , ( u_char * ) & bCAsdu20 , sizeof ( CASDU20 ) , INSERT_POLL_CMD ) ;
}
break ;
case STEP_YKYT_DIRECT : // ֱ<> <D6B1>
break ;
case STEP_YKYT_STOP : // <20> <> ͣ
//pDevParam = &pPortParam->m_psLink[sAddrParam.m_iLinkIdx].m_psDev[sAddrParam.m_iDevIdx];
ykytpnt - = pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iStartPntNo ;
bCAsdu20 . nTYP = asdu ; //<2F> <> <EFBFBD> ͱ<EFBFBD> ʶ
bCAsdu20 . nVSQ = 0x01 ; //<2F> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD>
bCAsdu20 . nCOT = 0x0c ; //<2F> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD>
bCAsdu20 . nADDR = pDevParam - > m_sDevParam . m_u8DevAddr ; //Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
bCAsdu20 . nFUN = ( u_char ) pDevParam - > m_sDevParam . m_sYkDBOrientation . m_psDataInfo [ ykytpnt ] . m_u8Fun ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
bCAsdu20 . nINF = ( u_char ) pDevParam - > m_sDevParam . m_sYkDBOrientation . m_psDataInfo [ ykytpnt ] . m_u8Inf ; //<2F> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD>
dco = 0x00 ;
bCAsdu20 . nDCO = ( 3 | dco ) ; //ң<> <D2A3> <EFBFBD> <EFBFBD> ͣ
bCAsdu20 . nRII = ( BYTE ) sAddrParam . m_iLinkIdx ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> ʶ<EFBFBD> <CAB6>
if ( pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_uchLinkAddr = = 255 )
{
MakeBuban103LinkCommand ( commid , pDevParam - > m_sDevParam . m_u8DevAddr , \
C_SD1_NA_3 , ( u_char * ) & bCAsdu20 , sizeof ( CASDU20 ) , INSERT_POLL_CMD ) ;
}
else
{
MakeBuban103LinkCommand ( commid , \
pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_uchLinkAddr , \
C_SD1_NA_3 , ( u_char * ) & bCAsdu20 , sizeof ( CASDU20 ) , INSERT_POLL_CMD ) ;
}
break ;
default :
break ;
}
}
//********************************************************************
//* ϵͳ<CFB5> ·<EFBFBD> <C2B7> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> int commid : <20> ˿ں<CBBF> *
//********************************************************************
void Buban103SendSystemTime ( int commid ) // ϵͳ<CFB5> <CDB3> ʱ
{
int i , j ;
CMDPARAM sCmdParam ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
char szbuf [ 128 ] ;
if ( IsExtInfoPtr ( commid ) = = FALSE )
{
return ;
}
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
if ( 2 ! = pPortParam - > m_psBaoHu - > CheckTime )
{
return ;
}
sprintf ( szbuf , " port=%d,CheckTime=%d " , commid + 1 , pPortParam - > m_psBaoHu - > CheckTime ) ;
DebugPrint ( szbuf ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> е <EFBFBD> װ<EFBFBD> ÷<EFBFBD> <C3B7> Ͷ<EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD>
for ( i = 0 ; i < pPortParam - > m_iLinkNum ; i + + )
{
pLinkParam = & pPortParam - > m_psLink [ i ] ;
for ( j = 0 ; j < pLinkParam - > m_iDevNum ; j + + )
{
pDevParam = & pLinkParam - > m_psDev [ j ] ;
sCmdParam . m_sDevAddr . m_uchLinkAddr = pLinkParam - > m_uchLinkAddr ;
sCmdParam . m_sDevAddr . m_uchCommAddr = pDevParam - > m_sDevParam . m_u8DevAddr ;
sCmdParam . m_uchFun = ( u_char ) pDevParam - > m_sDevParam . m_sSyncTimeInfo . m_u8Fun ;
sCmdParam . m_uchInf = ( u_char ) pDevParam - > m_sDevParam . m_sSyncTimeInfo . m_u8Inf ;
sCmdParam . m_uchRII = pDevParam - > m_u8RII ;
MakeTimeSyn_CAsdu6 ( commid , & sCmdParam ) ;
}
}
}
//********************************************************************
//* ϵͳ<CFB5> ˳<EFBFBD> ʱ<EFBFBD> <CAB1> Լ<EFBFBD> <D4BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> int commid : <20> ˿ں<CBBF> *
//********************************************************************
void Buban103Exit ( int commid )
{
int i , j , k ;
DBORIENTATION * pDB ;
GROUPDEF * pGroup ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
if ( SioParam [ commid ] . ExtInfo = = NULL )
{
return ;
}
pPortParam = ( pBUBAN103PORTPARAM ) SioParam [ commid ] . ExtInfo ;
if ( pPortParam - > m_psLink = = NULL )
{
return ;
}
for ( i = 0 ; i < pPortParam - > m_iLinkNum ; i + + )
{
pLinkParam = ( BUBAN103LINKDEF * ) ( & pPortParam - > m_psLink [ i ] ) ;
if ( pLinkParam - > m_psDev ! = NULL )
{
for ( j = 0 ; j < pLinkParam - > m_iDevNum ; j + + )
{
// ai
for ( k = 0 ; k < DEV_AI_MAXNUM ; k + + )
{
pDB = & pLinkParam - > m_psDev [ j ] . m_sDevParam . m_sAiDBOrientation [ k ] ;
if ( pDB - > m_psDataInfo ! = NULL )
{
HEAP_FREE ( pDB - > m_psDataInfo ) ;
pDB - > m_psDataInfo = NULL ;
}
}
// di
pDB = & pLinkParam - > m_psDev [ j ] . m_sDevParam . m_sDiDBOrientation ;
if ( pDB - > m_psDataInfo ! = NULL )
{
HEAP_FREE ( pDB - > m_psDataInfo ) ;
pDB - > m_psDataInfo = NULL ;
}
// pi
pDB = & pLinkParam - > m_psDev [ j ] . m_sDevParam . m_sPiDBOrientation ;
if ( pDB - > m_psDataInfo ! = NULL )
{
HEAP_FREE ( pDB - > m_psDataInfo ) ;
pDB - > m_psDataInfo = NULL ;
}
// yk
pDB = & pLinkParam - > m_psDev [ j ] . m_sDevParam . m_sYkDBOrientation ;
if ( pDB - > m_psDataInfo ! = NULL )
{
HEAP_FREE ( pDB - > m_psDataInfo ) ;
pDB - > m_psDataInfo = NULL ;
}
// group
for ( k = 0 ; k < pLinkParam - > m_psDev [ j ] . m_sDevParam . m_iCfgGroupNum ; k + + )
{
pGroup = & pLinkParam - > m_psDev [ j ] . m_sDevParam . m_saGroupDef [ k ] ;
if ( pGroup - > m_psDataInfo ! = NULL )
{
HEAP_FREE ( pGroup - > m_psDataInfo ) ;
pGroup - > m_psDataInfo = NULL ;
}
if ( pGroup - > m_psEventInfo ! = NULL )
{
HEAP_FREE ( pGroup - > m_psEventInfo ) ;
pGroup - > m_psEventInfo = NULL ;
}
if ( pGroup - > m_pu8DataLen ! = NULL )
{
HEAP_FREE ( pGroup - > m_pu8DataLen ) ;
pGroup - > m_pu8DataLen = NULL ;
}
if ( pGroup - > m_pu8DataType ! = NULL )
{
HEAP_FREE ( pGroup - > m_pu8DataType ) ;
pGroup - > m_pu8DataType = NULL ;
}
if ( pGroup - > m_pu8GIN ! = NULL )
{
HEAP_FREE ( pGroup - > m_pu8GIN ) ;
pGroup - > m_pu8GIN = NULL ;
}
}
if ( pLinkParam - > m_psDev [ j ] . m_sDisturbanceParam . m_pshValue ! = NULL )
{
HEAP_FREE ( pLinkParam - > m_psDev [ j ] . m_sDisturbanceParam . m_pshValue ) ;
pLinkParam - > m_psDev [ j ] . m_sDisturbanceParam . m_pshValue = NULL ;
}
}
HEAP_FREE ( pLinkParam - > m_psDev ) ;
pLinkParam - > m_psDev = NULL ;
}
if ( pLinkParam - > m_psProvDev ! = NULL )
{
for ( j = 0 ; j < pLinkParam - > m_iDevNum ; j + + )
{
if ( pLinkParam - > m_psProvDev [ j ] . m_sYxInfo . m_psDataInfo ! = NULL )
{
HEAP_FREE ( pLinkParam - > m_psProvDev [ j ] . m_sYxInfo . m_psDataInfo ) ;
pLinkParam - > m_psProvDev [ j ] . m_sYxInfo . m_psDataInfo = NULL ;
}
if ( pLinkParam - > m_psProvDev [ j ] . m_sYcInfo . m_psDataInfo ! = NULL )
{
HEAP_FREE ( pLinkParam - > m_psProvDev [ j ] . m_sYcInfo . m_psDataInfo ) ;
pLinkParam - > m_psProvDev [ j ] . m_sYcInfo . m_psDataInfo = NULL ;
}
if ( pLinkParam - > m_psProvDev [ j ] . m_sYmInfo . m_psDataInfo ! = NULL )
{
HEAP_FREE ( pLinkParam - > m_psProvDev [ j ] . m_sYmInfo . m_psDataInfo ) ;
pLinkParam - > m_psProvDev [ j ] . m_sYmInfo . m_psDataInfo = NULL ;
}
SingleListDelAllData ( & pLinkParam - > m_psProvDev [ j ] . m_sBaoHuData ) ;
}
HEAP_FREE ( pLinkParam - > m_psProvDev ) ;
pLinkParam - > m_psProvDev = NULL ;
}
HEAP_FREE ( pLinkParam - > m_pbLinkOk ) ;
pLinkParam - > m_pbLinkOk = NULL ;
HEAP_FREE ( pLinkParam - > m_pu32LinkOkCnt ) ;
pLinkParam - > m_pu32LinkOkCnt = NULL ;
HEAP_FREE ( pLinkParam - > m_pu8CtlByte ) ;
pLinkParam - > m_pu8CtlByte = NULL ;
}
HEAP_FREE ( pPortParam - > m_psLink ) ;
pPortParam - > m_psLink = NULL ;
}
// <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 Buban103BaoHuCmdProcess ( int commid , RTUMSG * rtumsg , BOOL bUpData )
{
int iProvAddr ;
PROVDEVDEF * pProvDevParam ;
DEVADDRPARAM sAddrParam ;
BUBAN103PORTPARAM * pPortParam ;
char szbuf [ 128 ] ;
if ( ( MSGTYPE_BAOHU_SCADACMD = = rtumsg - > MsgType )
| | ( MSGTYPE_BAOHU_SCADADATA = = rtumsg - > MsgType ) )
{
sprintf ( szbuf , " commid%d <20> յ<EFBFBD> <D5B5> <EFBFBD> ֵָ<D6B5> <D6B8> " , commid ) ;
DebugPrint ( szbuf ) ;
Buban103ScadaProtocolExchange ( commid , rtumsg ) ;
return ;
}
if ( FALSE = = GetPortParamPtr ( commid , & pPortParam ) )
{
return ;
}
switch ( rtumsg - > MsgData [ 0 ] )
{
case 0x68 : // <20> <> ֡
iProvAddr = rtumsg - > MsgData [ 9 ] ;
break ;
case 0x10 : // <20> <> ֡
default :
iProvAddr = - 1 ;
break ;
}
if ( iProvAddr < 0 )
{
return ;
}
if ( FALSE = = FindProtectDevFromProvAddr ( pPortParam , & sAddrParam , iProvAddr ) )
{
return ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//if(MSGTYPE_BAOHU_103DATA == rtumsg->MsgType)
if ( bUpData = = TRUE )
{
// ??? <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 洢<EFBFBD> <E6B4A2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (Ӧ<> <D3A6> ֻ<EFBFBD> <D6BB> asdu10<31> <30> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
pProvDevParam = & pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_psProvDev [ sAddrParam . m_iDevIdx ] ;
SingleListAddData ( & pProvDevParam - > m_sBaoHuData , rtumsg - > MsgData , rtumsg - > MsgLen ) ;
return ;
}
// Ҫ<> <D2AA> <EFBFBD> <EFBFBD> ת<EFBFBD> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> <DDB5> жϣ<D0B6> <CFA3> <EFBFBD> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݸ<EFBFBD> ʽ <EFBFBD> Ĵ洢<C4B4> <E6B4A2> <EFBFBD> <EFBFBD> ȷ<EFBFBD> <C8B7> ת<EFBFBD> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> <DDB5> <EFBFBD> Դ
pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_sBaoHuCmdParam . m_iBaoHuCommid = rtumsg - > PortIdx ;
memcpy ( ( void * ) & pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_sBaoHuCmdParam . m_sRealAddrParam ,
( void * ) & sAddrParam , sizeof ( DEVADDRPARAM ) ) ;
GetLocalTimeEx ( & pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_sBaoHuCmdParam . m_sBaoHuCmdStartTime ) ;
pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_sBaoHuCmdParam . m_iBaoHuMsgType = MSGTYPE_BAOHU_103CMD ;
// <20> <EFBFBD> Ҫ<EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> ĵ<EFBFBD> ַ
if ( sAddrParam . m_uchLinkAddr ! = 0xFF )
{
rtumsg - > MsgData [ 5 ] = sAddrParam . m_uchLinkAddr ;
}
else
{
rtumsg - > MsgData [ 5 ] = sAddrParam . m_uchCommAddr ;
}
rtumsg - > MsgData [ 9 ] = sAddrParam . m_uchCommAddr ;
PutPollCmdToBuf ( commid , INSERT_POLL_CMD , 0 , ( char * ) rtumsg - > MsgData , rtumsg - > MsgLen ) ;
}
int Buban103GetBaohuDataBase ( int commid , int iProvAddr , GROUPDEF * * ppBaoHuDB )
{
DEVDEF * pDevParam ;
DEVADDRPARAM sAddrParam ;
BUBAN103PORTPARAM * pPortParam ;
if ( FALSE = = GetPortParamPtr ( commid , & pPortParam ) )
{
return 0 ;
}
if ( FALSE = = FindProtectDevFromProvAddr ( pPortParam , & sAddrParam , iProvAddr ) )
{
return 0 ;
}
pDevParam = & pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_psDev [ sAddrParam . m_iDevIdx ] ;
* ppBaoHuDB = pDevParam - > m_sDevParam . m_saGroupDef ;
return pDevParam - > m_sDevParam . m_iCfgGroupNum ;
}
/////////////////////////ͨ<> ú<EFBFBD> <C3BA> <EFBFBD> <EFBFBD> ӿڽ<D3BF> <DABD> <EFBFBD> ///////////////////////////////
void Buban103ProvMakeYkYtCommand ( 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> , 0=ʧ<> <CAA7> )
// (<28> <> <EFBFBD> <EFBFBD> λΪ1ʱ<31> <CAB1> Ϊ<EFBFBD> <CEAA> У <EFBFBD> <D0A3> <EFBFBD> <EFBFBD> )
// <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 ykytpnt ;
u_char asdu ;
CASDU20 bCAsdu20 ;
DEVDEF * pDevParam ;
DEVADDRPARAM sAddrParam ;
BUBAN103PORTPARAM * pPortParam ;
if ( ( buf [ 8 ] ! = STEP_YKYT_EXEC ) \
& & ( buf [ 8 ] ! = STEP_YKYT_EXEC + 3 )
& & ( buf [ 8 ] ! = STEP_YKYT_DIRECT ) )
{
return ;
}
if ( IsExtInfoPtr ( commid ) = = FALSE )
{
return ;
}
pPortParam = ( pBUBAN103PORTPARAM ) SioParam [ commid ] . ExtInfo ;
ykytpnt = buf [ 4 ] + buf [ 5 ] * 256 + buf [ 6 ] * 65536 + buf [ 7 ] * 16777216 ;
if ( FALSE = = FindProtectDevFromYkYtPnt ( pPortParam , & sAddrParam , ykytpnt ) )
{
return ;
}
pDevParam = & pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_psDev [ sAddrParam . m_iDevIdx ] ;
ykytpnt - = pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iStartPntNo ;
asdu = pDevParam - > m_sDevParam . m_sYkDBOrientation . m_psDataInfo [ ykytpnt ] . m_u8Asdu ;
// ң<> ص<EFBFBD> <D8B5> <EFBFBD> <EFBFBD> ͱ<EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 20<32> <30> <EFBFBD> <EFBFBD> 64/65 yizhonghu 20060803
//bCAsdu20.nTYP = 20; //<2F> <> <EFBFBD> ͱ<EFBFBD> ʶ
bCAsdu20 . nTYP = asdu ; //<2F> <> <EFBFBD> ͱ<EFBFBD> ʶ
if ( asdu ! = 20 )
{
bCAsdu20 . nVSQ = 0x01 ; //<2F> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD>
bCAsdu20 . nCOT = 0x0c ; //<2F> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD>
}
else
{
bCAsdu20 . nVSQ = 0x81 ; //<2F> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD>
bCAsdu20 . nCOT = 0x14 ; //<2F> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD>
}
bCAsdu20 . nADDR = pDevParam - > m_sDevParam . m_u8DevAddr ; //Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
bCAsdu20 . nFUN = ( u_char ) pDevParam - > m_sDevParam . m_sYkDBOrientation . m_psDataInfo [ ykytpnt ] . m_u8Fun ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
bCAsdu20 . nINF = ( u_char ) pDevParam - > m_sDevParam . m_sYkDBOrientation . m_psDataInfo [ ykytpnt ] . m_u8Inf ; //<2F> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD>
if ( buf [ 9 ] = = 2 )
{
bCAsdu20 . nDCO = 1 ; //<2F> <> <EFBFBD> ƶ<EFBFBD> ·<EFBFBD> <C2B7> (<28> ط<EFBFBD> )
}
else
{
bCAsdu20 . nDCO = 2 ; //<2F> <> <EFBFBD> ƶ<EFBFBD> ·<EFBFBD> <C2B7> (<28> غ<EFBFBD> )
}
bCAsdu20 . nRII = pDevParam - > m_u8RII ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> ʶ<EFBFBD> <CAB6>
if ( pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_uchLinkAddr = = 255 )
{
MakeBuban103LinkCommand ( commid , pDevParam - > m_sDevParam . m_u8DevAddr , \
C_SD1_NA_3 , ( u_char * ) & bCAsdu20 , sizeof ( CASDU20 ) , FAST_POLL_CMD ) ;
}
else
{
MakeBuban103LinkCommand ( commid , \
pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_uchLinkAddr , \
C_SD1_NA_3 , ( u_char * ) & bCAsdu20 , sizeof ( CASDU20 ) , FAST_POLL_CMD ) ;
}
}
//********************************************************************
//* <20> <> ʼ <EFBFBD> <CABC> װ<EFBFBD> ò<EFBFBD> <C3B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> DEVPARAMDEF *psDevParam : װ<> ò<EFBFBD> <C3B2> <EFBFBD> ָ<EFBFBD> <D6B8> *
//********************************************************************
void SetProtectDevStatus ( BUBAN103LINKDEF * psLinkParam , int iDevNo , BOOL bStatus )
{
DI_DEF pntmsg ;
DEVDEF * psDevDef ;
if ( psLinkParam - > m_psDev = = NULL )
{
return ;
}
if ( bStatus = = TRUE )
{
pntmsg . Status = 1 ;
}
else
{
pntmsg . Status = 0 ;
}
psDevDef = & psLinkParam - > m_psDev [ iDevNo ] ;
if ( psLinkParam - > m_iInputStationOfDevStatus > 0 )
{
SetPntMsg ( psLinkParam - > m_iInputStationOfDevStatus - 1 ,
psLinkParam - > m_iInputStartPntOfDevStatus + iDevNo ,
( void * ) & pntmsg , DI_PNT_TYPE , PNT_STATUS ) ;
}
}
//===========================<3D> <> <EFBFBD> <EFBFBD> Ϊװ<CEAA> ó<EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> =====================
//********************************************************************
//* <20> <> ʼ <EFBFBD> <CABC> װ<EFBFBD> ò<EFBFBD> <C3B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> DEVPARAMDEF *psDevParam : װ<> ò<EFBFBD> <C3B2> <EFBFBD> ָ<EFBFBD> <D6B8> *
//********************************************************************
void InitDevParam ( DEVPARAMDEF * psDevParam )
{
psDevParam - > m_u8SCN = 0 ;
psDevParam - > m_sSyncTimeInfo . m_u8Fun = 255 ;
psDevParam - > m_u8CPUNo = 1 ;
psDevParam - > m_u8FixNo = 1 ;
}
//********************************************************************
//* <20> <> ȡģ<C8A1> <C4A3> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> int commid : <20> ˿ں<CBBF> *
//* char *ptrTemplate : ģ<> <C4A3> <EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> *
//* BUBAN103LINKDEF *psLink : Ҫ<> <D2AA> <EFBFBD> ö˿ڵIJ<DAB5> <C4B2> <EFBFBD> ָ<EFBFBD> <D6B8> *
//********************************************************************
BOOL InitBuban103InfoFromTempletFile ( int commid ,
char * ptrTemplate ,
BUBAN103LINKDEF * psLink )
{
int i ;
char * ptr ;
char szBuf [ 512 ] ;
BOOL bVal ;
HDSFILE hFile ;
enum Param_Type ParamType ;
hFile = DSOpenFileEx ( ptrTemplate ) ;
if ( hFile = = NULL )
{
// test
sprintf ( szBuf , " open<%s> is failed. " , ptrTemplate ) ;
DebugPrint ( szBuf ) ;
return FALSE ;
}
// test
sprintf ( szBuf , " open<%s> is succeed. " , ptrTemplate ) ;
DebugPrint ( szBuf ) ;
ParamType = PARAM_NO ;
while ( TRUE )
{
ptr = DSfgets ( szBuf , sizeof ( szBuf ) , hFile ) ;
if ( ! ptr )
{
break ;
}
// test
//DebugPrint(szBuf);
if ( strstr ( ptr , " <EFBFBD> <EFBFBD> ·<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ! = NULL )
{
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD>
ParamType = PARAM_LINK ;
}
else if ( strstr ( ptr , " <EFBFBD> 豸<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ! = NULL )
{
ParamType = PARAM_DEV ;
}
else if ( PARAM_NO = = ParamType )
{
continue ;
}
switch ( ParamType )
{
case PARAM_LINK :
bVal = GetLinkParamFromTemplateFile ( commid , hFile , psLink ) ;
if ( TRUE = = bVal )
{
if ( psLink - > m_iDevNum > 0 )
{
psLink - > m_psDev = ( DEVDEF * ) HEAP_MALLOC ( psLink - > m_iDevNum * sizeof ( DEVDEF ) ) ;
Buban103DispMalloc ( commid , psLink - > m_iDevNum * sizeof ( DEVDEF ) ) ;
if ( psLink - > m_psDev = = NULL )
{
psLink - > m_iDevNum = 0 ;
}
memset ( ( void * ) psLink - > m_psDev , 0 , psLink - > m_iDevNum * sizeof ( DEVDEF ) ) ;
if ( psLink - > m_uchLinkAddr = = 0xFF )
{
psLink - > m_pbLinkOk = ( BOOL * ) HEAP_MALLOC ( psLink - > m_iDevNum * sizeof ( BOOL ) ) ;
memset ( ( void * ) psLink - > m_pbLinkOk , 0 , psLink - > m_iDevNum * sizeof ( BOOL ) ) ;
Buban103DispMalloc ( commid , psLink - > m_iDevNum * sizeof ( BOOL ) ) ;
psLink - > m_pu32LinkOkCnt = ( u_32 * ) HEAP_MALLOC ( psLink - > m_iDevNum * sizeof ( u_32 ) ) ;
memset ( ( void * ) psLink - > m_pu32LinkOkCnt , 0 , psLink - > m_iDevNum * sizeof ( u_32 ) ) ;
Buban103DispMalloc ( commid , psLink - > m_iDevNum * sizeof ( u_32 ) ) ;
psLink - > m_pu8CtlByte = ( BYTE * ) HEAP_MALLOC ( psLink - > m_iDevNum * sizeof ( u_char ) ) ;
memset ( psLink - > m_pu8CtlByte , 0 , psLink - > m_iDevNum * sizeof ( u_char ) ) ;
Buban103DispMalloc ( commid , psLink - > m_iDevNum * sizeof ( u_char ) ) ;
}
else
{
psLink - > m_pbLinkOk = ( BOOL * ) HEAP_MALLOC ( sizeof ( BOOL ) ) ;
psLink - > m_pbLinkOk [ 0 ] = FALSE ;
Buban103DispMalloc ( commid , sizeof ( BOOL ) ) ;
psLink - > m_pu32LinkOkCnt = ( u_32 * ) HEAP_MALLOC ( sizeof ( u_32 ) ) ;
psLink - > m_pu32LinkOkCnt [ 0 ] = 0 ;
Buban103DispMalloc ( commid , sizeof ( u_32 ) ) ;
psLink - > m_pu8CtlByte = ( BYTE * ) HEAP_MALLOC ( sizeof ( u_char ) ) ;
psLink - > m_pu8CtlByte [ 0 ] = 0 ;
Buban103DispMalloc ( commid , sizeof ( u_char ) ) ;
}
for ( i = 0 ; i < psLink - > m_iDevNum ; i + + )
{
InitDevParam ( & psLink - > m_psDev [ i ] . m_sDevParam ) ;
}
}
}
break ;
case PARAM_DEV :
bVal = GetDevParamFromTemplateFile ( commid , hFile , psLink ) ;
break ;
default :
break ;
}
}
DSCloseFile ( hFile ) ;
return TRUE ;
}
BOOL InitBuban103InfoFromTempletFileEx ( int commid ,
char * ptrTemplate ,
BUBAN103LINKDEF * psLink ,
BOOL bMaster )
{
char * ptr ;
char szBuf [ 512 ] ;
BOOL bVal ;
HDSFILE hFile ;
enum Param_Type ParamType ;
if ( bMaster = = TRUE )
{
return InitBuban103InfoFromTempletFile ( commid , ptrTemplate , psLink ) ;
}
hFile = DSOpenFile ( ptrTemplate ) ;
if ( hFile = = NULL )
{
// test
sprintf ( szBuf , " open<%s> is failed. " , ptrTemplate ) ;
DebugPrint ( szBuf ) ;
return FALSE ;
}
// test
sprintf ( szBuf , " open<%s> is succeed. " , ptrTemplate ) ;
DebugPrint ( szBuf ) ;
ParamType = PARAM_NO ;
while ( TRUE )
{
ptr = DSfgets ( szBuf , sizeof ( szBuf ) , hFile ) ;
if ( ! ptr )
{
break ;
}
// test
//DebugPrint(szBuf);
if ( strstr ( ptr , " <EFBFBD> <EFBFBD> ·<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ! = NULL )
{
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD>
ParamType = PARAM_LINK ;
}
else if ( strstr ( ptr , " <EFBFBD> 豸<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ! = NULL )
{
ParamType = PARAM_DEV ;
}
else if ( PARAM_NO = = ParamType )
{
continue ;
}
switch ( ParamType )
{
case PARAM_LINK :
bVal = GetLinkParamFromTemplateFile ( commid , hFile , psLink ) ;
if ( TRUE = = bVal )
{
if ( psLink - > m_iDevNum > 0 )
{
psLink - > m_psProvDev = ( PROVDEVDEF * ) HEAP_MALLOC ( psLink - > m_iDevNum * sizeof ( PROVDEVDEF ) ) ;
if ( psLink - > m_psProvDev = = NULL )
{
psLink - > m_iDevNum = 0 ;
}
memset ( ( void * ) psLink - > m_psProvDev , 0 , psLink - > m_iDevNum * sizeof ( PROVDEVDEF ) ) ;
Buban103DispMalloc ( commid , psLink - > m_iDevNum * sizeof ( PROVDEVDEF ) ) ;
if ( psLink - > m_uchLinkAddr = = 0xFF )
{
psLink - > m_pbLinkOk = ( BOOL * ) HEAP_MALLOC ( psLink - > m_iDevNum * sizeof ( BOOL ) ) ;
memset ( ( void * ) psLink - > m_pbLinkOk , 0 , psLink - > m_iDevNum * sizeof ( BOOL ) ) ;
Buban103DispMalloc ( commid , psLink - > m_iDevNum * sizeof ( BOOL ) ) ;
psLink - > m_pu32LinkOkCnt = ( u_32 * ) HEAP_MALLOC ( psLink - > m_iDevNum * sizeof ( u_32 ) ) ;
memset ( ( void * ) psLink - > m_pu32LinkOkCnt , 0 , psLink - > m_iDevNum * sizeof ( u_32 ) ) ;
Buban103DispMalloc ( commid , psLink - > m_iDevNum * sizeof ( u_32 ) ) ;
psLink - > m_pu8CtlByte = ( BYTE * ) HEAP_MALLOC ( psLink - > m_iDevNum * sizeof ( u_char ) ) ;
memset ( psLink - > m_pu8CtlByte , 0 , psLink - > m_iDevNum * sizeof ( u_char ) ) ;
Buban103DispMalloc ( commid , psLink - > m_iDevNum * sizeof ( u_char ) ) ;
}
else
{
psLink - > m_pbLinkOk = ( BOOL * ) HEAP_MALLOC ( sizeof ( BOOL ) ) ;
psLink - > m_pbLinkOk [ 0 ] = FALSE ;
Buban103DispMalloc ( commid , sizeof ( BOOL ) ) ;
psLink - > m_pu32LinkOkCnt = ( u_32 * ) HEAP_MALLOC ( sizeof ( u_32 ) ) ;
psLink - > m_pu32LinkOkCnt [ 0 ] = 0 ;
Buban103DispMalloc ( commid , sizeof ( u_32 ) ) ;
psLink - > m_pu8CtlByte = ( BYTE * ) HEAP_MALLOC ( sizeof ( u_char ) ) ;
psLink - > m_pu8CtlByte [ 0 ] = 0 ;
Buban103DispMalloc ( commid , sizeof ( u_char ) ) ;
}
}
}
break ;
case PARAM_DEV :
bVal = GetProvDevParamFromTemplateFile ( commid , hFile , psLink ) ;
break ;
default :
break ;
}
}
DSCloseFile ( hFile ) ;
return TRUE ;
}
BOOL GetParamItem ( char * pSour , char * * ppDest )
{
if ( pSour = = NULL )
{
return FALSE ;
}
* ppDest = strstr ( pSour , " , " ) ;
if ( * ppDest = = NULL )
{
return FALSE ;
}
return TRUE ;
}
BOOL GetParamItemEx ( char * pSour , char * * ppDest , const char * pSplit )
{
if ( pSour = = NULL )
{
return FALSE ;
}
* ppDest = strstr ( pSour , pSplit ) ;
if ( * ppDest = = NULL )
{
return FALSE ;
}
return TRUE ;
}
BOOL GetLinkParamFromTemplateFile ( int commid , HDSFILE hFile , \
BUBAN103LINKDEF * psLink )
{
char * ptr , * ptrSour , * ptrDest ;
char szBuf [ 512 ] ;
int i , ilen ;
BOOL bRetVal ;
ptr = DSfgets ( szBuf , sizeof ( szBuf ) , hFile ) ;
if ( ptr = = NULL )
{
return FALSE ;
}
ptrSour = szBuf ;
if ( strstr ( ptrSour , " LINK " ) = = NULL )
{
return FALSE ;
}
// test
//DebugPrint(szBuf);
bRetVal = TRUE ;
for ( i = 0 ; i < 13 ; i + + )
{
if ( GetParamItem ( ptrSour , & ptrDest ) = = FALSE )
{
bRetVal = FALSE ;
break ;
}
* ptrDest = 0 ;
ilen = strlen ( ptrSour ) ;
switch ( i )
{
case 0 : // <20> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD>
if ( ilen > 0 )
{
if ( ilen > = sizeof ( psLink - > m_szLinkName ) )
{
ilen = sizeof ( psLink - > m_szLinkName ) - 1 ;
}
memcpy ( psLink - > m_szLinkName , ptrSour , ilen ) ;
psLink - > m_szLinkName [ ilen ] = 0 ;
}
break ;
case 1 : // <20> <> ·<EFBFBD> <C2B7> ʶ
break ;
case 2 : // <20> <> ·<EFBFBD> <C2B7> ַ
if ( ilen > 0 )
{
psLink - > m_uchLinkAddr = ( BYTE ) atoi ( ptrSour ) ;
}
else
{
psLink - > m_uchLinkAddr = 255 ;
}
break ;
case 3 : // װ<> <D7B0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ilen > 0 )
{
psLink - > m_iDevNum = ( BYTE ) atoi ( ptrSour ) ;
}
break ;
case 4 : // <20> <> <EFBFBD> <EFBFBD>
break ;
case 5 : // <20> <> <EFBFBD> <EFBFBD>
break ;
case 6 : // <20> <> ַƫ<D6B7> <C6AB>
if ( ilen > 0 )
{
psLink - > m_iProvAddrOffset = atoi ( ptrSour ) ;
}
break ;
case 7 : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
break ;
case 8 : // д<> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> վ<EFBFBD> <D5BE>
if ( ilen > 0 )
{
psLink - > m_iInputStationOfDevStatus = atoi ( ptrSour ) ;
}
break ;
case 9 : // д<> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> <DDBF> <EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD>
if ( ilen > 0 )
{
psLink - > m_iInputStartPntOfDevStatus = atoi ( ptrSour ) ;
}
break ;
case 10 : // <20> Ƿ<EFBFBD> <C7B7> ж<EFBFBD> ASDU<44> <55>
if ( ilen > 0 )
{
psLink - > m_iJudgeAsduNo = atoi ( ptrSour ) ;
}
break ;
case 11 : // <20> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ilen > 0 )
{
psLink - > m_iDisTransDataProcess = atoi ( ptrSour ) ;
}
break ;
case 12 : // <20> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> <EFBFBD> δ<EFBFBD> <CEB4> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD>
if ( ilen > 0 )
{
psLink - > m_iMaskNoMatchString = atoi ( ptrSour ) ;
}
break ;
case 13 : // һ <> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> ɴ<C9B4> <EFA3AC> ѭ<EFBFBD> <D1AD> <EFBFBD> <EFBFBD> <E2B4A6> )
if ( ilen > 0 )
{
psLink - > m_iQueryNum_CLASS1_Const = atoi ( ptrSour ) ;
}
else
{
psLink - > m_iQueryNum_CLASS1_Const = 1 ;
}
break ;
}
ptrSour = ptrDest + 1 ;
}
// <20> <> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB>
if ( bRetVal = = TRUE )
{
// һ <> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD>
if ( strlen ( ptrSour ) > 0 )
{
psLink - > m_iQueryNum_CLASS1_Const = atoi ( ptrSour ) ;
}
else
{
psLink - > m_iQueryNum_CLASS1_Const = 1 ;
}
}
return bRetVal ;
}
BOOL GetDevParamFromTemplateFile ( int commid , HDSFILE hFile , \
BUBAN103LINKDEF * psLink )
{
char * ptr , * ptrSour , * ptrDest ;
char szBuf [ 512 ] ;
int i , j , ilen , iNum ;
int iAiNum , iAiStart , iDiStart ;
int iPiStart , iYkStart , iPntNo ;
BOOL bRetVal ;
enum Param_Type ParamType ;
iAiStart = 0 ;
iDiStart = 0 ;
iPiStart = 0 ;
iYkStart = 0 ;
iAiNum = 0 ;
ParamType = PARAM_NO ;
bRetVal = TRUE ;
for ( i = 0 ; i < psLink - > m_iDevNum ; )
{
ptr = DSfgets ( szBuf , sizeof ( szBuf ) , hFile ) ;
if ( ptr = = NULL )
{
break ;
}
// test
//DebugPrint(szBuf);
if ( strstr ( ptr , " <EFBFBD> 豸<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ! = NULL )
{
i + + ;
iAiNum = 0 ;
ParamType = PARAM_NO ;
continue ;
}
if ( strstr ( ptr , " <EFBFBD> <EFBFBD> ·<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ! = NULL )
{
break ;
}
ptrSour = ptr ;
for ( j = 0 ; j < 8 ; j + + )
{
if ( GetParamItem ( ptrSour , & ptrDest ) = = FALSE )
{
bRetVal = FALSE ;
break ;
}
* ptrDest = 0 ;
ilen = strlen ( ptrSour ) ;
switch ( j )
{
case 0 : // <20> 豸<EFBFBD> <E8B1B8> <EFBFBD> <EFBFBD>
if ( ParamType ! = PARAM_NO )
{
break ;
}
if ( ilen > 0 )
{
if ( ilen > = sizeof ( psLink - > m_psDev [ i ] . m_sDevParam . m_szDevName ) )
{
ilen = sizeof ( psLink - > m_psDev [ i ] . m_sDevParam . m_szDevName ) - 1 ;
}
memcpy ( psLink - > m_psDev [ i ] . m_sDevParam . m_szDevName , ptrSour , ilen ) ;
psLink - > m_psDev [ i ] . m_sDevParam . m_szDevName [ ilen ] = 0 ;
}
break ;
case 1 : // <20> 豸<EFBFBD> ͺ <EFBFBD>
if ( ParamType ! = PARAM_NO )
{
break ;
}
if ( ilen > 0 )
{
if ( ilen > = sizeof ( psLink - > m_psDev [ i ] . m_sDevParam . m_szType ) )
{
ilen = sizeof ( psLink - > m_psDev [ i ] . m_sDevParam . m_szType ) - 1 ;
}
memcpy ( psLink - > m_psDev [ i ] . m_sDevParam . m_szType , ptrSour , ilen ) ;
psLink - > m_psDev [ i ] . m_sDevParam . m_szType [ ilen ] = 0 ;
}
else
{
strcpy ( psLink - > m_psDev [ i ] . m_sDevParam . m_szType , " dat103 " ) ;
}
break ;
case 2 : // <20> 豸<EFBFBD> <E8B1B8> ַ
if ( ParamType ! = PARAM_NO )
{
break ;
}
if ( ilen > 0 )
{
psLink - > m_psDev [ i ] . m_sDevParam . m_u8DevAddr = ( BYTE ) atoi ( ptrSour ) ;
}
break ;
case 3 : // ת<> <D7AA> <EFBFBD> <EFBFBD> ַ
if ( PARAM_NO ! = ParamType )
{
break ;
}
if ( ilen > 0 )
{
psLink - > m_psDev [ i ] . m_sDevParam . m_iProvAddr = atoi ( ptrSour ) ;
}
break ;
case 4 : // <20> <> <EFBFBD> <EFBFBD>
break ;
case 5 : // <20> <> <EFBFBD> <EFBFBD>
break ;
case 6 : // <20> <> <EFBFBD> <EFBFBD>
if ( ilen > 0 )
{
iNum = atoi ( ptrSour ) ;
}
break ;
case 7 : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( iNum < = 0 )
{
break ;
}
if ( ilen > 0 )
{
if ( strcmp ( ptrSour , " YC " ) = = 0 )
{
ParamType = PARAM_YC ;
psLink - > m_psDev [ i ] . m_sDevParam . m_sAiDBOrientation [ iAiNum ] . m_iStnNo = commid + 1 ;
psLink - > m_psDev [ i ] . m_sDevParam . m_sAiDBOrientation [ iAiNum ] . m_iStartPntNo = iAiStart ;
psLink - > m_psDev [ i ] . m_sDevParam . m_sAiDBOrientation [ iAiNum ] . m_iPntNum = iNum ;
if ( NULL ! = psLink - > m_psDev [ i ] . m_sDevParam . m_sAiDBOrientation [ iAiNum ] . m_psDataInfo )
{
HEAP_FREE ( psLink - > m_psDev [ i ] . m_sDevParam . m_sAiDBOrientation [ iAiNum ] . m_psDataInfo ) ;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//psLink->m_psDev[i].m_sDevParam.m_sAiDBOrientation[iAiNum].m_psDataInfo
// = (DBINFO *)HEAP_MALLOC(sizeof(DBINFO)*iNum);
//memset((void *)psLink->m_psDev[i].m_sDevParam.m_sAiDBOrientation[iAiNum].m_psDataInfo,
// 0, sizeof(DBINFO)*iNum);
//========================================================================================
psLink - > m_psDev [ i ] . m_sDevParam . m_sAiDBOrientation [ iAiNum ] . m_psDataInfo
= ( DBINFO * ) HEAP_MALLOC ( sizeof ( DBINFO ) ) ;
memset ( ( void * ) psLink - > m_psDev [ i ] . m_sDevParam . m_sAiDBOrientation [ iAiNum ] . m_psDataInfo ,
0 , sizeof ( DBINFO ) ) ;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Buban103DispMalloc ( commid , sizeof ( DBINFO ) * iNum ) ;
iAiStart + = iNum ;
iAiNum + + ;
iPntNo = 0 ;
}
else if ( strcmp ( ptrSour , " YX " ) = = 0 )
{
ParamType = PARAM_YX ;
psLink - > m_psDev [ i ] . m_sDevParam . m_sDiDBOrientation . m_iStnNo = commid + 1 ;
psLink - > m_psDev [ i ] . m_sDevParam . m_sDiDBOrientation . m_iStartPntNo = iDiStart ;
psLink - > m_psDev [ i ] . m_sDevParam . m_sDiDBOrientation . m_iPntNum = iNum ;
if ( NULL ! = psLink - > m_psDev [ i ] . m_sDevParam . m_sDiDBOrientation . m_psDataInfo )
{
HEAP_FREE ( psLink - > m_psDev [ i ] . m_sDevParam . m_sDiDBOrientation . m_psDataInfo ) ;
}
psLink - > m_psDev [ i ] . m_sDevParam . m_sDiDBOrientation . m_psDataInfo
= ( DBINFO * ) HEAP_MALLOC ( sizeof ( DBINFO ) * iNum ) ;
memset ( ( void * ) psLink - > m_psDev [ i ] . m_sDevParam . m_sDiDBOrientation . m_psDataInfo ,
0 , sizeof ( DBINFO ) * iNum ) ;
Buban103DispMalloc ( commid , sizeof ( DBINFO ) * iNum ) ;
iDiStart + = iNum ;
iPntNo = 0 ;
}
else if ( strcmp ( ptrSour , " YM " ) = = 0 )
{
ParamType = PARAM_YM ;
psLink - > m_psDev [ i ] . m_sDevParam . m_sPiDBOrientation . m_iStnNo = commid + 1 ;
psLink - > m_psDev [ i ] . m_sDevParam . m_sPiDBOrientation . m_iStartPntNo = iPiStart ;
psLink - > m_psDev [ i ] . m_sDevParam . m_sPiDBOrientation . m_iPntNum = iNum ;
if ( NULL ! = psLink - > m_psDev [ i ] . m_sDevParam . m_sPiDBOrientation . m_psDataInfo )
{
HEAP_FREE ( psLink - > m_psDev [ i ] . m_sDevParam . m_sPiDBOrientation . m_psDataInfo ) ;
}
psLink - > m_psDev [ i ] . m_sDevParam . m_sPiDBOrientation . m_psDataInfo
= ( DBINFO * ) HEAP_MALLOC ( sizeof ( DBINFO ) * iNum ) ;
memset ( ( void * ) psLink - > m_psDev [ i ] . m_sDevParam . m_sPiDBOrientation . m_psDataInfo ,
0 , sizeof ( DBINFO ) * iNum ) ;
Buban103DispMalloc ( commid , sizeof ( DBINFO ) * iNum ) ;
iPiStart + = iNum ;
iPntNo = 0 ;
}
else if ( strcmp ( ptrSour , " YK " ) = = 0 )
{
ParamType = PARAM_YK ;
psLink - > m_psDev [ i ] . m_sDevParam . m_sYkDBOrientation . m_iStnNo = commid + 1 ;
psLink - > m_psDev [ i ] . m_sDevParam . m_sYkDBOrientation . m_iStartPntNo = iYkStart ;
psLink - > m_psDev [ i ] . m_sDevParam . m_sYkDBOrientation . m_iPntNum = iNum ;
if ( NULL ! = psLink - > m_psDev [ i ] . m_sDevParam . m_sYkDBOrientation . m_psDataInfo )
{
HEAP_FREE ( psLink - > m_psDev [ i ] . m_sDevParam . m_sYkDBOrientation . m_psDataInfo ) ;
}
psLink - > m_psDev [ i ] . m_sDevParam . m_sYkDBOrientation . m_psDataInfo
= ( DBINFO * ) HEAP_MALLOC ( sizeof ( DBINFO ) * iNum ) ;
memset ( ( void * ) psLink - > m_psDev [ i ] . m_sDevParam . m_sYkDBOrientation . m_psDataInfo ,
0 , sizeof ( DBINFO ) * iNum ) ;
Buban103DispMalloc ( commid , sizeof ( DBINFO ) * iNum ) ;
iYkStart + = iNum ;
iPntNo = 0 ;
}
else if ( strcmp ( ptrSour , " SYNCTIME " ) = = 0 )
{
ParamType = PARAM_SYNCTIME ;
iPntNo = 0 ;
}
else if ( strcmp ( ptrSour , " ASDU10 " ) = = 0 )
{
ParamType = PARAM_ASDU10 ;
psLink - > m_psDev [ i ] . m_sDevParam . m_iCfgGroupNum = iNum ;
iPntNo = 0 ;
}
}
break ;
default :
break ;
}
ptrSour = ptrDest + 1 ;
}
switch ( ParamType )
{
case PARAM_YC :
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//if(TRUE == GetInfoData(ptrSour, iPntNo,
// (DBORIENTATION *)(&psLink->m_psDev[i].m_sDevParam.m_sAiDBOrientation)))
//{
// iPntNo++;
//}
//===============================================================================================
if ( iAiNum > 0 )
{
GetInfoData ( ptrSour , 0 , ( DBORIENTATION * ) ( & psLink - > m_psDev [ i ] . m_sDevParam . m_sAiDBOrientation [ iAiNum - 1 ] ) ) ;
}
else
{
GetInfoData ( ptrSour , 0 , ( DBORIENTATION * ) ( & psLink - > m_psDev [ i ] . m_sDevParam . m_sAiDBOrientation [ 0 ] ) ) ;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
break ;
case PARAM_YX :
if ( TRUE = = GetInfoData ( ptrSour , iPntNo ,
& psLink - > m_psDev [ i ] . m_sDevParam . m_sDiDBOrientation ) )
{
iPntNo + + ;
}
break ;
case PARAM_YM :
if ( TRUE = = GetInfoData ( ptrSour , iPntNo ,
& psLink - > m_psDev [ i ] . m_sDevParam . m_sPiDBOrientation ) )
{
iPntNo + + ;
}
break ;
case PARAM_YK :
if ( TRUE = = GetInfoData ( ptrSour , iPntNo ,
& psLink - > m_psDev [ i ] . m_sDevParam . m_sYkDBOrientation ) )
{
iPntNo + + ;
}
break ;
case PARAM_SYNCTIME :
GetSyncTimeInfoData ( ptrSour , & psLink - > m_psDev [ i ] . m_sDevParam . m_sSyncTimeInfo ) ;
break ;
case PARAM_ASDU10 :
if ( TRUE = = GetGroupInfoData ( ptrSour , iPntNo , & psLink - > m_psDev [ i ] . m_sDevParam ) )
{
iPntNo + + ;
}
break ;
default :
break ;
}
}
return bRetVal ;
}
BOOL GetProvDevParamFromTemplateFile ( int commid , HDSFILE hFile , \
BUBAN103LINKDEF * psLink )
{
char * ptr , * ptrSour , * ptrDest ;
char szBuf [ 512 ] ;
int i , j , ilen , iNum ;
int iAiNum , iAiStart , iDiStart ;
int iPiStart , iYkStart , iPntNo ;
BOOL bRetVal ;
enum Param_Type ParamType ;
iAiStart = 0 ;
iDiStart = 0 ;
iPiStart = 0 ;
iYkStart = 0 ;
iAiNum = 0 ;
ParamType = PARAM_NO ;
bRetVal = TRUE ;
for ( i = 0 ; i < psLink - > m_iDevNum ; )
{
ptr = DSfgets ( szBuf , sizeof ( szBuf ) , hFile ) ;
if ( ptr = = NULL )
{
break ;
}
// test
//DebugPrint(szBuf);
if ( strstr ( ptr , " <EFBFBD> 豸<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ! = NULL )
{
i + + ;
iAiNum = 0 ;
ParamType = PARAM_NO ;
continue ;
}
if ( strstr ( ptr , " <EFBFBD> <EFBFBD> ·<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ! = NULL )
{
break ;
}
ptrSour = ptr ;
for ( j = 0 ; j < 8 ; j + + )
{
if ( GetParamItem ( ptrSour , & ptrDest ) = = FALSE )
{
bRetVal = FALSE ;
break ;
}
* ptrDest = 0 ;
ilen = strlen ( ptrSour ) ;
switch ( j )
{
case 0 : // <20> 豸<EFBFBD> <E8B1B8> <EFBFBD> <EFBFBD>
break ;
case 1 : // <20> 豸<EFBFBD> ͺ <EFBFBD>
break ;
case 2 : // <20> 豸<EFBFBD> <E8B1B8> ַ
break ;
case 3 : // ת<> <D7AA> <EFBFBD> <EFBFBD> ַ
if ( PARAM_NO ! = ParamType )
{
break ;
}
if ( ilen > 0 )
{
psLink - > m_psProvDev [ i ] . m_iProvAddr = atoi ( ptrSour ) ;
}
break ;
case 4 : // <20> ˿ں<CBBF> &״̬վ<CCAC> <D5BE> &״̬<D7B4> <CCAC> <EFBFBD> <EFBFBD>
if ( PARAM_NO ! = ParamType )
{
break ;
}
if ( ilen > 0 )
{
psLink - > m_psProvDev [ i ] . m_iRealCommid = atoi ( ptrSour ) ;
if ( GetParamItemEx ( ptrSour , & ptrDest , " & " ) = = FALSE )
{
psLink - > m_psProvDev [ i ] . m_iStatusStn = 0 ;
psLink - > m_psProvDev [ i ] . m_iStatusPnt = 0 ;
break ;
}
ptrSour = ptrDest + 1 ;
if ( strlen ( ptrSour ) > 0 )
{
psLink - > m_psProvDev [ i ] . m_iStatusStn = atoi ( ptrSour ) ;
if ( GetParamItemEx ( ptrSour , & ptrDest , " & " ) = = FALSE )
{
psLink - > m_psProvDev [ i ] . m_iStatusStn = 0 ;
psLink - > m_psProvDev [ i ] . m_iStatusPnt = 0 ;
break ;
}
ptrSour = ptrDest + 1 ;
if ( strlen ( ptrSour ) > 0 )
{
psLink - > m_psProvDev [ i ] . m_iStatusPnt = atoi ( ptrSour ) ;
}
}
}
break ;
case 5 : // <20> <> <EFBFBD> <EFBFBD>
break ;
case 6 : // <20> <> <EFBFBD> <EFBFBD>
if ( ilen > 0 )
{
iNum = atoi ( ptrSour ) ;
}
break ;
case 7 : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( iNum < = 0 )
{
break ;
}
if ( ilen > 0 )
{
if ( strcmp ( ptrSour , " YC " ) = = 0 )
{
ParamType = PARAM_YC ;
psLink - > m_psProvDev [ i ] . m_sYcInfo . m_iPntNum = iNum ;
psLink - > m_psProvDev [ i ] . m_sYcInfo . m_iStartPntNo = 0 ;
psLink - > m_psProvDev [ i ] . m_sYcInfo . m_iStnNo = 0 ;
psLink - > m_psProvDev [ i ] . m_sYcInfo . m_psDataInfo = NULL ;
iPntNo = 0 ;
}
else if ( strcmp ( ptrSour , " YX " ) = = 0 )
{
ParamType = PARAM_YX ;
psLink - > m_psProvDev [ i ] . m_sYxInfo . m_iPntNum = iNum ;
psLink - > m_psProvDev [ i ] . m_sYxInfo . m_iStartPntNo = 0 ;
psLink - > m_psProvDev [ i ] . m_sYxInfo . m_iStnNo = 0 ;
if ( NULL ! = psLink - > m_psProvDev [ i ] . m_sYxInfo . m_psDataInfo )
{
HEAP_FREE ( psLink - > m_psProvDev [ i ] . m_sYxInfo . m_psDataInfo ) ;
}
psLink - > m_psProvDev [ i ] . m_sYxInfo . m_psDataInfo
= ( DBINFO * ) HEAP_MALLOC ( sizeof ( DBINFO ) * iNum ) ;
memset ( ( void * ) psLink - > m_psProvDev [ i ] . m_sYxInfo . m_psDataInfo ,
0 , sizeof ( DBINFO ) * iNum ) ;
Buban103DispMalloc ( commid , sizeof ( DBINFO ) * iNum ) ;
iPntNo = 0 ;
}
else if ( strcmp ( ptrSour , " YM " ) = = 0 )
{
ParamType = PARAM_YM ;
psLink - > m_psProvDev [ i ] . m_sYmInfo . m_iPntNum = iNum ;
psLink - > m_psProvDev [ i ] . m_sYmInfo . m_iStartPntNo = 0 ;
psLink - > m_psProvDev [ i ] . m_sYmInfo . m_iStnNo = 0 ;
psLink - > m_psProvDev [ i ] . m_sYmInfo . m_psDataInfo = NULL ;
iPntNo = 0 ;
}
else if ( strcmp ( ptrSour , " YK " ) = = 0 )
{
ParamType = PARAM_YK ;
iPntNo = 0 ;
}
else if ( strcmp ( ptrSour , " SYNCTIME " ) = = 0 )
{
ParamType = PARAM_SYNCTIME ;
iPntNo = 0 ;
}
else if ( strcmp ( ptrSour , " ASDU10 " ) = = 0 )
{
ParamType = PARAM_ASDU10 ;
psLink - > m_psProvDev [ i ] . m_iAsdu10Num = iNum ;
iPntNo = 0 ;
}
}
break ;
default :
break ;
}
ptrSour = ptrDest + 1 ;
}
switch ( ParamType )
{
case PARAM_YC :
break ;
case PARAM_YX :
if ( TRUE = = GetInfoData ( ptrSour , iPntNo ,
& psLink - > m_psProvDev [ i ] . m_sYxInfo ) )
{
iPntNo + + ;
}
break ;
case PARAM_YM :
break ;
case PARAM_YK :
break ;
case PARAM_SYNCTIME :
break ;
case PARAM_ASDU10 :
break ;
default :
break ;
}
}
return bRetVal ;
}
BOOL GetInfoData ( char * pInfo , int iPntNo , DBORIENTATION * psDB )
{
int i ;
char * ptr1 , * ptr2 ;
BOOL bRetVal ;
if ( pInfo = = NULL )
{
return FALSE ;
}
if ( iPntNo > = psDB - > m_iPntNum )
{
return FALSE ;
}
if ( psDB - > m_psDataInfo = = NULL )
{
return FALSE ;
}
bRetVal = TRUE ;
ptr1 = pInfo ;
for ( i = 0 ; i < 6 ; i + + )
{
if ( GetParamItem ( ptr1 , & ptr2 ) = = FALSE )
{
//bRetVal = FALSE;
break ;
}
* ptr2 = 0 ;
switch ( i )
{
case 0 : // <20> <> <EFBFBD> <EFBFBD>
break ;
case 1 : // ASDU
if ( strlen ( ptr1 ) > 0 )
{
psDB - > m_psDataInfo [ iPntNo ] . m_u8Asdu = atoi ( ptr1 ) ;
}
break ;
case 2 : // FUN
if ( strlen ( ptr1 ) > 0 )
{
psDB - > m_psDataInfo [ iPntNo ] . m_u8Fun = atoi ( ptr1 ) ;
}
break ;
case 3 : // INF
if ( strlen ( ptr1 ) > 0 )
{
psDB - > m_psDataInfo [ iPntNo ] . m_u8Inf = atoi ( ptr1 ) ;
}
break ;
case 4 : // PROV_FUN
if ( strlen ( ptr1 ) > 0 )
{
psDB - > m_psDataInfo [ iPntNo ] . m_u8ProvFun = atoi ( ptr1 ) ;
}
else
{
psDB - > m_psDataInfo [ iPntNo ] . m_u8ProvFun \
= ( u_char ) psDB - > m_psDataInfo [ iPntNo ] . m_u8Fun ;
}
break ;
case 5 : // PROV_INF
if ( strlen ( ptr1 ) > 0 )
{
psDB - > m_psDataInfo [ iPntNo ] . m_u8ProvInf = atoi ( ptr1 ) ;
}
else
{
psDB - > m_psDataInfo [ iPntNo ] . m_u8ProvInf \
= ( u_char ) psDB - > m_psDataInfo [ iPntNo ] . m_u8Inf ;
}
break ;
case 6 : //<2F> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD>
if ( strlen ( ptr1 ) > 0 )
{
psDB - > m_psDataInfo [ iPntNo ] . m_u8LoopData = atoi ( ptr1 ) ;
}
else
{
psDB - > m_psDataInfo [ iPntNo ] . m_u8LoopData = 0 ;
}
break ;
default :
bRetVal = FALSE ;
break ;
}
ptr1 = ptr2 + 1 ;
}
// INF
if ( strlen ( ptr1 ) > 0 )
{
switch ( i )
{
case 3 : // INF
psDB - > m_psDataInfo [ iPntNo ] . m_u8Inf = atoi ( ptr1 ) ;
psDB - > m_psDataInfo [ iPntNo ] . m_u8ProvFun \
= ( u_char ) psDB - > m_psDataInfo [ iPntNo ] . m_u8Fun ;
psDB - > m_psDataInfo [ iPntNo ] . m_u8ProvInf \
= ( u_char ) psDB - > m_psDataInfo [ iPntNo ] . m_u8Inf ;
psDB - > m_psDataInfo [ iPntNo ] . m_u8LoopData = 0 ;
break ;
case 4 : // PROV_FUN
psDB - > m_psDataInfo [ iPntNo ] . m_u8ProvFun = atoi ( ptr1 ) ;
psDB - > m_psDataInfo [ iPntNo ] . m_u8ProvInf \
= ( u_char ) psDB - > m_psDataInfo [ iPntNo ] . m_u8Inf ;
psDB - > m_psDataInfo [ iPntNo ] . m_u8LoopData = 0 ;
break ;
case 5 : // PROV_INF
psDB - > m_psDataInfo [ iPntNo ] . m_u8ProvInf = atoi ( ptr1 ) ;
psDB - > m_psDataInfo [ iPntNo ] . m_u8LoopData = 0 ;
break ;
case 6 : //<2F> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD>
psDB - > m_psDataInfo [ iPntNo ] . m_u8LoopData = atoi ( ptr1 ) ;
break ;
default :
if ( i < 6 )
{
bRetVal = FALSE ;
}
break ;
}
}
else
{
switch ( i )
{
case 4 : // PROV_FUN
psDB - > m_psDataInfo [ iPntNo ] . m_u8ProvFun \
= ( u_char ) psDB - > m_psDataInfo [ iPntNo ] . m_u8Fun ;
case 5 : // PROV_INF
psDB - > m_psDataInfo [ iPntNo ] . m_u8ProvInf \
= ( u_char ) psDB - > m_psDataInfo [ iPntNo ] . m_u8Inf ;
case 6 : //<2F> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD>
psDB - > m_psDataInfo [ iPntNo ] . m_u8LoopData = 0 ;
break ;
default :
if ( i < 6 )
{
bRetVal = FALSE ;
}
break ;
}
}
return bRetVal ;
}
BOOL GetSyncTimeInfoData ( char * pInfo , DBINFO * psSyncInfo )
{
int i ;
char * ptr1 , * ptr2 ;
BOOL bRetVal ;
if ( pInfo = = NULL )
{
return FALSE ;
}
if ( psSyncInfo = = NULL )
{
return FALSE ;
}
bRetVal = TRUE ;
ptr1 = pInfo ;
for ( i = 0 ; i < 3 ; i + + )
{
if ( GetParamItem ( ptr1 , & ptr2 ) = = FALSE )
{
bRetVal = FALSE ;
break ;
}
* ptr2 = 0 ;
switch ( i )
{
case 0 : // <20> <> <EFBFBD> <EFBFBD>
break ;
case 1 : // ASDU
if ( strlen ( ptr1 ) > 0 )
{
psSyncInfo - > m_u8Asdu = atoi ( ptr1 ) ;
}
break ;
case 2 : // FUN
if ( strlen ( ptr1 ) > 0 )
{
psSyncInfo - > m_u8Fun = atoi ( ptr1 ) ;
}
break ;
default :
bRetVal = FALSE ;
break ;
}
ptr1 = ptr2 + 1 ;
}
// INF
if ( strlen ( ptr1 ) > 0 )
{
psSyncInfo - > m_u8Inf = atoi ( ptr1 ) ;
}
return bRetVal ;
}
BOOL GetGroupInfoData ( char * pInfo , int iPntNo , DEVPARAMDEF * psDevParam )
{
int i ;
char * ptr1 , * ptr2 ;
BOOL bRetVal ;
if ( pInfo = = NULL )
{
return FALSE ;
}
if ( iPntNo > = psDevParam - > m_iCfgGroupNum )
{
return FALSE ;
}
bRetVal = TRUE ;
ptr1 = pInfo ;
for ( i = 0 ; i < 3 ; i + + )
{
if ( GetParamItem ( ptr1 , & ptr2 ) = = FALSE )
{
bRetVal = FALSE ;
break ;
}
* ptr2 = 0 ;
switch ( i )
{
case 0 : // GROUPNO
if ( strlen ( ptr1 ) > 0 )
{
psDevParam - > m_saGroupDef [ iPntNo ] . m_iGroupNo = atoi ( ptr1 ) ;
}
break ;
case 1 : // DATATYPE
if ( strlen ( ptr1 ) > 0 )
{
psDevParam - > m_saGroupDef [ iPntNo ] . m_iDataType = atoi ( ptr1 ) ;
}
break ;
case 2 : // STN
if ( strlen ( ptr1 ) > 0 )
{
psDevParam - > m_saGroupDef [ iPntNo ] . m_iStationNo = atoi ( ptr1 ) ;
}
break ;
default :
bRetVal = FALSE ;
break ;
}
ptr1 = ptr2 + 1 ;
}
// START_PNT
if ( strlen ( ptr1 ) > 0 )
{
psDevParam - > m_saGroupDef [ iPntNo ] . m_iStartPntNo = atoi ( ptr1 ) ;
}
return bRetVal ;
}
BOOL InitBuban103InfoFromDat ( int commid , BUBAN103LINKDEF * psLink )
{
int i , j , iMallocSize ;
char szDatFile [ 256 ] , szbuf [ 256 ] ;
//char szDbg[256];
char szSection [ 128 ] ;
GROUPDEF * psGroupParam ;
for ( i = 0 ; i < psLink - > m_iDevNum ; i + + )
{
# ifdef OS_LINUX
sprintf ( szDatFile , " dat/%s.dat " ,
psLink - > m_psDev [ i ] . m_sDevParam . m_szType ) ;
# else
sprintf ( szDatFile , " %s \\ dat \\ %s.dat " ,
IniFilePath , psLink - > m_psDev [ i ] . m_sDevParam . m_szType ) ;
# endif
for ( j = 0 ; j < psLink - > m_psDev [ i ] . m_sDevParam . m_iCfgGroupNum ; j + + )
{
psGroupParam = & psLink - > m_psDev [ i ] . m_sDevParam . m_saGroupDef [ j ] ;
//psGroupParam->m_pu8DataLen = NULL;
//psGroupParam->m_pu8DataType = NULL;
//psGroupParam->m_pu8GIN = NULL;
//psGroupParam->m_iPntNum = 0;
psGroupParam - > m_u32CurPntNo = 1 ;
psGroupParam - > m_bInit = FALSE ;
// (ȱʡΪ5<CEAA> <35> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD> 5<EFBFBD> <35> <EFBFBD> <EFBFBD> <EFBFBD> ݰ<EFBFBD> Ϊ<EFBFBD> м<EFBFBD> <D0BC> <EFBFBD> <EFBFBD> ݰ<EFBFBD> )
psGroupParam - > m_iStartItemNo = 5 ;
if ( PROTECT_EVENT_PNT_TYPE = = psGroupParam - > m_iDataType )
{
psGroupParam - > m_psEventInfo = ( GROUPEVENTDEF * ) HEAP_MALLOC ( sizeof ( GROUPEVENTDEF ) ) ;
memset ( ( void * ) psGroupParam - > m_psEventInfo , 0 , sizeof ( GROUPEVENTDEF ) ) ;
Buban103DispMalloc ( commid , sizeof ( GROUPEVENTDEF ) ) ;
//psGroupParam->m_psDataInfo = NULL;
}
else
{
//psGroupParam->m_psEventInfo = NULL;
//psGroupParam->m_psDataInfo = NULL;
sprintf ( szSection , " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> %d" , psGroupParam - > m_iGroupNo ) ;
szbuf [ 0 ] = 0 ;
GetPrivateProString ( szSection , " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " , " 0 " , szbuf , sizeof ( szbuf ) , szDatFile ) ;
//sprintf(szDbg, "[%s]:[<5B> <> <EFBFBD> <EFBFBD> ] = %s\n", szSection, szbuf);
//DebugPrint(szDbg);
psGroupParam - > m_iPntNum = atoi ( szbuf ) ;
if ( psGroupParam - > m_iPntNum > 0 )
{
iMallocSize = psGroupParam - > m_iPntNum * sizeof ( GROUPDATADEF ) ;
psGroupParam - > m_psDataInfo = ( GROUPDATADEF * ) HEAP_MALLOC ( iMallocSize ) ;
memset ( ( void * ) psGroupParam - > m_psDataInfo , 0 , iMallocSize ) ;
Buban103DispMalloc ( commid , iMallocSize ) ;
InitGroupParam ( psGroupParam , szDatFile ) ;
iMallocSize = psGroupParam - > m_iPntNum * sizeof ( BYTE ) ;
psGroupParam - > m_pu8GIN = ( BYTE * ) HEAP_MALLOC ( iMallocSize ) ;
Buban103DispMalloc ( commid , iMallocSize ) ;
if ( PROTECT_FIX_PNT_TYPE = = psGroupParam - > m_iDataType )
{
psGroupParam - > m_pu8DataLen = ( BYTE * ) HEAP_MALLOC ( iMallocSize ) ;
Buban103DispMalloc ( commid , iMallocSize ) ;
psGroupParam - > m_pu8DataType = ( BYTE * ) HEAP_MALLOC ( iMallocSize ) ;
Buban103DispMalloc ( commid , iMallocSize ) ;
}
}
GetPrivateProString ( szSection , " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <EFBFBD> " , " -1 " , szbuf , sizeof ( szbuf ) , szDatFile ) ;
//sprintf(szDbg, "[%s]:[<5B> <> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> ] = %s\n", szSection, szbuf);
//DebugPrint(szDbg);
if ( atoi ( szbuf ) > 0 )
{
psGroupParam - > m_iStartItemNo = atoi ( szbuf ) ;
}
}
}
}
return TRUE ;
}
void InitGroupParam ( GROUPDEF * psGroupParam , char * szDatFileName )
{
i_32 i , iNameLen , iFixDataType ;
char szbuf [ 512 ] , szSection [ 128 ] , szItem [ 128 ] ;
char * ptrFirst , * ptrFind ;
BOOL bValue ;
bValue = FALSE ;
sprintf ( szSection , " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> %d" , psGroupParam - > m_iGroupNo ) ;
for ( i = 0 ; i < psGroupParam - > m_iPntNum ; i + + )
{
ptrFirst = ( char * ) szbuf ;
sprintf ( szItem , " %d " , i + 1 ) ;
if ( GetPrivateProString ( szSection , szItem , " δ֪<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " , szbuf , sizeof ( szbuf ) , szDatFileName ) < 0 )
{
strcpy ( szbuf , " δ֪<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
}
// <20> <> <EFBFBD> <EFBFBD>
ptrFind = strstr ( ptrFirst , " , " ) ;
if ( ptrFind )
{
* ptrFind = 0 ;
iNameLen = strlen ( ptrFirst ) ;
}
else
{
iNameLen = strlen ( ptrFirst ) ;
if ( iNameLen > = sizeof ( psGroupParam - > m_psDataInfo [ i ] . m_szName ) )
{
iNameLen = sizeof ( psGroupParam - > m_psDataInfo [ i ] . m_szName ) - 1 ;
}
memcpy ( psGroupParam - > m_psDataInfo [ i ] . m_szName , ptrFirst , iNameLen ) ;
psGroupParam - > m_psDataInfo [ i ] . m_szName [ iNameLen ] = 0 ;
continue ;
}
if ( iNameLen > = sizeof ( psGroupParam - > m_psDataInfo [ i ] . m_szName ) )
{
iNameLen = sizeof ( psGroupParam - > m_psDataInfo [ i ] . m_szName ) - 1 ;
}
memcpy ( psGroupParam - > m_psDataInfo [ i ] . m_szName , ptrFirst , iNameLen ) ;
psGroupParam - > m_psDataInfo [ i ] . m_szName [ iNameLen ] = 0 ;
if ( PROTECT_DI_PNT_TYPE = = psGroupParam - > m_iDataType )
{
psGroupParam - > m_psDataInfo [ i ] . m_fValue = ( float ) bValue ;
bValue = ! bValue ;
}
else
{
psGroupParam - > m_psDataInfo [ i ] . m_fValue = ( float ) ( i + 1 ) ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
if ( PROTECT_DI_PNT_TYPE = = psGroupParam - > m_iDataType )
continue ;
if ( PROTECT_AI_PNT_TYPE = = psGroupParam - > m_iDataType )
{
// <20> <> <EFBFBD> <EFBFBD>
ptrFirst = ptrFind + 1 ;
ptrFind = strstr ( ptrFirst , " , " ) ;
if ( ptrFind )
* ptrFind = 0 ;
else
continue ;
// ռ <> <D5BC> λ
ptrFirst = ptrFind + 1 ;
ptrFind = strstr ( ptrFirst , " , " ) ;
if ( ptrFind )
* ptrFind = 0 ;
else
continue ;
// ϵ<> <CFB5>
ptrFirst = ptrFind + 1 ;
ptrFind = strstr ( ptrFirst , " , " ) ;
if ( ptrFind )
* ptrFind = 0 ;
else
continue ;
// <20> <> λ
ptrFirst = ptrFind + 1 ;
ptrFind = strstr ( ptrFirst , " , " ) ;
if ( ptrFind )
{
* ptrFind = 0 ;
iNameLen = strlen ( ptrFirst ) ;
}
else
{
iNameLen = strlen ( ptrFirst ) ;
}
if ( iNameLen > = sizeof ( psGroupParam - > m_psDataInfo [ i ] . m_szUnit ) )
{
iNameLen = sizeof ( psGroupParam - > m_psDataInfo [ i ] . m_szUnit ) - 1 ;
}
memcpy ( psGroupParam - > m_psDataInfo [ i ] . m_szUnit , ptrFirst , iNameLen ) ;
psGroupParam - > m_psDataInfo [ i ] . m_szUnit [ iNameLen ] = 0 ;
continue ;
}
if ( PROTECT_FIX_PNT_TYPE = = psGroupParam - > m_iDataType )
{
// <20> <> <EFBFBD> <EFBFBD> (AI=1, DI=2)
ptrFirst = ptrFind + 1 ;
ptrFind = strstr ( ptrFirst , " , " ) ;
if ( ptrFind )
* ptrFind = 0 ;
else
continue ;
iFixDataType = atoi ( ptrFirst ) ;
psGroupParam - > m_psDataInfo [ i ] . iFixDataType = ( u_char ) iFixDataType ;
// <20> <> <EFBFBD> <EFBFBD>
ptrFirst = ptrFind + 1 ;
ptrFind = strstr ( ptrFirst , " , " ) ;
if ( ptrFind )
* ptrFind = 0 ;
else
continue ;
// ռ <> <D5BC> λ
ptrFirst = ptrFind + 1 ;
ptrFind = strstr ( ptrFirst , " , " ) ;
if ( ptrFind )
* ptrFind = 0 ;
else
continue ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( iFixDataType = = 2 )
{
// <20> <> <EFBFBD> ܴ<EFBFBD> <DCB4> <EFBFBD> <EFBFBD> ж<EFBFBD> <D0B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
continue ;
}
// <20> <> <EFBFBD> <EFBFBD> Ϊģ<CEAA> <C4A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʼ <EFBFBD> <CABC>
// ϵ<> <CFB5> (<28> 䵱<EFBFBD> <E4B5B1> <EFBFBD> <EFBFBD> )
ptrFirst = ptrFind + 1 ;
ptrFind = strstr ( ptrFirst , " , " ) ;
psGroupParam - > m_psDataInfo [ i ] . m_fStepValue = ( float ) atof ( ptrFirst ) ;
if ( ptrFind )
* ptrFind = 0 ;
else
continue ;
// <20> <> λ
ptrFirst = ptrFind + 1 ;
ptrFind = strstr ( ptrFirst , " , " ) ;
if ( ptrFind )
{
* ptrFind = 0 ;
iNameLen = strlen ( ptrFirst ) ;
}
else
{
iNameLen = strlen ( ptrFirst ) ;
}
if ( iNameLen > = sizeof ( psGroupParam - > m_psDataInfo [ i ] . m_szUnit ) )
{
iNameLen = sizeof ( psGroupParam - > m_psDataInfo [ i ] . m_szUnit ) - 1 ;
}
memcpy ( psGroupParam - > m_psDataInfo [ i ] . m_szUnit , ptrFirst , iNameLen ) ;
psGroupParam - > m_psDataInfo [ i ] . m_szUnit [ iNameLen ] = 0 ;
if ( NULL = = ptrFind )
continue ;
// <20> <> С ֵ
ptrFirst = ptrFind + 1 ;
ptrFind = strstr ( ptrFirst , " , " ) ;
psGroupParam - > m_psDataInfo [ i ] . m_fMinValue = ( float ) atof ( ptrFirst ) ;
if ( ptrFind )
{
* ptrFind = 0 ;
}
else
{
continue ;
}
// <20> <> <EFBFBD> <EFBFBD> ֵ
ptrFirst = ptrFind + 1 ;
psGroupParam - > m_psDataInfo [ i ] . m_fMaxValue = ( float ) atof ( ptrFirst ) ;
}
}
}
void InitBuban103CmdBuf ( int commid , BUBAN103PORTPARAM * psPortParam )
{
int i ;
psPortParam - > m_iLinkIdx = 0 ;
for ( i = 0 ; i < psPortParam - > m_iLinkNum ; i + + )
{
InitBuban103LinkCmdBuf ( & psPortParam - > m_psLink [ i ] ) ;
}
}
void InitBuban103LinkCmdBuf ( BUBAN103LINKDEF * psLinkParam )
{
int i ;
psLinkParam - > m_bRstLinkOk = FALSE ;
psLinkParam - > m_bGotoNext = FALSE ;
psLinkParam - > m_iQueryNum_CLASS1_Count = 0 ;
psLinkParam - > m_iDevIdx = 0 ;
psLinkParam - > m_iQueryedAddr_CLASS1 = 0 ;
psLinkParam - > m_shCurCmdIdx = 0 ;
if ( psLinkParam - > m_uchLinkAddr ! = 0xFF )
{
psLinkParam - > m_pu8CtlByte [ 0 ] = 0x00 ;
psLinkParam - > m_pbLinkOk [ 0 ] = FALSE ;
psLinkParam - > m_pu32LinkOkCnt [ 0 ] = 0 ;
}
else
{
for ( i = 0 ; i < psLinkParam - > m_iDevNum ; i + + )
{
psLinkParam - > m_pu8CtlByte [ i ] = 0x00 ;
psLinkParam - > m_pbLinkOk [ i ] = FALSE ;
psLinkParam - > m_pu32LinkOkCnt [ i ] = 0 ;
}
}
// <20> <> ʼ <EFBFBD> <CABC> ָ<EFBFBD> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
for ( i = 0 ; i < BUBAN103_TIMER_CMD_NUM ; i + + )
{
if ( psLinkParam - > m_sArrayCmdTime [ i ] . m_iCmdTimerConst > 20 )
{
psLinkParam - > m_sArrayCmdTime [ i ] . m_iCmdTimerCnt
= psLinkParam - > m_sArrayCmdTime [ i ] . m_iCmdTimerConst - 20 ;
}
else
{
psLinkParam - > m_sArrayCmdTime [ i ] . m_iCmdTimerCnt
= psLinkParam - > m_sArrayCmdTime [ i ] . m_iCmdTimerConst ;
}
}
for ( i = 0 ; i < psLinkParam - > m_iDevNum ; i + + )
{
InitBuban103DevCmdBuf ( psLinkParam , i ) ;
}
}
void InitBuban103DevCmdBuf ( BUBAN103LINKDEF * psLinkParam , int iDevNo )
{
DEVDEF * psDevDef ;
PROVDEVDEF * psProvDevParam ;
SetProtectDevStatus ( psLinkParam , iDevNo , FALSE ) ;
if ( psLinkParam - > m_psDev ! = NULL )
{
psDevDef = & psLinkParam - > m_psDev [ iDevNo ] ;
}
else
{
psDevDef = NULL ;
}
if ( psLinkParam - > m_psProvDev ! = NULL )
{
psProvDevParam = & psLinkParam - > m_psProvDev [ iDevNo ] ;
}
else
{
psProvDevParam = NULL ;
}
// <20> <> ·<EFBFBD> <C2B7> ַΪ255<35> <35> <EFBFBD> <EFBFBD> ÿ<EFBFBD> <C3BF> װ<EFBFBD> ö<EFBFBD> <C3B6> <EFBFBD> <EFBFBD> <EFBFBD> ·װ<C2B7> <D7B0>
if ( psLinkParam - > m_uchLinkAddr = = 0xFF )
{
psLinkParam - > m_pbLinkOk [ iDevNo ] = FALSE ;
psLinkParam - > m_pu32LinkOkCnt [ iDevNo ] = 0 ;
psLinkParam - > m_pu8CtlByte [ iDevNo ] = 0 ;
}
if ( psDevDef ! = NULL )
{
psDevDef - > m_bAllQueryOk = TRUE ;
psDevDef - > m_bInitdata = FALSE ;
if ( psLinkParam - > m_u32TimeOutConst > 10 )
{
psDevDef - > m_u32CallCnt
= psLinkParam - > m_u32TimeOutConst - 5 ;
}
else
{
psDevDef - > m_u32CallCnt = 0 ;
}
psDevDef - > m_u8RII = 0 ;
psDevDef - > m_sDevParam . m_iFaultNo = - 1 ;
psDevDef - > m_sDevParam . m_u32FuncCode = 0 ;
if ( psDevDef - > m_sDisturbanceParam . m_pshValue ! = NULL )
{
HEAP_FREE ( psDevDef - > m_sDisturbanceParam . m_pshValue ) ;
}
memset ( ( void * ) & psDevDef - > m_sDisturbanceParam , 0 , sizeof ( BUBAN103DISTURBANCEDEF ) ) ;
}
if ( psProvDevParam ! = NULL )
{
memset ( ( void * ) & psProvDevParam - > m_sProvGroupParam , 0 , sizeof ( PROV_ALLITEMOFGROUPPARAM ) ) ;
psProvDevParam - > m_sProvGroupParam . m_bFinished = TRUE ;
psProvDevParam - > m_sProvSoe . m_shFront = 0 ;
psProvDevParam - > m_sProvSoe . m_shRear = 0 ;
psProvDevParam - > m_sProvSoe . m_shSoeNum = 0 ;
// ת<> <D7AA>
psProvDevParam - > m_bProvQuery = FALSE ;
psProvDevParam - > m_iProvAsdu5Cause = 0 ;
psProvDevParam - > m_iProvQueryStepWithASDU = 0 ;
// wen 2005.06.22 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// <20> <> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ10<31> <30>
//SingleListInit(&psProvDevParam->m_sBaoHuData, 10);
}
}
void ReCalcDevPntStart ( int commid , BUBAN103PORTPARAM * psPortParam )
{
int i , j , k ;
int iAiStart , iDiStart ;
int iPiStart , iYkStart ;
BOOL bSlave ;
DEVDEF * pDevParam = NULL ;
PROVDEVDEF * pProvDevParam = NULL ;
iAiStart = 0 ;
iDiStart = 0 ;
iPiStart = 0 ;
iYkStart = 0 ;
if ( psPortParam - > m_psLink [ 0 ] . m_psDev ! = NULL )
{
bSlave = FALSE ;
pProvDevParam = NULL ;
}
if ( psPortParam - > m_psLink [ 0 ] . m_psProvDev ! = NULL )
{
bSlave = TRUE ;
pDevParam = NULL ;
}
for ( i = 0 ; i < psPortParam - > m_iLinkNum ; i + + )
{
for ( j = 0 ; j < psPortParam - > m_psLink [ i ] . m_iDevNum ; j + + )
{
if ( FALSE = = bSlave )
{
pDevParam = & psPortParam - > m_psLink [ i ] . m_psDev [ j ] ;
}
else
{
pProvDevParam = & psPortParam - > m_psLink [ i ] . m_psProvDev [ j ] ;
}
if ( pDevParam ! = NULL )
{
// ai
for ( k = 0 ; k < DEV_AI_MAXNUM ; k + + )
{
if ( pDevParam - > m_sDevParam . m_sAiDBOrientation [ k ] . m_iPntNum < = 0 )
{
break ;
}
pDevParam - > m_sDevParam . m_sAiDBOrientation [ k ] . m_iStartPntNo = iAiStart ;
iAiStart + = pDevParam - > m_sDevParam . m_sAiDBOrientation [ k ] . m_iPntNum ;
}
// di
if ( pDevParam - > m_sDevParam . m_sDiDBOrientation . m_iPntNum > 0 )
{
pDevParam - > m_sDevParam . m_sDiDBOrientation . m_iStartPntNo = iDiStart ;
iDiStart + = pDevParam - > m_sDevParam . m_sDiDBOrientation . m_iPntNum ;
}
// pi
if ( pDevParam - > m_sDevParam . m_sPiDBOrientation . m_iPntNum > 0 )
{
pDevParam - > m_sDevParam . m_sPiDBOrientation . m_iStartPntNo = iPiStart ;
iPiStart + = pDevParam - > m_sDevParam . m_sPiDBOrientation . m_iPntNum ;
}
if ( pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iPntNum > 0 )
{
pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iStartPntNo = iYkStart ;
iYkStart + = pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iPntNum ;
}
}
if ( pProvDevParam ! = NULL )
{
// ai
if ( pProvDevParam - > m_sYcInfo . m_iPntNum > 0 )
{
pProvDevParam - > m_sYcInfo . m_iStartPntNo = iAiStart ;
iAiStart + = pProvDevParam - > m_sYcInfo . m_iPntNum ;
}
// di
if ( pProvDevParam - > m_sYxInfo . m_iPntNum > 0 )
{
pProvDevParam - > m_sYxInfo . m_iStartPntNo = iDiStart ;
iDiStart + = pProvDevParam - > m_sYxInfo . m_iPntNum ;
}
// Pi
if ( pProvDevParam - > m_sYmInfo . m_iPntNum > 0 )
{
pProvDevParam - > m_sYmInfo . m_iStartPntNo = iPiStart ;
iPiStart + = pProvDevParam - > m_sYmInfo . m_iPntNum ;
}
}
}
}
}
//===========================װ<> ó<EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> =======================
//===========================<3D> <> <EFBFBD> <EFBFBD> Ϊָ<CEAA> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> ɺ<EFBFBD> <C9BA> <EFBFBD> =======================
//**************************************************************************
//* <20> <> <EFBFBD> <EFBFBD> Buban103Э<33> <D0AD> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> u_32 commid:RTU<54> ˿ں<CBBF> *
//* BYTE bLinkAddr:<3A> <> ·<EFBFBD> <C2B7> ַ *
//* u_char link_cmd_idx:<3A> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//* u_char *msg:Ӧ<> ò<EFBFBD> <C3B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> Ӧ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʹ <EFBFBD> ù̶<C3B9> *
//* <20> <> <EFBFBD> ȵ<EFBFBD> ֡<EFBFBD> <D6A1> ʽ <EFBFBD> <CABD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> NULL<4C> <4C> <EFBFBD> <EFBFBD> *
//* u_32 len:Ӧ<> ò<EFBFBD> <C3B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> ij<EFBFBD> <C4B3> ȣ <EFBFBD> <C8A3> <EFBFBD> <EFBFBD> <EFBFBD> ʹ <EFBFBD> ù̶<C3B9> <CCB6> <EFBFBD> <EFBFBD> ȵ<EFBFBD> ֡<EFBFBD> <D6A1> ʽ <EFBFBD> <CABD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 0<EFBFBD> <30> <EFBFBD> <EFBFBD> *
//* u_32 cmdtype: ָ<> <EFBFBD> <EEBBBA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//**************************************************************************
void MakeBuban103LinkCommand ( u_32 commid , BYTE bLinkAddr , u_char link_cmd_idx ,
u_char * msg , u_32 len , u_32 cmdtype )
{
u_char tmp [ MAX_POLL_CMD_BUF_LEN ] , nCs , nEnd ;
CLPDU_FIX bClpdu_fix ;
CLPDU_VARR bClpdu_varr ;
memset ( & bClpdu_fix , 0 , sizeof ( CLPDU_FIX ) ) ;
memset ( & bClpdu_varr , 0 , sizeof ( CLPDU_VARR ) ) ;
memset ( tmp , 0 , sizeof ( tmp ) ) ;
switch ( link_cmd_idx )
{
case C_RLK_NA_3 : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·״̬
bClpdu_fix . nSTART = 0x10 ;
bClpdu_fix . nCONTROL = C_RLK_NA_3 | 0x40 ;
bClpdu_fix . nADDR = bLinkAddr ;
bClpdu_fix . nCS = CalBuban103Lpc ( & bClpdu_fix . nCONTROL , 2 ) ;
bClpdu_fix . nEnd = 0x16 ;
PutPollCmdToBuf ( commid , NORMAL_POLL_CMD , 0 , ( char * ) & bClpdu_fix , 5 ) ;
break ;
case C_RFB_NA_3 : // <20> <> λ֡<CEBB> <D6A1> <EFBFBD> <EFBFBD> λ
bClpdu_fix . nSTART = 0x10 ;
bClpdu_fix . nCONTROL = C_RFB_NA_3 | 0x40 ;
bClpdu_fix . nADDR = bLinkAddr ;
bClpdu_fix . nCS = CalBuban103Lpc ( & bClpdu_fix . nCONTROL , 2 ) ;
bClpdu_fix . nEnd = 0x16 ;
PutPollCmdToBuf ( commid , NORMAL_POLL_CMD , 0 , ( char * ) & bClpdu_fix , 5 ) ;
break ;
case C_RCU_NA_3 : // <20> <> λͨѶ<CDA8> <D1B6> Ԫ
bClpdu_fix . nSTART = 0x10 ;
bClpdu_fix . nCONTROL = C_RCU_NA_3 | 0x40 ;
bClpdu_fix . nADDR = bLinkAddr ;
bClpdu_fix . nCS = CalBuban103Lpc ( & bClpdu_fix . nCONTROL , 2 ) ;
bClpdu_fix . nEnd = 0x16 ;
PutPollCmdToBuf ( commid , NORMAL_POLL_CMD , 0 , ( char * ) & bClpdu_fix , 5 ) ;
break ;
case C_PL1_NA_3 : // <20> ٻ<EFBFBD> 1<EFBFBD> <31> <EFBFBD> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD>
bClpdu_fix . nSTART = 0x10 ;
bClpdu_fix . nCONTROL = C_PL1_NA_3 | 0x50 ;
bClpdu_fix . nADDR = bLinkAddr ;
bClpdu_fix . nCS = CalBuban103Lpc ( & bClpdu_fix . nCONTROL , 2 ) ;
bClpdu_fix . nEnd = 0x16 ;
PutPollCmdToBuf ( commid , INSERT_POLL_CMD , 0 , ( char * ) & bClpdu_fix , 5 ) ;
break ;
case C_PL2_NA_3 : // <20> ٻ<EFBFBD> 2<EFBFBD> <32> <EFBFBD> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD>
bClpdu_fix . nSTART = 0x10 ;
bClpdu_fix . nCONTROL = C_PL2_NA_3 | 0x50 ;
bClpdu_fix . nADDR = bLinkAddr ;
bClpdu_fix . nCS = CalBuban103Lpc ( & bClpdu_fix . nCONTROL , 2 ) ;
bClpdu_fix . nEnd = 0x16 ;
PutPollCmdToBuf ( commid , NORMAL_POLL_CMD , 0 , ( char * ) & bClpdu_fix , 5 ) ;
break ;
case C_SD1_NA_3 : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> <DDA3> <EFBFBD> <EFBFBD> <EFBFBD> /ȷ<> <C8B7> ֡<EFBFBD> <D6A1>
bClpdu_varr . nSTART1 = 0x68 ;
bClpdu_varr . nSTART2 = 0x68 ;
if ( len ! = 0 )
{
bClpdu_varr . nLEN1 = ( BYTE ) ( len + 2 ) ;
bClpdu_varr . nLEN2 = bClpdu_varr . nLEN1 ;
}
bClpdu_varr . nCONTROL = C_SD1_NA_3 | 0x50 ;
bClpdu_varr . nADDR = bLinkAddr ;
memcpy ( tmp , ( char * ) & bClpdu_varr , sizeof ( bClpdu_varr ) ) ;
memcpy ( & tmp [ 6 ] , msg , len ) ;
nCs = CalBuban103Lpc ( tmp , bClpdu_varr . nLEN1 ) ;
nEnd = 0x16 ;
tmp [ len + 6 ] = nCs ;
tmp [ len + 7 ] = nEnd ;
PutPollCmdToBuf ( commid , cmdtype , 0 , ( char * ) tmp , len + 8 ) ;
break ;
case C_SD2_NA_3 : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> <DDA3> <EFBFBD> <EFBFBD> <EFBFBD> /<2F> ش<DEBB> ֡<EFBFBD> <D6A1>
bClpdu_varr . nSTART1 = 0x68 ;
bClpdu_varr . nSTART2 = 0x68 ;
if ( len ! = 0 )
{
bClpdu_varr . nLEN1 = ( BYTE ) ( len + 2 ) ;
bClpdu_varr . nLEN2 = bClpdu_varr . nLEN1 ;
}
bClpdu_varr . nCONTROL = C_SD2_NA_3 | 0x40 ;
bClpdu_varr . nADDR = bLinkAddr ;
memcpy ( tmp , ( char * ) & bClpdu_varr , sizeof ( bClpdu_varr ) ) ;
memcpy ( & tmp [ 6 ] , msg , len ) ;
nCs = CalBuban103Lpc ( tmp , bClpdu_varr . nLEN1 ) ;
nEnd = 0x16 ;
tmp [ len + 6 ] = nCs ;
tmp [ len + 7 ] = nEnd ;
PutPollCmdToBuf ( commid , cmdtype , 0 , ( char * ) tmp , len + 8 ) ;
break ;
default :
break ;
}
}
//*************************************************************
//* <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> ͬ<EFBFBD> <CDAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> :u_32 commid:RTU<54> ˿ں<CBBF> *
//* u_char addr:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ
//*************************************************************
void MakeTimeSyn_CAsdu6 ( u_32 commid , CMDPARAM * psCmdParam )
{
CASDU6 bCAsdu6 ;
DAY_TIME sCurTime ;
char szbuf [ 128 ] ;
memset ( & bCAsdu6 , 0 , sizeof ( CASDU6 ) ) ;
bCAsdu6 . nTYP = C_SYN_TA_3 ;
bCAsdu6 . nVSQ = 0x81 ;
bCAsdu6 . nCOT = 8 ;
bCAsdu6 . nADDR = psCmdParam - > m_sDevAddr . m_uchCommAddr ;
bCAsdu6 . nFUN = psCmdParam - > m_uchFun ;
bCAsdu6 . nINF = psCmdParam - > m_uchInf ;
GetLocalTimeEx ( & sCurTime ) ;
sCurTime . mSec = sCurTime . Sec * 1000 + sCurTime . mSec ;
bCAsdu6 . nTIME [ 0 ] = sCurTime . mSec % 256 ;
bCAsdu6 . nTIME [ 1 ] = sCurTime . mSec / 256 ;
bCAsdu6 . nTIME [ 2 ] = ( u_char ) sCurTime . Min ;
bCAsdu6 . nTIME [ 3 ] = ( u_char ) sCurTime . Hour ;
//bCAsdu6.nTIME[4] = (u_char)ControlParam->CurTime.wDayOfWeek;
bCAsdu6 . nTIME [ 4 ] = ( u_char ) ( sCurTime . Day & 0x1F ) ;
bCAsdu6 . nTIME [ 5 ] = ( u_char ) sCurTime . Month ;
bCAsdu6 . nTIME [ 6 ] = ( u_char ) ( sCurTime . Year % 100 ) ;
sprintf ( szbuf , " <EFBFBD> <EFBFBD> ʱʱ<EFBFBD> <EFBFBD> Ϊ:%d<> <64> %d<> <64> %d<> <64> %d<> <64> %d<> <64> %d<> <64> %d<> <64> <EFBFBD> <EFBFBD> " , sCurTime . Year , sCurTime . Month , bCAsdu6 . nTIME [ 4 ] , sCurTime . Hour , sCurTime . Min , sCurTime . Sec , sCurTime . mSec - sCurTime . Sec * 1000 ) ;
DebugPrint ( szbuf ) ;
if ( psCmdParam - > m_sDevAddr . m_uchLinkAddr = = 255 )
{
MakeBuban103LinkCommand ( commid , psCmdParam - > m_sDevAddr . m_uchLinkAddr , \
C_SD2_NA_3 , ( u_char * ) & bCAsdu6 , sizeof ( CASDU6 ) , FAST_POLL_CMD ) ;
}
else
{
MakeBuban103LinkCommand ( commid , psCmdParam - > m_sDevAddr . m_uchLinkAddr , \
C_SD1_NA_3 , ( u_char * ) & bCAsdu6 , sizeof ( CASDU6 ) , NORMAL_POLL_CMD ) ;
}
}
//*************************************************************
//* <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> :u_32 commid:RTU<54> ˿ں<CBBF> *
//*<2A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> u_char addr:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ
//*************************************************************
void MakeAllQuery_CAsdu7 ( u_32 commid , CMDPARAM * psCmdParam )
{
BYTE u8SCN ;
CASDU7 bCAsdu7 ;
BUBAN103PORTPARAM * pPortParam ;
if ( SioParam [ commid ] . ExtInfo = = NULL )
{
return ;
}
pPortParam = ( pBUBAN103PORTPARAM ) SioParam [ commid ] . ExtInfo ;
memset ( & bCAsdu7 , 0 , sizeof ( CASDU7 ) ) ;
bCAsdu7 . nTYP = C_TGI_NA_3 ;
bCAsdu7 . nVSQ = 0x81 ;
bCAsdu7 . nCOT = 9 ;
bCAsdu7 . nADDR = psCmdParam - > m_sDevAddr . m_uchCommAddr ;
bCAsdu7 . nFUN = 255 ;
bCAsdu7 . nINF = 0 ;
//ɨ<> <C9A8> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> ʵ
u8SCN = pPortParam - > m_psLink [ psCmdParam - > m_sDevAddr . m_iLinkIdx ] . m_psDev [ psCmdParam - > m_sDevAddr . m_iDevIdx ] . m_sDevParam . m_u8SCN ;
bCAsdu7 . nSCN = u8SCN ;
MakeBuban103LinkCommand ( commid , psCmdParam - > m_sDevAddr . m_uchLinkAddr , \
C_SD1_NA_3 , ( unsigned char * ) & bCAsdu7 , sizeof ( CASDU7 ) , NORMAL_POLL_CMD ) ;
pPortParam - > m_psLink [ psCmdParam - > m_sDevAddr . m_iLinkIdx ] . m_psDev [ psCmdParam - > m_sDevAddr . m_iDevIdx ] . m_bAllQueryOk = FALSE ;
pPortParam - > m_psLink [ psCmdParam - > m_sDevAddr . m_iLinkIdx ] . m_psDev [ psCmdParam - > m_sDevAddr . m_iDevIdx ] . m_sDevParam . m_u8SCN = ( u8SCN + 1 ) % 256 ;
}
//*******************************************************************
//* <20> <> <EFBFBD> <EFBFBD> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> :u_32 commid:RTU<54> ˿ں<CBBF> *
//*<2A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> u_char addr:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ
//* u_char inf:<3A> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> ţ<EFBFBD> ȡֵ<C8A1> <D6B5> Χ ֻ<CEA7> <D6BB> <EFBFBD> <EFBFBD> 248-251,<2C> <> <EFBFBD> У <EFBFBD> *
//* 248<34> <38> д<EFBFBD> <D0B4> Ŀ *
//* 249<34> <39> <EFBFBD> <EFBFBD> ȷ<EFBFBD> ϵ<EFBFBD> д<EFBFBD> <D0B4> Ŀ *
//* 250<35> <30> <EFBFBD> <EFBFBD> ִ<EFBFBD> е <EFBFBD> д<EFBFBD> <D0B4> Ŀ *
//* 251<35> <31> д<EFBFBD> <D0B4> Ŀ<EFBFBD> <C4BF> ֹ *
//* unsigned char* dataset:ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> <EFBFBD> Ϣ *
//* u_char ngd:ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ״̬λ<CCAC> <CEBB> *
//*******************************************************************
void MakeGenIdentData_CAsdu10 ( u_32 commid , CMDPARAM * psCmdParam ,
u_char * dataset , u_char ngd )
{
CASDU10 bCAsdu10 ;
u_32 len , len1 , i , start ;
u_char tmp [ MAX_POLL_CMD_BUF_LEN ] ;
memset ( & bCAsdu10 , 0 , sizeof ( CASDU10 ) ) ;
bCAsdu10 . nTYP = C_GD_NA_3 ;
bCAsdu10 . nVSQ = 0x81 ;
bCAsdu10 . nCOT = 40 ;
bCAsdu10 . nADDR = psCmdParam - > m_sDevAddr . m_uchCommAddr ;
bCAsdu10 . nFUN = 254 ;
if ( ( psCmdParam - > m_uchInf > = 248 )
& & ( psCmdParam - > m_uchInf < = 251 ) )
{
bCAsdu10 . nINF = psCmdParam - > m_uchInf ;
}
bCAsdu10 . nRII = psCmdParam - > m_uchRII ;
bCAsdu10 . nNGD = ngd ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> ij<EFBFBD> <C4B3> <EFBFBD>
start = 0 ;
len = 0 ;
for ( i = 0 ; i < ngd ; i + + )
{
if ( dataset [ start + 3 ] = = 2 ) //<2F> <> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <CEAA> <EFBFBD> <EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
if ( ( dataset [ start + 4 ] % 8 ) = = 0 )
{
len + = dataset [ start + 4 ] / 8 ;
}
else
{
len + = dataset [ start + 4 ] / 8 + 1 ;
}
}
else //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
len + = 6 + dataset [ start + 4 ] * dataset [ start + 5 ] ;
}
start = len ;
}
len1 = sizeof ( bCAsdu10 ) - sizeof ( unsigned char * ) ;
memcpy ( ( void * ) tmp , ( void * ) & bCAsdu10 , len1 ) ;
if ( ( len > 0 ) & & ( dataset ! = NULL ) )
{
memcpy ( ( void * ) & tmp [ len1 ] , dataset , len ) ;
}
MakeBuban103LinkCommand ( commid , psCmdParam - > m_sDevAddr . m_uchLinkAddr , \
C_SD1_NA_3 , ( unsigned char * ) tmp , len + len1 , NORMAL_POLL_CMD ) ;
}
//*******************************************************************
//* <20> <> <EFBFBD> <EFBFBD> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> :u_32 commid:RTU<54> ˿ں<CBBF> *
//*<2A> <> <EFBFBD> <EFBFBD> :u_char addr:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ *
//* u_char inf:<3A> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> ţ<EFBFBD> ȡֵ<C8A1> <D6B5> Χ ֻ<CEA7> <D6BB> <EFBFBD> <EFBFBD> 248-251,<2C> <> <EFBFBD> У <EFBFBD> *
//* 248<34> <38> д<EFBFBD> <D0B4> Ŀ *
//* 249<34> <39> <EFBFBD> <EFBFBD> ȷ<EFBFBD> ϵ<EFBFBD> д<EFBFBD> <D0B4> Ŀ *
//* 250<35> <30> <EFBFBD> <EFBFBD> ִ<EFBFBD> е <EFBFBD> д<EFBFBD> <D0B4> Ŀ *
//* 251<35> <31> д<EFBFBD> <D0B4> Ŀ<EFBFBD> <C4BF> ֹ *
//* unsigned char* dataset:ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> <EFBFBD> Ϣ *
//* u_char ngd:ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ״̬λ<CCAC> <CEBB> *
//* u_32 cmdtype : ָ<> <EFBFBD> <EEBBBA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//*******************************************************************
void MakeGenIdentData_CAsdu10Ex ( u_32 commid , CMDPARAM * psCmdParam ,
u_char * dataset , u_char ngd , u_32 cmdtype )
{
CASDU10 bCAsdu10 ;
u_32 len , len1 , i , start ;
u_char tmp [ MAX_POLL_CMD_BUF_LEN ] ;
memset ( & bCAsdu10 , 0 , sizeof ( CASDU10 ) ) ;
bCAsdu10 . nTYP = C_GD_NA_3 ;
bCAsdu10 . nVSQ = 0x81 ;
bCAsdu10 . nCOT = 40 ;
bCAsdu10 . nADDR = psCmdParam - > m_sDevAddr . m_uchCommAddr ;
bCAsdu10 . nFUN = 254 ;
if ( ( psCmdParam - > m_uchInf > = 248 )
& & ( psCmdParam - > m_uchInf < = 251 ) )
{
bCAsdu10 . nINF = psCmdParam - > m_uchInf ;
}
bCAsdu10 . nRII = psCmdParam - > m_uchRII ;
bCAsdu10 . nNGD = ngd ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> ij<EFBFBD> <C4B3> <EFBFBD>
start = 0 ;
len = 0 ;
for ( i = 0 ; i < ngd ; i + + )
{
if ( dataset [ start + 3 ] = = 2 ) //<2F> <> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <CEAA> <EFBFBD> <EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
if ( ( dataset [ start + 4 ] % 8 ) = = 0 )
{
len + = dataset [ start + 4 ] / 8 ;
}
else
{
len + = dataset [ start + 4 ] / 8 + 1 ;
}
}
else //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
len + = 6 + dataset [ start + 4 ] * dataset [ start + 5 ] ;
}
start = len ;
}
len1 = sizeof ( bCAsdu10 ) - sizeof ( unsigned char * ) ;
memcpy ( ( void * ) tmp , ( void * ) & bCAsdu10 , len1 ) ;
if ( ( len > 0 ) & & ( dataset ! = NULL ) )
{
memcpy ( ( void * ) & tmp [ len1 ] , dataset , len ) ;
}
MakeBuban103LinkCommand ( commid , psCmdParam - > m_sDevAddr . m_uchLinkAddr , \
C_SD1_NA_3 , ( unsigned char * ) tmp , len + len1 , cmdtype ) ;
}
//*************************************************************
//* <20> <> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> :u_32 commid:RTU<54> ˿ں<CBBF> *
//*<2A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> u_char addr:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ
//* u_char inf:<3A> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> ţ<EFBFBD> ȡֵ<C8A1> <D6B5> Χ Ϊ16--26 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//* 16=<3D> Զ<EFBFBD> <D4B6> غ<EFBFBD> բͶ<D5A2> <CDB6> /<2F> ˳<EFBFBD> <CBB3> <EFBFBD> ON/OFF<46> <46> *
//* 17=Զ<> <D4B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ͷ<EFBFBD> <CDB6> /<2F> ˳<EFBFBD> <CBB3> <EFBFBD> ON/OF<4F> <46> *
//* 18=<3D> <> <EFBFBD> <EFBFBD> Ͷ<EFBFBD> <CDB6> /<2F> ˳<EFBFBD> <CBB3> <EFBFBD> ON/OF<4F> <46> *
//* 19=LED<45> <44> λ *
//* 23=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 1 *
//* 24=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 2 *
//* 25=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 3 *
//* 26=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 4 *
//* <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> Ϊ<EFBFBD> Ƿ<EFBFBD> *
//* bool cmd:<3A> <> <EFBFBD> <EFBFBD> ״̬<D7B4> <CCAC> true=<3D> ϣ<EFBFBD> false=<3D> <> <EFBFBD> <EFBFBD> *
//*************************************************************
void MakeGenCommand_CAsdu20 ( u_32 commid , CMDPARAM * psCmdParam , bool cmd )
{
CASDU20 bCAsdu20 ;
memset ( & bCAsdu20 , 0 , sizeof ( CASDU20 ) ) ;
bCAsdu20 . nTYP = C_GRC_NA_3 ;
bCAsdu20 . nVSQ = 0x81 ;
bCAsdu20 . nCOT = 20 ;
bCAsdu20 . nADDR = psCmdParam - > m_sDevAddr . m_uchCommAddr ;
bCAsdu20 . nFUN = 128 ; //<2F> <> Ҫ<EFBFBD> <D2AA> ֤ȷ<D6A4> <C8B7>
bCAsdu20 . nINF = psCmdParam - > m_uchInf ;
bCAsdu20 . nRII = psCmdParam - > m_uchRII ;
if ( cmd )
{
bCAsdu20 . nDCO = 0x02 ;
}
else
{
bCAsdu20 . nDCO = 0x01 ;
}
MakeBuban103LinkCommand ( commid , psCmdParam - > m_sDevAddr . m_uchLinkAddr , \
C_SD1_NA_3 , ( u_char * ) & bCAsdu20 , sizeof ( CASDU20 ) , NORMAL_POLL_CMD ) ;
}
//******************************************************************
//* <20> <> <EFBFBD> <EFBFBD> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> :u_32 commid:RTU<54> ˿ں<CBBF> *
//*<2A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> u_char addr:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ
//* u_char inf:<3A> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> ţ<EFBFBD> ȡֵ<C8A1> <D6B5> Χ ֻ<CEA7> <D6BB> <EFBFBD> <EFBFBD> 240-245,<2C> <> <EFBFBD> У <EFBFBD> *
//* 240<34> <30> <EFBFBD> <EFBFBD> ȫ<EFBFBD> <C8AB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> *
//* 241<34> <31> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȫ<EFBFBD> <C8AB> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//* 242<34> <32> δ<EFBFBD> <CEB4> *
//* 243<34> <33> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> Ŀ¼ *
//* 244<34> <34> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//* 245<34> <35> <EFBFBD> <EFBFBD> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> <DDB5> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> *
//* GEN_DATAGROUP* datagroup:ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ *
//* u_char nog:ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> ʾ <EFBFBD> <CABE> Ŀ *
//******************************************************************
void MakeGenIdentCommand_CAsdu21 ( u_32 commid , CMDPARAM * psCmdParam ,
GEN_DATAGROUP * datagroup , u_char nog )
{
CASDU21 bCAsdu21 ;
u_32 len ;
u_char tmp [ MAX_POLL_CMD_BUF_LEN ] ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
memset ( & bCAsdu21 , 0 , sizeof ( CASDU21 ) ) ;
bCAsdu21 . nTYP = C_GC_NA_3 ;
bCAsdu21 . nVSQ = 0x81 ;
if ( psCmdParam - > m_uchInf = = C_INF_QUERYGENERAL )
{
bCAsdu21 . nCOT = C_CAUSE_QUERY ;
}
else // ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
bCAsdu21 . nCOT = C_CAUSE_READWITHVALIDDATA ;
}
bCAsdu21 . nADDR = psCmdParam - > m_sDevAddr . m_uchCommAddr ;
bCAsdu21 . nFUN = FUNC_GENERALSORT ;
if ( ( psCmdParam - > m_uchInf > = C_INF_READGROUPTITLE )
& & ( psCmdParam - > m_uchInf < = C_INF_QUERYGENERAL ) )
{
bCAsdu21 . nINF = psCmdParam - > m_uchInf ;
}
else
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d<> <64> <EFBFBD> <EFBFBD> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> INF=%d<> <64> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> ķ<EFBFBD> Χ <EFBFBD> <CEA7> !!!" ,
commid , psCmdParam - > m_sDevAddr . m_uchLinkAddr , psCmdParam - > m_sDevAddr . m_uchCommAddr , psCmdParam - > m_uchInf ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
bCAsdu21 . nRII = psCmdParam - > m_uchRII ;
bCAsdu21 . nNOG = nog ;
len = sizeof ( CASDU21 ) - sizeof ( GEN_DATAGROUP * ) ;
memcpy ( ( void * ) tmp , ( void * ) & bCAsdu21 , len ) ;
if ( nog = = 0 )
{
MakeBuban103LinkCommand ( commid , psCmdParam - > m_sDevAddr . m_uchLinkAddr , \
C_SD1_NA_3 , tmp , len , NORMAL_POLL_CMD ) ;
}
else
{
memcpy ( ( void * ) & tmp [ len ] , datagroup , sizeof ( GEN_DATAGROUP ) * nog ) ;
len + = sizeof ( GEN_DATAGROUP ) * nog ;
MakeBuban103LinkCommand ( commid , psCmdParam - > m_sDevAddr . m_uchLinkAddr , \
C_SD1_NA_3 , tmp , len , NORMAL_POLL_CMD ) ;
}
}
//*************************************************************
//* <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> :u_32 commid:RTU<54> ˿ں<CBBF> *
//*<2A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> u_char addr:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ
//* u_char too:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͣ<EFBFBD> <CDA3> <EFBFBD> ֵ<EFBFBD> <D6B5> Χ Ϊ1--255<35> <35> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//* 1=<3D> <> <EFBFBD> ϵ<EFBFBD> ѡ <EFBFBD> <D1A1>
//* 2=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> <EFBFBD>
//* 3=<3D> <> ֹ<EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> <EFBFBD>
//* 4--7 = <20> <> <EFBFBD> <EFBFBD>
//* 8=ͨ<> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//* 9=ͨ<> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ
//* 10--15 = <20> <> <EFBFBD> <EFBFBD>
//* 16=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ
//* 17=<3D> <> ֹ<EFBFBD> <D6B9> <EFBFBD> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ
//* 18--23 = <20> <> <EFBFBD> <EFBFBD>
//* 24=<3D> <> <EFBFBD> <EFBFBD> ¼<EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD>
//* 25--31 =<3D> <> <EFBFBD> <EFBFBD>
//* 32=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 33=<3D> ɿ<EFBFBD> <C9BF> <EFBFBD> ϵͳ<CFB5> <CDB3> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 34=<3D> ɼ̵籣<CCB5> <E7B1A3> <EFBFBD> 豸<EFBFBD> <E8B1B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 35=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 36=<3D> ɿ<EFBFBD> <C9BF> <EFBFBD> ϵͳ<CFB5> <CDB3> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 37=<3D> ɼ̵籣<CCB5> <E7B1A3> <EFBFBD> 豸<EFBFBD> <E8B1B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 38=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//* 39=<3D> ɿ<EFBFBD> <C9BF> <EFBFBD> ϵͳ<CFB5> <CDB3> <EFBFBD> <EFBFBD> ֹ<EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 40=<3D> ɼ̵籣<CCB5> <E7B1A3> <EFBFBD> 豸<EFBFBD> <E8B1B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 41--63=<3D> <> <EFBFBD> <EFBFBD>
//* 64=<3D> ɹ<EFBFBD> <C9B9> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> 䣨<EFBFBD> ϶<EFBFBD> <CFB6> <EFBFBD>
//* 65=<3D> <> <EFBFBD> ɹ<EFBFBD> <C9B9> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> 䣨<EFBFBD> <EFBFBD>
//* 66=<3D> ɹ<EFBFBD> <C9B9> <EFBFBD> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> 䣨<EFBFBD> ϶<EFBFBD> <CFB6> <EFBFBD>
//* 67=<3D> <> <EFBFBD> ɹ<EFBFBD> <C9B9> <EFBFBD> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> 䣨<EFBFBD> <EFBFBD>
//* 68=<3D> ɹ<EFBFBD> <C9B9> ش<EFBFBD> <D8B4> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> 䣨<EFBFBD> ϶<EFBFBD> <CFB6> <EFBFBD>
//* 69=<3D> <> <EFBFBD> ɹ<EFBFBD> <C9B9> ش<EFBFBD> <D8B4> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> 䣨<EFBFBD> <EFBFBD>
//* 70--255=<3D> <> <EFBFBD> <EFBFBD>
//* u_char tov:<3A> Ŷ<EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//* u_short fan:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//* u_char acc:ʵ<> <CAB5> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//*************************************************************
void MakeDisTrans_CAsdu24 ( u_32 commid , CMDPARAM * psCmdParam ,
u_char too , u_char tov , u_short fan , u_char acc )
{
CASDU24 bCAsdu24 ;
memset ( & bCAsdu24 , 0 , sizeof ( CASDU24 ) ) ;
bCAsdu24 . nTYP = C_ODT_NA_3 ;
bCAsdu24 . nVSQ = 0x81 ;
bCAsdu24 . nCOT = 31 ;
bCAsdu24 . nADDR = psCmdParam - > m_sDevAddr . m_uchCommAddr ;
bCAsdu24 . nFUN = psCmdParam - > m_uchFun ;
bCAsdu24 . nTOO = too ;
bCAsdu24 . nTOV = tov ;
bCAsdu24 . nFAN = fan ;
bCAsdu24 . nACC = acc ;
MakeBuban103LinkCommand ( commid , psCmdParam - > m_sDevAddr . m_uchLinkAddr , \
C_SD1_NA_3 , ( u_char * ) & bCAsdu24 , sizeof ( CASDU24 ) , INSERT_POLL_CMD ) ;
}
//*************************************************************
//* <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ͽ<EFBFBD> <CFBF> <EFBFBD> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> :u_32 commid:RTU<54> ˿ں<CBBF> *
//*<2A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> u_char addr:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ
//* u_char too:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͣ<EFBFBD> <CDA3> <EFBFBD> ֵ<EFBFBD> <D6B5> Χ Ϊ1--255<35> <35> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//* 1=<3D> <> <EFBFBD> ϵ<EFBFBD> ѡ <EFBFBD> <D1A1>
//* 2=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> <EFBFBD>
//* 3=<3D> <> ֹ<EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> <EFBFBD>
//* 4--7 = <20> <> <EFBFBD> <EFBFBD>
//* 8=ͨ<> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//* 9=ͨ<> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ
//* 10--15 = <20> <> <EFBFBD> <EFBFBD>
//* 16=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ
//* 17=<3D> <> ֹ<EFBFBD> <D6B9> <EFBFBD> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ
//* 18--23 = <20> <> <EFBFBD> <EFBFBD>
//* 24=<3D> <> <EFBFBD> <EFBFBD> ¼<EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD>
//* 25--31 =<3D> <> <EFBFBD> <EFBFBD>
//* 32=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 33=<3D> ɿ<EFBFBD> <C9BF> <EFBFBD> ϵͳ<CFB5> <CDB3> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 34=<3D> ɼ̵籣<CCB5> <E7B1A3> <EFBFBD> 豸<EFBFBD> <E8B1B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 35=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 36=<3D> ɿ<EFBFBD> <C9BF> <EFBFBD> ϵͳ<CFB5> <CDB3> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 37=<3D> ɼ̵籣<CCB5> <E7B1A3> <EFBFBD> 豸<EFBFBD> <E8B1B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 38=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//* 39=<3D> ɿ<EFBFBD> <C9BF> <EFBFBD> ϵͳ<CFB5> <CDB3> <EFBFBD> <EFBFBD> ֹ<EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 40=<3D> ɼ̵籣<CCB5> <E7B1A3> <EFBFBD> 豸<EFBFBD> <E8B1B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> Ľ<EFBFBD> <C4BD> <EFBFBD>
//* 41--63=<3D> <> <EFBFBD> <EFBFBD>
//* 64=<3D> ɹ<EFBFBD> <C9B9> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> 䣨<EFBFBD> ϶<EFBFBD> <CFB6> <EFBFBD>
//* 65=<3D> <> <EFBFBD> ɹ<EFBFBD> <C9B9> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> 䣨<EFBFBD> <EFBFBD>
//* 66=<3D> ɹ<EFBFBD> <C9B9> <EFBFBD> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> 䣨<EFBFBD> ϶<EFBFBD> <CFB6> <EFBFBD>
//* 67=<3D> <> <EFBFBD> ɹ<EFBFBD> <C9B9> <EFBFBD> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> 䣨<EFBFBD> <EFBFBD>
//* 68=<3D> ɹ<EFBFBD> <C9B9> ش<EFBFBD> <D8B4> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> 䣨<EFBFBD> ϶<EFBFBD> <CFB6> <EFBFBD>
//* 69=<3D> <> <EFBFBD> ɹ<EFBFBD> <C9B9> ش<EFBFBD> <D8B4> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> 䣨<EFBFBD> <EFBFBD>
//* 70--255=<3D> <> <EFBFBD> <EFBFBD>
//* u_char tov:<3A> Ŷ<EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//* u_short fan:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//* u_char acc:ʵ<> <CAB5> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//*************************************************************
void MakeDisTrans_CAsdu25 ( u_32 commid , CMDPARAM * psCmdParam ,
u_char too , u_char tov , u_short fan , u_char acc )
{
CASDU25 bCAsdu25 ;
memset ( & bCAsdu25 , 0 , sizeof ( CASDU25 ) ) ;
bCAsdu25 . nTYP = C_ADT_NA_3 ;
bCAsdu25 . nVSQ = 0x81 ;
bCAsdu25 . nCOT = 31 ;
bCAsdu25 . nADDR = psCmdParam - > m_sDevAddr . m_uchCommAddr ;
bCAsdu25 . nFUN = psCmdParam - > m_uchFun ;
bCAsdu25 . nTOO = too ;
bCAsdu25 . nTOV = tov ;
bCAsdu25 . nFAN = fan ;
bCAsdu25 . nACC = acc ;
MakeBuban103LinkCommand ( commid , psCmdParam - > m_sDevAddr . m_uchLinkAddr , \
C_SD1_NA_3 , ( unsigned char * ) & bCAsdu25 , sizeof ( CASDU25 ) , INSERT_POLL_CMD ) ;
}
//*************************************************************
//* <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȵIJ<C8B5> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> *
//*<2A> <> <EFBFBD> <EFBFBD> :u_32 commid:RTU<54> ˿ں<CBBF> *
//*<2A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> u_char addr:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ
//*************************************************************
void MakeQCC_CAsdu88 ( u_32 commid , CMDPARAM * psCmdParam )
{
CASDU88 bCAsdu88 ;
memset ( & bCAsdu88 , 0 , sizeof ( CASDU88 ) ) ;
bCAsdu88 . nTYP = C_CI_NA_3 ;
bCAsdu88 . nVSQ = 0x81 ;
bCAsdu88 . nCOT = C_CAUSE_CYCLE ;
bCAsdu88 . nADDR = psCmdParam - > m_sDevAddr . m_uchCommAddr ;
// ??? wen 2003.11.03 bu(1)---bu(6)
bCAsdu88 . nFUN = 1 ; // BU(1)
bCAsdu88 . nINF = 0 ;
// ʹ <> ö<EFBFBD> <C3B6> <EFBFBD> <E1B2BB> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> yizhonghu 20060803
//bCAsdu88.nQCC = 5;
bCAsdu88 . nQCC = 45 ;
bCAsdu88 . nRII = psCmdParam - > m_uchRII ;
MakeBuban103LinkCommand ( commid , psCmdParam - > m_sDevAddr . m_uchLinkAddr , \
C_SD2_NA_3 , ( unsigned char * ) & bCAsdu88 , sizeof ( CASDU88 ) , NORMAL_POLL_CMD ) ;
}
void MakeBuban103_PL1_NA_3_Cmd ( int commid , DEVADDRPARAM * psAddrParam )
{
BUBAN103PORTPARAM * pPortParam ;
BUBAN103LINKDEF * pLinkParam ;
if ( IsExtInfoPtr ( commid ) = = FALSE )
{
return ;
}
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
pLinkParam = ( BUBAN103LINKDEF * ) & pPortParam - > m_psLink [ psAddrParam - > m_iLinkIdx ] ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 豸װ<E8B1B8> <D7B0>
if ( pLinkParam - > m_iDevNum > 1 )
{
if ( pLinkParam - > m_iQueryedAddr_CLASS1 ! = ( psAddrParam - > m_iDevIdx + 1 ) )
{
pLinkParam - > m_iQueryedAddr_CLASS1 = psAddrParam - > m_iDevIdx + 1 ;
pLinkParam - > m_iQueryNum_CLASS1_Count = 1 ;
MakeBuban103LinkCommand ( commid , psAddrParam - > m_uchLinkAddr , \
C_PL1_NA_3 , NULL , 0 , INSERT_POLL_CMD ) ;
}
// <20> <> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> ж<EFBFBD> <D0B6> <EFBFBD> װ<EFBFBD> õ<EFBFBD> <C3B5> <EFBFBD> <EFBFBD> <EFBFBD>
else if ( pLinkParam - > m_uchLinkAddr ! = 0xFF )
{
pLinkParam - > m_iQueryNum_CLASS1_Count = 0 ;
MakeBuban103LinkCommand ( commid , \
psAddrParam - > m_uchLinkAddr , \
C_PL1_NA_3 , NULL , 0 , INSERT_POLL_CMD ) ;
}
else
{
if ( pLinkParam - > m_iQueryNum_CLASS1_Count < pLinkParam - > m_iQueryNum_CLASS1_Const )
{
pLinkParam - > m_iQueryNum_CLASS1_Count + + ;
MakeBuban103LinkCommand ( commid , psAddrParam - > m_uchLinkAddr , \
C_PL1_NA_3 , NULL , 0 , INSERT_POLL_CMD ) ;
}
else
{
pLinkParam - > m_iQueryedAddr_CLASS1 = 0 ;
pLinkParam - > m_iQueryNum_CLASS1_Count = 0 ;
}
}
}
else
{
MakeBuban103LinkCommand ( commid , psAddrParam - > m_uchLinkAddr , \
C_PL1_NA_3 , NULL , 0 , INSERT_POLL_CMD ) ;
}
}
BOOL IsDevLinkOk ( BUBAN103LINKDEF * psLinkParam , int iDevNo )
{
if ( psLinkParam - > m_uchLinkAddr = = 0xFF )
{
return psLinkParam - > m_pbLinkOk [ iDevNo ] ;
}
else
{
return psLinkParam - > m_pbLinkOk [ 0 ] ;
}
}
void SetDevLinkOk ( BUBAN103LINKDEF * psLinkParam , int iDevNo , BOOL bFlagOk )
{
if ( psLinkParam - > m_uchLinkAddr = = 0xFF )
{
psLinkParam - > m_pbLinkOk [ iDevNo ] = bFlagOk ;
psLinkParam - > m_pu32LinkOkCnt [ iDevNo ] = 0 ;
}
else
{
psLinkParam - > m_pbLinkOk [ 0 ] = bFlagOk ;
psLinkParam - > m_pu32LinkOkCnt [ 0 ] = 0 ;
}
}
void ClearLinkCnt ( BUBAN103LINKDEF * psLinkParam , int iDevNo )
{
if ( psLinkParam - > m_uchLinkAddr = = 0xFF )
{
psLinkParam - > m_pu32LinkOkCnt [ iDevNo ] = 0 ;
}
else
{
psLinkParam - > m_pu32LinkOkCnt [ 0 ] = 0 ;
}
}
BYTE GetLinkAddr ( BUBAN103LINKDEF * psLinkParam , int iDevNo )
{
if ( psLinkParam - > m_uchLinkAddr = = 0xFF )
{
return psLinkParam - > m_psDev [ iDevNo ] . m_sDevParam . m_u8DevAddr ;
}
else
{
return psLinkParam - > m_uchLinkAddr ;
}
}
BYTE * GetLinkCtrl ( BUBAN103LINKDEF * psLinkParam , int iDevNo )
{
if ( psLinkParam - > m_uchLinkAddr = = 0xFF )
{
return & psLinkParam - > m_pu8CtlByte [ iDevNo ] ;
}
else
{
return & psLinkParam - > m_pu8CtlByte [ 0 ] ;
}
}
BOOL IsLinkTimeOut ( BUBAN103LINKDEF * psLinkParam , int iDevNo )
{
int iNo ;
iNo = iDevNo ;
psLinkParam - > m_pu32LinkOkCnt [ iNo ] + + ;
if ( psLinkParam - > m_pu32LinkOkCnt [ iNo ] \
> = psLinkParam - > m_u32TimeOutConst )
{
return TRUE ;
}
return FALSE ;
}
//***************************************************************
//* ָ<> <EFBFBD> <EEB7A2> *
//*<2A> <> <EFBFBD> <EFBFBD> :u_32 commid : RTU<54> ˿ں<CBBF> *
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> *
//***************************************************************
void Buban103SendCmdFormPollCmdBuf ( int commid )
{
BYTE fcb = 0x20 ;
BYTE * pu8CtrlByte , buf [ 256 ] ;
i_32 len ;
DAY_TIME sDateTime ;
DEVADDRPARAM DevAddrParam ;
BUBAN103PORTPARAM * pPortParam ;
if ( ( commid < 0 ) | | ( commid > = GetMaxPort ( ) ) )
{
return ;
}
if ( ! ShmGetPortFlag ( commid , FLAG_OPEN ) )
{
return ;
}
pPortParam = ( BUBAN103PORTPARAM * ) 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 )
{
len = ReGetCmdFormPollCmdBuf ( commid , buf , MAX_MSG_BUF_SIZE ) ;
if ( buf [ 2 ] = = 0x10 )
{
DevAddrParam . m_uchLinkAddr = buf [ 4 ] ;
if ( FindProtectDev ( pPortParam , & DevAddrParam , TRUE ) = = TRUE )
{
if ( pPortParam - > m_psLink [ DevAddrParam . m_iLinkIdx ] . m_uchLinkAddr ! = 0xFF )
{
InitBuban103LinkCmdBuf ( & pPortParam - > m_psLink [ DevAddrParam . m_iLinkIdx ] ) ;
}
else
{
DevAddrParam . m_uchCommAddr = buf [ 4 ] ;
InitBuban103DevCmdBuf ( & pPortParam - > m_psLink [ DevAddrParam . m_iLinkIdx ] , DevAddrParam . m_iDevIdx ) ;
}
}
}
else if ( buf [ 2 ] = = 0x68 )
{
DevAddrParam . m_uchLinkAddr = buf [ 7 ] ;
DevAddrParam . m_uchCommAddr = buf [ 11 ] ;
if ( FindProtectDev ( pPortParam , & DevAddrParam , FALSE ) = = TRUE )
{
InitBuban103DevCmdBuf ( & pPortParam - > m_psLink [ DevAddrParam . m_iLinkIdx ] , DevAddrParam . m_iDevIdx ) ;
}
}
else
{
pPortParam - > m_psBaoHu - > RevCmdFlag = 1 ;
}
// <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 - > 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 , MAX_MSG_BUF_SIZE ) ;
}
else
{
len = GetCmdFormPollCmdBuf ( commid , buf , MAX_MSG_BUF_SIZE ) ;
}
if ( len < 7 )
{
return ;
}
# ifndef OS_LINUX
if ( isUdpSocketExist ( ) = = TRUE )
# endif
{
if ( buf [ 2 ] = = 0x10 )
{
DevAddrParam . m_uchLinkAddr = buf [ 4 ] ;
if ( FindProtectDev ( pPortParam , & DevAddrParam , TRUE ) = = FALSE )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD>
ClearCmdFormPollCmdBuf ( commid ) ;
//ClearCmdAllFlag(commid);
return ;
}
if ( PROTOCOL_MASTER = = pPortParam - > m_psBaoHu - > PortType )
{
if ( pPortParam - > m_psBaoHu - > ReSendCmdFlag )
{
pu8CtrlByte = GetLinkCtrl ( & pPortParam - > m_psLink [ DevAddrParam . m_iLinkIdx ] , DevAddrParam . m_iDevIdx ) ;
* pu8CtrlByte = ~ ( * pu8CtrlByte ) ;
}
pu8CtrlByte = GetLinkCtrl ( & pPortParam - > m_psLink [ DevAddrParam . m_iLinkIdx ] , DevAddrParam . m_iDevIdx ) ;
buf [ 3 ] | = ( fcb & * pu8CtrlByte ) ;
* pu8CtrlByte = ~ ( * pu8CtrlByte ) ;
}
else
{
if ( ProvHaveClassOne ( commid , & DevAddrParam , pPortParam - > m_bSendChangeDi ) = = TRUE )
{
buf [ 3 ] | = 0x20 ;
}
}
buf [ 5 ] = CalBuban103Lpc ( & buf [ 3 ] , 2 ) ;
}
else if ( buf [ 2 ] = = 0x68 )
{
DevAddrParam . m_uchLinkAddr = buf [ 7 ] ;
DevAddrParam . m_uchCommAddr = buf [ 11 ] ;
if ( 0xFF ! = DevAddrParam . m_uchLinkAddr )
{
if ( FindProtectDev ( pPortParam , & DevAddrParam , FALSE ) = = FALSE )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD>
ClearCmdFormPollCmdBuf ( commid ) ;
//ClearCmdAllFlag(commid);
return ;
}
if ( PROTOCOL_MASTER = = pPortParam - > m_psBaoHu - > PortType )
{
if ( pPortParam - > m_psBaoHu - > ReSendCmdFlag )
{
pu8CtrlByte = GetLinkCtrl ( & pPortParam - > m_psLink [ DevAddrParam . m_iLinkIdx ] , DevAddrParam . m_iDevIdx ) ;
* pu8CtrlByte = ~ ( * pu8CtrlByte ) ;
}
pu8CtrlByte = GetLinkCtrl ( & pPortParam - > m_psLink [ DevAddrParam . m_iLinkIdx ] , DevAddrParam . m_iDevIdx ) ;
buf [ 6 ] | = ( fcb & * pu8CtrlByte ) ;
//if(buf[7] != 0xFF)
//{
// *pu8CtrlByte = ~(*pu8CtrlByte);
//}
* pu8CtrlByte = ~ ( * pu8CtrlByte ) ;
}
else
{
if ( ProvHaveClassOne ( commid , & DevAddrParam , pPortParam - > m_bSendChangeDi ) = = TRUE )
{
buf [ 6 ] | = 0x20 ;
}
}
}
if ( ( buf [ 8 ] = = C_SYN_TA_3 ) & & ( buf [ 3 ] = = 15 ) )
{
GetLocalTimeEx ( & sDateTime ) ;
sDateTime . mSec = sDateTime . Sec * 1000 + sDateTime . mSec ;
buf [ 14 ] = sDateTime . mSec % 256 ;
buf [ 15 ] = sDateTime . mSec / 256 ;
buf [ 16 ] = ( u_char ) sDateTime . Min ;
buf [ 17 ] = ( u_char ) sDateTime . Hour ;
buf [ 18 ] = ( u_char ) ( sDateTime . Day & 0x1F ) ;
buf [ 19 ] = ( u_char ) sDateTime . Month ;
buf [ 20 ] = ( u_char ) ( sDateTime . Year % 100 ) ;
}
buf [ buf [ 3 ] + 6 ] = CalBuban103Lpc ( & buf [ 6 ] , buf [ 3 ] ) ;
}
else
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD>
ClearCmdFormPollCmdBuf ( commid ) ;
//ClearCmdAllFlag(commid);
return ;
}
SendDataToPort ( commid , ( char * ) & buf [ 2 ] , len - 2 ) ;
pPortParam - > m_psBaoHu - > SendCmdFlag = 1 ;
pPortParam - > m_psBaoHu - > ReSendCmdFlag = 0 ;
pPortParam - > m_psBaoHu - > RevCmdFlag = 0 ;
}
# ifdef OS_LINUX
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>
}
}
}
/*!
\ 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 Buban103FindNextCmd ( int commid )
{
int i , j , iCurCmdIdx ;
BYTE * pu8CtrlByte ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
if ( ( commid < 0 ) | | ( commid > = GetMaxPort ( ) ) )
{
return ;
}
if ( ! ShmGetPortFlag ( commid , FLAG_OPEN ) )
{
return ;
}
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
//<2F> <> <EFBFBD> е <EFBFBD> <D0B5> <EFBFBD> <EFBFBD> ʱ<EEB6A8> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> +1
for ( i = 0 ; i < pPortParam - > m_iLinkNum ; i + + )
{
pLinkParam = & pPortParam - > m_psLink [ i ] ;
for ( j = 0 ; j < BUBAN103_TIMER_CMD_NUM ; j + + )
{
if ( pLinkParam - > m_sArrayCmdTime [ j ] . m_iCmdTimerConst > 0 )
{
pLinkParam - > m_sArrayCmdTime [ j ] . m_iCmdTimerCnt + + ;
}
}
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEBBBA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEA3AC> <EFBFBD> ˳<EFBFBD> <CBB3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( CheckPollCmdBufEmpty ( commid ) < = 0 )
{
return ;
}
pLinkParam = & pPortParam - > m_psLink [ pPortParam - > m_iLinkIdx ] ;
//ÿ<> <C3BF> <EFBFBD> <EFBFBD> ַ<EFBFBD> ·<EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> ѭ<EEA3AC> <D1AD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( pLinkParam - > m_iDevIdx > = pLinkParam - > m_iDevNum - 1 )
{
pLinkParam - > m_iDevIdx = 0 ;
pPortParam - > m_iLinkIdx = ( pPortParam - > m_iLinkIdx + 1 ) % pPortParam - > m_iLinkNum ;
pLinkParam = & pPortParam - > m_psLink [ pPortParam - > m_iLinkIdx ] ;
pLinkParam - > m_iDevIdx = 0 ;
}
else
{
pLinkParam - > m_iDevIdx + + ;
}
//<2F> ж<EFBFBD> <D0B6> <EFBFBD> ·<EFBFBD> <C2B7> ״̬<D7B4> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> δ<EFBFBD> <CEB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> δʵ<CEB4> ֣<EFBFBD> <D6A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·״̬<D7B4> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ѯ<EFBFBD> <D1AF> ·״̬<D7B4> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> ˳<EFBFBD> <CBB3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĺ<EFBFBD> <C4BA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pDevParam = & pLinkParam - > m_psDev [ pLinkParam - > m_iDevIdx ] ;
if ( IsDevLinkOk ( pLinkParam , pLinkParam - > m_iDevIdx ) = = FALSE )
{
// һ <> <D2BB> <EFBFBD> <EFBFBD> ·һ <C2B7> <D2BB> ѭ<EFBFBD> <D1AD> ֻ<EFBFBD> <D6BB> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> λ
if ( ( pLinkParam - > m_uchLinkAddr ! = 0xFF )
& & ( pLinkParam - > m_iDevIdx ! = 0 ) )
{
pLinkParam - > m_iDevIdx = pLinkParam - > m_iDevNum - 1 ;
return ;
}
pu8CtrlByte = GetLinkCtrl ( pLinkParam , pLinkParam - > m_iDevIdx ) ;
* pu8CtrlByte = 0 ;
MakeBuban103LinkCommand ( commid ,
GetLinkAddr ( pLinkParam , pLinkParam - > m_iDevIdx ) ,
C_RCU_NA_3 , NULL , 0 , NORMAL_POLL_CMD ) ;
return ;
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˱<EFBFBD> <CBB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <CDB9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEA3AC> <EFBFBD> <EFBFBD> δ<EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD>
if ( pDevParam - > m_bInitdata = = TRUE )
{
pDevParam - > m_u32CallCnt + + ;
if ( pDevParam - > m_u32CallCnt < pLinkParam - > m_u32TimeOutConst )
{
if ( IsDevLinkOk ( pLinkParam , pLinkParam - > m_iDevIdx ) = = TRUE )
{
MakeBuban103LinkCommand ( commid , \
GetLinkAddr ( pLinkParam , pLinkParam - > m_iDevIdx ) , \
C_PL2_NA_3 , NULL , 0 , NORMAL_POLL_CMD ) ;
return ;
}
}
else
{
pDevParam - > m_u32CallCnt = 0 ;
pDevParam - > m_bInitdata = FALSE ;
}
}
//<2F> ж<EFBFBD> <D0B6> з<D0B7> <F1B1A3BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( IsDevLinkOk ( pLinkParam , pLinkParam - > m_iDevIdx ) = = TRUE )
{
// wen 2004.02.11 <20> ı <DEB8> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> (<28> <> ʱû<CAB1> <C3BB> <EFBFBD> ·<EFBFBD> )
//seladdr = (u_char)(*(WORD*)&gBuban103_RtuMsg.MsgData[0]);
//if((gBuban103_RtuMsg.MsgLen > 0) && (gBuban103_RtuMsg.PortNumber == commid))
//{
// itmpBuIdx = FindMatchingBuIdx(commid, seladdr);
// if(itmpBuIdx >= 0)
// {
// MakeBuban103BaohuCommand();
// Buban103PortParam[commid][selidx][iBuIdx].CallCnt = 0;
// Buban103PortParam[commid][selidx][iBuIdx].RstLinkOk = true;
// memset((char*)&gBuban103_RtuMsg, 0, sizeof(gBuban103_RtuMsg));
// return;
// }
//}
}
iCurCmdIdx = pLinkParam - > m_shCurCmdIdx ;
if ( pDevParam - > m_bAllQueryOk = = TRUE )
{
for ( i = 0 ; i < BUBAN103_TIMER_CMD_NUM ; i + + )
{
if ( pLinkParam - > m_sArrayCmdTime [ iCurCmdIdx ] . m_iCmdTimerConst > 0 )
{
if ( pLinkParam - > m_sArrayCmdTime [ iCurCmdIdx ] . m_iCmdTimerCnt \
> pLinkParam - > m_sArrayCmdTime [ iCurCmdIdx ] . m_iCmdTimerConst )
{
break ;
}
}
iCurCmdIdx = ( iCurCmdIdx + 1 ) % BUBAN103_TIMER_CMD_NUM ;
}
pLinkParam - > m_shCurCmdIdx = iCurCmdIdx ;
if ( i > = BUBAN103_TIMER_CMD_NUM )
{
pPortParam - > m_iLinkIdx = ( pPortParam - > m_iLinkIdx + 1 ) % pPortParam - > m_iLinkNum ;
}
else
{
MakeBuban103PollingCmd ( commid , pLinkParam , iCurCmdIdx ) ;
pLinkParam - > m_iDevIdx = ( pLinkParam - > m_iDevIdx + 1 ) % pLinkParam - > m_iDevNum ;
if ( pLinkParam - > m_iDevIdx = = 0 )
{
pLinkParam - > m_sArrayCmdTime [ iCurCmdIdx ] . m_iCmdTimerCnt = 0 ;
pLinkParam - > m_shCurCmdIdx = ( pLinkParam - > m_shCurCmdIdx + 1 ) % BUBAN103_TIMER_CMD_NUM ;
pPortParam - > m_iLinkIdx = ( pPortParam - > m_iLinkIdx + 1 ) % pPortParam - > m_iLinkNum ;
}
}
}
//<2F> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> 䲻ͣ<E4B2BB> <CDA3> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( IsDevLinkOk ( pLinkParam , pLinkParam - > m_iDevIdx ) = = TRUE )
{
if ( CheckPollCmdBufEmpty ( commid ) < = 0 )
{
return ;
}
MakeBuban103LinkCommand ( commid , \
GetLinkAddr ( pLinkParam , pLinkParam - > m_iDevIdx ) , \
C_PL2_NA_3 , NULL , 0 , NORMAL_POLL_CMD ) ;
}
}
BOOL Buban103FindNextCmdEx ( int commid )
{
int i , j , iCurCmdIdx ;
BYTE * pu8CtrlByte ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
//char szbuf[128];
if ( ( commid < 0 ) | | ( commid > = GetMaxPort ( ) ) )
{
return FALSE ;
}
if ( ! ShmGetPortFlag ( commid , FLAG_OPEN ) )
{
return FALSE ;
}
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
/*
char szbuf [ 256 ] ;
FILE * fp ;
DAY_TIME sTime ;
fp = NULL ;
if ( commid = = 6 )
{
getcwd ( szbuf , sizeof ( szbuf ) ) ;
sprintf ( szbuf , " %s/log/cmdtime.txt " , szbuf ) ;
fp = fopen ( szbuf , " a " ) ;
GetLocalTimeEx ( & sTime ) ;
sprintf ( szbuf , " wen: %02d:%02d:%02d.%03d, commid=%d calc pollcmd count. \n " , sTime . Hour , sTime . Min , sTime . Sec , sTime . mSec , commid ) ;
//DebugPrint(szbuf);
if ( fp )
fwrite ( szbuf , 1 , strlen ( szbuf ) , fp ) ;
}
*/
//<2F> <> <EFBFBD> е <EFBFBD> <D0B5> <EFBFBD> <EFBFBD> ʱ<EEB6A8> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> +1
for ( i = 0 ; i < pPortParam - > m_iLinkNum ; i + + )
{
pLinkParam = & pPortParam - > m_psLink [ i ] ;
if ( ! IsDevLinkOk ( pLinkParam , i ) )
{
continue ;
}
for ( j = 0 ; j < BUBAN103_TIMER_CMD_NUM ; j + + )
{
if ( pLinkParam - > m_sArrayCmdTime [ j ] . m_iCmdTimerConst > 0 )
{
pLinkParam - > m_sArrayCmdTime [ j ] . m_iCmdTimerCnt + + ;
}
}
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEBBBA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEA3AC> <EFBFBD> ˳<EFBFBD> <CBB3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( CheckPollCmdBufEmpty ( commid ) < = 0 )
{
return FALSE ;
}
pLinkParam = & pPortParam - > m_psLink [ pPortParam - > m_iLinkIdx ] ;
pDevParam = & pLinkParam - > m_psDev [ pLinkParam - > m_iDevIdx ] ;
if ( IsDevLinkOk ( pLinkParam , pLinkParam - > m_iDevIdx ) = = FALSE )
{
// һ <> <D2BB> <EFBFBD> <EFBFBD> ·һ <C2B7> <D2BB> ѭ<EFBFBD> <D1AD> ֻ<EFBFBD> <D6BB> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> λ
if ( ( pLinkParam - > m_uchLinkAddr ! = 0xFF ) \
& & ( pLinkParam - > m_iDevIdx ! = 0 ) )
{
pLinkParam - > m_iDevIdx = pLinkParam - > m_iDevNum - 1 ;
return TRUE ;
}
pu8CtrlByte = GetLinkCtrl ( pLinkParam , pLinkParam - > m_iDevIdx ) ;
* pu8CtrlByte = 0 ;
MakeBuban103LinkCommand ( commid ,
GetLinkAddr ( pLinkParam , pLinkParam - > m_iDevIdx ) ,
C_RCU_NA_3 , NULL , 0 , NORMAL_POLL_CMD ) ;
return TRUE ;
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˱<EFBFBD> <CBB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <CDB9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEA3AC> <EFBFBD> <EFBFBD> δ<EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD>
if ( pDevParam - > m_bInitdata = = TRUE )
{
pDevParam - > m_u32CallCnt + + ;
if ( pDevParam - > m_u32CallCnt < pLinkParam - > m_u32TimeOutConst )
{
if ( IsDevLinkOk ( pLinkParam , pLinkParam - > m_iDevIdx ) = = TRUE )
{
MakeBuban103LinkCommand ( commid , \
GetLinkAddr ( pLinkParam , pLinkParam - > m_iDevIdx ) , \
C_PL2_NA_3 , NULL , 0 , NORMAL_POLL_CMD ) ;
return TRUE ;
}
}
else
{
pDevParam - > m_u32CallCnt = 0 ;
pDevParam - > m_bInitdata = FALSE ;
}
}
//<2F> ж<EFBFBD> <D0B6> з<D0B7> <F1B1A3BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( IsDevLinkOk ( pLinkParam , pLinkParam - > m_iDevIdx ) = = TRUE )
{
// wen 2004.02.11 <20> ı <DEB8> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> (<28> <> ʱû<CAB1> <C3BB> <EFBFBD> ·<EFBFBD> )
//seladdr = (u_char)(*(WORD*)&gBuban103_RtuMsg.MsgData[0]);
//if((gBuban103_RtuMsg.MsgLen > 0) && (gBuban103_RtuMsg.PortNumber == commid))
//{
// itmpBuIdx = FindMatchingBuIdx(commid, seladdr);
// if(itmpBuIdx >= 0)
// {
// MakeBuban103BaohuCommand();
// Buban103PortParam[commid][selidx][iBuIdx].CallCnt = 0;
// Buban103PortParam[commid][selidx][iBuIdx].RstLinkOk = true;
// memset((char*)&gBuban103_RtuMsg, 0, sizeof(gBuban103_RtuMsg));
// return;
// }
//}
}
if ( pLinkParam - > m_shCurCmdIdx < BUBAN103_TIMER_CMD_NUM )
{
iCurCmdIdx = pLinkParam - > m_shCurCmdIdx ;
}
else
{
iCurCmdIdx = 0 ;
}
if ( pDevParam - > m_bAllQueryOk = = TRUE )
{
for ( i = 0 ; i < BUBAN103_TIMER_CMD_NUM ; i + + )
{
if ( iCurCmdIdx > = BUBAN103_TIMER_CMD_NUM )
{
break ;
}
if ( pLinkParam - > m_sArrayCmdTime [ iCurCmdIdx ] . m_iCmdTimerConst > 0 )
{
if ( pLinkParam - > m_sArrayCmdTime [ iCurCmdIdx ] . m_iCmdTimerCnt \
> pLinkParam - > m_sArrayCmdTime [ iCurCmdIdx ] . m_iCmdTimerConst )
{
break ;
}
}
iCurCmdIdx + + ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> µ<EFBFBD> <C2B5> <EFBFBD> ѯָ<D1AF> <EFBFBD> <EEA3AC> <EFBFBD> ӵ<EFBFBD> һ <EFBFBD> <D2BB> װ<EFBFBD> ÿ<EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8>
if ( pLinkParam - > m_shCurCmdIdx ! = iCurCmdIdx )
{
pLinkParam - > m_iDevIdx = 0 ;
pLinkParam - > m_shCurCmdIdx = iCurCmdIdx ;
}
if ( iCurCmdIdx < BUBAN103_TIMER_CMD_NUM )
{
//if(iCurCmdIdx == 0)
//{
/ / sprintf ( szbuf , " %d<> ˿<EFBFBD> ʱ<EFBFBD> <CAB1> ͬ<EFBFBD> <CDAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> =%d,<2C> <> <EFBFBD> <EFBFBD> =%d " , commid + 1 , pLinkParam - > m_sArrayCmdTime [ iCurCmdIdx ] . m_iCmdTimerConst , \
// pLinkParam->m_sArrayCmdTime[iCurCmdIdx].m_iCmdTimerCnt);
// DebugPrint(szbuf);
// }
MakeBuban103PollingCmd ( commid , pLinkParam , iCurCmdIdx ) ;
if ( pLinkParam - > m_iDevIdx > = ( pLinkParam - > m_iDevNum - 1 ) )
{
pLinkParam - > m_sArrayCmdTime [ iCurCmdIdx ] . m_iCmdTimerCnt = 0 ;
}
return TRUE ;
}
}
//<2F> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> 䲻ͣ<E4B2BB> <CDA3> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//if(IsDevLinkOk(pLinkParam, pLinkParam->m_iDevIdx) == TRUE)
//{
//if(CheckPollCmdBufEmpty(commid) <= 0)
//{
// return;
//}
/ / MakeBuban103LinkCommand ( commid , \
/ / GetLinkAddr ( pLinkParam , pLinkParam - > m_iDevIdx ) , \
// C_PL2_NA_3, NULL, 0, NORMAL_POLL_CMD);
// return TRUE;
//}
MakeBuban103LinkCommand ( commid , \
GetLinkAddr ( pLinkParam , pLinkParam - > m_iDevIdx ) , \
C_PL2_NA_3 , NULL , 0 , NORMAL_POLL_CMD ) ;
return TRUE ;
}
void Buban103CalcNextDev ( int commid , BOOL bFlag )
{
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
//printf("Buban103CalcNextDev: commid_%d\n", commid);
if ( FALSE = = GetPortParamPtr ( commid , & pPortParam ) )
{
return ;
}
if ( ! ShmGetPortFlag ( commid , FLAG_OPEN ) )
{
return ;
}
//printf("Buban103CalcNextDev: LinkIdx=%d, LinkNum=%d\n", pPortParam->m_iLinkIdx, pPortParam->m_iLinkNum);
//return;
if ( pPortParam - > m_iLinkIdx > = pPortParam - > m_iLinkNum )
{
pPortParam - > m_iLinkIdx = 0 ;
pLinkParam = & pPortParam - > m_psLink [ pPortParam - > m_iLinkIdx ] ;
pLinkParam - > m_iDevIdx = 0 ;
}
else
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> װ<EFBFBD> ü<EFBFBD> <C3BC> <EFBFBD>
pLinkParam = & pPortParam - > m_psLink [ pPortParam - > m_iLinkIdx ] ;
if ( FALSE = = bFlag )
{
if ( ( pLinkParam - > m_uchLinkAddr ! = 0xFF ) \
& & ( pLinkParam - > m_iDevNum > 1 ) )
{
pDevParam = & pLinkParam - > m_psDev [ pLinkParam - > m_iDevIdx ] ;
if ( pDevParam - > m_bAllQueryOk = = FALSE )
{
pLinkParam - > m_bGotoNext = TRUE ;
return ;
}
// else if(<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ķ<EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> 䲻<EFBFBD> <E4B2BB> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> <EFBFBD> л<EFBFBD> <D0BB> <EFBFBD> <EFBFBD> ж<EFBFBD> )
}
}
// <20> <> һ <EFBFBD> <D2BB> װ<EFBFBD> <D7B0> <EFBFBD> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ժ<EFBFBD> <D4BA> ļ<EFBFBD> <C4BC> <EFBFBD>
else
{
pDevParam = & pLinkParam - > m_psDev [ pLinkParam - > m_iDevIdx ] ;
if ( pLinkParam - > m_bGotoNext = = FALSE )
{
return ;
}
if ( pDevParam - > m_bAllQueryOk = = TRUE )
{
return ;
}
// else if(<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ķ<EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> 䲻<EFBFBD> <E4B2BB> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> <EFBFBD> л<EFBFBD> <D0BB> <EFBFBD> <EFBFBD> ж<EFBFBD> )
}
pLinkParam - > m_bGotoNext = FALSE ;
pLinkParam - > m_iDevIdx + + ;
if ( pLinkParam - > m_iDevIdx > = pLinkParam - > m_iDevNum )
{
pLinkParam - > m_iDevIdx = 0 ;
pPortParam - > m_iLinkIdx = ( pPortParam - > m_iLinkIdx + 1 ) % pPortParam - > m_iLinkNum ;
pLinkParam = & pPortParam - > m_psLink [ pPortParam - > m_iLinkIdx ] ;
pLinkParam - > m_iDevIdx = 0 ;
}
}
}
//***************************************************************************/
//* <20> <> ʱ<EFBFBD> <CAB1> ѯ<EFBFBD> <D1AF> 103ָ<33> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> ɺ<EFBFBD> <C9BA> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> :u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//* i_32 CmdIdx : ָ<> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:BOOL retval : ָ<> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> ɳɹ<C9B3> <C9B9> <EFBFBD> ʶ */
//***************************************************************************/
void MakeBuban103PollingCmd ( int commid , BUBAN103LINKDEF * psLinkParam , i_32 CmdIdx )
{
i_32 i ;
DEVDEF * pDevParam ;
CMDPARAM CmdParam ;
GEN_DATAGROUP sGenDataGroup ;
//#ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
//#endif
pDevParam = & psLinkParam - > m_psDev [ psLinkParam - > m_iDevIdx ] ;
switch ( CmdIdx )
{
case 0 : // ʱ<> <CAB1> ͬ<EFBFBD> <CDAC>
// <20> 㲥<EFBFBD> <E3B2A5> ʱ<EFBFBD> <CAB1> ִ<EFBFBD> <D6B4> һ <EFBFBD> <D2BB>
sprintf ( szbuf , " port=%d,<2C> 㲥<EFBFBD> <E3B2A5> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> " , commid + 1 ) ;
DebugPrint ( szbuf ) ;
psLinkParam - > m_sArrayCmdTime [ CmdIdx ] . m_iCmdTimerCnt = 0 ;
CmdParam . m_sDevAddr . m_uchLinkAddr = 0xFF ;
CmdParam . m_sDevAddr . m_uchCommAddr = 0xFF ;
CmdParam . m_uchFun = ( u_char ) pDevParam - > m_sDevParam . m_sSyncTimeInfo . m_u8Fun ;
CmdParam . m_uchInf = ( u_char ) pDevParam - > m_sDevParam . m_sSyncTimeInfo . m_u8Inf ;
CmdParam . m_uchRII = pDevParam - > m_u8RII ;
MakeTimeSyn_CAsdu6 ( commid , & CmdParam ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ǰָ<C7B0> ָ<EEA3AC> <D6B8> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> ·
psLinkParam - > m_iDevIdx = psLinkParam - > m_iDevNum - 1 ;
break ;
case 1 : // <20> ܲ<EFBFBD> ѯ
CmdParam . m_sDevAddr . m_uchLinkAddr = psLinkParam - > m_uchLinkAddr ;
CmdParam . m_sDevAddr . m_uchCommAddr = pDevParam - > m_sDevParam . m_u8DevAddr ;
if ( FALSE = = FindProtectDev ( ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo , & CmdParam . m_sDevAddr , FALSE ) )
{
break ;
}
MakeAllQuery_CAsdu7 ( commid , & CmdParam ) ;
break ;
case 2 : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ѯ
CmdParam . m_sDevAddr . m_uchLinkAddr = psLinkParam - > m_uchLinkAddr ;
CmdParam . m_sDevAddr . m_uchCommAddr = pDevParam - > m_sDevParam . m_u8DevAddr ;
if ( FALSE = = FindProtectDev ( ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo , & CmdParam . m_sDevAddr , FALSE ) )
{
break ;
}
CmdParam . m_uchRII = pDevParam - > m_u8RII ;
MakeQCC_CAsdu88 ( commid , & CmdParam ) ;
break ;
case 3 : // ģ<> <C4A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ѯ(ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
CmdParam . m_sDevAddr . m_uchLinkAddr = psLinkParam - > m_uchLinkAddr ;
CmdParam . m_sDevAddr . m_uchCommAddr = pDevParam - > m_sDevParam . m_u8DevAddr ;
if ( FALSE = = FindProtectDev ( ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo , & CmdParam . m_sDevAddr , FALSE ) )
{
break ;
}
for ( i = 0 ; i < pDevParam - > m_sDevParam . m_iCfgGroupNum ; i + + )
{
if ( AI_PNT_TYPE = = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iDataType )
{
break ;
}
}
if ( i = = pDevParam - > m_sDevParam . m_iCfgGroupNum )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ģ<EFBFBD> <C4A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ѯָ<D1AF> <D6B8> !!!\n " ,
commid , CmdParam . m_sDevAddr . m_uchLinkAddr , CmdParam . m_sDevAddr . m_uchCommAddr ) ;
//ǰ<> û<EFBFBD> վ<EFBFBD> <D5BE> =1
DebugPrint ( szbuf ) ;
# endif
break ;
}
CmdParam . m_uchInf = C_INF_READGROUPALLITEMS ;
sGenDataGroup . m_u8Grp = ( BYTE ) pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iGroupNo ;
sGenDataGroup . m_u8Itm = 0 ;
sGenDataGroup . m_u8KOD = KOD_ACTUALVALUE ;
CmdParam . m_uchRII = pDevParam - > m_u8RII ;
MakeGenIdentCommand_CAsdu21 ( commid , & CmdParam , & sGenDataGroup , 1 ) ;
break ;
case 4 : // ״̬<D7B4> <CCAC> <EFBFBD> <EFBFBD> ѯ(ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
CmdParam . m_sDevAddr . m_uchLinkAddr = psLinkParam - > m_uchLinkAddr ;
CmdParam . m_sDevAddr . m_uchCommAddr = pDevParam - > m_sDevParam . m_u8DevAddr ;
if ( FALSE = = FindProtectDev ( ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo , & CmdParam . m_sDevAddr , FALSE ) )
{
break ;
}
for ( i = 0 ; i < pDevParam - > m_sDevParam . m_iCfgGroupNum ; i + + )
{
if ( DI_PNT_TYPE = = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iDataType )
{
break ;
}
}
if ( i = = pDevParam - > m_sDevParam . m_iCfgGroupNum )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> <DDBF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ѯָ<D1AF> <D6B8> !!!\n " ,
commid , CmdParam . m_sDevAddr . m_uchLinkAddr , CmdParam . m_sDevAddr . m_uchCommAddr ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
CmdParam . m_uchInf = C_INF_READGROUPALLITEMS ;
sGenDataGroup . m_u8Grp = ( BYTE ) pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iGroupNo ;
sGenDataGroup . m_u8Itm = 0 ;
sGenDataGroup . m_u8KOD = KOD_ACTUALVALUE ;
CmdParam . m_uchRII = pDevParam - > m_u8RII ;
MakeGenIdentCommand_CAsdu21 ( commid , & CmdParam , & sGenDataGroup , 1 ) ;
break ;
default :
break ;
}
}
//===========================ָ<> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> ɺ<EFBFBD> <C9BA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> =========================
//===========================<3D> <> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <CEAA> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> =======================
//***************************************************************
//* <20> <> <EFBFBD> <EFBFBD> Buban103 <20> ۼӺͼ<D3BA> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> *
//* <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> BYTE* msg:<> <D7BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> Ϣ *
//* u_32 len:<> <D7BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> <EFBFBD> *
//***************************************************************
BYTE CalBuban103Lpc ( BYTE * msg , u_32 len )
{
u_32 i ;
char retval ;
retval = 0 ;
for ( i = 0 ; i < len ; i + + )
{
retval + = msg [ i ] ;
}
return retval ;
}
BOOL Buban103Check ( char * pData , int iDataLen )
{
BOOL bRetval ;
int iCheckLen ;
bRetval = FALSE ;
switch ( pData [ 0 ] )
{
case 0x10 : // <20> <> ֡
if ( pData [ 4 ] ! = 0x16 )
{
break ;
}
if ( CalBuban103Lpc ( ( BYTE * ) & pData [ 1 ] , 2 ) ! = ( BYTE ) pData [ 3 ] )
{
break ;
}
bRetval = TRUE ;
break ;
case 0x68 : // <20> <> ֡
if ( pData [ 0 ] ! = pData [ 3 ] )
{
break ;
}
if ( pData [ iDataLen - 1 ] ! = 0x16 )
{
break ;
}
if ( pData [ 1 ] ! = pData [ 2 ] )
{
break ;
}
iCheckLen = ( BYTE ) pData [ 1 ] ;
if ( CalBuban103Lpc ( ( BYTE * ) & pData [ 4 ] , iCheckLen ) ! = ( BYTE ) pData [ iDataLen - 2 ] )
{
break ;
}
bRetval = TRUE ;
break ;
default :
break ;
}
return bRetval ;
}
void Buban103ProcessData ( int commid , BUBAN103PORTPARAM * psPortParam , BOOL bProcess )
{
RTUMSG msg ;
BUBAN103PORTPARAM * pPortParam ;
/*
if ( FALSE = = GetPortParamPtr ( commid , & pPortParam ) )
{
return ;
}
*/
pPortParam = psPortParam ;
if ( TRUE = = bProcess )
{
msg . PortIdx = commid ;
//msg.MsgType = iCOMM_DATA;
msg . MsgLen = psPortParam - > m_iRecvLen ;
memcpy ( msg . MsgData , psPortParam - > m_achRecvBuf , msg . MsgLen ) ;
msg . MsgData [ msg . MsgLen ] = CHECK_WHOLE ;
msg . MsgData [ msg . MsgLen + 1 ] = 0 ;
// <20> <> վ<EFBFBD> <D5BE> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD>
if ( PROTOCOL_SLAVE = = pPortParam - > m_psBaoHu - > PortType )
{
ProvRtuProtocolDataProcess ( commid , & msg ) ;
return ;
}
// <20> <> վ<EFBFBD> <D5BE> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD>
switch ( msg . MsgData [ 0 ] )
{
case 0x68 :
Buban103longprocess ( & msg ) ;
break ;
case 0x10 :
Buban103shortprocess ( & msg ) ;
break ;
default :
break ;
}
}
// <20> <> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> ɺ<EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> ַ
Buban103CalcNextDev ( commid , TRUE ) ;
}
BOOL FindProtectDev ( BUBAN103PORTPARAM * psPortParam , \
DEVADDRPARAM * psAddrParam , \
BOOL bJudgeLinkOnly )
{
int i , j ;
BYTE uchAddr ;
BOOL bRetVal ;
bRetVal = FALSE ;
for ( i = 0 ; i < psPortParam - > m_iLinkNum ; i + + )
{
if ( psPortParam - > m_psLink [ i ] . m_uchLinkAddr ! = 0xFF )
{
if ( psPortParam - > m_psLink [ i ] . m_uchLinkAddr ! = psAddrParam - > m_uchLinkAddr )
{
continue ;
}
uchAddr = psAddrParam - > m_uchCommAddr ;
if ( bJudgeLinkOnly = = TRUE )
{
bRetVal = TRUE ;
psAddrParam - > m_iLinkIdx = i ;
psAddrParam - > m_iDevIdx = 0 ;
break ;
}
}
else
{
// װ<> õ<EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> ַ
uchAddr = psAddrParam - > m_uchLinkAddr ;
if ( psAddrParam - > m_uchLinkAddr = = 0xFF )
{
uchAddr = psAddrParam - > m_uchCommAddr ;
psAddrParam - > m_uchLinkAddr = uchAddr ;
}
}
for ( j = 0 ; j < psPortParam - > m_psLink [ i ] . m_iDevNum ; j + + )
{
if ( psPortParam - > m_psLink [ i ] . m_psDev ! = NULL )
{
if ( psPortParam - > m_psLink [ i ] . m_psDev [ j ] . m_sDevParam . m_u8DevAddr = = uchAddr )
{
break ;
}
}
else if ( psPortParam - > m_psLink [ i ] . m_psProvDev ! = NULL )
{
if ( psPortParam - > m_psLink [ i ] . m_psProvDev [ j ] . m_iProvAddr = = ( int ) uchAddr )
{
break ;
}
}
}
if ( j < psPortParam - > m_psLink [ i ] . m_iDevNum )
{
psAddrParam - > m_iLinkIdx = i ;
psAddrParam - > m_iDevIdx = j ;
bRetVal = TRUE ;
break ;
}
}
return bRetVal ;
}
BOOL FindProtectDevFromProvAddr ( BUBAN103PORTPARAM * psPortParam , \
DEVADDRPARAM * psAddrParam , \
int iProvAddr )
{
int i , j ;
BOOL bRetVal ;
DEVDEF * pDevParam ;
PROVDEVDEF * pProvDevParam ;
bRetVal = FALSE ;
for ( i = 0 ; i < psPortParam - > m_iLinkNum ; i + + )
{
for ( j = 0 ; j < psPortParam - > m_psLink [ i ] . m_iDevNum ; j + + )
{
if ( psPortParam - > m_psLink [ i ] . m_psDev ! = NULL )
{
pDevParam = & psPortParam - > m_psLink [ i ] . m_psDev [ j ] ;
if ( iProvAddr = = pDevParam - > m_sDevParam . m_iProvAddr )
{
psAddrParam - > m_iDevIdx = j ;
psAddrParam - > m_iLinkIdx = i ;
psAddrParam - > m_uchLinkAddr = psPortParam - > m_psLink [ i ] . m_uchLinkAddr ;
psAddrParam - > m_uchCommAddr = pDevParam - > m_sDevParam . m_u8DevAddr ;
bRetVal = TRUE ;
break ;
}
}
else if ( psPortParam - > m_psLink [ i ] . m_psProvDev ! = NULL )
{
pProvDevParam = & psPortParam - > m_psLink [ i ] . m_psProvDev [ j ] ;
if ( iProvAddr = = pProvDevParam - > m_iProvAddr )
{
psAddrParam - > m_iDevIdx = j ;
psAddrParam - > m_iLinkIdx = i ;
psAddrParam - > m_uchLinkAddr = 0 ;
psAddrParam - > m_uchCommAddr = 0 ;
bRetVal = TRUE ;
break ;
}
}
else
{
return FALSE ;
}
}
if ( bRetVal = = TRUE )
{
break ;
}
}
return bRetVal ;
}
BOOL FindProtectDevFromPntNo ( BUBAN103PORTPARAM * psPortParam , \
DEVADDRPARAM * psAddrParam , \
DBINFO * psDBInfo , \
int iPntNo , int itype )
{
int i , j , inum , ipnt ;
BOOL bRetVal , bProv ;
DEVDEF * pDevParam = NULL ;
PROVDEVDEF * pProvDevParam = NULL ;
DBORIENTATION * pDataUnit = NULL ;
bRetVal = FALSE ;
if ( psPortParam - > m_psLink [ 0 ] . m_psDev ! = NULL )
{
pProvDevParam = NULL ;
bProv = FALSE ;
}
else if ( psPortParam - > m_psLink [ 0 ] . m_psProvDev ! = NULL )
{
pDevParam = NULL ;
bProv = TRUE ;
}
else
{
return FALSE ;
}
for ( i = 0 ; i < psPortParam - > m_iLinkNum ; i + + )
{
for ( j = 0 ; j < psPortParam - > m_psLink [ i ] . m_iDevNum ; j + + )
{
if ( bProv = = FALSE )
{
pDevParam = & psPortParam - > m_psLink [ i ] . m_psDev [ j ] ;
switch ( itype )
{
case AI_PNT_TYPE :
pDataUnit = & pDevParam - > m_sDevParam . m_sAiDBOrientation [ 0 ] ;
break ;
case DI_PNT_TYPE :
pDataUnit = & pDevParam - > m_sDevParam . m_sDiDBOrientation ;
break ;
case PI_PNT_TYPE :
pDataUnit = & pDevParam - > m_sDevParam . m_sPiDBOrientation ;
break ;
default :
pDataUnit = NULL ;
break ;
}
}
else
{
pProvDevParam = & psPortParam - > m_psLink [ i ] . m_psProvDev [ j ] ;
switch ( itype )
{
case DI_PNT_TYPE :
pDataUnit = & pProvDevParam - > m_sYxInfo ;
break ;
case AI_PNT_TYPE :
case PI_PNT_TYPE :
default :
pDataUnit = NULL ;
break ;
}
}
if ( pDataUnit = = NULL )
{
continue ;
}
if ( AI_PNT_TYPE = = itype )
{
for ( inum = 0 ; inum < DEV_AI_MAXNUM ; inum + + )
{
if ( pDataUnit [ inum ] . m_iPntNum < = 0 )
{
break ;
}
ipnt = iPntNo - pDataUnit [ inum ] . m_iStartPntNo ;
if ( ( ipnt > = 0 ) & & ( ipnt < pDataUnit [ inum ] . m_iPntNum ) )
{
pDataUnit = & pDataUnit [ inum ] ;
bRetVal = TRUE ;
break ;
}
}
}
else
{
if ( pDataUnit - > m_iPntNum < = 0 )
{
break ;
}
ipnt = iPntNo - pDataUnit - > m_iStartPntNo ;
if ( ( ipnt > = 0 ) & & ( ipnt < pDataUnit - > m_iPntNum ) )
{
bRetVal = TRUE ;
}
}
if ( TRUE = = bRetVal )
{
break ;
}
}
if ( bRetVal = = TRUE )
{
break ;
}
}
if ( TRUE = = bRetVal )
{
psAddrParam - > m_iDevIdx = j ;
psAddrParam - > m_iLinkIdx = i ;
psAddrParam - > m_uchLinkAddr = psPortParam - > m_psLink [ i ] . m_uchLinkAddr ;
//if(pDevParam != NULL)
//{
// psAddrParam->m_uchCommAddr = pDevParam->m_sDevParam.m_u8DevAddr;
//}
//else if(pProvDevParam != NULL)
//{
// psAddrParam->m_uchCommAddr = (BYTE)pProvDevParam->m_iProvAddr;
//}
//else
//{
// bRetVal = FALSE;
//}
if ( FALSE = = bProv )
{
psAddrParam - > m_uchCommAddr = pDevParam - > m_sDevParam . m_u8DevAddr ;
}
else
{
psAddrParam - > m_uchCommAddr = ( BYTE ) pProvDevParam - > m_iProvAddr ;
}
if ( psDBInfo ! = NULL )
{
memcpy ( ( void * ) psDBInfo , ( void * ) & pDataUnit - > m_psDataInfo [ ipnt ] , sizeof ( DBINFO ) ) ;
}
}
return bRetVal ;
}
BOOL FindProtectDevFromYkYtPnt ( BUBAN103PORTPARAM * psPortParam , \
DEVADDRPARAM * psAddrParam , \
int iYkYtPnt )
{
int i , j , iYkNo ;
BOOL bRetVal ;
DEVDEF * pDevParam ;
bRetVal = FALSE ;
for ( i = 0 ; i < psPortParam - > m_iLinkNum ; i + + )
{
for ( j = 0 ; j < psPortParam - > m_psLink [ i ] . m_iDevNum ; j + + )
{
pDevParam = & psPortParam - > m_psLink [ i ] . m_psDev [ j ] ;
if ( pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iPntNum < = 0 )
{
continue ;
}
iYkNo = iYkYtPnt - pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iStartPntNo ;
if ( iYkNo < 0 )
{
continue ;
}
if ( iYkNo < pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iPntNum )
{
psAddrParam - > m_iDevIdx = j ;
psAddrParam - > m_iLinkIdx = i ;
psAddrParam - > m_uchLinkAddr = psPortParam - > m_psLink [ i ] . m_uchLinkAddr ;
psAddrParam - > m_uchCommAddr = pDevParam - > m_sDevParam . m_u8DevAddr ;
bRetVal = TRUE ;
break ;
}
}
if ( bRetVal = = TRUE )
{
break ;
}
}
return bRetVal ;
}
int FindYkPointFromDev ( DBORIENTATION * psYkYtDBUnit , BYTE u8Fun , BYTE u8Inf )
{
int i , iYkNo ;
if ( psYkYtDBUnit - > m_iPntNum < = 0 )
{
return - 1 ;
}
for ( i = 0 ; i < psYkYtDBUnit - > m_iPntNum ; i + + )
{
if ( ( psYkYtDBUnit - > m_psDataInfo [ i ] . m_u8Fun = = u8Fun ) \
& & ( psYkYtDBUnit - > m_psDataInfo [ i ] . m_u8Inf = = u8Inf ) )
{
break ;
}
}
if ( i > = psYkYtDBUnit - > m_iPntNum )
{
return - 1 ;
}
iYkNo = psYkYtDBUnit - > m_iStartPntNo + i ;
return iYkNo ;
}
BOOL GetSpecialPtr ( int commid , DEVADDRPARAM * psDevAddrParam , \
BUBAN103PORTPARAM * * ppsPortParam , \
BUBAN103LINKDEF * * ppsLinkParam , DEVDEF * * ppsDevParam )
{
if ( IsExtInfoPtr ( commid ) = = FALSE )
{
return FALSE ;
}
// wen 2005.06.22 <20> <EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> ж<EFBFBD> Ϊֱ<CEAA> Ӹ<EFBFBD> ֵ
/*
if ( ( * ppsPortParam ) ! = NULL )
{
* ppsPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
}
if ( ( * ppsLinkParam ) ! = NULL )
{
* ppsLinkParam = & ( ( * ppsPortParam ) - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ) ;
}
if ( ( * ppsDevParam ) ! = NULL )
{
* ppsDevParam = & ( ( * ppsLinkParam ) - > m_psDev [ psDevAddrParam - > m_iDevIdx ] ) ;
}
*/
if ( ppsPortParam ! = NULL )
{
* ppsPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
}
if ( ppsLinkParam ! = NULL )
{
* ppsLinkParam = & ( ( * ppsPortParam ) - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ) ;
}
if ( ppsDevParam ! = NULL )
{
* ppsDevParam = & ( ( * ppsLinkParam ) - > m_psDev [ psDevAddrParam - > m_iDevIdx ] ) ;
}
return TRUE ;
}
BOOL GetSpecialProvPtr ( int commid , DEVADDRPARAM * psDevAddrParam , \
BUBAN103PORTPARAM * * ppsPortParam , \
BUBAN103LINKDEF * * ppsLinkParam , PROVDEVDEF * * ppsProvDevParam )
{
if ( IsExtInfoPtr ( commid ) = = FALSE )
{
return FALSE ;
}
// wen 2005.06.22 <20> <EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> ж<EFBFBD> Ϊֱ<CEAA> Ӹ<EFBFBD> ֵ
/*
if ( ( * ppsPortParam ) ! = NULL )
{
* ppsPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
}
if ( ( * ppsLinkParam ) ! = NULL )
{
* ppsLinkParam = & ( ( * ppsPortParam ) - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ) ;
}
if ( ( * ppsProvDevParam ) ! = NULL )
{
* ppsProvDevParam = & ( ( * ppsLinkParam ) - > m_psProvDev [ psDevAddrParam - > m_iDevIdx ] ) ;
}
*/
if ( ppsPortParam ! = NULL )
{
* ppsPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
}
if ( ppsLinkParam ! = NULL )
{
* ppsLinkParam = & ( ( * ppsPortParam ) - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ) ;
}
if ( ppsProvDevParam ! = NULL )
{
* ppsProvDevParam = & ( ( * ppsLinkParam ) - > m_psProvDev [ psDevAddrParam - > m_iDevIdx ] ) ;
}
return TRUE ;
}
BOOL GetPortParamPtr ( int commid , BUBAN103PORTPARAM * * ppsPortParam )
{
if ( IsExtInfoPtr ( commid ) = = FALSE )
{
return FALSE ;
}
// wen 2005.06.22 <20> <EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> ж<EFBFBD> Ϊֱ<CEAA> Ӹ<EFBFBD> ֵ
/*
if ( ( * ppsPortParam ) ! = NULL )
{
* ppsPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
}
else
{
printf ( " *ppsPortParam is NULL. \n " ) ;
return FALSE ;
}
*/
if ( ppsPortParam ! = NULL )
{
* ppsPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
}
else
{
return FALSE ;
}
return TRUE ;
}
BOOL GetOneValueOfASDU10 ( BYTE * pu8SourData , VALUEDEF * psValue , BYTE u8DataType , BYTE u8DataLen )
{
BOOL bRetVal ;
BYTE i , u8Len ;
float fValue ;
double dfValue ;
psValue - > m_unValue . m_dwValue = 0 ;
psValue - > m_iDataType = DT_NO ;
u8Len = u8DataLen ;
bRetVal = TRUE ;
switch ( u8DataType )
{
case DATAID_OS8ASCII : // 8λASCII
psValue - > m_iDataType = DT_STRING ;
if ( u8Len > = MAXSTRINGLEN )
{
u8Len = MAXSTRINGLEN - 1 ;
}
for ( i = 0 ; i < u8Len ; i + + )
{
psValue - > m_szValue [ i ] = pu8SourData [ i ] ;
}
psValue - > m_szValue [ i ] = 0 ;
psValue - > m_iDataNum = u8Len ;
break ;
case DATAID_BSTRING : // 8λ2<CEBB> <32> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
psValue - > m_iDataType = DT_CONTROL ;
psValue - > m_iDataNum = u8Len ;
u8Len = ( u8DataLen + 7 ) / 8 ;
if ( u8Len > sizeof ( DWORD ) )
{
u8Len = sizeof ( DWORD ) ;
psValue - > m_iDataNum = u8Len * 8 ;
}
for ( i = 0 ; i < u8Len ; i + + )
{
psValue - > m_unValue . m_dwValue + = ( pu8SourData [ i ] < < ( i * 8 ) ) ;
}
break ;
case DATAID_UI : // <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
psValue - > m_iDataType = DT_UINT ;
for ( i = 0 ; i < u8Len ; i + + )
{
psValue - > m_unValue . m_uValue + = ( pu8SourData [ i ] < < ( i * 8 ) ) ;
}
break ;
case DATAID_INT : // <20> <> <EFBFBD> <EFBFBD>
case DATAID_EXDATA_0X24 :
psValue - > m_iDataType = DT_INT ;
for ( i = 0 ; i < u8Len ; i + + )
{
psValue - > m_unValue . m_iValue + = ( pu8SourData [ i ] < < ( i * 8 ) ) ;
}
break ;
case DATAID_UFLOAT : // <20> <EFBFBD> <DEB7> Ÿ<EFBFBD> <C5B8> <EFBFBD> <EFBFBD> <EFBFBD>
psValue - > m_iDataType = DT_FLOAT ;
fValue = * ( float * ) ( pu8SourData ) ;
SequenceRtuToHost ( ( char * ) ( & fValue ) , sizeof ( float ) ) ;
psValue - > m_unValue . m_fValue = fabs ( fValue ) ;
break ;
case DATAID_FLOAT : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
psValue - > m_iDataType = DT_FLOAT ;
fValue = * ( float * ) ( pu8SourData ) ;
SequenceRtuToHost ( ( char * ) ( & fValue ) , sizeof ( float ) ) ;
psValue - > m_unValue . m_fValue = fValue ;
break ;
case DATAID_754SHORT : // R32.23 IEEE <20> <> 754<35> <34> ʵ<EFBFBD> <CAB5>
psValue - > m_iDataType = DT_FLOAT ;
fValue = * ( float * ) ( pu8SourData ) ;
SequenceRtuToHost ( ( char * ) ( & fValue ) , sizeof ( float ) ) ;
psValue - > m_unValue . m_fValue = fValue ;
break ;
case DATAID_754REAL : // R64.53 IEEE <20> <> 754ʵ<34> <CAB5>
psValue - > m_iDataType = DT_FLOAT ;
dfValue = * ( double * ) ( pu8SourData ) ;
SequenceRtuToHost ( ( char * ) ( & dfValue ) , sizeof ( dfValue ) ) ;
psValue - > m_unValue . m_fValue = dfValue ;
break ;
case DATAID_DOUBLE : // ˫<> <CBAB> <EFBFBD> <EFBFBD> Ϣ
psValue - > m_iDataType = DT_BINARY ;
psValue - > m_iDataNum = 2 ;
psValue - > m_unValue . m_dwValue = pu8SourData [ 0 ] & 0x03 ;
break ;
case DATAID_SINGLE : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
psValue - > m_iDataType = DT_BINARY ;
psValue - > m_iDataNum = 1 ;
psValue - > m_unValue . m_dwValue = pu8SourData [ 0 ] & 0x01 ;
break ;
case DATAID_13BITS : // <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ(13BITS)
psValue - > m_iDataType = DT_UINT ;
psValue - > m_unValue . m_uValue = pu8SourData [ 0 ] ;
psValue - > m_unValue . m_uValue = ( pu8SourData [ 1 ] & 0x1f ) * 256 ;
break ;
case DATAID_WITHTIME : // <20> <> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD>
case DATAID_WITHTIMESPACE : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD>
case DATAID_SORTIDNO : // ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD>
case DATAID_STRUCT : // <20> <> <EFBFBD> ݽṹ
default :
bRetVal = FALSE ;
break ;
}
return bRetVal ;
}
int FindAiGroupIdx ( DBORIENTATION * pAiDB , int iMaxNum , BYTE u8Asdu , BYTE u8Fun , BYTE u8Inf )
{
int idx ;
for ( idx = 0 ; idx < iMaxNum ; idx + + )
{
if ( pAiDB [ idx ] . m_psDataInfo = = NULL )
{
continue ;
}
if ( u8Asdu = = pAiDB [ idx ] . m_psDataInfo [ 0 ] . m_u8Asdu )
{
if ( ( u8Fun = = pAiDB [ idx ] . m_psDataInfo [ 0 ] . m_u8Fun ) \
& & ( u8Inf = = pAiDB [ idx ] . m_psDataInfo [ 0 ] . m_u8Inf ) )
{
break ;
}
}
}
return idx ;
}
//***************************************************************
//* <09> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> ̶<EFBFBD> ֡<EFBFBD> <D6A1> ʱ<EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//*<2A> <> <EFBFBD> <EFBFBD> RTUMSG* rtumsg:<3A> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//***************************************************************
void Buban103shortprocess ( RTUMSG * rtumsg )
{
BOOL bHaveClass1 ;
int commid ;
DEVADDRPARAM sDevAddrParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
sDevAddrParam . m_uchLinkAddr = rtumsg - > MsgData [ 2 ] ;
sDevAddrParam . m_uchCommAddr = 0 ;
if ( FindProtectDev ( pPortParam , & sDevAddrParam , TRUE ) = = FALSE )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d <20> <> <EFBFBD> ڶ˿<DAB6> <CBBF> <EFBFBD> <EFBFBD> ñ<EFBFBD> <C3B1> <EFBFBD> <EFBFBD> <EFBFBD> Χ <EFBFBD> <CEA7> !!!" ,
commid , sDevAddrParam . m_uchLinkAddr , sDevAddrParam . m_uchCommAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
else
{
//printf("find is right and exit.\n");
//return;
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d linkidx=%d, iDevIdx=%d." ,
commid , sDevAddrParam . m_uchLinkAddr , sDevAddrParam . m_uchCommAddr ,
sDevAddrParam . m_iLinkIdx , sDevAddrParam . m_iDevIdx ) ;
DebugPrint ( szbuf ) ;
# endif
//Buban103DispConfig(commid, pPortParam);
//return;
pLinkParam = & pPortParam - > m_psLink [ sDevAddrParam . m_iLinkIdx ] ;
SetProtectDevStatus ( pLinkParam , sDevAddrParam . m_iDevIdx , TRUE ) ;
ClearLinkCnt ( pLinkParam , sDevAddrParam . m_iDevIdx ) ;
}
bHaveClass1 = FALSE ;
if ( rtumsg - > MsgData [ 1 ] & 0x10 )
{
pLinkParam - > m_iQueryedAddr_CLASS1 = 0 ;
pLinkParam - > m_iQueryNum_CLASS1_Count = 0 ;
}
else
{
if ( rtumsg - > MsgData [ 1 ] & 0x20 )
{
bHaveClass1 = TRUE ;
MakeBuban103_PL1_NA_3_Cmd ( commid , & sDevAddrParam ) ;
}
else
{
pLinkParam - > m_iQueryedAddr_CLASS1 = 0 ;
pLinkParam - > m_iQueryNum_CLASS1_Count = 0 ;
}
}
switch ( rtumsg - > MsgData [ 1 ] & 0x0f )
{
case M_CON_NA_3 : //ȷ<> <C8B7> ֡
SetDevLinkOk ( pLinkParam , sDevAddrParam . m_iDevIdx , TRUE ) ;
if ( pLinkParam - > m_bRstLinkOk = = TRUE )
{
pLinkParam - > m_psDev [ sDevAddrParam . m_iDevIdx ] . m_bInitdata = TRUE ;
}
break ;
case M_BY_NA_3 : //æ֡<C3A6> <D6A1> ȷ<EFBFBD> <C8B7> ֡<EFBFBD> <D6A1>
pLinkParam - > m_psDev [ sDevAddrParam . m_iDevIdx ] . m_bInitdata = TRUE ;
break ;
case M_NV_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> ش<EFBFBD>
if ( FALSE = = bHaveClass1 )
{
pLinkParam - > m_psDev [ sDevAddrParam . m_iDevIdx ] . m_bInitdata = TRUE ;
pLinkParam - > m_psDev [ sDevAddrParam . m_iDevIdx ] . m_bAllQueryOk = TRUE ;
}
break ;
case M_LKR_NA_3_1 : //<2F> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
SetDevLinkOk ( pLinkParam , sDevAddrParam . m_iDevIdx , TRUE ) ;
break ;
case M_LKR_NA_3_2 : //<2F> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> δ<EFBFBD> <CEB4> <EFBFBD> <EFBFBD>
SetDevLinkOk ( pLinkParam , sDevAddrParam . m_iDevIdx , FALSE ) ;
break ;
case M_LKR_NA_3_3 : //<2F> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> δʵ<CEB4> <CAB5>
SetDevLinkOk ( pLinkParam , sDevAddrParam . m_iDevIdx , FALSE ) ;
break ;
default :
# ifdef _DEBUG_MSG_
//OutputDebugString("<22> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEA3AC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> .\n");
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 ;
}
}
//***************************************************************
//* <09> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> ɱ<EFBFBD> ֡<EFBFBD> <D6A1> ʱ<EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//*<2A> <> <EFBFBD> <EFBFBD> RTUMSG* rtumsg:<3A> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//***************************************************************
void Buban103longprocess ( RTUMSG * rtumsg )
{
int commid ;
DEVADDRPARAM sDevAddrParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
sDevAddrParam . m_uchLinkAddr = rtumsg - > MsgData [ 5 ] ;
sDevAddrParam . m_uchCommAddr = rtumsg - > MsgData [ 9 ] ;
if ( FindProtectDev ( pPortParam , & sDevAddrParam , FALSE ) = = FALSE )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d <20> <> <EFBFBD> ڶ˿<DAB6> <CBBF> <EFBFBD> <EFBFBD> ñ<EFBFBD> <C3B1> <EFBFBD> <EFBFBD> <EFBFBD> Χ <EFBFBD> <CEA7> !!!" ,
commid , sDevAddrParam . m_uchLinkAddr , sDevAddrParam . m_uchCommAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
else
{
pLinkParam = & pPortParam - > m_psLink [ sDevAddrParam . m_iLinkIdx ] ;
SetProtectDevStatus ( pLinkParam , sDevAddrParam . m_iDevIdx , TRUE ) ;
ClearLinkCnt ( pLinkParam , sDevAddrParam . m_iDevIdx ) ;
}
if ( rtumsg - > MsgData [ 4 ] & 0x10 )
{
pLinkParam - > m_iQueryedAddr_CLASS1 = 0 ;
pLinkParam - > m_iQueryNum_CLASS1_Count = 0 ;
}
else
{
if ( rtumsg - > MsgData [ 4 ] & 0x20 )
{
MakeBuban103_PL1_NA_3_Cmd ( commid , & sDevAddrParam ) ;
}
else
{
if ( pLinkParam - > m_psDev [ sDevAddrParam . m_iDevIdx ] . m_bAllQueryOk = = FALSE )
{
pLinkParam - > m_psDev [ sDevAddrParam . m_iDevIdx ] . m_bAllQueryOk = TRUE ;
}
pLinkParam - > m_iQueryedAddr_CLASS1 = 0 ;
pLinkParam - > m_iQueryNum_CLASS1_Count = 0 ;
}
}
switch ( rtumsg - > MsgData [ 6 ] ) //<2F> <> <EFBFBD> ͱ<EFBFBD> ʶ<EFBFBD> <CAB6>
{
case M_TM_TA_3 : // 1<> <31> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD>
Buban103TMprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_TMR_TA_3 : // 2<> <32> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> ʱ<EFBFBD> 걨<EFBFBD> <EAB1A8>
Buban103TMRprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_MEI_NA_3 : // 3<> <33> <EFBFBD> <EFBFBD> ֵI<D6B5> <49> <EFBFBD> <EFBFBD>
Buban103MEIprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_TME_TA_3 : // 4<> <34> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD>
Buban103TMEprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_IRC_NA_3 : // 5<> <35> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD>
Buban103IRCprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_SYN_TA_3 : // 6ʱ<36> <CAB1> ͬ<EFBFBD> <CDAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Buban103SynTime ( rtumsg , & sDevAddrParam ) ;
break ;
case M_TGI_NA_3 : // 8<> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> <EFBFBD> <EFBFBD>
pLinkParam - > m_bRstLinkOk = FALSE ;
pLinkParam - > m_psDev [ sDevAddrParam . m_iDevIdx ] . m_bInitdata = FALSE ;
pLinkParam - > m_psDev [ sDevAddrParam . m_iDevIdx ] . m_bAllQueryOk = TRUE ;
break ;
case M_MEII_NA_3 : // 9<> <39> <EFBFBD> <EFBFBD> ֵII<49> <49> <EFBFBD> <EFBFBD>
Buban103MEIINAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_GD_NTA_3 : // 10ͨ<30> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݱ<EFBFBD> <DDB1> <EFBFBD>
//<2F> <> <EFBFBD> <EFBFBD> NGD<47> <44> COUNTλΪ<CEBB> 㣬<EFBFBD> <E3A3AC> <EFBFBD> <EFBFBD> ʾ <EFBFBD> <CABE> <EFBFBD> <EFBFBD> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ( rtumsg - > MsgData [ 13 ] & 0x80 ) = = 0 )
{
pLinkParam - > m_bRstLinkOk = FALSE ;
pLinkParam - > m_psDev [ sDevAddrParam . m_iDevIdx ] . m_bInitdata = FALSE ;
}
Buban103GDprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_GI_NTA_3 : // 11ͨ<31> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD>
Buban103GIprocess ( rtumsg , & sDevAddrParam ) ;
break ;
// wen 2003.10.27 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݵĴ<DDB5> <C4B4> <EFBFBD>
case M_LRD_TA_3 : // 23<32> <33> <EFBFBD> <EFBFBD> ¼<EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Buban103LRDprocess ( rtumsg ) ;
break ;
case M_RTD_TA_3 : // 26<32> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <D7BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Buban103RTDprocess ( rtumsg ) ;
break ;
case M_RTC_NA_3 : // 27<32> <37> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <D7BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Buban103RTCprocess ( rtumsg ) ;
break ;
case M_RTT_NA_3 : // 28<32> <38> <EFBFBD> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> <EFBFBD> <D7BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Buban103RTTprocess ( rtumsg ) ;
break ;
case M_TOT_TA_3 : // 29<32> <39> <EFBFBD> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> 䱨<EFBFBD> <E4B1A8>
Buban103TOTprocess ( rtumsg ) ;
break ;
case M_TOV_NA_3 : // 30<33> <30> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD>
Buban103TOVprocess ( rtumsg ) ;
break ;
case M_EOT_TA_3 : // 31<33> <31> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Buban103EOTprocess ( rtumsg ) ;
pLinkParam - > m_bRstLinkOk = FALSE ;
pLinkParam - > m_psDev [ sDevAddrParam . m_iDevIdx ] . m_bInitdata = FALSE ;
break ;
case M_MEIII_TA_3 : // 32<33> <32> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ<EFBFBD> <D6B5>
Buban103MEIIITAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_MEIV_TA_3 : // 33<33> <33> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ<EFBFBD> <D6B5>
Buban103MEIVTAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_MEV_TA_3 : // 34<33> <34> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ<EFBFBD> <D6B5>
Buban103MEVTAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_MEVI_TA_3 : // 35<33> <35> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ<EFBFBD> <D6B5>
Buban103MEVITAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_IT_NA_3 : // 36<33> <36> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ
Buban103ITNAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_IT_TA_3 : // 37<33> <37> ʱ<EFBFBD> <CAB1> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ
//Buban103MEITTAprocess(rtumsg, &sDevAddrParam);
break ;
case M_ST_NA_3 : // 38<33> <38> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> Ϣ
Buban103STNAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_ST_TA_3 : // 39<33> <39> ʱ<EFBFBD> <CAB1> <EFBFBD> IJ<EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> Ϣ
//Buban103STTAprocess(rtumsg, &sDevAddrParam);
break ;
case M_SP_NA_3 : // 40<34> <30> <EFBFBD> <EFBFBD> ״̬<D7B4> <CCAC> Ϣ
Buban103SPNAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_SP_TA_3 : // 41<34> <31> ʱ<EFBFBD> <CAB1> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> ״̬<D7B4> <CCAC> Ϣ
Buban103SPTAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_DP_NA_3 : // 42˫<32> <CBAB> ״̬<D7B4> <CCAC> Ϣ
Buban103DPNAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_DP_TA_3 : // 43<34> <33> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> ˫<EFBFBD> <CBAB> ״̬<D7B4> <CCAC> Ϣ
Buban103DPTAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_SS_NA_3 : // 44<34> <34> <EFBFBD> <EFBFBD> ״̬<D7B4> <CCAC> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD>
Buban103SSNAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_SS_TA_3 : // 45<34> <35> ʱ<EFBFBD> <CAB1> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> ״̬<D7B4> <CCAC> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD>
Buban103SSTAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_DS_NA_3 : // 46˫<36> <CBAB> ״̬<D7B4> <CCAC> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD>
Buban103DSNAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_DS_TA_3 : // 47<34> <37> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> ˫<EFBFBD> <CBAB> ״̬<D7B4> <CCAC> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD>
Buban103DSTAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_WL_TA_3 : // 48ˮλ
Buban103WLTAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case M_MEVII_NA_3 : // 50<35> <30> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5>
Buban103MEVIINAprocess ( rtumsg , & sDevAddrParam ) ;
break ;
case C_DC_NA_3 : // 64<36> <34> <EFBFBD> ƶ<EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Buban103YkAck ( rtumsg , & sDevAddrParam ) ;
break ;
case C_RC_NA_3 : // 65<36> <35> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Buban103YtAck ( rtumsg , & sDevAddrParam ) ;
break ;
case C_SE_NA_3 : // 66<36> 趨<EFBFBD> <E8B6A8> <EFBFBD> <EFBFBD>
break ;
case C_CC_NA_3 : // 67<36> <37> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
break ;
case M_EX_PI_3 : // 205<30> <35> <EFBFBD> <EFBFBD> <EFBFBD> ӹ<EFBFBD> ˾<EFBFBD> <CBBE> չ<EFBFBD> <D5B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Buban103EXPIprocess ( rtumsg , & sDevAddrParam ) ;
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 Buban103TMprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=0x81
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)
//rtumsg->MsgData[11];
// DPI
//rtumsg->MsgData[12];
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[13];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[17];
Buban103TMprocessOfSoe ( rtumsg , psDevAddrParam ) ;
// wen 2004.01.12 <20> <> <EFBFBD> <EFBFBD> <CDB8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//Buban103TMprocessOfPEvent(rtumsg, psDevAddrParam);
}
void Buban103TMprocessOfSoe ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
int i , dipnt , commid , iYkNo ;
BYTE buf [ 16 ] , st ;
// <20> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
time_t iTime ;
WORD wMillSeconds ;
struct tm * ptrtm ;
DI_DEF pntmsg ;
SOE_DEF sSoeData ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=0x81
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)
//rtumsg->MsgData[11];
// DPI
//rtumsg->MsgData[12];
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[13];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[17];
commid = rtumsg - > PortIdx ;
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
pLinkParam = & pPortParam - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ;
pDevParam = & pLinkParam - > m_psDev [ psDevAddrParam - > m_iDevIdx ] ;
pDataUnit = & pDevParam - > m_sDevParam . m_sDiDBOrientation ;
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU1<55> <31> Ϣ<EFBFBD> <CFA2> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
for ( i = 0 ; i < pDataUnit - > m_iPntNum ; i + + )
{
// wen 2004.04.11 <20> <> <EFBFBD> <EFBFBD> asdu<64> <75> <EFBFBD> <EFBFBD> <EFBFBD> ж<EFBFBD>
if ( pLinkParam - > m_iJudgeAsduNo ! = 0 )
{
if ( M_TM_TA_3 ! = pDataUnit - > m_psDataInfo [ i ] . m_u8Asdu )
{
continue ;
}
}
if ( ( pDataUnit - > m_psDataInfo [ i ] . m_u8Fun = = rtumsg - > MsgData [ 10 ] ) \
& & ( pDataUnit - > m_psDataInfo [ i ] . m_u8Inf = = rtumsg - > MsgData [ 11 ] ) )
{
break ;
}
}
if ( i > = pDataUnit - > m_iPntNum )
{
//ң<> <D2A3> ң<EFBFBD> <D2A3> <EFBFBD> <EFBFBD> У
if ( M_CAUSE_REMOTE ! = rtumsg - > MsgData [ 8 ] )
{
return ;
}
iYkNo = FindYkPointFromDev ( & pDevParam - > m_sDevParam . m_sYkDBOrientation , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
if ( iYkNo > = 0 )
{
// 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>
buf [ 0 ] = ( BYTE ) ( commid & 0xFF ) ;
buf [ 1 ] = ( BYTE ) ( ( commid & 0xFF00 ) < < 8 ) ;
buf [ 2 ] = ( BYTE ) ( ( commid & 0xFF0000 ) < < 16 ) ;
buf [ 3 ] = ( BYTE ) ( ( commid & 0xFF000000 ) < < 24 ) ;
buf [ 4 ] = ( BYTE ) ( iYkNo & 0xFF ) ;
buf [ 5 ] = ( BYTE ) ( ( iYkNo & 0xFF00 ) < < 8 ) ;
buf [ 6 ] = ( BYTE ) ( ( iYkNo & 0xFF0000 ) < < 16 ) ;
buf [ 7 ] = ( BYTE ) ( ( iYkNo & 0xFF000000 ) < < 24 ) ;
buf [ 8 ] = STEP_YKYT_EXEC ;
buf [ 9 ] = rtumsg - > MsgData [ 12 ] | 0x80 ;
if ( ShmGetDispYkYtFlag ( ) )
{
# ifdef _DEBUG_MSG_
//sprintf(szbuf, "<22> ˿<EFBFBD> %d <20> <> ·<EFBFBD> <C2B7> ַ=%d װ<> õ<EFBFBD> ַ%d RII=0x%02x, ң<> ص<EFBFBD> <D8B5> <EFBFBD> =%d, op=0x%02x!!!\n",
// commid, rtumsg->MsgData[5], rtumsg->MsgData[9], rtumsg->MsgData[13], iYkNo, rtumsg->MsgData[12]);
//DebugPrint(szbuf);
sprintf ( szbuf , " TIP_(%04d): commid=%d linkaddr=%d devaddr=%d RII=0x%02x ykytpnt=%d, op=0x%02x. \n " ,
_getpid ( ) , commid , rtumsg - > MsgData [ 5 ] , rtumsg - > MsgData [ 9 ] , rtumsg - > MsgData [ 13 ] , iYkNo , rtumsg - > MsgData [ 12 ] ) ;
DebugPrint ( szbuf ) ;
# endif
}
Buban103YkYtProcess ( commid , buf , 10 ) ;
}
return ;
}
dipnt = pDataUnit - > m_iStartPntNo + i ;
st = rtumsg - > MsgData [ 12 ] & 0x03 ;
if ( ( st = = 0 ) | | ( st = = 3 ) )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d <20> <> ·<EFBFBD> <C2B7> ַ=%d װ<> õ<EFBFBD> ַ%d RII=%d, <20> <> <EFBFBD> <EFBFBD> =%d, status=%d!!!\n " ,
commid , rtumsg - > MsgData [ 5 ] , rtumsg - > MsgData [ 9 ] , dipnt , rtumsg - > MsgData [ 12 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
st - - ;
pntmsg . Status = st ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Է<EFBFBD> <D4B7> <EFBFBD> <EFBFBD> <EFBFBD> ͻ<EFBFBD> <CDBB> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> soe
//if(rtumsg->MsgData[8] == M_CAUSE_AUTOSEND)
if ( rtumsg - > MsgData [ 8 ] ! = M_CAUSE_QUERY )
{
// <20> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
time ( & iTime ) ;
ptrtm = localtime ( & iTime ) ;
if ( ptrtm - > tm_hour < ( rtumsg - > MsgData [ 16 ] & 0x1f ) )
{
iTime - = 24 * 3600 ;
ptrtm = localtime ( & iTime ) ;
}
ptrtm - > tm_hour = rtumsg - > MsgData [ 16 ] & 0x1f ;
ptrtm - > tm_min = rtumsg - > MsgData [ 15 ] & 0x3f ;
wMillSeconds = rtumsg - > MsgData [ 13 ] + rtumsg - > MsgData [ 14 ] * 256 ;
ptrtm - > tm_sec = wMillSeconds / 1000 ;
wMillSeconds % = 1000 ;
sSoeData . bStatus = st ;
sSoeData . iPntNo = dipnt ;
sSoeData . u8Type = 1 ; // ASDU1
sSoeData . wFaultNo = 0 ;
sSoeData . u8ProvFun = pDataUnit - > m_psDataInfo [ i ] . m_u8ProvFun ;
sSoeData . u8ProvInf = pDataUnit - > m_psDataInfo [ i ] . m_u8ProvInf ;
sSoeData . wRelativeTime = 0 ;
sSoeData . SoeTime . Year = ptrtm - > tm_year + 1900 ;
sSoeData . SoeTime . Month = ( BYTE ) ( ptrtm - > tm_mon + 1 ) ;
sSoeData . SoeTime . Day = ( BYTE ) ( ptrtm - > tm_mday ) ;
sSoeData . SoeTime . Hour = ( BYTE ) ( ptrtm - > tm_hour ) ;
sSoeData . SoeTime . Min = ( BYTE ) ( ptrtm - > tm_min ) ;
sSoeData . SoeTime . Sec = ( BYTE ) ( ptrtm - > tm_sec ) ;
sSoeData . SoeTime . mSec = wMillSeconds ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , dipnt , ( void * ) & sSoeData , DI_PNT_TYPE , PNT_SOE_TIME_EX ) ;
}
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , dipnt , ( void * ) & pntmsg , DI_PNT_TYPE , PNT_STATUS ) ;
}
void Buban103TMRprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=0x81
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)
//rtumsg->MsgData[11];
// DPI
//rtumsg->MsgData[12];
// <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[13];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[15];
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[17];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[21];
Buban103TMRprocessOfSoe ( rtumsg , psDevAddrParam ) ;
// wen 2004.01.12 <20> <> <EFBFBD> <EFBFBD> <CDB8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//Buban103TMRprocessOfPEvent(rtumsg, psDevAddrParam);
}
void Buban103TMRprocessOfSoe ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
int i , dipnt , commid ;
BYTE st ;
// <20> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
time_t iTime ;
WORD wMillSeconds , wTime , wFault ;
struct tm * ptrtm ;
DI_DEF pntmsg ;
SOE_DEF sSoeData ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=0x81
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)
//rtumsg->MsgData[11];
// DPI
//rtumsg->MsgData[12];
// <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[13];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[15];
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[17];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[21];
commid = rtumsg - > PortIdx ;
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
pLinkParam = & pPortParam - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ;
pDevParam = & pLinkParam - > m_psDev [ psDevAddrParam - > m_iDevIdx ] ;
pDataUnit = & pDevParam - > m_sDevParam . m_sDiDBOrientation ;
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU2<55> <32> Ϣ<EFBFBD> <CFA2> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
for ( i = 0 ; i < pDataUnit - > m_iPntNum ; i + + )
{
// wen 2004.04.11 <20> <> <EFBFBD> <EFBFBD> asdu<64> <75> <EFBFBD> <EFBFBD> <EFBFBD> ж<EFBFBD>
if ( pLinkParam - > m_iJudgeAsduNo ! = 0 )
{
if ( M_TMR_TA_3 ! = pDataUnit - > m_psDataInfo [ i ] . m_u8Asdu )
{
continue ;
}
}
if ( ( pDataUnit - > m_psDataInfo [ i ] . m_u8Fun = = rtumsg - > MsgData [ 10 ] ) \
& & ( pDataUnit - > m_psDataInfo [ i ] . m_u8Inf = = rtumsg - > MsgData [ 11 ] ) )
{
break ;
}
}
if ( i > = pDataUnit - > m_iPntNum )
{
return ;
}
dipnt = pDataUnit - > m_iStartPntNo + i ;
if ( rtumsg - > MsgData [ 8 ] = = M_CAUSE_QUERY )
{
// <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <CDB9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ص<DEB9>
}
else
{
// <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <CDB9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ص<EFBFBD>
}
st = rtumsg - > MsgData [ 12 ] & 0x03 ;
if ( ( st = = 0 ) | | ( st = = 3 ) )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d <20> <> ·<EFBFBD> <C2B7> ַ=%d װ<> õ<EFBFBD> ַ%d <20> <> <EFBFBD> <EFBFBD> =%d, status=%d!!!\n " ,
commid , rtumsg - > MsgData [ 5 ] , rtumsg - > MsgData [ 9 ] , dipnt , rtumsg - > MsgData [ 12 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
wTime = rtumsg - > MsgData [ 13 ] + rtumsg - > MsgData [ 14 ] * 256 ;
wFault = rtumsg - > MsgData [ 15 ] + rtumsg - > MsgData [ 16 ] * 256 ;
st - - ;
pntmsg . Status = st ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Է<EFBFBD> <D4B7> <EFBFBD> <EFBFBD> <EFBFBD> ͻ<EFBFBD> <CDBB> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> soe
//if(rtumsg->MsgData[8] == M_CAUSE_AUTOSEND)
if ( rtumsg - > MsgData [ 8 ] ! = M_CAUSE_QUERY )
{
// <20> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
time ( & iTime ) ;
ptrtm = localtime ( & iTime ) ;
if ( ptrtm - > tm_hour < ( rtumsg - > MsgData [ 20 ] & 0x1f ) )
{
iTime - = 24 * 3600 ;
ptrtm = localtime ( & iTime ) ;
}
ptrtm - > tm_hour = rtumsg - > MsgData [ 20 ] & 0x1f ;
ptrtm - > tm_min = rtumsg - > MsgData [ 19 ] & 0x3f ;
wMillSeconds = rtumsg - > MsgData [ 17 ] + rtumsg - > MsgData [ 18 ] * 256 ;
ptrtm - > tm_sec = wMillSeconds / 1000 ;
wMillSeconds % = 1000 ;
sSoeData . bStatus = st ;
sSoeData . iPntNo = dipnt ;
sSoeData . u8Type = 2 ; // ASDU2
sSoeData . wFaultNo = wFault ;
sSoeData . wRelativeTime = wTime ;
sSoeData . u8ProvFun = pDataUnit - > m_psDataInfo [ i ] . m_u8ProvFun ;
sSoeData . u8ProvInf = pDataUnit - > m_psDataInfo [ i ] . m_u8ProvInf ;
sSoeData . SoeTime . Year = ptrtm - > tm_year + 1900 ;
sSoeData . SoeTime . Month = ( BYTE ) ( ptrtm - > tm_mon + 1 ) ;
sSoeData . SoeTime . Day = ( BYTE ) ( ptrtm - > tm_mday ) ;
sSoeData . SoeTime . Hour = ( BYTE ) ( ptrtm - > tm_hour ) ;
sSoeData . SoeTime . Min = ( BYTE ) ( ptrtm - > tm_min ) ;
sSoeData . SoeTime . Sec = ( BYTE ) ( ptrtm - > tm_sec ) ;
sSoeData . SoeTime . mSec = wMillSeconds ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , dipnt , ( void * ) & sSoeData , DI_PNT_TYPE , PNT_SOE_TIME_EX ) ;
}
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , dipnt , ( void * ) & pntmsg , DI_PNT_TYPE , PNT_STATUS ) ;
}
void Buban103MEIprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
int commid ;
int i , aipnt , iNum , idx ;
AI_DEF pntmsg ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)
//rtumsg->MsgData[11];
// B<> <42> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[12];
// AB<41> <42> <EFBFBD> ߵ <EFBFBD> <DFB5> <EFBFBD>
//rtumsg->MsgData[14];
// <20> й<EFBFBD> <D0B9> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[16];
// <20> <EFBFBD> <DEB9> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[18];
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
// wen 2004.02.04 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> Ͳ<EFBFBD> <CDB2> ̶<EFBFBD> <CCB6> <EFBFBD> <EFBFBD> <EFBFBD>
// <20> ܹ<EFBFBD> 7<EFBFBD> 鱻<EFBFBD> <E9B1BB> ֵ
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*for(idx = 0; idx < DEV_AI_MAXNUM; idx++)
{
if ( pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo = = NULL )
{
continue ;
}
if ( M_MEI_NA_3 = = pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo [ 0 ] . m_u8Asdu )
{
break ;
}
} */
//===================================================================================================
idx = FindAiGroupIdx ( pDevParam - > m_sDevParam . m_sAiDBOrientation , DEV_AI_MAXNUM , M_MEI_NA_3 , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if ( idx > = DEV_AI_MAXNUM )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU3(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
else
{
pDataUnit = & pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] ;
}
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU3(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
/ / if ( ( rtumsg - > MsgData [ 10 ] ! = pDataUnit - > m_psDataInfo [ 0 ] . m_u8Fun ) \
// || (rtumsg->MsgData[11] != pDataUnit->m_psDataInfo[0].m_u8Inf))
//{
// return;
//}
iNum = rtumsg - > MsgData [ 7 ] & 0x7f ;
if ( iNum > pDataUnit - > m_iPntNum )
{
iNum = pDataUnit - > m_iPntNum ;
}
aipnt = pDataUnit - > m_iStartPntNo ;
for ( i = 0 ; i < iNum ; i + + )
{
// <20> <> <EFBFBD> <EFBFBD> 3λΪƷ <CEAA> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pntmsg . RawValue = ( short ) ( ( rtumsg - > MsgData [ 12 + 2 * i ] & 0xf8 ) + rtumsg - > MsgData [ 13 + 2 * i ] * 256 ) ;
pntmsg . RawValue / = 8 ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , aipnt + i , & pntmsg , AI_PNT_TYPE , PNT_RAWVALUE ) ;
}
}
void Buban103TMEprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
int commid ;
int idx ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=0x81
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)
//rtumsg->MsgData[11];
// DPI
//rtumsg->MsgData[12];
// <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[13];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[15];
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[17];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[21];
return ;
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
// wen 2004.02.04 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> Ͳ<EFBFBD> <CDB2> ̶<EFBFBD> <CCB6> <EFBFBD> <EFBFBD> <EFBFBD>
// <20> ܹ<EFBFBD> 7<EFBFBD> 鱻<EFBFBD> <E9B1BB> ֵ
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*for(idx = 0; idx < DEV_AI_MAXNUM; idx++)
{
if ( pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo = = NULL )
{
continue ;
}
if ( M_TME_TA_3 = = pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo [ 0 ] . m_u8Asdu )
{
break ;
}
} */
//===================================================================================================
idx = FindAiGroupIdx ( pDevParam - > m_sDevParam . m_sAiDBOrientation , DEV_AI_MAXNUM , M_TME_TA_3 , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if ( idx > = DEV_AI_MAXNUM )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU4(%d,%d) <20> <> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
else
{
pDataUnit = & pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] ;
}
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU4(%d,%d) <20> <> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
}
void Buban103IRCprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
int commid ;
CMDPARAM sCmdParam ;
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD>
if ( rtumsg - > MsgData [ 8 ] = = M_CAUSE_POWERON )
{
commid = rtumsg - > PortIdx ;
memcpy ( ( void * ) & sCmdParam . m_sDevAddr , ( void * ) psDevAddrParam , sizeof ( DEVADDRPARAM ) ) ;
sCmdParam . m_uchFun = 255 ;
sCmdParam . m_uchInf = 0 ;
MakeAllQuery_CAsdu7 ( commid , & sCmdParam ) ;
}
}
void Buban103MEIINAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)
//rtumsg->MsgData[11];
// A<> <41> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[12];
// B<> <42> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[14];
// C<> <43> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[16];
// A<> <41> <EFBFBD> <EFBFBD> ѹ
//rtumsg->MsgData[18];
// B<> <42> <EFBFBD> <EFBFBD> ѹ
//rtumsg->MsgData[20];
// C<> <43> <EFBFBD> <EFBFBD> ѹ
//rtumsg->MsgData[22];
// <20> й<EFBFBD> <D0B9> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[24];
// <20> <EFBFBD> <DEB9> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[26];
// Ƶ<> <C6B5>
//rtumsg->MsgData[28];
int commid ;
int i , aipnt , iNum , idx ;
AI_DEF pntmsg ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
// <20> ܹ<EFBFBD> 7<EFBFBD> 鱻<EFBFBD> <E9B1BB> ֵ
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*for(idx = 0; idx < DEV_AI_MAXNUM; idx++)
{
if ( pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo = = NULL )
{
continue ;
}
if ( M_MEII_NA_3 = = pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo [ 0 ] . m_u8Asdu )
{
break ;
}
} */
//===================================================================================================
idx = FindAiGroupIdx ( pDevParam - > m_sDevParam . m_sAiDBOrientation , DEV_AI_MAXNUM , M_MEII_NA_3 , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if ( idx > = DEV_AI_MAXNUM )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU9(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
else
{
pDataUnit = & pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] ;
}
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU9(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
/ / if ( ( rtumsg - > MsgData [ 10 ] ! = pDataUnit - > m_psDataInfo [ 0 ] . m_u8Fun ) \
// || (rtumsg->MsgData[11] != pDataUnit->m_psDataInfo[0].m_u8Inf))
//{
// return;
//}
iNum = rtumsg - > MsgData [ 7 ] & 0x7f ;
if ( iNum > pDataUnit - > m_iPntNum )
{
iNum = pDataUnit - > m_iPntNum ;
}
aipnt = pDataUnit - > m_iStartPntNo ;
for ( i = 0 ; i < iNum ; i + + )
{
// Ʒ <> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//if(rtumsg->MsgData[12+2*i] & 0x01);
// Ʒ <> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ч
//if(rtumsg->MsgData[12+2*i] & 0x02);
// <20> <> <EFBFBD> <EFBFBD> 3λΪƷ <CEAA> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pntmsg . RawValue = ( short ) ( ( rtumsg - > MsgData [ 12 + 2 * i ] & 0xf8 ) + rtumsg - > MsgData [ 13 + 2 * i ] * 256 ) ;
pntmsg . RawValue / = 8 ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , aipnt + i , & pntmsg , AI_PNT_TYPE , PNT_RAWVALUE ) ;
}
}
void Buban103MEIIITAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)
// = 144 --- 147
//rtumsg->MsgData[11];
// L2<4C> <32> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[12];
// L1-L2<4C> <32> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[14];
// <20> й<EFBFBD> <D0B9> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[16];
// <20> <EFBFBD> <DEB9> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[18];
// <20> <> <EFBFBD> <EFBFBD> г <EFBFBD> <D0B3> ֵ1(3 BYTES)
//rtumsg->MsgData[20];
// ... ...
// <20> <> <EFBFBD> <EFBFBD> г <EFBFBD> <D0B3> ֵN(3 BYTES)
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
int commid ;
int i , aipnt , iNum , idx ;
AI_DEF pntmsg ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
// <20> ܹ<EFBFBD> 7<EFBFBD> 鱻<EFBFBD> <E9B1BB> ֵ
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*for(idx = 0; idx < DEV_AI_MAXNUM; idx++)
{
if ( pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo = = NULL )
{
continue ;
}
if ( M_MEIII_TA_3 = = pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo [ 0 ] . m_u8Asdu )
{
break ;
}
} */
//===================================================================================================
idx = FindAiGroupIdx ( pDevParam - > m_sDevParam . m_sAiDBOrientation , DEV_AI_MAXNUM , M_MEIII_TA_3 , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if ( idx > = DEV_AI_MAXNUM )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU32(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
else
{
pDataUnit = & pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] ;
}
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU32(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
/ / if ( ( rtumsg - > MsgData [ 10 ] ! = pDataUnit - > m_psDataInfo [ 0 ] . m_u8Fun ) \
// || (rtumsg->MsgData[11] != pDataUnit->m_psDataInfo[0].m_u8Inf))
//{
// return;
//}
iNum = rtumsg - > MsgData [ 7 ] & 0x7f ;
if ( iNum > pDataUnit - > m_iPntNum )
{
iNum = pDataUnit - > m_iPntNum ;
}
aipnt = pDataUnit - > m_iStartPntNo ;
// wen 2003.11.01 <20> <> <EFBFBD> <EFBFBD> 4<EFBFBD> Ժ<EFBFBD> <D4BA> <EFBFBD> Ϊг <CEAA> <D0B3> ֵ<EFBFBD> Ͷ<EFBFBD> <CDB6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
iNum = 4 ;
for ( i = 0 ; i < iNum ; i + + )
{
// <20> <> <EFBFBD> <EFBFBD> 3λΪƷ <CEAA> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pntmsg . RawValue = ( short ) ( ( rtumsg - > MsgData [ 12 + 2 * i ] & 0xf8 ) + rtumsg - > MsgData [ 13 + 2 * i ] * 256 ) ;
pntmsg . RawValue / = 8 ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , aipnt + i , & pntmsg , AI_PNT_TYPE , PNT_RAWVALUE ) ;
}
}
void Buban103MEIVTAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF) = 148
//rtumsg->MsgData[11];
// L1<4C> <31> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[12];
// L2<4C> <32> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[14];
// L3<4C> <33> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[16];
// Ul1<6C> <31> ѹ
//rtumsg->MsgData[18];
// Ul2<6C> <32> ѹ
//rtumsg->MsgData[20];
// Ul3<6C> <33> ѹ
//rtumsg->MsgData[22];
// <20> й<EFBFBD> <D0B9> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[24];
// <20> <EFBFBD> <DEB9> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[26];
// Ƶ<> <C6B5>
//rtumsg->MsgData[28];
// <20> <> <EFBFBD> <EFBFBD> г <EFBFBD> <D0B3> ֵ1(3 BYTES)
//rtumsg->MsgData[30];
// ... ...
// <20> <> <EFBFBD> <EFBFBD> г <EFBFBD> <D0B3> ֵN(3 BYTES)
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
int commid ;
int i , aipnt , iNum , idx ;
AI_DEF pntmsg ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
// <20> ܹ<EFBFBD> 7<EFBFBD> 鱻<EFBFBD> <E9B1BB> ֵ
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*for(idx = 0; idx < DEV_AI_MAXNUM; idx++)
{
if ( pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo = = NULL )
{
continue ;
}
if ( M_MEIV_TA_3 = = pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo [ 0 ] . m_u8Asdu )
{
break ;
}
} */
//===================================================================================================
idx = FindAiGroupIdx ( pDevParam - > m_sDevParam . m_sAiDBOrientation , DEV_AI_MAXNUM , M_MEIV_TA_3 , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if ( idx > = DEV_AI_MAXNUM )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU33(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
else
{
pDataUnit = & pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] ;
}
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU33(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
/ / if ( ( rtumsg - > MsgData [ 10 ] ! = pDataUnit - > m_psDataInfo [ 0 ] . m_u8Fun ) \
// || (rtumsg->MsgData[11] != pDataUnit->m_psDataInfo[0].m_u8Inf))
//{
// return;
//}
iNum = rtumsg - > MsgData [ 7 ] & 0x7f ;
if ( iNum > pDataUnit - > m_iPntNum )
{
iNum = pDataUnit - > m_iPntNum ;
}
aipnt = pDataUnit - > m_iStartPntNo ;
// wen 2003.11.01 <20> <> <EFBFBD> <EFBFBD> 9<EFBFBD> Ժ<EFBFBD> <D4BA> <EFBFBD> Ϊг <CEAA> <D0B3> ֵ<EFBFBD> Ͷ<EFBFBD> <CDB6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
iNum = 9 ;
for ( i = 0 ; i < iNum ; i + + )
{
// <20> <> <EFBFBD> <EFBFBD> 3λΪƷ <CEAA> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pntmsg . RawValue = ( short ) ( ( rtumsg - > MsgData [ 12 + 2 * i ] & 0xf8 ) + rtumsg - > MsgData [ 13 + 2 * i ] * 256 ) ;
pntmsg . RawValue / = 8 ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , aipnt + i , & pntmsg , AI_PNT_TYPE , PNT_RAWVALUE ) ;
}
}
// <20> <> <EFBFBD> <EFBFBD> ֵV<D6B5> <56> <EFBFBD> <EFBFBD>
void Buban103MEVTAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)
// = 144 --- 147
//rtumsg->MsgData[11];
// <20> <> <EFBFBD> <EFBFBD> ֵΪ<D6B5> <CEAA> <EFBFBD> <EFBFBD>
// L2<4C> <32> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[12];
// L1-L2<4C> <32> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[16];
// <20> й<EFBFBD> <D0B9> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[20];
// <20> <EFBFBD> <DEB9> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[24];
// <20> <> <EFBFBD> <EFBFBD> г <EFBFBD> <D0B3> ֵ1(4 BYTES)
//rtumsg->MsgData[28];
// ... ...
// <20> <> <EFBFBD> <EFBFBD> г <EFBFBD> <D0B3> ֵN(4 BYTES)
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
int commid ;
int aipnt , iNum , idx ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
// <20> ܹ<EFBFBD> 7<EFBFBD> 鱻<EFBFBD> <E9B1BB> ֵ
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*for(idx = 0; idx < DEV_AI_MAXNUM; idx++)
{
if ( pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo = = NULL )
{
continue ;
}
if ( M_MEV_TA_3 = = pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo [ 0 ] . m_u8Asdu )
{
break ;
}
} */
//===================================================================================================
idx = FindAiGroupIdx ( pDevParam - > m_sDevParam . m_sAiDBOrientation , DEV_AI_MAXNUM , M_MEV_TA_3 , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if ( idx > = DEV_AI_MAXNUM )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU34(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
else
{
pDataUnit = & pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] ;
}
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU34(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
/ / if ( ( rtumsg - > MsgData [ 10 ] ! = pDataUnit - > m_psDataInfo [ 0 ] . m_u8Fun ) \
// || (rtumsg->MsgData[11] != pDataUnit->m_psDataInfo[0].m_u8Inf))
//{
// return;
//}
iNum = rtumsg - > MsgData [ 7 ] & 0x7f ;
if ( iNum > pDataUnit - > m_iPntNum )
{
iNum = pDataUnit - > m_iPntNum ;
}
aipnt = pDataUnit - > m_iStartPntNo ;
}
// <20> <> <EFBFBD> <EFBFBD> ֵVI<56> <49> <EFBFBD> <EFBFBD>
void Buban103MEVITAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF) = 148
//rtumsg->MsgData[11];
// L1<4C> <31> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[12];
// L2<4C> <32> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[16];
// L3<4C> <33> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[20];
// Ul1<6C> <31> ѹ
//rtumsg->MsgData[24];
// Ul2<6C> <32> ѹ
//rtumsg->MsgData[28];
// Ul3<6C> <33> ѹ
//rtumsg->MsgData[32];
// <20> <> <EFBFBD> ڹ<EFBFBD> <DAB9> <EFBFBD>
//rtumsg->MsgData[36];
// Ƶ<> <C6B5>
//rtumsg->MsgData[38];
// Ƶ<> ʱ仯<CAB1> <E4BBAF> df/dt
//rtumsg->MsgData[40];
// <20> <> <EFBFBD> <EFBFBD> г <EFBFBD> <D0B3> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> 1(3 BYTES)
//rtumsg->MsgData[42];
// ... ...
// <20> <> <EFBFBD> <EFBFBD> г <EFBFBD> <D0B3> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> N(3 BYTES)
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
int commid ;
int aipnt , iNum , idx ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
// <20> ܹ<EFBFBD> 7<EFBFBD> 鱻<EFBFBD> <E9B1BB> ֵ
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*for(idx = 0; idx < DEV_AI_MAXNUM; idx++)
{
if ( pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo = = NULL )
{
continue ;
}
if ( M_MEVI_TA_3 = = pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] . m_psDataInfo [ 0 ] . m_u8Asdu )
{
break ;
}
} */
//===================================================================================================
idx = FindAiGroupIdx ( pDevParam - > m_sDevParam . m_sAiDBOrientation , DEV_AI_MAXNUM , M_MEVI_TA_3 , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if ( idx > = DEV_AI_MAXNUM )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU35(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
else
{
pDataUnit = & pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] ;
}
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU35(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
/ / if ( ( rtumsg - > MsgData [ 10 ] ! = pDataUnit - > m_psDataInfo [ 0 ] . m_u8Fun ) \
// || (rtumsg->MsgData[11] != pDataUnit->m_psDataInfo[0].m_u8Inf))
//{
// return;
//}
iNum = rtumsg - > MsgData [ 7 ] & 0x7f ;
if ( iNum > pDataUnit - > m_iPntNum )
{
iNum = pDataUnit - > m_iPntNum ;
}
aipnt = pDataUnit - > m_iStartPntNo ;
}
// <20> <> <EFBFBD> <EFBFBD> ֵVII<49> <49> <EFBFBD> <EFBFBD>
void Buban103MEVIINAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(92 --- 148)
//rtumsg->MsgData[11];
// <20> <> <EFBFBD> <EFBFBD> ֵ1
//rtumsg->MsgData[12];
// <20> <> <EFBFBD> <EFBFBD> ֵ2
//rtumsg->MsgData[14];
// ... ...
// <20> <> <EFBFBD> <EFBFBD> ֵn
//rtumsg->MsgData[10+2*N];
int commid ;
int i , aipnt , iNum , idx ;
AI_DEF pntmsg ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
// <20> ܹ<EFBFBD> 7<EFBFBD> 鱻<EFBFBD> <E9B1BB> ֵ
idx = FindAiGroupIdx ( pDevParam - > m_sDevParam . m_sAiDBOrientation , DEV_AI_MAXNUM , M_MEVII_NA_3 , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if ( idx > = DEV_AI_MAXNUM )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU50(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
else
{
pDataUnit = & pDevParam - > m_sDevParam . m_sAiDBOrientation [ idx ] ;
}
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU50(%d,%d) <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , rtumsg - > MsgData [ 10 ] , rtumsg - > MsgData [ 11 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
iNum = rtumsg - > MsgData [ 7 ] & 0x7f ;
if ( iNum > pDataUnit - > m_iPntNum )
{
iNum = pDataUnit - > m_iPntNum ;
}
aipnt = pDataUnit - > m_iStartPntNo ;
// wen 2003.11.01 <20> <> <EFBFBD> <EFBFBD> 9<EFBFBD> Ժ<EFBFBD> <D4BA> <EFBFBD> Ϊг <CEAA> <D0B3> ֵ<EFBFBD> Ͷ<EFBFBD> <CDB6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
// <20> <> <EFBFBD> <EFBFBD> 103û<33> д<EFBFBD> Ҫ<EFBFBD> <D2AA> 20060803 yizhonghu
// iNum = 9;
for ( i = 0 ; i < iNum ; i + + )
{
// <20> <> <EFBFBD> <EFBFBD> 3λΪƷ <CEAA> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pntmsg . RawValue = ( short ) ( ( rtumsg - > MsgData [ 12 + 2 * i ] & 0xf8 ) + rtumsg - > MsgData [ 13 + 2 * i ] * 256 ) ;
pntmsg . RawValue / = 8 ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , aipnt + i , & pntmsg , AI_PNT_TYPE , PNT_RAWVALUE ) ;
}
}
void Buban103STNAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=1
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(76 --- 79)
//rtumsg->MsgData[11];
// <20> <> ˲<EFBFBD> <CBB2> ״ָ̬ʾ <D6B8> <CABE> ֵ(VTI)
//rtumsg->MsgData[12];
// Ʒ <> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (QDS)
//rtumsg->MsgData[13];
int commid ;
int aipnt ;
AI_DEF pntmsg ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
pDataUnit = & pDevParam - > m_sDevParam . m_sStepDBOrientation ;
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU38 <20> <> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
aipnt = pDataUnit - > m_iStartPntNo + rtumsg - > MsgData [ 11 ] - 76 ;
if ( rtumsg - > MsgData [ 12 ] & 0x80 )
{
// <20> 豸<EFBFBD> <E8B1B8> ˲<EFBFBD> <CBB2> ״̬
}
else
{
// <20> 豸δ<E8B1B8> <CEB4> ˲<EFBFBD> <CBB2> ״̬
}
pntmsg . RawValue = rtumsg - > MsgData [ 12 ] & 0x7F ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , aipnt , & pntmsg , AI_PNT_TYPE , PNT_RAWVALUE ) ;
//Ʒ <> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (QDS) rtumsg->MsgData[13];
}
void Buban103SPNAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
int i , dipnt , commid ;
BYTE st ;
DI_DEF pntmsg ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(149 --- 238)
//rtumsg->MsgData[11];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ1
//rtumsg->MsgData[12];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[13];
commid = rtumsg - > PortIdx ;
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
pLinkParam = & pPortParam - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ;
pDevParam = & pLinkParam - > m_psDev [ psDevAddrParam - > m_iDevIdx ] ;
pDataUnit = & pDevParam - > m_sDevParam . m_sDiDBOrientation ;
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU1<55> <31> Ϣ<EFBFBD> <CFA2> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
for ( i = 0 ; i < pDataUnit - > m_iPntNum ; i + + )
{
// asdu<64> <75> <EFBFBD> <EFBFBD> <EFBFBD> ж<EFBFBD>
if ( pLinkParam - > m_iJudgeAsduNo ! = 0 )
{
if ( M_SP_NA_3 ! = pDataUnit - > m_psDataInfo [ i ] . m_u8Asdu )
{
continue ;
}
}
if ( ( pDataUnit - > m_psDataInfo [ i ] . m_u8Fun = = rtumsg - > MsgData [ 10 ] ) \
& & ( pDataUnit - > m_psDataInfo [ i ] . m_u8Inf = = rtumsg - > MsgData [ 11 ] ) )
{
break ;
}
}
if ( i > = pDataUnit - > m_iPntNum )
{
return ;
}
dipnt = pDataUnit - > m_iStartPntNo + i ;
st = rtumsg - > MsgData [ 12 ] & 0x01 ;
pntmsg . Status = st ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , dipnt , ( void * ) & pntmsg , DI_PNT_TYPE , PNT_STATUS ) ;
}
void Buban103SPTAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
Buban103SPTAprocessOfSoe ( rtumsg , psDevAddrParam ) ;
}
void Buban103SPTAprocessOfSoe ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
int i , dipnt , commid ;
BYTE st ;
// <20> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
time_t iTime ;
WORD wMillSeconds ;
struct tm * ptrtm ;
DI_DEF pntmsg ;
SOE_DEF sSoeData ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(149 --- 238)
//rtumsg->MsgData[11];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ1
//rtumsg->MsgData[12];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ1<CFA2> 仯ʱ<E4BBAF> <CAB1> (4 bytes)
//rtumsg->MsgData[13];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ2
//rtumsg->MsgData[17];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ2<CFA2> 仯ʱ<E4BBAF> <CAB1> (4 bytes)
//rtumsg->MsgData[18];
// ... ...
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣn
//rtumsg->MsgData[12+5*(n-1)];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣn<CFA2> 仯ʱ<E4BBAF> <CAB1> (4 bytes)
//rtumsg->MsgData[12+5*(n-1)+1];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[12+5*n];
commid = rtumsg - > PortIdx ;
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
pLinkParam = & pPortParam - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ;
pDevParam = & pLinkParam - > m_psDev [ psDevAddrParam - > m_iDevIdx ] ;
pDataUnit = & pDevParam - > m_sDevParam . m_sDiDBOrientation ;
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU1<55> <31> Ϣ<EFBFBD> <CFA2> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
for ( i = 0 ; i < pDataUnit - > m_iPntNum ; i + + )
{
// asdu<64> <75> <EFBFBD> <EFBFBD> <EFBFBD> ж<EFBFBD>
if ( pLinkParam - > m_iJudgeAsduNo ! = 0 )
{
if ( M_SP_TA_3 ! = pDataUnit - > m_psDataInfo [ i ] . m_u8Asdu )
{
continue ;
}
}
if ( ( pDataUnit - > m_psDataInfo [ i ] . m_u8Fun = = rtumsg - > MsgData [ 10 ] ) \
& & ( pDataUnit - > m_psDataInfo [ i ] . m_u8Inf = = rtumsg - > MsgData [ 11 ] ) )
{
break ;
}
}
if ( i > = pDataUnit - > m_iPntNum )
{
return ;
}
dipnt = pDataUnit - > m_iStartPntNo + i ;
st = rtumsg - > MsgData [ 12 ] & 0x01 ;
pntmsg . Status = st ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Է<EFBFBD> <D4B7> <EFBFBD> <EFBFBD> <EFBFBD> ͻ<EFBFBD> <CDBB> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> soe
if ( rtumsg - > MsgData [ 8 ] ! = M_CAUSE_QUERY )
{
// <20> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
time ( & iTime ) ;
ptrtm = localtime ( & iTime ) ;
if ( ptrtm - > tm_hour < ( rtumsg - > MsgData [ 16 ] & 0x1f ) )
{
iTime - = 24 * 3600 ;
ptrtm = localtime ( & iTime ) ;
}
ptrtm - > tm_hour = rtumsg - > MsgData [ 16 ] & 0x1f ;
ptrtm - > tm_min = rtumsg - > MsgData [ 15 ] & 0x3f ;
wMillSeconds = rtumsg - > MsgData [ 13 ] + rtumsg - > MsgData [ 14 ] * 256 ;
ptrtm - > tm_sec = wMillSeconds / 1000 ;
wMillSeconds % = 1000 ;
sSoeData . bStatus = st ;
sSoeData . iPntNo = dipnt ;
sSoeData . u8Type = 1 ; // ASDU1
sSoeData . wFaultNo = 0 ;
sSoeData . u8ProvFun = pDataUnit - > m_psDataInfo [ i ] . m_u8ProvFun ;
sSoeData . u8ProvInf = pDataUnit - > m_psDataInfo [ i ] . m_u8ProvInf ;
sSoeData . wRelativeTime = 0 ;
sSoeData . SoeTime . Year = ptrtm - > tm_year + 1900 ;
sSoeData . SoeTime . Month = ( BYTE ) ( ptrtm - > tm_mon + 1 ) ;
sSoeData . SoeTime . Day = ( BYTE ) ( ptrtm - > tm_mday ) ;
sSoeData . SoeTime . Hour = ( BYTE ) ( ptrtm - > tm_hour ) ;
sSoeData . SoeTime . Min = ( BYTE ) ( ptrtm - > tm_min ) ;
sSoeData . SoeTime . Sec = ( BYTE ) ( ptrtm - > tm_sec ) ;
sSoeData . SoeTime . mSec = wMillSeconds ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , dipnt , ( void * ) & sSoeData , DI_PNT_TYPE , PNT_SOE_TIME_EX ) ;
}
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , dipnt , ( void * ) & pntmsg , DI_PNT_TYPE , PNT_STATUS ) ;
}
void Buban103DPNAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(149 --- 238)
//rtumsg->MsgData[11];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˫<EFBFBD> <CBAB> <EFBFBD> <EFBFBD> Ϣ1
//rtumsg->MsgData[12];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˫<EFBFBD> <CBAB> <EFBFBD> <EFBFBD> Ϣ2
//rtumsg->MsgData[13];
// ... ...
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˫<EFBFBD> <CBAB> <EFBFBD> <EFBFBD> Ϣn
//rtumsg->MsgData[12+n-1];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[12+n];
}
void Buban103DPTAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(149 --- 238)
//rtumsg->MsgData[11];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ1
//rtumsg->MsgData[12];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ1<CFA2> 仯ʱ<E4BBAF> <CAB1> (4 bytes)
//rtumsg->MsgData[13];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ2
//rtumsg->MsgData[17];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ2<CFA2> 仯ʱ<E4BBAF> <CAB1> (4 bytes)
//rtumsg->MsgData[18];
// ... ...
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣn
//rtumsg->MsgData[12+5*(n-1)];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣn<CFA2> 仯ʱ<E4BBAF> <CAB1> (4 bytes)
//rtumsg->MsgData[12+5*(n-1)+1];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[12+5*n];
Buban103DPTAprocessOfSoe ( rtumsg , psDevAddrParam ) ;
}
void Buban103DPTAprocessOfSoe ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(149 --- 238)
//rtumsg->MsgData[11];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ1
//rtumsg->MsgData[12];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ1<CFA2> 仯ʱ<E4BBAF> <CAB1> (4 bytes)
//rtumsg->MsgData[13];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ2
//rtumsg->MsgData[17];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ2<CFA2> 仯ʱ<E4BBAF> <CAB1> (4 bytes)
//rtumsg->MsgData[18];
// ... ...
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣn
//rtumsg->MsgData[12+5*(n-1)];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣn<CFA2> 仯ʱ<E4BBAF> <CAB1> (4 bytes)
//rtumsg->MsgData[12+5*(n-1)+1];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[12+5*n];
}
void Buban103SSNAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
int i , j , dipnt , commid ;
BYTE st , len ;
WORD wStatusBit ;
DI_DEF pntmsg ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(149 --- 238)
//rtumsg->MsgData[11];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ1״̬<D7B4> <CCAC> ״̬<D7B4> 仯<EFBFBD> <E4BBAF> <EFBFBD> <EFBFBD> =SCD(4 BYTE)
//rtumsg->MsgData[12];
// QDS
//rtumsg->MsgData[16];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ2״̬<D7B4> <CCAC> ״̬<D7B4> 仯<EFBFBD> <E4BBAF> <EFBFBD> <EFBFBD> =SCD(4 BYTE)
//rtumsg->MsgData[17];
// QDS
//rtumsg->MsgData[21];
// ... ...
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣn״̬<D7B4> <CCAC> ״̬<D7B4> 仯<EFBFBD> <E4BBAF> <EFBFBD> <EFBFBD> =SCD(4 BYTE)
//rtumsg->MsgData[12+5*(n-1)];
// QDS
//rtumsg->MsgData[12+5*(n-1)+4];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[12+5*n];
commid = rtumsg - > PortIdx ;
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
pLinkParam = & pPortParam - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ;
pDevParam = & pLinkParam - > m_psDev [ psDevAddrParam - > m_iDevIdx ] ;
pDataUnit = & pDevParam - > m_sDevParam . m_sDiDBOrientation ;
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU1<55> <31> Ϣ<EFBFBD> <CFA2> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
for ( i = 0 ; i < pDataUnit - > m_iPntNum ; i + + )
{
// asdu<64> <75> <EFBFBD> <EFBFBD> <EFBFBD> ж<EFBFBD>
if ( pLinkParam - > m_iJudgeAsduNo ! = 0 )
{
if ( M_SS_NA_3 ! = pDataUnit - > m_psDataInfo [ i ] . m_u8Asdu )
{
continue ;
}
}
if ( ( pDataUnit - > m_psDataInfo [ i ] . m_u8Fun = = rtumsg - > MsgData [ 10 ] ) \
& & ( pDataUnit - > m_psDataInfo [ i ] . m_u8Inf = = rtumsg - > MsgData [ 11 ] ) )
{
break ;
}
}
if ( i > = pDataUnit - > m_iPntNum )
{
return ;
}
dipnt = pDataUnit - > m_iStartPntNo + i ;
len = ( int ) rtumsg - > MsgData [ 1 ] ;
st = rtumsg - > MsgData [ 12 ] & 0x01 ;
pntmsg . Status = st ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , dipnt , ( void * ) & pntmsg , DI_PNT_TYPE , PNT_STATUS ) ;
for ( i = 10 ; i < 4 + len ; i + = 5 , dipnt + = 16 )
{
wStatusBit = rtumsg - > MsgData [ i + 3 ] ;
wStatusBit = ( wStatusBit < < 8 ) + rtumsg - > MsgData [ i + 2 ] ;
for ( j = 0 ; j < 16 ; j + + )
{
if ( wStatusBit & ( 0x0001 < < j ) )
pntmsg . Status = 1 ;
else
pntmsg . Status = 0 ;
SetPntMsg ( commid , dipnt + j , ( void * ) & pntmsg , DI_PNT_TYPE , PNT_STATUS ) ;
}
}
}
void Buban103SSTAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ) & 0x7f = <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(149 --- 238)
//rtumsg->MsgData[11];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ1״̬<D7B4> <CCAC> ״̬<D7B4> 仯<EFBFBD> <E4BBAF> <EFBFBD> <EFBFBD> =SCD(4 BYTE)
//rtumsg->MsgData[12];
// QDS
//rtumsg->MsgData[16];
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[17];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(149 --- 238)
//rtumsg->MsgData[21];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ2״̬<D7B4> <CCAC> ״̬<D7B4> 仯<EFBFBD> <E4BBAF> <EFBFBD> <EFBFBD> =SCD(4 BYTE)
//rtumsg->MsgData[22];
// QDS
//rtumsg->MsgData[26];
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[27];
// ... ...
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(149 --- 238)
//rtumsg->MsgData[11+10*(n-1)];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> Ϣn״̬<D7B4> <CCAC> ״̬<D7B4> 仯<EFBFBD> <E4BBAF> <EFBFBD> <EFBFBD> =SCD(4 BYTE)
//rtumsg->MsgData[11+10*(n-1)+1];
// QDS
//rtumsg->MsgData[11+10*(n-1)+5];
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[11+10*(n-1)+6];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[11+10*n];
}
void Buban103DSNAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(149 --- 238)
//rtumsg->MsgData[11];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˫<EFBFBD> <CBAB> <EFBFBD> <EFBFBD> Ϣ1״̬<D7B4> <CCAC> ״̬<D7B4> 仯<EFBFBD> <E4BBAF> <EFBFBD> <EFBFBD> =SCD(4 BYTE)
//rtumsg->MsgData[12];
// QDS
//rtumsg->MsgData[16];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˫<EFBFBD> <CBAB> <EFBFBD> <EFBFBD> Ϣ2״̬<D7B4> <CCAC> ״̬<D7B4> 仯<EFBFBD> <E4BBAF> <EFBFBD> <EFBFBD> =SCD(4 BYTE)
//rtumsg->MsgData[17];
// QDS
//rtumsg->MsgData[21];
// ... ...
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˫<EFBFBD> <CBAB> <EFBFBD> <EFBFBD> Ϣn״̬<D7B4> <CCAC> ״̬<D7B4> 仯<EFBFBD> <E4BBAF> <EFBFBD> <EFBFBD> =SCD(4 BYTE)
//rtumsg->MsgData[12+5*(n-1)];
// QDS
//rtumsg->MsgData[12+5*(n-1)+4];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[12+5*n];
}
void Buban103DSTAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ) & 0x7f = <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(149 --- 238)
//rtumsg->MsgData[11];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˫<EFBFBD> <CBAB> <EFBFBD> <EFBFBD> Ϣ1״̬<D7B4> <CCAC> ״̬<D7B4> 仯<EFBFBD> <E4BBAF> <EFBFBD> <EFBFBD> =SCD(4 BYTE)
//rtumsg->MsgData[12];
// QDS
//rtumsg->MsgData[16];
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[17];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(149 --- 238)
//rtumsg->MsgData[21];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˫<EFBFBD> <CBAB> <EFBFBD> <EFBFBD> Ϣ2״̬<D7B4> <CCAC> ״̬<D7B4> 仯<EFBFBD> <E4BBAF> <EFBFBD> <EFBFBD> =SCD(4 BYTE)
//rtumsg->MsgData[22];
// QDS
//rtumsg->MsgData[26];
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[27];
// ... ...
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(149 --- 238)
//rtumsg->MsgData[11+10*(n-1)];
// <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˫<EFBFBD> <CBAB> <EFBFBD> <EFBFBD> Ϣn״̬<D7B4> <CCAC> ״̬<D7B4> 仯<EFBFBD> <E4BBAF> <EFBFBD> <EFBFBD> =SCD(4 BYTE)
//rtumsg->MsgData[11+10*(n-1)+1];
// QDS
//rtumsg->MsgData[11+10*(n-1)+5];
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λλ<CEBB> <CEBB> <EFBFBD> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1>
//rtumsg->MsgData[11+10*(n-1)+6];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//rtumsg->MsgData[11+10*n];
}
void Buban103WLTAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
int commid ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU48 ˮλ<CBAE> <CEBB> Ϣ<EFBFBD> <CFA2> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
}
void Buban103ITNAprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP)
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ)=<3D> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF)(6 --- 31)
//rtumsg->MsgData[11];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ƽ <EFBFBD> <C6BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> CR1(5 BYTES)
//rtumsg->MsgData[12];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ƽ <EFBFBD> <C6BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> CR2
//rtumsg->MsgData[17];
// ... ...
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ƽ <EFBFBD> <C6BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> CRn
//rtumsg->MsgData[12+5*(N-1)];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> ʶ<EFBFBD> <CAB6> (RII)
//rtumsg->MsgData[12+5*N];
int commid ;
int i , pipnt , iNum ;
PI_DEF pntmsg ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
pDataUnit = & pDevParam - > m_sDevParam . m_sPiDBOrientation ;
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU36 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
iNum = rtumsg - > MsgData [ 7 ] & 0x7f ;
pipnt = pDataUnit - > m_iStartPntNo + rtumsg - > MsgData [ 11 ] - 6 ;
for ( i = 0 ; i < iNum ; i + + )
{
// <20> ж<EFBFBD> <D0B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƿ<EFBFBD> <C7B7> <EFBFBD> Ч
if ( rtumsg - > MsgData [ 12 + 5 * i + 4 ] & 0x80 )
{
continue ;
}
// <20> <> <EFBFBD> <EFBFBD> 3λΪƷ <CEAA> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pntmsg . RawValue = rtumsg - > MsgData [ 12 + 5 * i ] + ( rtumsg - > MsgData [ 13 + 5 * i ] < < 8 )
+ ( rtumsg - > MsgData [ 13 + 5 * i ] < < 16 ) + ( rtumsg - > MsgData [ 13 + 5 * i ] < < 24 ) ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , pipnt + i , ( void * ) & pntmsg , PI_PNT_TYPE , PNT_RAWVALUE ) ;
}
}
// ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݱ<EFBFBD> <DDB1> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> е Ķ<D0B5> ֵ<EFBFBD> <D6B5> ģ<EFBFBD> <C4A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (ѹ<> 塢<EFBFBD> <E5A1A2> <EFBFBD> 뿪<EFBFBD> <EBBFAA> <EFBFBD> <EFBFBD> ))
void Buban103GDprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP):10
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ):0x81
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN): 254(0xfe)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF):
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : 240
// <20> <> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȫ<EFBFBD> <C8AB> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : 241
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> Ŀ¼ : 243
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : 244
// <20> <> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> ֹ : 245
//rtumsg->MsgData[11];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> ʶ<EFBFBD> <CAB6> (RII)
//rtumsg->MsgData[12];
// ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> <EFBFBD> Ŀ
//rtumsg->MsgData[13];
// <20> <> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <CEAA> <EFBFBD> <EFBFBD> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD> (GIN):<3A> <> Ŀ<EFBFBD> ź<EFBFBD> <C5BA> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[14];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (KOD)
// <20> <> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : KOD_NOSPECIFIED(0)
// ʵ<> <CAB5> ֵ : KOD_ACTUALVALUE(1)
// ȱʡֵ : KOD_DEFAULTVALUE(2)
// <20> <> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> С ֵ<D0A1> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ) : KOD_RANGE(3)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP1(4)
// <20> <> <EFBFBD> <EFBFBD> (n,m) : KOD_PRECISION(5)
// <20> <> <EFBFBD> <EFBFBD> : KOD_FACTOR(6)
// <20> α <EFBFBD> : KOD_REFERENCE(7)
// <20> б <EFBFBD> : KOD_ENUMERATION(8)
// <20> <> <EFBFBD> <EFBFBD> : KOD_DIMENSION(9)
// <20> <> <EFBFBD> <EFBFBD> : KOD_DESCRIPTION(10)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP2(11)
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ : KOD_PASSWORD(12)
// ֻ<> <D6BB> : KOD_READONLY(13)
// ֻд : KOD_WRITEONLY(14)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP3(15)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP4(16)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP5(17)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP6(18)
// <20> <> Ӧ<EFBFBD> Ĺ<EFBFBD> <C4B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͺ <EFBFBD> <CDBA> <EFBFBD> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> : KOD_CORFUNCANDINF(19)
// <20> <> Ӧ<EFBFBD> <D3A6> <EFBFBD> ¼<EFBFBD> : KOD_COREVENT(20)
// <20> б <EFBFBD> <D0B1> <EFBFBD> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD> : KOD_ENUMTEXTARRAY(21)
// <20> б <EFBFBD> <D0B1> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> : KOD_ENUMVALUEARRAY(22)
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ : KOD_RELATEDENTRIES(23)
//rtumsg->MsgData[16];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[17];
//DATAID_NO : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_OS8ASCII : 8λASCII
//DATAID_BSTRING : 8λ2<CEBB> <32> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_UIX : <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_INT : <20> <> <EFBFBD> <EFBFBD>
//DATAID_UFLOAT : <20> <EFBFBD> <DEB7> Ÿ<EFBFBD> <C5B8> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_FLOAT : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_754SHORT : R32.23 IEEE <20> <> 754<35> <34> ʵ<EFBFBD> <CAB5>
//DATAID_754REAL : R64.53 IEEE <20> <> 754ʵ<34> <CAB5>
//DATAID_DOUBLE : ˫<> <CBAB> <EFBFBD> <EFBFBD> Ϣ
//DATAID_SINGLE : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//DATAID_13BITS : <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ(13BITS)
//DATAID_SORTIDNO : ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD>
//DATAID_WITHTIME : <20> <> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD>
//DATAID_WITHTIMESPACE : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD>
//DATAID_STRUCT : <20> <> <EFBFBD> ݽṹ
// <20> <> <EFBFBD> ݳߴ <DDB3>
//rtumsg->MsgData[18]
// <20> <> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[19]
// <20> <> <EFBFBD> <EFBFBD> ֵ(<28> <> <EFBFBD> ȸ<EFBFBD> <C8B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
// 2 ... n <20> <> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
int commid ;
int i , iGroupNo , iCfgGroupIdx ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
// <20> <> <EFBFBD> <EFBFBD> ת<EFBFBD> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ﴦ<EFBFBD> <EFB4A6>
if ( rtumsg - > MsgData [ 12 ] = = RII_PROV_ID )
{
if ( pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuCommid > = 0 )
{
if ( psDevAddrParam - > m_uchCommAddr = = \
pLinkParam - > m_sBaoHuCmdParam . m_sRealAddrParam . m_uchCommAddr )
{
// <20> жϳ <D0B6> ʱʱ<CAB1> <CAB1> Ϊ5<CEAA> <35> <EFBFBD> <EFBFBD>
if ( JudgeTimeOut ( & pLinkParam - > m_sBaoHuCmdParam . m_sBaoHuCmdStartTime , 5 * 60 ) = = FALSE )
{
if ( MSGTYPE_BAOHU_103CMD = = pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuMsgType )
{
// ת<> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> ת<EFBFBD> <D7AA> <EFBFBD> ˿<EFBFBD>
rtumsg - > MsgData [ 9 ] = ( BYTE ) pDevParam - > m_sDevParam . m_iProvAddr ;
rtumsg - > PortIdx = pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuCommid ;
rtumsg - > MsgType = MSGTYPE_BAOHU_103DATA ;
PutBaohuDataToPort ( rtumsg ) ;
}
else if ( MSGTYPE_BAOHU_SCADACMD = = pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuMsgType )
{
//rtumsg->MsgData[9] = (BYTE)pDevParam->m_sDevParam.m_iProvAddr;
//rtumsg->PortIdx = pLinkParam->m_sBaoHuCmdParam.m_iBaoHuCommid;
rtumsg - > MsgType = MSGTYPE_BAOHU_SCADADATA ;
// <20> <> <EFBFBD> ڲ<EFBFBD> <DAB2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʽ ת<CABD> <D7AA>
Buban103ScadaProtocolExchange ( commid , rtumsg ) ;
}
// û<> к<EFBFBD> <D0BA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ( rtumsg - > MsgData [ 13 ] & 0x80 ) = = 0 )
{
pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuCommid = - 1 ;
pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuMsgType = 0 ;
}
return ;
}
else
{
pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuCommid = - 1 ;
}
}
}
}
//<2F> <> <20> <>
iGroupNo = rtumsg - > MsgData [ 14 ] ;
for ( i = 0 ; i < pDevParam - > m_sDevParam . m_iCfgGroupNum ; i + + )
{
if ( pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iGroupNo = = iGroupNo )
{
iCfgGroupIdx = i ;
break ;
}
}
if ( i > = pDevParam - > m_sDevParam . m_iCfgGroupNum )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10 ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> ʱ<EFBFBD> <CAB1> Group=%d<> <64> <EFBFBD> ڴ<EFBFBD> <DAB4> <EFBFBD> <EFBFBD> <EFBFBD> Χ <EFBFBD> <CEA7> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
switch ( pDevParam - > m_sDevParam . m_saGroupDef [ iCfgGroupIdx ] . m_iDataType )
{
// <20> <> <EFBFBD> <EFBFBD> ģ<EFBFBD> <C4A3> <EFBFBD> <EFBFBD>
case AI_PNT_TYPE :
Buban103GDprocessWithAI ( rtumsg , psDevAddrParam , iCfgGroupIdx ) ;
break ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
case DI_PNT_TYPE :
Buban103GDprocessWithDI ( rtumsg , psDevAddrParam , iCfgGroupIdx ) ;
break ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
case PI_PNT_TYPE :
Buban103GDprocessWithPI ( rtumsg , psDevAddrParam , iCfgGroupIdx ) ;
break ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ģ<EFBFBD> <C4A3> <EFBFBD> <EFBFBD>
case PROTECT_AI_PNT_TYPE :
Buban103GDprocessWithPAI ( rtumsg , psDevAddrParam , iCfgGroupIdx ) ;
break ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
case PROTECT_DI_PNT_TYPE :
Buban103GDprocessWithPDI ( rtumsg , psDevAddrParam , iCfgGroupIdx ) ;
break ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ
case PROTECT_FIX_PNT_TYPE :
Buban103GDprocessWithPFIX ( rtumsg , psDevAddrParam , iCfgGroupIdx ) ;
break ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD>
case PROTECT_EVENT_PNT_TYPE :
Buban103GDprocessWithPEVENT ( rtumsg , psDevAddrParam , iCfgGroupIdx ) ;
break ;
default :
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10<31> <30> <EFBFBD> <EFBFBD> ʱ, Group=%d<> <64> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (=%d)<29> <> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ,
pDevParam - > m_sDevParam . m_saGroupDef [ iCfgGroupIdx ] . m_iGroupNo ,
pDevParam - > m_sDevParam . m_saGroupDef [ iCfgGroupIdx ] . m_iDataType ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
}
void Buban103YkAck ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP):64
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ):0x81
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
//M_CAUSE_REMOTE : // Զ<> <D4B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN): 1
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF): 48 --- 75
//rtumsg->MsgData[11];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (DCC)
//rtumsg->MsgData[12];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> ʶ<EFBFBD> <CAB6> (RII)
//rtumsg->MsgData[13];
int commid ;
int iYkNo ;
BYTE buf [ 16 ] ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
if ( pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iPntNum < = 0 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU64 δ<> <CEB4> <EFBFBD> <EFBFBD> ң<EFBFBD> ص<EFBFBD> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
iYkNo = rtumsg - > MsgData [ 11 ] - 48 + pDevParam - > m_sDevParam . m_iYkStartPnt ;
if ( iYkNo > = 0 )
{
// 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>
buf [ 0 ] = ( BYTE ) ( commid & 0xFF ) ;
buf [ 1 ] = ( BYTE ) ( ( commid & 0xFF00 ) < < 8 ) ;
buf [ 2 ] = ( BYTE ) ( ( commid & 0xFF0000 ) < < 16 ) ;
buf [ 3 ] = ( BYTE ) ( ( commid & 0xFF000000 ) < < 24 ) ;
buf [ 4 ] = ( BYTE ) ( iYkNo & 0xFF ) ;
buf [ 5 ] = ( BYTE ) ( ( iYkNo & 0xFF00 ) < < 8 ) ;
buf [ 6 ] = ( BYTE ) ( ( iYkNo & 0xFF0000 ) < < 16 ) ;
buf [ 7 ] = ( BYTE ) ( ( iYkNo & 0xFF000000 ) < < 24 ) ;
switch ( ( rtumsg - > MsgData [ 12 ] & 0xc0 ) > > 6 )
{
case 0 : //
buf [ 8 ] = STEP_YKYT_EXEC ;
break ;
case 2 :
buf [ 8 ] = STEP_YKYT_SELECT ;
break ;
case 3 :
buf [ 8 ] = STEP_YKYT_CANCEL ;
break ;
default :
buf [ 8 ] = STEP_YKYT_NOEXEC ;
break ;
}
switch ( rtumsg - > MsgData [ 12 ] & 0x03 )
{
case 0 :
case 3 :
buf [ 8 ] = STEP_YKYT_NOEXEC ;
break ;
default :
buf [ 9 ] = ( rtumsg - > MsgData [ 12 ] & 0x03 ) | 0x80 ;
break ;
}
if ( ShmGetDispYkYtFlag ( ) )
{
# ifdef _DEBUG_MSG_
//sprintf(szbuf, "<22> ˿<EFBFBD> %d <20> <> ·<EFBFBD> <C2B7> ַ=%d װ<> õ<EFBFBD> ַ%d RII=0x%02x, ң<> ص<EFBFBD> <D8B5> <EFBFBD> =%d, op=0x%02x!!!\n",
// commid, rtumsg->MsgData[5], rtumsg->MsgData[9], rtumsg->MsgData[13], iYkNo, rtumsg->MsgData[12]);
//DebugPrint(szbuf);
sprintf ( szbuf , " TIP_(%04d): commid=%d linkaddr=%d devaddr=%d RII=0x%02x ykpnt=%d, op=0x%02x. \n " ,
_getpid ( ) , commid , rtumsg - > MsgData [ 5 ] , rtumsg - > MsgData [ 9 ] , rtumsg - > MsgData [ 13 ] , iYkNo , rtumsg - > MsgData [ 12 ] ) ;
DebugPrint ( szbuf ) ;
# endif
}
Buban103YkYtProcess ( commid , buf , 10 ) ;
}
}
void Buban103YtAck ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP):65
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ):0x81
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
//M_CAUSE_REMOTE : // Զ<> <D4B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN): 1
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF): 48 --- 75
//rtumsg->MsgData[11];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (RCC)
//rtumsg->MsgData[12];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> ʶ<EFBFBD> <CAB6> (RII)
//rtumsg->MsgData[13];
int commid ;
int iYtNo ;
BYTE buf [ 16 ] ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
if ( pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iPntNum < = 0 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10 δ<> <CEB4> <EFBFBD> <EFBFBD> ң<EFBFBD> ص<EFBFBD> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
iYtNo = rtumsg - > MsgData [ 11 ] - 48 + pDevParam - > m_sDevParam . m_iYtStartPnt ;
if ( iYtNo > = 0 )
{
// 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>
buf [ 0 ] = ( BYTE ) ( commid & 0xFF ) ;
buf [ 1 ] = ( BYTE ) ( ( commid & 0xFF00 ) < < 8 ) ;
buf [ 2 ] = ( BYTE ) ( ( commid & 0xFF0000 ) < < 16 ) ;
buf [ 3 ] = ( BYTE ) ( ( commid & 0xFF000000 ) < < 24 ) ;
buf [ 4 ] = ( BYTE ) ( iYtNo & 0xFF ) ;
buf [ 5 ] = ( BYTE ) ( ( iYtNo & 0xFF00 ) < < 8 ) ;
buf [ 6 ] = ( BYTE ) ( ( iYtNo & 0xFF0000 ) < < 16 ) ;
buf [ 7 ] = ( BYTE ) ( ( iYtNo & 0xFF000000 ) < < 24 ) ;
switch ( ( rtumsg - > MsgData [ 12 ] & 0xc0 ) > > 6 )
{
case 0 : //
buf [ 8 ] = STEP_YT_EXEC ;
break ;
case 2 :
buf [ 8 ] = STEP_YT_SELECT ;
break ;
case 3 :
buf [ 8 ] = STEP_YT_CANCEL ;
break ;
default :
buf [ 8 ] = STEP_YKYT_NOEXEC ;
break ;
}
switch ( rtumsg - > MsgData [ 12 ] & 0x03 )
{
case 0 :
case 3 :
buf [ 8 ] = STEP_YKYT_NOEXEC ;
break ;
default :
buf [ 9 ] = ( rtumsg - > MsgData [ 12 ] & 0x03 ) | 0x80 ;
break ;
}
if ( ShmGetDispYkYtFlag ( ) )
{
# ifdef _DEBUG_MSG_
//sprintf(szbuf, "<22> ˿<EFBFBD> %d <20> <> ·<EFBFBD> <C2B7> ַ=%d װ<> õ<EFBFBD> ַ%d RII=0x%02x, ң<> <D2A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> =%d, op=0x%02x!!!\n",
// commid, rtumsg->MsgData[5], rtumsg->MsgData[9], rtumsg->MsgData[13], iYtNo, rtumsg->MsgData[12]);
//DebugPrint(szbuf);
sprintf ( szbuf , " TIP_(%04d): commid=%d linkaddr=%d devaddr=%d RII=0x%02x ytpnt=%d, op=0x%02x. \n " ,
_getpid ( ) , commid , rtumsg - > MsgData [ 5 ] , rtumsg - > MsgData [ 9 ] , rtumsg - > MsgData [ 13 ] , iYtNo , rtumsg - > MsgData [ 12 ] ) ;
DebugPrint ( szbuf ) ;
# endif
}
Buban103YkYtProcess ( commid , buf , 10 ) ;
}
}
void Buban103GDprocessWithAI ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam , i_32 iGroupIdx )
{
int i , j , commid ;
BYTE u8KOD , u8INF , u8NGD , u8DataType ;
BYTE u8DataNum , u8DataLen ;
int aipnt , aistart , stn , iOffset ;
AI_DEF pntmsg ;
VALUEDEF sValue ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
iOffset = 14 ;
if ( iOffset > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(AI)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
stn = pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] . m_iStationNo ;
if ( stn < = 0 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(AI)_Group=%d <20> <> Ϣ<EFBFBD> <CFA2> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" , \
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , \
pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] . m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
}
u8INF = rtumsg - > MsgData [ 11 ] ;
u8NGD = rtumsg - > MsgData [ 13 ] & 0x3f ;
aistart = pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] . m_iStartPntNo ;
for ( i = 0 ; i < u8NGD ; i + + )
{
if ( ( iOffset + 6 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(AI)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
}
// <20> <> <EFBFBD> ݳ<EFBFBD> <DDB3> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݳ<EFBFBD> *<2A> <> <EFBFBD> <EFBFBD> )
u8DataNum = rtumsg - > MsgData [ iOffset + 5 ] ;
u8DataLen = rtumsg - > MsgData [ iOffset + 4 ] ;
if ( ( iOffset + 6 + u8DataLen * u8DataNum ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(AI)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <EFBFBD> ź<EFBFBD> <C5BA> <EFBFBD> Ŀ<EFBFBD> <C4BF>
aipnt = aistart + rtumsg - > MsgData [ iOffset + 1 ] ;
iOffset + = 2 ;
u8KOD = rtumsg - > MsgData [ iOffset + + ] ;
if ( KOD_ACTUALVALUE ! = u8KOD )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(AI)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> KOD=%d<> <64> <EFBFBD> ڴ<EFBFBD> <DAB4> <EFBFBD> <EFBFBD> <EFBFBD> Χ <EFBFBD> ڣ<EFBFBD> ֻ<EFBFBD> <D6BB> <EFBFBD> <EFBFBD> ʵ<EFBFBD> <CAB5> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , u8KOD ) ;
DebugPrint ( szbuf ) ;
# endif
iOffset + = u8DataLen * u8DataNum + 3 ;
continue ;
}
u8DataType = rtumsg - > MsgData [ iOffset + + ] ;
iOffset + = 2 ;
for ( j = 0 ; j < u8DataNum ; j + + )
{
// wen 2004.02.01 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> Ϊ0<CEAA> <30> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĿΪ<C4BF> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ( ( aipnt - aistart ) = = 0 ) & & ( j = = 0 ) )
{
if ( DATAID_BSTRING ! = u8DataType )
iOffset + = u8DataLen ;
else
iOffset + = ( u8DataLen + 7 ) / 8 ;
continue ;
}
if ( TRUE = = GetOneValueOfASDU10 ( & rtumsg - > MsgData [ iOffset ] , & sValue , u8DataType , u8DataLen ) )
{
switch ( sValue . m_iDataType )
{
case DT_UINT : // <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pntmsg . RawValue = ( WORD ) sValue . m_unValue . m_uValue ;
SetPntMsg ( stn - 1 , aipnt + j , & pntmsg , AI_PNT_TYPE , PNT_RAWVALUE ) ;
break ;
case DT_INT :
pntmsg . RawValue = ( WORD ) sValue . m_unValue . m_iValue ;
SetPntMsg ( stn - 1 , aipnt + j , & pntmsg , AI_PNT_TYPE , PNT_RAWVALUE ) ;
break ;
case DT_FLOAT :
pntmsg . RawValue = ( WORD ) sValue . m_unValue . m_fValue ;
SetPntMsg ( stn - 1 , aipnt + j , & pntmsg , AI_PNT_TYPE , PNT_RAWVALUE ) ;
break ;
case DT_CONTROL :
pntmsg . RawValue = ( WORD ) sValue . m_unValue . m_dwValue ;
SetPntMsg ( stn - 1 , aipnt + j , & pntmsg , AI_PNT_TYPE , PNT_RAWVALUE ) ;
break ;
case DT_NO : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
case DT_STRING :
case DT_BINARY :
default :
break ;
}
}
iOffset + = u8DataLen ;
}
}
}
void Buban103GDprocessWithDI ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam , i_32 iGroupIdx )
{
int i , j , commid ;
BYTE u8KOD , u8INF , u8NGD , u8DataType ;
BYTE u8DataNum , u8DataLen ;
int dipnt , distart , stn , iOffset ;
DI_DEF pntmsg ;
VALUEDEF sValue ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
iOffset = 14 ;
if ( iOffset > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(DI)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
stn = pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] . m_iStationNo ;
if ( stn < = 0 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(DI)_Group=%d <20> <> Ϣ<EFBFBD> <CFA2> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" , \
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , \
pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] . m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
}
u8INF = rtumsg - > MsgData [ 11 ] ;
u8NGD = rtumsg - > MsgData [ 13 ] & 0x3f ;
distart = pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] . m_iStartPntNo ;
for ( i = 0 ; i < u8NGD ; i + + )
{
if ( ( iOffset + 6 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(DI)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
}
// <20> <> <EFBFBD> ݳ<EFBFBD> <DDB3> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݳ<EFBFBD> *<2A> <> <EFBFBD> <EFBFBD> )
u8DataNum = rtumsg - > MsgData [ iOffset + 5 ] ;
u8DataLen = rtumsg - > MsgData [ iOffset + 4 ] ;
if ( ( iOffset + 6 + u8DataLen * u8DataNum ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(DI)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <EFBFBD> ź<EFBFBD> <C5BA> <EFBFBD> Ŀ<EFBFBD> <C4BF>
dipnt = distart + rtumsg - > MsgData [ iOffset + 1 ] ;
iOffset + = 2 ;
u8KOD = rtumsg - > MsgData [ iOffset + + ] ;
if ( KOD_ACTUALVALUE ! = u8KOD )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(DI)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> KOD=%d<> <64> <EFBFBD> ڴ<EFBFBD> <DAB4> <EFBFBD> <EFBFBD> <EFBFBD> Χ <EFBFBD> ڣ<EFBFBD> ֻ<EFBFBD> <D6BB> <EFBFBD> <EFBFBD> ʵ<EFBFBD> <CAB5> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , u8KOD ) ;
DebugPrint ( szbuf ) ;
# endif
iOffset + = u8DataLen * u8DataNum + 3 ;
continue ;
}
u8DataType = rtumsg - > MsgData [ iOffset + + ] ;
iOffset + = 2 ;
for ( j = 0 ; j < u8DataNum ; j + + )
{
// wen 2004.02.01 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> Ϊ0<CEAA> <30> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĿΪ<C4BF> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ( ( dipnt - distart ) = = 0 ) & & ( j = = 0 ) )
{
if ( DATAID_BSTRING ! = u8DataType )
iOffset + = u8DataLen ;
else
iOffset + = ( u8DataLen + 7 ) / 8 ;
continue ;
}
if ( TRUE = = GetOneValueOfASDU10 ( & rtumsg - > MsgData [ iOffset ] , & sValue , u8DataType , u8DataLen ) )
{
switch ( sValue . m_iDataType )
{
case DT_BINARY :
if ( sValue . m_iDataNum > 1 )
{
if ( ( sValue . m_unValue . m_dwValue > 0 ) \
& & ( sValue . m_unValue . m_dwValue < 3 ) )
{
pntmsg . Status = ( BYTE ) ( sValue . m_unValue . m_dwValue - 1 ) ;
}
else
{
pntmsg . Status = 0 ;
}
}
else
{
pntmsg . Status = ( BYTE ) ( sValue . m_unValue . m_dwValue ) ;
}
SetPntMsg ( stn - 1 , dipnt + j , & pntmsg , DI_PNT_TYPE , PNT_STATUS ) ;
break ;
case DT_UINT : // <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( sValue . m_unValue . m_uValue ! = 0 )
{
pntmsg . Status = 1 ;
}
else
{
pntmsg . Status = 0 ;
}
SetPntMsg ( stn - 1 , dipnt + j , & pntmsg , DI_PNT_TYPE , PNT_STATUS ) ;
break ;
case DT_INT :
if ( sValue . m_unValue . m_iValue ! = 0 )
{
pntmsg . Status = 1 ;
}
else
{
pntmsg . Status = 0 ;
}
SetPntMsg ( stn - 1 , dipnt + j , & pntmsg , DI_PNT_TYPE , PNT_STATUS ) ;
break ;
case DT_FLOAT :
case DT_CONTROL :
case DT_NO : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
case DT_STRING :
default :
break ;
}
}
iOffset + = u8DataLen ;
}
}
}
void Buban103GDprocessWithPI ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam , i_32 iGroupIdx )
{
int i , j , commid ;
BYTE u8KOD , u8INF , u8NGD , u8DataType ;
BYTE u8DataNum , u8DataLen ;
int pipnt , pistart , stn , iOffset ;
PI_DEF pntmsg ;
VALUEDEF sValue ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
iOffset = 14 ;
if ( iOffset > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(PI)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
stn = pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] . m_iStationNo ;
if ( stn < = 0 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(PI)_Group=%d <20> <> Ϣ<EFBFBD> <CFA2> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" , \
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , \
pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] . m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
}
u8INF = rtumsg - > MsgData [ 11 ] ;
u8NGD = rtumsg - > MsgData [ 13 ] & 0x3f ;
pistart = pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] . m_iStartPntNo ;
for ( i = 0 ; i < u8NGD ; i + + )
{
if ( ( iOffset + 6 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(PI)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
}
// <20> <> <EFBFBD> ݳ<EFBFBD> <DDB3> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݳ<EFBFBD> *<2A> <> <EFBFBD> <EFBFBD> )
u8DataNum = rtumsg - > MsgData [ iOffset + 5 ] ;
u8DataLen = rtumsg - > MsgData [ iOffset + 4 ] ;
if ( ( iOffset + 6 + u8DataLen * u8DataNum ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(PI)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <EFBFBD> ź<EFBFBD> <C5BA> <EFBFBD> Ŀ<EFBFBD> <C4BF>
pipnt = pistart + rtumsg - > MsgData [ iOffset + 1 ] ;
iOffset + = 2 ;
u8KOD = rtumsg - > MsgData [ iOffset + + ] ;
if ( KOD_ACTUALVALUE ! = u8KOD )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(PI)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> KOD=%d<> <64> <EFBFBD> ڴ<EFBFBD> <DAB4> <EFBFBD> <EFBFBD> <EFBFBD> Χ <EFBFBD> ڣ<EFBFBD> ֻ<EFBFBD> <D6BB> <EFBFBD> <EFBFBD> ʵ<EFBFBD> <CAB5> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , u8KOD ) ;
DebugPrint ( szbuf ) ;
# endif
iOffset + = u8DataLen * u8DataNum + 3 ;
continue ;
}
u8DataType = rtumsg - > MsgData [ iOffset + + ] ;
iOffset + = 2 ;
for ( j = 0 ; j < u8DataNum ; j + + )
{
// wen 2004.02.01 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> Ϊ0<CEAA> <30> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĿΪ<C4BF> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ( ( pipnt - pistart ) = = 0 ) & & ( j = = 0 ) )
{
if ( DATAID_BSTRING ! = u8DataType )
iOffset + = u8DataLen ;
else
iOffset + = ( u8DataLen + 7 ) / 8 ;
continue ;
}
if ( TRUE = = GetOneValueOfASDU10 ( & rtumsg - > MsgData [ iOffset ] , & sValue , u8DataType , u8DataLen ) )
{
switch ( sValue . m_iDataType )
{
case DT_UINT : // <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pntmsg . RawValue = sValue . m_unValue . m_uValue ;
SetPntMsg ( stn - 1 , pipnt + j , & pntmsg , PI_PNT_TYPE , PNT_RAWVALUE ) ;
break ;
case DT_INT :
pntmsg . RawValue = sValue . m_unValue . m_iValue ;
SetPntMsg ( stn - 1 , pipnt + j , & pntmsg , PI_PNT_TYPE , PNT_RAWVALUE ) ;
break ;
case DT_FLOAT :
pntmsg . RawValue = ( u_long ) sValue . m_unValue . m_fValue ;
SetPntMsg ( stn - 1 , pipnt + j , & pntmsg , PI_PNT_TYPE , PNT_RAWVALUE ) ;
break ;
case DT_CONTROL :
case DT_NO : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
case DT_BINARY :
case DT_STRING :
default :
break ;
}
}
iOffset + = u8DataLen ;
}
}
}
void Buban103GDprocessWithPAI ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam , i_32 iGroupIdx )
{
int i , j , commid , iItemNum , iStrLen ;
BYTE u8KOD , u8INF , u8DataType ;
BYTE u8DataNum , u8DataLen , u8ItemNo ;
int iOffset ;
double fValue ;
BOOL bFirst , bNumChanged ;
VALUEDEF sValue ;
GROUPDEF * pGroupParam ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
bNumChanged = FALSE ;
bFirst = TRUE ;
iOffset = 14 ;
pGroupParam = & pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] ;
if ( ( iOffset + 3 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
u8INF = rtumsg - > MsgData [ 11 ] ;
u8KOD = rtumsg - > MsgData [ 16 ] ;
pGroupParam - > m_u8NGD = rtumsg - > MsgData [ 13 ] ;
if ( pGroupParam - > m_iPntNum < = 0 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> ݿռ <DDBF> Ϊ<EFBFBD> <CEAA> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
// ֻ<> <D6BB> <EFBFBD> <EFBFBD> ʵ<EFBFBD> <CAB5> ֵ
if ( KOD_ACTUALVALUE ! = u8KOD )
{
return ;
}
iItemNum = pGroupParam - > m_u8NGD & 0x3F ;
for ( i = 0 ; i < iItemNum ; i + + )
{
if ( ( iOffset + 6 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <EFBFBD> ݳ<EFBFBD> <DDB3> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݳ<EFBFBD> *<2A> <> <EFBFBD> <EFBFBD> )
u8DataNum = rtumsg - > MsgData [ iOffset + 5 ] ;
u8DataLen = rtumsg - > MsgData [ iOffset + 4 ] ;
if ( ( iOffset + 6 + u8DataLen * u8DataNum ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <20> <>
// <20> <> Ŀ<EFBFBD> <C4BF>
u8ItemNo = rtumsg - > MsgData [ iOffset + 1 ] ;
iOffset + = 2 ;
if ( TRUE = = bFirst )
{
if ( u8ItemNo = = 0 )
{
pGroupParam - > m_u32CurPntNo = 1 ;
}
else if ( u8ItemNo < = pGroupParam - > m_iStartItemNo )
{
pGroupParam - > m_u32CurPntNo = 1 ;
}
if ( ( M_INF_WRITEITEMWITHACK = = u8INF )
& & ( pGroupParam - > m_bInit = = FALSE ) )
{
for ( j = 0 ; j < pGroupParam - > m_iPntNum ; j + + )
{
if ( pGroupParam - > m_pu8GIN [ j ] = = u8ItemNo )
{
break ;
}
}
if ( j > = pGroupParam - > m_iPntNum )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)дȷ<D0B4> ϴ<EFBFBD> <CFB4> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> GIN=%d!!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , u8ItemNo , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
pGroupParam - > m_u32CurPntNo = j + 1 ;
}
bFirst = FALSE ;
}
if ( u8KOD ! = rtumsg - > MsgData [ iOffset ] )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)дȷ<D0B4> ϴ<EFBFBD> <CFB4> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> KOD=%d<> <64> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> KOD=%d<> <64> <EFBFBD> <EFBFBD> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo , rtumsg - > MsgData [ iOffset ] , u8KOD ) ;
DebugPrint ( szbuf ) ;
# endif
iOffset + = u8DataLen * u8DataNum + 4 ;
continue ;
}
else
{
iOffset + + ;
}
u8DataType = rtumsg - > MsgData [ iOffset + + ] ;
iOffset + = 2 ;
for ( j = 0 ; j < ( int ) u8DataNum ; j + + )
{
if ( ( int ) pGroupParam - > m_u32CurPntNo > pGroupParam - > m_iPntNum )
{
break ;
}
if ( pGroupParam - > m_bInit = = FALSE )
{
//pGroupParam->m_pu8DataLen[pGroupParam->m_u32CurPntNo-1] = u8DataLen;
//pGroupParam->m_pu8DataType[pGroupParam->m_u32CurPntNo-1] = u8DataType;
pGroupParam - > m_pu8GIN [ pGroupParam - > m_u32CurPntNo - 1 ] = u8ItemNo + j ;
}
if ( GetOneValueOfASDU10 ( & rtumsg - > MsgData [ iOffset ] , & sValue , u8DataType , u8DataLen ) = = FALSE )
{
iOffset + = u8DataLen ;
continue ;
}
iOffset + = u8DataLen ;
switch ( sValue . m_iDataType )
{
case DT_UINT : // <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
fValue = sValue . m_unValue . m_uValue ;
break ;
case DT_INT :
fValue = sValue . m_unValue . m_iValue ;
break ;
case DT_FLOAT :
fValue = sValue . m_unValue . m_fValue ;
break ;
case DT_CONTROL :
fValue = sValue . m_unValue . m_dwValue ;
break ;
case DT_STRING :
fValue = - 1 ;
break ;
case DT_BINARY :
fValue = sValue . m_unValue . m_dwValue ;
break ;
case DT_NO : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
default :
fValue = - 1 ;
break ;
}
if ( pGroupParam - > m_bInit = = FALSE )
{
if ( ( u8ItemNo = = 0 ) & & ( j = = 0 ) )
{
if ( ( fValue > 0 ) & & ( KOD_ACTUALVALUE = = u8KOD ) )
{
if ( ( int ) fValue > pGroupParam - > m_iPntNum )
{
//pGroupParam->m_iPntNum = (int)sValue.m_unValue.m_uValue;
bNumChanged = TRUE ;
}
else
{
pGroupParam - > m_iPntNum = ( int ) fValue ;
}
}
}
}
if ( TRUE = = bNumChanged )
{
//freeallfixmemory
}
if ( DT_STRING ! = sValue . m_iDataType )
{
pGroupParam - > m_psDataInfo [ pGroupParam - > m_u32CurPntNo - 1 ] . m_fValue = ( float ) fValue ;
}
else
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( KOD_DESCRIPTION = = u8KOD )
{
iStrLen = sizeof ( pGroupParam - > m_psDataInfo - > m_szName ) - 1 ;
if ( iStrLen > sValue . m_iDataNum )
{
iStrLen = sValue . m_iDataNum ;
}
memcpy ( pGroupParam - > m_psDataInfo - > m_szName , sValue . m_szValue , iStrLen ) ;
pGroupParam - > m_psDataInfo - > m_szName [ iStrLen ] = 0 ;
}
else if ( KOD_DIMENSION = = u8KOD )
{
iStrLen = sizeof ( pGroupParam - > m_psDataInfo - > m_szUnit ) - 1 ;
if ( iStrLen > sValue . m_iDataNum )
{
iStrLen = sValue . m_iDataNum ;
}
memcpy ( pGroupParam - > m_psDataInfo - > m_szUnit , sValue . m_szValue , iStrLen ) ;
pGroupParam - > m_psDataInfo - > m_szUnit [ iStrLen ] = 0 ;
}
}
if ( pGroupParam - > m_bInit = = FALSE )
{
pGroupParam - > m_psDataInfo [ pGroupParam - > m_u32CurPntNo - 1 ] . m_u32DataID = u8DataType ;
}
pGroupParam - > m_u32CurPntNo + + ;
}
}
if ( pGroupParam - > m_iPntNum > 0 )
{
if ( ( int ) pGroupParam - > m_u32CurPntNo > = pGroupParam - > m_iPntNum )
{
pGroupParam - > m_bInit = TRUE ;
pGroupParam - > m_u32CurPntNo = 1 ;
}
}
}
void Buban103GDprocessWithPDI ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam , i_32 iGroupIdx )
{
Buban103GDprocessWithPAI ( rtumsg , psDevAddrParam , iGroupIdx ) ;
}
void Buban103GDprocessWithPFIX ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam , i_32 iGroupIdx )
{
int i , j , commid , iItemNum , iStrLen ;
BYTE u8KOD , u8INF , u8DataType ;
BYTE u8DataNum , u8DataLen , u8ItemNo ;
int iOffset ;
double fValue ;
BOOL bFirst , bNumChanged ;
VALUEDEF sValue ;
GROUPDEF * pGroupParam ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
bNumChanged = FALSE ;
bFirst = TRUE ;
iOffset = 14 ;
pGroupParam = & pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] ;
if ( ( iOffset + 3 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
u8INF = rtumsg - > MsgData [ 11 ] ;
u8KOD = rtumsg - > MsgData [ 16 ] ;
pGroupParam - > m_u8NGD = rtumsg - > MsgData [ 13 ] ;
if ( pGroupParam - > m_iPntNum > 0 )
{
if ( pGroupParam - > m_pu8DataLen = = NULL )
{
pGroupParam - > m_pu8DataLen = ( BYTE * ) HEAP_MALLOC ( pGroupParam - > m_iPntNum * sizeof ( BYTE ) ) ;
Buban103DispMalloc ( commid , pGroupParam - > m_iPntNum * sizeof ( BYTE ) ) ;
}
if ( pGroupParam - > m_pu8DataType = = NULL )
{
pGroupParam - > m_pu8DataType = ( BYTE * ) HEAP_MALLOC ( pGroupParam - > m_iPntNum * sizeof ( BYTE ) ) ;
Buban103DispMalloc ( commid , pGroupParam - > m_iPntNum * sizeof ( BYTE ) ) ;
}
if ( pGroupParam - > m_pu8GIN = = NULL )
{
pGroupParam - > m_pu8GIN = ( BYTE * ) HEAP_MALLOC ( pGroupParam - > m_iPntNum * sizeof ( BYTE ) ) ;
Buban103DispMalloc ( commid , pGroupParam - > m_iPntNum * sizeof ( BYTE ) ) ;
}
}
else
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> ݿռ <DDBF> Ϊ<EFBFBD> <CEAA> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
// ֻ<> <D6BB> <EFBFBD> <EFBFBD> ʵ<EFBFBD> <CAB5> ֵ
if ( KOD_ACTUALVALUE ! = u8KOD )
{
return ;
}
iItemNum = pGroupParam - > m_u8NGD & 0x3F ;
for ( i = 0 ; i < iItemNum ; i + + )
{
if ( ( iOffset + 6 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <EFBFBD> ݳ<EFBFBD> <DDB3> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݳ<EFBFBD> *<2A> <> <EFBFBD> <EFBFBD> )
u8DataNum = rtumsg - > MsgData [ iOffset + 5 ] ;
u8DataLen = rtumsg - > MsgData [ iOffset + 4 ] ;
if ( ( iOffset + 6 + u8DataLen * u8DataNum ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <20> <>
// <20> <> Ŀ<EFBFBD> <C4BF>
u8ItemNo = rtumsg - > MsgData [ iOffset + 1 ] ;
iOffset + = 2 ;
if ( TRUE = = bFirst )
{
if ( u8ItemNo = = 0 )
{
pGroupParam - > m_u32CurPntNo = 1 ;
}
else if ( u8ItemNo < = pGroupParam - > m_iStartItemNo )
{
pGroupParam - > m_u32CurPntNo = 1 ;
}
if ( ( M_INF_WRITEITEMWITHACK = = u8INF )
& & ( pGroupParam - > m_bInit = = FALSE ) )
{
for ( j = 0 ; j < pGroupParam - > m_iPntNum ; j + + )
{
if ( pGroupParam - > m_pu8GIN [ j ] = = u8ItemNo )
{
break ;
}
}
if ( j > = pGroupParam - > m_iPntNum )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)дȷ<D0B4> ϴ<EFBFBD> <CFB4> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> GIN=%d!!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , u8ItemNo , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
pGroupParam - > m_u32CurPntNo = j + 1 ;
}
bFirst = FALSE ;
}
if ( u8KOD ! = rtumsg - > MsgData [ iOffset ] )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)дȷ<D0B4> ϴ<EFBFBD> <CFB4> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> KOD=%d<> <64> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> KOD=%d<> <64> <EFBFBD> <EFBFBD> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo , rtumsg - > MsgData [ iOffset ] , u8KOD ) ;
DebugPrint ( szbuf ) ;
# endif
iOffset + = u8DataLen * u8DataNum + 4 ;
continue ;
}
else
{
iOffset + + ;
}
u8DataType = rtumsg - > MsgData [ iOffset + + ] ;
iOffset + = 2 ;
for ( j = 0 ; j < ( int ) u8DataNum ; j + + )
{
if ( ( int ) pGroupParam - > m_u32CurPntNo > pGroupParam - > m_iPntNum )
{
break ;
}
if ( pGroupParam - > m_bInit = = FALSE )
{
pGroupParam - > m_pu8DataLen [ pGroupParam - > m_u32CurPntNo - 1 ] = u8DataLen ;
pGroupParam - > m_pu8DataType [ pGroupParam - > m_u32CurPntNo - 1 ] = u8DataType ;
pGroupParam - > m_pu8GIN [ pGroupParam - > m_u32CurPntNo - 1 ] = u8ItemNo + j ;
}
if ( GetOneValueOfASDU10 ( & rtumsg - > MsgData [ iOffset ] , & sValue , u8DataType , u8DataLen ) = = FALSE )
{
iOffset + = u8DataLen ;
continue ;
}
iOffset + = u8DataLen ;
switch ( sValue . m_iDataType )
{
case DT_UINT : // <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
fValue = sValue . m_unValue . m_uValue ;
break ;
case DT_INT :
fValue = sValue . m_unValue . m_iValue ;
break ;
case DT_FLOAT :
fValue = sValue . m_unValue . m_fValue ;
break ;
case DT_CONTROL :
fValue = sValue . m_unValue . m_dwValue ;
break ;
case DT_STRING :
fValue = - 1 ;
break ;
case DT_BINARY :
fValue = sValue . m_unValue . m_dwValue ;
break ;
case DT_NO : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
default :
fValue = - 1 ;
break ;
}
if ( pGroupParam - > m_bInit = = FALSE )
{
if ( ( u8ItemNo = = 0 ) & & ( j = = 0 ) )
{
if ( ( fValue > 0 ) & & ( KOD_ACTUALVALUE = = u8KOD ) )
{
if ( ( int ) fValue > pGroupParam - > m_iPntNum )
{
//pGroupParam->m_iPntNum = (int)sValue.m_unValue.m_uValue;
bNumChanged = TRUE ;
}
else
{
pGroupParam - > m_iPntNum = ( int ) fValue ;
}
}
}
}
if ( TRUE = = bNumChanged )
{
//freeallfixmemory
}
if ( DT_STRING ! = sValue . m_iDataType )
{
pGroupParam - > m_psDataInfo [ pGroupParam - > m_u32CurPntNo - 1 ] . m_fValue = ( float ) fValue ;
}
else
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( KOD_DESCRIPTION = = u8KOD )
{
iStrLen = sizeof ( pGroupParam - > m_psDataInfo - > m_szName ) - 1 ;
if ( iStrLen > sValue . m_iDataNum )
{
iStrLen = sValue . m_iDataNum ;
}
memcpy ( pGroupParam - > m_psDataInfo - > m_szName , sValue . m_szValue , iStrLen ) ;
pGroupParam - > m_psDataInfo - > m_szName [ iStrLen ] = 0 ;
}
else if ( KOD_DIMENSION = = u8KOD )
{
iStrLen = sizeof ( pGroupParam - > m_psDataInfo - > m_szUnit ) - 1 ;
if ( iStrLen > sValue . m_iDataNum )
{
iStrLen = sValue . m_iDataNum ;
}
memcpy ( pGroupParam - > m_psDataInfo - > m_szUnit , sValue . m_szValue , iStrLen ) ;
pGroupParam - > m_psDataInfo - > m_szUnit [ iStrLen ] = 0 ;
}
}
if ( pGroupParam - > m_bInit = = FALSE )
{
pGroupParam - > m_psDataInfo [ pGroupParam - > m_u32CurPntNo - 1 ] . m_u32DataID = u8DataType ;
}
pGroupParam - > m_u32CurPntNo + + ;
}
}
if ( pGroupParam - > m_iPntNum > 0 )
{
if ( ( int ) pGroupParam - > m_u32CurPntNo > = pGroupParam - > m_iPntNum )
{
pGroupParam - > m_bInit = TRUE ;
pGroupParam - > m_u32CurPntNo = 1 ;
}
}
// wen 2004.01.06 д<> <D0B4> ֵȷ<D6B5> <C8B7>
if ( ( M_CAUSE_WRITEACK = = rtumsg - > MsgData [ 8 ] )
| | ( M_CAUSE_WRITECONFIRM = = rtumsg - > MsgData [ 8 ] ) )
{
//ptrProHead->uFuncCode = hWRITEFIXACK;
//RtuProtocolBaoHuCommand(&msg);
}
else if ( M_CAUSE_WRITENAK = = rtumsg - > MsgData [ 8 ] )
{
//ptrProHead->uFuncCode = hWRITEFIXNAK;
//RtuProtocolBaoHuCommand(&msg);
}
}
void Buban103GDprocessWithPEVENT ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam , i_32 iGroupIdx )
{
int i , j , k , commid , iItemNum ;
BYTE u8KOD , u8INF , u8DataType ;
BYTE u8DataNum , u8DataLen , u8ItemNo ;
int iOffset ;
BOOL bFirst , bNumChanged ;
time_t iTime ;
WORD wMillSeconds , wTime , wFault ;
struct tm * ptrtm ;
SOE_DEF sSoeData ;
DBORIENTATION * pDataUnit ;
GROUPDEF * pGroupParam ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
bNumChanged = FALSE ;
bFirst = TRUE ;
iOffset = 14 ;
pGroupParam = & pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] ;
pDataUnit = & pDevParam - > m_sDevParam . m_sDiDBOrientation ;
if ( ( iOffset + 3 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
u8INF = rtumsg - > MsgData [ 11 ] ;
u8KOD = rtumsg - > MsgData [ 16 ] ;
pGroupParam - > m_u8NGD = rtumsg - > MsgData [ 13 ] ;
// ֻ<> <D6BB> <EFBFBD> <EFBFBD> ʵ<EFBFBD> <CAB5> ֵ
if ( KOD_ACTUALVALUE ! = u8KOD )
{
return ;
}
iItemNum = pGroupParam - > m_u8NGD & 0x3F ;
for ( i = 0 ; i < iItemNum ; i + + )
{
if ( ( iOffset + 6 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <EFBFBD> ݳ<EFBFBD> <DDB3> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݳ<EFBFBD> *<2A> <> <EFBFBD> <EFBFBD> )
u8DataNum = rtumsg - > MsgData [ iOffset + 5 ] ;
u8DataLen = rtumsg - > MsgData [ iOffset + 4 ] ;
if ( ( iOffset + 6 + u8DataLen * u8DataNum ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <20> <>
// <20> <> Ŀ<EFBFBD> <C4BF>
u8ItemNo = rtumsg - > MsgData [ iOffset + 1 ] ;
iOffset + = 2 ;
if ( u8KOD ! = rtumsg - > MsgData [ iOffset ] )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)дȷ<D0B4> ϴ<EFBFBD> <CFB4> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> KOD=%d<> <64> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> KOD=%d<> <64> <EFBFBD> <EFBFBD> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo , rtumsg - > MsgData [ iOffset ] , u8KOD ) ;
DebugPrint ( szbuf ) ;
# endif
iOffset + = u8DataLen * u8DataNum + 4 ;
continue ;
}
else
{
iOffset + + ;
}
u8DataType = rtumsg - > MsgData [ iOffset + + ] ;
iOffset + = 2 ;
for ( j = 0 ; j < ( int ) u8DataNum ; j + + )
{
if ( ( int ) pGroupParam - > m_u32CurPntNo > pGroupParam - > m_iPntNum )
{
break ;
}
for ( k = 0 ; k < pDataUnit - > m_iPntNum ; k + + )
{
if ( ( pDataUnit - > m_psDataInfo [ k ] . m_u8Asdu = = 10 ) \
& & ( pDataUnit - > m_psDataInfo [ k ] . m_u8Inf = = ( u8ItemNo + j ) ) \
& & ( pDataUnit - > m_psDataInfo [ k ] . m_u8Fun = = pGroupParam - > m_iGroupNo ) )
{
break ;
}
}
if ( k > = pDataUnit - > m_iPntNum )
{
iOffset + = u8DataLen ;
continue ;
}
switch ( u8DataType )
{
case DATAID_WITHTIME : // <20> <> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD>
switch ( rtumsg - > MsgData [ iOffset ] & 0x03 )
{
case 1 :
sSoeData . bStatus = 0 ;
break ;
case 2 :
sSoeData . bStatus = 1 ;
break ;
case 3 :
case 0 :
default :
sSoeData . bStatus = 0 ;
break ;
}
time ( & iTime ) ;
ptrtm = localtime ( & iTime ) ;
if ( ptrtm - > tm_hour < ( rtumsg - > MsgData [ iOffset + 4 ] & 0x1f ) )
{
iTime - = 24 * 3600 ;
ptrtm = localtime ( & iTime ) ;
}
ptrtm - > tm_hour = rtumsg - > MsgData [ iOffset + 4 ] & 0x1f ;
ptrtm - > tm_min = rtumsg - > MsgData [ iOffset + 3 ] & 0x3f ;
wMillSeconds = rtumsg - > MsgData [ iOffset + 1 ] + rtumsg - > MsgData [ iOffset + 2 ] * 256 ;
ptrtm - > tm_sec = wMillSeconds / 1000 ;
sSoeData . iPntNo = pDataUnit - > m_iStartPntNo + k ;
sSoeData . u8Type = 1 ; // ASDU1
sSoeData . wFaultNo = 0 ;
sSoeData . u8ProvFun = pDataUnit - > m_psDataInfo [ k ] . m_u8ProvFun ;
sSoeData . u8ProvInf = pDataUnit - > m_psDataInfo [ k ] . m_u8ProvInf ;
sSoeData . wRelativeTime = 0 ;
sSoeData . SoeTime . Year = ptrtm - > tm_year + 1900 ;
sSoeData . SoeTime . Month = ( BYTE ) ( ptrtm - > tm_mon + 1 ) ;
sSoeData . SoeTime . Day = ( BYTE ) ( ptrtm - > tm_mday ) ;
sSoeData . SoeTime . Hour = ( BYTE ) ( ptrtm - > tm_hour ) ;
sSoeData . SoeTime . Min = ( BYTE ) ( ptrtm - > tm_min ) ;
sSoeData . SoeTime . Sec = ( BYTE ) ( ptrtm - > tm_sec ) ;
sSoeData . SoeTime . mSec = wMillSeconds ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , pDataUnit - > m_iStartPntNo + k , ( void * ) & sSoeData , DI_PNT_TYPE , PNT_SOE_TIME_EX ) ;
break ;
case DATAID_WITHTIMESPACE : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD>
switch ( rtumsg - > MsgData [ iOffset ] & 0x03 )
{
case 1 :
sSoeData . bStatus = 0 ;
break ;
case 2 :
sSoeData . bStatus = 1 ;
break ;
case 3 :
case 0 :
default :
sSoeData . bStatus = 0 ;
break ;
}
wTime = rtumsg - > MsgData [ iOffset + 1 ] + rtumsg - > MsgData [ iOffset + 2 ] * 256 ;
wFault = rtumsg - > MsgData [ iOffset + 3 ] + rtumsg - > MsgData [ iOffset + 4 ] * 256 ;
time ( & iTime ) ;
ptrtm = localtime ( & iTime ) ;
if ( ptrtm - > tm_hour < ( rtumsg - > MsgData [ iOffset + 8 ] & 0x1f ) )
{
iTime - = 24 * 3600 ;
ptrtm = localtime ( & iTime ) ;
}
ptrtm - > tm_hour = rtumsg - > MsgData [ iOffset + 8 ] & 0x1f ;
ptrtm - > tm_min = rtumsg - > MsgData [ iOffset + 7 ] & 0x3f ;
wMillSeconds = rtumsg - > MsgData [ iOffset + 5 ] + rtumsg - > MsgData [ iOffset + 6 ] * 256 ;
ptrtm - > tm_sec = wMillSeconds / 1000 ;
sSoeData . iPntNo = pDataUnit - > m_iStartPntNo + k ;
sSoeData . u8Type = 2 ; // ASDU2
sSoeData . wFaultNo = wFault ;
sSoeData . u8ProvFun = pDataUnit - > m_psDataInfo [ k ] . m_u8ProvFun ;
sSoeData . u8ProvInf = pDataUnit - > m_psDataInfo [ k ] . m_u8ProvInf ;
sSoeData . wRelativeTime = wTime ;
sSoeData . SoeTime . Year = ptrtm - > tm_year + 1900 ;
sSoeData . SoeTime . Month = ( BYTE ) ( ptrtm - > tm_mon + 1 ) ;
sSoeData . SoeTime . Day = ( BYTE ) ( ptrtm - > tm_mday ) ;
sSoeData . SoeTime . Hour = ( BYTE ) ( ptrtm - > tm_hour ) ;
sSoeData . SoeTime . Min = ( BYTE ) ( ptrtm - > tm_min ) ;
sSoeData . SoeTime . Sec = ( BYTE ) ( ptrtm - > tm_sec ) ;
sSoeData . SoeTime . mSec = wMillSeconds ;
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , pDataUnit - > m_iStartPntNo + k , ( void * ) & sSoeData , DI_PNT_TYPE , PNT_SOE_TIME_EX ) ;
break ;
default :
break ;
}
iOffset + = u8DataLen ;
}
}
}
void Buban103GIprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP):11
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ):0x81
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
//M_CAUSE_READWITHVALIDDATA : <20> <> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ч<EFBFBD> <D0A7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӧ
//M_CAUSE_READWITHINVALIDDATA : <09> <> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ч<EFBFBD> <D0A7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӧ
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN): 254(0xfe)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF):
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> Ŀ¼ : 243
//rtumsg->MsgData[11];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> ʶ<EFBFBD> <CAB6> (RII)
//rtumsg->MsgData[12];
// ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD> (GIN):<3A> <> Ŀ<EFBFBD> ź<EFBFBD> <C5BA> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[13];
// <20> <> <EFBFBD> <EFBFBD> Ԫ<EFBFBD> ص<EFBFBD> <D8B5> <EFBFBD> Ŀ(NDE)
//rtumsg->MsgData[15];
// <20> <> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <CEAA> <EFBFBD> <EFBFBD> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (KOD)
// <20> <> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : KOD_NOSPECIFIED(0)
// ʵ<> <CAB5> ֵ : KOD_ACTUALVALUE(1)
// ȱʡֵ : KOD_DEFAULTVALUE(2)
// <20> <> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> С ֵ<D0A1> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ) : KOD_RANGE(3)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP1(4)
// <20> <> <EFBFBD> <EFBFBD> (n,m) : KOD_PRECISION(5)
// <20> <> <EFBFBD> <EFBFBD> : KOD_FACTOR(6)
// <20> α <EFBFBD> : KOD_REFERENCE(7)
// <20> б <EFBFBD> : KOD_ENUMERATION(8)
// <20> <> <EFBFBD> <EFBFBD> : KOD_DIMENSION(9)
// <20> <> <EFBFBD> <EFBFBD> : KOD_DESCRIPTION(10)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP2(11)
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ : KOD_PASSWORD(12)
// ֻ<> <D6BB> : KOD_READONLY(13)
// ֻд : KOD_WRITEONLY(14)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP3(15)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP4(16)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP5(17)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP6(18)
// <20> <> Ӧ<EFBFBD> Ĺ<EFBFBD> <C4B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͺ <EFBFBD> <CDBA> <EFBFBD> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> : KOD_CORFUNCANDINF(19)
// <20> <> Ӧ<EFBFBD> <D3A6> <EFBFBD> ¼<EFBFBD> : KOD_COREVENT(20)
// <20> б <EFBFBD> <D0B1> <EFBFBD> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD> : KOD_ENUMTEXTARRAY(21)
// <20> б <EFBFBD> <D0B1> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> : KOD_ENUMVALUEARRAY(22)
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ : KOD_RELATEDENTRIES(23)
//rtumsg->MsgData[16];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[17];
//DATAID_NO : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_OS8ASCII : 8λASCII
//DATAID_BSTRING : <20> ַ<EFBFBD> <D6B7> <EFBFBD>
//DATAID_UIX : <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_INT : <20> <> <EFBFBD> <EFBFBD>
//DATAID_UFLOAT : <20> <EFBFBD> <DEB7> Ÿ<EFBFBD> <C5B8> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_FLOAT : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_754SHORT : R32.23 IEEE <20> <> 754<35> <34> ʵ<EFBFBD> <CAB5>
//DATAID_754REAL : R64.53 IEEE <20> <> 754ʵ<34> <CAB5>
//DATAID_DOUBLE : ˫<> <CBAB> <EFBFBD> <EFBFBD> Ϣ
//DATAID_SINGLE : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//DATAID_13BITS : <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ(13BITS)
//DATAID_SORTIDNO : ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD>
//DATAID_WITHTIME : <20> <> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD>
//DATAID_WITHTIMESPACE : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD>
//DATAID_STRUCT : <20> <> <EFBFBD> ݽṹ
// <20> <> <EFBFBD> ݳߴ <DDB3>
//rtumsg->MsgData[18]
// <20> <> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[19]
// ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD> (GID)
// <20> <> <EFBFBD> ȸ<EFBFBD> <C8B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// 2 ... n <20> <> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
}
void Buban103SynTime ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
//char szDbg[128];
int commid ;
DAY_TIME stime ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
//DebugPrint("sync time.");
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
//DebugPrint("sync time hello1.");
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> ͬ<EFBFBD> <CDAC> ԭ<EFBFBD> <D4AD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <F2B2BBBD> ж<EFBFBD> ʱ
if ( M_CAUSE_CHECKTIME ! = rtumsg - > MsgData [ 8 ] )
{
return ;
}
//DebugPrint("sync time hello2.");
// <20> ϶<EFBFBD> ʱ
if ( 1 ! = pPortParam - > m_psBaoHu - > CheckTime )
{
return ;
}
stime . mSec = rtumsg - > MsgData [ 12 ] + rtumsg - > MsgData [ 13 ] * 256 ;
stime . Sec = stime . mSec / 1000 ;
stime . mSec = 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 ;
//sprintf(szDbg, "time:%04d-%02d-%02d_%02d:%02d:%02d.%03d\n",
// stime.Year, stime.Month, stime.Day, stime.Hour,
// stime.Min, stime.Sec, stime.mSec);
//DebugPrint(szDbg);
SetLocalTimeEx ( & stime ) ;
}
void Buban103EXPIprocess ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
int i , commid ;
int pipnt ;
PI_DEF pntmsg ;
DBORIENTATION * pDataUnit ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
pDataUnit = & pDevParam - > m_sDevParam . m_sPiDBOrientation ;
if ( pDataUnit - > m_iStnNo < 1 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d SIEMENS<4E> <53> չ<EFBFBD> <D5B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> д<EFBFBD> <D0B4> <EFBFBD> <EFBFBD> <EFBFBD> ݿ<EFBFBD> !!!" ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
for ( i = 0 ; i < pDataUnit - > m_iPntNum ; i + + )
{
if ( ( pDataUnit - > m_psDataInfo [ i ] . m_u8Fun = = rtumsg - > MsgData [ 10 ] ) \
& & ( pDataUnit - > m_psDataInfo [ i ] . m_u8Inf = = rtumsg - > MsgData [ 11 ] ) )
{
break ;
}
}
if ( i > = pDataUnit - > m_iPntNum )
{
return ;
}
pipnt = pDataUnit - > m_iStartPntNo + i ;
pntmsg . RawValue = rtumsg - > MsgData [ 12 ] + rtumsg - > MsgData [ 13 ] * 256 \
+ rtumsg - > MsgData [ 14 ] * 256 * 256 + ( rtumsg - > MsgData [ 15 ] & 0x0f ) * 256 * 256 * 256 ;
// <20> <> <EFBFBD> <EFBFBD> λ
if ( rtumsg - > MsgData [ 15 ] & 0x10 )
{
pntmsg . RawValue | = 0xF0000000 ;
}
SetPntMsg ( pDataUnit - > m_iStnNo - 1 , pipnt , ( void * ) & pntmsg , PI_PNT_TYPE , PNT_RAWVALUE ) ;
}
// <20> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> ʼ
// <20> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݱ<EFBFBD> <DDB1> <EFBFBD> <EFBFBD> <EFBFBD>
void Buban103LRDprocess ( RTUMSG * rtumsg )
{ }
// <20> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <D7BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
void Buban103RTDprocess ( RTUMSG * rtumsg )
{ }
// <20> <> <EFBFBD> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <D7BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
void Buban103RTTprocess ( RTUMSG * rtumsg )
{ }
// <20> <> <EFBFBD> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD>
void Buban103TOTprocess ( RTUMSG * rtumsg )
{ }
// <20> <> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <D7BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
void Buban103RTCprocess ( RTUMSG * rtumsg )
{ }
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> ֵ
void Buban103TOVprocess ( RTUMSG * rtumsg )
{ }
// <20> <> <EFBFBD> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
void Buban103EOTprocess ( RTUMSG * rtumsg )
{ }
// <20> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// дͨ<D0B4> <CDA8> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݵ<EFBFBD> <DDB5> ļ<EFBFBD> <C4BC> <EFBFBD>
BOOL Buban103WriteACCDatatoFile ( RTUMSG * rtumsg )
{
return FALSE ;
}
// <20> <> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD> ͷ
void Buban103GetFileHead ( char * ptrDataHead , size_t * piNOF , size_t * piNOC , size_t * piNOE , size_t * piINT )
{ }
// <20> <> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> ݼ<EFBFBD> ¼ʱ<C2BC> <CAB1>
//void Buban103GetTime(char *ptrDataHead, SYSTEMTIME *ptrtm)
//{}
// <20> <> ¼<EFBFBD> <C2BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ģ<EFBFBD> <C4A3> <EFBFBD> <EFBFBD> ͷ
void Buban103ProcessAiHead ( char * ptrDataHead , DISTURBANCEAIDATA * pAiData )
{ }
// ת<> <D7AA> <EFBFBD> <EFBFBD> ʱ<EFBFBD> ļ<EFBFBD> Ϊ<EFBFBD> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> ļ<EFBFBD>
void Buban103tmpFileChangetodatFile ( char * sztmpFileName )
{ }
// <20> <> <EFBFBD> <EFBFBD> CFG<46> ļ<EFBFBD>
//void Buban103MakeCFGFile(int iStationNo, pDISTURBANCEDIDATA ptrDi, pDISTURBANCEAIDATA ptrAi, FILE *fp, char *szInfFile, SYSTEMTIME *tm)
//{}
// <20> <> <EFBFBD> <EFBFBD> DAT<41> ļ<EFBFBD>
void Buban103MakeDATFile ( pDISTURBANCEDIDATA ptrDi , pDISTURBANCEAIDATA ptrAi , FILE * fp )
{ }
//=========================<3D> <> <EFBFBD> <EFBFBD> ΪBuban103ת<33> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> ݹ<EFBFBD> <DDB9> <EFBFBD> =======================//
//***************************************************************************/
//* <20> <> <EFBFBD> <EFBFBD> SOE<4F> <45> <EFBFBD> ݺ<EFBFBD> <DDBA> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* u_32 selidx : <20> ˿<EFBFBD> <CBBF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//* PROV_SOE *pSoeMsg : ת<> <D7AA> SOE<4F> <45> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:BOOL retval : <20> <> <EFBFBD> <EFBFBD> SOE<4F> <45> <EFBFBD> <EFBFBD> ʱ<EFBFBD> Ƿ<C7B7> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> <EFBFBD> ) */
//***************************************************************************/
BOOL ProvInsertSoe ( u_32 commid , DEVADDRPARAM * psDevAddrParam , SOE_DEF * pSoeMsg )
{
BOOL bReturn ;
short front , rear ;
PROVDEVDEF * pProvDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
if ( FALSE = = GetSpecialProvPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pProvDevParam ) )
{
return FALSE ;
}
front = pProvDevParam - > m_sProvSoe . m_shFront ;
rear = pProvDevParam - > m_sProvSoe . m_shRear ;
if ( pProvDevParam - > m_sProvSoe . m_shSoeNum > = PROV_SOE_MAX )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
memcpy ( ( void * ) & pProvDevParam - > m_sProvSoe . m_sSoeData [ rear ] ,
( void * ) pSoeMsg , sizeof ( SOE_DEF ) ) ;
pProvDevParam - > m_sProvSoe . m_shFront = ( front + 1 ) % PROV_SOE_MAX ;
pProvDevParam - > m_sProvSoe . m_shRear = ( rear + 1 ) % PROV_SOE_MAX ;
bReturn = FALSE ;
}
else
{
memcpy ( ( void * ) & pProvDevParam - > m_sProvSoe . m_sSoeData [ rear ] ,
( void * ) pSoeMsg , sizeof ( SOE_DEF ) ) ;
pProvDevParam - > m_sProvSoe . m_shRear = ( rear + 1 ) % PROV_SOE_MAX ;
pProvDevParam - > m_sProvSoe . m_shSoeNum + + ;
bReturn = TRUE ;
}
return bReturn ;
}
//***************************************************************************/
//* <20> ӻ<EFBFBD> <D3BB> <EFBFBD> <EFBFBD> <EFBFBD> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> ɾ<EFBFBD> <C9BE> SOE<4F> <45> <EFBFBD> ݺ<EFBFBD> <DDBA> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* u_32 selidx : <20> ˿<EFBFBD> <CBBF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//* PROV_SOE *pSoeMsg : SOE<4F> <45> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:BOOL retval : <20> <> ȡSOE<4F> <45> <EFBFBD> <EFBFBD> <EFBFBD> Ƿ<EFBFBD> <C7B7> ɹ<EFBFBD> */
//***************************************************************************/
BOOL ProvGetAndDelSoe ( u_32 commid , DEVADDRPARAM * psDevAddrParam , SOE_DEF * pSoeMsg )
{
short front , rear ;
PROVDEVDEF * pProvDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
if ( FALSE = = GetSpecialProvPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pProvDevParam ) )
{
return FALSE ;
}
front = pProvDevParam - > m_sProvSoe . m_shFront ;
rear = pProvDevParam - > m_sProvSoe . m_shRear ;
if ( pProvDevParam - > m_sProvSoe . m_shSoeNum < = 0 )
{
pProvDevParam - > m_sProvSoe . m_shSoeNum = 0 ;
pProvDevParam - > m_sProvSoe . m_shFront = 0 ;
pProvDevParam - > m_sProvSoe . m_shRear = 0 ;
return FALSE ;
}
memcpy ( ( void * ) pSoeMsg , ( void * ) & pProvDevParam - > m_sProvSoe . m_sSoeData [ front ] , sizeof ( SOE_DEF ) ) ;
pProvDevParam - > m_sProvSoe . m_shFront = ( front + 1 ) % PROV_SOE_MAX ;
pProvDevParam - > m_sProvSoe . m_shSoeNum - - ;
return TRUE ;
}
BOOL ProvGetNoXSoe ( u_32 commid , DEVADDRPARAM * psDevAddrParam , int iNo , SOE_DEF * pSoeMsg )
{
short rear ;
PROVDEVDEF * pProvDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
if ( FALSE = = GetSpecialProvPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pProvDevParam ) )
{
return FALSE ;
}
if ( pProvDevParam - > m_sProvSoe . m_shSoeNum < = 0 )
{
pProvDevParam - > m_sProvSoe . m_shSoeNum = 0 ;
pProvDevParam - > m_sProvSoe . m_shFront = 0 ;
pProvDevParam - > m_sProvSoe . m_shRear = 0 ;
return FALSE ;
}
iNo = iNo % PROV_SOE_MAX ;
rear = pProvDevParam - > m_sProvSoe . m_shRear - iNo - 1 ;
if ( rear < 0 )
{
rear + = PROV_SOE_MAX ;
}
memcpy ( ( void * ) pSoeMsg , ( void * ) & pProvDevParam - > m_sProvSoe . m_sSoeData [ rear ] , sizeof ( SOE_DEF ) ) ;
return TRUE ;
}
//***************************************************************************/
//* ת<> <D7AA> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> ں<EFBFBD> <DABA> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
BOOL ProvHaveClassOne ( u_32 commid , DEVADDRPARAM * psDevAddrParam , BOOL bCheckDiChange )
{
int i ;
BOOL bACD , bQueryAllDev ;
PROVDEVDEF * pProvDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
pLinkParam = & pPortParam - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ;
bACD = FALSE ;
if ( ProvHaveSoeData ( commid ) > 0 )
{
bACD = TRUE ;
}
else
{
if ( pLinkParam - > m_uchLinkAddr ! = 0xFF )
{
bQueryAllDev = TRUE ;
}
else
{
bQueryAllDev = FALSE ;
}
// <20> Ƿ<EFBFBD> ת<EFBFBD> <D7AA> ң<EFBFBD> ű<EFBFBD> λ,һ <> 㽫<EFBFBD> <E3BDAB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( TRUE = = bCheckDiChange )
{
if ( pPortParam - > m_psBaoHu ! = NULL )
{
if ( pPortParam - > m_psBaoHu - > DiChange = = TRUE )
{
bACD = TRUE ;
}
}
}
if ( bACD = = FALSE )
{
for ( i = 0 ; i < pLinkParam - > m_iDevNum ; i + + )
{
if ( bQueryAllDev = = TRUE )
{
psDevAddrParam - > m_iDevIdx = i ;
}
else
{
if ( i > = 1 )
{
break ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ж<EFBFBD> Ӧ<EFBFBD> ò<EFBFBD> <C3B2> <EFBFBD> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD>
//if(psDevAddrParam->m_iDevIdx >= pLinkParam->m_iDevNum)
//{
// break;
//}
}
pProvDevParam = & pLinkParam - > m_psProvDev [ psDevAddrParam - > m_iDevIdx ] ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//if((pProvDevParam->m_bProvQuery == TRUE) || (pProvDevParam->m_sProvGroupParam.m_bFinished == FALSE))
if ( pProvDevParam - > m_bProvQuery = = TRUE )
{
bACD = TRUE ;
break ;
}
if ( SingleListHaveData ( & pProvDevParam - > m_sBaoHuData ) > 0 )
{
bACD = TRUE ;
break ;
}
}
}
}
return bACD ;
}
//***************************************************************************/
//* ת<> <D7AA> <EFBFBD> <EFBFBD> ·ָ<C2B7> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɺ<EFBFBD> <C9BA> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* u_char addr : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ */
//* u_char cmdidx : ָ<> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
//* BOOL bACD : һ <> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> ڱ<EFBFBD> ʶ */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvMakeLinkCommand ( u_32 commid , u_char addr , u_char cmdidx , BOOL bACD )
{
CLPDU_FIX bClpdu_fix ;
memset ( & bClpdu_fix , 0 , sizeof ( CLPDU_FIX ) ) ;
switch ( cmdidx )
{
case M_CON_NA_3 : // ȷ<> <C8B7> ֡
bClpdu_fix . nSTART = 0x10 ;
if ( bACD )
bClpdu_fix . nCONTROL = cmdidx | 0x20 ;
else
bClpdu_fix . nCONTROL = cmdidx ;
bClpdu_fix . nADDR = addr ;
bClpdu_fix . nCS = CalBuban103Lpc ( & bClpdu_fix . nCONTROL , 2 ) ;
bClpdu_fix . nEnd = 0x16 ;
PutPollCmdToBuf ( commid , FAST_POLL_CMD , 0 , ( char * ) & bClpdu_fix , 5 ) ;
break ;
case M_BY_NA_3 : // æ֡<C3A6> <D6A1> ȷ<EFBFBD> <C8B7> ֡<EFBFBD> <D6A1>
case M_NV_NA_3 : // <20> <> <EFBFBD> <EFBFBD> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> ش<EFBFBD>
case M_LKR_NA_3_1 : // <20> <> ·״̬<D7B4> <CCAC> Ӧ֡--<2D> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
case M_LKR_NA_3_2 : // <20> <> ·״̬<D7B4> <CCAC> Ӧ֡--<2D> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> δ<EFBFBD> <CEB4> <EFBFBD> <EFBFBD>
case M_LKR_NA_3_3 : // <20> <> ·״̬<D7B4> <CCAC> Ӧ֡--<2D> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> δʵ<CEB4> <CAB5>
bClpdu_fix . nSTART = 0x10 ;
if ( bACD )
bClpdu_fix . nCONTROL = cmdidx | 0x20 ;
else
bClpdu_fix . nCONTROL = cmdidx ;
bClpdu_fix . nADDR = addr ;
bClpdu_fix . nCS = CalBuban103Lpc ( & bClpdu_fix . nCONTROL , 2 ) ;
bClpdu_fix . nEnd = 0x16 ;
PutPollCmdToBuf ( commid , FAST_POLL_CMD , 0 , ( char * ) & bClpdu_fix , 5 ) ;
break ;
default :
break ;
}
}
//***************************************************************************/
//* ת<> <D7AA> <EFBFBD> <EFBFBD> ·ָ<C2B7> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɺ<EFBFBD> <C9BA> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* u_char addr : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ */
//* u_char cmdidx : ָ<> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
//* BOOL bACD : һ <> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> ڱ<EFBFBD> ʶ */
//* BOOL bClearRecvBuf : <20> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ջ<EFBFBD> <D5BB> <EFBFBD> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvMakeLinkCommandEx ( u_32 commid , u_char addr , u_char cmdidx , BOOL bACD , BOOL bClearRecvBuf , u_32 cmdtype )
{
CLPDU_FIX bClpdu_fix ;
memset ( & bClpdu_fix , 0 , sizeof ( CLPDU_FIX ) ) ;
switch ( cmdidx )
{
case M_CON_NA_3 : // ȷ<> <C8B7> ֡
case M_BY_NA_3 : // æ֡<C3A6> <D6A1> ȷ<EFBFBD> <C8B7> ֡<EFBFBD> <D6A1>
case M_NV_NA_3 : // <20> <> <EFBFBD> <EFBFBD> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> ش<EFBFBD>
case M_LKR_NA_3_1 : // <20> <> ·״̬<D7B4> <CCAC> Ӧ֡--<2D> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
case M_LKR_NA_3_2 : // <20> <> ·״̬<D7B4> <CCAC> Ӧ֡--<2D> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> δ<EFBFBD> <CEB4> <EFBFBD> <EFBFBD>
case M_LKR_NA_3_3 : // <20> <> ·״̬<D7B4> <CCAC> Ӧ֡--<2D> <> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> δʵ<CEB4> <CAB5>
bClpdu_fix . nSTART = 0x10 ;
if ( bACD )
bClpdu_fix . nCONTROL = cmdidx | 0x20 ;
else
bClpdu_fix . nCONTROL = cmdidx ;
bClpdu_fix . nADDR = addr ;
bClpdu_fix . nCS = CalBuban103Lpc ( & bClpdu_fix . nCONTROL , 2 ) ;
bClpdu_fix . nEnd = 0x16 ;
PutPollCmdToBuf ( commid , cmdtype , 0 , ( char * ) & bClpdu_fix , 5 ) ;
break ;
default :
break ;
}
}
//***************************************************************************/
//* ת<> <D7AA> <EFBFBD> <EFBFBD> ·ָ<C2B7> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɺ<EFBFBD> <C9BA> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* u_char addr : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ */
//* u_char cmdidx : ָ<> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
//* BOOL bACD : һ <> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> ڱ<EFBFBD> ʶ */
//* BYTE bCause : <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> */
//* u_32 cmdtype : ָ<> <EFBFBD> <EEBBBA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvMakeVarCommand ( u_32 commid , u_char linkaddr , u_char addr , \
u_char cmdidx , BOOL bACD , BYTE bCause , u_32 cmdtype )
{
u_char tmp [ MAX_POLL_CMD_BUF_LEN ] ;
CLPDU_VARR * ptrClpdu_varr ;
i_32 len ;
memset ( tmp , 0 , sizeof ( tmp ) ) ;
ptrClpdu_varr = ( CLPDU_VARR * ) tmp ;
ptrClpdu_varr - > nSTART1 = 0x68 ;
ptrClpdu_varr - > nSTART2 = 0x68 ;
ptrClpdu_varr - > nADDR = linkaddr ;
if ( bACD )
ptrClpdu_varr - > nCONTROL = 0x28 ;
else
ptrClpdu_varr - > nCONTROL = 0x08 ;
len = 0 ;
switch ( cmdidx )
{
case M_TM_TA_3 : //<2F> <> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD>
break ;
case M_TMR_TA_3 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> Ĵ<EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD>
break ;
case M_MEI_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> ֵI
break ;
case M_TME_TA_3 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> Ĵ<EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ
break ;
case M_IRC_NA_3 : //<2F> <> ʶ
len = sizeof ( CLPDU_VARR ) ;
tmp [ len + + ] = cmdidx ;
tmp [ len + + ] = 0x81 ;
tmp [ len + + ] = bCause ;
tmp [ len + + ] = addr ;
tmp [ len + + ] = FUNC_GLOBAL ;
tmp [ len + + ] = bCause - 1 ;
tmp [ len + + ] = 2 ;
memcpy ( tmp + len , " SZ-SCADA " , 8 ) ;
len + = 8 ;
tmp [ len + + ] = 0x01 ;
len + = 3 ;
break ;
case M_SYN_TA_3 : //ʱ<> <CAB1> ͬ<EFBFBD> <CDAC>
break ;
case M_TGI_NA_3 : //<2F> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD> ֹ
len = sizeof ( CLPDU_VARR ) ;
tmp [ len + + ] = cmdidx ;
tmp [ len + + ] = 0x81 ;
tmp [ len + + ] = bCause ;
tmp [ len + + ] = addr ;
tmp [ len + + ] = FUNC_GLOBAL ;
tmp [ len + + ] = 0 ;
tmp [ len + + ] = 0 ;
break ;
case M_MEII_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> ֵII
break ;
case M_GD_NTA_3 : //ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
break ;
case M_GI_NTA_3 : //ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> ʶ
break ;
case M_LRD_TA_3 : //<2F> <> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD>
break ;
case M_RTD_TA_3 : //<2F> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <D7BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
break ;
case M_RTC_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> ͨ<EFBFBD> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <D7BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
break ;
case M_RTT_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <D7BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
break ;
case M_TOT_TA_3 : //<2F> <> <EFBFBD> ʹ <EFBFBD> <CDB4> <EFBFBD> ־<EFBFBD> <D6BE> ״̬<D7B4> <CCAC> λ
break ;
case M_TOV_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> Ŷ<EFBFBD> ֵ
break ;
case M_EOT_TA_3 : //<2F> <> <EFBFBD> ͽ<EFBFBD> <CDBD> <EFBFBD>
break ;
case M_MEIII_TA_3 : //<2F> <> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ<EFBFBD> <D6B5>
break ;
case M_MEIV_TA_3 : //<2F> <> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ<EFBFBD> <D6B5>
break ;
case M_MEV_TA_3 : //<2F> <> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ<EFBFBD> <D6B5>
break ;
case M_MEVI_TA_3 : //<2F> <> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ<EFBFBD> <D6B5>
break ;
case M_MEVII_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5>
break ;
case M_IT_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ
break ;
case M_IT_TA_3 : //<2F> <> ʱ<EFBFBD> <CAB1> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ
break ;
case M_ST_NA_3 : //<2F> <> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> Ϣ
break ;
case M_ST_TA_3 : //<2F> <> ʱ<EFBFBD> <CAB1> <EFBFBD> IJ<EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> Ϣ
break ;
case M_SP_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> ״̬<D7B4> <CCAC> Ϣ
break ;
case M_SP_TA_3 : //<2F> <> ʱ<EFBFBD> <CAB1> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> ״̬<D7B4> <CCAC> Ϣ
break ;
case M_DP_NA_3 : //˫<> <CBAB> ״̬<D7B4> <CCAC> Ϣ
break ;
case M_DP_TA_3 : //<2F> <> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> ˫<EFBFBD> <CBAB> ״̬<D7B4> <CCAC> Ϣ
break ;
case M_SS_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> ״̬<D7B4> <CCAC> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD>
break ;
case M_SS_TA_3 : //<2F> <> ʱ<EFBFBD> <CAB1> <EFBFBD> ĵ<EFBFBD> <C4B5> <EFBFBD> ״̬<D7B4> <CCAC> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD>
break ;
case M_DS_NA_3 : //˫<> <CBAB> ״̬<D7B4> <CCAC> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD>
break ;
case M_DS_TA_3 : //<2F> <> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> ˫<EFBFBD> <CBAB> ״̬<D7B4> <CCAC> ״̬<D7B4> <CCAC> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD>
break ;
case M_WL_TA_3 : //ˮλ
break ;
case M_DC_NA_3 : //<2F> <> <EFBFBD> ƶ<EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
break ;
case M_RC_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
break ;
case M_SE_NA_3 : //<2F> 趨<EFBFBD> <E8B6A8> <EFBFBD> <EFBFBD>
break ;
case M_CC_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
break ;
}
if ( len > 0 )
{
ptrClpdu_varr - > nLEN1 = len - 4 ;
ptrClpdu_varr - > nLEN2 = len - 4 ;
tmp [ len + + ] = CalBuban103Lpc ( tmp + 4 , ptrClpdu_varr - > nLEN1 ) ;
tmp [ len + + ] = 0x16 ;
PutPollCmdToBuf ( commid , cmdtype , 0 , ( char * ) tmp , len ) ;
}
}
//***************************************************************************/
//* ת<> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEB4A6> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 portidx : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvRtuProtocolDataProcess ( int commid , RTUMSG * rtumsg )
{
if ( rtumsg - > MsgLen = = 0 )
return ;
// <20> <> <EFBFBD> <EFBFBD> У <EFBFBD> <D0A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> ֽڵĵڶ<C4B5> <DAB6> <EFBFBD> <EFBFBD> ֽ<EFBFBD> )
if ( rtumsg - > MsgData [ rtumsg - > MsgLen + 1 ] > 0 )
return ;
// wen <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƣ<EFBFBD> <C6A3> <EFBFBD> ʹ <EFBFBD> <CAB9> ָ<EFBFBD> <EFBFBD> <EEBBBA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɶ<EFBFBD> <C9B6> <EFBFBD> ָ<EFBFBD> <D6B8>
//if(CheckPollCmdBuf(commid)) return;
switch ( rtumsg - > MsgData [ 0 ] )
{
case 0x10 : //shortframe process
Provshortprocess ( commid , rtumsg ) ;
break ;
case 0x68 :
Provlongprocess ( commid , rtumsg ) ;
break ;
default :
break ;
}
}
//***************************************************************************/
//* <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvSendCmdToPort ( u_32 commid , RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
u_32 destport ;
PROVDEVDEF * pProvDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
if ( FALSE = = GetSpecialProvPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pProvDevParam ) )
{
return ;
}
if ( ( C_GD_NA_3 ! = rtumsg - > MsgData [ 6 ] ) \
& & ( C_GRC_NA_3 ! = rtumsg - > MsgData [ 6 ] ) \
& & ( C_GC_NA_3 ! = rtumsg - > MsgData [ 6 ] ) )
{
return ;
}
// ??? <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ォ<EFBFBD> <EFBDAB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݷ<EFBFBD> <DDB7> ͵<EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> <EFBFBD> ·<EFBFBD> <C2B7> ˿<EFBFBD>
if ( pProvDevParam - > m_iRealCommid > 0 )
{
destport = pProvDevParam - > m_iRealCommid - 1 ;
}
else
{
return ;
}
rtumsg - > MsgData [ 12 ] = RII_PROV_ID ;
rtumsg - > MsgType = MSGTYPE_BAOHU_103CMD ;
SendProtectCmdToDev ( destport , rtumsg ) ;
}
//***************************************************************************/
//* <20> <> <EFBFBD> <EFBFBD> ת<EFBFBD> <D7AA> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void Provshortprocess ( u_32 commid , RTUMSG * rtumsg )
{
BOOL bFind ;
DEVADDRPARAM DevAddrParam ;
BUBAN103LINKDEF * pLinkParam = NULL ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
if ( ( rtumsg - > MsgData [ 1 ] & 0xc0 ) = = 0 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d(CtrlByte=%02x)<29> <> <EFBFBD> յ<EFBFBD> <D5B5> Ķ<EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> ݲ<EFBFBD> <DDB2> <EFBFBD> <EFBFBD> <EFBFBD> վ<EFBFBD> <D5BE> <EFBFBD> <EFBFBD> !!!\n " ,
commid , rtumsg - > MsgData [ 2 ] , rtumsg - > MsgData [ 1 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
if ( ! IsExtInfoPtr ( commid ) )
{
return ;
}
pPortParam = ( pBUBAN103PORTPARAM ) SioParam [ commid ] . ExtInfo ;
DevAddrParam . m_uchLinkAddr = rtumsg - > MsgData [ 2 ] ;
if ( FindProtectDev ( pPortParam , & DevAddrParam , TRUE ) = = FALSE )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d <20> <> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , rtumsg - > MsgData [ 2 ] ) ;
DebugPrint ( szbuf ) ;
# endif
bFind = FALSE ;
}
else
{
bFind = TRUE ;
}
//printf("commid=%d, iLinkIdx=%d, iDevIdx=%d\n", commid, DevAddrParam.m_iLinkIdx, DevAddrParam.m_iDevIdx);
if ( TRUE = = bFind )
{
pLinkParam = & pPortParam - > m_psLink [ DevAddrParam . m_iLinkIdx ] ;
}
/*
if ( ( rtumsg - > MsgData [ 1 ] & 0x0f ) = = C_RCU_NA_3 )
{
//InitBuban103LinkCmdBuf(pLinkParam);
//SetDevLinkOk(pLinkParam, DevAddrParam.m_iDevIdx, TRUE);
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 2 ] , M_CON_NA_3 , TRUE ) ;
//pLinkParam->m_psProvDev[DevAddrParam.m_iDevIdx].m_iProvAsdu5Cause = M_CAUSE_RESET_CU;
}
return ;
*/
switch ( rtumsg - > MsgData [ 1 ] & 0x0f )
{
case C_RCU_NA_3 : //<2F> <> λͨ<CEBB> ŵ<EFBFBD> Ԫ
if ( TRUE = = bFind )
{
InitBuban103LinkCmdBuf ( pLinkParam ) ;
SetDevLinkOk ( pLinkParam , DevAddrParam . m_iDevIdx , TRUE ) ;
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 2 ] , M_CON_NA_3 , TRUE ) ;
pLinkParam - > m_psProvDev [ DevAddrParam . m_iDevIdx ] . m_iProvAsdu5Cause = M_CAUSE_RESET_CU ;
}
else
{
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 2 ] , M_CON_NA_3 , FALSE ) ;
}
break ;
case C_RFB_NA_3 : //<2F> <> λ֡<CEBB> <D6A1> <EFBFBD> <EFBFBD> λ
if ( TRUE = = bFind )
{
pLinkParam - > m_pu8CtlByte [ DevAddrParam . m_iDevIdx ] = 0 ;
pLinkParam - > m_psProvDev [ DevAddrParam . m_iDevIdx ] . m_iProvAsdu5Cause = M_CAUSE_RESET_FCB ;
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 2 ] , M_CON_NA_3 , TRUE ) ;
}
else
{
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 2 ] , M_CON_NA_3 , FALSE ) ;
}
break ;
case C_RLK_NA_3 : //<2F> <> ·״̬<D7B4> <CCAC> <EFBFBD> <EFBFBD>
if ( TRUE = = bFind )
{
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 2 ] , M_LKR_NA_3_1 , FALSE ) ;
}
else
{
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 2 ] , M_LKR_NA_3_2 , FALSE ) ;
}
break ;
case C_PL1_NA_3 : //<2F> ٻ<EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( FALSE = = bFind )
{
break ;
}
if ( TRUE = = IsDevLinkOk ( pLinkParam , DevAddrParam . m_iDevIdx ) )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> е <EFBFBD> װ<EFBFBD> <D7B0>
//if(pLinkParam->m_uchLinkAddr != 0xFF)
//{
// DevAddrParam.m_iDevIdx = -1;
//}
ProvPL1process ( commid , & DevAddrParam ) ;
}
break ;
case C_PL2_NA_3 : //<2F> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( FALSE = = bFind )
{
break ;
}
if ( TRUE = = IsDevLinkOk ( pLinkParam , DevAddrParam . m_iDevIdx ) )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> е <EFBFBD> װ<EFBFBD> <D7B0>
//if(pLinkParam->m_uchLinkAddr != 0xFF)
//{
// DevAddrParam.m_iDevIdx = -1;
//}
ProvPL2process ( commid , & DevAddrParam ) ;
}
break ;
default :
break ;
}
}
//***************************************************************************/
//* ת<> <D7AA> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* u_char addr : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvPL1process ( u_32 commid , DEVADDRPARAM * psDevAddrParam )
{
BOOL bACD ;
WORD wValue ;
DAY_TIME sCurTime ;
SOE_DEF sSoeData ;
DI_DEF pntmsg ;
PROV_DI_PNT * diprovptr ;
DBINFO sDbInfo ;
i_32 i , len ;
char szDebugbuf [ 256 ] ;
RTUMSG rtumsg , msg ;
DBORIENTATION * pDBUnit ;
CLPDU_VARR * ptrClpdu_varr ;
DEVADDRPARAM sDevAddrParam ;
PROVDEVDEF * pProvDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
memset ( szDebugbuf , 0 , sizeof ( szDebugbuf ) ) ;
memset ( ( void * ) & rtumsg , 0 , sizeof ( rtumsg ) ) ;
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
pLinkParam = & pPortParam - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ;
pProvDevParam = & pLinkParam - > m_psProvDev [ psDevAddrParam - > m_iDevIdx ] ;
if ( pProvDevParam - > m_iProvAsdu5Cause > 0 )
{
ProvMakeVarCommand ( commid , pLinkParam - > m_uchLinkAddr , \
( BYTE ) pProvDevParam - > m_iProvAddr , M_IRC_NA_3 , FALSE , \
( BYTE ) pProvDevParam - > m_iProvAsdu5Cause , FAST_POLL_CMD ) ;
pProvDevParam - > m_iProvAsdu5Cause = 0 ;
return ;
}
// <20> <> <EFBFBD> ȷ<EFBFBD> <C8B7> <EFBFBD> ͻ<EFBFBD> <CDBB> <EFBFBD> ¼<EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> װ<EFBFBD> õ<EFBFBD> <C3B5> <EFBFBD> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֻ<EFBFBD> <D6BB> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·)
while ( ProvHaveSoeData ( commid ) > 0 )
{
ProvAndDelGetSoeData ( commid , & sSoeData ) ;
//if(ProvAndDelGetSoeData(commid, &sSoeData) > 0)
//{
// bACD = TRUE;
//}
//else
//{
// bACD = ProvHaveClassOne(commid, psDevAddrParam, FALSE);
//}
if ( FALSE = = FindProtectDevFromPntNo ( pPortParam , & sDevAddrParam , & sDbInfo , sSoeData . iPntNo , DI_PNT_TYPE ) )
{
continue ;
}
ptrClpdu_varr = ( CLPDU_VARR * ) rtumsg . MsgData ;
ptrClpdu_varr - > nSTART1 = 0x68 ;
ptrClpdu_varr - > nSTART2 = 0x68 ;
// <20> <> <EFBFBD> ¸ <EFBFBD> ֵ<EFBFBD> <D6B5> ·<EFBFBD> <C2B7> ת<EFBFBD> <D7AA> <EFBFBD> <EFBFBD> ַ
ptrClpdu_varr - > nADDR = sDevAddrParam . m_uchLinkAddr ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
/*
if ( pLinkParam - > m_psProvDev [ psDevAddrParam - > m_iDevIdx ] . m_bProvQuery )
{
ptrClpdu_varr - > nCONTROL | = 0x20 ;
}
else
{
// <20> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( TRUE = = bACD )
{
ptrClpdu_varr - > nCONTROL | = 0x20 ;
}
else
{
ptrClpdu_varr - > nCONTROL & = 0xDF ;
}
} */
// <20> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//if(TRUE == bACD)
//{
// ptrClpdu_varr->nCONTROL |= 0x20;
//}
//else
//{
// ptrClpdu_varr->nCONTROL &= 0xDF;
//}
ptrClpdu_varr - > nCONTROL & = 0xDF ;
wValue = sSoeData . SoeTime . mSec + sSoeData . SoeTime . Sec * 1000 ;
if ( sSoeData . u8Type = = 1 )
{
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) ] = 0x01 ;
len = 14 ;
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 7 ] = LOBYTE ( wValue ) ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 8 ] = HIBYTE ( wValue ) ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 9 ] = sSoeData . SoeTime . Min & 0x3F ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 10 ] = sSoeData . SoeTime . Hour & 0x1F ;
// SIN
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 11 ] = 0 ;
}
else
{
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) ] = 0x02 ;
len = 18 ;
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 7 ] = LOBYTE ( sSoeData . wRelativeTime ) ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 8 ] = HIBYTE ( sSoeData . wRelativeTime ) ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 9 ] = LOBYTE ( sSoeData . wFaultNo ) ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 10 ] = HIBYTE ( sSoeData . wFaultNo ) ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 11 ] = LOBYTE ( wValue ) ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 12 ] = HIBYTE ( wValue ) ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 13 ] = sSoeData . SoeTime . Min & 0x3F ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 14 ] = sSoeData . SoeTime . Hour & 0x1F ;
// SIN
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 15 ] = 0 ;
}
ptrClpdu_varr - > nLEN1 = ( BYTE ) len ;
ptrClpdu_varr - > nLEN2 = ( BYTE ) len ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 1 ] = 0x81 ;
//COT
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 2 ] = M_CAUSE_AUTOSEND ;
// <20> <> <EFBFBD> ¸ <EFBFBD> ֵ ASDU <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 3 ] = sDevAddrParam . m_uchCommAddr ;
// FUN
//rtumsg.MsgData[sizeof(CLPDU_VARR)+4] = sSoeData.u8ProvFun;
// INF
//rtumsg.MsgData[sizeof(CLPDU_VARR)+5] = sSoeData.u8ProvInf;
// FUN
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 4 ] = sDbInfo . m_u8ProvFun ;
// INF
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 5 ] = sDbInfo . m_u8ProvInf ;
// DPI
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 6 ] = sSoeData . bStatus + 1 ;
len = ptrClpdu_varr - > nLEN1 + 4 ;
// <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD>
//rtumsg.MsgData[len++] = CalBuban103Lpc(rtumsg.MsgData+4, ptrClpdu_varr->nLEN1);
rtumsg . MsgData [ len + + ] = 0 ;
rtumsg . MsgData [ len + + ] = 0x16 ;
PutPollCmdToBuf ( commid , FAST_POLL_CMD , 0 , ( char * ) rtumsg . MsgData , len ) ;
return ;
}
bACD = ProvHaveClassOne ( commid , psDevAddrParam , pPortParam - > m_bSendChangeDi ) ;
if ( bACD = = TRUE )
{
// ??? <20> <> Ҫ<EFBFBD> <EFBFBD> Ϊʵ<CEAA> <CAB5> <EFBFBD> <EFBFBD> Ϣ
//bACD = FALSE;
pProvDevParam = & pLinkParam - > m_psProvDev [ psDevAddrParam - > m_iDevIdx ] ;
if ( SingleListHaveData ( & pProvDevParam - > m_sBaoHuData ) > 0 )
{
msg . MsgLen = SingleListGetAndDelData ( & pProvDevParam - > m_sBaoHuData , msg . MsgData , sizeof ( msg . MsgData ) ) ;
if ( pLinkParam - > m_uchLinkAddr ! = 0xFF )
{
msg . MsgData [ 5 ] = pLinkParam - > m_uchLinkAddr ;
}
else
{
msg . MsgData [ 5 ] = ( BYTE ) pProvDevParam - > m_iProvAddr ;
}
msg . MsgData [ 9 ] = ( BYTE ) pProvDevParam - > m_iProvAddr ;
PutPollCmdToBuf ( commid , FAST_POLL_CMD , 0 , ( char * ) msg . MsgData , msg . MsgLen ) ;
return ;
}
// <20> Ƿ<EFBFBD> ת<EFBFBD> <D7AA> ң<EFBFBD> ű<EFBFBD> λ,һ <> 㽫<EFBFBD> <E3BDAB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( pPortParam - > m_bSendChangeDi = = TRUE )
{
if ( pPortParam - > m_psBaoHu - > DiChange = = TRUE )
{
if ( TRUE = = ProvSendChangedDi ( commid , psDevAddrParam ) )
{
return ;
}
}
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( pProvDevParam - > m_bProvQuery = = TRUE )
{
pDBUnit = & pProvDevParam - > m_sYxInfo ;
for ( i = pProvDevParam - > m_iQueryPntNo ; i < pDBUnit - > m_iPntNum ; i + + )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD>
if ( pDBUnit - > m_psDataInfo [ i ] . m_u8LoopData )
{
break ;
}
}
if ( i > = pDBUnit - > m_iPntNum )
{
pProvDevParam - > m_bProvQuery = FALSE ;
pProvDevParam - > m_iProvQueryStepWithASDU = 0 ;
ProvMakeVarCommand ( commid , pLinkParam - > m_uchLinkAddr , \
( BYTE ) pProvDevParam - > m_iProvAddr , M_TGI_NA_3 , FALSE , \
( BYTE ) M_CAUSE_STOPQUERY , FAST_POLL_CMD ) ;
pProvDevParam - > m_iQueryPntNo = 0 ;
}
else
{
pProvDevParam - > m_iQueryPntNo + + ;
diprovptr = ( PROV_DI_PNT * ) pPortParam - > m_psBaoHu - > DiPtr ;
ptrClpdu_varr = ( CLPDU_VARR * ) rtumsg . MsgData ;
ptrClpdu_varr - > nSTART1 = 0x68 ;
ptrClpdu_varr - > nSTART2 = 0x68 ;
// <20> <> <EFBFBD> ¸ <EFBFBD> ֵ<EFBFBD> <D6B5> ·<EFBFBD> <C2B7> ת<EFBFBD> <D7AA> <EFBFBD> <EFBFBD> ַ
ptrClpdu_varr - > nADDR = pLinkParam - > m_uchLinkAddr ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
ptrClpdu_varr - > nCONTROL | = 0x20 ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) ] = 0x01 ;
len = 14 ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 1 ] = 0x81 ;
//COT
//rtumsg.MsgData[sizeof(CLPDU_VARR)+2] = M_CAUSE_AUTOSEND;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 2 ] = M_CAUSE_QUERY ;
// <20> <> <EFBFBD> ¸ <EFBFBD> ֵ ASDU <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 3 ] = ( BYTE ) pProvDevParam - > m_iProvAddr ;
// FUN
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 4 ] = pDBUnit - > m_psDataInfo [ i ] . m_u8ProvFun ;
// INF
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 5 ] = pDBUnit - > m_psDataInfo [ i ] . m_u8ProvInf ;
GetPntMsg ( diprovptr [ pDBUnit - > m_iStartPntNo + i ] . PortNo , \
diprovptr [ pDBUnit - > m_iStartPntNo + i ] . PntNo , \
( void * ) & pntmsg , DI_PNT_TYPE , PNT_STATUS ) ;
// DPI
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 6 ] = pntmsg . Status + 1 ;
GetLocalTimeEx ( & sCurTime ) ;
wValue = sCurTime . Sec * 1000 + sCurTime . mSec ;
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 7 ] = LOBYTE ( wValue ) ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 8 ] = HIBYTE ( wValue ) ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 9 ] = sCurTime . Min & 0x3F ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 10 ] = sCurTime . Hour & 0x1F ;
// SIN
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 11 ] = 0 ;
ptrClpdu_varr - > nLEN1 = ( BYTE ) len ;
ptrClpdu_varr - > nLEN2 = ( BYTE ) len ;
len = ptrClpdu_varr - > nLEN1 + 4 ;
// <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD>
//rtumsg.MsgData[len++] = CalBuban103Lpc(rtumsg.MsgData+4, ptrClpdu_varr->nLEN1);
rtumsg . MsgData [ len + + ] = 0 ;
rtumsg . MsgData [ len + + ] = 0x16 ;
PutPollCmdToBuf ( commid , FAST_POLL_CMD , 0 , ( char * ) rtumsg . MsgData , len ) ;
}
return ;
}
}
/*
if ( pLinkParam - > m_uchLinkAddr ! = 0xFF )
{
ProvMakeLinkCommand ( commid , pLinkParam - > m_uchLinkAddr , M_NV_NA_3 , FALSE ) ;
}
else
{
ProvMakeLinkCommand ( commid , psDevAddrParam - > m_uchLinkAddr , M_NV_NA_3 , FALSE ) ;
}
*/
//ProvMakeLinkCommand(commid, psDevAddrParam->m_uchLinkAddr, M_NV_NA_3, bACD);
ProvMakeLinkCommand ( commid , psDevAddrParam - > m_uchLinkAddr , M_NV_NA_3 , FALSE ) ;
}
//***************************************************************************/
//* ת<> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* u_char addr : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> 豸<EFBFBD> <E8B1B8> ַ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvPL2process ( u_32 commid , DEVADDRPARAM * psDevAddrParam )
{
//BOOL bACD;
//PROVDEVDEF *pProvDevParam;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
pLinkParam = & pPortParam - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ;
//pProvDevParam = &pLinkParam->m_psProvDev[pLinkParam->m_iDevIdx];
//psDevAddrParam->m_iDevIdx = pLinkParam->m_iDevIdx;
/*
// <20> <> <EFBFBD> ȷ<EFBFBD> <C8B7> <EFBFBD> ͻ<EFBFBD> <CDBB> <EFBFBD> ¼<EFBFBD>
if ( ProvHaveSoeData ( commid ) > 0 )
{
bACD = TRUE ;
}
else if ( pProvDevParam - > m_bProvQuery = = TRUE )
{
bACD = TRUE ;
}
else
{
bACD = FALSE ;
}
*/
//bACD = ProvHaveClassOne(commid, psDevAddrParam, FALSE);
//ProvMakeLinkCommand(commid, pLinkParam->m_uchLinkAddr, M_NV_NA_3, bACD);
ProvMakeLinkCommand ( commid , pLinkParam - > m_uchLinkAddr , M_NV_NA_3 , FALSE ) ;
}
//***************************************************************************/
//* <20> <> <EFBFBD> <EFBFBD> ת<EFBFBD> <D7AA> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void Provlongprocess ( u_32 commid , RTUMSG * rtumsg )
{
BOOL bFind ;
DEVADDRPARAM DevAddrParam ;
BUBAN103LINKDEF * pLinkParam = NULL ;
BUBAN103PORTPARAM * pPortParam = NULL ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
if ( ( rtumsg - > MsgData [ 4 ] & 0xc0 ) = = 0 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d(CtrlByte=%02x)<29> <> <EFBFBD> յ<EFBFBD> <D5B5> Ķ<EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> ݲ<EFBFBD> <DDB2> <EFBFBD> <EFBFBD> <EFBFBD> վ<EFBFBD> <D5BE> <EFBFBD> <EFBFBD> !!!\n " ,
commid , rtumsg - > MsgData [ 5 ] , rtumsg - > MsgData [ 4 ] ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
if ( ! IsExtInfoPtr ( commid ) )
{
return ;
}
pPortParam = ( pBUBAN103PORTPARAM ) SioParam [ commid ] . ExtInfo ;
DevAddrParam . m_uchLinkAddr = rtumsg - > MsgData [ 5 ] ;
DevAddrParam . m_uchCommAddr = rtumsg - > MsgData [ 9 ] ;
if ( 0xFF ! = DevAddrParam . m_uchLinkAddr )
{
if ( FindProtectDev ( pPortParam , & DevAddrParam , FALSE ) = = FALSE )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d <20> <> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , rtumsg - > MsgData [ 5 ] , rtumsg - > MsgData [ 9 ] ) ;
DebugPrint ( szbuf ) ;
# endif
bFind = FALSE ;
}
else
{
bFind = TRUE ;
}
if ( TRUE = = bFind )
{
pLinkParam = & pPortParam - > m_psLink [ DevAddrParam . m_iLinkIdx ] ;
}
if ( IsDevLinkOk ( pLinkParam , DevAddrParam . m_iDevIdx ) = = FALSE )
{
return ;
}
}
else
{
if ( C_SYN_TA_3 ! = rtumsg - > MsgData [ 6 ] )
{
return ;
}
}
// <20> <> ֡<EFBFBD> <D6A1> <EFBFBD> ݵĹ<DDB5> <C4B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
switch ( rtumsg - > MsgData [ 6 ] )
{
case C_SYN_TA_3 : //ʱ<> <CAB1> ͬ<EFBFBD> <CDAC>
ProvSYNprocess ( commid , rtumsg ) ;
break ;
case C_TGI_NA_3 : //<2F> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD>
ProvTGIprocess ( commid , rtumsg , & DevAddrParam ) ;
break ;
case C_GD_NA_3 : //ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
ProvGDprocess ( commid , rtumsg , & DevAddrParam ) ;
//ProvSendCmdToPort(commid, rtumsg, &DevAddrParam);
break ;
case C_GRC_NA_3 : //һ <> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
ProvGRCprocess ( commid , rtumsg , & DevAddrParam ) ;
break ;
case C_GC_NA_3 : //ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
ProvGCprocess ( commid , rtumsg , & DevAddrParam ) ;
//ProvSendCmdToPort(commid, rtumsg, &DevAddrParam);
break ;
case C_ODT_NA_3 : //<2F> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
ProvODTprocess ( commid , rtumsg , & DevAddrParam ) ;
break ;
case C_ADT_NA_3 : //<2F> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ͽ<EFBFBD>
ProvADTprocess ( commid , rtumsg , & DevAddrParam ) ;
break ;
case C_DC_NA_3 : //<2F> <> <EFBFBD> ƶ<EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
ProvDCprocess ( commid , rtumsg , & DevAddrParam ) ;
break ;
case C_RC_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
ProvRCprocess ( commid , rtumsg , & DevAddrParam ) ;
break ;
case C_SE_NA_3 : //<2F> 趨<EFBFBD> <E8B6A8> <EFBFBD> <EFBFBD>
ProvSEprocess ( commid , rtumsg , & DevAddrParam ) ;
break ;
case C_CC_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
ProvCCprocess ( commid , rtumsg , & DevAddrParam ) ;
break ;
case C_CI_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD>
ProvCIprocess ( commid , rtumsg , & DevAddrParam ) ;
break ;
default :
break ;
}
switch ( rtumsg - > MsgData [ 4 ] & 0x0f )
{
case C_SD1_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> <DDA3> <EFBFBD> <EFBFBD> <EFBFBD> /ȷ<> <C8B7> ֡<EFBFBD> <D6A1>
// <20> <> <EFBFBD> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD>
/*
if ( C_TGI_NA_3 = = rtumsg - > MsgData [ 6 ] )
{
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 5 ] , M_CON_NA_3 , TRUE ) ;
}
else if ( C_SYN_TA_3 = = rtumsg - > MsgData [ 6 ] )
{
if ( rtumsg - > MsgData [ 5 ] ! = 0xFF )
{
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 5 ] , M_CON_NA_3 , TRUE ) ;
}
}
else
{
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 5 ] , M_CON_NA_3 , FALSE ) ;
}
*/
//if(TRUE == ProvHaveClassOne(commid, &DevAddrParam, FALSE))
//{
// ProvMakeLinkCommand(commid, rtumsg->MsgData[5], M_CON_NA_3, TRUE);
//}
//else
//{
// ProvMakeLinkCommand(commid, rtumsg->MsgData[5], M_CON_NA_3, FALSE);
//}
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 5 ] , M_CON_NA_3 , FALSE ) ;
break ;
case C_SD2_NA_3 : //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> <DDA3> <EFBFBD> <EFBFBD> <EFBFBD> /<2F> ش<DEBB> ֡<EFBFBD> <D6A1>
break ;
}
}
//***************************************************************************/
//* ת<> <D7AA> ʱ<EFBFBD> <CAB1> ͬ<EFBFBD> <CDAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvSYNprocess ( u_32 commid , RTUMSG * rtumsg )
{
i_32 len ;
DAY_TIME sTime ;
//char szDbg[128];
u_char tmp [ MAX_POLL_CMD_BUF_LEN ] ;
CLPDU_VARR bClpdu_varr ;
BUBAN103PORTPARAM * pPortParam ;
if ( ! IsExtInfoPtr ( commid ) )
{
return ;
}
pPortParam = ( pBUBAN103PORTPARAM ) SioParam [ commid ] . ExtInfo ;
sTime . mSec = rtumsg - > MsgData [ 12 ] + ( rtumsg - > MsgData [ 13 ] < < 8 ) ;
sTime . Sec = sTime . mSec / 1000 ;
sTime . mSec = 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 ;
//sprintf(szDbg, "time:%04d-%02d-%02d_%02d:%02d:%02d.%03d\n",
// sTime.Year, sTime.Month, sTime.Day, sTime.Hour,
// sTime.Min, sTime.Sec, sTime.mSec);
//DebugPrint(szDbg);
// <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> ͬ<EFBFBD> <CDAC> ԭ<EFBFBD> <D4AD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ж<EFBFBD> ʱ
if ( ( pPortParam - > m_psBaoHu - > CheckTime = = 1 )
& & ( rtumsg - > MsgData [ 8 ] = = M_CAUSE_CHECKTIME ) )
{
SetLocalTimeEx ( & sTime ) ;
}
// <20> 㲥<EFBFBD> <E3B2A5> ַ
if ( rtumsg - > MsgData [ 5 ] = = 0xff )
{
return ;
}
memset ( & bClpdu_varr , 0 , sizeof ( CLPDU_VARR ) ) ;
memset ( tmp , 0 , sizeof ( tmp ) ) ;
bClpdu_varr . nSTART1 = 0x68 ;
bClpdu_varr . nSTART2 = 0x68 ;
bClpdu_varr . nLEN1 = 15 ;
bClpdu_varr . nLEN2 = 15 ;
bClpdu_varr . nCONTROL = M_DATA_NA_3 ;
bClpdu_varr . nADDR = rtumsg - > MsgData [ 5 ] ;
len = sizeof ( bClpdu_varr ) ;
memcpy ( tmp , ( char * ) & bClpdu_varr , len ) ;
tmp [ len + + ] = M_SYN_TA_3 ;
tmp [ len + + ] = 0x81 ;
tmp [ len + + ] = M_CAUSE_CHECKTIME ;
tmp [ len + + ] = rtumsg - > MsgData [ 9 ] ;
tmp [ len + + ] = FUNC_GLOBAL ;
tmp [ len + + ] = 0 ;
memcpy ( tmp + len , rtumsg - > MsgData + 12 , 7 ) ;
//if(!SetLocalTime(&t))
// tmp[len+2] |= 0x80;
len + = 7 ;
//tmp[len++] = CalBuban103Lpc(tmp+4, bClpdu_varr.nLEN1);
tmp [ len + + ] = 0 ;
tmp [ len + + ] = 0x16 ;
PutPollCmdToBuf ( commid , FAST_POLL_CMD , 0 , ( char * ) tmp , len ) ;
}
//***************************************************************************/
//* ת<> <D7AA> <EFBFBD> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> <EFBFBD> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvTGIprocess ( u_32 commid , RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
PROVDEVDEF * pProvDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
if ( GetPortParamPtr ( commid , & pPortParam ) = = FALSE )
{
return ;
}
pPortParam - > m_iLinkIdx = psDevAddrParam - > m_iLinkIdx ;
pLinkParam = & pPortParam - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ;
pLinkParam - > m_iDevIdx = psDevAddrParam - > m_iDevIdx ;
pProvDevParam = & pLinkParam - > m_psProvDev [ psDevAddrParam - > m_iDevIdx ] ;
// <20> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> ʼ
pProvDevParam - > m_bProvQuery = TRUE ;
pProvDevParam - > m_iProvQueryStepWithASDU = M_MEVII_NA_3 ;
// <20> <> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> <DDA3> <EFBFBD> <EFBFBD> <EFBFBD> ѯ
//ProvMakeLinkCommand(commid, rtumsg->MsgData[9], M_CON_NA_3, TRUE);
//ProvMakeLinkCommand(commid, rtumsg->MsgData[5], M_CON_NA_3, TRUE);
}
//***************************************************************************/
//* ת<> <D7AA> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvGDprocess ( u_32 commid , RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
//PROVDEVDEF *pProvDevParam;
//BUBAN103LINKDEF *pLinkParam;
//BUBAN103PORTPARAM *pPortParam;
if ( rtumsg - > MsgData [ 12 ] ! = RII_PROV_ID )
{
ProvSendCmdToPort ( commid , rtumsg , psDevAddrParam ) ;
return ;
}
//if(FALSE == GetSpecialProvPtr(commid, psDevAddrParam, &pPortParam, &pLinkParam, &pProvDevParam))
//{
// return;
//}
}
//***************************************************************************/
//* ת<> <D7AA> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEB4A6> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvGRCprocess ( u_32 commid , RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
if ( rtumsg - > MsgData [ 12 ] ! = RII_PROV_ID )
{
ProvSendCmdToPort ( commid , rtumsg , psDevAddrParam ) ;
return ;
}
}
//***************************************************************************/
//* ת<> <D7AA> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEB4A6> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvGCprocess ( u_32 commid , RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
int iGrpNum ;
GROUPDEF * pBaoHuDB ;
PROVDEVDEF * pProvDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
/*wen 2005.06.01 ʵ<> <CAB5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ,ֱ<> <D6B1> ת<EFBFBD> <D7AA> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> ȥ
if ( rtumsg - > MsgData [ 12 ] ! = RII_PROV_ID )
{
ProvSendCmdToPort ( commid , rtumsg , psDevAddrParam ) ;
return ;
}
*/
if ( FALSE = = GetSpecialProvPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pProvDevParam ) )
{
return ;
}
if ( rtumsg - > MsgData [ 12 ] ! = RII_PROV_ID )
{
pProvDevParam - > m_sProvGroupParam . m_u8Group = rtumsg - > MsgData [ 9 ] ;
pProvDevParam - > m_sProvGroupParam . m_u8ItemAttr = rtumsg - > MsgData [ 11 ] ;
pProvDevParam - > m_sProvGroupParam . m_u8ItemNo = rtumsg - > MsgData [ 10 ] ;
pProvDevParam - > m_sProvGroupParam . m_u8RII = rtumsg - > MsgData [ 12 ] ;
pBaoHuDB = NULL ;
iGrpNum = GetBaohuDB ( pProvDevParam - > m_iRealCommid - 1 , pProvDevParam - > m_iProvAddr , & pBaoHuDB ) ;
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
if ( rtumsg - > MsgData [ 8 ] = = C_CAUSE_READWITHVALIDDATA )
{
// INF
switch ( rtumsg - > MsgData [ 11 ] )
{
case C_INF_READGROUPTITLE : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ( pBaoHuDB ! = NULL ) & & ( iGrpNum > 0 ) )
{
ProvMakeTitleOfGroups ( commid , rtumsg , pProvDevParam , pBaoHuDB , iGrpNum ) ;
}
else
{
ProvSendCmdToPort ( commid , rtumsg , psDevAddrParam ) ;
}
break ;
case C_INF_READGROUPALLITEMS : // <20> <> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȫ<EFBFBD> <C8AB> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ( pBaoHuDB ! = NULL ) & & ( iGrpNum > 0 ) )
{
ProvMakeAttrOfAllItemInGroup ( commid , rtumsg , pProvDevParam , pBaoHuDB , iGrpNum ) ;
}
else
{
ProvSendCmdToPort ( commid , rtumsg , psDevAddrParam ) ;
}
break ;
case C_INF_READDIROFSINGLEITEM : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> Ŀ¼
if ( ( pBaoHuDB ! = NULL ) & & ( iGrpNum > 0 ) )
{
ProvMakeDirOfItem ( commid , rtumsg , pProvDevParam , pBaoHuDB , iGrpNum ) ;
}
else
{
ProvSendCmdToPort ( commid , rtumsg , psDevAddrParam ) ;
}
break ;
case C_INF_READATTROFISNGLEITEM : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ( pBaoHuDB ! = NULL ) & & ( iGrpNum > 0 ) )
{
ProvMakeAttrOfItem ( commid , rtumsg , pProvDevParam , pBaoHuDB , iGrpNum ) ;
}
else
{
ProvSendCmdToPort ( commid , rtumsg , psDevAddrParam ) ;
}
break ;
case C_INF_QUERYGENERAL : // <20> <> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ܲ<EFBFBD> ѯ
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 5 ] , M_NV_NA_3 , FALSE ) ;
break ;
default :
ProvSendCmdToPort ( commid , rtumsg , psDevAddrParam ) ;
break ;
}
}
else
{
ProvSendCmdToPort ( commid , rtumsg , psDevAddrParam ) ;
}
return ;
}
// wen test <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ӱ<EFBFBD> <D3B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݷ<EFBFBD> <DDB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( RII_PROV_ID = = rtumsg - > MsgData [ 12 ] )
{
// test
RTUMSG msg ;
BYTE buffix [ ] = { 0x68 , 0x46 , 0x46 , 0x68 , 0x08 , 0x01 ,
0x0A , 0x81 , 0x2A , 0x01 , 0xFE , 0xF1 ,
0xFF , 0x06 , 0x50 , 0x01 , 0x01 , 0x07 ,
0x04 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 ,
0x50 , 0x02 , 0x01 , 0x07 , 0x04 , 0x01 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x50 , 0x03 ,
0x01 , 0x07 , 0x04 , 0x01 , 0x22 , 0xDB ,
0x79 , 0x3F , 0x50 , 0x04 , 0x01 , 0x07 ,
0x04 , 0x01 , 0x3D , 0x6A , 0x53 , 0x43 ,
0x50 , 0x05 , 0x01 , 0x07 , 0x04 , 0x01 ,
0x00 , 0x00 , 0x00 , 0x00 , 0x50 , 0x06 ,
0x01 , 0x07 , 0x04 , 0x01 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x08 , 0x16 } ;
BYTE bufsoe [ ] = { 0x68 , 0x0E , 0x0E , 0x68 , 0x28 , 0x01 ,
0x01 , 0x81 , 0x01 , 0x01 , 0x64 , 0x42 ,
0x01 , 0x70 , 0x94 , 0x05 , 0x0D , 0x00 ,
0x6A , 0x16 } ;
msg . MsgLen = sizeof ( buffix ) ;
memcpy ( msg . MsgData , buffix , msg . MsgLen ) ;
msg . PortIdx = ( BYTE ) commid ;
if ( pLinkParam - > m_uchLinkAddr ! = 0xFF )
{
msg . MsgData [ 5 ] = pLinkParam - > m_uchLinkAddr ;
}
else
{
msg . MsgData [ 5 ] = ( BYTE ) pProvDevParam - > m_iProvAddr ;
}
msg . MsgData [ 9 ] = ( BYTE ) pProvDevParam - > m_iProvAddr ;
SingleListAddData ( & pProvDevParam - > m_sBaoHuData , msg . MsgData , msg . MsgLen ) ;
return ;
}
}
//***************************************************************************/
//* ת<> <D7AA> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEB4A6> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvODTprocess ( u_32 commid , RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
}
//***************************************************************************/
//* ת<> <D7AA> <EFBFBD> Ŷ<EFBFBD> <C5B6> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ͽɴ<CFBF> <C9B4> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvADTprocess ( u_32 commid , RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
}
//***************************************************************************/
//* ת<> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> ƶ<EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEB4A6> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvDCprocess ( u_32 commid , RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
}
//***************************************************************************/
//* ת<> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEB4A6> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvRCprocess ( u_32 commid , RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
}
//***************************************************************************/
//* ת<> <D7AA> <EFBFBD> 趨<EFBFBD> <E8B6A8> <EFBFBD> <EFBFBD> <EEB4A6> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvSEprocess ( u_32 commid , RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
}
//***************************************************************************/
//* ת<> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EEB4A6> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvCCprocess ( u_32 commid , RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
}
//***************************************************************************/
//* ת<> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ٻ<EFBFBD> <D9BB> <EFBFBD> <EFBFBD> <EFBFBD> <EEB4A6> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
void ProvCIprocess ( u_32 commid , RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam )
{
i_32 iPiNum ;
i_32 i ;
u_char tmp [ MAX_POLL_CMD_BUF_LEN ] ;
CLPDU_VARR * ptrClpdu_varr ;
i_32 len ;
PI_DEF pntmsg ;
PROV_PI_PNT * piprovptr ;
PROVDEVDEF * pProvDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
if ( GetSpecialProvPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pProvDevParam ) = = FALSE )
{
return ;
}
memset ( tmp , 0 , sizeof ( tmp ) ) ;
ptrClpdu_varr = ( CLPDU_VARR * ) tmp ;
ptrClpdu_varr - > nSTART1 = 0x68 ;
ptrClpdu_varr - > nSTART2 = 0x68 ;
ptrClpdu_varr - > nADDR = rtumsg - > MsgData [ 5 ] ;
//if(ProvHaveClassOne(commid, psDevAddrParam, TRUE))
//{
// ptrClpdu_varr->nCONTROL = 0x28;
//}
//else
//{
// ptrClpdu_varr->nCONTROL = 0x08;
//}
ptrClpdu_varr - > nCONTROL = 0x08 ;
len = sizeof ( CLPDU_VARR ) ;
tmp [ len + + ] = M_IT_NA_3 ;
tmp [ len + + ] = 0x00 ;
tmp [ len + + ] = M_CAUSE_CYCLE ;
tmp [ len + + ] = rtumsg - > MsgData [ 9 ] ;
tmp [ len + + ] = 1 ;
iPiNum = pProvDevParam - > m_sYmInfo . m_iPntNum ;
if ( iPiNum > INF_PI_NUM )
{
iPiNum = INF_PI_NUM ;
}
piprovptr = ( PROV_PI_PNT * ) pPortParam - > m_psBaoHu - > PiPtr ;
if ( ( pProvDevParam - > m_sYmInfo . m_iStartPntNo + iPiNum ) \
> pPortParam - > m_psBaoHu - > PiNum )
{
if ( ( pProvDevParam - > m_bProvQuery = = TRUE ) \
| | ( CheckPollCmdBufEmpty ( commid ) = = 0 ) )
{
//ProvMakeLinkCommand(commid, pLinkParam->m_uchLinkAddr, M_NV_NA_3, TRUE);
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 5 ] , M_NV_NA_3 , TRUE ) ;
}
else
{
//ProvMakeLinkCommand(commid, pLinkParam->m_uchLinkAddr, M_NV_NA_3, FALSE);
ProvMakeLinkCommand ( commid , rtumsg - > MsgData [ 5 ] , M_NV_NA_3 , FALSE ) ;
}
return ;
}
tmp [ len + + ] = INF_PI_START ;
for ( i = 0 ; i < iPiNum ; i + + )
{
GetPntMsg ( piprovptr [ pProvDevParam - > m_sYmInfo . m_iStartPntNo + i ] . PortNo , \
piprovptr [ pProvDevParam - > m_sYmInfo . m_iStartPntNo + i ] . PntNo , \
& pntmsg , PI_PNT_TYPE , PNT_RAWVALUE ) ;
tmp [ len + + ] = ( BYTE ) ( pntmsg . RawValue & 0xFF ) ;
tmp [ len + + ] = ( BYTE ) ( ( pntmsg . RawValue & 0xFF00 ) > > 8 ) ;
tmp [ len + + ] = ( BYTE ) ( ( pntmsg . RawValue & 0xFF0000 ) > > 16 ) ;
tmp [ len + + ] = ( BYTE ) ( ( pntmsg . RawValue & 0xFF000000 ) > > 24 ) ;
// IV/CA/CY/˳<> <CBB3> <EFBFBD> <EFBFBD>
len + + ;
}
tmp [ sizeof ( CLPDU_VARR ) + 1 ] = ( BYTE ) ( iPiNum ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> RII
tmp [ len + + ] = rtumsg - > MsgData [ 13 ] ;
ptrClpdu_varr - > nLEN1 = len - 4 ;
ptrClpdu_varr - > nLEN2 = len - 4 ;
//tmp[len++] = CalBuban103Lpc(tmp+4, ptrClpdu_varr->nLEN1);
tmp [ len + + ] = 0 ;
tmp [ len + + ] = 0x16 ;
PutPollCmdToBuf ( commid , FAST_POLL_CMD , 0 , ( char * ) tmp , len ) ;
}
//***************************************************************************/
//* ת<> <D7AA> ȫ<EFBFBD> <C8AB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
BOOL ProvMakeTitleOfGroups ( u_32 commid , RTUMSG * rtumsg , PROVDEVDEF * pProvDevParam , GROUPDEF * pBaoHuDB , int iNum )
{
i_32 i , len ;
RTUMSG msg ;
CLPDU_VARR * ptrClpdu_varr ;
memset ( ( void * ) & msg , 0 , sizeof ( RTUMSG ) ) ;
ptrClpdu_varr = ( CLPDU_VARR * ) msg . MsgData ;
ptrClpdu_varr - > nSTART1 = 0x68 ;
ptrClpdu_varr - > nSTART2 = 0x68 ;
ptrClpdu_varr - > nADDR = rtumsg - > MsgData [ 5 ] ;
len = sizeof ( CLPDU_VARR ) ;
msg . MsgData [ len + + ] = M_GD_NTA_3 ;
msg . MsgData [ len + + ] = 0x81 ;
msg . MsgData [ len + + ] = M_CAUSE_READWITHVALIDDATA ;
msg . MsgData [ len + + ] = rtumsg - > MsgData [ 9 ] ;
msg . MsgData [ len + + ] = FUNC_GENERALSORT ;
msg . MsgData [ len + + ] = M_INF_READGROUPTITLE ;
msg . MsgData [ len + + ] = rtumsg - > MsgData [ 12 ] ; //RII
msg . MsgData [ len + + ] = ( BYTE ) iNum ;
for ( i = 0 ; i < iNum ; i + + )
{
//msg.MsgData[len++] = i;// <20> <> <EFBFBD> <EFBFBD>
msg . MsgData [ len + + ] = ( BYTE ) pBaoHuDB [ i ] . m_iGroupNo ; // <20> <> <EFBFBD> <EFBFBD>
msg . MsgData [ len + + ] = 0 ; // <20> <> Ŀ<EFBFBD> <C4BF>
msg . MsgData [ len + + ] = KOD_DESCRIPTION ; //<2F> <> <EFBFBD> <EFBFBD>
msg . MsgData [ len + + ] = DATAID_OS8ASCII ; //datatype
switch ( pBaoHuDB [ i ] . m_iDataType )
{
case AI_PNT_TYPE : // ģ<> <C4A3> <EFBFBD> <EFBFBD>
msg . MsgData [ len + + ] = strlen ( " ģ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
msg . MsgData [ len + + ] = 1 ;
memcpy ( ( void * ) & msg . MsgData [ len ] , ( void * ) " ģ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " , strlen ( " ģ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ) ;
len + = strlen ( " ģ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
break ;
case DI_PNT_TYPE : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
msg . MsgData [ len + + ] = strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
msg . MsgData [ len + + ] = 1 ;
memcpy ( ( void * ) & msg . MsgData [ len ] , ( void * ) " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " , strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ) ;
len + = strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
break ;
case PI_PNT_TYPE : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
msg . MsgData [ len + + ] = strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
msg . MsgData [ len + + ] = 1 ;
memcpy ( ( void * ) & msg . MsgData [ len ] , ( void * ) " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " , strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ) ;
len + = strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
break ;
case PROTECT_AI_PNT_TYPE : // <20> <> <EFBFBD> <EFBFBD> ģ<EFBFBD> <C4A3> <EFBFBD> <EFBFBD>
msg . MsgData [ len + + ] = strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ģ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
msg . MsgData [ len + + ] = 1 ;
memcpy ( ( void * ) & msg . MsgData [ len ] , ( void * ) " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ģ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " , strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ģ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ) ;
len + = strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ģ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
break ;
case PROTECT_DI_PNT_TYPE : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
msg . MsgData [ len + + ] = strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
msg . MsgData [ len + + ] = 1 ;
memcpy ( ( void * ) & msg . MsgData [ len ] , ( void * ) " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " , strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ) ;
len + = strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
break ;
case PROTECT_FIX_PNT_TYPE : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ
msg . MsgData [ len + + ] = strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ" ) ;
msg . MsgData [ len + + ] = 1 ;
memcpy ( ( void * ) & msg . MsgData [ len ] , ( void * ) " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ" , strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ" ) ) ;
len + = strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ" ) ;
break ;
case PROTECT_EVENT_PNT_TYPE : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD>
msg . MsgData [ len + + ] = strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> " ) ;
msg . MsgData [ len + + ] = 1 ;
memcpy ( ( void * ) & msg . MsgData [ len ] , ( void * ) " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> " , strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> " ) ) ;
len + = strlen ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> " ) ;
break ;
default :
msg . MsgData [ len + + ] = strlen ( " δ֪<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
msg . MsgData [ len + + ] = 1 ;
memcpy ( ( void * ) & msg . MsgData [ len ] , ( void * ) " δ֪<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " , strlen ( " δ֪<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ) ;
len + = strlen ( " δ֪<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
break ;
}
}
ptrClpdu_varr - > nLEN1 = len - 4 ;
ptrClpdu_varr - > nLEN2 = len - 4 ;
//msg.MsgData[len++] = CalBuban103Lpc(msg.MsgData+4, ptrClpdu_varr->nLEN1);
msg . MsgData [ len + + ] = 0 ;
msg . MsgData [ len + + ] = 0x16 ;
msg . MsgLen = ( WORD ) len ;
msg . PortIdx = ( BYTE ) commid ;
return SingleListAddData ( & pProvDevParam - > m_sBaoHuData , msg . MsgData , msg . MsgLen ) ;
}
//***************************************************************************/
//* ת<> <D7AA> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȫ<EFBFBD> <C8AB> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//* BOOL bContinue : δ<> <CEB4> <EFBFBD> ͵ı <CDB5> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//*<2A> <> ע:<3A> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֻ<EFBFBD> <D6BB> ת<EFBFBD> <D7AA> һ ֡ */
//***************************************************************************/
BOOL ProvMakeAttrOfAllItemInGroup ( u_32 commid , RTUMSG * rtumsg , \
PROVDEVDEF * pProvDevParam , \
GROUPDEF * pBaoHuDB , int iNum )
{
BOOL bRetVal ;
i_32 i , ifixlen ;
RTUMSG msg ;
u_char * ptrPntNum ;
CLPDU_VARR * ptrClpdu_varr ;
i_32 iGroupNo , iPntNum , iNameLen ;
float * pfValue , fValue ;
memset ( ( void * ) & msg , 0 , sizeof ( RTUMSG ) ) ;
ptrClpdu_varr = ( CLPDU_VARR * ) msg . MsgData ;
ptrClpdu_varr - > nSTART1 = 0x68 ;
ptrClpdu_varr - > nSTART2 = 0x68 ;
ptrClpdu_varr - > nADDR = rtumsg - > MsgData [ 5 ] ;
ifixlen = sizeof ( CLPDU_VARR ) ;
// <20> <> <EFBFBD> <EFBFBD>
for ( iGroupNo = 0 ; iGroupNo < iNum ; iGroupNo + + )
{
if ( pBaoHuDB [ iGroupNo ] . m_iGroupNo = = ( int ) rtumsg - > MsgData [ 14 ] )
{
break ;
}
}
if ( iGroupNo > = iNum )
{
return FALSE ;
}
msg . MsgData [ ifixlen + + ] = M_GD_NTA_3 ;
msg . MsgData [ ifixlen + + ] = 0x81 ;
msg . MsgData [ ifixlen + + ] = M_CAUSE_READWITHVALIDDATA ;
msg . MsgData [ ifixlen + + ] = rtumsg - > MsgData [ 9 ] ;
msg . MsgData [ ifixlen + + ] = FUNC_GENERALSORT ;
msg . MsgData [ ifixlen + + ] = M_INF_READGROUPALLITEMS ;
msg . MsgData [ ifixlen + + ] = rtumsg - > MsgData [ 12 ] ; //RII
iPntNum = pBaoHuDB [ iGroupNo ] . m_iPntNum ;
ptrPntNum = & msg . MsgData [ ifixlen + + ] ;
msg . MsgLen = ( WORD ) ifixlen ;
bRetVal = TRUE ;
switch ( rtumsg - > MsgData [ 16 ] )
{
case KOD_ACTUALVALUE : // ʵ<> <CAB5> ֵ
for ( i = 0 ; i < iPntNum ; i + + )
{
// <20> ṹ<EFBFBD> <E1B9B9> <EFBFBD> <EFBFBD> = 10
msg . MsgData [ msg . MsgLen + + ] = rtumsg - > MsgData [ 14 ] ; // <20> <> <20> <>
msg . MsgData [ msg . MsgLen + + ] = i + 1 ; // <20> <> Ŀ<EFBFBD> <C4BF>
msg . MsgData [ msg . MsgLen + + ] = KOD_ACTUALVALUE ; // ʵ<> <CAB5> ֵ
msg . MsgData [ msg . MsgLen + + ] = DATAID_FLOAT ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
msg . MsgData [ msg . MsgLen + + ] = sizeof ( float ) ;
msg . MsgData [ msg . MsgLen + + ] = 1 ;
pfValue = ( float * ) ( & msg . MsgData [ msg . MsgLen ] ) ;
fValue = pBaoHuDB [ iGroupNo ] . m_psDataInfo [ i ] . m_fValue ;
SequenceHostToRtu ( ( char * ) & fValue , sizeof ( float ) ) ;
* pfValue = fValue ;
msg . MsgLen + = sizeof ( float ) ;
* ptrPntNum + + ;
if ( msg . MsgLen > = 240 )
{
ptrClpdu_varr - > nLEN1 = msg . MsgLen - 4 ;
ptrClpdu_varr - > nLEN2 = msg . MsgLen - 4 ;
msg . MsgLen + + ; // lpc
msg . MsgData [ msg . MsgLen + + ] = 0x16 ;
SingleListAddData ( & pProvDevParam - > m_sBaoHuData , msg . MsgData , msg . MsgLen ) ;
msg . MsgLen = ( WORD ) ifixlen ;
* ptrPntNum = 0 ;
}
}
if ( msg . MsgLen > ifixlen )
{
ptrClpdu_varr - > nLEN1 = msg . MsgLen - 4 ;
ptrClpdu_varr - > nLEN2 = msg . MsgLen - 4 ;
msg . MsgLen + + ; // lpc
msg . MsgData [ msg . MsgLen + + ] = 0x16 ;
SingleListAddData ( & pProvDevParam - > m_sBaoHuData , msg . MsgData , msg . MsgLen ) ;
}
break ;
case KOD_RANGE : // <20> <> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> С ֵ<D0A1> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
for ( i = 0 ; i < iPntNum ; i + + )
{
// <20> ṹ<EFBFBD> <E1B9B9> <EFBFBD> <EFBFBD> = 17
msg . MsgData [ msg . MsgLen + + ] = rtumsg - > MsgData [ 14 ] ; // <20> <> <20> <>
msg . MsgData [ msg . MsgLen + + ] = i + 1 ; // <20> <> Ŀ<EFBFBD> <C4BF>
msg . MsgData [ msg . MsgLen + + ] = KOD_RANGE ; // <20> <> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> С ֵ<D0A1> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
msg . MsgData [ msg . MsgLen + + ] = DATAID_FLOAT ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
msg . MsgData [ msg . MsgLen + + ] = sizeof ( float ) ;
msg . MsgData [ msg . MsgLen + + ] = 3 ;
pfValue = ( float * ) ( & msg . MsgData [ msg . MsgLen ] ) ;
fValue = pBaoHuDB [ iGroupNo ] . m_psDataInfo [ i ] . m_fMaxValue ;
SequenceHostToRtu ( ( char * ) & fValue , sizeof ( float ) ) ;
* pfValue = fValue ;
pfValue + + ;
fValue = pBaoHuDB [ iGroupNo ] . m_psDataInfo [ i ] . m_fMinValue ;
SequenceHostToRtu ( ( char * ) & fValue , sizeof ( float ) ) ;
* pfValue = fValue ;
pfValue + + ;
fValue = pBaoHuDB [ iGroupNo ] . m_psDataInfo [ i ] . m_fStepValue ;
SequenceHostToRtu ( ( char * ) & fValue , sizeof ( float ) ) ;
* pfValue = fValue ;
msg . MsgLen + = 3 * sizeof ( float ) ;
* ptrPntNum + + ;
if ( msg . MsgLen > = 240 )
{
ptrClpdu_varr - > nLEN1 = msg . MsgLen - 4 ;
ptrClpdu_varr - > nLEN2 = msg . MsgLen - 4 ;
msg . MsgLen + + ; // lpc
msg . MsgData [ msg . MsgLen + + ] = 0x16 ;
SingleListAddData ( & pProvDevParam - > m_sBaoHuData , msg . MsgData , msg . MsgLen ) ;
msg . MsgLen = ( WORD ) ifixlen ;
* ptrPntNum = 0 ;
}
}
if ( msg . MsgLen > ifixlen )
{
ptrClpdu_varr - > nLEN1 = msg . MsgLen - 4 ;
ptrClpdu_varr - > nLEN2 = msg . MsgLen - 4 ;
msg . MsgLen + + ; // lpc
msg . MsgData [ msg . MsgLen + + ] = 0x16 ;
SingleListAddData ( & pProvDevParam - > m_sBaoHuData , msg . MsgData , msg . MsgLen ) ;
}
break ;
case KOD_DIMENSION : // <20> <> <20> <>
for ( i = 0 ; i < iPntNum ; i + + )
{
// <20> ṹ<EFBFBD> <E1B9B9> <EFBFBD> <EFBFBD> = 6 + <20> <> <EFBFBD> ٳ<EFBFBD> <D9B3> <EFBFBD>
msg . MsgData [ msg . MsgLen + + ] = rtumsg - > MsgData [ 14 ] ; // <20> <> <20> <>
msg . MsgData [ msg . MsgLen + + ] = i + 1 ; // <20> <> Ŀ<EFBFBD> <C4BF>
msg . MsgData [ msg . MsgLen + + ] = KOD_DIMENSION ; // <20> <> <20> <>
msg . MsgData [ msg . MsgLen + + ] = DATAID_OS8ASCII ;
iNameLen = strlen ( pBaoHuDB [ iGroupNo ] . m_psDataInfo [ i ] . m_szUnit ) ;
msg . MsgData [ msg . MsgLen + + ] = ( BYTE ) iNameLen ;
msg . MsgData [ msg . MsgLen + + ] = 1 ;
memcpy ( & msg . MsgData [ msg . MsgLen ] , pBaoHuDB [ iGroupNo ] . m_psDataInfo [ i ] . m_szUnit , iNameLen ) ;
msg . MsgLen + = ( WORD ) iNameLen ;
* ptrPntNum + + ;
if ( msg . MsgLen > = 240 )
{
ptrClpdu_varr - > nLEN1 = msg . MsgLen - 4 ;
ptrClpdu_varr - > nLEN2 = msg . MsgLen - 4 ;
msg . MsgLen + + ; // lpc
msg . MsgData [ msg . MsgLen + + ] = 0x16 ;
SingleListAddData ( & pProvDevParam - > m_sBaoHuData , msg . MsgData , msg . MsgLen ) ;
msg . MsgLen = ( WORD ) ifixlen ;
* ptrPntNum = 0 ;
}
}
if ( msg . MsgLen > ifixlen )
{
ptrClpdu_varr - > nLEN1 = msg . MsgLen - 4 ;
ptrClpdu_varr - > nLEN2 = msg . MsgLen - 4 ;
msg . MsgLen + + ; // lpc
msg . MsgData [ msg . MsgLen + + ] = 0x16 ;
SingleListAddData ( & pProvDevParam - > m_sBaoHuData , msg . MsgData , msg . MsgLen ) ;
}
break ;
case KOD_DESCRIPTION : // <20> <> <20> <>
for ( i = 0 ; i < iPntNum ; i + + )
{
// <20> ṹ<EFBFBD> <E1B9B9> <EFBFBD> <EFBFBD> = 6 + <20> <> <EFBFBD> ٳ<EFBFBD> <D9B3> <EFBFBD>
msg . MsgData [ msg . MsgLen + + ] = rtumsg - > MsgData [ 14 ] ; // <20> <> <20> <>
msg . MsgData [ msg . MsgLen + + ] = i + 1 ; // <20> <> Ŀ<EFBFBD> <C4BF>
msg . MsgData [ msg . MsgLen + + ] = KOD_DIMENSION ; // <20> <> <20> <>
msg . MsgData [ msg . MsgLen + + ] = DATAID_OS8ASCII ;
iNameLen = strlen ( pBaoHuDB [ iGroupNo ] . m_psDataInfo [ i ] . m_szName ) ;
msg . MsgData [ msg . MsgLen + + ] = ( BYTE ) iNameLen ;
msg . MsgData [ msg . MsgLen + + ] = 1 ;
memcpy ( & msg . MsgData [ msg . MsgLen ] , pBaoHuDB [ iGroupNo ] . m_psDataInfo [ i ] . m_szName , iNameLen ) ;
msg . MsgLen + = ( WORD ) iNameLen ;
* ptrPntNum + + ;
if ( msg . MsgLen > = 220 )
{
ptrClpdu_varr - > nLEN1 = msg . MsgLen - 4 ;
ptrClpdu_varr - > nLEN2 = msg . MsgLen - 4 ;
msg . MsgLen + + ; // lpc
msg . MsgData [ msg . MsgLen + + ] = 0x16 ;
SingleListAddData ( & pProvDevParam - > m_sBaoHuData , msg . MsgData , msg . MsgLen ) ;
msg . MsgLen = ( WORD ) ifixlen ;
* ptrPntNum = 0 ;
}
}
if ( msg . MsgLen > ifixlen )
{
ptrClpdu_varr - > nLEN1 = msg . MsgLen - 4 ;
ptrClpdu_varr - > nLEN2 = msg . MsgLen - 4 ;
msg . MsgLen + + ; // lpc
msg . MsgData [ msg . MsgLen + + ] = 0x16 ;
SingleListAddData ( & pProvDevParam - > m_sBaoHuData , msg . MsgData , msg . MsgLen ) ;
}
break ;
default :
bRetVal = FALSE ;
break ;
}
return bRetVal ;
}
//***************************************************************************/
//* ת<> <D7AA> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> Ŀ¼ */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
BOOL ProvMakeDirOfItem ( u_32 commid , RTUMSG * rtumsg , PROVDEVDEF * pProvDevParam , GROUPDEF * pBaoHuDB , int iNum )
{
RTUMSG msg ;
CLPDU_VARR * ptrClpdu_varr ;
i_32 iNameLen , iGroupNo , iItemNo ;
float * pfValue , fValue ;
// <20> <> Ŀ<EFBFBD> <C4BF>
iItemNo = rtumsg - > MsgData [ 15 ] ;
for ( iGroupNo = 0 ; iGroupNo < iNum ; iGroupNo + + )
{
if ( pBaoHuDB [ iGroupNo ] . m_iGroupNo = = ( int ) rtumsg - > MsgData [ 14 ] )
{
break ;
}
}
if ( iGroupNo > = iNum )
{
return FALSE ;
}
if ( iItemNo < = 0 )
{
return FALSE ;
}
if ( iItemNo > = pBaoHuDB [ iGroupNo ] . m_iPntNum )
{
return FALSE ;
}
memset ( ( void * ) & msg , 0 , sizeof ( RTUMSG ) ) ;
ptrClpdu_varr = ( CLPDU_VARR * ) msg . MsgData ;
ptrClpdu_varr - > nSTART1 = 0x68 ;
ptrClpdu_varr - > nSTART2 = 0x68 ;
ptrClpdu_varr - > nADDR = rtumsg - > MsgData [ 5 ] ;
msg . MsgLen = sizeof ( CLPDU_VARR ) ;
msg . MsgData [ msg . MsgLen + + ] = M_GD_NTA_3 ;
msg . MsgData [ msg . MsgLen + + ] = 0x81 ;
msg . MsgData [ msg . MsgLen + + ] = M_CAUSE_READWITHVALIDDATA ;
msg . MsgData [ msg . MsgLen + + ] = rtumsg - > MsgData [ 9 ] ;
msg . MsgData [ msg . MsgLen + + ] = FUNC_GENERALSORT ;
msg . MsgData [ msg . MsgLen + + ] = M_INF_READDIROFSINGLEITEM ;
msg . MsgData [ msg . MsgLen + + ] = rtumsg - > MsgData [ 12 ] ; //RII
msg . MsgData [ msg . MsgLen + + ] = rtumsg - > MsgData [ 14 ] ;
msg . MsgData [ msg . MsgLen + + ] = rtumsg - > MsgData [ 15 ] ;
msg . MsgData [ msg . MsgLen + + ] = 4 ;
msg . MsgData [ msg . MsgLen + + ] = KOD_ACTUALVALUE ; // ʵ<> <CAB5> ֵ
msg . MsgData [ msg . MsgLen + + ] = DATAID_FLOAT ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
msg . MsgData [ msg . MsgLen + + ] = sizeof ( float ) ;
msg . MsgData [ msg . MsgLen + + ] = 1 ;
pfValue = ( float * ) ( & msg . MsgData [ msg . MsgLen ] ) ;
fValue = pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo - 1 ] . m_fValue ;
SequenceHostToRtu ( ( char * ) & fValue , sizeof ( float ) ) ;
* pfValue = fValue ;
msg . MsgLen + = sizeof ( float ) ;
msg . MsgData [ msg . MsgLen + + ] = KOD_RANGE ; // <20> <> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> С ֵ<D0A1> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
msg . MsgData [ msg . MsgLen + + ] = DATAID_FLOAT ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
msg . MsgData [ msg . MsgLen + + ] = sizeof ( float ) ;
msg . MsgData [ msg . MsgLen + + ] = 3 ;
pfValue = ( float * ) ( & msg . MsgData [ msg . MsgLen ] ) ;
fValue = pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo - 1 ] . m_fMaxValue ;
SequenceHostToRtu ( ( char * ) & fValue , sizeof ( float ) ) ;
* pfValue = fValue ;
pfValue + + ;
fValue = pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo - 1 ] . m_fMinValue ;
SequenceHostToRtu ( ( char * ) & fValue , sizeof ( float ) ) ;
* pfValue = fValue ;
pfValue + + ;
fValue = pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo - 1 ] . m_fStepValue ;
SequenceHostToRtu ( ( char * ) & fValue , sizeof ( float ) ) ;
* pfValue = fValue ;
msg . MsgLen + = 3 * sizeof ( float ) ;
msg . MsgData [ msg . MsgLen + + ] = KOD_DIMENSION ; // <20> <> <20> <>
msg . MsgData [ msg . MsgLen + + ] = DATAID_OS8ASCII ;
iNameLen = strlen ( pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo ] . m_szUnit ) ;
msg . MsgData [ msg . MsgLen + + ] = ( BYTE ) iNameLen ;
msg . MsgData [ msg . MsgLen + + ] = 1 ;
memcpy ( & msg . MsgData [ msg . MsgLen ] , pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo ] . m_szUnit , iNameLen ) ;
msg . MsgLen + = ( WORD ) iNameLen ;
msg . MsgData [ msg . MsgLen + + ] = KOD_DESCRIPTION ; // <20> <> <20> <>
msg . MsgData [ msg . MsgLen + + ] = DATAID_OS8ASCII ;
iNameLen = strlen ( pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo ] . m_szName ) ;
msg . MsgData [ msg . MsgLen + + ] = ( BYTE ) iNameLen ;
msg . MsgData [ msg . MsgLen + + ] = 1 ;
memcpy ( & msg . MsgData [ msg . MsgLen ] , pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo ] . m_szName , iNameLen ) ;
msg . MsgLen + = ( WORD ) iNameLen ;
ptrClpdu_varr - > nLEN1 = msg . MsgLen - 4 ;
ptrClpdu_varr - > nLEN2 = msg . MsgLen - 4 ;
msg . MsgLen + + ; //lpc
msg . MsgData [ msg . MsgLen + + ] = 0x16 ;
return SingleListAddData ( & pProvDevParam - > m_sBaoHuData , msg . MsgData , msg . MsgLen ) ;
}
//***************************************************************************/
//* ת<> <D7AA> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> : u_32 commid : <20> <> վ<EFBFBD> ˿ں<CBBF> */
//* RTUMSG *rtumsg : <20> <> <EFBFBD> յ<EFBFBD> <D5B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ */
//* i_32 iBuIdx : <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> <D7B0> (<28> <> <EFBFBD> <EFBFBD> )<29> <> <EFBFBD> <EFBFBD> */
//*<2A> <> <EFBFBD> <EFBFBD> ֵ:<3A> <> */
//***************************************************************************/
BOOL ProvMakeAttrOfItem ( u_32 commid , RTUMSG * rtumsg , PROVDEVDEF * pProvDevParam , GROUPDEF * pBaoHuDB , int iNum )
{
RTUMSG msg ;
CLPDU_VARR * ptrClpdu_varr ;
i_32 iNameLen , iGroupNo , iItemNo ;
float * pfValue , fValue ;
// <20> <> Ŀ<EFBFBD> <C4BF>
iItemNo = rtumsg - > MsgData [ 15 ] ;
for ( iGroupNo = 0 ; iGroupNo < iNum ; iGroupNo + + )
{
if ( pBaoHuDB [ iGroupNo ] . m_iGroupNo = = ( int ) rtumsg - > MsgData [ 14 ] )
{
break ;
}
}
if ( iGroupNo > = iNum )
{
return FALSE ;
}
if ( iItemNo < = 0 )
{
return FALSE ;
}
if ( iItemNo > = pBaoHuDB [ iGroupNo ] . m_iPntNum )
{
return FALSE ;
}
memset ( ( void * ) & msg , 0 , sizeof ( RTUMSG ) ) ;
ptrClpdu_varr = ( CLPDU_VARR * ) msg . MsgData ;
ptrClpdu_varr - > nSTART1 = 0x68 ;
ptrClpdu_varr - > nSTART2 = 0x68 ;
ptrClpdu_varr - > nADDR = rtumsg - > MsgData [ 5 ] ;
msg . MsgLen = sizeof ( CLPDU_VARR ) ;
msg . MsgData [ msg . MsgLen + + ] = M_GD_NTA_3 ;
msg . MsgData [ msg . MsgLen + + ] = 0x81 ;
msg . MsgData [ msg . MsgLen + + ] = M_CAUSE_READWITHVALIDDATA ;
msg . MsgData [ msg . MsgLen + + ] = rtumsg - > MsgData [ 9 ] ;
msg . MsgData [ msg . MsgLen + + ] = FUNC_GENERALSORT ;
msg . MsgData [ msg . MsgLen + + ] = M_INF_READDIROFSINGLEITEM ;
msg . MsgData [ msg . MsgLen + + ] = rtumsg - > MsgData [ 12 ] ; //RII
msg . MsgData [ msg . MsgLen + + ] = 1 ;
msg . MsgData [ msg . MsgLen + + ] = rtumsg - > MsgData [ 14 ] ;
msg . MsgData [ msg . MsgLen + + ] = rtumsg - > MsgData [ 15 ] ;
switch ( rtumsg - > MsgData [ 16 ] )
{
case KOD_ACTUALVALUE : // ʵ<> <CAB5> ֵ
msg . MsgData [ msg . MsgLen + + ] = KOD_ACTUALVALUE ; // ʵ<> <CAB5> ֵ
msg . MsgData [ msg . MsgLen + + ] = DATAID_FLOAT ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
msg . MsgData [ msg . MsgLen + + ] = sizeof ( float ) ;
msg . MsgData [ msg . MsgLen + + ] = 1 ;
pfValue = ( float * ) ( & msg . MsgData [ msg . MsgLen ] ) ;
fValue = pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo - 1 ] . m_fValue ;
SequenceHostToRtu ( ( char * ) & fValue , sizeof ( float ) ) ;
* pfValue = fValue ;
msg . MsgLen + = sizeof ( float ) ;
break ;
case KOD_RANGE : // <20> <> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> С ֵ<D0A1> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
msg . MsgData [ msg . MsgLen + + ] = KOD_RANGE ; // <20> <> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> С ֵ<D0A1> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
msg . MsgData [ msg . MsgLen + + ] = DATAID_FLOAT ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
msg . MsgData [ msg . MsgLen + + ] = sizeof ( float ) ;
msg . MsgData [ msg . MsgLen + + ] = 3 ;
pfValue = ( float * ) ( & msg . MsgData [ msg . MsgLen ] ) ;
fValue = pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo - 1 ] . m_fMaxValue ;
SequenceHostToRtu ( ( char * ) & fValue , sizeof ( float ) ) ;
* pfValue = fValue ;
pfValue + + ;
fValue = pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo - 1 ] . m_fMinValue ;
SequenceHostToRtu ( ( char * ) & fValue , sizeof ( float ) ) ;
* pfValue = fValue ;
pfValue + + ;
fValue = pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo - 1 ] . m_fStepValue ;
SequenceHostToRtu ( ( char * ) & fValue , sizeof ( float ) ) ;
* pfValue = fValue ;
msg . MsgLen + = 3 * sizeof ( float ) ;
break ;
case KOD_DIMENSION : // <20> <> <20> <>
msg . MsgData [ msg . MsgLen + + ] = KOD_DIMENSION ; // <20> <> <20> <>
msg . MsgData [ msg . MsgLen + + ] = DATAID_OS8ASCII ;
iNameLen = strlen ( pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo ] . m_szUnit ) ;
msg . MsgData [ msg . MsgLen + + ] = ( BYTE ) iNameLen ;
msg . MsgData [ msg . MsgLen + + ] = 1 ;
memcpy ( & msg . MsgData [ msg . MsgLen ] , pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo ] . m_szUnit , iNameLen ) ;
msg . MsgLen + = ( WORD ) iNameLen ;
break ;
case KOD_DESCRIPTION : // <20> <> <20> <>
msg . MsgData [ msg . MsgLen + + ] = KOD_DIMENSION ; // <20> <> <20> <>
msg . MsgData [ msg . MsgLen + + ] = DATAID_OS8ASCII ;
iNameLen = strlen ( pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo ] . m_szName ) ;
msg . MsgData [ msg . MsgLen + + ] = ( BYTE ) iNameLen ;
msg . MsgData [ msg . MsgLen + + ] = 1 ;
memcpy ( & msg . MsgData [ msg . MsgLen ] , pBaoHuDB [ iGroupNo ] . m_psDataInfo [ iItemNo ] . m_szName , iNameLen ) ;
msg . MsgLen + = ( WORD ) iNameLen ;
break ;
}
ptrClpdu_varr - > nLEN1 = msg . MsgLen - 4 ;
ptrClpdu_varr - > nLEN2 = msg . MsgLen - 4 ;
msg . MsgLen + + ; //lpc
msg . MsgData [ msg . MsgLen + + ] = 0x16 ;
return SingleListAddData ( & pProvDevParam - > m_sBaoHuData , msg . MsgData , msg . MsgLen ) ;
}
BOOL ProvSendChangedDi ( u_32 commid , DEVADDRPARAM * psDevAddrParam )
{
int i , j , iStart , len ;
WORD wValue ;
BOOL bQueryAllDev , bFind ;
DAY_TIME sCurTime ;
RTUMSG rtumsg ;
DI_DEF pntmsg ;
PROV_DI_PNT * diprovptr = NULL ;
CLPDU_VARR * ptrClpdu_varr = NULL ;
PROVDEVDEF * pProvDevParam = NULL ;
BUBAN103LINKDEF * pLinkParam = NULL ;
BUBAN103PORTPARAM * pPortParam = NULL ;
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
pLinkParam = & pPortParam - > m_psLink [ psDevAddrParam - > m_iLinkIdx ] ;
diprovptr = ( PROV_DI_PNT * ) pPortParam - > m_psBaoHu - > DiPtr ;
bFind = FALSE ;
if ( pLinkParam - > m_uchLinkAddr ! = 0xFF )
{
bQueryAllDev = TRUE ;
}
else
{
bQueryAllDev = FALSE ;
}
for ( i = 0 ; i < pLinkParam - > m_iDevNum ; i + + )
{
if ( bQueryAllDev = = TRUE )
{
psDevAddrParam - > m_iDevIdx = i ;
}
else
{
if ( i > = 1 )
{
break ;
}
}
pProvDevParam = & pLinkParam - > m_psProvDev [ psDevAddrParam - > m_iDevIdx ] ;
iStart = pProvDevParam - > m_sYxInfo . m_iStartPntNo ;
for ( j = 0 ; j < pProvDevParam - > m_sYxInfo . m_iPntNum ; j + + )
{
if ( TRUE = = diprovptr [ iStart + j ] . ChangeFlag )
{
bFind = TRUE ;
diprovptr [ iStart + j ] . ChangeFlag = FALSE ;
GetPntMsg ( diprovptr [ iStart + j ] . PortNo , diprovptr [ iStart + j ] . PntNo ,
( void * ) & pntmsg , DI_PNT_TYPE , PNT_STATUS ) ;
break ;
}
}
if ( TRUE = = bFind )
{
break ;
}
}
if ( bFind = = TRUE )
{
GetLocalTimeEx ( & sCurTime ) ;
ptrClpdu_varr = ( CLPDU_VARR * ) rtumsg . MsgData ;
ptrClpdu_varr - > nSTART1 = 0x68 ;
ptrClpdu_varr - > nSTART2 = 0x68 ;
// <20> <> <EFBFBD> ¸ <EFBFBD> ֵ<EFBFBD> <D6B5> ·<EFBFBD> <C2B7> ת<EFBFBD> <D7AA> <EFBFBD> <EFBFBD> ַ
ptrClpdu_varr - > nADDR = psDevAddrParam - > m_uchLinkAddr ;
ptrClpdu_varr - > nCONTROL & = 0xDF ;
// wen 2005.06.10 ң<> ű<EFBFBD> λֻ<CEBB> <D6BB> ȷ<EFBFBD> <C8B7> <EFBFBD> <EFBFBD>
//wValue = sCurTime.Sec*1000 + sCurTime.mSec;
wValue = sCurTime . Sec * 1000 ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) ] = 0x01 ;
// <20> ĸ<EFBFBD> <C4B8> <EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 7 ] = LOBYTE ( wValue ) ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 8 ] = HIBYTE ( wValue ) ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 9 ] = sCurTime . Min & 0x3F ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 10 ] = sCurTime . Hour & 0x1F ;
// SIN
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 11 ] = 0 ;
len = 14 ;
ptrClpdu_varr - > nLEN1 = len ;
ptrClpdu_varr - > nLEN2 = len ;
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 1 ] = 0x81 ;
//COT
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 2 ] = M_CAUSE_AUTOSEND ;
// <20> <> <EFBFBD> ¸ <EFBFBD> ֵ ASDU <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 3 ] = ( BYTE ) pProvDevParam - > m_iProvAddr ;
// FUN
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 4 ] = pProvDevParam - > m_sYxInfo . m_psDataInfo [ j ] . m_u8ProvFun ;
// INF
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 5 ] = pProvDevParam - > m_sYxInfo . m_psDataInfo [ j ] . m_u8ProvInf ;
// DPI
rtumsg . MsgData [ sizeof ( CLPDU_VARR ) + 6 ] = pntmsg . Status + 1 ;
len = ptrClpdu_varr - > nLEN1 + 4 ;
// <20> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> ¼<EFBFBD> <C2BC> <EFBFBD>
//rtumsg.MsgData[len++] = CalBuban103Lpc(rtumsg.MsgData+4, ptrClpdu_varr->nLEN1);
rtumsg . MsgData [ len + + ] = 0 ;
rtumsg . MsgData [ len + + ] = 0x16 ;
PutPollCmdToBuf ( commid , FAST_POLL_CMD , 0 , ( char * ) rtumsg . MsgData , len ) ;
}
else
{
pPortParam - > m_psBaoHu - > DiChange = FALSE ;
}
return bFind ;
}
i_32 PackOneValueIntoPackage ( BYTE * pbDestBuf , u_32 uMaxBufLen , BYTE bDataFormat ,
u_32 uDataType , u_32 uDataLen , BYTE * pbSourData )
{
i_32 iCount , k ;
float * ptrfValue , fValue ;
double * ptrdbValue ;
short * ptri16Value ;
i_32 * ptriValue ;
iCount = 0 ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
switch ( bDataFormat )
{
case 0 : // ģ<> <C4A3> <EFBFBD> <EFBFBD>
// pbSourData[0] // <20> <> <EFBFBD> <EFBFBD> Դ<EFBFBD> <D4B4> <EFBFBD> <EFBFBD>
fValue = * ( float * ) ( pbSourData + 1 ) ;
// <20> <> <EFBFBD> ݳ<EFBFBD> <DDB3> <EFBFBD>
pbDestBuf [ iCount + + ] = ( BYTE ) uDataLen ;
pbDestBuf [ iCount + + ] = 1 ;
// <20> <> <EFBFBD> ݳ<EFBFBD> <DDB3> <EFBFBD> (103<30> <33> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
//rtumsg->MsgData[uOffset++];
//ptrfValueSour = (float *)&rtumsg->MsgData[uOffset];
if ( uDataType = = DATAID_UI ) // <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
if ( uDataLen = = 1 )
{
pbDestBuf [ iCount ] = ( BYTE ) ( ( u_32 ) fabs ( fValue ) ) ;
}
else if ( uDataLen = = 2 )
{
ptri16Value = ( short * ) & pbDestBuf [ iCount ] ;
* ptri16Value = ( short ) fabs ( fValue ) ;
SequenceHostToRtu ( ( char * ) ptri16Value , sizeof ( short ) ) ;
}
else if ( uDataLen = = 4 )
{
ptriValue = ( i_32 * ) & pbDestBuf [ iCount ] ;
* ptriValue = ( i_32 ) fabs ( fValue ) ;
SequenceHostToRtu ( ( char * ) ptriValue , sizeof ( i_32 ) ) ;
}
}
// wen 2005.04.05 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ķ<EFBFBD> <C4B7> <EFBFBD> չ<EFBFBD> <D5B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//else if(uDataType == DATAID_INT)
else if ( ( DATAID_INT = = uDataType ) | | ( DATAID_EXDATA_0X24 = = uDataType ) )
{
if ( uDataLen = = 1 )
{
pbDestBuf [ iCount ] = ( BYTE ) ( ( i_32 ) fabs ( fValue ) ) ;
}
else if ( uDataLen = = 2 )
{
ptri16Value = ( short * ) & pbDestBuf [ iCount ] ;
* ptri16Value = ( short ) fabs ( fValue ) ;
SequenceHostToRtu ( ( char * ) ptri16Value , sizeof ( short ) ) ;
}
else if ( uDataLen = = 4 )
{
ptriValue = ( i_32 * ) & pbDestBuf [ iCount ] ;
* ptriValue = ( i_32 ) fabs ( fValue ) ;
SequenceHostToRtu ( ( char * ) ptriValue , sizeof ( i_32 ) ) ;
}
}
else if ( uDataType = = DATAID_UFLOAT ) // <20> <EFBFBD> <DEB7> Ÿ<EFBFBD> <C5B8> <EFBFBD> <EFBFBD> <EFBFBD>
{
ptrfValue = ( float * ) & pbDestBuf [ iCount ] ;
* ptrfValue = ( float ) fabs ( fValue ) ;
SequenceHostToRtu ( ( char * ) ptrfValue , sizeof ( float ) ) ;
}
else if ( uDataType = = DATAID_FLOAT ) // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
ptrfValue = ( float * ) & pbDestBuf [ iCount ] ;
* ptrfValue = fValue ;
SequenceHostToRtu ( ( char * ) ptrfValue , sizeof ( float ) ) ;
}
else if ( uDataType = = DATAID_754SHORT ) // R32.23 IEEE <20> <> 754<35> <34> ʵ<EFBFBD> <CAB5>
{
ptrfValue = ( float * ) & pbDestBuf [ iCount ] ;
* ptrfValue = fValue ;
SequenceHostToRtu ( ( char * ) ptrfValue , sizeof ( float ) ) ;
}
else if ( uDataType = = DATAID_754REAL ) // R64.53 IEEE <20> <> 754ʵ<34> <CAB5>
{
ptrdbValue = ( double * ) & pbDestBuf [ iCount ] ;
* ptrdbValue = fValue ;
SequenceHostToRtu ( ( char * ) ptrdbValue , sizeof ( double ) ) ;
}
else if ( uDataType = = DATAID_13BITS ) // <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ(13BITS)
{
ptri16Value = ( short * ) & pbDestBuf [ iCount ] ;
* ptri16Value = ( ( short ) ( fValue ) ) & 0x1fff ;
SequenceHostToRtu ( ( char * ) ptri16Value , sizeof ( short ) ) ;
}
// wen 2004.07.26 <20> ĸ<DEB8> <C4B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵĴ<DDB5> <C4B4> <EFBFBD>
else if ( uDataType = = DATAID_BSTRING ) // 8λ2<CEBB> <32> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
uDataLen = ( uDataLen + 7 ) / 8 ;
for ( k = 0 ; k < ( int ) uDataLen ; k + + ) ;
{
pbDestBuf [ iCount + k ] = ( BYTE ) ( ( ( int ) ( fValue ) ) / 256 ) ;
fValue / = 256 ;
}
}
iCount + = uDataLen ;
break ;
case 1 : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// pbSourData[0] // <20> <> <EFBFBD> <EFBFBD> Դ<EFBFBD> <D4B4> <EFBFBD> <EFBFBD>
fValue = * ( float * ) ( pbSourData + 1 ) ;
// <20> <> <EFBFBD> ݳ<EFBFBD> <DDB3> <EFBFBD>
pbDestBuf [ iCount + + ] = ( BYTE ) uDataLen ;
pbDestBuf [ iCount + + ] = 1 ;
if ( uDataType = = DATAID_UI ) // <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
if ( uDataLen = = 1 )
{
pbDestBuf [ iCount ] = ( BYTE ) ( ( u_32 ) fabs ( fValue ) ) ;
}
else if ( uDataLen = = 2 )
{
ptri16Value = ( short * ) & pbDestBuf [ iCount ] ;
* ptri16Value = ( short ) fabs ( fValue ) ;
SequenceHostToRtu ( ( char * ) ptri16Value , sizeof ( short ) ) ;
}
else if ( uDataLen = = 4 )
{
ptriValue = ( i_32 * ) & pbDestBuf [ iCount ] ;
* ptriValue = ( i_32 ) fabs ( fValue ) ;
SequenceHostToRtu ( ( char * ) ptriValue , sizeof ( i_32 ) ) ;
}
}
else if ( uDataType = = DATAID_INT )
{
if ( uDataLen = = 1 )
{
pbDestBuf [ iCount ] = ( BYTE ) ( ( i_32 ) fabs ( fValue ) ) ;
}
else if ( uDataLen = = 2 )
{
ptri16Value = ( short * ) & pbDestBuf [ iCount ] ;
* ptri16Value = ( short ) fabs ( fValue ) ;
SequenceHostToRtu ( ( char * ) ptri16Value , sizeof ( short ) ) ;
}
else if ( uDataLen = = 4 )
{
ptriValue = ( i_32 * ) & pbDestBuf [ iCount ] ;
* ptriValue = ( i_32 ) fabs ( fValue ) ;
SequenceHostToRtu ( ( char * ) ptriValue , sizeof ( i_32 ) ) ;
}
}
else if ( uDataType = = DATAID_UFLOAT ) // <20> <EFBFBD> <DEB7> Ÿ<EFBFBD> <C5B8> <EFBFBD> <EFBFBD> <EFBFBD>
{
ptrfValue = ( float * ) & pbDestBuf [ iCount ] ;
* ptrfValue = ( float ) fabs ( fValue ) ;
SequenceHostToRtu ( ( char * ) ptrfValue , sizeof ( float ) ) ;
}
else if ( uDataType = = DATAID_FLOAT ) // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
ptrfValue = ( float * ) & pbDestBuf [ iCount ] ;
* ptrfValue = fValue ;
SequenceHostToRtu ( ( char * ) ptrfValue , sizeof ( float ) ) ;
}
else if ( uDataType = = DATAID_754SHORT ) // R32.23 IEEE <20> <> 754<35> <34> ʵ<EFBFBD> <CAB5>
{
ptrfValue = ( float * ) & pbDestBuf [ iCount ] ;
* ptrfValue = fValue ;
SequenceHostToRtu ( ( char * ) ptrfValue , sizeof ( float ) ) ;
}
else if ( uDataType = = DATAID_754REAL ) // R64.53 IEEE <20> <> 754ʵ<34> <CAB5>
{
ptrdbValue = ( double * ) & pbDestBuf [ iCount ] ;
* ptrdbValue = fValue ;
SequenceHostToRtu ( ( char * ) ptrdbValue , sizeof ( double ) ) ;
}
else if ( uDataType = = DATAID_13BITS ) // <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ(13BITS)
{
ptri16Value = ( short * ) & pbDestBuf [ iCount ] ;
* ptri16Value = ( ( short ) ( fValue ) ) & 0x1fff ;
SequenceHostToRtu ( ( char * ) ptri16Value , sizeof ( short ) ) ;
}
// wen 2004.07.26 <20> ĸ<DEB8> <C4B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵĴ<DDB5> <C4B4> <EFBFBD>
else if ( uDataType = = DATAID_BSTRING ) // 8λ2<CEBB> <32> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
uDataLen = ( uDataLen + 7 ) / 8 ;
for ( k = 0 ; k < ( int ) uDataLen ; k + + ) ;
{
pbDestBuf [ iCount + k ] = ( BYTE ) ( ( ( int ) ( fValue ) ) / 256 ) ;
fValue / = 256 ;
}
}
else if ( uDataType = = DATAID_DOUBLE ) // ˫<> <CBAB> <EFBFBD> <EFBFBD> Ϣ
{
pbDestBuf [ iCount ] = ( BYTE ) ( ( u_32 ) ( fabs ( fValue ) + 1 ) ) ;
}
else if ( uDataType = = DATAID_SINGLE ) // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
{
pbDestBuf [ iCount ] = ( BYTE ) ( ( u_32 ) fabs ( fValue ) ) ;
}
iCount + = uDataLen ;
break ;
case 3 : // <20> ַ<EFBFBD> <D6B7> <EFBFBD>
pbDestBuf [ iCount + + ] = pbSourData [ 0 ] ;
pbDestBuf [ iCount + + ] = 1 ;
if ( uDataType = = DATAID_OS8ASCII ) // 8λASCII
{
memcpy ( ( void * ) ( pbDestBuf + iCount ) , ( void * ) ( pbSourData + 1 ) , pbSourData [ 0 ] ) ;
iCount + = pbSourData [ 0 ] ;
}
break ;
}
return iCount ;
}
// <20> <> <EFBFBD> <EFBFBD> 103<30> <33> ˹<EFBFBD> <CBB9> <EFBFBD> <EFBFBD> <EFBFBD> ڲ<EFBFBD> <DAB2> <EFBFBD> Լ<EFBFBD> <D4BC> <EFBFBD> ĸ<EFBFBD> ʽ ת<CABD> <D7AA>
void Buban103ScadaCmdchange ( int commid , RTUMSG * rtumsg )
{
u_32 uInterAction , uOffset , uDataLen , uDataType ;
u_char bFaultNo ;
i_32 i , j , k , iGroupNo , iStartNo , iCPUNo , offset ;
BOOL bIsValidCmd ;
GEN_DATAGROUP sGenDataGroup ;
PROTECTCONTENTHEAD * ptrProHead ;
BYTE bSourData [ 4096 ] ;
i_32 iFixDataNGD ;
CMDPARAM sCmdParam ;
PROTECTMSG PrtMsg ;
int iProvAddr , iYkNo ;
DEVDEF * pDevParam ;
DEVADDRPARAM sAddrParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
char szbuf [ 256 ] ;
memcpy ( ( void * ) & PrtMsg , rtumsg - > MsgData , rtumsg - > MsgLen ) ;
ptrProHead = ( PROTECTCONTENTHEAD * ) PrtMsg . MsgData ;
if ( FALSE = = GetPortParamPtr ( commid , & pPortParam ) )
{
return ;
}
iProvAddr = ptrProHead - > uAddr ;
sprintf ( szbuf , " <EFBFBD> <EFBFBD> ַ=%d " , ptrProHead - > uAddr ) ;
DebugPrint ( szbuf ) ;
if ( FALSE = = FindProtectDevFromProvAddr ( pPortParam , & sAddrParam , iProvAddr ) )
{
sprintf ( szbuf , " <EFBFBD> <EFBFBD> ַ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
DebugPrint ( szbuf ) ;
return ;
}
// wen 2005.06.06 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݷ<EFBFBD> <DDB7> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ĵ洢
pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_sBaoHuCmdParam . m_iBaoHuCommid = rtumsg - > PortIdx ;
memcpy ( ( void * ) & pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_sBaoHuCmdParam . m_sRealAddrParam ,
( void * ) & sAddrParam , sizeof ( DEVADDRPARAM ) ) ;
GetLocalTimeEx ( & pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_sBaoHuCmdParam . m_sBaoHuCmdStartTime ) ;
pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] . m_sBaoHuCmdParam . m_iBaoHuMsgType = MSGTYPE_BAOHU_SCADACMD ;
bIsValidCmd = TRUE ;
uOffset = sizeof ( PROTECTCONTENTHEAD ) ;
pLinkParam = & pPortParam - > m_psLink [ sAddrParam . m_iLinkIdx ] ;
pDevParam = & pLinkParam - > m_psDev [ sAddrParam . m_iDevIdx ] ;
// CPU<50> <55> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ һ <D2BB> <D2BB> Ӧ
if ( ( ptrProHead - > cCPUNo ! = ( char ) 0xFF ) & & ( ptrProHead - > cCPUNo ! = 0 ) )
{
pDevParam - > m_sDevParam . m_u8CPUNo = ptrProHead - > cCPUNo ;
}
if ( ( ptrProHead - > cFixNo ! = ( char ) 0xFF ) & & ( ptrProHead - > cFixNo ! = 0 ) )
{
pDevParam - > m_sDevParam . m_u8FixNo = ptrProHead - > cFixNo ;
}
iCPUNo = 1 ;
// <20> <> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ptrProHead - > uAddr ! = 0xff )
{
pDevParam - > m_sDevParam . m_u32FuncCode = ptrProHead - > uFuncCode ;
}
memcpy ( ( void * ) & sCmdParam . m_sDevAddr , ( void * ) & sAddrParam , sizeof ( DEVADDRPARAM ) ) ;
switch ( ptrProHead - > uFuncCode )
{
case hREADFIX : // <20> <> ȡ<EFBFBD> <C8A1> ֵ(ֻ<> <D6BB> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
uInterAction = hREADINGDATA ;
for ( i = 0 ; i < pDevParam - > m_sDevParam . m_iCfgGroupNum ; i + + )
{
if ( PROTECT_FIX_PNT_TYPE = = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iDataType )
{
sprintf ( szbuf , " <EFBFBD> <EFBFBD> %d<> <64> CPU<50> <55> = %d!!!\n " , i + 1 ,
pDevParam - > m_sDevParam . m_u8CPUNo ) ;
DebugPrint ( szbuf ) ;
if ( pDevParam - > m_sDevParam . m_u8CPUNo = = iCPUNo )
{
break ;
}
else
{
iCPUNo + + ;
}
}
}
if ( i = = pDevParam - > m_sDevParam . m_iCfgGroupNum )
{
bIsValidCmd = FALSE ;
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d<> <64> <EFBFBD> <EFBFBD> <EFBFBD> ڱ<EFBFBD> <DAB1> <EFBFBD> <EFBFBD> <EFBFBD> ֵ!!!\n " ,
commid , sAddrParam . m_uchLinkAddr , sAddrParam . m_uchCommAddr ) ;
DebugPrint ( szbuf ) ;
break ;
}
pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_u32CurPntNo = 1 ;
sCmdParam . m_uchInf = C_INF_READGROUPALLITEMS ;
sGenDataGroup . m_u8Grp = ( BYTE ) pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iGroupNo ;
sGenDataGroup . m_u8Itm = 0 ;
sGenDataGroup . m_u8KOD = PrtMsg . MsgData [ uOffset ] ;
sCmdParam . m_uchRII = RII_PROV_ID ;
MakeGenIdentCommand_CAsdu21 ( commid , & sCmdParam , & sGenDataGroup , 1 ) ;
break ;
case hREADFIXNO : // <20> <> ȡ<EFBFBD> <C8A1> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD>
uInterAction = hREADINGDATA ;
bIsValidCmd = FALSE ;
break ;
case hREADPAI : // <20> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> ģ<EFBFBD> <C4A3> <EFBFBD> <EFBFBD>
uInterAction = hREADINGDATA ;
for ( i = 0 ; i < pDevParam - > m_sDevParam . m_iCfgGroupNum ; i + + )
{
if ( PROTECT_AI_PNT_TYPE = = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iDataType )
{
break ;
}
}
if ( i = = pDevParam - > m_sDevParam . m_iCfgGroupNum )
{
bIsValidCmd = FALSE ;
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d<> <64> <EFBFBD> <EFBFBD> <EFBFBD> ڱ<EFBFBD> <DAB1> <EFBFBD> ģ<EFBFBD> <C4A3> <EFBFBD> <EFBFBD> !!!\n " ,
commid , sAddrParam . m_uchLinkAddr , sAddrParam . m_uchCommAddr ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_u32CurPntNo = 1 ;
sCmdParam . m_uchInf = C_INF_READGROUPALLITEMS ;
sGenDataGroup . m_u8Grp = ( BYTE ) pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iGroupNo ;
sGenDataGroup . m_u8Itm = 0 ;
sGenDataGroup . m_u8KOD = PrtMsg . MsgData [ uOffset ] ;
sCmdParam . m_uchRII = RII_PROV_ID ;
MakeGenIdentCommand_CAsdu21 ( commid , & sCmdParam , & sGenDataGroup , 1 ) ;
break ;
case hREADPDI : // <20> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
uInterAction = hREADINGDATA ;
for ( i = 0 ; i < pDevParam - > m_sDevParam . m_iCfgGroupNum ; i + + )
{
if ( PROTECT_DI_PNT_TYPE = = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iDataType )
{
break ;
}
}
if ( i = = pDevParam - > m_sDevParam . m_iCfgGroupNum )
{
bIsValidCmd = FALSE ;
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d<> <64> <EFBFBD> <EFBFBD> <EFBFBD> ڱ<EFBFBD> <DAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> !!!\n " ,
commid , sAddrParam . m_uchLinkAddr , sAddrParam . m_uchCommAddr ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_u32CurPntNo = 1 ;
sCmdParam . m_uchInf = C_INF_READGROUPALLITEMS ;
sGenDataGroup . m_u8Grp = ( BYTE ) pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iGroupNo ;
sGenDataGroup . m_u8Itm = 0 ;
sGenDataGroup . m_u8KOD = PrtMsg . MsgData [ uOffset ] ;
sCmdParam . m_uchRII = RII_PROV_ID ;
MakeGenIdentCommand_CAsdu21 ( commid , & sCmdParam , & sGenDataGroup , 1 ) ;
break ;
case hREADPWAVE : // <20> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
case hQUERYFAULT : // <20> <> ȡָ<C8A1> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> ϱ <EFBFBD> <CFB1> <EFBFBD>
bFaultNo = rtumsg - > MsgData [ sizeof ( PROTECTCONTENTHEAD ) ] ;
uInterAction = hREADINGDATA ;
bIsValidCmd = FALSE ;
break ;
case hQUERYSELFCHECK : // <20> <> ȡָ<C8A1> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> Լ챨<D4BC> <ECB1A8>
bFaultNo = rtumsg - > MsgData [ sizeof ( PROTECTCONTENTHEAD ) ] ;
uInterAction = hREADINGDATA ;
bIsValidCmd = FALSE ;
break ;
case hWRITEALLFIX : // <20> ı <DEB8> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD> ֵ
uInterAction = hREADINGDATA ;
//uOffset += 12;
pDevParam - > m_u32CallCnt = pLinkParam - > m_u32TimeOutConst ;
for ( i = 0 ; i < pDevParam - > m_sDevParam . m_iCfgGroupNum ; i + + )
{
if ( PROTECT_FIX_PNT_TYPE = = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iDataType )
{
if ( pDevParam - > m_sDevParam . m_u8CPUNo = = iCPUNo )
{
break ;
}
else
{
iCPUNo + + ;
}
}
}
if ( i = = pDevParam - > m_sDevParam . m_iCfgGroupNum )
{
bIsValidCmd = FALSE ;
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d<> <64> <EFBFBD> <EFBFBD> <EFBFBD> ڱ<EFBFBD> <DAB1> <EFBFBD> <EFBFBD> <EFBFBD> ֵ!!!\n " ,
commid , sAddrParam . m_uchLinkAddr , sAddrParam . m_uchCommAddr ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
iGroupNo = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iGroupNo ;
iStartNo = * ( ( int * ) & PrtMsg . MsgData [ uOffset ] ) ;
sprintf ( szbuf , " <EFBFBD> Ķ<EFBFBD> ֵ<EFBFBD> <EFBFBD> ֡<EFBFBD> <EFBFBD> ʼ <20> <> <EFBFBD> <EFBFBD> =%d, <20> <> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD> =%d, uoffset=%d <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> :\n " , iGroupNo , iStartNo , uOffset ) ;
DebugPrint ( szbuf ) ;
for ( k = 0 ; k < rtumsg - > MsgLen ; k + = 6 )
{
sprintf ( szbuf , " %2X %2X %2X %2X %2X %2X " , rtumsg - > MsgData [ k ] , rtumsg - > MsgData [ k + 1 ] , rtumsg - > MsgData [ k + 2 ] , rtumsg - > MsgData [ k + 3 ] , rtumsg - > MsgData [ k + 4 ] , rtumsg - > MsgData [ k + 5 ] ) ;
DebugPrint ( szbuf ) ;
}
// wen 2004.02.02 <20> <> ǰ<EFBFBD> <C7B0> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD>
pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_u32CurPntNo = 1 ;
if ( pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_bInit = = FALSE )
{
bIsValidCmd = FALSE ;
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d <20> <> <EFBFBD> <EFBFBD> %d δ<> ȶ<EFBFBD> ȡ<EFBFBD> <C8A1> ֵ!!!\n " ,
commid , sAddrParam . m_uchLinkAddr , sAddrParam . m_uchCommAddr , iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
uOffset + = 4 ;
offset = 0 ;
for ( j = 0 , iFixDataNGD = 0 ; ( uOffset < rtumsg - > MsgLen ) & & ( j < pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iPntNum ) ; j + + , iFixDataNGD + + )
{
// wen 2004.02.02 <20> <> <EFBFBD> <EFBFBD> һ ֡<D2BB> <D6A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȫ<EFBFBD> <C8AB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֳɶ<D6B3> ֡<EFBFBD> <D6A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( offset > = 200 )
{
sCmdParam . m_uchInf = C_INF_WRITEITEMWITHACK ;
sCmdParam . m_uchRII = RII_PROV_ID ;
MakeGenIdentData_CAsdu10 ( commid , & sCmdParam , bSourData , ( BYTE ) iFixDataNGD ) ;
offset = 0 ;
iFixDataNGD = 0 ;
}
// wen 2004.01.07 ÿһ <C3BF> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> ݶ<EFBFBD> <DDB6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
bSourData [ offset + + ] = ( BYTE ) iGroupNo ;
// wen 2004.02.02 <20> ô洢<C3B4> <E6B4A2> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF>
//bSourData[offset++] = (BYTE)(iStartNo-1+j);
bSourData [ offset + + ] = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_pu8GIN [ iStartNo - 1 + j ] ;
bSourData [ offset + + ] = 1 ;
uDataType = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_pu8DataType [ iStartNo - 1 + j ] ;
uDataLen = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_pu8DataLen [ iStartNo - 1 + j ] ;
bSourData [ offset + + ] = ( BYTE ) uDataType ;
// <20> <> <EFBFBD> ܴ<EFBFBD> <DCB4> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD>
offset + = PackOneValueIntoPackage ( bSourData + offset , sizeof ( bSourData ) - offset ,
PrtMsg . MsgData [ uOffset ] , uDataType , uDataLen , & PrtMsg . MsgData [ uOffset + 1 ] ) ;
sprintf ( szbuf , " <EFBFBD> <EFBFBD> %d<> 㶨ֵ<E3B6A8> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> =%d,<2C> <> Ŀ<EFBFBD> <C4BF> =%d,<2C> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> =%d,<2C> <> <EFBFBD> ݿ<EFBFBD> <DDBF> <EFBFBD> =%d,ֵ=%d; %02X %02X %02X %02X" , iStartNo - 1 + j , \
iGroupNo , pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_pu8GIN [ iStartNo - 1 + j ] , \
uDataType , uDataLen , * ( float * ) ( & PrtMsg . MsgData [ uOffset + 1 + 1 ] ) , PrtMsg . MsgData [ uOffset + 2 ] , PrtMsg . MsgData [ uOffset + 3 ] , PrtMsg . MsgData [ uOffset + 4 ] , PrtMsg . MsgData [ uOffset + 5 ] ) ;
DebugPrint ( szbuf ) ;
uOffset + = sizeof ( float ) + 2 ;
}
if ( iFixDataNGD > 0 )
{
sCmdParam . m_uchInf = C_INF_WRITEITEMWITHACK ;
sCmdParam . m_uchRII = RII_PROV_ID ;
MakeGenIdentData_CAsdu10 ( commid , & sCmdParam , bSourData , ( BYTE ) iFixDataNGD ) ;
}
break ;
case hWRITEFIXNO : // <20> ı <DEB8> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5>
uInterAction = hREADINGDATA ;
pDevParam - > m_u32CallCnt = pLinkParam - > m_u32TimeOutConst ;
bIsValidCmd = FALSE ;
break ;
case hRESETPROTECT : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> źŸ<C5BA> <C5B8> <EFBFBD>
//Param.bCmdIdx = APPLY_REVERT;
uInterAction = hREADDATAEND ;
if ( pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iPntNum < = 0 )
{
bIsValidCmd = FALSE ;
break ;
}
else
{
bIsValidCmd = TRUE ;
}
iYkNo = pDevParam - > m_sDevParam . m_sYkDBOrientation . m_iStartPntNo ;
bSourData [ 0 ] = ( BYTE ) ( commid & 0xFF ) ;
bSourData [ 1 ] = ( BYTE ) ( ( commid & 0xFF00 ) < < 8 ) ;
bSourData [ 2 ] = ( BYTE ) ( ( commid & 0xFF0000 ) < < 16 ) ;
bSourData [ 3 ] = ( BYTE ) ( ( commid & 0xFF000000 ) < < 24 ) ;
bSourData [ 4 ] = ( BYTE ) ( iYkNo & 0xFF ) ;
bSourData [ 5 ] = ( BYTE ) ( ( iYkNo & 0xFF00 ) < < 8 ) ;
bSourData [ 6 ] = ( BYTE ) ( ( iYkNo & 0xFF0000 ) < < 16 ) ;
bSourData [ 7 ] = ( BYTE ) ( ( iYkNo & 0xFF000000 ) < < 24 ) ;
bSourData [ 8 ] = STEP_YKYT_EXEC ;
bSourData [ 9 ] = 1 ;
Buban103YkYtProcess ( commid , bSourData , 10 ) ;
break ;
case hCHECKTIME : // <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> ö<EFBFBD> ʱ
//Param.bCmdIdx = CHECK_TIME;
uInterAction = hREADINGDATA ;
MakeTimeSyn_CAsdu6 ( commid , & sCmdParam ) ;
break ;
case hBROADCASTCHECKTIME : // <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> ù㲥<C3B9> <E3B2A5> ʱ
uInterAction = hREADDATAEND ;
sCmdParam . m_sDevAddr . m_uchLinkAddr = 0xFF ;
MakeTimeSyn_CAsdu6 ( commid , & sCmdParam ) ;
break ;
case hWRITEFIXACK : // <20> ı <DEB8> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD> ֵȷ<D6B5> <C8B7>
sCmdParam . m_uchInf = C_INF_WRITEITEMWITHEXEC ;
sCmdParam . m_uchRII = RII_PROV_ID ;
MakeGenIdentData_CAsdu10 ( commid , & sCmdParam , NULL , 0 ) ;
uInterAction = hREADDATAEND ;
break ;
case hWRITEFIXNAK : // <20> ı <DEB8> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> ȷ<EFBFBD> <C8B7>
sCmdParam . m_uchInf = C_INF_STOPWRITEITEM ;
sCmdParam . m_uchRII = RII_PROV_ID ;
MakeGenIdentData_CAsdu10 ( commid , & sCmdParam , NULL , 0 ) ;
uInterAction = hREADDATAEND ;
break ;
// wen 2004.09.29
case hWRITESPECIALFIX : // <20> <EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD> ֵ
uInterAction = hREADINGDATA ;
pDevParam - > m_u32CallCnt = pLinkParam - > m_u32TimeOutConst ;
for ( i = 0 ; i < pDevParam - > m_sDevParam . m_iCfgGroupNum ; i + + )
{
if ( PROTECT_FIX_PNT_TYPE = = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iDataType )
{
if ( pDevParam - > m_sDevParam . m_u8CPUNo = = iCPUNo )
{
break ;
}
else
{
iCPUNo + + ;
}
}
}
if ( i = = pDevParam - > m_sDevParam . m_iCfgGroupNum )
{
bIsValidCmd = FALSE ;
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d<> <64> <EFBFBD> <EFBFBD> <EFBFBD> ڱ<EFBFBD> <DAB1> <EFBFBD> <EFBFBD> <EFBFBD> ֵ!!!\n " ,
commid , sAddrParam . m_uchLinkAddr , sAddrParam . m_uchCommAddr ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
iGroupNo = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iGroupNo ;
iStartNo = * ( ( int * ) & PrtMsg . MsgData [ uOffset ] ) ;
pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_u32CurPntNo = iStartNo ;
if ( pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_bInit = = FALSE )
{
bIsValidCmd = FALSE ;
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d <20> <> <EFBFBD> <EFBFBD> %d δ<> ȶ<EFBFBD> ȡ<EFBFBD> <C8A1> ֵ!!!\n " ,
commid , sAddrParam . m_uchLinkAddr , sAddrParam . m_uchCommAddr , iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
uOffset + = 4 ;
offset = 0 ;
// wen 2004.01.07 ÿһ <C3BF> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> ݶ<EFBFBD> <DDB6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
bSourData [ offset + + ] = ( BYTE ) iGroupNo ;
// wen 2004.02.02 <20> ô洢<C3B4> <E6B4A2> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF>
bSourData [ offset + + ] = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_pu8GIN [ iStartNo - 1 ] ;
bSourData [ offset + + ] = 1 ;
uDataType = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_pu8DataType [ iStartNo - 1 ] ;
uDataLen = pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_pu8DataLen [ iStartNo - 1 ] ;
bSourData [ offset + + ] = ( BYTE ) uDataType ;
// <20> <> <EFBFBD> ܴ<EFBFBD> <DCB4> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD>
offset + = PackOneValueIntoPackage ( bSourData + offset , sizeof ( bSourData ) - offset ,
PrtMsg . MsgData [ uOffset ] , uDataType , uDataLen , & PrtMsg . MsgData [ uOffset + 1 ] ) ;
uOffset + = sizeof ( float ) + 2 ;
sCmdParam . m_uchInf = C_INF_WRITEITEMWITHACK ;
sCmdParam . m_uchRII = RII_PROV_ID ;
MakeGenIdentData_CAsdu10 ( commid , & sCmdParam , bSourData , 1 ) ;
break ;
default :
bIsValidCmd = FALSE ;
break ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> Ϸ<EFBFBD> <CFB7> <EFBFBD> <EFBFBD> <EFBFBD> ָ<EFBFBD> <EFBFBD> Ϸ<EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> ߲<EFBFBD> ѯָ<D1AF> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> , ֱ<> <D6B1> <EFBFBD> ˳<EFBFBD>
if ( ! bIsValidCmd )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%dָ<64> <EFBFBD> <EEB2BB> ʶ<EFBFBD> <CAB6> !!!\n " ,
commid , sAddrParam . m_uchLinkAddr , sAddrParam . m_uchCommAddr ) ;
DebugPrint ( szbuf ) ;
# endif
MakeInteractionCmd ( pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuCommid , commid , hREADDATAEND , ptrProHead , FALSE ) ;
}
else
{
MakeInteractionCmd ( pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuCommid , commid , uInterAction , ptrProHead , FALSE ) ;
}
}
void Buban103GDprocessWithPAIToScada ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam , i_32 iGroupIdx )
{
int i , j , commid , iItemNum ;
BYTE u8KOD , u8INF , u8DataType ;
BYTE u8DataNum , u8DataLen , u8ItemNo ;
u_32 * puStartNo ;
int iOffset , offset ;
double fValue ;
float * pfValue ;
BOOL bFirst , bNumChanged ;
PROTECTCONTENTHEAD * ptrProHead ;
RTUMSG sendmsg ;
PROTECTMSG msg ;
VALUEDEF sValue ;
GROUPDEF * pGroupParam ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
bNumChanged = FALSE ;
bFirst = TRUE ;
iOffset = 14 ;
pGroupParam = & pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] ;
if ( pGroupParam - > m_iPntNum < = 0 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> ݿռ <DDBF> Ϊ<EFBFBD> <CEAA> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
if ( ( iOffset + 3 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
u8INF = rtumsg - > MsgData [ 11 ] ;
u8KOD = rtumsg - > MsgData [ 16 ] ;
pGroupParam - > m_u8NGD = rtumsg - > MsgData [ 13 ] ;
memset ( ( void * ) & msg , 0 , sizeof ( PROTECTMSG ) ) ;
msg . MsgType = fPFV_PROTECT_BYPASS_ACK ;
msg . PortNumber = commid ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> û<EFBFBD>
ptrProHead = ( pPROTECTCONTENTHEAD ) msg . MsgData ;
ptrProHead - > ummid = 0xFFFFFFFF ;
ptrProHead - > uAddr = pDevParam - > m_sDevParam . m_iProvAddr ;
// <20> <> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> Ҫʱ<D2AA> <CAB1> <EFBFBD> <EFBFBD> д0xFF)
ptrProHead - > cFixNo = ( char ) pDevParam - > m_sDevParam . m_u8FixNo ;
// C P U <20> <> (<28> <> <EFBFBD> <EFBFBD> Ҫʱ<D2AA> <CAB1> <EFBFBD> <EFBFBD> д0xFF)
ptrProHead - > cCPUNo = ( char ) pDevParam - > m_sDevParam . m_u8CPUNo ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
ptrProHead - > uFuncCode = hPAIDATA ;
// <20> <> չ<EFBFBD> <D5B9> <EFBFBD> <EFBFBD>
offset = sizeof ( PROTECTCONTENTHEAD ) ;
// ʵ<> <CAB5> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD>
msg . MsgData [ offset + + ] = u8KOD ;
// <20> <> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD>
puStartNo = ( u_32 * ) & msg . MsgData [ offset ] ;
offset + = sizeof ( u_32 ) ;
iItemNum = pGroupParam - > m_u8NGD & 0x3F ;
for ( i = 0 ; i < iItemNum ; i + + )
{
if ( ( iOffset + 6 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <EFBFBD> ݳ<EFBFBD> <DDB3> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݳ<EFBFBD> *<2A> <> <EFBFBD> <EFBFBD> )
u8DataNum = rtumsg - > MsgData [ iOffset + 5 ] ;
u8DataLen = rtumsg - > MsgData [ iOffset + 4 ] ;
if ( ( iOffset + 6 + u8DataLen * u8DataNum ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <20> <>
// <20> <> Ŀ<EFBFBD> <C4BF>
u8ItemNo = rtumsg - > MsgData [ iOffset + 1 ] ;
iOffset + = 2 ;
if ( TRUE = = bFirst )
{
if ( u8ItemNo = = 0 )
{
pGroupParam - > m_u32CurPntNo = 1 ;
}
else if ( u8ItemNo < = pGroupParam - > m_iStartItemNo )
{
pGroupParam - > m_u32CurPntNo = 1 ;
}
if ( ( M_INF_WRITEITEMWITHACK = = u8INF )
& & ( pGroupParam - > m_bInit = = FALSE ) )
{
for ( j = 0 ; j < pGroupParam - > m_iPntNum ; j + + )
{
if ( pGroupParam - > m_pu8GIN [ j ] = = u8ItemNo )
{
break ;
}
}
if ( j > = pGroupParam - > m_iPntNum )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)дȷ<D0B4> ϴ<EFBFBD> <CFB4> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> GIN=%d!!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , u8ItemNo , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
pGroupParam - > m_u32CurPntNo = j + 1 ;
}
* puStartNo = pGroupParam - > m_u32CurPntNo ;
bFirst = FALSE ;
}
if ( u8KOD ! = rtumsg - > MsgData [ iOffset ] )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)дȷ<D0B4> ϴ<EFBFBD> <CFB4> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> KOD=%d<> <64> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> KOD=%d<> <64> <EFBFBD> <EFBFBD> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo , rtumsg - > MsgData [ iOffset ] , u8KOD ) ;
DebugPrint ( szbuf ) ;
# endif
iOffset + = u8DataLen * u8DataNum + 4 ;
continue ;
}
else
{
iOffset + + ;
}
u8DataType = rtumsg - > MsgData [ iOffset + + ] ;
iOffset + = 2 ;
for ( j = 0 ; j < ( int ) u8DataNum ; j + + )
{
// wen 2004.02.01 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> Ϊ0<CEAA> <30> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĿΪ<C4BF> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ( u8ItemNo = = 0 ) & & ( j = = 0 ) )
{
iOffset + = u8DataLen ;
continue ;
}
if ( ( int ) pGroupParam - > m_u32CurPntNo > pGroupParam - > m_iPntNum )
{
break ;
}
if ( pGroupParam - > m_bInit = = FALSE )
{
//pGroupParam->m_pu8DataLen[pGroupParam->m_u32CurPntNo-1] = u8DataLen;
//pGroupParam->m_pu8DataType[pGroupParam->m_u32CurPntNo-1] = u8DataType;
pGroupParam - > m_pu8GIN [ pGroupParam - > m_u32CurPntNo - 1 ] = u8ItemNo + j ;
}
if ( GetOneValueOfASDU10 ( & rtumsg - > MsgData [ iOffset ] , & sValue , u8DataType , u8DataLen ) = = FALSE )
{
iOffset + = u8DataLen ;
continue ;
}
iOffset + = u8DataLen ;
switch ( sValue . m_iDataType )
{
case DT_UINT : // <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
fValue = sValue . m_unValue . m_uValue ;
break ;
case DT_INT :
fValue = sValue . m_unValue . m_iValue ;
break ;
case DT_FLOAT :
fValue = sValue . m_unValue . m_fValue ;
break ;
case DT_CONTROL :
fValue = sValue . m_unValue . m_dwValue ;
break ;
case DT_STRING :
fValue = - 1 ;
break ;
case DT_BINARY :
fValue = sValue . m_unValue . m_dwValue ;
break ;
case DT_NO : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
default :
fValue = - 1 ;
break ;
}
if ( pGroupParam - > m_bInit = = FALSE )
{
if ( ( u8ItemNo = = 0 ) & & ( j = = 0 ) )
{
if ( ( fValue > 0 ) & & ( KOD_ACTUALVALUE = = u8KOD ) )
{
if ( ( int ) fValue > pGroupParam - > m_iPntNum )
{
//pGroupParam->m_iPntNum = (int)sValue.m_unValue.m_uValue;
bNumChanged = TRUE ;
}
else
{
pGroupParam - > m_iPntNum = ( int ) fValue ;
}
}
}
}
if ( TRUE = = bNumChanged )
{
//freeallfixmemory
}
if ( DT_STRING ! = sValue . m_iDataType )
{
pfValue = ( float * ) & msg . MsgData [ offset ] ;
* pfValue = ( float ) fValue ;
offset + = sizeof ( float ) ;
}
if ( pGroupParam - > m_bInit = = FALSE )
{
pGroupParam - > m_psDataInfo [ pGroupParam - > m_u32CurPntNo - 1 ] . m_u32DataID = u8DataType ;
}
pGroupParam - > m_u32CurPntNo + + ;
}
}
if ( pGroupParam - > m_iPntNum > 0 )
{
if ( ( int ) pGroupParam - > m_u32CurPntNo > = pGroupParam - > m_iPntNum )
{
pGroupParam - > m_bInit = TRUE ;
pGroupParam - > m_u32CurPntNo = 1 ;
}
}
msg . MsgLen = offset ;
sendmsg . MsgLen = ( WORD ) ( msg . MsgLen + sizeof ( PROTECTMSGHEAD ) ) ;
sendmsg . MsgType = MSGTYPE_BAOHU_SCADADATA ;
sendmsg . PortIdx = pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuCommid ;
memcpy ( sendmsg . MsgData , ( BYTE * ) & msg , sendmsg . MsgLen ) ;
PutBaohuDataToPort ( & sendmsg ) ;
if ( pDevParam - > m_sDevParam . m_u32FuncCode = = hREADPAI )
{
if ( TRUE = = pGroupParam - > m_bInit )
{
MakeInteractionCmd ( pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuCommid , commid , hREADDATAEND , ptrProHead , FALSE ) ;
pDevParam - > m_sDevParam . m_u32FuncCode = 0 ;
}
}
}
void Buban103GDprocessWithPDIToScada ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam , i_32 iGroupIdx )
{
int i , j , commid , iItemNum ;
BYTE u8KOD , u8INF , u8DataType ;
BYTE u8DataNum , u8DataLen , u8ItemNo ;
u_32 * puStartNo ;
int iOffset , offset ;
double fValue ;
BOOL bFirst , bNumChanged ;
PROTECTCONTENTHEAD * ptrProHead ;
RTUMSG sendmsg ;
PROTECTMSG msg ;
VALUEDEF sValue ;
GROUPDEF * pGroupParam ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
bNumChanged = FALSE ;
bFirst = TRUE ;
iOffset = 14 ;
pGroupParam = & pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] ;
if ( pGroupParam - > m_iPntNum < = 0 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> ݿռ <DDBF> Ϊ<EFBFBD> <CEAA> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
if ( ( iOffset + 3 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
u8INF = rtumsg - > MsgData [ 11 ] ;
u8KOD = rtumsg - > MsgData [ 16 ] ;
pGroupParam - > m_u8NGD = rtumsg - > MsgData [ 13 ] ;
memset ( ( void * ) & msg , 0 , sizeof ( PROTECTMSG ) ) ;
msg . MsgType = fPFV_PROTECT_BYPASS_ACK ;
msg . PortNumber = commid ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> û<EFBFBD>
ptrProHead = ( pPROTECTCONTENTHEAD ) msg . MsgData ;
ptrProHead - > ummid = 0xFFFFFFFF ;
ptrProHead - > uAddr = pDevParam - > m_sDevParam . m_iProvAddr ;
// <20> <> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> Ҫʱ<D2AA> <CAB1> <EFBFBD> <EFBFBD> д0xFF)
ptrProHead - > cFixNo = ( char ) pDevParam - > m_sDevParam . m_u8FixNo ;
// C P U <20> <> (<28> <> <EFBFBD> <EFBFBD> Ҫʱ<D2AA> <CAB1> <EFBFBD> <EFBFBD> д0xFF)
ptrProHead - > cCPUNo = ( char ) pDevParam - > m_sDevParam . m_u8CPUNo ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
ptrProHead - > uFuncCode = hPDIDATA ;
// <20> <> չ<EFBFBD> <D5B9> <EFBFBD> <EFBFBD>
offset = sizeof ( PROTECTCONTENTHEAD ) ;
// ʵ<> <CAB5> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD>
msg . MsgData [ offset + + ] = u8KOD ;
// <20> <> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD>
puStartNo = ( u_32 * ) & msg . MsgData [ offset ] ;
offset + = sizeof ( u_32 ) ;
iItemNum = pGroupParam - > m_u8NGD & 0x3F ;
for ( i = 0 ; i < iItemNum ; i + + )
{
if ( ( iOffset + 6 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <EFBFBD> ݳ<EFBFBD> <DDB3> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݳ<EFBFBD> *<2A> <> <EFBFBD> <EFBFBD> )
u8DataNum = rtumsg - > MsgData [ iOffset + 5 ] ;
u8DataLen = rtumsg - > MsgData [ iOffset + 4 ] ;
if ( ( iOffset + 6 + u8DataLen * u8DataNum ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <20> <>
// <20> <> Ŀ<EFBFBD> <C4BF>
u8ItemNo = rtumsg - > MsgData [ iOffset + 1 ] ;
iOffset + = 2 ;
if ( TRUE = = bFirst )
{
if ( u8ItemNo = = 0 )
{
pGroupParam - > m_u32CurPntNo = 1 ;
}
else if ( u8ItemNo < = pGroupParam - > m_iStartItemNo )
{
pGroupParam - > m_u32CurPntNo = 1 ;
}
if ( ( M_INF_WRITEITEMWITHACK = = u8INF )
& & ( pGroupParam - > m_bInit = = FALSE ) )
{
for ( j = 0 ; j < pGroupParam - > m_iPntNum ; j + + )
{
if ( pGroupParam - > m_pu8GIN [ j ] = = u8ItemNo )
{
break ;
}
}
if ( j > = pGroupParam - > m_iPntNum )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)дȷ<D0B4> ϴ<EFBFBD> <CFB4> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> GIN=%d!!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , u8ItemNo , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
pGroupParam - > m_u32CurPntNo = j + 1 ;
}
* puStartNo = pGroupParam - > m_u32CurPntNo ;
bFirst = FALSE ;
}
if ( u8KOD ! = rtumsg - > MsgData [ iOffset ] )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)дȷ<D0B4> ϴ<EFBFBD> <CFB4> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> KOD=%d<> <64> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> KOD=%d<> <64> <EFBFBD> <EFBFBD> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo , rtumsg - > MsgData [ iOffset ] , u8KOD ) ;
DebugPrint ( szbuf ) ;
# endif
iOffset + = u8DataLen * u8DataNum + 4 ;
continue ;
}
else
{
iOffset + + ;
}
u8DataType = rtumsg - > MsgData [ iOffset + + ] ;
iOffset + = 2 ;
for ( j = 0 ; j < ( int ) u8DataNum ; j + + )
{
// wen 2004.02.01 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> Ϊ0<CEAA> <30> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĿΪ<C4BF> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ( u8ItemNo = = 0 ) & & ( j = = 0 ) )
{
iOffset + = u8DataLen ;
continue ;
}
if ( ( int ) pGroupParam - > m_u32CurPntNo > pGroupParam - > m_iPntNum )
{
break ;
}
if ( pGroupParam - > m_bInit = = FALSE )
{
//pGroupParam->m_pu8DataLen[pGroupParam->m_u32CurPntNo-1] = u8DataLen;
//pGroupParam->m_pu8DataType[pGroupParam->m_u32CurPntNo-1] = u8DataType;
pGroupParam - > m_pu8GIN [ pGroupParam - > m_u32CurPntNo - 1 ] = u8ItemNo + j ;
}
if ( GetOneValueOfASDU10 ( & rtumsg - > MsgData [ iOffset ] , & sValue , u8DataType , u8DataLen ) = = FALSE )
{
iOffset + = u8DataLen ;
continue ;
}
iOffset + = u8DataLen ;
switch ( sValue . m_iDataType )
{
case DT_UINT : // <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
fValue = sValue . m_unValue . m_uValue ;
break ;
case DT_INT :
fValue = sValue . m_unValue . m_iValue ;
break ;
case DT_FLOAT :
fValue = sValue . m_unValue . m_fValue ;
break ;
case DT_CONTROL :
fValue = sValue . m_unValue . m_dwValue ;
break ;
case DT_STRING :
fValue = - 1 ;
break ;
case DT_BINARY :
fValue = sValue . m_unValue . m_dwValue ;
break ;
case DT_NO : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
default :
fValue = - 1 ;
break ;
}
/*
if ( pGroupParam - > m_bInit = = FALSE )
{
if ( ( u8ItemNo = = 0 ) & & ( j = = 0 ) )
{
if ( ( fValue > 0 ) & & ( KOD_ACTUALVALUE = = u8KOD ) )
{
if ( ( int ) fValue > pGroupParam - > m_iPntNum )
{
//pGroupParam->m_iPntNum = (int)sValue.m_unValue.m_uValue;
bNumChanged = TRUE ;
}
else
{
pGroupParam - > m_iPntNum = ( int ) fValue ;
}
}
}
}
if ( TRUE = = bNumChanged )
{
//freeallfixmemory
}
*/
if ( DT_BINARY = = sValue . m_iDataType )
{
if ( 2 = = sValue . m_iDataNum )
{
if ( ( fValue < 1 ) | | ( fValue > 2 ) )
{
fValue = 0 ;
}
else
{
fValue - = 1 ;
}
}
}
if ( fValue > 0 )
{
msg . MsgData [ offset + + ] = TRUE ;
}
else
{
msg . MsgData [ offset + + ] = FALSE ;
}
if ( pGroupParam - > m_bInit = = FALSE )
{
pGroupParam - > m_psDataInfo [ pGroupParam - > m_u32CurPntNo - 1 ] . m_u32DataID = u8DataType ;
}
pGroupParam - > m_u32CurPntNo + + ;
}
}
if ( pGroupParam - > m_iPntNum > 0 )
{
if ( ( int ) pGroupParam - > m_u32CurPntNo > = pGroupParam - > m_iPntNum )
{
pGroupParam - > m_bInit = TRUE ;
pGroupParam - > m_u32CurPntNo = 1 ;
}
}
msg . MsgLen = offset ;
sendmsg . MsgLen = ( WORD ) ( msg . MsgLen + sizeof ( PROTECTMSGHEAD ) ) ;
sendmsg . MsgType = MSGTYPE_BAOHU_SCADADATA ;
sendmsg . PortIdx = pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuCommid ;
memcpy ( sendmsg . MsgData , ( BYTE * ) & msg , sendmsg . MsgLen ) ;
PutBaohuDataToPort ( & sendmsg ) ;
if ( pDevParam - > m_sDevParam . m_u32FuncCode = = hREADPDI )
{
if ( TRUE = = pGroupParam - > m_bInit )
{
MakeInteractionCmd ( pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuCommid , commid , hREADDATAEND , ptrProHead , FALSE ) ;
pDevParam - > m_sDevParam . m_u32FuncCode = 0 ;
}
}
}
void Buban103GDprocessWithPFIXToScada ( RTUMSG * rtumsg , DEVADDRPARAM * psDevAddrParam , i_32 iGroupIdx )
{
int i , j , commid , iItemNum ;
BYTE u8KOD , u8INF , u8DataType ;
BYTE u8DataNum , u8DataLen , u8ItemNo ;
u_32 * puStartNo ;
int iOffset , offset ;
double fValue ;
float * pfValue ;
BOOL bFirst , bNumChanged ;
PROTECTCONTENTHEAD * ptrProHead ;
RTUMSG sendmsg ;
PROTECTMSG msg ;
VALUEDEF sValue ;
GROUPDEF * pGroupParam ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
//#ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
//#endif
sprintf ( szbuf , " Buban103GDprocessWithPFIXToScada " ) ;
DebugPrint ( szbuf ) ;
commid = rtumsg - > PortIdx ;
if ( FALSE = = GetSpecialPtr ( commid , psDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
bNumChanged = FALSE ;
bFirst = TRUE ;
iOffset = 14 ;
pGroupParam = & pDevParam - > m_sDevParam . m_saGroupDef [ iGroupIdx ] ;
if ( pGroupParam - > m_iPntNum < = 0 )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> ݿռ <DDBF> Ϊ<EFBFBD> <CEAA> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
if ( ( iOffset + 3 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ, <20> <> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
u8INF = rtumsg - > MsgData [ 11 ] ;
u8KOD = rtumsg - > MsgData [ 16 ] ;
pGroupParam - > m_u8NGD = rtumsg - > MsgData [ 13 ] ;
if ( ( 0xf9 = = u8INF ) & & ( rtumsg - > MsgData [ 8 ] = = 0x29 ) )
{
sprintf ( szbuf , " Buban103GDprocessWithPFIXToScadaд<EFBFBD> <EFBFBD> ֵȷ<EFBFBD> <EFBFBD> ʧ<EFBFBD> <EFBFBD> " ) ;
DebugPrint ( szbuf ) ;
}
if ( ( 0xf9 = = u8INF ) & & ( rtumsg - > MsgData [ 8 ] = = 0x2c ) )
{
sprintf ( szbuf , " Buban103GDprocessWithPFIXToScadaд<EFBFBD> <EFBFBD> ֵȷ<EFBFBD> ϳ ɹ<EFBFBD> " ) ;
DebugPrint ( szbuf ) ;
}
if ( ( 0xfa = = u8INF ) & & ( rtumsg - > MsgData [ 8 ] = = 0x28 ) )
{
sprintf ( szbuf , " Buban103GDprocessWithPFIXToScadaд<EFBFBD> <EFBFBD> ִֵ<EFBFBD> г ɹ<EFBFBD> " ) ;
DebugPrint ( szbuf ) ;
}
if ( ( 0xfa = = u8INF ) & & ( rtumsg - > MsgData [ 8 ] = = 0x29 ) )
{
sprintf ( szbuf , " Buban103GDprocessWithPFIXToScadaд<EFBFBD> <EFBFBD> ִֵ<EFBFBD> <EFBFBD> ʧ<EFBFBD> <EFBFBD> " ) ;
DebugPrint ( szbuf ) ;
}
if ( ( 0xfb = = u8INF ) & & ( rtumsg - > MsgData [ 8 ] = = 0x28 ) )
{
sprintf ( szbuf , " Buban103GDprocessWithPFIXToScadaд<EFBFBD> <EFBFBD> ֵ<EFBFBD> <EFBFBD> ִֹ<EFBFBD> г ɹ<EFBFBD> " ) ;
DebugPrint ( szbuf ) ;
}
memset ( ( void * ) & msg , 0 , sizeof ( PROTECTMSG ) ) ;
msg . MsgType = fPFV_PROTECT_BYPASS_ACK ;
msg . PortNumber = commid ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> û<EFBFBD>
ptrProHead = ( pPROTECTCONTENTHEAD ) msg . MsgData ;
ptrProHead - > ummid = 0xFFFFFFFF ;
ptrProHead - > uAddr = pDevParam - > m_sDevParam . m_iProvAddr ;
// <20> <> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> Ҫʱ<D2AA> <CAB1> <EFBFBD> <EFBFBD> д0xFF)
ptrProHead - > cFixNo = ( char ) pDevParam - > m_sDevParam . m_u8FixNo ;
// C P U <20> <> (<28> <> <EFBFBD> <EFBFBD> Ҫʱ<D2AA> <CAB1> <EFBFBD> <EFBFBD> д0xFF)
ptrProHead - > cCPUNo = ( char ) pDevParam - > m_sDevParam . m_u8CPUNo ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
ptrProHead - > uFuncCode = hFIXDATA ;
// <20> <> չ<EFBFBD> <D5B9> <EFBFBD> <EFBFBD>
offset = sizeof ( PROTECTCONTENTHEAD ) ;
// ʵ<> <CAB5> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD>
msg . MsgData [ offset + + ] = u8KOD ;
// <20> <> ʼ <EFBFBD> <CABC> <EFBFBD> <EFBFBD>
puStartNo = ( u_32 * ) & msg . MsgData [ offset ] ;
offset + = sizeof ( u_32 ) ;
iItemNum = pGroupParam - > m_u8NGD & 0x3F ;
for ( i = 0 ; i < iItemNum ; i + + )
{
if ( ( iOffset + 6 ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <EFBFBD> ݳ<EFBFBD> <DDB3> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݳ<EFBFBD> *<2A> <> <EFBFBD> <EFBFBD> )
u8DataNum = rtumsg - > MsgData [ iOffset + 5 ] ;
u8DataLen = rtumsg - > MsgData [ iOffset + 4 ] ;
if ( ( iOffset + 6 + u8DataLen * u8DataNum ) > = rtumsg - > MsgLen )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)<29> <> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֡<EFBFBD> <D6A1> <EFBFBD> Ȳ<EFBFBD> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
// <20> <> <20> <>
// <20> <> Ŀ<EFBFBD> <C4BF>
u8ItemNo = rtumsg - > MsgData [ iOffset + 1 ] ;
iOffset + = 2 ;
if ( TRUE = = bFirst )
{
if ( u8ItemNo = = 0 )
{
pGroupParam - > m_u32CurPntNo = 1 ;
}
else if ( u8ItemNo < = pGroupParam - > m_iStartItemNo )
{
pGroupParam - > m_u32CurPntNo = 1 ;
}
if ( ( M_INF_WRITEITEMWITHACK = = u8INF )
& & ( pGroupParam - > m_bInit = = FALSE ) )
{
for ( j = 0 ; j < pGroupParam - > m_iPntNum ; j + + )
{
if ( pGroupParam - > m_pu8GIN [ j ] = = u8ItemNo )
{
break ;
}
}
if ( j > = pGroupParam - > m_iPntNum )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)дȷ<D0B4> ϴ<EFBFBD> <CFB4> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> GIN=%d!!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , u8ItemNo , pGroupParam - > m_iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
pGroupParam - > m_u32CurPntNo = j + 1 ;
}
* puStartNo = pGroupParam - > m_u32CurPntNo ;
bFirst = FALSE ;
}
if ( u8KOD ! = rtumsg - > MsgData [ iOffset ] )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10(Group=%d)дȷ<D0B4> ϴ<EFBFBD> <CFB4> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> KOD=%d<> <64> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> KOD=%d<> <64> <EFBFBD> <EFBFBD> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , pGroupParam - > m_iGroupNo , rtumsg - > MsgData [ iOffset ] , u8KOD ) ;
DebugPrint ( szbuf ) ;
# endif
iOffset + = u8DataLen * u8DataNum + 4 ;
continue ;
}
else
{
iOffset + + ;
}
u8DataType = rtumsg - > MsgData [ iOffset + + ] ;
iOffset + = 2 ;
for ( j = 0 ; j < ( int ) u8DataNum ; j + + )
{
// wen 2004.02.01 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> Ϊ0<CEAA> <30> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĿΪ<C4BF> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( ( u8ItemNo = = 0 ) & & ( j = = 0 ) )
{
iOffset + = u8DataLen ;
continue ;
}
if ( ( int ) pGroupParam - > m_u32CurPntNo > pGroupParam - > m_iPntNum )
{
break ;
}
if ( pGroupParam - > m_bInit = = FALSE )
{
pGroupParam - > m_pu8DataLen [ pGroupParam - > m_u32CurPntNo - 1 ] = u8DataLen ;
pGroupParam - > m_pu8DataType [ pGroupParam - > m_u32CurPntNo - 1 ] = u8DataType ;
pGroupParam - > m_pu8GIN [ pGroupParam - > m_u32CurPntNo - 1 ] = u8ItemNo + j ;
}
if ( GetOneValueOfASDU10 ( & rtumsg - > MsgData [ iOffset ] , & sValue , u8DataType , u8DataLen ) = = FALSE )
{
iOffset + = u8DataLen ;
continue ;
}
iOffset + = u8DataLen ;
switch ( sValue . m_iDataType )
{
case DT_UINT : // <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
fValue = sValue . m_unValue . m_uValue ;
break ;
case DT_INT :
fValue = sValue . m_unValue . m_iValue ;
break ;
case DT_FLOAT :
fValue = sValue . m_unValue . m_fValue ;
break ;
case DT_CONTROL :
fValue = sValue . m_unValue . m_dwValue ;
break ;
case DT_STRING :
fValue = - 1 ;
break ;
case DT_BINARY :
fValue = sValue . m_unValue . m_dwValue ;
break ;
case DT_NO : // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
default :
fValue = - 1 ;
break ;
}
if ( DT_STRING = = sValue . m_iDataType )
{
msg . MsgData [ offset + + ] = DATATYPE_STRING ;
msg . MsgData [ offset + + ] = ( BYTE ) sValue . m_iDataNum ;
memcpy ( ( void * ) & msg . MsgData [ offset ] , sValue . m_szValue , sValue . m_iDataNum ) ;
offset + = sValue . m_iDataNum ;
}
else if ( DT_BINARY = = sValue . m_iDataType )
{
if ( 2 = = sValue . m_iDataNum )
{
if ( ( fValue < 1 ) | | ( fValue > 2 ) )
{
fValue = 0 ;
}
else
{
fValue - = 1 ;
}
}
msg . MsgData [ offset + + ] = DATATYPE_DI ;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//ң<> <D2A3> <EFBFBD> <EFBFBD> Ҳ<EFBFBD> <D2B2> <EFBFBD> <EFBFBD> float<61> <74> <EFBFBD> <EFBFBD> ʽ <EFBFBD> <CABD> <EFBFBD> ͵<EFBFBD>
//if(fValue > 0)
//{
// msg.MsgData[offset++] = TRUE;
//}
//else
//{
// msg.MsgData[offset++] = FALSE;
//}
//===============================================================
if ( fValue > 0 )
{
fValue = TRUE ;
}
else
{
fValue = FALSE ;
}
pfValue = ( float * ) & msg . MsgData [ offset ] ;
* pfValue = ( float ) fValue ;
offset + = sizeof ( float ) ;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
}
else
{
// <20> <> <EFBFBD> <EFBFBD> װ<EFBFBD> õĿ<C3B5> <C4BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//msg.MsgData[offset++] = DATATYPE_AI;
if ( pGroupParam - > m_psDataInfo [ pGroupParam - > m_u32CurPntNo - 1 ] . iFixDataType = = 2 )
msg . MsgData [ offset + + ] = DATATYPE_DI ;
else
msg . MsgData [ offset + + ] = DATATYPE_AI ;
pfValue = ( float * ) & msg . MsgData [ offset ] ;
* pfValue = ( float ) fValue ;
offset + = sizeof ( float ) ;
}
if ( pGroupParam - > m_bInit = = FALSE )
{
pGroupParam - > m_psDataInfo [ pGroupParam - > m_u32CurPntNo - 1 ] . m_u32DataID = u8DataType ;
}
pGroupParam - > m_u32CurPntNo + + ;
}
}
if ( pGroupParam - > m_iPntNum > 0 )
{
if ( ( int ) pGroupParam - > m_u32CurPntNo > pGroupParam - > m_iPntNum )
{
sprintf ( szbuf , " <EFBFBD> <EFBFBD> ǰ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> m_u32CurPntNo=%d, <20> <> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> m_iPntNum= %d" , pGroupParam - > m_u32CurPntNo , pGroupParam - > m_iPntNum ) ;
DebugPrint ( szbuf ) ;
pGroupParam - > m_bInit = TRUE ;
pGroupParam - > m_u32CurPntNo = 1 ;
}
}
msg . MsgLen = offset ;
sendmsg . MsgLen = ( WORD ) ( msg . MsgLen + sizeof ( PROTECTMSGHEAD ) ) ;
sendmsg . MsgType = MSGTYPE_BAOHU_SCADADATA ;
sendmsg . PortIdx = pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuCommid ;
memcpy ( sendmsg . MsgData , ( BYTE * ) & msg , sendmsg . MsgLen ) ;
PutBaohuDataToPort ( & sendmsg ) ;
if ( pDevParam - > m_sDevParam . m_u32FuncCode = = hREADFIX )
{
if ( TRUE = = pGroupParam - > m_bInit )
{
MakeInteractionCmd ( pLinkParam - > m_sBaoHuCmdParam . m_iBaoHuCommid , commid , hREADDATAEND , ptrProHead , FALSE ) ;
pDevParam - > m_sDevParam . m_u32FuncCode = 0 ;
}
}
ptrProHead = ( pPROTECTCONTENTHEAD ) & sendmsg . MsgData [ sizeof ( PROTECTMSGHEAD ) ] ;
// wen 2004.01.06 д<> <D0B4> ֵȷ<D6B5> <C8B7>
if ( ( M_CAUSE_WRITEACK = = rtumsg - > MsgData [ 8 ] )
| | ( M_CAUSE_WRITECONFIRM = = rtumsg - > MsgData [ 8 ] ) )
{
ptrProHead - > uFuncCode = hWRITEFIXACK ;
Buban103ScadaCmdchange ( commid , & sendmsg ) ;
}
else if ( M_CAUSE_WRITENAK = = rtumsg - > MsgData [ 8 ] )
{
ptrProHead - > uFuncCode = hWRITEFIXNAK ;
Buban103ScadaCmdchange ( commid , & sendmsg ) ;
}
}
void Buban103ScadaDatachange ( int commid , RTUMSG * rtumsg )
{
// <20> <> <EFBFBD> ͱ<EFBFBD> ʶ(TYP):10
//rtumsg->MsgData[6];
// <20> ɱ<EFBFBD> <C9B1> ṹ<EFBFBD> <EFBFBD> <DEB6> <EFBFBD> (VSQ):0x81
//rtumsg->MsgData[7];
// <20> <> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> (COT)
//rtumsg->MsgData[8];
// Ӧ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݵ<EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ
//rtumsg->MsgData[9];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (FUN): 254(0xfe)
//rtumsg->MsgData[10];
// <20> <> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> (INF):
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : 240
// <20> <> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȫ<EFBFBD> <C8AB> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : 241
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> Ŀ¼ : 243
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ<EFBFBD> <C4BF> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : 244
// <20> <> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ܲ<EFBFBD> ѯ<EFBFBD> <D1AF> ֹ : 245
//rtumsg->MsgData[11];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ<EFBFBD> <CFA2> ʶ<EFBFBD> <CAB6> (RII)
//rtumsg->MsgData[12];
// ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݼ<EFBFBD> <DDBC> <EFBFBD> Ŀ
//rtumsg->MsgData[13];
// <20> <> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <CEAA> <EFBFBD> <EFBFBD> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD> (GIN):<3A> <> Ŀ<EFBFBD> ź<EFBFBD> <C5BA> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[14];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (KOD)
// <20> <> <EFBFBD> <EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : KOD_NOSPECIFIED(0)
// ʵ<> <CAB5> ֵ : KOD_ACTUALVALUE(1)
// ȱʡֵ : KOD_DEFAULTVALUE(2)
// <20> <> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> С ֵ<D0A1> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ) : KOD_RANGE(3)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP1(4)
// <20> <> <EFBFBD> <EFBFBD> (n,m) : KOD_PRECISION(5)
// <20> <> <EFBFBD> <EFBFBD> : KOD_FACTOR(6)
// <20> α <EFBFBD> : KOD_REFERENCE(7)
// <20> б <EFBFBD> : KOD_ENUMERATION(8)
// <20> <> <EFBFBD> <EFBFBD> : KOD_DIMENSION(9)
// <20> <> <EFBFBD> <EFBFBD> : KOD_DESCRIPTION(10)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP2(11)
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ : KOD_PASSWORD(12)
// ֻ<> <D6BB> : KOD_READONLY(13)
// ֻд : KOD_WRITEONLY(14)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP3(15)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP4(16)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP5(17)
// <20> <> <EFBFBD> <EFBFBD> : KOD_BACKUP6(18)
// <20> <> Ӧ<EFBFBD> Ĺ<EFBFBD> <C4B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͺ <EFBFBD> <CDBA> <EFBFBD> Ϣ<EFBFBD> <CFA2> <EFBFBD> <EFBFBD> : KOD_CORFUNCANDINF(19)
// <20> <> Ӧ<EFBFBD> <D3A6> <EFBFBD> ¼<EFBFBD> : KOD_COREVENT(20)
// <20> б <EFBFBD> <D0B1> <EFBFBD> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> <EFBFBD> <EFBFBD> : KOD_ENUMTEXTARRAY(21)
// <20> б <EFBFBD> <D0B1> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> : KOD_ENUMVALUEARRAY(22)
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ : KOD_RELATEDENTRIES(23)
//rtumsg->MsgData[16];
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[17];
//DATAID_NO : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_OS8ASCII : 8λASCII
//DATAID_BSTRING : 8λ2<CEBB> <32> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_UIX : <20> <EFBFBD> <DEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_INT : <20> <> <EFBFBD> <EFBFBD>
//DATAID_UFLOAT : <20> <EFBFBD> <DEB7> Ÿ<EFBFBD> <C5B8> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_FLOAT : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//DATAID_754SHORT : R32.23 IEEE <20> <> 754<35> <34> ʵ<EFBFBD> <CAB5>
//DATAID_754REAL : R64.53 IEEE <20> <> 754ʵ<34> <CAB5>
//DATAID_DOUBLE : ˫<> <CBAB> <EFBFBD> <EFBFBD> Ϣ
//DATAID_SINGLE : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
//DATAID_13BITS : <20> <> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD> ֵ(13BITS)
//DATAID_SORTIDNO : ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> ʶ<EFBFBD> <CAB6> <EFBFBD> <EFBFBD>
//DATAID_WITHTIME : <20> <> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD>
//DATAID_WITHTIMESPACE : <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ<EFBFBD> <CAB1> <EFBFBD> ı <EFBFBD> <C4B1> <EFBFBD>
//DATAID_STRUCT : <20> <> <EFBFBD> ݽṹ
// <20> <> <EFBFBD> ݳߴ <DDB3>
//rtumsg->MsgData[18]
// <20> <> <EFBFBD> <EFBFBD>
//rtumsg->MsgData[19]
// <20> <> <EFBFBD> <EFBFBD> ֵ(<28> <> <EFBFBD> ȸ<EFBFBD> <C8B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> )
// 2 ... n <20> <> ͨ<EFBFBD> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
int i , iGroupNo , iCfgGroupIdx ;
DEVDEF * pDevParam ;
BUBAN103LINKDEF * pLinkParam ;
BUBAN103PORTPARAM * pPortParam ;
DEVADDRPARAM sDevAddrParam ;
# ifdef _DEBUG_MSG_
char szbuf [ 256 ] ;
# endif
sDevAddrParam . m_uchLinkAddr = rtumsg - > MsgData [ 5 ] ;
sDevAddrParam . m_uchCommAddr = rtumsg - > MsgData [ 9 ] ;
pPortParam = ( BUBAN103PORTPARAM * ) SioParam [ commid ] . ExtInfo ;
if ( FindProtectDev ( pPortParam , & sDevAddrParam , FALSE ) = = FALSE )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d <20> <> <EFBFBD> ڶ˿<DAB6> <CBBF> <EFBFBD> <EFBFBD> ñ<EFBFBD> <C3B1> <EFBFBD> <EFBFBD> <EFBFBD> Χ <EFBFBD> <CEA7> !!!" ,
commid , sDevAddrParam . m_uchLinkAddr , sDevAddrParam . m_uchCommAddr ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
if ( FALSE = = GetSpecialPtr ( commid , & sDevAddrParam , & pPortParam , & pLinkParam , & pDevParam ) )
{
return ;
}
//<2F> <> <20> <>
iGroupNo = rtumsg - > MsgData [ 14 ] ;
for ( i = 0 ; i < pDevParam - > m_sDevParam . m_iCfgGroupNum ; i + + )
{
if ( pDevParam - > m_sDevParam . m_saGroupDef [ i ] . m_iGroupNo = = iGroupNo )
{
iCfgGroupIdx = i ;
break ;
}
}
if ( i > = pDevParam - > m_sDevParam . m_iCfgGroupNum )
{
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10 ͨ<> ÷<EFBFBD> <C3B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> ʱ<EFBFBD> <CAB1> Group=%d<> <64> <EFBFBD> ڴ<EFBFBD> <DAB4> <EFBFBD> <EFBFBD> <EFBFBD> Χ <EFBFBD> <CEA7> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr , iGroupNo ) ;
DebugPrint ( szbuf ) ;
# endif
return ;
}
switch ( pDevParam - > m_sDevParam . m_saGroupDef [ iCfgGroupIdx ] . m_iDataType )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ģ<EFBFBD> <C4A3> <EFBFBD> <EFBFBD>
case PROTECT_AI_PNT_TYPE :
Buban103GDprocessWithPAIToScada ( rtumsg , & sDevAddrParam , iCfgGroupIdx ) ;
break ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
case PROTECT_DI_PNT_TYPE :
Buban103GDprocessWithPDIToScada ( rtumsg , & sDevAddrParam , iCfgGroupIdx ) ;
break ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ
case PROTECT_FIX_PNT_TYPE :
Buban103GDprocessWithPFIXToScada ( rtumsg , & sDevAddrParam , iCfgGroupIdx ) ;
break ;
default :
# ifdef _DEBUG_MSG_
sprintf ( szbuf , " <EFBFBD> ˿<EFBFBD> %d linkaddr=%d devaddr=%d ASDU10<31> <30> <EFBFBD> <EFBFBD> ʱ, Group=%d<> <64> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (=%d)<29> <> ƥ<EFBFBD> <C6A5> !!!\n " ,
commid , pLinkParam - > m_uchLinkAddr , pDevParam - > m_sDevParam . m_u8DevAddr ,
pDevParam - > m_sDevParam . m_saGroupDef [ iCfgGroupIdx ] . m_iGroupNo ,
pDevParam - > m_sDevParam . m_saGroupDef [ iCfgGroupIdx ] . m_iDataType ) ;
DebugPrint ( szbuf ) ;
# endif
break ;
}
}
void Buban103ScadaProtocolExchange ( int commid , RTUMSG * rtumsg )
{
if ( MSGTYPE_BAOHU_SCADACMD = = rtumsg - > MsgType )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Buban103ScadaCmdchange ( commid , rtumsg ) ;
}
if ( MSGTYPE_BAOHU_SCADADATA = = rtumsg - > MsgType )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Buban103ScadaDatachange ( commid , rtumsg ) ;
}
}
void Buban103DispConfig ( int commid , BUBAN103PORTPARAM * psPortParam )
{
int i , j ;
char szDbg [ 256 ] ;
sprintf ( szDbg , " >>>Disp Commid_%02d Config(PortType=%d): " , commid , psPortParam - > m_psBaoHu - > PortType ) ;
DebugPrint ( szDbg ) ;
sprintf ( szDbg , " >>>LinkNum=%d " , psPortParam - > m_iLinkNum ) ;
DebugPrint ( szDbg ) ;
for ( i = 0 ; i < psPortParam - > m_iLinkNum ; i + + )
{
sprintf ( szDbg , " >>>LinkIdx=%d DevNum=%d " , i , psPortParam - > m_psLink [ i ] . m_iDevNum ) ;
DebugPrint ( szDbg ) ;
if ( PROTOCOL_MASTER = = psPortParam - > m_psBaoHu - > PortType )
{
for ( j = 0 ; j < psPortParam - > m_psLink [ i ] . m_iDevNum ; j + + )
{
sprintf ( szDbg , " ###DevNo %d " , j ) ;
DebugPrint ( szDbg ) ;
sprintf ( szDbg , " >>>ProvAddr=%d CfgGroupNum=%d, DevAddr=%d " ,
psPortParam - > m_psLink [ i ] . m_psDev [ j ] . m_sDevParam . m_iProvAddr ,
psPortParam - > m_psLink [ i ] . m_psDev [ j ] . m_sDevParam . m_iCfgGroupNum ,
psPortParam - > m_psLink [ i ] . m_psDev [ j ] . m_sDevParam . m_u8DevAddr ) ;
DebugPrint ( szDbg ) ;
DebugPrint ( ( char * ) " \n " ) ;
}
}
else
{
for ( j = 0 ; j < psPortParam - > m_psLink [ i ] . m_iDevNum ; j + + )
{
sprintf ( szDbg , " ###DevNo %d " , j ) ;
sprintf ( szDbg , " >>>ProvAddr=%d Asdu10Num=%d, RealCommid=%d " ,
psPortParam - > m_psLink [ i ] . m_psProvDev [ j ] . m_iProvAddr ,
psPortParam - > m_psLink [ i ] . m_psProvDev [ j ] . m_iAsdu10Num ,
psPortParam - > m_psLink [ i ] . m_psProvDev [ j ] . m_iRealCommid ) ;
DebugPrint ( szDbg ) ;
DebugPrint ( ( char * ) " \n " ) ;
}
}
}
}
void Buban103DispMalloc ( int commid , int iSize )
{
char szbuf [ 128 ] ;
return ;
sprintf ( szbuf , " disp: commid=%d, malloc(%d) " , commid , iSize ) ;
DebugPrint ( szbuf ) ;
}
//===========================ת<> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> =========================
//===========================<3D> <> <EFBFBD> ݴ<EFBFBD> <DDB4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> =========================