/******************************************************************************

	:
*******************************************************************************/


//-----------------------------------------------------------------------------
//03/06指令 
//1/固件信息 bms lin

#define     AnalogBeginID                      ((Uint16)0x10 )
#define     AnalogFirmwareBeginID              ((Uint16)0x10 )
#define     AnalogFirmwareEndID                ((Uint16)0x2F )
#define     eFirmwarDataLen                    ((Uint16)AnalogFirmwareEndID - (Uint16)AnalogFirmwareBeginID)

//2 lin 下发 电池相关信息
#define     BAT_SetMesAddrBegin                ((Uint16)0x0250)
#define     BAT_SetMesAddrEnd                  ((Uint16)0x026F)
#define     eBatSetDataLen                     ((Uint16)BAT_SetMesAddrEnd - (Uint16)BAT_SetMesAddrBegin)

//2 BMS 下发 电池相关信息 
#define     Bms_SetMesAddrBegin                ((Uint16)0x0250)
#define     Bms_SetMesAddrEnd                  ((Uint16)0x025A)
#define     eBmsSetDataLen                     ((Uint16)Bms_SetMesAddrEnd - (Uint16)Bms_SetMesAddrBegin)

//3 lin 下发 母线相关信息
#define     BUS_SetMesAddrBegin                ((Uint16)0x0450)
#define     BUS_SetMesAddrEnd                  ((Uint16)0x045F)
#define     eBUSSetDataLen                     ((Uint16)BUS_SetMesAddrEnd - (Uint16)BUS_SetMesAddrBegin)


//4 lin reg 下发 相关信息
#define     REG_SetMesAddrBegin                ((Uint16)0x0600)
#define     REG_SetMesAddrEnd                  ((Uint16)0x061F)
#define     eREGSetDataLen                     ((Uint16)REG_SetMesAddrEnd - (Uint16)REG_SetMesAddrBegin)

//02/04指令 lin监控

//1/BAT 告警信息
#define     BAT_Warm_BeginID                   ((Uint16)0x110 )
#define     BAT_Warm_EndID                     ((Uint16)0x12F )
#define     BAT_Warm_DataLen                    ((Uint16)BAT_Warm_EndID - (Uint16)BAT_Warm_BeginID)

//2/BAT 故障 信息
#define     BAT_Fault_BeginID                   ((Uint16)0x150 )
#define     BAT_Fault_EndID                     ((Uint16)0x16F )
#define     BAT_Fault_DataLen                    ((Uint16)BAT_Fault_EndID - (Uint16)BAT_Fault_BeginID)

//3/dcdc 充电信息
#define     DCDC_Char_Mes_BeginID                   ((Uint16)0x200 )
#define     DCDC_Char_Mes_EndID                     ((Uint16)0x20F )
#define     DCDC_Char_Mes_DataLen                   ((Uint16)DCDC_Char_Mes_EndID - (Uint16)DCDC_Char_Mes_BeginID)

//4/dcdc 放电信息
#define     DCDC_ReChar_Mes_BeginID                   ((Uint16)0x400 )
#define     DCDC_ReChar_Mes_EndID                     ((Uint16)0x40F )
#define     DCDC_ReChar_Mes_DataLen                   ((Uint16)DCDC_ReChar_Mes_EndID - (Uint16)DCDC_ReChar_Mes_BeginID)

//5/Misc 信息
#define     Misc_BeginID                   ((Uint16)0x800 )
#define     Misc_EndID                     ((Uint16)0x80F )
#define     Misc_DataLen                    ((Uint16)Misc_EndID - (Uint16)Misc_BeginID)

//6/温度 信息
#define     Temp_BeginID                   ((Uint16)0x900 )
#define     Temp_EndID                     ((Uint16)0x90F )
#define     Temp_DataLen                    ((Uint16)Temp_EndID - (Uint16)Temp_BeginID)

//7/状态 信息
#define     Sta_BeginID                   ((Uint16)0x100 )
#define     Sta_EndID                     ((Uint16)0x10F )
#define     Sta_DataLen                   ((Uint16)Sta_EndID - (Uint16)Sta_BeginID)

//02/04指令 BMS相关
//1/BAT 状态信息
#define     Bms_sta_BeginID                   ((Uint16)0x110 )
#define     Bms_sta_EndID                     ((Uint16)0x118 )
#define     Bms_staDataLen                    ((Uint16)Bms_sta_EndID - (Uint16)Bms_sta_BeginID)



#define     AnalogRunInforBeginID              ((Uint16)500 )
#define     AnalogRunInforEndID                ((Uint16)500 )//(AnalogRunInforBeginID + (Uint16)eSciAnalogDataEndID - (Uint16)eAnalogDataRunInforBeginID)
#define     AnalogEndID                        ((Uint16)500 )//(AnalogRunInforBeginID + (Uint16)eSciAnalogDataEndID - (Uint16)eAnalogDataRunInforBeginID)


