deep rabbit holes are the best ones!

refactoring: encapsulation
This commit is contained in:
Andrey 2022-09-14 02:17:04 -04:00
parent 12d857b99c
commit 2c0ce0ec7d
10 changed files with 25 additions and 16 deletions

View File

@ -242,7 +242,7 @@ void LogTriggerTooth(trigger_event_e tooth, efitick_t timestamp) {
}
// Don't log at significant engine speed
if (!engine->isEngineSnifferEnabled) {
if (!getTriggerCentral()->isEngineSnifferEnabled) {
return;
}

View File

@ -261,7 +261,7 @@ void Engine::updateSlowSensors() {
#if EFI_ENGINE_CONTROL
int rpm = Sensor::getOrZero(SensorType::Rpm);
isEngineSnifferEnabled = rpm < engineConfiguration->engineSnifferRpmThreshold;
triggerCentral.isEngineSnifferEnabled = rpm < engineConfiguration->engineSnifferRpmThreshold;
sensorChartMode = rpm < engineConfiguration->sensorSnifferRpmThreshold ? engineConfiguration->sensorChartMode : SC_OFF;
engineState.updateSlowSensors();
@ -609,3 +609,7 @@ ExecutorInterface *getExecutorInterface() {
TriggerCentral * getTriggerCentral() {
return &engine->triggerCentral;
}
LimpManager * getLimpManager() {
return &engine->limpManager;
}

View File

@ -220,10 +220,6 @@ public:
// todo: move to electronic_throttle something?
bool etbAutoTune = false;
/**
* this is based on engineSnifferRpmThreshold settings and current RPM
*/
bool isEngineSnifferEnabled = false;
#if EFI_UNIT_TEST
bool tdcMarkEnabled = true;

View File

@ -365,7 +365,7 @@ static void onTdcCallback(void *) {
void tdcMarkCallback(
uint32_t trgEventIndex, efitick_t edgeTimestamp) {
bool isTriggerSynchronizationPoint = trgEventIndex == 0;
if (isTriggerSynchronizationPoint && engine->isEngineSnifferEnabled) {
if (isTriggerSynchronizationPoint && getTriggerCentral()->isEngineSnifferEnabled) {
#if EFI_UNIT_TEST
if (!engine->tdcMarkEnabled) {

View File

@ -183,7 +183,7 @@ operation_mode_e lookupOperationMode();
#define getRevolutionCounter() (engine->rpmCalculator.getRevolutionCounterM())
#if EFI_ENGINE_SNIFFER
#define addEngineSnifferEvent(name, msg) { if (engine->isEngineSnifferEnabled) { waveChart.addEvent3((name), (msg)); } }
#define addEngineSnifferEvent(name, msg) { if (getTriggerCentral()->isEngineSnifferEnabled) { waveChart.addEvent3((name), (msg)); } }
#else
#define addEngineSnifferEvent(n, msg) {}
#endif /* EFI_ENGINE_SNIFFER */

View File

@ -115,3 +115,7 @@ private:
Timer m_engineStopTimer;
};
LimpManager * getLimpManager();

View File

@ -451,7 +451,7 @@ void handleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp) {
}
// Don't accept trigger input in case of some problems
if (!engine->limpManager.allowTriggerInput()) {
if (!getLimpManager()->allowTriggerInput()) {
return;
}
@ -520,8 +520,8 @@ static const bool isUpEvent[4] = { false, true, false, true };
static const int wheelIndeces[4] = { 0, 0, 1, 1};
static void reportEventToWaveChart(trigger_event_e ckpSignalType, int triggerEventIndex) {
if (!engine->isEngineSnifferEnabled) { // this is here just as a shortcut so that we avoid engine sniffer as soon as possible
return; // engineSnifferRpmThreshold is accounted for inside engine->isEngineSnifferEnabled
if (!getTriggerCentral()->isEngineSnifferEnabled) { // this is here just as a shortcut so that we avoid engine sniffer as soon as possible
return; // engineSnifferRpmThreshold is accounted for inside getTriggerCentral()->isEngineSnifferEnabled
}
int wheelIndex = wheelIndeces[(int )ckpSignalType];
@ -631,7 +631,7 @@ void TriggerCentral::decodeMapCam(efitick_t timestamp, float currentPhase) {
// but current implementation which is based on periodicFastCallback would only make result available on NEXT tooth
int rpm = Sensor::getOrZero(SensorType::Rpm);
efitick_t nowNt = getTimeNowNt();
engine->limpManager.updateState(rpm, nowNt);
getLimpManager()->updateState(rpm, nowNt);
#endif // EFI_UNIT_TEST
}

View File

@ -153,6 +153,11 @@ public:
// Keep track of the last time we got a valid trigger event
Timer m_lastEventTimer;
/**
* this is based on engineSnifferRpmThreshold settings and current RPM
*/
bool isEngineSnifferEnabled = false;
private:
void decodeMapCam(efitick_t nowNt, float currentPhase);

View File

@ -611,7 +611,7 @@ expected<TriggerDecodeResult> TriggerDecoderBase::decodeTriggerEvent(
#endif /* EFI_UNIT_TEST */
#if EFI_PROD_CODE || EFI_SIMULATOR
bool verbose = engine->isEngineSnifferEnabled && triggerConfiguration.VerboseTriggerSynchDetails;
bool verbose = getTriggerCentral()->isEngineSnifferEnabled && triggerConfiguration.VerboseTriggerSynchDetails;
if (verbose || (someSortOfTriggerError() && !silentTriggerError)) {
const char * prefix = verbose ? "[vrb]" : "[err]";

View File

@ -114,7 +114,7 @@ int WaveChart::getSize() {
#if ! EFI_UNIT_TEST
static void printStatus() {
efiPrintf("engine sniffer: %s", boolToString(engine->isEngineSnifferEnabled));
efiPrintf("engine sniffer: %s", boolToString(getTriggerCentral()->isEngineSnifferEnabled));
efiPrintf("engine sniffer size=%d", engineConfiguration->engineChartSize);
}
@ -141,7 +141,7 @@ void WaveChart::publish() {
Logging *l = &chart->logging;
efiPrintf("IT'S TIME", strlen(l->buffer));
#endif
if (engine->isEngineSnifferEnabled) {
if (getTriggerCentral()->isEngineSnifferEnabled) {
scheduleLogging(&logging);
}
}
@ -157,7 +157,7 @@ void WaveChart::addEvent3(const char *name, const char * msg) {
if (nowNt < pauseEngineSnifferUntilNt) {
return;
}
if (!engine->isEngineSnifferEnabled) {
if (!getTriggerCentral()->isEngineSnifferEnabled) {
return;
}
if (skipUntilEngineCycle != 0 && getRevolutionCounter() < skipUntilEngineCycle)