Add Clang-Format file and apply it
The format tries to maintain the previously used Libre Solar firmware coding style as much as possible. Applying the format fixed some issues and re-ordered some parts of the code.
This commit is contained in:
committed by
Martin Jäger
parent
2359a96bbe
commit
5bdbecf19d
@@ -9,7 +9,8 @@
|
||||
|
||||
/** Data to fill adc_filtered array during unit-tests
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
float solar_voltage;
|
||||
float battery_voltage;
|
||||
float dcdc_current;
|
||||
|
||||
+4
-4
@@ -4,11 +4,11 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "unity.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <device.h>
|
||||
#include <zephyr.h>
|
||||
|
||||
#ifdef CONFIG_ARCH_POSIX
|
||||
#include "posix_board_if.h"
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
void setUp (void) {}
|
||||
void tearDown (void) {}
|
||||
void setUp(void) {}
|
||||
void tearDown(void) {}
|
||||
|
||||
} /* extern "C" */
|
||||
|
||||
|
||||
+1
-1
@@ -4,8 +4,8 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <unity.h>
|
||||
#include <time.h>
|
||||
#include <unity.h>
|
||||
|
||||
int bat_charger_tests();
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "setup.h"
|
||||
|
||||
@@ -100,8 +100,8 @@ void stop_topping_after_time_limit()
|
||||
charger.target_voltage_timer = bat_conf.topping_duration - 1;
|
||||
bat_terminal.current = bat_conf.topping_cutoff_current + 0.1;
|
||||
bat_terminal.current_filtered = bat_terminal.current;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage -
|
||||
bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
bat_terminal.bus->voltage =
|
||||
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
||||
|
||||
charger.charge_control(&bat_conf);
|
||||
@@ -119,8 +119,8 @@ void stop_topping_at_cutoff_current()
|
||||
charger.target_voltage_timer = 0;
|
||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
||||
bat_terminal.current_filtered = bat_terminal.current;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage -
|
||||
bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
bat_terminal.bus->voltage =
|
||||
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
bat_terminal.bus->voltage_filtered = bat_terminal.bus->voltage;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_FLOAT, charger.state);
|
||||
@@ -133,8 +133,8 @@ void float_to_idle_for_li_ion()
|
||||
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage -
|
||||
bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
bat_terminal.bus->voltage =
|
||||
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
||||
}
|
||||
@@ -147,8 +147,7 @@ void no_equalization_if_disabled()
|
||||
// set triggers such that it would normally start
|
||||
charger.deep_dis_last_equalization =
|
||||
charger.num_deep_discharges - bat_conf.equalization_trigger_deep_cycles;
|
||||
charger.time_last_equalization =
|
||||
time(NULL) - bat_conf.equalization_trigger_days * 24*60*60;
|
||||
charger.time_last_equalization = time(NULL) - bat_conf.equalization_trigger_days * 24 * 60 * 60;
|
||||
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage + 0.1;
|
||||
@@ -166,7 +165,7 @@ void no_equalization_if_limits_not_reached()
|
||||
charger.deep_dis_last_equalization =
|
||||
charger.num_deep_discharges - bat_conf.equalization_trigger_deep_cycles + 1;
|
||||
charger.time_last_equalization =
|
||||
time(NULL) - (bat_conf.equalization_trigger_days - 1) * 24*60*60;
|
||||
time(NULL) - (bat_conf.equalization_trigger_days - 1) * 24 * 60 * 60;
|
||||
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage + 0.1;
|
||||
@@ -179,18 +178,16 @@ void float_to_equalization_if_enabled_and_time_limit_reached()
|
||||
{
|
||||
enter_topping_at_voltage_setpoint();
|
||||
bat_conf.equalization_enabled = true;
|
||||
charger.time_last_equalization =
|
||||
time(NULL) - bat_conf.equalization_trigger_days * 24*60*60;
|
||||
charger.time_last_equalization = time(NULL) - bat_conf.equalization_trigger_days * 24 * 60 * 60;
|
||||
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage -
|
||||
bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
bat_terminal.bus->voltage =
|
||||
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||
}
|
||||
|
||||
|
||||
void float_to_equalization_if_enabled_and_deep_dis_limit_reached()
|
||||
{
|
||||
enter_topping_at_voltage_setpoint();
|
||||
@@ -200,20 +197,19 @@ void float_to_equalization_if_enabled_and_deep_dis_limit_reached()
|
||||
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal.current = bat_conf.topping_cutoff_current - 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.topping_voltage -
|
||||
bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
bat_terminal.bus->voltage =
|
||||
bat_conf.topping_voltage - bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||
}
|
||||
|
||||
|
||||
void stop_equalization_after_time_limit()
|
||||
{
|
||||
float_to_equalization_if_enabled_and_time_limit_reached();
|
||||
|
||||
charger.time_state_changed = time(NULL) - bat_conf.equalization_duration + 1;
|
||||
bat_terminal.bus->voltage = bat_conf.equalization_voltage -
|
||||
bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
bat_terminal.bus->voltage = bat_conf.equalization_voltage
|
||||
- bat_terminal.current * bat_terminal.bus->sink_droop_res + 0.1;
|
||||
|
||||
charger.charge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||
@@ -322,7 +318,7 @@ int bat_charger_tests()
|
||||
RUN_TEST(float_to_equalization_if_enabled_and_deep_dis_limit_reached);
|
||||
RUN_TEST(stop_equalization_after_time_limit);
|
||||
|
||||
//RUN_TEST(restart_bulk_from_float_if_voltage_drops);
|
||||
// RUN_TEST(restart_bulk_from_float_if_voltage_drops);
|
||||
|
||||
// TODO: temperature compensation
|
||||
// TODO: current compensation
|
||||
@@ -332,11 +328,11 @@ int bat_charger_tests()
|
||||
RUN_TEST(stop_discharge_at_undertemp);
|
||||
RUN_TEST(restart_discharge_if_allowed);
|
||||
|
||||
//RUN_TEST(battery_values_propagated_to_lv_bus_int);
|
||||
// RUN_TEST(battery_values_propagated_to_lv_bus_int);
|
||||
|
||||
// ToDo: SOC calculation
|
||||
//RUN_TEST(no_soc_above_100);
|
||||
//RUN_TEST(no_soc_below_0);
|
||||
// RUN_TEST(no_soc_above_100);
|
||||
// RUN_TEST(no_soc_below_0);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
#include "daq.h"
|
||||
#include "daq_stub.h"
|
||||
#include "helper.h"
|
||||
#include "setup.h"
|
||||
#include "tests.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -70,14 +70,14 @@ void check_solar_terminal_readings()
|
||||
{
|
||||
TEST_ASSERT_EQUAL_FLOAT(adcval.solar_voltage, round(hv_terminal.bus->voltage * 10) / 10);
|
||||
TEST_ASSERT_EQUAL_FLOAT(adcval.dcdc_current / adcval.solar_voltage * adcval.battery_voltage,
|
||||
-round(hv_terminal.current * 10) / 10);
|
||||
-round(hv_terminal.current * 10) / 10);
|
||||
}
|
||||
|
||||
void check_bat_terminal_readings()
|
||||
{
|
||||
TEST_ASSERT_EQUAL_FLOAT(adcval.battery_voltage, round(lv_terminal.bus->voltage * 10) / 10);
|
||||
TEST_ASSERT_EQUAL_FLOAT(adcval.dcdc_current - adcval.load_current,
|
||||
round(lv_terminal.current * 10) / 10);
|
||||
round(lv_terminal.current * 10) / 10);
|
||||
}
|
||||
|
||||
void check_load_terminal_readings()
|
||||
@@ -116,7 +116,7 @@ void adc_alert_lv_undervoltage_triggering()
|
||||
daq_update();
|
||||
|
||||
charger.discharge_control(&bat_conf);
|
||||
TEST_ASSERT_EQUAL(false, dev_stat.has_error(ERR_BAT_UNDERVOLTAGE)); // ToDo
|
||||
TEST_ASSERT_EQUAL(false, dev_stat.has_error(ERR_BAT_UNDERVOLTAGE)); // ToDo
|
||||
}
|
||||
|
||||
void adc_alert_lv_overvoltage_triggering()
|
||||
@@ -136,7 +136,7 @@ void adc_alert_lv_overvoltage_triggering()
|
||||
TEST_ASSERT_EQUAL(false, dev_stat.has_error(ERR_BAT_OVERVOLTAGE));
|
||||
adc_update_value(ADC_POS(v_low));
|
||||
TEST_ASSERT_EQUAL(true, dev_stat.has_error(ERR_BAT_OVERVOLTAGE));
|
||||
//TEST_ASSERT_EQUAL(false, pwm_switch.active());
|
||||
// TEST_ASSERT_EQUAL(false, pwm_switch.active());
|
||||
TEST_ASSERT_EQUAL(DCDC_CONTROL_OFF, dcdc.state);
|
||||
|
||||
// reset values
|
||||
@@ -203,7 +203,7 @@ int daq_tests()
|
||||
RUN_TEST(check_bat_terminal_readings);
|
||||
RUN_TEST(check_load_terminal_readings);
|
||||
|
||||
//RUN_TEST(check_temperature_readings); // TODO
|
||||
// RUN_TEST(check_temperature_readings); // TODO
|
||||
|
||||
RUN_TEST(adc_alert_lv_undervoltage_triggering);
|
||||
RUN_TEST(adc_alert_lv_overvoltage_triggering);
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
#include "half_bridge.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "setup.h"
|
||||
|
||||
@@ -49,7 +49,7 @@ static void start_buck()
|
||||
half_bridge_init(70, 200, 12 / dcdc.hs_voltage_max, 0.97);
|
||||
dcdc.control();
|
||||
dcdc.control();
|
||||
dcdc.control(); // call multiple times because of startup delay
|
||||
dcdc.control(); // call multiple times because of startup delay
|
||||
TEST_ASSERT_EQUAL(DCDC_CONTROL_MPPT, dcdc.state);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ static void start_boost()
|
||||
half_bridge_init(70, 200, 12 / dcdc.hs_voltage_max, 0.97);
|
||||
dcdc.control();
|
||||
dcdc.control();
|
||||
dcdc.control(); // call multiple times because of startup delay
|
||||
dcdc.control(); // call multiple times because of startup delay
|
||||
TEST_ASSERT_EQUAL(DCDC_CONTROL_MPPT, dcdc.state);
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ void buck_derating_output_voltage_too_high()
|
||||
lv_terminal.bus->voltage = lv_terminal.bus->sink_voltage_intercept + 0.1;
|
||||
dcdc.control();
|
||||
float pwm_after = half_bridge_get_duty_cycle();
|
||||
TEST_ASSERT(pwm_after < pwm_before); // less duty cycle = higher voltage
|
||||
TEST_ASSERT(pwm_after < pwm_before); // less duty cycle = higher voltage
|
||||
TEST_ASSERT_EQUAL(DCDC_CONTROL_CV_LS, dcdc.state);
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ void buck_correct_mppt_operation()
|
||||
float pwm2 = half_bridge_get_duty_cycle();
|
||||
TEST_ASSERT(pwm2 > pwm1);
|
||||
|
||||
dcdc.power = 6; // decrease power to make the direction turn around
|
||||
dcdc.power = 6; // decrease power to make the direction turn around
|
||||
dcdc.control();
|
||||
float pwm3 = half_bridge_get_duty_cycle();
|
||||
TEST_ASSERT(pwm3 < pwm2);
|
||||
@@ -332,7 +332,7 @@ void boost_derating_output_voltage_too_high()
|
||||
hv_terminal.bus->voltage = hv_terminal.bus->sink_voltage_intercept + 0.5;
|
||||
dcdc.control();
|
||||
float pwm_after = half_bridge_get_duty_cycle();
|
||||
TEST_ASSERT(pwm_after > pwm_before); // higher duty cycle = less power
|
||||
TEST_ASSERT(pwm_after > pwm_before); // higher duty cycle = less power
|
||||
}
|
||||
|
||||
void boost_derating_output_current_too_high()
|
||||
@@ -407,7 +407,7 @@ void boost_correct_mppt_operation()
|
||||
float pwm2 = half_bridge_get_duty_cycle();
|
||||
TEST_ASSERT(pwm2 < pwm1);
|
||||
|
||||
dcdc.power = -6; // decrease power to make the direction turn around
|
||||
dcdc.power = -6; // decrease power to make the direction turn around
|
||||
dcdc.control();
|
||||
float pwm3 = half_bridge_get_duty_cycle();
|
||||
TEST_ASSERT(pwm3 > pwm2);
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
#include "tests.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "setup.h"
|
||||
|
||||
@@ -23,7 +23,7 @@ void reset_counters_at_start_of_day()
|
||||
bat_terminal.pos_energy_Wh = 4.0;
|
||||
load.pos_energy_Wh = 9.0;
|
||||
|
||||
// 5 houurs without sun
|
||||
// 5 hours without sun
|
||||
for (int i = 0; i <= 5 * 60 * 60; i++) {
|
||||
dev_stat.update_energy();
|
||||
}
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
#include "half_bridge.h"
|
||||
#include "tests.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#define MAX_PWM_DUTY 0.97
|
||||
#define MIN_PWM_DUTY 0.1
|
||||
#define MID_PWM_DUTY ((MIN_PWM_DUTY + MAX_PWM_DUTY)/2)
|
||||
#define PWM_F_KHZ 70
|
||||
#define MAX_PWM_DUTY 0.97
|
||||
#define MIN_PWM_DUTY 0.1
|
||||
#define MID_PWM_DUTY ((MIN_PWM_DUTY + MAX_PWM_DUTY) / 2)
|
||||
#define PWM_F_KHZ 70
|
||||
#define PWM_DEADTIME_NS 300
|
||||
|
||||
const float duty_epsilon = 0.006;
|
||||
|
||||
+11
-10
@@ -4,13 +4,13 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
#include "daq_stub.h"
|
||||
#include "daq.h"
|
||||
#include "daq_stub.h"
|
||||
#include "tests.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "setup.h"
|
||||
|
||||
@@ -103,7 +103,7 @@ void control_on_to_off_overvoltage()
|
||||
TEST_ASSERT_EQUAL(0, load_out.error_flags);
|
||||
TEST_ASSERT_EQUAL(LOAD_STATE_ON, load_out.state);
|
||||
|
||||
load_out.control(); // once more
|
||||
load_out.control(); // once more
|
||||
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
||||
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
||||
}
|
||||
@@ -124,7 +124,7 @@ void control_on_to_off_overvoltage_dual_battery()
|
||||
TEST_ASSERT_EQUAL(0, load_out.error_flags);
|
||||
TEST_ASSERT_EQUAL(LOAD_STATE_ON, load_out.state);
|
||||
|
||||
load_out.control(); // once more
|
||||
load_out.control(); // once more
|
||||
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
||||
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
||||
}
|
||||
@@ -140,7 +140,8 @@ void control_on_to_off_overcurrent()
|
||||
load_out.control();
|
||||
TEST_ASSERT_EQUAL(LOAD_STATE_ON, load_out.state);
|
||||
|
||||
// almost 2x current = 4x heat generation: Should definitely trigger after waiting one time constant
|
||||
// almost 2x current = 4x heat generation: Should definitely trigger after waiting one time
|
||||
// constant
|
||||
int trigger_steps = DT_PROP(DT_PATH(pcb), mosfets_tau_ja) * CONFIG_CONTROL_FREQUENCY;
|
||||
for (int i = 0; i <= trigger_steps; i++) {
|
||||
load_out.control();
|
||||
@@ -233,7 +234,7 @@ void control_off_overvoltage_to_on_at_lower_voltage()
|
||||
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
||||
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
||||
|
||||
bus.voltage = load_out.overvoltage - 0.1; // test hysteresis
|
||||
bus.voltage = load_out.overvoltage - 0.1; // test hysteresis
|
||||
load_out.control();
|
||||
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
||||
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
||||
@@ -256,7 +257,7 @@ void control_off_overvoltage_to_on_at_lower_voltage_dual_battery()
|
||||
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
||||
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
||||
|
||||
bus.voltage = (load_out.overvoltage - 0.1) * bus.series_multiplier; // test hysteresis
|
||||
bus.voltage = (load_out.overvoltage - 0.1) * bus.series_multiplier; // test hysteresis
|
||||
load_out.control();
|
||||
TEST_ASSERT_EQUAL(ERR_LOAD_OVERVOLTAGE, load_out.error_flags);
|
||||
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
||||
@@ -278,7 +279,7 @@ void control_off_short_circuit_flag_reset()
|
||||
TEST_ASSERT_EQUAL(ERR_LOAD_SHORT_CIRCUIT, load_out.error_flags);
|
||||
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
||||
|
||||
load_out.enable = false; // this is like a manual reset
|
||||
load_out.enable = false; // this is like a manual reset
|
||||
load_out.control();
|
||||
TEST_ASSERT_EQUAL(0, load_out.error_flags);
|
||||
TEST_ASSERT_EQUAL(LOAD_STATE_OFF, load_out.state);
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "tests.h"
|
||||
#include "daq_stub.h"
|
||||
#include "daq.h"
|
||||
#include "daq_stub.h"
|
||||
#include "tests.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "setup.h"
|
||||
|
||||
@@ -46,7 +46,7 @@ void energy_calculation_init()
|
||||
prepare_adc_filtered();
|
||||
daq_update();
|
||||
|
||||
for (int i = 0; i < 60*60*sun_hours; i++) {
|
||||
for (int i = 0; i < 60 * 60 * sun_hours; i++) {
|
||||
hv_terminal.energy_balance();
|
||||
lv_terminal.energy_balance();
|
||||
load.energy_balance();
|
||||
@@ -58,7 +58,7 @@ void energy_calculation_init()
|
||||
prepare_adc_filtered();
|
||||
daq_update();
|
||||
|
||||
for (int i = 0; i < 60*60*night_hours; i++) {
|
||||
for (int i = 0; i < 60 * 60 * night_hours; i++) {
|
||||
hv_terminal.energy_balance();
|
||||
lv_terminal.energy_balance();
|
||||
load.energy_balance();
|
||||
@@ -69,26 +69,32 @@ void charging_energy_calculation_valid()
|
||||
{
|
||||
energy_calculation_init();
|
||||
// charging only during sun hours
|
||||
TEST_ASSERT_EQUAL_FLOAT(round(sun_hours * lv_terminal.bus->voltage * (dcdc_current_sun - load_current)), round(lv_terminal.pos_energy_Wh));
|
||||
TEST_ASSERT_EQUAL_FLOAT(
|
||||
round(sun_hours * lv_terminal.bus->voltage * (dcdc_current_sun - load_current)),
|
||||
round(lv_terminal.pos_energy_Wh));
|
||||
}
|
||||
|
||||
void discharging_energy_calculation_valid()
|
||||
{
|
||||
energy_calculation_init();
|
||||
// discharging (sum of current) only during dis hours
|
||||
TEST_ASSERT_EQUAL_FLOAT(round(night_hours * lv_terminal.bus->voltage * adcval.load_current), round(lv_terminal.neg_energy_Wh));
|
||||
TEST_ASSERT_EQUAL_FLOAT(round(night_hours * lv_terminal.bus->voltage * adcval.load_current),
|
||||
round(lv_terminal.neg_energy_Wh));
|
||||
}
|
||||
|
||||
void solar_input_energy_calculation_valid()
|
||||
{
|
||||
energy_calculation_init();
|
||||
TEST_ASSERT_EQUAL_FLOAT(round(sun_hours * lv_terminal.bus->voltage * dcdc_current_sun), round(hv_terminal.neg_energy_Wh));
|
||||
TEST_ASSERT_EQUAL_FLOAT(round(sun_hours * lv_terminal.bus->voltage * dcdc_current_sun),
|
||||
round(hv_terminal.neg_energy_Wh));
|
||||
}
|
||||
|
||||
void load_output_energy_calculation_valid()
|
||||
{
|
||||
energy_calculation_init();
|
||||
TEST_ASSERT_EQUAL_FLOAT(round((sun_hours + night_hours) * lv_terminal.bus->voltage * adcval.load_current), round(load.pos_energy_Wh));
|
||||
TEST_ASSERT_EQUAL_FLOAT(
|
||||
round((sun_hours + night_hours) * lv_terminal.bus->voltage * adcval.load_current),
|
||||
round(load.pos_energy_Wh));
|
||||
}
|
||||
|
||||
int power_port_tests()
|
||||
|
||||
Reference in New Issue
Block a user