2019-11-23 19:55:21 -08:00
|
|
|
/*
|
|
|
|
* @file test_aux_valves.cpp
|
|
|
|
*
|
|
|
|
* @date: Nov 23, 2019
|
2020-04-18 19:46:22 -07:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2019-11-23 19:55:21 -08:00
|
|
|
*/
|
|
|
|
|
2021-07-25 22:05:17 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
2019-11-23 19:55:21 -08:00
|
|
|
#include "aux_valves.h"
|
|
|
|
|
2022-02-02 13:36:35 -08:00
|
|
|
TEST(Actuators, AuxValves) {
|
2020-04-05 16:33:33 -07:00
|
|
|
Sensor::setMockValue(SensorType::DriverThrottleIntent, 0);
|
|
|
|
|
2023-05-31 22:31:28 -07:00
|
|
|
EngineTestHelper eth(engine_type_e::NISSAN_PRIMERA);
|
2019-11-23 19:55:21 -08:00
|
|
|
|
2022-12-10 13:15:11 -08:00
|
|
|
// Engine must be "spinning" for scheduleByAngle to work
|
|
|
|
engine->rpmCalculator.setRpmValue(1000);
|
|
|
|
|
|
|
|
eth.assertTriggerEvent("a0", 0, &engine->auxValves[0][0].open, (void*)&auxPlainPinTurnOn, 0);
|
|
|
|
eth.assertTriggerEvent("a1", 1, &engine->auxValves[0][1].open, (void*)&auxPlainPinTurnOn, 360);
|
|
|
|
eth.assertTriggerEvent("a2", 2, &engine->auxValves[1][0].open, (void*)&auxPlainPinTurnOn, 180);
|
|
|
|
eth.assertTriggerEvent("a3", 3, &engine->auxValves[1][1].open, (void*)&auxPlainPinTurnOn, 540);
|
|
|
|
|
|
|
|
// Execute the first one, ensure scheduling for the "close" event happens
|
2022-12-10 14:07:02 -08:00
|
|
|
engine->module<TriggerScheduler>()->scheduleEventsUntilNextTriggerTooth(1000, 0, 0, 1);
|
2022-12-10 13:15:11 -08:00
|
|
|
|
|
|
|
// Old head should now be missing - we just ran it
|
|
|
|
eth.assertTriggerEvent("a1", 0, &engine->auxValves[0][1].open, (void*)&auxPlainPinTurnOn, 360);
|
|
|
|
eth.assertTriggerEvent("a2", 1, &engine->auxValves[1][0].open, (void*)&auxPlainPinTurnOn, 180);
|
|
|
|
eth.assertTriggerEvent("a3", 2, &engine->auxValves[1][1].open, (void*)&auxPlainPinTurnOn, 540);
|
|
|
|
|
|
|
|
// Execute the action it put on the regular scheduler
|
|
|
|
eth.executeUntil(999999);
|
|
|
|
|
|
|
|
eth.assertTriggerEvent("a1", 0, &engine->auxValves[0][1].open, (void*)&auxPlainPinTurnOn, 360);
|
|
|
|
eth.assertTriggerEvent("a2", 1, &engine->auxValves[1][0].open, (void*)&auxPlainPinTurnOn, 180);
|
|
|
|
eth.assertTriggerEvent("a3", 2, &engine->auxValves[1][1].open, (void*)&auxPlainPinTurnOn, 540);
|
|
|
|
// same event is back at the end of the list
|
|
|
|
eth.assertTriggerEvent("a0", 3, &engine->auxValves[0][0].open, (void*)&auxPlainPinTurnOn, 0);
|
|
|
|
// PLUS the turn off event!
|
|
|
|
eth.assertTriggerEvent("off", 4, &engine->auxValves[0][0].close, nullptr, 30);
|
2019-11-23 19:55:21 -08:00
|
|
|
}
|