refactoring: better field name(s)

This commit is contained in:
rusefi 2019-10-08 01:03:57 -04:00
parent ca67249522
commit 1ab488e4b4
6 changed files with 29 additions and 30 deletions

View File

@ -373,8 +373,8 @@ void TriggerShape::findTriggerPosition(event_trigger_position_s *position,
}
position->triggerEventIndex = triggerEventIndex;
position->eventAngle = triggerEventAngle;
position->angleOffset = angle - triggerEventAngle;
position->triggerEventAngle = triggerEventAngle;
position->angleOffsetFromTriggerEvent = angle - triggerEventAngle;
}
void TriggerShape::prepareShape() {

View File

@ -43,19 +43,18 @@
}
/**
* This structure defines an angle position within the trigger
* This structure defines an angle position in relation to specific tooth within trigger shape
*/
class event_trigger_position_s {
public:
/**
* That's trigger event index
*/
uint32_t triggerEventIndex = 0;
angle_t eventAngle = 0;
/**
* Angle offset from the trigger event
* angle of that 'triggerEventIndex' event
* todo: Technically we can simply take angle of trigger event from trigger shape by 'triggerEventIndex'?
*/
angle_t angleOffset = 0;
angle_t triggerEventAngle = 0;
angle_t angleOffsetFromTriggerEvent = 0;
};
#define TRIGGER_CHANNEL_COUNT 3
@ -84,7 +83,7 @@ public:
void initializeTriggerShape(Logging *logger, operation_mode_e ambiguousOperationMode,
bool useOnlyRisingEdgeForTrigger, const trigger_config_s *triggerConfig);
void findTriggerPosition(event_trigger_position_s *position,
angle_t angleOffset DEFINE_CONFIG_PARAM(angle_t, globalTriggerAngleOffset));
angle_t angle DEFINE_CONFIG_PARAM(angle_t, globalTriggerAngleOffset));
void setShapeDefinitionError(bool value);
/**

View File

@ -260,7 +260,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
// scheduleMsg(logger, "handleFuel engineCycleDuration=%.2f", engineCycleDuration);
#endif /* FUEL_MATH_EXTREME_LOGGING */
floatus_t injectionStartDelayUs = ENGINE(rpmCalculator.oneDegreeUs) * event->injectionStart.angleOffset;
floatus_t injectionStartDelayUs = ENGINE(rpmCalculator.oneDegreeUs) * event->injectionStart.angleOffsetFromTriggerEvent;
#if EFI_DEFAILED_LOGGING
scheduleMsg(logger, "handleFuel pin=%s eventIndex %d duration=%.2fms %d", event->outputs[0]->name,
@ -290,7 +290,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
} else {
#if EFI_UNIT_TEST
printf("scheduling injection angle=%.2f/delay=%.2f injectionDuration=%.2f\r\n", event->injectionStart.angleOffset, injectionStartDelayUs, injectionDuration);
printf("scheduling injection angle=%.2f/delay=%.2f injectionDuration=%.2f\r\n", event->injectionStart.angleOffsetFromTriggerEvent, injectionStartDelayUs, injectionDuration);
#endif
// we are in this branch of code only in case of NOT IM_SIMULTANEOUS/IM_SINGLE_POINT injection

View File

@ -224,7 +224,7 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI
return;
}
floatus_t chargeDelayUs = ENGINE(rpmCalculator.oneDegreeUs) * iEvent->dwellPosition.angleOffset;
floatus_t chargeDelayUs = ENGINE(rpmCalculator.oneDegreeUs) * iEvent->dwellPosition.angleOffsetFromTriggerEvent;
int isIgnitionError = chargeDelayUs < 0;
ignitionErrorDetection.add(isIgnitionError);
if (isIgnitionError) {
@ -273,8 +273,8 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI
#if EFI_UNIT_TEST
if (verboseMode) {
printf("spark dwell@ %d/%d spark@ %d/%d id=%d\r\n", iEvent->dwellPosition.triggerEventIndex, (int)iEvent->dwellPosition.angleOffset,
iEvent->sparkPosition.triggerEventIndex, (int)iEvent->sparkPosition.angleOffset,
printf("spark dwell@ %d/%d spark@ %d/%d id=%d\r\n", iEvent->dwellPosition.triggerEventIndex, (int)iEvent->dwellPosition.angleOffsetFromTriggerEvent,
iEvent->sparkPosition.triggerEventAngle, (int)iEvent->sparkPosition.angleOffsetFromTriggerEvent,
iEvent->sparkId);
}
#endif
@ -296,7 +296,7 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI
/**
* Spark should be fired before the next trigger event - time-based delay is best precision possible
*/
float timeTillIgnitionUs = ENGINE(rpmCalculator.oneDegreeUs) * iEvent->sparkPosition.angleOffset;
float timeTillIgnitionUs = ENGINE(rpmCalculator.oneDegreeUs) * iEvent->sparkPosition.angleOffsetFromTriggerEvent;
#if SPARK_EXTREME_LOGGING
scheduleMsg(logger, "scheduling sparkDown ind=%d %d %s now=%d %d later id=%d", trgEventIndex, getRevolutionCounter(), iEvent->getOutputForLoggins()->name, (int)getTimeNowUs(), (int)timeTillIgnitionUs, iEvent->sparkId);
@ -392,7 +392,7 @@ static void scheduleAllSparkEventsUntilNextTriggerTooth(uint32_t trgEventIndex D
#endif /* FUEL_MATH_EXTREME_LOGGING */
float timeTillIgnitionUs = ENGINE(rpmCalculator.oneDegreeUs) * current->sparkPosition.angleOffset;
float timeTillIgnitionUs = ENGINE(rpmCalculator.oneDegreeUs) * current->sparkPosition.angleOffsetFromTriggerEvent;
engine->executor.scheduleForLater(sDown, (int) timeTillIgnitionUs, (schfunc_t) &fireSparkAndPrepareNextSchedule, current);
}
}

View File

@ -183,32 +183,32 @@ TEST(misc, testAngleResolver) {
printf("*************************************************** testAngleResolver 0\r\n");
TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -122, engineConfiguration->globalTriggerAngleOffset));
ASSERT_EQ( 2, injectionStart.triggerEventIndex) << "eventIndex@0";
ASSERT_NEAR(0.24, injectionStart.angleOffset, EPS5D);
ASSERT_NEAR(0.24, injectionStart.angleOffsetFromTriggerEvent, EPS5D);
printf("*************************************************** testAngleResolver 0.1\r\n");
TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -80, engineConfiguration->globalTriggerAngleOffset));
ASSERT_EQ( 2, injectionStart.triggerEventIndex) << "eventIndex@0";
ASSERT_FLOAT_EQ(42.24, injectionStart.angleOffset);
ASSERT_FLOAT_EQ(42.24, injectionStart.angleOffsetFromTriggerEvent);
printf("*************************************************** testAngleResolver 0.2\r\n");
TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -54, engineConfiguration->globalTriggerAngleOffset));
ASSERT_EQ( 2, injectionStart.triggerEventIndex) << "eventIndex@0";
ASSERT_FLOAT_EQ(68.2400, injectionStart.angleOffset);
ASSERT_FLOAT_EQ(68.2400, injectionStart.angleOffsetFromTriggerEvent);
printf("*************************************************** testAngleResolver 0.3\r\n");
TRIGGER_SHAPE(findTriggerPosition(&injectionStart, -53, engineConfiguration->globalTriggerAngleOffset));
ASSERT_EQ(2, injectionStart.triggerEventIndex);
ASSERT_FLOAT_EQ(69.24, injectionStart.angleOffset);
ASSERT_FLOAT_EQ(69.24, injectionStart.angleOffsetFromTriggerEvent);
printf("*************************************************** testAngleResolver 1\r\n");
TRIGGER_SHAPE(findTriggerPosition(&injectionStart, 0, engineConfiguration->globalTriggerAngleOffset));
ASSERT_EQ(2, injectionStart.triggerEventIndex);
ASSERT_FLOAT_EQ(122.24, injectionStart.angleOffset);
ASSERT_FLOAT_EQ(122.24, injectionStart.angleOffsetFromTriggerEvent);
printf("*************************************************** testAngleResolver 2\r\n");
TRIGGER_SHAPE(findTriggerPosition(&injectionStart, 56, engineConfiguration->globalTriggerAngleOffset));
ASSERT_EQ(2, injectionStart.triggerEventIndex);
ASSERT_FLOAT_EQ(178.24, injectionStart.angleOffset);
ASSERT_FLOAT_EQ(178.24, injectionStart.angleOffsetFromTriggerEvent);
TriggerShape t;
confgiureFordAspireTriggerShape(&t);

