BBox_Bcu.c 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #include <BBox_Bcu.h>
  2. static process_Rte gProcess_Rte_Task;
  3. #define PROC_RTE_STATE_SWITCH(a) (gProcess_Rte_Task = a)
  4. //=========================================================================
  5. //=========================================================================
  6. //=========================================================================
  7. void BBox_BCU_Task(void *pvParameters)
  8. {
  9. uint16_T i;
  10. uint16_T RecvCounter = 0;
  11. static boolean_T Flg;
  12. //鍚姩寤惰繜娌″仛
  13. PROC_RTE_STATE_SWITCH(PROCESS_STATE_INIT);
  14. while (true)
  15. {
  16. switch (gProcess_Rte_Task)
  17. {
  18. //=========================鍒濆鍖�===============================
  19. case PROCESS_STATE_INIT:
  20. {
  21. BCU_initialize();
  22. BCUEEDataRead();
  23. PROC_RTE_STATE_SWITCH(PROCESS_STATE_WORK);
  24. break;
  25. }
  26. //============================宸ヤ綔妯″紡==========================
  27. case PROCESS_STATE_WORK:
  28. {
  29. if (TimerCounter % 100 == 0 && BBox_DataReadyFlag==1)
  30. {
  31. IH_Data_Update();
  32. /*
  33. bswv_V_cellU = 0;
  34. bswv_T_modT = 0;
  35. bswd_tm_month = 0;
  36. bswd_tm_day = 0;
  37. bswd_tm_hour = 0;
  38. bswd_tm_min = 0;
  39. bswd_tm_sec = 0;
  40. bswd_tm_year = 0;
  41. hvmd_st_operMod_T1 = 0;
  42. dcmd_st_chrgMod_T1 = 0;
  43. dcmd_st_chrgSts_T1 = 0;
  44. ihd_I_battCurr_T1 = 0;
  45. ihd_V_battU_T1 = 0;
  46. */
  47. // Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_OFF);
  48. BCU_step();
  49. //
  50. if (socd_flg_EEsave == 1)
  51. {
  52. BCUEEDataSave();
  53. }
  54. // Dio_WriteChannel(DioConf_DioChannel_PTE7_GPIO_OUT_MCU_LED3, STD_ON);
  55. OH_Data_Update();
  56. }
  57. vTaskDelay(pdMS_TO_TICKS(10));
  58. break;
  59. }
  60. default:
  61. {
  62. PROC_RTE_STATE_SWITCH(PROCESS_STATE_INIT);
  63. break;
  64. }
  65. }
  66. }
  67. }
  68. //=========================鏁版嵁瀛樺偍========================================
  69. void BCUEEDataRead(void)
  70. {
  71. // memset(rtev_flg_EESt, 0, sizeof(rtev_flg_EESt));
  72. //时间
  73. ihd_tm_yearEi = BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_yearE;
  74. ihd_tm_monthEi = BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_monthE;
  75. ihd_tm_dayEi = BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_dayE;
  76. ihd_tm_hourEi = BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_hourE;
  77. ihd_tm_minEi = BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_minE;
  78. ihd_tm_secEi = BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_secE;
  79. //SOC
  80. socd_pct_bcuSocEi = BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_bcuSocE;
  81. socd_pct_battSocEi = BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_battSocE;
  82. sohd_pct_bcuSoh = BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_pct_bcuSohE;
  83. /*/SOH
  84. sohd_flg_countEi = BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_flg_countE;
  85. sohd_Q_chrgEi = BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_Q_chrgE;
  86. memcpy(sohv_Q_cellCapEi, BcuSaveDataInfo.BcuAppSaveDataInfo.sohv_Q_cellCapE, sizeof(sohv_Q_cellCapEi));
  87. memcpy(sohv_V_cellUEi, BcuSaveDataInfo.BcuAppSaveDataInfo.sohv_V_cellUE, sizeof(sohv_V_cellUEi));
  88. memcpy(sohv_Q_packCapEi, BcuSaveDataInfo.BcuAppSaveDataInfo.sohv_Q_packCapE, sizeof(sohv_Q_packCapEi));
  89. //SOR
  90. memcpy(sorv_ohm_cellREi, BcuSaveDataInfo.BcuAppSaveDataInfo.sorv_ohm_cellRE, sizeof(sorv_ohm_cellREi));
  91. //BLC
  92. memcpy(blcv_Q_totalCpEi, BcuSaveDataInfo.BcuAppSaveDataInfo.blcv_Q_totalCpE, sizeof(blcv_Q_totalCpEi));
  93. memcpy(blcv_Q_reqCpEi, BcuSaveDataInfo.BcuAppSaveDataInfo.blcv_Q_reqCpE, sizeof(blcv_Q_reqCpEi));
  94. //ISC
  95. iscd_tm_chrgEi = BcuSaveDataInfo.BcuAppSaveDataInfo.iscd_tm_chrgE;
  96. iscd_tm_staticEi = BcuSaveDataInfo.BcuAppSaveDataInfo.iscd_tm_staticE;
  97. memcpy(iscv_ohm_chrgEi, BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_ohm_chrgE, sizeof(iscv_ohm_chrgEi));
  98. memcpy(iscv_ohm_staticEi, BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_ohm_staticE, sizeof(iscv_ohm_staticEi));
  99. memcpy(iscv_Q_chrgEi, BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_Q_chrgE, sizeof(iscv_Q_chrgEi));
  100. memcpy(iscv_Q_staticEi, BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_Q_staticE, sizeof(iscv_Q_staticEi));
  101. *///DAM
  102. //uint16
  103. damd_Nr_totalStaChrgEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Nr_totalStaChrgE;
  104. damd_Nr_totalChgEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Nr_totalChgE;
  105. damd_Nr_totalVehChrgEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Nr_totalVehChrgE ;
  106. //float
  107. damd_Q_totalChrgCpEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalChrgCpE;
  108. damd_E_totalChrgEngEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalChrgEngE;
  109. damd_Q_totalRegenCpEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalRegenCpE;
  110. damd_E_totalRegenEngEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalRegenEngE;
  111. damd_Q_totalDisChrgCpEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalDisChrgCpE;
  112. damd_E_totalDisChrgEngEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalDisChrgEngE;
  113. damd_Q_totalVehChrgCpEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalVehChrgCpE;
  114. damd_E_totalVehChrgEngEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalVehChrgEngE;
  115. damd_Q_totalSatChrgCpEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalSatChrgCpE ;
  116. damd_E_totalSatChrgEngEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalSatChrgEngE;
  117. }
  118. void BCUEEDataSave(void)
  119. {
  120. BcuSaveDataInfo.BcuAppSaveDataInfo.bcuSaveFlg = TRUE;
  121. //
  122. BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_yearE = ihd_tm_yearEo;
  123. BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_monthE = ihd_tm_monthEo;
  124. BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_dayE = ihd_tm_dayEo;
  125. BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_hourE = ihd_tm_hourEo;
  126. BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_minE = ihd_tm_minEo;
  127. BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_secE = ihd_tm_secEo;
  128. //SOC
  129. BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_bcuSocE = socd_pct_bcuSocEo;
  130. BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_battSocE = socd_pct_battSocEo;
  131. BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_pct_bcuSohE = sohd_pct_bcuSoh;
  132. /*/SOH
  133. BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_flg_countE = sohd_flg_countEo;
  134. BcuSaveDataInfo.BcuAppSaveDataInfo.sohd_Q_chrgE = sohd_Q_chrgEo;
  135. memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.sohv_Q_cellCapE, sohv_Q_cellCapEo,sizeof(sohv_Q_cellCapEo));
  136. memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.sohv_V_cellUE,sohv_V_cellUEo, sizeof(sohv_V_cellUEo));
  137. memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.sohv_Q_packCapE,sohv_Q_packCapEo, sizeof(sohv_Q_packCapEo));
  138. //SOR
  139. memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.sorv_ohm_cellRE,sorv_ohm_cellREo, sizeof(sorv_ohm_cellREo));
  140. //BLC
  141. memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.blcv_Q_totalCpE, blcv_Q_totalCpEo,sizeof(blcv_Q_totalCpEo));
  142. memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.blcv_Q_reqCpE, blcv_Q_reqCpEo,sizeof(blcv_Q_reqCpEo));
  143. //ISC
  144. BcuSaveDataInfo.BcuAppSaveDataInfo.iscd_tm_chrgE = iscd_tm_chrgEo;
  145. BcuSaveDataInfo.BcuAppSaveDataInfo.iscd_tm_staticE = iscd_tm_staticEo;
  146. memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_ohm_chrgE, iscv_ohm_chrgEo,sizeof(iscv_ohm_chrgEo));
  147. memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_ohm_staticE, iscv_ohm_staticEo,sizeof(iscv_ohm_staticEo));
  148. memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_Q_chrgE, iscv_Q_chrgEo,sizeof(iscv_Q_chrgEo));
  149. memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_Q_staticE, iscv_Q_staticEo,sizeof(iscv_Q_staticEo));
  150. *///DAM
  151. //uint16
  152. BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Nr_totalStaChrgE = damd_Nr_totalStaChrgEo;
  153. BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Nr_totalChgE = damd_Nr_totalChgEo;
  154. BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Nr_totalVehChrgE = damd_Nr_totalVehChrgEo;
  155. //float
  156. BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalChrgCpE = damd_Q_totalChrgCpEo;
  157. BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalChrgEngE = damd_E_totalChrgEngEo;
  158. BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalRegenCpE = damd_Q_totalRegenCpEo;
  159. BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalRegenEngE = damd_E_totalRegenEngEo;
  160. BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalDisChrgCpE = damd_Q_totalDisChrgCpEo;
  161. BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalDisChrgEngE = damd_E_totalDisChrgEngEo;
  162. BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalVehChrgCpE = damd_Q_totalVehChrgCpEo;
  163. BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalVehChrgEngE = damd_E_totalVehChrgEngEo;
  164. BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalSatChrgCpE = damd_Q_totalSatChrgCpEo;
  165. BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalSatChrgEngE = damd_E_totalSatChrgEngEo;
  166. }