rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Functions
trigger_emulator_algo.h File Reference

Detailed Description

Date
Mar 3, 2014
Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file trigger_emulator_algo.h.

Data Structures

class  TriggerEmulatorHelper
 

Functions

void initTriggerEmulator ()
 
void startTriggerEmulatorPins ()
 
void stopTriggerEmulatorPins ()
 
void setTriggerEmulatorRPM (int value)
 
void onConfigurationChangeRpmEmulatorCallback (engine_configuration_s *previousConfiguration)
 
void enableTriggerStimulator (bool incGlobalConfiguration=true)
 
void enableExternalTriggerStimulator ()
 
void disableTriggerStimulator ()
 
int getPreviousIndex (const int currentIndex, const int size)
 
bool needEvent (const int currentIndex, const MultiChannelStateSequence &mcss, int channelIndex)
 

Function Documentation

◆ disableTriggerStimulator()

void disableTriggerStimulator ( )

Definition at line 222 of file trigger_emulator_algo.cpp.

222 {
224 for (int channel = 0; channel < NUM_EMULATOR_CHANNELS; channel++) {
226 }
229}
uint16_t channel
Definition adc_inputs.h:104
TriggerCentral triggerCentral
Definition engine.h:318
static EngineAccessor engine
Definition engine.h:413
void incrementGlobalConfigurationVersion(const char *msg)
PwmConfig triggerEmulatorSignals[NUM_EMULATOR_CHANNELS]
static bool hasInitTriggerEmulator

Referenced by configureRusefiLuaHooks(), enableOrDisable(), and handleCommandX14().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enableExternalTriggerStimulator()

void enableExternalTriggerStimulator ( )

Definition at line 216 of file trigger_emulator_algo.cpp.

216 {
220}
static void startSimulatedTriggerSignal()

Referenced by enableOrDisable(), and handleCommandX14().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enableTriggerStimulator()

void enableTriggerStimulator ( bool  incGlobalConfiguration = true)

Definition at line 205 of file trigger_emulator_algo.cpp.

205 {
209 if (incGlobalConfiguration) {
211 }
212}
RpmCalculator rpmCalculator
Definition engine.h:306
bool Register()
Definition sensor.cpp:131

Referenced by configureRusefiLuaHooks(), enableOrDisable(), and handleCommandX14().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPreviousIndex()

int getPreviousIndex ( const int  currentIndex,
const int  size 
)

Definition at line 19 of file trigger_emulator_algo.cpp.

19 {
20 return (currentIndex + size - 1) % size;
21}
composite packet size

Referenced by TriggerStimulatorHelper::feedSimulatedEvent(), and needEvent().

Here is the caller graph for this function:

◆ initTriggerEmulator()

void initTriggerEmulator ( )

Definition at line 239 of file trigger_emulator_algo.cpp.

239 {
240 efiPrintf("Emulating %s", getEngine_type_e(engineConfiguration->engineType));
241
243
245}
const char * getEngine_type_e(engine_type_e value)
void addConsoleActionI(const char *token, VoidInt callback)
Register a console command with one Integer parameter.
static constexpr engine_configuration_s * engineConfiguration
void setTriggerEmulatorRPM(int rpm)
void startTriggerEmulatorPins()

Referenced by initEngineEmulator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ needEvent()

bool needEvent ( const int  currentIndex,
const MultiChannelStateSequence mcss,
int  channelIndex 
)

Definition at line 23 of file trigger_emulator_algo.cpp.

23 {
24 int prevIndex = getPreviousIndex(currentIndex, mcss.phaseCount);
25 pin_state_t previousValue = mcss.getChannelState(channelIndex, /*phaseIndex*/prevIndex);
26 pin_state_t currentValue = mcss.getChannelState(channelIndex, /*phaseIndex*/currentIndex);
27
28 return previousValue != currentValue;
29}
virtual pin_state_t getChannelState(int channelIndex, int phaseIndex) const =0
TriggerValue
int getPreviousIndex(const int currentIndex, const int size)

Referenced by TriggerStimulatorHelper::feedSimulatedEvent(), and TriggerEmulatorHelper::handleEmulatorCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onConfigurationChangeRpmEmulatorCallback()