View File

@ -104,7 +104,7 @@ static void testDodgeNeonDecoder(void) {
static void assertTriggerPosition(event_trigger_position_s *position, int eventIndex, float angleOffset) {
assertEqualsM("eventIndex", eventIndex, position->triggerEventIndex);
assertEqualsM("angleOffset", angleOffset, position->angleOffset);
assertEqualsM("angleOffset", angleOffset, position->angleOffsetFromTriggerEvent);
}
TEST(misc, testSomethingWeird) {
@ -177,10 +177,10 @@ TEST(misc, test1995FordInline6TriggerDecoder) {
IgnitionEventList *ecl = &engine->ignitionEvents;
ASSERT_EQ( 1, ecl->isReady) << "ford inline ignition events size";
ASSERT_EQ( 0, ecl->elements[0].dwellPosition.triggerEventIndex) << "event index";
ASSERT_NEAR(7.8621, ecl->elements[0].dwellPosition.angleOffset, EPS4D) << "angle offset#1";
ASSERT_NEAR(7.8621, ecl->elements[0].dwellPosition.angleOffsetFromTriggerEvent, EPS4D) << "angle offset#1";
ASSERT_EQ( 10, ecl->elements[5].dwellPosition.triggerEventIndex) << "event index";
ASSERT_NEAR(7.8621, ecl->elements[5].dwellPosition.angleOffset, EPS4D) << "angle offset#2";
ASSERT_NEAR(7.8621, ecl->elements[5].dwellPosition.angleOffsetFromTriggerEvent, EPS4D) << "angle offset#2";
ASSERT_FLOAT_EQ(0.5, getSparkDwell(2000 PASS_ENGINE_PARAMETER_SUFFIX)) << "running dwell";
@ -330,7 +330,7 @@ TEST(misc, testRpmCalculator) {
assertEqualsM("fuel #1", 4.5450, engine->injectionDuration);
InjectionEvent *ie0 = &engine->injectionEvents.elements[0];
assertEqualsM("injection angle", 31.365, ie0->injectionStart.angleOffset);
assertEqualsM("injection angle", 31.365, ie0->injectionStart.angleOffsetFromTriggerEvent);
eth.firePrimaryTriggerRise();
ASSERT_EQ(1500, eth.engine.rpmCalculator.rpmValue);
@ -339,8 +339,8 @@ TEST(misc, testRpmCalculator) {
assertEqualsM("fuel #2", 4.5450, engine->injectionDuration);
assertEqualsM("one degree", 111.1111, engine->rpmCalculator.oneDegreeUs);
ASSERT_EQ( 1, ilist->isReady) << "size #2";
ASSERT_EQ( 0, ilist->elements[0].dwellPosition.eventAngle) << "dwell angle";
assertEqualsM("dwell offset", 8.5, ilist->elements[0].dwellPosition.angleOffset);
ASSERT_EQ( 0, ilist->elements[0].dwellPosition.triggerEventAngle) << "dwell angle";
assertEqualsM("dwell offset", 8.5, ilist->elements[0].dwellPosition.angleOffsetFromTriggerEvent);
ASSERT_EQ( 0, eth.engine.triggerCentral.triggerState.getCurrentIndex()) << "index #2";
ASSERT_EQ( 2, engine->executor.size()) << "queue size/2";
@ -555,7 +555,7 @@ extern fuel_Map3D_t fuelMap;
static void assertInjectionEvent(const char *msg, InjectionEvent *ev, int injectorIndex, int eventIndex, angle_t angleOffset, bool isOverlapping) {
assertEqualsM4(msg, "inj index", injectorIndex, ev->outputs[0]->injectorIndex);
assertEqualsM4(msg, " event index", eventIndex, ev->injectionStart.triggerEventIndex);
assertEqualsM4(msg, " event offset", angleOffset, ev->injectionStart.angleOffset);
assertEqualsM4(msg, " event offset", angleOffset, ev->injectionStart.angleOffsetFromTriggerEvent);
}
static void setTestBug299(EngineTestHelper *eth) {