auto-sync
This commit is contained in:
parent
1fe848275f
commit
be693a33a3
|
@ -27,7 +27,6 @@
|
||||||
InjectionEvent::InjectionEvent() {
|
InjectionEvent::InjectionEvent() {
|
||||||
isSimultanious = false;
|
isSimultanious = false;
|
||||||
isOverlapping = false;
|
isOverlapping = false;
|
||||||
injectorIndex = 0;
|
|
||||||
output = NULL;
|
output = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ public:
|
||||||
*/
|
*/
|
||||||
bool isSimultanious;
|
bool isSimultanious;
|
||||||
InjectorOutputPin *output;
|
InjectorOutputPin *output;
|
||||||
int injectorIndex;
|
|
||||||
bool isOverlapping;
|
bool isOverlapping;
|
||||||
|
|
||||||
event_trigger_position_s injectionStart;
|
event_trigger_position_s injectionStart;
|
||||||
|
|
|
@ -43,7 +43,7 @@ extern WaveChart waveChart;
|
||||||
|
|
||||||
OutputSignalPair::OutputSignalPair() {
|
OutputSignalPair::OutputSignalPair() {
|
||||||
isScheduled = false;
|
isScheduled = false;
|
||||||
output = NULL;
|
memset(outputs, 0, sizeof(outputs));
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSignalExecutor(void) {
|
void initSignalExecutor(void) {
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include "signal_executor_sleep.h"
|
#include "signal_executor_sleep.h"
|
||||||
#endif /* EFI_SIGNAL_EXECUTOR_SLEEP */
|
#endif /* EFI_SIGNAL_EXECUTOR_SLEEP */
|
||||||
|
|
||||||
|
#define MAX_WIRES_COUNT 2
|
||||||
|
|
||||||
class OutputSignalPair {
|
class OutputSignalPair {
|
||||||
public:
|
public:
|
||||||
OutputSignalPair();
|
OutputSignalPair();
|
||||||
|
@ -38,7 +40,7 @@ public:
|
||||||
* TODO: make watchdog decrement relevant counter
|
* TODO: make watchdog decrement relevant counter
|
||||||
*/
|
*/
|
||||||
bool isScheduled;
|
bool isScheduled;
|
||||||
InjectorOutputPin *output;
|
InjectorOutputPin *outputs[MAX_WIRES_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -111,7 +111,6 @@ void FuelSchedule::registerInjectionEvent(int injectorIndex, float angle, angle_
|
||||||
fixAngle(angle);
|
fixAngle(angle);
|
||||||
ev->isOverlapping = angle < 720 && (angle + injectionDuration) > 720;
|
ev->isOverlapping = angle < 720 && (angle + injectionDuration) > 720;
|
||||||
|
|
||||||
ev->injectorIndex = injectorIndex;
|
|
||||||
ev->output = output;
|
ev->output = output;
|
||||||
|
|
||||||
ev->isSimultanious = isSimultanious;
|
ev->isSimultanious = isSimultanious;
|
||||||
|
|
|
@ -29,6 +29,7 @@ NamedOutputPin::NamedOutputPin(const char *name) : OutputPin() {
|
||||||
|
|
||||||
InjectorOutputPin::InjectorOutputPin() : NamedOutputPin() {
|
InjectorOutputPin::InjectorOutputPin() : NamedOutputPin() {
|
||||||
reset();
|
reset();
|
||||||
|
injectorIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *sparkNames[IGNITION_PIN_COUNT] = { "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8",
|
static const char *sparkNames[IGNITION_PIN_COUNT] = { "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8",
|
||||||
|
@ -46,6 +47,7 @@ EnginePins::EnginePins() {
|
||||||
enginePins.coils[i].name = sparkNames[i];
|
enginePins.coils[i].name = sparkNames[i];
|
||||||
}
|
}
|
||||||
for (int i = 0; i < INJECTION_PIN_COUNT;i++) {
|
for (int i = 0; i < INJECTION_PIN_COUNT;i++) {
|
||||||
|
enginePins.injectors[i].injectorIndex = i;
|
||||||
enginePins.injectors[i].name = injectorNames[i];
|
enginePins.injectors[i].name = injectorNames[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
InjectorOutputPin();
|
InjectorOutputPin();
|
||||||
void reset();
|
void reset();
|
||||||
efitimeus_t overlappingScheduleOffTime;
|
efitimeus_t overlappingScheduleOffTime;
|
||||||
|
int injectorIndex;
|
||||||
bool cancelNextTurningInjectorOff;
|
bool cancelNextTurningInjectorOff;
|
||||||
int overlappingCounter;
|
int overlappingCounter;
|
||||||
};
|
};
|
||||||
|
|
|
@ -87,9 +87,7 @@ static void endSimultaniousInjection(Engine *engine) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: make these macro? kind of a penny optimization if compiler is not smart to inline
|
static void tempTurnPinHigh(InjectorOutputPin *output) {
|
||||||
void seTurnPinHigh(OutputSignalPair *pair) {
|
|
||||||
InjectorOutputPin *output = pair->output;
|
|
||||||
output->overlappingCounter++;
|
output->overlappingCounter++;
|
||||||
|
|
||||||
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)
|
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)
|
||||||
|
@ -121,9 +119,13 @@ void seTurnPinHigh(OutputSignalPair *pair) {
|
||||||
turnPinHigh(output);
|
turnPinHigh(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void seTurnPinLow(OutputSignalPair *pair) {
|
// todo: make these macro? kind of a penny optimization if compiler is not smart to inline
|
||||||
pair->isScheduled = false;
|
void seTurnPinHigh(OutputSignalPair *pair) {
|
||||||
InjectorOutputPin *output = pair->output;
|
InjectorOutputPin *output = pair->outputs[0];
|
||||||
|
tempTurnPinHigh(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tempTurnPinLow(InjectorOutputPin *output) {
|
||||||
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)
|
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)
|
||||||
printf("seTurnPinLow %s %d %d\r\n", output->name, output->overlappingCounter, (int)getTimeNowUs());
|
printf("seTurnPinLow %s %d %d\r\n", output->name, output->overlappingCounter, (int)getTimeNowUs());
|
||||||
#endif /* FUEL_MATH_EXTREME_LOGGING */
|
#endif /* FUEL_MATH_EXTREME_LOGGING */
|
||||||
|
@ -162,8 +164,14 @@ void seTurnPinLow(OutputSignalPair *pair) {
|
||||||
turnPinLow(output);
|
turnPinLow(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void seTurnPinLow(OutputSignalPair *pair) {
|
||||||
|
pair->isScheduled = false;
|
||||||
|
InjectorOutputPin *output = pair->outputs[0];
|
||||||
|
tempTurnPinLow(output);
|
||||||
|
}
|
||||||
|
|
||||||
static void seScheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, OutputSignalPair *pair) {
|
static void seScheduleByTime(const char *prefix, scheduling_s *scheduling, efitimeus_t time, schfunc_t callback, OutputSignalPair *pair) {
|
||||||
InjectorOutputPin *param = pair->output;
|
InjectorOutputPin *param = pair->outputs[0];
|
||||||
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)
|
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)
|
||||||
// scheduleMsg(&sharedLogger, "schX %s %x %d", prefix, scheduling, time);
|
// scheduleMsg(&sharedLogger, "schX %s %x %d", prefix, scheduling, time);
|
||||||
// scheduleMsg(&sharedLogger, "schX %s", param->name);
|
// scheduleMsg(&sharedLogger, "schX %s", param->name);
|
||||||
|
@ -200,7 +208,7 @@ static void scheduleFuelInjection(int rpm, OutputSignal *signal, efitimeus_t now
|
||||||
#endif /* EFI_UNIT_TEST || EFI_SIMULATOR */
|
#endif /* EFI_UNIT_TEST || EFI_SIMULATOR */
|
||||||
return; // this OutputSignalPair is still needed for an extremely long injection scheduled previously
|
return; // this OutputSignalPair is still needed for an extremely long injection scheduled previously
|
||||||
}
|
}
|
||||||
pair->output = output;
|
pair->outputs[0] = output;
|
||||||
scheduling_s * sUp = &pair->signalTimerUp;
|
scheduling_s * sUp = &pair->signalTimerUp;
|
||||||
scheduling_s * sDown = &pair->signalTimerDown;
|
scheduling_s * sDown = &pair->signalTimerDown;
|
||||||
|
|
||||||
|
@ -229,7 +237,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
||||||
* wetting coefficient works the same way for any injection mode, or is something
|
* wetting coefficient works the same way for any injection mode, or is something
|
||||||
* x2 or /2?
|
* x2 or /2?
|
||||||
*/
|
*/
|
||||||
const floatms_t injectionDuration = ENGINE(wallFuel).adjust(event->injectorIndex, ENGINE(fuelMs) PASS_ENGINE_PARAMETER);
|
const floatms_t injectionDuration = ENGINE(wallFuel).adjust(event->output->injectorIndex, ENGINE(fuelMs) PASS_ENGINE_PARAMETER);
|
||||||
#if EFI_PRINTF_FUEL_DETAILS || defined(__DOXYGEN__)
|
#if EFI_PRINTF_FUEL_DETAILS || defined(__DOXYGEN__)
|
||||||
printf("fuel fuelMs=%f adjusted=%f\t\n", ENGINE(fuelMs), injectionDuration);
|
printf("fuel fuelMs=%f adjusted=%f\t\n", ENGINE(fuelMs), injectionDuration);
|
||||||
#endif /*EFI_PRINTF_FUEL_DETAILS */
|
#endif /*EFI_PRINTF_FUEL_DETAILS */
|
||||||
|
@ -332,7 +340,7 @@ static void scheduleOutput2(OutputSignalPair *pair, efitimeus_t nowUs, float del
|
||||||
pair->isScheduled = true;
|
pair->isScheduled = true;
|
||||||
scheduling_s *sDown = &pair->signalTimerDown;
|
scheduling_s *sDown = &pair->signalTimerDown;
|
||||||
|
|
||||||
pair->output = output;
|
pair->outputs[0] = output;
|
||||||
seScheduleByTime("out up2", sUp, turnOnTime, (schfunc_t) &seTurnPinHigh, pair);
|
seScheduleByTime("out up2", sUp, turnOnTime, (schfunc_t) &seTurnPinHigh, pair);
|
||||||
efitimeus_t turnOffTime = nowUs + (int) (delayUs + durationUs);
|
efitimeus_t turnOffTime = nowUs + (int) (delayUs + durationUs);
|
||||||
|
|
||||||
|
@ -352,7 +360,7 @@ static void handleFuelScheduleOverlap(InjectionEventList *injectionEvents DECLAR
|
||||||
if (!engine->engineConfiguration2->wasOverlapping[injEventIndex] && event->isOverlapping) {
|
if (!engine->engineConfiguration2->wasOverlapping[injEventIndex] && event->isOverlapping) {
|
||||||
// we are here if new fuel schedule is crossing engine cycle boundary with this event
|
// we are here if new fuel schedule is crossing engine cycle boundary with this event
|
||||||
|
|
||||||
InjectorOutputPin *output = &enginePins.injectors[event->injectorIndex];
|
InjectorOutputPin *output = event->output;
|
||||||
|
|
||||||
// todo: recalc fuel? account for wetting?
|
// todo: recalc fuel? account for wetting?
|
||||||
floatms_t injectionDuration = ENGINE(fuelMs);
|
floatms_t injectionDuration = ENGINE(fuelMs);
|
||||||
|
|
|
@ -588,7 +588,7 @@ void assertEvent(const char *msg, int index, void *callback, efitime_t start, ef
|
||||||
assertEqualsM4(msg, "up/down", (void*)ev->callback == (void*) callback, 1);
|
assertEqualsM4(msg, "up/down", (void*)ev->callback == (void*) callback, 1);
|
||||||
assertEqualsM(msg, momentX, ev->momentX - start);
|
assertEqualsM(msg, momentX, ev->momentX - start);
|
||||||
OutputSignalPair *pair = (OutputSignalPair *)ev->param;
|
OutputSignalPair *pair = (OutputSignalPair *)ev->param;
|
||||||
assertEqualsLM(msg, param, (long)pair->output);
|
assertEqualsLM(msg, param, (long)pair->outputs[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertInjectorUpEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex) {
|
void assertInjectorUpEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex) {
|
||||||
|
@ -600,7 +600,7 @@ void assertInjectorDownEvent(const char *msg, int eventIndex, efitime_t momentX,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void assertInjectionEvent(const char *msg, InjectionEvent *ev, int injectorIndex, int eventIndex, angle_t angleOffset, bool isOverlapping) {
|
static void assertInjectionEvent(const char *msg, InjectionEvent *ev, int injectorIndex, int eventIndex, angle_t angleOffset, bool isOverlapping) {
|
||||||
assertEqualsM4(msg, "inj index", injectorIndex, ev->injectorIndex);
|
assertEqualsM4(msg, "inj index", injectorIndex, ev->output->injectorIndex);
|
||||||
assertEqualsM4(msg, " event index", eventIndex, ev->injectionStart.eventIndex);
|
assertEqualsM4(msg, " event index", eventIndex, ev->injectionStart.eventIndex);
|
||||||
assertEqualsM4(msg, " event offset", angleOffset, ev->injectionStart.angleOffset);
|
assertEqualsM4(msg, " event offset", angleOffset, ev->injectionStart.angleOffset);
|
||||||
assertTrueM("is overlapping", isOverlapping == ev->isOverlapping);
|
assertTrueM("is overlapping", isOverlapping == ev->isOverlapping);
|
||||||
|
|
Loading…
Reference in New Issue