#define     eSciCommdEndID                     ((Uint16)eDateTimeCalib3CmdID)

#define     CommandDataBeginID      ((Uint16)61460)     //0XF000    控制命令的开始地址
//#define     BmsCommandDataEndID1           (BmsCommandDataBeginID1 + (Uint16)eBmsCommdIDEnd - (Uint16)eDCOutVoltSetCmdID)
#define     CommandDataEndID           (CommandDataBeginID + (Uint16)eSciCommdEndID - (Uint16)eDCOutVoltSetCmdID)


#define     SetDataBeginID                   ((Uint16)2000 )
#define     SetFirmwareBeginID              ((Uint16)2000 )
#define     SetFirmwareEndID                (SetFirmwareBeginID + (Uint16)eSetDataControlDebugEndSetID - (Uint16)eSetDataFirmwareBeginID)


#define     SetUserParamBeginID              ((Uint16)2500 )
#define     SetUserParamEndID                (SetUserParamBeginID + (Uint16)eSciSetDataEndID - (Uint16)eSetDataUserParamBeginSetID)
#define     SetDataEndID                     (SetUserParamBeginID + (Uint16)eSciSetDataEndID - (Uint16)eSetDataUserParamBeginSetID)


#define     FaultBeginID                      ((Uint16)1000 )
#define     FaultEndID                       (FaultBeginID + 12)


#define     SEND_DATA_LENGTH                (Uint16)260
#define     SCI_UPLOAD_FRAME_WORDS          (Uint16)(SEND_DATA_LENGTH - (Uint16)10)

#define     UartFunCodeError          0x01

#define     RECEIVE_DATA_LENGTH             (Uint16)260
#define     TRUE               1//
#define     FALSE              0//

//==================================================================================================
//
//==================================================================================================
enum
{
    eComUpSlaveAddressMonitorSci,         //0 上传从机地址
    eComUpRealStatusMonitorSci,           //1 上传实时告警量和故障量
    eComUpRealAnalogMonitorSci,           //2 上传实时模拟量
    eComUpSetDataMonitorSci,              //3 上传设置量
    eWriteSetSingleDataMonitorSci,        //4 下达单个设置量
    eWriteSetMultipleDataMonitorSci,      //5 下达多个设置量  0x10
    eInvalidMonitorSci,                   //6 指令无效
    eSlaveAddressMismatchMonitorSci,      //7 从机地址不匹配
    eUpdateProgramMonitorSci,             //8 升级指令
    eCom_EndMonitorSci
};


typedef struct
{
    Uint16    uiTopLimit;
    Uint16    uiDownLimit;

}   st_abcd;


//==================================================================================================
//
//==================================================================================================
extern   Uint16              uiMonitorSciRxDataBuff[]; //uiMonitorSciRxDataBuff

extern   Uint16              uiMonitorSciTxDataBuff[];

extern   Uint16  uiMonitorSciRxDataBuff_lin[]; //uiMonitorSciRxDataBuff

extern   Uint16  uiMonitorSciTxDataBuff_lin[]; 

extern   Uint16              uiMonitorSciErrorCntNum;

extern   st_abcd    strCmdParaTable[ ];

extern   st_abcd    strSetParaTable[ ];

extern Uint16  uiSetDataBag[];            //设置量
extern Uint16  uBatSetDataBag[];
extern Uint16  uBusSetDataBag[];    //设置量Bus 
extern Uint16  uRegSetDataBag[];    //设置量reg
extern Uint16  uBmsSetDataBag[];    //设置量BAT 

extern Uint16  uBATWarmDataBag[];    
extern Uint16  uBATFaultDataBag[];     
extern Uint16  uDCDCCharMesDataBag[];     
extern Uint16  uDCDCReCharMesDataBag[];    
extern Uint16  uMiscDataBag[];    
extern Uint16  uTempDataBag[]; 
extern Uint16  uStaDataBag[]; 

//==================================================================================================
//
//==================================================================================================


//==================================================================================================
//
//==================================================================================================
extern      void   MonitorSci_CommandIdentify(void);
extern      void   MonitorSci_CrcCheck(void);
extern      void   MonitorSci_CommandDeal(void);
extern      void   MonitorSci_RenewTxBuffer(Uint16 uiUpLoadDataType,Uint16 uiUpLoadDataFirstAddr,Uint16 uiUpLoadDataLength);

extern      void   MonitorSci_CommandIdentify_lin(void);
extern      void   MonitorSci_CrcCheck_lin(void);
extern      void   MonitorSci_CommandDeal_lin(void);
extern      void   MonitorSci_RenewTxBuffer_lin(Uint16 uiUpLoadDataType,Uint16 uiUpLoadDataFirstAddr,Uint16 uiUpLoadDataLength);

//==================================================================================================
//
//==================================================================================================

