/* @处根据实际情况填写相关信息，将@字符以及这条提示语句去掉 */
/******************************************************************************
|  File Name :  @文件名 
|  Description: @文件描述 
 *****************************************************************************/

/******************************************************************************
 * Description:     : Include File Section 									
******************************************************************************/
/* @包含其他文件 */
#include "r_cg_macrodriver.h"
#include "Dcm_DID_Cfg.h"
//#include "R_TypeDefs.h"
//#include "r_fdl_types.h"
//#include "eel.h"
#include "r_cg_userdefine.h"
#include "Dcm_extern.h"
#include "hwCtrl.h"
#include "appTask.h"

unsigned char DF_Read(unsigned char* read_buf,unsigned char data_num,unsigned char len);

/******************************************************************************
 * Description:     : Global Variable Definition Section 									
 ******************************************************************************/
/*@ 定义全局变量 */
extern uint16 adResult[7];
uint8 TempTxBuffer[40];

/******************************************************************************
 * Description:     : Static Variable Definition Section 									
 ******************************************************************************/

uint8 CaDcm_u_NRCData[DCM_NRCCOUNT] = {0x11,0x12,0x13,0x14,0x22,0x24,0x31,0x33,0x35,0x36,0x37,0x7F,0x72,0x71,0x73,0x78,0x7E};   /*27 负响应码数组*/

uint8 wBuf[20] = {0,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff,0};

/******************************************************************************
 * Description:     : Static Function Prototype Declaration									
 *****************************************************************************/
/*@静态函数声明*/
/******************************************************************************
 * Description:     : Write User Function Code								
 *****************************************************************************/
/*@函数头注释格式，所有函数头按照此格式注释*/
/******************************************************************************
 *函数名称    : @

 *参数        : @

 *返回值      : @

 *描述        : @

 *编辑时间    : @

 *备注        : @
 *****************************************************************************/
uint8 GetRTE_Dcm_DidServices_0x0200_ReadData(uint8* data)
{
	data[0] = *(__far uint8 *)DID_0200_ADDR;
 	if(data[0] != 0xFF)		//R_FDL_OK
		return DCM_CHECK_OK;
  	else
	  	return DCM_CHECK_NOK;
}

/******************************************************************************
 *函数名称    : @

 *参数        : @

 *返回值      : @

 *描述        : @

 *编辑时间    : @

 *备注        : @
 *****************************************************************************/
uint8 GetRTE_Dcm_DidServices_0x0201_ReadData(uint8* data)
{
	data[0] = *(__far uint8 *)DID_0201_ADDR;
 	if(data[0] != 0xFF)		//R_FDL_OK
		return DCM_CHECK_OK;
  	else
	  	return DCM_CHECK_NOK;
}


/******************************************************************************
 *函数名称    : @

 *参数        : @

 *返回值      : @

 *描述        : @

 *编辑时间    : @

 *备注        : @
 *****************************************************************************/
uint8 GetRTE_Dcm_DidServices_0xF110_ReadData(uint8* data)
{
	if( 0 == DF_Read(data,GetIndexNumber(INDEX_0xF110),8))		//R_FDL_OK
		return DCM_CHECK_OK;
  	else
	  	return DCM_CHECK_NOK;
}

/******************************************************************************
 *函数名称    : @

 *参数        : @

 *返回值      : @

 *描述        : @

 *编辑时间    : @

 *备注        : @
 *****************************************************************************/
uint8 GetRTE_Dcm_DidServices_0xF112_ReadData(uint8* data)
{
	if( 0 == DF_Read(data,GetIndexNumber(INDEX_0xF112),8))		//R_FDL_OK
		return DCM_CHECK_OK;
  	else
	  	return DCM_CHECK_NOK;
}

/******************************************************************************
 *函数名称    : @

 *参数        : @

 *返回值      : @

 *描述        : @

 *编辑时间    : @

 *备注        : @
 *****************************************************************************/
uint8  GetRTE_Dcm_DidServices_0xF197_ReadData(uint8* data)
{
  (void)data;
  data[0] = 	'M';
  data[1] = 	'S';
  data[2] = 	'W';
  data[3] = 	' ';
  data[4] = 	' ';
  data[5] = 	' ';
  return DCM_CHECK_OK;
}

/******************************************************************************
 *函数名称    : @

 *参数        : @

 *返回值      : @

 *描述        : @

 *编辑时间    : @

 *备注        : @
 *****************************************************************************/
uint8  GetRTE_Dcm_DidServices_0xF180_ReadData(uint8* data)
{
  __far uint8 *p = DID_F180_ADDR;
  (void)data; 
  data[0] = 	*p++;
  data[1] = 	*p++;
  data[2] = 	*p++;
  data[3] = 	*p++;
  data[4] = 	*p++;
  data[5] = 	*p++;
  data[6] = 	*p++;
  data[7] = 	*p++;
  data[8] = 	*p++;
  data[9] = 	*p++;
  return DCM_CHECK_OK;
}

