#include "CAN_CH0_APP.h"
#include "CAN_CH0_Tx_Matirx.h"
#include "CAN_CH0_CAN_Communication_Matrix.h"
#include "CAN_CH1_CAN_Communication_Matrix.h"
#include "SGMCD1020Q.h"

void Can_Set_Buff_18FEF117(uint8_t CopyData[])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;
  if (Get_ID_18FFA017_Sig_Instrument_Igon_Wake_Up_Power() == 1)
  {
    /*3.7.2.1.1、手刹*/
    CopyData[0] |= (uint8_t)(Get_ID_18FFA017_Sig_Hand_Brake() << 2);
    /*3.7.2.1.2、车速*/
    CopyData[1] = (uint8_t)(Get_ID_18FE17EF_Sig_Speed() & 0xFFu);
    CopyData[2] = (uint8_t)((uint8_t)(Get_ID_18FE17EF_Sig_Speed() >> 8) & 0xFFu);
    /*3.7.2.1.3、脚刹*/
    /*规范错误*/
    CopyData[3] = 0;
  }

  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
}

void Can_Set_Buff_18FEF100(uint8_t CopyData [])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;
  if (Get_ID_18FFA017_Sig_Instrument_Igon_Wake_Up_Power() == 1)
  {
    /*3.7.2.2.1、手刹*/
    CopyData[0] |= (uint8_t)(Get_ID_18FFA017_Sig_Hand_Brake() << 2);
    /*3.7.2.2.2、车速*/
    CopyData[1] = (uint8_t)(Get_ID_18FE17EF_Sig_Speed() & 0xFFu);
    CopyData[2] = (uint8_t)((uint8_t)(Get_ID_18FE17EF_Sig_Speed() >> 8) & 0xFFu);
    /*3.7.2.1.3、脚刹*/
    /*规范错误*/
    CopyData[3] = 0;
  }

  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
}

void Can_Set_Buff_18F10117(uint8_t CopyData[])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;
  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
  if (Get_ID_18FFA017_Sig_Instrument_Igon_Wake_Up_Power() == 1)
  {
    /*3.7.2.3.1、干燥器排气信号  */
    CopyData[0] |= (uint8_t)(~SGMCD1020Q_2.bits.sg10 << 2);

    /*3.7.2.3.2、打气泵使能信号*/
    /*规范错误*/

    /*3.7.2.3.3、后仓门互锁*/
    CopyData[0] |= (uint8_t)(~SGMCD1020Q_3.bits.sg4 << 6);

    /*3.7.2.3.4、充电舱门互锁 */
    CopyData[1] = Get_ID_18FFA017_Sig_Charging_Door_Open();
    /*冷凝器电源输出状态*/
    /*规范错误*/
    /*3.7.2.3.6、空压机强打开关硬线信号输入*/
    CopyData[1] |= (uint8_t)(SGMCD1020Q_3.bits.sp3 << 4);
    /*3.7.2.3.7、乘客门*/
    CopyData[2] |= (uint8_t)(SGMCD1020Q_3.bits.sp1 << 6);
    /*3.7.2.3.8、乘客门（右前门）*/
    CopyData[3] |= (uint8_t)(~SGMCD1020Q_3.bits.sp1);
    /*3.7.2.3.9、转向灯信号（仪表转发给AEBS使用）*/
    /*规范错误*/
    /*3.7.2.3.10、后舱门状态*/
    CopyData[3] |= (uint8_t)(~SGMCD1020Q_3.bits.sg4 << 4);
    /*3.7.2.3.11、乘客门（右中门）*/
    CopyData[3] |= (uint8_t)(~SGMCD1020Q_3.bits.sp0 << 6);
    /*3.7.2.3.12、安全带状态*/
    CopyData[3] |= (uint8_t)(SGMCD1020Q_2.bits.sg10);
  }
}

