Trigger: warning code on normal engine start up #669

making more code unit-testable
This commit is contained in:
Andrey 2021-06-25 12:50:19 -04:00
parent 1c87b9ccfe
commit 8d4b9c4535
2 changed files with 10 additions and 4 deletions

View File

@ -33,6 +33,13 @@ bool isUsefulSignal(trigger_event_e signal, const TriggerConfiguration& triggerC
extern bool printTriggerDebug; extern bool printTriggerDebug;
#endif /* ! EFI_UNIT_TEST */ #endif /* ! EFI_UNIT_TEST */
int getSimulatedEventTime(const TriggerWaveform& shape, int i) {
int stateIndex = i % shape.getSize();
int loopIndex = i / shape.getSize();
return (int) (SIMULATION_CYCLE_PERIOD * (loopIndex + shape.wave.getSwitchTime(stateIndex)));
}
void TriggerStimulatorHelper::feedSimulatedEvent( void TriggerStimulatorHelper::feedSimulatedEvent(
const TriggerStateCallback triggerCycleCallback, const TriggerStateCallback triggerCycleCallback,
const TriggerConfiguration& triggerConfiguration, const TriggerConfiguration& triggerConfiguration,
@ -44,9 +51,7 @@ void TriggerStimulatorHelper::feedSimulatedEvent(
int stateIndex = i % shape.getSize(); int stateIndex = i % shape.getSize();
int size = shape.getSize(); int size = shape.getSize();
int loopIndex = i / shape.getSize(); int time = getSimulatedEventTime(shape, i);
int time = (int) (SIMULATION_CYCLE_PERIOD * (loopIndex + shape.wave.getSwitchTime(stateIndex)));
const MultiChannelStateSequence& multiChannelStateSequence = shape.wave; const MultiChannelStateSequence& multiChannelStateSequence = shape.wave;

View File

@ -10,6 +10,8 @@
#include "trigger_decoder.h" #include "trigger_decoder.h"
int getSimulatedEventTime(const TriggerWaveform& shape, int i);
class TriggerStimulatorHelper { class TriggerStimulatorHelper {
public: public:
@ -26,7 +28,6 @@ public:
TriggerWaveform& shape TriggerWaveform& shape
); );
private:
// send next event so that we can see how state reacts // send next event so that we can see how state reacts
void feedSimulatedEvent(const TriggerStateCallback triggerCycleCallback, void feedSimulatedEvent(const TriggerStateCallback triggerCycleCallback,
const TriggerConfiguration& triggerConfiguration, const TriggerConfiguration& triggerConfiguration,