/******************************************************************************
 *函数名称    : @

 *参数        : @

 *返回值      : @

 *描述        : @

 *编辑时间    : @

 *备注        : @
 *****************************************************************************/
uint8 GetRTE_Dcm_DidServices_0xF181_ReadData(uint8* data)
{
  (void)data;
  return DCM_CHECK_OK;
}


uint8 GetRTE_Dcm_DidServices_0xF183_ReadData(uint8* data)
{
  (void)data;
   return DCM_CHECK_OK;
}

#define DCM_DEFAULT_SESSION                       0x01       /*默认模式*/
#define DCM_PROGRAMME_SESSION                     0x02       /*编程模式*/
#define DCM_EXTEND_SESSION                        0x04       /*扩展模式*/
extern uint8 MngDcm_GetDiagnosticSession(void);
uint8 GetRTE_Dcm_DidServices_0xF186_ReadData(uint8* data)
{
  	uint8 temp = 0xFF;
  	
  	temp = MngDcm_GetDiagnosticSession();	/* 当前会话模式 */
  	
  	if(temp == DCM_DEFAULT_SESSION){
  		*data = 0x01;
  	}
  	else if(temp == DCM_PROGRAMME_SESSION){
  		*data = 0x02;
  	} 
  	else if(temp == DCM_EXTEND_SESSION){
  		*data = 0x03;
  	}
  	
  	if( 0xFF != temp)	
		return DCM_CHECK_OK;
  	else
	  	return DCM_CHECK_NOK;
}

