Combine angle based event (#4884)
* Remove AngleBasedEventOld/New, only AngleBasedEvent now * this 7 year old comment of old test code can go away
This commit is contained in:
parent
016b71babe
commit
29db8e2474
|
@ -24,49 +24,6 @@
|
|||
|
||||
#include "event_registry.h"
|
||||
|
||||
static void findTriggerPosition(TriggerWaveform *triggerShape,
|
||||
TriggerFormDetails *details,
|
||||
event_trigger_position_s *position,
|
||||
angle_t angle) {
|
||||
efiAssertVoid(CUSTOM_ERR_6574, !cisnan(angle), "findAngle#1");
|
||||
assertAngleRange(angle, "findAngle#a1", CUSTOM_ERR_6545);
|
||||
|
||||
efiAssertVoid(CUSTOM_ERR_6575, !cisnan(triggerShape->tdcPosition), "tdcPos#1")
|
||||
assertAngleRange(triggerShape->tdcPosition, "tdcPos#a1", CUSTOM_UNEXPECTED_TDC_ANGLE);
|
||||
|
||||
efiAssertVoid(CUSTOM_ERR_6576, !cisnan(engineConfiguration->globalTriggerAngleOffset), "tdcPos#2")
|
||||
assertAngleRange(engineConfiguration->globalTriggerAngleOffset, "tdcPos#a2", CUSTOM_INVALID_GLOBAL_OFFSET);
|
||||
|
||||
// convert engine cycle angle into trigger cycle angle
|
||||
angle += triggerShape->tdcPosition + engineConfiguration->globalTriggerAngleOffset;
|
||||
efiAssertVoid(CUSTOM_ERR_6577, !cisnan(angle), "findAngle#2");
|
||||
wrapAngle2(angle, "addFuel#2", CUSTOM_ERR_6555, getEngineCycle(triggerShape->getWheelOperationMode()));
|
||||
|
||||
int triggerEventIndex = triggerShape->findAngleIndex(details, angle);
|
||||
angle_t triggerEventAngle = details->eventAngles[triggerEventIndex];
|
||||
angle_t offsetFromTriggerEvent = angle - triggerEventAngle;
|
||||
|
||||
// Guarantee that we aren't going to try and schedule an event prior to the tooth
|
||||
if (offsetFromTriggerEvent < 0) {
|
||||
warning(CUSTOM_OBD_ANGLE_CONSTRAINT_VIOLATION, "angle constraint violation in findTriggerPosition(): %.2f/%.2f", angle, triggerEventAngle);
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
// This must happen under lock so that the tooth and offset don't get partially read and mismatched
|
||||
chibios_rt::CriticalSectionLocker csl;
|
||||
|
||||
position->triggerEventIndex = triggerEventIndex;
|
||||
position->angleOffsetFromTriggerEvent = offsetFromTriggerEvent;
|
||||
}
|
||||
}
|
||||
|
||||
void event_trigger_position_s::setAngle(angle_t angle) {
|
||||
findTriggerPosition(&engine->triggerCentral.triggerShape,
|
||||
&engine->triggerCentral.triggerFormDetails,
|
||||
this, angle);
|
||||
}
|
||||
|
||||
IgnitionEvent::IgnitionEvent() {
|
||||
memset(outputs, 0, sizeof(outputs));
|
||||
}
|
||||
|
|
|
@ -13,59 +13,20 @@
|
|||
#include "fl_stack.h"
|
||||
#include "trigger_structure.h"
|
||||
|
||||
struct AngleBasedEventOld;
|
||||
struct AngleBasedEventNew;
|
||||
|
||||
struct AngleBasedEventBase {
|
||||
struct AngleBasedEvent {
|
||||
scheduling_s scheduling;
|
||||
action_s action;
|
||||
/**
|
||||
* Trigger-based scheduler maintains a linked list of all pending tooth-based events.
|
||||
*/
|
||||
AngleBasedEventBase *nextToothEvent = nullptr;
|
||||
AngleBasedEvent *nextToothEvent = nullptr;
|
||||
|
||||
virtual void setAngle(angle_t angle) = 0;
|
||||
|
||||
virtual bool shouldSchedule(uint32_t trgEventIndex, float currentPhase, float nextPhase) const = 0;
|
||||
virtual float getAngleFromNow(float currentPhase) const = 0;
|
||||
|
||||
// Virtual functions to get these as old/new variants, since we don't have RTTI for dynamic casts to work
|
||||
// (this is poor man's RTTI)
|
||||
virtual const AngleBasedEventOld* asOld() const { return nullptr; }
|
||||
virtual const AngleBasedEventNew* asNew() const { return nullptr; }
|
||||
};
|
||||
|
||||
/**
|
||||
* This structure defines an angle position in relation to specific tooth within trigger shape
|
||||
*/
|
||||
class event_trigger_position_s {
|
||||
public:
|
||||
size_t triggerEventIndex = 0;
|
||||
|
||||
angle_t angleOffsetFromTriggerEvent = 0;
|
||||
|
||||
void setAngle(angle_t angle);
|
||||
};
|
||||
|
||||
struct AngleBasedEventOld : public AngleBasedEventBase {
|
||||
event_trigger_position_s position;
|
||||
|
||||
void setAngle(angle_t angle) override;
|
||||
bool shouldSchedule(uint32_t trgEventIndex, float currentPhase, float nextPhase) const override;
|
||||
float getAngleFromNow(float currentPhase) const override;
|
||||
|
||||
virtual const AngleBasedEventOld* asOld() const override { return this; }
|
||||
};
|
||||
|
||||
struct AngleBasedEventNew : public AngleBasedEventBase {
|
||||
float enginePhase;
|
||||
|
||||
void setAngle(angle_t angle) override;
|
||||
bool shouldSchedule(uint32_t trgEventIndex, float currentPhase, float nextPhase) const override;
|
||||
bool shouldSchedule(float currentPhase, float nextPhase) const;
|
||||
float getAngleFromNow(float currentPhase) const override;
|
||||
void setAngle(angle_t angle);
|
||||
|
||||
virtual const AngleBasedEventNew* asNew() const override { return this; }
|
||||
bool shouldSchedule(float currentPhase, float nextPhase) const;
|
||||
float getAngleFromNow(float currentPhase) const;
|
||||
};
|
||||
|
||||
#define MAX_OUTPUTS_FOR_IGNITION 2
|
||||
|
@ -75,7 +36,7 @@ public:
|
|||
IgnitionEvent();
|
||||
IgnitionOutputPin *outputs[MAX_OUTPUTS_FOR_IGNITION];
|
||||
scheduling_s dwellStartTimer;
|
||||
AngleBasedEventNew sparkEvent;
|
||||
AngleBasedEvent sparkEvent;
|
||||
|
||||
scheduling_s trailingSparkCharge;
|
||||
scheduling_s trailingSparkFire;
|
||||
|
@ -125,8 +86,8 @@ public:
|
|||
int valveIndex;
|
||||
angle_t extra;
|
||||
|
||||
AngleBasedEventNew open;
|
||||
AngleBasedEventNew close;
|
||||
AngleBasedEvent open;
|
||||
AngleBasedEvent close;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1738,7 +1738,7 @@ typedef enum {
|
|||
|
||||
CUSTOM_OBD_INJECTION_NO_PIN_ASSIGNED = 6020,
|
||||
CUSTOM_OBD_UNEXPECTED_INJECTION_MODE = 6021,
|
||||
CUSTOM_OBD_ANGLE_CONSTRAINT_VIOLATION = 6022,
|
||||
CUSTOM_6022 = 6022,
|
||||
CUSTOM_OBD_UNKNOWN_FIRING_ORDER = 6023,
|
||||
CUSTOM_OBD_WRONG_FIRING_ORDER = 6024,
|
||||
CUSTOM_OBD_IGNITION_MODE = 6025,
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
#if !EFI_UNIT_TEST
|
||||
private:
|
||||
#endif // EFI_UNIT_TEST
|
||||
AngleBasedEventNew m_event;
|
||||
AngleBasedEvent m_event;
|
||||
|
||||
HpfpQuantity m_quantity;
|
||||
HpfpLobe m_lobe;
|
||||
|
|
|
@ -200,11 +200,10 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase
|
|||
#endif /* EFI_DEFAILED_LOGGING */
|
||||
}
|
||||
|
||||
static void handleFuel(uint32_t trgEventIndex, int rpm, efitick_t nowNt, float currentPhase, float nextPhase) {
|
||||
static void handleFuel(int rpm, efitick_t nowNt, float currentPhase, float nextPhase) {
|
||||
ScopePerf perf(PE::HandleFuel);
|
||||
|
||||
efiAssertVoid(CUSTOM_STACK_6627, getCurrentRemainingStack() > 128, "lowstck#3");
|
||||
efiAssertVoid(CUSTOM_ERR_6628, trgEventIndex < getTriggerCentral()->engineCycleEventCount, "handleFuel/event index");
|
||||
|
||||
LimpState limitedFuelState = getLimpManager()->allowInjection();
|
||||
|
||||
|
@ -226,7 +225,7 @@ static void handleFuel(uint32_t trgEventIndex, int rpm, efitick_t nowNt, float c
|
|||
|
||||
#if FUEL_MATH_EXTREME_LOGGING
|
||||
if (printFuelDebug) {
|
||||
efiPrintf("handleFuel ind=%d %d", trgEventIndex, getRevolutionCounter());
|
||||
efiPrintf("handleFuel [%.1f, %.1f) %d", currentPhase, nextPhase, getRevolutionCounter());
|
||||
}
|
||||
#endif /* FUEL_MATH_EXTREME_LOGGING */
|
||||
|
||||
|
@ -282,10 +281,10 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp, angle_
|
|||
* For fuel we schedule start of injection based on trigger angle, and then inject for
|
||||
* specified duration of time
|
||||
*/
|
||||
handleFuel(trgEventIndex, rpm, edgeTimestamp, currentPhase, nextPhase);
|
||||
handleFuel(rpm, edgeTimestamp, currentPhase, nextPhase);
|
||||
|
||||
engine->module<TriggerScheduler>()->scheduleEventsUntilNextTriggerTooth(
|
||||
rpm, trgEventIndex, edgeTimestamp, currentPhase, nextPhase);
|
||||
rpm, edgeTimestamp, currentPhase, nextPhase);
|
||||
|
||||
/**
|
||||
* For spark we schedule both start of coil charge and actual spark based on trigger angle
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
#define QUEUE_LENGTH_LIMIT 1000
|
||||
|
||||
// templates do not accept field names so we use a macro here
|
||||
#define assertNotInListMethodBody(T, head, element, field) \
|
||||
#define assertNotInListMethodBody(head, element, field) \
|
||||
/* this code is just to validate state, no functional load*/ \
|
||||
T * current; \
|
||||
decltype(head) current; \
|
||||
int counter = 0; \
|
||||
LL_FOREACH2(head, current, field) { \
|
||||
if (++counter > QUEUE_LENGTH_LIMIT) { \
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
#include "event_queue.h"
|
||||
|
||||
bool TriggerScheduler::assertNotInList(AngleBasedEventBase *head, AngleBasedEventBase *element) {
|
||||
assertNotInListMethodBody(AngleBasedEventBase, head, element, nextToothEvent)
|
||||
bool TriggerScheduler::assertNotInList(AngleBasedEvent *head, AngleBasedEvent *element) {
|
||||
assertNotInListMethodBody(head, element, nextToothEvent)
|
||||
}
|
||||
|
||||
void TriggerScheduler::schedule(AngleBasedEventBase* event, angle_t angle, action_s action) {
|
||||
void TriggerScheduler::schedule(AngleBasedEvent* event, angle_t angle, action_s action) {
|
||||
event->setAngle(angle);
|
||||
|
||||
schedule(event, action);
|
||||
|
@ -18,7 +18,7 @@ void TriggerScheduler::schedule(AngleBasedEventBase* event, angle_t angle, actio
|
|||
* @return true if event corresponds to current tooth and was time-based scheduler
|
||||
* false if event was put into queue for scheduling at a later tooth
|
||||
*/
|
||||
bool TriggerScheduler::scheduleOrQueue(AngleBasedEventNew *event,
|
||||
bool TriggerScheduler::scheduleOrQueue(AngleBasedEvent *event,
|
||||
efitick_t edgeTimestamp,
|
||||
angle_t angle,
|
||||
action_s action,
|
||||
|
@ -43,7 +43,7 @@ bool TriggerScheduler::scheduleOrQueue(AngleBasedEventNew *event,
|
|||
}
|
||||
}
|
||||
|
||||
void TriggerScheduler::schedule(AngleBasedEventBase* event, action_s action) {
|
||||
void TriggerScheduler::schedule(AngleBasedEvent* event, action_s action) {
|
||||
event->action = action;
|
||||
|
||||
{
|
||||
|
@ -61,7 +61,6 @@ void TriggerScheduler::schedule(AngleBasedEventBase* event, action_s action) {
|
|||
}
|
||||
|
||||
void TriggerScheduler::scheduleEventsUntilNextTriggerTooth(int rpm,
|
||||
uint32_t trgEventIndex,
|
||||
efitick_t edgeTimestamp, float currentPhase, float nextPhase) {
|
||||
|
||||
if (!isValidRpm(rpm)) {
|
||||
|
@ -69,8 +68,8 @@ void TriggerScheduler::scheduleEventsUntilNextTriggerTooth(int rpm,
|
|||
return;
|
||||
}
|
||||
|
||||
AngleBasedEventBase *current, *tmp, *keephead;
|
||||
AngleBasedEventBase *keeptail = nullptr;
|
||||
AngleBasedEvent *current, *tmp, *keephead;
|
||||
AngleBasedEvent *keeptail = nullptr;
|
||||
|
||||
{
|
||||
chibios_rt::CriticalSectionLocker csl;
|
||||
|
@ -81,7 +80,7 @@ void TriggerScheduler::scheduleEventsUntilNextTriggerTooth(int rpm,
|
|||
|
||||
LL_FOREACH_SAFE2(keephead, current, tmp, nextToothEvent)
|
||||
{
|
||||
if (current->shouldSchedule(trgEventIndex, currentPhase, nextPhase)) {
|
||||
if (current->shouldSchedule(currentPhase, nextPhase)) {
|
||||
// time to fire a spark which was scheduled previously
|
||||
|
||||
// Yes this looks like O(n^2), but that's only over the entire engine
|
||||
|
@ -96,8 +95,8 @@ void TriggerScheduler::scheduleEventsUntilNextTriggerTooth(int rpm,
|
|||
scheduling_s * sDown = ¤t->scheduling;
|
||||
|
||||
#if SPARK_EXTREME_LOGGING
|
||||
efiPrintf("time to invoke ind=%d %d %d",
|
||||
trgEventIndex, getRevolutionCounter(), (int)getTimeNowUs());
|
||||
efiPrintf("time to invoke [%.1f, %.1f) %d %d",
|
||||
currentPhase, nextPhase, getRevolutionCounter(), (int)getTimeNowUs());
|
||||
#endif /* SPARK_EXTREME_LOGGING */
|
||||
|
||||
// In case this event was scheduled by overdwell protection, cancel it so
|
||||
|
@ -124,31 +123,15 @@ void TriggerScheduler::scheduleEventsUntilNextTriggerTooth(int rpm,
|
|||
}
|
||||
}
|
||||
|
||||
void AngleBasedEventOld::setAngle(angle_t angle) {
|
||||
position.setAngle(angle);
|
||||
}
|
||||
|
||||
bool AngleBasedEventOld::shouldSchedule(uint32_t trgEventIndex, float /*currentPhase*/, float /*nextPhase*/) const {
|
||||
return position.triggerEventIndex == trgEventIndex;
|
||||
}
|
||||
|
||||
float AngleBasedEventOld::getAngleFromNow(float /*currentPhase*/) const {
|
||||
return position.angleOffsetFromTriggerEvent;
|
||||
}
|
||||
|
||||
void AngleBasedEventNew::setAngle(angle_t angle) {
|
||||
void AngleBasedEvent::setAngle(angle_t angle) {
|
||||
this->enginePhase = angle;
|
||||
}
|
||||
|
||||
bool AngleBasedEventNew::shouldSchedule(uint32_t /*trgEventIndex*/, float currentPhase, float nextPhase) const {
|
||||
return shouldSchedule(currentPhase, nextPhase);
|
||||
}
|
||||
|
||||
bool AngleBasedEventNew::shouldSchedule(float currentPhase, float nextPhase) const {
|
||||
bool AngleBasedEvent::shouldSchedule(float currentPhase, float nextPhase) const {
|
||||
return isPhaseInRange(this->enginePhase, currentPhase, nextPhase);
|
||||
}
|
||||
|
||||
float AngleBasedEventNew::getAngleFromNow(float currentPhase) const {
|
||||
float AngleBasedEvent::getAngleFromNow(float currentPhase) const {
|
||||
float angleOffset = this->enginePhase - currentPhase;
|
||||
if (angleOffset < 0) {
|
||||
angleOffset += engine->engineState.engineCycle;
|
||||
|
@ -159,8 +142,8 @@ float AngleBasedEventNew::getAngleFromNow(float currentPhase) const {
|
|||
|
||||
#if EFI_UNIT_TEST
|
||||
// todo: reduce code duplication with another 'getElementAtIndexForUnitText'
|
||||
AngleBasedEventBase * TriggerScheduler::getElementAtIndexForUnitTest(int index) {
|
||||
AngleBasedEventBase * current;
|
||||
AngleBasedEvent * TriggerScheduler::getElementAtIndexForUnitTest(int index) {
|
||||
AngleBasedEvent * current;
|
||||
|
||||
LL_FOREACH2(m_angleBasedEventsHead, current, nextToothEvent)
|
||||
{
|
||||
|
|
|
@ -2,26 +2,25 @@
|
|||
|
||||
class TriggerScheduler : public EngineModule {
|
||||
public:
|
||||
void schedule(AngleBasedEventBase* event, angle_t angle, action_s action);
|
||||
void schedule(AngleBasedEvent* event, angle_t angle, action_s action);
|
||||
|
||||
bool scheduleOrQueue(AngleBasedEventNew *event,
|
||||
bool scheduleOrQueue(AngleBasedEvent *event,
|
||||
efitick_t edgeTimestamp,
|
||||
angle_t angle,
|
||||
action_s action,
|
||||
float currentPhase, float nextPhase);
|
||||
|
||||
void scheduleEventsUntilNextTriggerTooth(int rpm,
|
||||
uint32_t trgEventIndex,
|
||||
efitick_t edgeTimestamp,
|
||||
float currentPhase, float nextPhase);
|
||||
|
||||
// For unit tests
|
||||
AngleBasedEventBase * getElementAtIndexForUnitTest(int index);
|
||||
AngleBasedEvent * getElementAtIndexForUnitTest(int index);
|
||||
|
||||
private:
|
||||
void schedule(AngleBasedEventBase* event, action_s action);
|
||||
void schedule(AngleBasedEvent* event, action_s action);
|
||||
|
||||
bool assertNotInList(AngleBasedEventBase *head, AngleBasedEventBase *element);
|
||||
bool assertNotInList(AngleBasedEvent *head, AngleBasedEvent *element);
|
||||
|
||||
/**
|
||||
* That's the linked list of pending events scheduled in relation to trigger
|
||||
|
@ -29,5 +28,5 @@ private:
|
|||
* trigger index We can make it an array of lists per trigger index, but that would take
|
||||
* some RAM and probably not needed yet.
|
||||
*/
|
||||
AngleBasedEventBase *m_angleBasedEventsHead = nullptr;
|
||||
AngleBasedEvent *m_angleBasedEventsHead = nullptr;
|
||||
};
|
||||
|
|
|
@ -308,30 +308,11 @@ scheduling_s * EngineTestHelper::assertEvent5(const char *msg, int index, void *
|
|||
return event;
|
||||
}
|
||||
|
||||
const AngleBasedEventBase * EngineTestHelper::assertTriggerEvent(const char *msg,
|
||||
int index, AngleBasedEventBase *expected,
|
||||
void *callback,
|
||||
int triggerEventIndex, angle_t angleOffsetFromTriggerEvent) {
|
||||
AngleBasedEventBase * event2 =
|
||||
engine.module<TriggerScheduler>()->getElementAtIndexForUnitTest(index);
|
||||
|
||||
auto event = event2->asOld();
|
||||
|
||||
assertEqualsM4(msg, " callback up/down", (void*)event->action.getCallback() == (void*) callback, 1);
|
||||
|
||||
assertEqualsM4(msg, " trigger", triggerEventIndex, event->position.triggerEventIndex);
|
||||
assertEqualsM4(msg, " angle", angleOffsetFromTriggerEvent, event->position.angleOffsetFromTriggerEvent);
|
||||
return event;
|
||||
}
|
||||
|
||||
const AngleBasedEventBase * EngineTestHelper::assertTriggerEvent(const char *msg,
|
||||
int index, AngleBasedEventBase *expected,
|
||||
const AngleBasedEvent * EngineTestHelper::assertTriggerEvent(const char *msg,
|
||||
int index, AngleBasedEvent *expected,
|
||||
void *callback,
|
||||
angle_t enginePhase) {
|
||||
AngleBasedEventBase * event2 =
|
||||
engine.module<TriggerScheduler>()->getElementAtIndexForUnitTest(index);
|
||||
|
||||
auto event = event2->asNew();
|
||||
auto event = engine.module<TriggerScheduler>()->getElementAtIndexForUnitTest(index);
|
||||
|
||||
if (callback) {
|
||||
assertEqualsM4(msg, " callback up/down", (void*)event->action.getCallback() == (void*) callback, 1);
|
||||
|
|
|
@ -84,8 +84,7 @@ public:
|
|||
scheduling_s * assertEvent5(const char *msg, int index, void *callback, efitimeus_t expectedTimestamp);
|
||||
scheduling_s * assertScheduling(const char *msg, int index, scheduling_s *expected, void *callback, efitimeus_t expectedTimestamp);
|
||||
|
||||
const AngleBasedEventBase* assertTriggerEvent(const char *msg, int index, AngleBasedEventBase *expected, void *callback, int triggerEventIndex, angle_t angleOffsetFromTriggerEvent);
|
||||
const AngleBasedEventBase* assertTriggerEvent(const char *msg, int index, AngleBasedEventBase *expected, void *callback, angle_t enginePhase);
|
||||
const AngleBasedEvent* assertTriggerEvent(const char *msg, int index, AngleBasedEvent *expected, void *callback, angle_t enginePhase);
|
||||
|
||||
void assertEvent(const char *msg, int index, void *callback, efitimeus_t momentX, InjectionEvent *event);
|
||||
void assertInjectorUpEvent(const char *msg, int eventIndex, efitimeus_t momentX, long injectorIndex);
|
||||
|
|
|
@ -23,7 +23,7 @@ TEST(Actuators, AuxValves) {
|
|||
eth.assertTriggerEvent("a3", 3, &engine->auxValves[1][1].open, (void*)&auxPlainPinTurnOn, 540);
|
||||
|
||||
// Execute the first one, ensure scheduling for the "close" event happens
|
||||
engine->module<TriggerScheduler>()->scheduleEventsUntilNextTriggerTooth(1000, 0, 0, 0, 1);
|
||||
engine->module<TriggerScheduler>()->scheduleEventsUntilNextTriggerTooth(1000, 0, 0, 1);
|
||||
|
||||
// Old head should now be missing - we just ran it
|
||||
eth.assertTriggerEvent("a1", 0, &engine->auxValves[0][1].open, (void*)&auxPlainPinTurnOn, 360);
|
||||
|
|
|
@ -146,38 +146,6 @@ TEST(misc, testAngleResolver) {
|
|||
|
||||
ASSERT_EQ( 10, ts->getSize()) << "shape size";
|
||||
|
||||
event_trigger_position_s injectionStart;
|
||||
|
||||
printf("*************************************************** testAngleResolver 0\r\n");
|
||||
injectionStart.setAngle(-122);
|
||||
ASSERT_EQ( 2, injectionStart.triggerEventIndex) << "eventIndex@0";
|
||||
ASSERT_NEAR(0.24, injectionStart.angleOffsetFromTriggerEvent, EPS5D);
|
||||
|
||||
printf("*************************************************** testAngleResolver 0.1\r\n");
|
||||
injectionStart.setAngle(-80);
|
||||
ASSERT_EQ( 2, injectionStart.triggerEventIndex) << "eventIndex@0";
|
||||
ASSERT_FLOAT_EQ(42.24, injectionStart.angleOffsetFromTriggerEvent);
|
||||
|
||||
printf("*************************************************** testAngleResolver 0.2\r\n");
|
||||
injectionStart.setAngle(-54);
|
||||
ASSERT_EQ( 2, injectionStart.triggerEventIndex) << "eventIndex@0";
|
||||
ASSERT_FLOAT_EQ(68.2400, injectionStart.angleOffsetFromTriggerEvent);
|
||||
|
||||
printf("*************************************************** testAngleResolver 0.3\r\n");
|
||||
injectionStart.setAngle(-53);
|
||||
ASSERT_EQ(2, injectionStart.triggerEventIndex);
|
||||
ASSERT_FLOAT_EQ(69.24, injectionStart.angleOffsetFromTriggerEvent);
|
||||
|
||||
printf("*************************************************** testAngleResolver 1\r\n");
|
||||
injectionStart.setAngle(0);
|
||||
ASSERT_EQ(2, injectionStart.triggerEventIndex);
|
||||
ASSERT_FLOAT_EQ(122.24, injectionStart.angleOffsetFromTriggerEvent);
|
||||
|
||||
printf("*************************************************** testAngleResolver 2\r\n");
|
||||
injectionStart.setAngle(56);
|
||||
ASSERT_EQ(2, injectionStart.triggerEventIndex);
|
||||
ASSERT_FLOAT_EQ(178.24, injectionStart.angleOffsetFromTriggerEvent);
|
||||
|
||||
TriggerWaveform t;
|
||||
configureFordAspireTriggerWaveform(&t);
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ TEST(HPFP, Schedule) {
|
|||
|
||||
// Make the previous event happen, schedule the next.
|
||||
engine->module<TriggerScheduler>()->scheduleEventsUntilNextTriggerTooth(
|
||||
1000, 1, tick_per_deg * 0, 180, 360);
|
||||
1000, tick_per_deg * 0, 180, 360);
|
||||
// Mock executor doesn't run events, so we run it manually
|
||||
HpfpController::pinTurnOff(&hpfp);
|
||||
|
||||
|
@ -285,7 +285,7 @@ TEST(HPFP, Schedule) {
|
|||
|
||||
// Make it happen
|
||||
engine->module<TriggerScheduler>()->scheduleEventsUntilNextTriggerTooth(
|
||||
1000, 2, tick_per_deg * 180, 360, 540);
|
||||
1000, tick_per_deg * 180, 360, 540);
|
||||
|
||||
// Since we have a mock scheduler, lets insert the correct timestamp in the scheduling
|
||||
// struct.
|
||||
|
|
|
@ -67,45 +67,6 @@ static void testDodgeNeonDecoder() {
|
|||
TriggerDecoderBase state("test");
|
||||
|
||||
ASSERT_FALSE(state.getShaftSynchronized()) << "1 shaft_is_synchronized";
|
||||
|
||||
// int r = 0;
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 60);
|
||||
// ASSERT_FALSE(state.shaft_is_synchronized) << "2 shaft_is_synchronized"; // still no synchronization
|
||||
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 210);
|
||||
// ASSERT_FALSE(state.shaft_is_synchronized) << "3 shaft_is_synchronized"; // still no synchronization
|
||||
//
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 420);
|
||||
// ASSERT_FALSE(state.shaft_is_synchronized) << "4 shaft_is_synchronized"; // still no synchronization
|
||||
//
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 630);
|
||||
// ASSERT_FALSE(state.shaft_is_synchronized); // still no synchronization
|
||||
//
|
||||
// printf("2nd camshaft revolution\r\n");
|
||||
// r = 720;
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 60);
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 210);
|
||||
// ASSERT_TRUE(state.shaft_is_synchronized);
|
||||
// ASSERT_EQ(0, state.current_index);
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 420);
|
||||
// ASSERT_EQ(1, state.current_index);
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 630);
|
||||
// ASSERT_EQ(2, state.current_index);
|
||||
//
|
||||
// printf("3rd camshaft revolution\r\n");
|
||||
// r = 2 * 720;
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 60);
|
||||
// ASSERT_EQ( 3, state.current_index) << "current index";
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 210);
|
||||
// ASSERT_TRUE(state.shaft_is_synchronized);
|
||||
// ASSERT_EQ( 0, state.current_index) << "current index";
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_RISING, r + 420);
|
||||
// processTriggerEvent(&state, shape, &ec->triggerConfig, SHAFT_PRIMARY_FALLING, r + 630);
|
||||
}
|
||||
|
||||
static void assertTriggerPosition(event_trigger_position_s *position, int eventIndex, float angleOffset) {
|
||||
assertEqualsM("eventIndex", eventIndex, position->triggerEventIndex);
|
||||
assertEqualsM("angleOffset", angleOffset, position->angleOffsetFromTriggerEvent);
|
||||
}
|
||||
|
||||
TEST(trigger, testSomethingWeird) {
|
||||
|
@ -148,17 +109,6 @@ TEST(trigger, test1995FordInline6TriggerDecoder) {
|
|||
|
||||
ASSERT_EQ( 0, shape->getTriggerWaveformSynchPointIndex()) << "triggerShapeSynchPointIndex";
|
||||
|
||||
event_trigger_position_s position;
|
||||
ASSERT_EQ( 0, engineConfiguration->globalTriggerAngleOffset) << "globalTriggerAngleOffset";
|
||||
position.setAngle(0);
|
||||
assertTriggerPosition(&position, 0, 0);
|
||||
|
||||
position.setAngle(200);
|
||||
assertTriggerPosition(&position, 2, 80);
|
||||
|
||||
position.setAngle(360);
|
||||
assertTriggerPosition(&position, 6, 0);
|
||||
|
||||
eth.applyTriggerWaveform();
|
||||
|
||||
engine->periodicFastCallback();
|
||||
|
|
Loading…
Reference in New Issue