void Can_Set_Buff_18FEAE17(uint8_t CopyData [])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;
  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
  if (Get_ID_18FFA017_Sig_Instrument_Igon_Wake_Up_Power() == 1)
  {
    /*3.7.2.4.1、后桥储气筒气压*/

    /*3.7.2.4.2、前桥储气筒气压*/


  }
}
/*8.21*/
void Can_Set_Buff_18FEAE30(uint8_t CopyData [])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;
  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
  if (Get_ID_18FFA017_Sig_Instrument_Igon_Wake_Up_Power() == 1)
  {
    /*3.7.2.5.1、后桥储气筒气压*/

    /*3.7.2.5.2、前桥储气筒气压*/

    
  }
}
/*8.21*/
void Can_Set_Buff_18F10217(uint8_t CopyData[])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;
  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
  if (Get_ID_18FFA017_Sig_Instrument_Igon_Wake_Up_Power() == 1)
  {
    /*3.7.2.6.1、前门开*/
    CopyData[0] |= (uint8_t)(SGMCD1020Q_3.bits.sp1);
    /*3.7.2.6.2、前门开电磁阀*/
    /*规范错误*/
    /*3.7.2.6.3、前门关*/
    CopyData[0] |= (uint8_t)(~SGMCD1020Q_3.bits.sg11 << 2);
    /*3.7.2.6.4、前门关电磁阀*/
    /*规范错误*/
    /*3.7.2.6.5、前门开状态*/
    CopyData[0] |= (uint8_t)(SGMCD1020Q_3.bits.sg11 << 4);
    /*3.7.2.6.6、中门开*/
    CopyData[0] |= (uint8_t)(~SGMCD1020Q_3.bits.sp0 << 5);
    /*3.7.2.6.7、中门开电磁阀*/
    /*规范错误*/
    /*3.7.2.6.8、中门关*/
    CopyData[0] |= (uint8_t)(~SGMCD1020Q_3.bits.sp0 << 7);
    /*3.7.2.6.9、中门关电磁阀*/
    /*规范错误*/
    /*3.7.2.6.10、中门开状态*/
    CopyData[1] |= (uint8_t)(SGMCD1020Q_3.bits.sp0 << 1);
    /*3.7.2.6.11、运动模式*/
    CopyData[3] |= (uint8_t)(SGMCD1020Q_1.bits.sp7 << 6);
    /*3.7.2.6.12、雪地模式*/
    CopyData[3] |= (uint8_t)(SGMCD1020Q_1.bits.sg13 << 7);
    /*3.7.2.6.13、空压机强打开关*/
    CopyData[1] |= (uint8_t)(SGMCD1020Q_3.bits.sp0 << 4);
    /*3.7.2.6.14、经济模式*/
    CopyData[4] |= (uint8_t)(SGMCD1020Q_1.bits.sg12 << 3);
  }
}

