fome-fw/unit_tests/test_idle_controller.cpp

67 lines
1.5 KiB
C++
Raw Normal View History

2015-07-10 06:01:56 -07:00
/*
* @file test_idle_controller.cpp
*
* @date Oct 17, 2013
* @author Andrey Belomutskiy, (c) 2012-2014
*/
#include <stdio.h>
#include "idle_controller.h"
#include "efitime.h"
#include "engine_test_helper.h"
#include "pid.h"
void idleDebug(const char *msg, percent_t value) {
printf("%s\r\n", msg);
}
static IdleValveState is;
void testIdleController(void) {
print("******************************************* testIdleController\r\n");
EngineTestHelper eth(FORD_INLINE_6_1995);
EXPAND_EngineTestHelper;
engineConfiguration->targetIdleRpm = 1200;
is.init(PASS_ENGINE_PARAMETER_F);
efitimems_t time = 0;
2016-06-12 21:02:04 -07:00
assertEqualsM("#1", 60.0, is.getIdle(900, time PASS_ENGINE_PARAMETER));
2015-07-10 06:01:56 -07:00
time += 2000;
2016-12-26 12:03:03 -08:00
assertEqualsM("idle#2", 60.5, is.getIdle(900, time PASS_ENGINE_PARAMETER));
2015-07-10 06:01:56 -07:00
time += 2000;
2016-12-26 12:03:03 -08:00
assertEqualsM("idke#3", 60.6, is.getIdle(1050, time PASS_ENGINE_PARAMETER));
2015-07-10 06:01:56 -07:00
}
void testPidController(void) {
print("******************************************* testPidController\r\n");
2016-01-20 20:03:03 -08:00
pid_s pidS;
pidS.pFactor = 50;
pidS.iFactor = 0.5;
pidS.dFactor = 0;
2016-07-13 18:03:05 -07:00
pidS.offset = 0;
2016-01-20 20:03:03 -08:00
Pid pid(&pidS, 10, 90);
2015-07-10 06:01:56 -07:00
2016-07-13 18:03:05 -07:00
assertEqualsM("getValue#90", 90, pid.getValue(14, 12, 0.1));
2015-07-10 06:01:56 -07:00
2016-07-13 18:03:05 -07:00
assertEqualsM("getValue#10", 10, pid.getValue(14, 16, 0.1));
2015-07-10 06:01:56 -07:00
assertEquals(10, pid.getValue(14, 16, 1));
pid.updateFactors(29, 0, 0);
assertEquals(10, pid.getValue(14, 16, 1));
// assertEquals(68, pid.getIntegration());
assertEquals(10, pid.getValue(14, 16, 1));
// assertEquals(0, pid.getIntegration());
assertEquals(10, pid.getValue(14, 16, 1));
// assertEquals(68, pid.getIntegration());
}