diff --git a/include/charger.h b/include/charger.h index 14e3c24..d44803a 100644 --- a/include/charger.h +++ b/include/charger.h @@ -11,4 +11,5 @@ void DisableAll(); void EvseRead(); bool CheckStartCondition(); bool CheckVoltage(); +void ResetValuesInOffMode(); #endif diff --git a/libopeninv/libopeninv.a b/libopeninv/libopeninv.a index 62596d2..bda1a57 100644 Binary files a/libopeninv/libopeninv.a and b/libopeninv/libopeninv.a differ diff --git a/src/charger.cpp b/src/charger.cpp index e4cba2c..261ff52 100644 --- a/src/charger.cpp +++ b/src/charger.cpp @@ -166,3 +166,14 @@ void EvseRead() } } +void ResetValuesInOffMode() +{ + if (Param::GetInt(Param::state) == OFF) + { + for (int i = Param::c1stt; i <= Param::c3idc; i++) + { + Param::SetInt((Param::PARAM_NUM)i, 0); + } + } +} + diff --git a/src/main.cpp b/src/main.cpp index 57ede44..cf2af08 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -241,17 +241,6 @@ static void CalcEnable() Param::SetInt(Param::enable, enable); } -static void ResetValuesInOffMode() -{ - if (Param::GetInt(Param::state) == OFF) - { - for (int i = Param::c1stt; i <= Param::c3idc; i++) - { - Param::SetInt((Param::PARAM_NUM)i, 0); - } - } -} - //sample 100ms task static void Ms100Task(void) { diff --git a/test/test.c b/test/test.c index 7b98ac0..0bb01e0 100644 --- a/test/test.c +++ b/test/test.c @@ -25,6 +25,7 @@ int main() { (TestCase){"test_evse_read", test_evse_read}, (TestCase){"test_check_start_condition", test_check_start_condition}, (TestCase){"test_check_voltage", test_check_voltage}, + (TestCase){"test_reset_values_in_off_mode", test_reset_values_in_off_mode}, // Example: //(TestCase){"Your tests name", function_name_without_brackets} //... diff --git a/test/test.out b/test/test.out index 4c71687..6ee71ef 100755 Binary files a/test/test.out and b/test/test.out differ diff --git a/test/test_logic.h b/test/test_logic.h index 749b852..697eb85 100644 --- a/test/test_logic.h +++ b/test/test_logic.h @@ -168,3 +168,16 @@ void test_check_voltage(){ } assert(res); } + +void test_reset_values_in_off_mode(){ + Param::SetInt(Param::c1flag, 1); + Param::SetInt(Param::c2tmp2, 15); + Param::SetInt(Param::c3stt, 15); + Param::SetInt(Param::c3uac, 239); + assert(1 == Param::GetInt(Param::c1flag)); + ResetValuesInOffMode(); + assert(0 == Param::GetInt(Param::c1flag)); + assert(0 == Param::GetInt(Param::c2tmp2)); + assert(0 == Param::GetInt(Param::c3stt)); + assert(0 == Param::GetInt(Param::c3uac)); +}