app: convert device status to C struct
DeviceStatus becomes struct device_status with prefixed functions. The error flag helpers are static inline functions in the header. The implementation stays in C++ for now, as it reads data from objects which are not converted yet. The header doesn't include the headers of these objects anymore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3cc24411b5
commit
a428892916
@@ -25,7 +25,7 @@ ZTEST(device_status, test_reset_counters_at_start_of_day)
|
||||
|
||||
// 5 hours without sun
|
||||
for (int i = 0; i <= 5 * 60 * 60; i++) {
|
||||
dev_stat.update_energy();
|
||||
device_status_update_energy(&dev_stat);
|
||||
}
|
||||
|
||||
zassert_equal(dev_stat.solar_in_total_Wh, 10);
|
||||
@@ -43,7 +43,7 @@ ZTEST(device_status, test_reset_counters_at_start_of_day)
|
||||
|
||||
// now solar power comes back
|
||||
solar_terminal.bus->voltage = bat_terminal.bus->voltage + 1;
|
||||
dev_stat.update_energy();
|
||||
device_status_update_energy(&dev_stat);
|
||||
|
||||
// day counter should be increased and daily energy counters reset
|
||||
zassert_equal(dev_stat.day_counter, 1);
|
||||
@@ -56,35 +56,35 @@ ZTEST(device_status, test_reset_counters_at_start_of_day)
|
||||
ZTEST(device_status, test_dev_stat_new_solar_voltage_max)
|
||||
{
|
||||
solar_terminal.bus->voltage = 40;
|
||||
dev_stat.update_min_max_values();
|
||||
device_status_update_min_max_values(&dev_stat);
|
||||
zassert_equal(dev_stat.solar_voltage_max, 40);
|
||||
}
|
||||
|
||||
ZTEST(device_status, test_dev_stat_new_bat_voltage_max)
|
||||
{
|
||||
bat_terminal.bus->voltage = 31;
|
||||
dev_stat.update_min_max_values();
|
||||
device_status_update_min_max_values(&dev_stat);
|
||||
zassert_equal(dev_stat.battery_voltage_max, 31);
|
||||
}
|
||||
|
||||
ZTEST(device_status, test_dev_stat_new_dcdc_current_max)
|
||||
{
|
||||
dcdc.inductor_current = 21;
|
||||
dev_stat.update_min_max_values();
|
||||
device_status_update_min_max_values(&dev_stat);
|
||||
zassert_equal(dev_stat.dcdc_current_max, 21);
|
||||
}
|
||||
|
||||
ZTEST(device_status, test_dev_stat_new_load_current_max)
|
||||
{
|
||||
load.current = 21;
|
||||
dev_stat.update_min_max_values();
|
||||
device_status_update_min_max_values(&dev_stat);
|
||||
zassert_equal(dev_stat.load_current_max, 21);
|
||||
}
|
||||
|
||||
ZTEST(device_status, test_dev_stat_solar_power_max)
|
||||
{
|
||||
solar_terminal.power = -50;
|
||||
dev_stat.update_min_max_values();
|
||||
device_status_update_min_max_values(&dev_stat);
|
||||
zassert_equal(dev_stat.solar_power_max_day, 50);
|
||||
zassert_equal(dev_stat.solar_power_max_total, 50);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ ZTEST(device_status, test_dev_stat_solar_power_max)
|
||||
ZTEST(device_status, test_dev_stat_load_power_max)
|
||||
{
|
||||
load.power = 50;
|
||||
dev_stat.update_min_max_values();
|
||||
device_status_update_min_max_values(&dev_stat);
|
||||
zassert_equal(dev_stat.load_power_max_day, 50);
|
||||
zassert_equal(dev_stat.load_power_max_total, 50);
|
||||
}
|
||||
@@ -100,14 +100,14 @@ ZTEST(device_status, test_dev_stat_load_power_max)
|
||||
ZTEST(device_status, test_dev_stat_new_mosfet_temp_max)
|
||||
{
|
||||
dcdc.temp_mosfets = 80;
|
||||
dev_stat.update_min_max_values();
|
||||
device_status_update_min_max_values(&dev_stat);
|
||||
zassert_equal(dev_stat.mosfet_temp_max, 80);
|
||||
}
|
||||
|
||||
ZTEST(device_status, test_dev_stat_new_bat_temp_max)
|
||||
{
|
||||
charger.bat_temperature = 45;
|
||||
dev_stat.update_min_max_values();
|
||||
device_status_update_min_max_values(&dev_stat);
|
||||
zassert_equal(dev_stat.bat_temp_max, 45);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ ZTEST(device_status, test_dev_stat_new_int_temp_max)
|
||||
{
|
||||
dev_stat.int_temp_max = 20;
|
||||
dev_stat.internal_temp = 22;
|
||||
dev_stat.update_min_max_values();
|
||||
device_status_update_min_max_values(&dev_stat);
|
||||
zassert_equal(dev_stat.int_temp_max, 22);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user