test CheckStartCondition

This commit is contained in:
Janosch
2022-10-11 12:12:07 +01:00
parent 7a3dd9fb89
commit 7481f0f7e8
7 changed files with 63 additions and 5 deletions
+1
View File
@@ -8,4 +8,5 @@ bool CheckTimeout();
void CalcTotals();
void DisableAll();
void EvseRead();
bool CheckStartCondition();
#endif
Binary file not shown.
+6
View File
@@ -48,6 +48,12 @@ void CalcTotals()
Param::SetFixed(Param::udc, udcmax);
}
bool CheckStartCondition()
{
return (IsEvseInput() && Param::GetBool(Param::proximity) && Param::Get(Param::cablelim) > FP_FROMFLT(1.4) && Param::GetBool(Param::enable)) ||
(!IsEvseInput() && Param::GetBool(Param::enable));
}
bool CheckTimeout()
{
uint32_t now = rtc_get_counter_val();
-5
View File
@@ -48,11 +48,6 @@ static Can* can;
static PiController dcCurController;
uint32_t startTime;
static bool CheckStartCondition()
{
return (IsEvseInput() && Param::GetBool(Param::proximity) && Param::Get(Param::cablelim) > FP_FROMFLT(1.4) && Param::GetBool(Param::enable)) ||
(!IsEvseInput() && Param::GetBool(Param::enable));
}
static bool CheckVoltage()
{
+1
View File
@@ -22,6 +22,7 @@ int main() {
(TestCase){"test_calc_totals", test_calc_totals},
(TestCase){"test_check_timeout", test_check_timeout},
(TestCase){"test_evse_read", test_evse_read},
(TestCase){"test_check_start_condition", test_check_start_condition},
// Example:
//(TestCase){"Your tests name", function_name_without_brackets}
//...
BIN
View File
Binary file not shown.
+55
View File
@@ -73,4 +73,59 @@ void test_evse_read()
EvseRead();
assert(0 == Param::GetInt(Param::proximity));
assert(0 == Param::GetInt(Param::cablelim));
// INP_TYPE2 and variations
//above threshold
Param::SetInt(Param::inputype, INP_TYPE2);
AnaIn::cablelim.Set(4222);
EvseRead();
assert(0 == Param::GetInt(Param::proximity));
assert(0 == Param::GetInt(Param::cablelim));
// under threshold (example)
Param::SetInt(Param::inputype, INP_TYPE2);
AnaIn::cablelim.Set(2822);
EvseRead();
assert(1 == Param::GetInt(Param::proximity));
assert(20 == Param::GetInt(Param::cablelim));
}
void test_check_start_condition()
{
bool res;
//not met by default
Param::SetInt(Param::inputype, INP_TYPE1);
Param::SetInt(Param::cablelim, 0);
Param::SetInt(Param::proximity, 0);
assert(IsEvseInput());
res = CheckStartCondition();
assert(!res);
//enable override not in EVSE type
Param::SetInt(Param::enable, 1);
assert(IsEvseInput());
res = CheckStartCondition();
assert(!res);
//enable override in manual type
Param::SetInt(Param::inputype, INP_MANUAL);
assert(!IsEvseInput());
res = CheckStartCondition();
assert(res);
//EVSE start condition met
Param::SetInt(Param::inputype, INP_TYPE2_3P);
Param::SetInt(Param::enable, 1);
Param::SetInt(Param::proximity, 1);
Param::SetInt(Param::cablelim, 32);
res = CheckStartCondition();
assert(res);
//EVSE start condition not met cablelim
Param::SetInt(Param::inputype, INP_TYPE2_3P);
Param::SetInt(Param::enable, 1);
Param::SetInt(Param::proximity, 1);
Param::SetInt(Param::cablelim, 0);
res = CheckStartCondition();
assert(!res);
}