uint8 GetRTE_Dcm_DidServices_0xF187_ReadData(uint8* data)
{
    (void)data;//5HY1-169500-6000
    data[0] = 	'5';
    data[1] = 	'H';
    data[2] = 	'Y';
    data[3] = 	'1';
    data[4] = 	'-';
    data[5] = 	'1';
    data[6] = 	'6';
    data[7] = 	'9';
    data[8] = 	'5';
    data[9] = 	'0';
    data[10] = 	'0';
    data[11] = 	'-';
    data[12] = 	'6';
    data[13] = 	'0';
    data[14] = 	'0';
    data[15] = 	'0';
    data[16] = 	' ';
    data[17] = 	' ';
    data[18] = 	' ';
    data[19] = 	' ';
    return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0xF189_ReadData(uint8* data)
{
  (void)data;
  data[0 ] = 	'C';
  data[1 ] = 	'4';
  data[2 ] = 	'0';
  data[3 ] = 	' ';
  data[4 ] = 	' ';
  data[5 ] = 	' ';
  data[6 ] = 	' ';
  data[7 ] = 	' ';
  data[8 ] = 	' ';
  data[9 ] = 	' ';
  data[10] = 	' ';
  data[11] = 	' ';
  data[12] = 	' ';
  data[13] = 	' ';
  data[14] = 	' ';
  data[15] = 	' ';
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0xF18A_ReadData(uint8* data)
{
    (void)data;
    data[0] = 	'Z';
    data[1] = 	'H';
    data[2] = 	'E';
    data[3] = 	'N';
    data[4] = 	'A';
    data[5] = 	'N';
    data[6] = 	' ';
    data[7] = 	' ';
    data[8] = 	' ';
    data[9] = 	' ';
    return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0xF18B_ReadData(uint8* data)
{
  (void)data;
  data[0] = 0x20;
  GetManufacturingDate(&data[1]);
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0xF190_ReadData(uint8* data)
{
 	(void *)data;
  
  	if(0 == DF_Read(data,GetIndexNumber(INDEX_0xF190),17))		//R_FDL_OK
		return DCM_CHECK_OK;
  	else
	  	return DCM_CHECK_NOK;
}

uint8 GetRTE_Dcm_DidServices_0xF191_ReadData(uint8* data)
{
    __far uint8 *p = DID_F193_ADDR;
    (void)data;
    data[0] = *p++;
    data[1] = *p++;
    data[2] = *p++;
    data[3] = *p++;
    data[4] = *p++;
    data[5] = *p++;
    data[6] = *p++;
    data[7] = *p++;
    data[8] = *p++;
    data[9] = *p++;
    return DCM_CHECK_OK;
}
uint8 GetRTE_Dcm_DidServices_0xF192_ReadData(uint8* data)
{
  (void)data;
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0xF193_ReadData(uint8* data)
{
	__far uint8 *p = DID_F193_ADDR;
	(void)data;
	*data++ = *p++;
	*data++ = *p++;
	*data++ = *p++;
	*data++ = *p++;
	*data++ = *p++;
	*data++ = *p++;
	*data++ = *p++;
	*data++ = *p++;
	*data++ = *p++;
    *data++ = *p++;
  	
//	GetHardwareVersion(data);

	return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0xF194_ReadData(uint8* data)
{
  (void)data;
  return DCM_CHECK_OK;
}
uint8 GetRTE_Dcm_DidServices_0xF195_ReadData(uint8* data)
{
  	GetSoftwareVersion(data);
  	return DCM_CHECK_OK;
}


uint8 GetRTE_Dcm_DidServices_0xF198_ReadData(uint8* data)
{
  	(void *)data; 
  	if(0 == DF_Read(data,GetIndexNumber(INDEX_0xF198),16))		//R_FDL_OK
		return DCM_CHECK_OK;
  	else
	  	return DCM_CHECK_NOK;
}


uint8 GetRTE_Dcm_DidServices_0xF199_ReadData(uint8* data)
{
  	(void)data;
  	if(0 == DF_Read(data,GetIndexNumber(INDEX_0xF199),4))		//R_FDL_OK
		return DCM_CHECK_OK;
  	else
	  	return DCM_CHECK_NOK;
}

uint8 GetRTE_Dcm_DidServices_0xF19D_ReadData(uint8* data)
{
  	(void)data;
  	if(0 == DF_Read(data,GetIndexNumber(INDEX_0xF19D),4))		//R_FDL_OK
		return DCM_CHECK_OK;
  	else
	  	return DCM_CHECK_NOK;
}

uint8 GetRTE_Dcm_DidServices_0x6300_ReadData(uint8* data)
{
  (void)data;
  *data = GetIoParameter(IO_TEMP);
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x6308_ReadData(uint8* data)
{
  (void)data;
  *data = GetIoParameter(IO_REC);
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x630B_ReadData(uint8* data)
{
  (void)data;
  *data = GetIoParameter(IO_FAN);
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x630C_ReadData(uint8* data)
{
  (void)data;
  *data = GetIoParameter(IO_MODE);
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x630D_ReadData(uint8* data)
{
  (void)data;
  *data = GetIoParameter(IO_DEFROST);
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x630F_ReadData(uint8* data)
{
  (void)data;
  *data = GetIoParameter(IO_AC);
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0xFD00_ReadData(uint8* data)
{
  (void)data;
  *data = GetIoParameter(IO_K30);
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0xF1A2_ReadData(uint8* data)
{
  (void)data;
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0xF1A2_WriteData(uint8* data)
{
  (void)data;
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0xF1A4_ReadData(uint8* data)
{
  (void)data;
  return DCM_CHECK_OK;
}


uint8 GetRTE_Dcm_DidServices_0xF1A5_ReadData(uint8* data)
{
  (void)data;
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0xF1A5_WriteData(uint8* data)
{
  (void)data;
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0xF1A6_ReadData(uint8* data)
{
  (void)data;
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0xF1A6_WriteData(uint8* data)
{
  (void)data;
  return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x061BReadData(uint8* data)
{
   (void)data;
    return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x061CReadData(uint8* data)
{
   (void)data;
    return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x061DReadData(uint8* data)
{
   (void)data;
    return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x061EReadData(uint8* data)
{
   (void)data;
    return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x061FReadData(uint8* data)
{
   (void)data;
    return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x0620ReadData(uint8* data)
{
   (void)data;
    return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x0621ReadData(uint8* data)
{
   (void)data;
    return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x0622ReadData(uint8* data)
{
   (void)data;
    return DCM_CHECK_OK;
}

uint8 GetRTE_Dcm_DidServices_0x1701ReadData(uint8* data)
{
    //getHallNum(data);
    return DCM_CHECK_OK;
}
uint8 GetRTE_Dcm_DidServices_0x1702ReadData(uint8* data)
{
    //getHallSoftStop(data);
    return DCM_CHECK_OK;
}
uint8 GetRTE_Dcm_DidServices_0x1706ReadData(uint8* data)
{
    //getMotorLearnState(data);
    return DCM_CHECK_OK;
}
uint8 GetRTE_Dcm_DidServices_0x1707ReadData(uint8* data)
{
    //getMotorCurrent(data);
    return DCM_CHECK_OK;
}
uint8 GetRTE_Dcm_DidServices_0x1708ReadData(uint8* data)
{
    //getInputStatus(data);
    return DCM_CHECK_OK;
}
uint8 GetRTE_Dcm_DidServices_0x1709ReadData(uint8* data)
{
    //getOutputStatus(data);
    return DCM_CHECK_OK;
}
uint8 GetRTE_Dcm_DidServices_0x170BReadData(uint8* data)
{
    getIGNVoltage(data);
    return DCM_CHECK_OK;
}

uint8 GetVehicel_u_SpeedVal(void)
{
  uint8 LeVehicle_U_Speed = 1;
  return LeVehicle_U_Speed;
}


/****************************************************************/
uint8 GetRTE_Dcm_DidServices_0xF110_WriteData(uint8* data)
{
	uint8 temp;
	for(temp = 0;temp < 8;temp++)
	{
		wBuf[temp] = data[temp];
	}
	temp = DF_Write(wBuf,GetIndexNumber(INDEX_0xF110),8);
	if(temp == 0)		//R_FDL_OK
		return DCM_CHECK_OK;
	else
		return DCM_CHECK_NOK;
}

/****************************************************************/
uint8 GetRTE_Dcm_DidServices_0xF112_WriteData(uint8* data)
{
	uint8 temp;
	for(temp = 0;temp < 8;temp++)
	{
		wBuf[temp] = data[temp];
	}
	temp = DF_Write(wBuf,GetIndexNumber(INDEX_0xF112),8);
	if(temp == 0)		//R_FDL_OK
		return DCM_CHECK_OK;
	else
		return DCM_CHECK_NOK;
}


uint8 GetRTE_Dcm_DidServices_0xF190_WriteData(uint8* data)
{
   uint8 temp;
  for(temp = 0;temp < 17;temp++)
  {
  	wBuf[temp] = data[temp];
  }
  temp = DF_Write(wBuf,GetIndexNumber(INDEX_0xF190),17);
  if(temp == 0)		//R_FDL_OK
	return DCM_CHECK_OK;
  else
	  return DCM_CHECK_NOK;
}

uint8 GetRTE_Dcm_DidServices_0xF197_WriteData(uint8* data)
{
   uint8 temp;
  for(temp = 0;temp < 8;temp++)
  {
  	wBuf[temp] = data[temp];
  }
  temp = DF_Write(wBuf,GetIndexNumber(INDEX_0xF197),8);
  if(temp == 0)		//R_FDL_OK
	return DCM_CHECK_OK;
  else
	  return DCM_CHECK_NOK;
}

uint8 GetRTE_Dcm_DidServices_0xF198_WriteData(uint8* data)
{
   uint8 temp;
  for(temp = 0;temp < 16;temp++)
  {
  	wBuf[temp] = data[temp];
  }
  temp = DF_Write(wBuf,GetIndexNumber(INDEX_0xF198),16);
  if(temp == 0)		//R_FDL_OK
	return DCM_CHECK_OK;
  else
	  return DCM_CHECK_NOK;
}

uint8 GetRTE_Dcm_DidServices_0xF199_WriteData(uint8* data)
{
   uint8 temp;
  for(temp = 0;temp < 4;temp++)
  {
  	wBuf[temp] = data[temp];
  }
  temp = DF_Write(wBuf,GetIndexNumber(INDEX_0xF199),4);
  if(temp == 0)		//R_FDL_OK
	return DCM_CHECK_OK;
  else
	  return DCM_CHECK_NOK;
}

uint8 GetRTE_Dcm_DidServices_0xF19D_WriteData(uint8* data)
{
   uint8 temp;
  for(temp = 0;temp < 4;temp++)
  {
  	wBuf[temp] = data[temp];
  }
  temp = DF_Write(wBuf,GetIndexNumber(INDEX_0xF19D),4);
  if(temp == 0)		//R_FDL_OK
	return DCM_CHECK_OK;
  else
	  return DCM_CHECK_NOK;
}


/****************************************************************/
uint8 GetRTE_Dcm_DidServices_0x6300_WriteData(uint8* data)
{
	uint8 temp;
	
	temp = *(data+1);
	WriteIoParameter(IO_TEMP,temp);
	
	return DCM_CHECK_OK;
}

/****************************************************************/
uint8 GetRTE_Dcm_DidServices_0x6308_WriteData(uint8* data)
{
	uint8 temp;
	
	temp = *(data+1);
	WriteIoParameter(IO_REC,temp);
	
	return DCM_CHECK_OK;
}

/****************************************************************/
uint8 GetRTE_Dcm_DidServices_0x630B_WriteData(uint8* data)
{
	uint8 temp;
	
	temp = *(data+1);
	WriteIoParameter(IO_FAN,temp);
	
	return DCM_CHECK_OK;
}

/****************************************************************/
uint8 GetRTE_Dcm_DidServices_0x630C_WriteData(uint8* data)
{
	uint8 temp;
	
	temp = *(data+1);
	WriteIoParameter(IO_MODE,temp);
	
	return DCM_CHECK_OK;
}

/****************************************************************/
uint8 GetRTE_Dcm_DidServices_0x630E_WriteData(uint8* data)
{
	uint8 temp;
	
	temp = *(data+1);
	WriteIoParameter(IO_REARDEF,temp);
	
	return DCM_CHECK_OK;
}

