code style

This commit is contained in:
amarofarinha 2024-09-28 21:21:14 +01:00
parent 0cd0b384c3
commit 09421057c4
4 changed files with 13 additions and 9 deletions

View file

@ -588,8 +588,9 @@ void receive_can_native() { // This section checks if we have a complete CAN me
} }
void send_can() { void send_can() {
if (!can_send_CAN) if (!allowed_to_send_CAN) {
return; return;
}
send_can_battery(); send_can_battery();
@ -921,9 +922,11 @@ void check_reset_reason() {
break; break;
} }
} }
void transmit_can(CAN_frame* tx_frame, int interface) { void transmit_can(CAN_frame* tx_frame, int interface) {
if (!can_send_CAN) if (!allowed_to_send_CAN) {
return; return;
}
switch (interface) { switch (interface) {
case CAN_NATIVE: case CAN_NATIVE:

View file

@ -125,7 +125,7 @@ static void publish_common_info(void) {
doc["pause_status"] = get_emulator_pause_status(); doc["pause_status"] = get_emulator_pause_status();
//only publish these values if BMS is active and we are comunication with the battery (can send CAN messages to the battery) //only publish these values if BMS is active and we are comunication with the battery (can send CAN messages to the battery)
if (datalayer.battery.status.bms_status == ACTIVE && can_send_CAN && millis() > BOOTUP_TIME) { if (datalayer.battery.status.bms_status == ACTIVE && allowed_to_send_CAN && millis() > BOOTUP_TIME) {
doc["SOC"] = ((float)datalayer.battery.status.reported_soc) / 100.0; doc["SOC"] = ((float)datalayer.battery.status.reported_soc) / 100.0;
doc["SOC_real"] = ((float)datalayer.battery.status.real_soc) / 100.0; doc["SOC_real"] = ((float)datalayer.battery.status.real_soc) / 100.0;
doc["state_of_health"] = ((float)datalayer.battery.status.soh_pptt) / 100.0; doc["state_of_health"] = ((float)datalayer.battery.status.soh_pptt) / 100.0;

View file

@ -12,7 +12,7 @@ static bool battery_empty_event_fired = false;
//battery pause status begin //battery pause status begin
bool emulator_pause_request_ON = false; bool emulator_pause_request_ON = false;
bool emulator_pause_CAN_send_ON = false; bool emulator_pause_CAN_send_ON = false;
bool can_send_CAN = true; bool allowed_to_send_CAN = true;
battery_pause_status emulator_pause_status = NORMAL; battery_pause_status emulator_pause_status = NORMAL;
//battery pause status end //battery pause status end
@ -224,8 +224,9 @@ void setBatteryPause(bool pause_battery, bool pause_CAN) {
/// @return true if CAN messages should be sent to battery, false if not /// @return true if CAN messages should be sent to battery, false if not
void emulator_pause_state_send_CAN_battery() { void emulator_pause_state_send_CAN_battery() {
if (emulator_pause_status == NORMAL) if (emulator_pause_status == NORMAL) {
can_send_CAN = true; allowed_to_send_CAN = true;
}
// in some inverters this values are not accurate, so we need to check if we are consider 1.8 amps as the limit // in some inverters this values are not accurate, so we need to check if we are consider 1.8 amps as the limit
if (emulator_pause_request_ON && emulator_pause_status == PAUSING && datalayer.battery.status.current_dA < 18 && if (emulator_pause_request_ON && emulator_pause_status == PAUSING && datalayer.battery.status.current_dA < 18 &&
@ -235,10 +236,10 @@ void emulator_pause_state_send_CAN_battery() {
if (!emulator_pause_request_ON && emulator_pause_status == RESUMING) { if (!emulator_pause_request_ON && emulator_pause_status == RESUMING) {
emulator_pause_status = NORMAL; emulator_pause_status = NORMAL;
can_send_CAN = true; allowed_to_send_CAN = true;
} }
can_send_CAN = (!emulator_pause_CAN_send_ON || emulator_pause_status == NORMAL); allowed_to_send_CAN = (!emulator_pause_CAN_send_ON || emulator_pause_status == NORMAL);
} }
std::string get_emulator_pause_status() { std::string get_emulator_pause_status() {

View file

@ -12,7 +12,7 @@ enum battery_pause_status { NORMAL = 0, PAUSING = 1, PAUSED = 2, RESUMING = 3 };
extern bool emulator_pause_request_ON; extern bool emulator_pause_request_ON;
extern bool emulator_pause_CAN_send_ON; extern bool emulator_pause_CAN_send_ON;
extern battery_pause_status emulator_pause_status; extern battery_pause_status emulator_pause_status;
extern bool can_send_CAN; extern bool allowed_to_send_CAN;
//battery pause status end //battery pause status end
void update_machineryprotection(); void update_machineryprotection();