uint16_t ADC_U16 = 0;
uint16_t ADC_U48 = 0;
void Can_Set_Buff_18000001(uint8_t CopyData[])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;

  /*U16电流*/
  CopyData[0] = (uint8_t)(ADC_U16 & 0xFFu);
  CopyData[1] = (uint8_t)((uint8_t)(ADC_U16 >> 8) & 0xFFu);
  /*U48电流*/
  CopyData[2] = (uint8_t)(ADC_U48 & 0xFFu);
  CopyData[3] = (uint8_t)((uint8_t)(ADC_U48 >> 8) & 0xFFu);

  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
}
void Can_Set_Buff_0CFDCC17(uint8_t CopyData[])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;
  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
  if (Get_ID_18FFA017_Sig_Instrument_Igon_Wake_Up_Power() == 1)
  {
/*3.7.2.7.1、转向灯*/
    /*规范错误*/
/*3.7.2.7.2、危险指示灯*/
    CopyData[1] |= (uint8_t)(Get_ID_18FFA017_Sig_Danger_Lights() << 4);
/*3.7.2.7.3、远近光灯*/
    /*规范错误*/
  }

}
void Can_Set_Buff_0CFEC317(uint8_t CopyData[])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;
  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
  if (Get_ID_18FFA017_Sig_Instrument_Igon_Wake_Up_Power() == 1)
  {
    /*倒挡信号*/
    /*规范有问题*/
  }
}
void Can_Set_Buff_0CD22F27(uint8_t CopyData[])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;
  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
  if (Get_ID_18FFA017_Sig_Instrument_Igon_Wake_Up_Power() == 1)
  {
    /*3.7.2.9.1、ECAS复位*/
    if (SGMCD1020Q_2.bits.sg3 == 1)
    {
      CopyData[1] = 0x11;
    }
    else
    {
      if ((SGMCD1020Q_3.bits.sp3 == 0) && (Get_ID_18FF4AEF_Sig_Power_On_High_Voltage_Indicator != 1) && ((Get_ID_0CFE5A2F_Sig_ECAS_Kneeling_Work_Light == 1) || (Get_ID_0CFE5A2F_Sig_ECAS_Kneeling_Work_Light == 2) || (Get_ID_0CFE5A2F_Sig_ECAS_Kneeling_Work_Light == 3)))
      {
        CopyData[1] = 0x11;
      }
    }
    /*3.7.2.9.2、ECAS上升*/
    if (SGMCD1020Q_3.bits.sp7 == 1)
    {
      CopyData[1] = 0x77;
    }
    /*3.7.2.9.3、ECAS下降*/
    if (SGMCD1020Q_3.bits.sp6 == 0)
    {
      CopyData[1] = 0x66;
    }
    /*3.7.2.9.4、ECAS侧跪*/
    if (SGMCD1020Q_1.bits.sp0 == 0)
    {
      CopyData[0] |= 0x10;
    }
    else
    {
      if ((SGMCD1020Q_3.bits.sp3 == 0) && (Get_ID_18FF4AEF_Sig_Power_On_High_Voltage_Indicator == 1) && ((SGMCD1020Q_3.bits.sp1 == 1) || (SGMCD1020Q_3.bits.sp0 == 1)))
      {
        CopyData[0] |= 0x10;
      }
    }
  }
}
void Can_Set_Buff_18FAB017(uint8_t CopyData[])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;
  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
  if (Get_ID_18FFA017_Sig_Instrument_Igon_Wake_Up_Power() == 1)
  {
    /*3.7.2.10.1、自动雨量*/
    if (SGMCD1020Q_1.bits.sg5 == 1)
    {
      CopyData[0] = 1;
    }
    /*3.7.2.10.2、雨刮复位*/
    if (SGMCD1020Q_1.bits.sg2 == 1)
    {
      CopyData[0] |= 2;
    }
    /*3.7.2.10.3、雨刮灵敏度*/
    CopyData[0] |= 4;
    /*3.7.2.10.4、雨刮手动状态*/
    if (SGMCD1020Q_1.bits.sg10 == 1)
    {
      CopyData[0] |= 0x10;
    }
    /*3.7.2.10.5、洗涤开关*/
    /*规范有问题*/
    /*3.7.2.10.6、自动灯光*/
    if (SGMCD1020Q_1.bits.sg5 == 0)
    {
      CopyData[0] |= 0x40;
    }
    /*3.7.2.10.7、车速*/
    CopyData[1] = (uint8_t)(Get_ID_18FE17EF_Sig_Speed() & 0xFFu);
    CopyData[2] = (uint8_t)((uint8_t)(Get_ID_18FE17EF_Sig_Speed() >> 8) & 0xFFu);
  }
}
void Can_Set_Buff_18FF0121(uint8_t CopyData[])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;
  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
  if (Get_ID_18FFA017_Sig_Instrument_Igon_Wake_Up_Power() == 1)
  {
    /*3.7.2.11.1、蓄电池舱温报警*/
    if (SGMCD1020Q_2.bits.sp4 == 1)
    {
      CopyData[0] = 1;
    }
    /*3.7.2.11.2、解除门开制动指令*/
    if (SGMCD1020Q_2.bits.sg11 == 0)
    {
      CopyData[0] |= 4;
    }
    /*3.7.2.11.3、驾驶员安全带未系信号*/
    if (SGMCD1020Q_2.bits.sg12 == 0)
    {
      CopyData[0] |= 0x10;
    }
    /*3.7.2.11.4、驾驶员离座报警信号*/
    if (SGMCD1020Q_2.bits.sp7 == 1)
    {
      CopyData[0] |= 0x40;
    }
    /*3.7.2.11.5、前门应急阀开盖报警开关*/
    if (SGMCD1020Q_2.bits.sp6 == 0)
    {
      CopyData[1] = 1;
    }
    /*3.7.2.11.6、前门应急阀旋转报警开关*/
    if (SGMCD1020Q_2.bits.sp5 == 0)
    {
      CopyData[1] |= 4;
    }
    /*3.7.2.11.7、门泵气压低报警开关*/
    if (SGMCD1020Q_3.bits.sp5 == 0)
    {
      CopyData[1] |= 0x10;
    }
    /*3.7.2.11.8、下车提示铃stop指示灯*/
    if (SGMCD1020Q_3.bits.sg3 == 0)
    {
      CopyData[1] |= 0x40;
    }
    /*3.7.2.11.9、前门开信号*/
    if (SGMCD1020Q_3.bits.sp1 == 1)
    {
      CopyData[2] = 1;
    }
    /*3.7.2.11.10、中门开信号*/
    if (SGMCD1020Q_3.bits.sp0 == 1)
    {
      CopyData[2] |= 4;
    }
    /*3.7.2.11.11、暖风散热水位过低开关*/
    if (SGMCD1020Q_3.bits.sg2 == 0)
    {
      CopyData[2] |= 0x10;
    }
    /*3.7.2.11.12、电机低水位报警开关*/
    if (SGMCD1020Q_3.bits.sg1 == 0)
    {
      CopyData[2] |= 0x40;
    }
    /*3.7.2.11.13、中门应急阀开盖报警开关*/
    if (SGMCD1020Q_3.bits.sg0 == 0)
    {
      CopyData[3] = 1;
    }
    /*3.7.2.11.14、中门应急阀旋转报警开关*/
    if (SGMCD1020Q_2.bits.sg13 == 0)
    {
      CopyData[3] = 4;
    }
    /*3.7.2.11.15、前门锁止信号*/
    if (SGMCD1020Q_3.bits.sg6 == 0)
    {
      CopyData[3] |= 0x10;
    }
    /*3.7.2.11.16、中门锁止信号*/
    if (SGMCD1020Q_3.bits.sg5 == 0)
    {
      CopyData[3] |= 0x40;
    }
  }
}
void Can_Set_Buff_18FF0221(uint8_t CopyData[])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;
  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
  if (Get_ID_18FFA017_Sig_Instrument_Igon_Wake_Up_Power() == 1)
  {
    /*3.7.2.12.1、燃油液位传感器*/
    /*MCU_RIN2采集*/
    CopyData[0] = 0;
    /*3.7.2.12.2、气压1*/
    CopyData[1] = 0;
    /*3.7.2.12.3、气压2*/
    CopyData[2] = 0;
  }
}
void Can_Set_Buff_18FF0321(uint8_t CopyData[])
{
  CopyData[0] = 0;
  CopyData[1] = 0;
  CopyData[2] = 0;
  CopyData[3] = 0;
  CopyData[4] = 0;
  CopyData[5] = 0;
  CopyData[6] = 0;
  CopyData[7] = 0;
  if (Get_ID_18FFA017_Sig_Instrument_Igon_Wake_Up_Power() == 1)
  {
    /*3.7.2.13.1、示廓灯/位置灯(输出)*/
    /*规范有问题*/
    /*3.7.2.13.2、右前转向灯(输出)*/
    /*规范有问题*/
    /*3.7.2.13.3、左前转向灯(输出)*/
    /*规范有问题*/
    /*3.7.2.13.4、近光灯(输出)*/
    /*规范有问题*/
    /*3.7.2.13.5、远光灯(输出)*/
    /*规范有问题*/
    /*3.7.2.13.6、前雾灯(输出)*/
    /*规范有问题*/
    /*3.7.2.13.7、后雾灯(输出)*/
    /*规范有问题*/
    /*3.7.2.13.8、空压机使能(输出)*/
    /*规范有问题*/
  }
}