test CheckStartCondition
This commit is contained in:
@@ -8,4 +8,5 @@ bool CheckTimeout();
|
|||||||
void CalcTotals();
|
void CalcTotals();
|
||||||
void DisableAll();
|
void DisableAll();
|
||||||
void EvseRead();
|
void EvseRead();
|
||||||
|
bool CheckStartCondition();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Binary file not shown.
@@ -48,6 +48,12 @@ void CalcTotals()
|
|||||||
Param::SetFixed(Param::udc, udcmax);
|
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()
|
bool CheckTimeout()
|
||||||
{
|
{
|
||||||
uint32_t now = rtc_get_counter_val();
|
uint32_t now = rtc_get_counter_val();
|
||||||
|
|||||||
@@ -48,11 +48,6 @@ static Can* can;
|
|||||||
static PiController dcCurController;
|
static PiController dcCurController;
|
||||||
uint32_t startTime;
|
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()
|
static bool CheckVoltage()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ int main() {
|
|||||||
(TestCase){"test_calc_totals", test_calc_totals},
|
(TestCase){"test_calc_totals", test_calc_totals},
|
||||||
(TestCase){"test_check_timeout", test_check_timeout},
|
(TestCase){"test_check_timeout", test_check_timeout},
|
||||||
(TestCase){"test_evse_read", test_evse_read},
|
(TestCase){"test_evse_read", test_evse_read},
|
||||||
|
(TestCase){"test_check_start_condition", test_check_start_condition},
|
||||||
// Example:
|
// Example:
|
||||||
//(TestCase){"Your tests name", function_name_without_brackets}
|
//(TestCase){"Your tests name", function_name_without_brackets}
|
||||||
//...
|
//...
|
||||||
|
|||||||
Binary file not shown.
@@ -73,4 +73,59 @@ void test_evse_read()
|
|||||||
EvseRead();
|
EvseRead();
|
||||||
assert(0 == Param::GetInt(Param::proximity));
|
assert(0 == Param::GetInt(Param::proximity));
|
||||||
assert(0 == Param::GetInt(Param::cablelim));
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user