void onConfigurationChangeRpmEmulatorCallback ( engine_configuration_s previousConfiguration)

Definition at line 231 of file trigger_emulator_algo.cpp.

Referenced by incrementGlobalConfigurationVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTriggerEmulatorRPM()

void setTriggerEmulatorRPM ( int  value)

All we need to do here is to change the periodMs togglePwmState() would see that the periodMs has changed and act accordingly

Definition at line 97 of file trigger_emulator_algo.cpp.

97 {
98 criticalAssertVoid(rpm >= 0 && rpm <= 30000, "emulator RPM out of range");
99
101 /**
102 * All we need to do here is to change the periodMs
103 * togglePwmState() would see that the periodMs has changed and act accordingly
104 */
105 for (int channel = 0; channel < NUM_EMULATOR_CHANNELS; channel++) {
106 float rPerSecond = NAN;
107 if (rpm != 0) {
108 // use 0.5 multiplier for cam
109 float rpmM = (channel == 0) ? getRpmMultiplier(getEngineRotationState()->getOperationMode()) : 0.5f;
110 rPerSecond = rpm * rpmM / 60.0; // per minute converted to per second
111 }
113 }
114
116
117 efiPrintf("Emulating position sensor(s). RPM=%d", rpm);
118}
void resetEngineSnifferIfInTestMode()
Definition engine.cpp:53
virtual operation_mode_e getOperationMode() const =0
void setFrequency(float frequency)
EngineRotationState * getEngineRotationState()
Definition engine.cpp:573
static float getRpmMultiplier(operation_mode_e mode)

Referenced by configureRusefiLuaHooks(), initTriggerEmulator(), onConfigurationChangeRpmEmulatorCallback(), setValue(), and startSimulatedTriggerSignal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startTriggerEmulatorPins()

void startTriggerEmulatorPins ( )

Definition at line 249 of file trigger_emulator_algo.cpp.

249 {
250 hasStimPins = false;
251 for (int channel = 0; channel < NUM_EMULATOR_CHANNELS; channel++) {
252 for (size_t i = 0; i < efi::size(emulatorOutputs[channel]); i++) {
254
255#if EFI_PROD_CODE
257
258 pin_output_mode_e outputMode;
259 if (channel == 0) {
262 } else if (channel == 1 && i == 0) {
265 } else {
266 // todo: add pin configs for cam simulator channels
267 continue;
268 }
269
270 // Only bother trying to set output pins if they're configured
271 if (isBrainPinValid(pin)) {
272 hasStimPins = true;
273 }
274
275 if (isConfigurationChanged(triggerSimulatorPins[i])) {
276 triggerEmulatorSignals[channel].outputPins[i]->initPin("Trigger emulator", pin,
277 outputMode);
278 }
279#endif // EFI_PROD_CODE
280 }
281 }
282}
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
Definition efi_gpio.cpp:711
OutputPin * outputPins[PWM_PHASE_MAX_WAVE_PER_PWM]
bool isBrainPinValid(brain_pin_e brainPin)
pin_output_mode_e
brain_pin_e pin
Definition stm32_adc.cpp:15
pin_output_mode_e triggerSimulatorPinModes[TRIGGER_SIMULATOR_PIN_COUNT]
static bool hasStimPins
static OutputPin emulatorOutputs[NUM_EMULATOR_CHANNELS][PWM_PHASE_MAX_WAVE_PER_PWM]

Referenced by applyNewHardwareSettings(), and initTriggerEmulator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stopTriggerEmulatorPins()

void stopTriggerEmulatorPins ( )

Definition at line 284 of file trigger_emulator_algo.cpp.

284 {
285#if EFI_PROD_CODE
286 for (int channel = 0; channel < NUM_EMULATOR_CHANNELS; channel++) {
287 // todo: add pin configs for cam simulator channels
288 if (channel != 0)
289 continue;
290 for (size_t i = 0; i < efi::size(emulatorOutputs[channel]); i++) {
291 if (isConfigurationChanged(triggerSimulatorPins[i])) {
293 }
294 }
295 }
296#endif // EFI_PROD_CODE
297}
void deInit()
Definition efi_gpio.cpp:802

Referenced by stopHardware().

Here is the call graph for this function:
Here is the caller graph for this function:

Go to the source code of this file.