1#include "AMSInterface.h"
8 can_msg.id = pack_function(structure, can_msg.buf, &can_msg.len, (uint8_t*) &can_msg.flags.extended);
9 uint8_t buf[
sizeof(CAN_message_t)] = {};
10 memmove(buf, &can_msg,
sizeof(CAN_message_t));
11 msg_queue_->push_back(buf,
sizeof(CAN_message_t));
81 float lowest_voltage = HYTECH_low_voltage_ro_fromS(
bms_voltages_.low_voltage_ro);
98 charge_ -= (current * delta_time_micros) / 1000000;
104 unsigned long delta_time_micros =
tick.micros -
last_tick_.micros;
142 STATE_OF_CHARGE_t soc_struct;
143 soc_struct.charge_percentage_ro = HYTECH_charge_percentage_ro_toS(
SoC_);
144 soc_struct.charge_coulombs_ro = HYTECH_charge_coulombs_ro_toS(
charge_);
146 enqueue_new_CAN<STATE_OF_CHARGE_t>(&soc_struct, Pack_STATE_OF_CHARGE_hytech);
162 Unpack_BMS_VOLTAGES_hytech(&
bms_voltages_, can_msg.buf, can_msg.len);
181 float voltage_lim_factor = 1.0;
182 float startDerateVoltage = 3.5;
183 float endDerateVoltage = 3.2;
184 float voltage_lim_max = 1;
185 float voltage_lim_min = 0.2;
187 float temp_lim_factor = 1.0;
188 float startDerateTemp = 50;
189 float stopDerateTemp = 58;
190 float temp_lim_max = 1;
191 float temp_lim_min = 0.2;
195 voltage_lim_factor = (
filtered_min_cell_voltage - startDerateVoltage) * (voltage_lim_min - voltage_lim_max) / (endDerateVoltage - startDerateVoltage) + voltage_lim_max;
196 voltage_lim_factor = max(min(voltage_lim_max, voltage_lim_factor), voltage_lim_min);
198 temp_lim_factor = (
filtered_max_cell_temp - startDerateTemp) * (temp_lim_min - temp_lim_max) / (stopDerateTemp - startDerateTemp) + temp_lim_max;
199 temp_lim_factor = max(min(temp_lim_factor, temp_lim_max), temp_lim_min);
float get_acc_derate_factor()
bool has_initialized_charge_
void tick(const SysTick_s &tick)
BMS_VOLTAGES_t bms_voltages_
float filtered_min_cell_voltage
void retrieve_current_shunt_CAN(const CAN_message_t &can_msg)
void set_heartbeat(unsigned long curr_millis)
BMS_temperatures bms_temperatures_
float get_filtered_min_cell_voltage()
ACU_SHUNT_MEASUREMENTS_t acu_shunt_measurements_
bool is_below_pack_charge_critical_total_thresh()
void init(SysTick_s &initial_tick)
void retrieve_status_CAN(unsigned long curr_millis, CAN_message_t &recvd_msg)
void retrieve_temp_CAN(CAN_message_t &recvd_msg)
void enqueue_new_CAN(U *structure, uint32_t(*pack_function)(U *, uint8_t *, uint8_t *, uint8_t *))
unsigned long last_heartbeat_time_
bool heartbeat_received(unsigned long curr_millis)
void calculate_SoC_acu(const SysTick_s &tick)
float get_filtered_max_cell_temp()
unsigned long timestamp_start_
void set_state_ok_high(bool ok_high)
bool has_received_bms_voltage_
bool is_below_pack_charge_critical_low_thresh()
void retrieve_voltage_CAN(CAN_message_t &recvd_msg)
EM_MEASUREMENT_t em_measurements_
CANBufferType * msg_queue_
float initialize_charge()
float filtered_max_cell_temp
void retrieve_em_measurement_CAN(CAN_message_t &can_msg)
const float VOLTAGE_LOOKUP_TABLE[101]
bool pack_charge_is_critical()
void calculate_acc_derate_factor()
void calculate_SoC_em(const SysTick_s &tick)
const unsigned short MAX_PACK_CHARGE
const unsigned long PACK_CHARGE_CRIT_LOWEST_CELL_THRESHOLD
const unsigned long PACK_CHARGE_CRIT_TOTAL_THRESHOLD
const unsigned long DEFAULT_INITIALIZATION_WAIT_INTERVAL
const unsigned long HEARTBEAT_INTERVAL