#ifndef BMS_RUN_STATUS_H_
#define BMS_RUN_STATUS_H_

#ifdef __cplusplus
extern "C" {
#endif 

#include "kit_macro.h"

typedef enum{
	kRunCtrl_Start = 0,
	kRunCtrl_Self = kRunCtrl_Start, //就地
	kRunCtrl_Cmd,	                //远程
	kRunCtrl_End
}RunCtrl;//上下电模式枚举

//BMS工作模式
typedef enum
{
	kRunStatus_Dis,		//BMS放电中 0
	kRunStatus_Chg,		//BMS充电中 1
	kRunStatus_Init, //2 
    kRunStatus_Standby,// 3
	kRunStatus_PwrOff,
    kRunStatus_Stop, //急停
    kRunStatus_End,
}RunStatus;


typedef enum
{
	kRunStatusBasis_Start = 0,
	kRunStatusBasis_Cur = kRunStatusBasis_Start,
	kRunStatusBasis_Cmd,
	kRunStatusBasis_CC2,
	kRunStatusBasis_End
}RunStatusBasis;

typedef enum
{
    kCircuitStatus_Off,
    kCircuitStatus_On,
}CircuitStatus;

typedef enum
{
    kCircuitType_Chg,
    kCircuitType_Dis,
    kCircuitType_Main,
    kCircuitType_End,
}CircuitType;


void bms_init_run(void);
void bms_poll_run_status(uint32_t base_time);
RunStatus bms_get_run_status(void);
RunStatusBasis bms_get_run_status_basis(void);
uint8_t bms_get_bus_bar_bcu(void);
void bms_set_bus_bar_bcu(uint8_t idx);

void bms_clear_cmd_heartbeat(void);
uint16_t bms_get_cmd_heartbeat(void);
CircuitStatus bms_get_circuit_cmd_status(void); 
CircuitStatus bms_get_circuit_status(CircuitType type);    
void bms_set_circuit_status(CircuitType type, CircuitStatus st);  
void bms_set_circuit_cmd_status(CircuitStatus st);

bool bms_is_chg_allow(void);
bool bms_is_dis_allow(void);

bool bms_is_bus_bar_bcu(void);
bool bms_is_circuit_allow(void);
bool bms_is_dis_circuit_allow(void);
bool bms_is_chg_circuit_allow(void);

bool bms_is_single_full_chg(void);
void bms_set_single_full_chg_status(bool is_en);

#ifdef __cplusplus
}
#endif

#endif
