35 int stateIndex = i % shape.
getSize();
36 int loopIndex = i / shape.
getSize();
38 return (
int) (SIMULATION_CYCLE_PERIOD * (loopIndex + shape.
wave.
getSwitchTime(stateIndex)));
48 int stateIndex = index % shape.
getSize();
52 const auto & multiChannelStateSequence = shape.
wave;
57 pin_state_t primaryWheelState = multiChannelStateSequence.getChannelState(0, prevIndex);
58 pin_state_t newPrimaryWheelState = multiChannelStateSequence.getChannelState(0, stateIndex);
60 pin_state_t secondaryWheelState = multiChannelStateSequence.getChannelState(1, prevIndex);
61 pin_state_t newSecondaryWheelState = multiChannelStateSequence.getChannelState(1, stateIndex);
67 printf(
"TriggerStimulator: simulatedEvent: %d>%d primary %d>%d secondary %d>%d\r\n", prevIndex, stateIndex, primaryWheelState, newPrimaryWheelState,
68 secondaryWheelState, newSecondaryWheelState );
78 for (
size_t i = 0; i < PWM_PHASE_MAX_WAVE_PER_PWM; i++) {
79 if (
needEvent(stateIndex, multiChannelStateSequence, i)) {
80 pin_state_t currentValue = multiChannelStateSequence.getChannelState(i, stateIndex);
83 state.decodeTriggerEvent(
96 const uint32_t syncIndex,
102#define TEST_REVOLUTIONS 6
107 for (uint32_t i = syncIndex + 1; i <= syncIndex + TEST_REVOLUTIONS * shape.
getSize(); i++) {
111 int revolutionCounter =
state.getSynchronizationCounter();
112 if (revolutionCounter != TEST_REVOLUTIONS) {
122 printf(
"Happy %s revolutionCounter=%d\r\n",
136 for (
int i = 0; i < 4 * PWM_PHASE_MAX_COUNT; i++) {
139 if (
state.getShaftSynchronized()) {
const char * getTrigger_type_e(trigger_type_e value)
float getSwitchTime(int phaseIndex) const override
trigger_config_s TriggerType
static expected< uint32_t > findTriggerSyncPoint(TriggerWaveform &shape, const TriggerConfiguration &triggerConfiguration, TriggerDecoderBase &state)
static void feedSimulatedEvent(const TriggerConfiguration &triggerConfiguration, TriggerDecoderBase &state, const TriggerWaveform &shape, int i)
static void assertSyncPosition(const TriggerConfiguration &triggerConfiguration, const uint32_t index, TriggerDecoderBase &state, TriggerWaveform &shape)
static constexpr engine_configuration_s * engineConfiguration
bool warning(ObdCode code, const char *fmt,...)
void firmwareError(ObdCode code, const char *fmt,...)
@ CUSTOM_ERR_CUSTOM_GAPS_BAD
@ CUSTOM_OBD_TRIGGER_WAVEFORM
@ CUSTOM_ERR_TRIGGER_SYNC
state("state", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1871, 1.0, -1.0, -1.0, "")
@ SHAFT_SECONDARY_FALLING
constexpr bool isTriggerUpEvent(trigger_event_e event)
int getPreviousIndex(const int currentIndex, const int size)
bool needEvent(const int currentIndex, const MultiChannelStateSequence &mcss, int channelIndex)
int getSimulatedEventTime(const TriggerWaveform &shape, int i)
bool isUsefulSignal(trigger_event_e signal, const TriggerWaveform &shape)
int getSimulatedEventTime(const TriggerWaveform &shape, int i)
bool isUsefulSignal(trigger_event_e signal, const TriggerWaveform &shape)