something is over-complicated here? looks like two classes should become one?

This commit is contained in:
rusefi 2019-10-08 02:35:21 -04:00
parent fbbf8995e4
commit a65c8c9295
6 changed files with 33 additions and 34 deletions

View File

@ -53,8 +53,6 @@ public:
void setConfig(persistent_config_s *config);
injection_mode_e getCurrentInjectionMode(DECLARE_ENGINE_PARAMETER_SIGNATURE);
InjectionSignalPair fuelActuators[INJECTION_PIN_COUNT];
IgnitionEventList ignitionEvents;
LocalVersionHolder versionForConfigurationListeners;
LocalVersionHolder auxParametersVersion;
operation_mode_e getOperationMode(DECLARE_ENGINE_PARAMETER_SIGNATURE);
@ -93,6 +91,7 @@ public:
#if EFI_ENGINE_CONTROL
FuelSchedule injectionEvents;
IgnitionEventList ignitionEvents;
#endif /* EFI_ENGINE_CONTROL */
WallFuel wallFuel;

View File

@ -13,10 +13,32 @@
#include "trigger_structure.h"
#define MAX_INJECTION_OUTPUT_COUNT INJECTION_PIN_COUNT
#define MAX_WIRES_COUNT 2
class Engine;
class InjectionEvent;
class InjectionSignalPair {
public:
InjectionSignalPair();
scheduling_s signalTimerUp;
scheduling_s endOfInjectionEvent;
/**
* we need atomic flag so that we do not schedule a new pair of up/down before previous down was executed.
*
* That's because we want to be sure that no 'down' side callback would be ignored since we are counting to see
* overlaps so we need the end counter to always have zero.
* TODO: make watchdog decrement relevant counter
*/
bool isScheduled;
InjectorOutputPin *outputs[MAX_WIRES_COUNT];
InjectionEvent *event;
};
class InjectionEvent {
public:
InjectionEvent();
@ -31,8 +53,11 @@ public:
Engine *engine;
#endif
event_trigger_position_s injectionStart;
InjectionSignalPair pair;
};
/**
* This class knows about when to inject fuel
*/

View File

@ -832,6 +832,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20191006;
return 20191007;
}
#endif /* EFI_UNIT_TEST */

View File

@ -6,8 +6,7 @@
* @author Andrey Belomutskiy, (c) 2012-2017
*/
#ifndef SIGNAL_EXECUTOR_H_
#define SIGNAL_EXECUTOR_H_
#pragma once
#include "global.h"
#include "scheduler.h"
@ -17,28 +16,4 @@
#include "signal_executor_sleep.h"
#endif /* EFI_SIGNAL_EXECUTOR_SLEEP */
#define MAX_WIRES_COUNT 2
class InjectionEvent;
class InjectionSignalPair {
public:
InjectionSignalPair();
scheduling_s signalTimerUp;
scheduling_s endOfInjectionEvent;
/**
* we need atomic flag so that we do not schedule a new pair of up/down before previous down was executed.
*
* That's because we want to be sure that no 'down' side callback would be ignored since we are counting to see
* overlaps so we need the end counter to always have zero.
* TODO: make watchdog decrement relevant counter
*/
bool isScheduled;
InjectorOutputPin *outputs[MAX_WIRES_COUNT];
InjectionEvent *event;
};
#endif /* SIGNAL_EXECUTOR_H_ */

View File

@ -271,7 +271,7 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
getRevolutionCounter());
#endif /* EFI_DEFAILED_LOGGING */
InjectionSignalPair *pair = &ENGINE(fuelActuators[injEventIndex]);
InjectionSignalPair *pair = &event->pair;
if (event->isSimultanious) {
/**
@ -582,7 +582,7 @@ void startPrimeInjectionPulse(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
primeInjEvent.ownIndex = 0;
primeInjEvent.isSimultanious = true;
scheduling_s *sDown = &ENGINE(fuelActuators[0]).endOfInjectionEvent;
scheduling_s *sDown = &ENGINE(injectionEvents.elements[0].pair).endOfInjectionEvent;
// When the engine is hot, basically we don't need prime inj.pulse, so we use an interpolation over temperature (falloff).
// If 'primeInjFalloffTemperature' is not specified (by default), we have a prime pulse deactivation at zero celsius degrees, which is okay.
const float maxPrimeInjAtTemperature = -40.0f; // at this temperature the pulse is maximal.

View File

@ -152,12 +152,12 @@ void EngineTestHelper::fireTriggerEvents(int count) {
}
void EngineTestHelper::assertInjectorUpEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex) {
InjectionSignalPair *pair = &engine.fuelActuators[injectorIndex];
InjectionSignalPair *pair = &engine.injectionEvents.elements[injectorIndex].pair;
assertEvent(msg, eventIndex, (void*)seTurnPinHigh, momentX, (long)pair);
}
void EngineTestHelper::assertInjectorDownEvent(const char *msg, int eventIndex, efitime_t momentX, long injectorIndex) {
InjectionSignalPair *pair = &engine.fuelActuators[injectorIndex];
InjectionSignalPair *pair = &engine.injectionEvents.elements[injectorIndex].pair;
assertEvent(msg, eventIndex, (void*)seTurnPinLow, momentX, (long)pair);
}