2024-01-30 03:31:27 +00:00
|
|
|
|
#include "Err_code.h"
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#define Err_MAX_SingleEVENTS 5 //<2F><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD> MAX_SingleEVENTS-1
|
|
|
|
|
void add_event(uint8_t event);
|
|
|
|
|
static int32_t Err_front = 0;
|
|
|
|
|
static int32_t Err_rear = 0;
|
|
|
|
|
|
|
|
|
|
uint8_t Err_Code_BitMap[Err_Code_Max] = {0};
|
|
|
|
|
static uint8_t event_queue[Err_MAX_SingleEVENTS];
|
|
|
|
|
|
|
|
|
|
const ErrCode_info ErrCode_info_Table[] = {
|
|
|
|
|
{0, "δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|
|
|
|
{1, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|
|
|
|
{2, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|
|
|
|
{3, "ֱ<EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|
|
|
|
{4, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|
|
|
|
{5, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|
|
|
|
{6, "SOC 100%"},
|
|
|
|
|
{7, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFB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S<EFBFBD>ȹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣"},
|
|
|
|
|
{31, "BMS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧЧ"},
|
|
|
|
|
{32, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|
|
|
|
{33, "VCU<EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|
|
|
|
{34, "VCU<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>쳣"},
|
|
|
|
|
{36, "BMSͨѶ<EFBFBD><EFBFBD>ʱ"},
|
|
|
|
|
{37, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨѶ<EFBFBD><EFBFBD>ʱ"},
|
|
|
|
|
{38, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD>ϸ<EFBFBD>ѹ"},
|
|
|
|
|
{39, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|
|
|
|
{40, "CML <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|
|
|
|
{41, "CCS <20><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>"},
|
|
|
|
|
{42, "KL30<EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|
|
|
|
{43, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const struct Err_shine Fault_type_Table[Fault_typeSDDC_Len] = {
|
|
|
|
|
{0,7},
|
|
|
|
|
{7,2},
|
|
|
|
|
{9,3},
|
|
|
|
|
{12,2},
|
|
|
|
|
{14,2},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>Ĵ<EFBFBD>С
|
|
|
|
|
const size_t ErrCode_info_Table_Size = sizeof(ErrCode_info_Table) / sizeof(ErrCode_info);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static __inline uint8_t GetArr_NUM(uint8_t Err_NUM)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return Err_NUM/8;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static __inline uint8_t GetArr_Bit(uint8_t Err_NUM)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return Err_NUM%8;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Err_Set(uint8_t Err_NUM)
|
|
|
|
|
{
|
|
|
|
|
#ifdef __Err_Debug__
|
|
|
|
|
if(Err_NUM>=Err_Code_Max_NUM)//<2F><><EFBFBD>õ<EFBFBD>Err_NUM<55><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
return false;
|
|
|
|
|
#endif
|
|
|
|
|
if(Err_Read(Err_NUM) == false)
|
|
|
|
|
{
|
|
|
|
|
add_event(Err_NUM);
|
|
|
|
|
}
|
|
|
|
|
uint8_t Arr_Num = GetArr_NUM(Err_NUM);
|
|
|
|
|
uint8_t Bit_Num = GetArr_Bit(Err_NUM);
|
|
|
|
|
|
|
|
|
|
Err_Code_BitMap[Arr_Num] |= 1<< Bit_Num;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Find_FaultCode_Location(uint8_t Err_NUM)
|
|
|
|
|
{
|
|
|
|
|
for(uint8_t i=0;i<Err_MAX_SingleEVENTS;i++)
|
|
|
|
|
{
|
|
|
|
|
if(event_queue[i] == Err_NUM)
|
|
|
|
|
{
|
|
|
|
|
event_queue[i] = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Err_Clear(uint8_t Err_NUM)
|
|
|
|
|
{
|
|
|
|
|
#ifdef __Err_Debug__
|
|
|
|
|
if(Err_NUM>=Err_Code_Max_NUM)//<2F><><EFBFBD>õ<EFBFBD>Err_NUM<55><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
return false;
|
|
|
|
|
#endif
|
|
|
|
|
uint8_t Arr_Num = GetArr_NUM(Err_NUM);
|
|
|
|
|
uint8_t Bit_Num = GetArr_Bit(Err_NUM);
|
|
|
|
|
|
|
|
|
|
Find_FaultCode_Location(Err_NUM);
|
|
|
|
|
Err_Code_BitMap[Arr_Num] &= 0<< Bit_Num;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Err_Read(uint8_t Err_NUM)
|
|
|
|
|
{
|
|
|
|
|
uint8_t Arr_Num = GetArr_NUM(Err_NUM);
|
|
|
|
|
uint8_t Bit_Num = GetArr_Bit(Err_NUM);
|
|
|
|
|
|
|
|
|
|
uint8_t Err_State = Err_Code_BitMap[Arr_Num] & (1<< Bit_Num);
|
|
|
|
|
|
|
|
|
|
if(Err_State)
|
|
|
|
|
return true;//<2F><><EFBFBD>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//<2F>Ƿ<EFBFBD><C7B7>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
bool Err_Check()
|
|
|
|
|
{
|
|
|
|
|
for(uint8_t i = 0;i<Err_Code_Max;i++)
|
|
|
|
|
{
|
|
|
|
|
if(Err_Code_BitMap[i] != 0)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
bool Err_Traverse()
|
|
|
|
|
{
|
|
|
|
|
for(uint8_t i = 0;i<Err_Code_Max;i++)
|
|
|
|
|
{
|
|
|
|
|
if(Err_Code_BitMap[i] != 0)
|
|
|
|
|
{
|
|
|
|
|
for(uint8_t j=0;j<8;j++)
|
|
|
|
|
{
|
|
|
|
|
if(Err_Code_BitMap[i]&(1<<j))
|
|
|
|
|
{
|
|
|
|
|
uint8_t ErrCode = i*8 + j;
|
|
|
|
|
printf("ErrCode is %d\r\n",ErrCode);
|
|
|
|
|
// uint8_t ErrLen = ARRAY_LENGTH(ErrCode_info_Table);
|
|
|
|
|
// for(uint8_t k=0;k<ErrLen;k++)
|
|
|
|
|
// {
|
|
|
|
|
// if(ErrCode_info_Table[k].index == ErrCode)
|
|
|
|
|
// {
|
|
|
|
|
// printf("Error Code InFo is %s\r\n",ErrCode_info_Table[k].data);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ѯ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڷּ<DAB7><D6BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//return true <20><><EFBFBD>ڶ<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD> false û<>ж<EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>
|
|
|
|
|
bool Err_ScanHierarchical_fault(enum Fault_typeSDDC Fault_type)
|
|
|
|
|
{
|
|
|
|
|
if(Fault_type >= Fault_typeSDDC_Len)
|
|
|
|
|
{
|
|
|
|
|
printf("ERR SACN Hierarchical ERR!!\r\n");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
uint8_t Star_Arr = Fault_type_Table[Fault_type].Star_Num;//<2F><><EFBFBD><EFBFBD><EFBFBD>鱻<EFBFBD><E9B1BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>flash<73><68>,<2C><>ȡ<EFBFBD><C8A1>R3R4<52><34><EFBFBD><EFBFBD>
|
|
|
|
|
uint8_t Arr_len = Fault_type_Table[Fault_type].Err_shine_len;
|
|
|
|
|
for(uint8_t i= 0;i<Arr_len;i++)
|
|
|
|
|
{
|
|
|
|
|
if(Err_Code_BitMap[Star_Arr+i] != 0)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool is_queue_empty(void) {
|
|
|
|
|
return Err_front == Err_rear;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool is_queue_full() {
|
|
|
|
|
return Err_front == (Err_rear + 1) % Err_MAX_SingleEVENTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void add_event(uint8_t event) {
|
|
|
|
|
if (is_queue_full()) {
|
|
|
|
|
printf("Event queue is full\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
event_queue[Err_rear] = event;
|
|
|
|
|
Err_rear = (Err_rear + 1) % Err_MAX_SingleEVENTS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ErrGetSequence(void)
|
|
|
|
|
{
|
|
|
|
|
while (!is_queue_empty())
|
|
|
|
|
{
|
|
|
|
|
printf("Err NUM is %d\r\n",event_queue[Err_front]);
|
|
|
|
|
Err_front = (Err_front + 1) % Err_MAX_SingleEVENTS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Print_Err(void)
|
|
|
|
|
{
|
|
|
|
|
for(uint8_t i=0;i<Err_MAX_SingleEVENTS;i++)
|
|
|
|
|
{
|
|
|
|
|
if(event_queue[i] > 0)
|
|
|
|
|
{
|
|
|
|
|
ErrGetSequence();
|
|
|
|
|
uint8_t ErrLen = ARRAY_LENGTH(ErrCode_info_Table);
|
|
|
|
|
for(uint8_t k=0;k<ErrLen;k++)
|
|
|
|
|
{
|
|
|
|
|
if(ErrCode_info_Table[k].index == event_queue[i])
|
|
|
|
|
{
|
|
|
|
|
printf("Error Code InFo is %s\r\n",ErrCode_info_Table[k].data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ErrClearSequence(void)
|
|
|
|
|
{
|
|
|
|
|
memset(Err_Code_BitMap,0,Err_Code_Max);//<2F><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
memset(event_queue,0, Err_MAX_SingleEVENTS);
|
|
|
|
|
Err_front = 0;
|
|
|
|
|
Err_rear = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|