rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
MultiChannelStateSequence Class Referenceabstract

#include <state_sequence.h>

Inheritance diagram for MultiChannelStateSequence:
Inheritance graph
[legend]
Collaboration diagram for MultiChannelStateSequence:
Collaboration graph
[legend]

Public Member Functions

virtual float getSwitchTime (int phaseIndex) const =0
 
virtual pin_state_t getChannelState (int channelIndex, int phaseIndex) const =0
 
void checkSwitchTimes (float scale) const
 
expected< int > findAngleMatch (float angle) const
 
int findInsertionAngle (float angle) const
 

Data Fields

uint16_t phaseCount = 0
 
uint16_t waveCount = 0
 

Detailed Description

This class represents multi-channel logical signals with shared time axis

This is a semi-abstract interface so that implementations can exist for either regularized patterns (60-2, etc) or completely arbitrary patterns stored in arrays.

Definition at line 52 of file state_sequence.h.

Member Function Documentation

◆ checkSwitchTimes()

void MultiChannelStateSequence::checkSwitchTimes ( float  scale) const

Definition at line 12 of file state_sequence.cpp.

12 {
13 efiAssertVoid(ObdCode::CUSTOM_ERR_WAVE_1, phaseCount > 0, "StateSequence cannot be empty");
14 if (getSwitchTime(phaseCount - 1) != 1) {
15#if EFI_UNIT_TEST
16 for (int index = 0;index < phaseCount;index ++) {
17 printf("switch time index=%d angle=%f\n", index, getSwitchTime(index));
18 }
19#endif // EFI_UNIT_TEST
20
21 firmwareError(ObdCode::CUSTOM_ERR_WAVE_1, "[count=%d] last switch time has to be 1/%f not %.2f/%f",
23 scale, getSwitchTime(phaseCount - 1),
24 scale * getSwitchTime(phaseCount - 1));
25 return;
26 }
27 for (int i = 0; i < phaseCount - 1; i++) {
28 if (getSwitchTime(i) >= getSwitchTime(i + 1)) {
29 firmwareError(ObdCode::CUSTOM_ERR_WAVE_2, "invalid switchTimes @%d: %.2f/%.2f",
30 i, getSwitchTime(i), getSwitchTime(i + 1));
31 }
32 }
33}
virtual float getSwitchTime(int phaseIndex) const =0
void firmwareError(ObdCode code, const char *fmt,...)
@ CUSTOM_ERR_WAVE_1
@ CUSTOM_ERR_WAVE_2
printf("\n")

Referenced by copyPwmParameters(), and TriggerWaveform::initializeTriggerWaveform().

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

◆ findAngleMatch()

expected< int > MultiChannelStateSequence::findAngleMatch ( float  angle) const

Definition at line 43 of file state_sequence.cpp.

43 {
44 for (int i = 0; i < phaseCount; i++) {
45 if (isSameF(getSwitchTime(i), angle))
46 return i;
47 }
48 return unexpected;
49}

Referenced by TriggerWaveform::addEvent().

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

◆ findInsertionAngle()

int MultiChannelStateSequence::findInsertionAngle ( float  angle) const

Definition at line 35 of file state_sequence.cpp.

35 {
36 for (int i = phaseCount - 1; i >= 0; i--) {
37 if (angle > getSwitchTime(i))
38 return i + 1;
39 }
40 return 0;
41}

Referenced by TriggerWaveform::addEvent().

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

◆ getChannelState()

virtual pin_state_t MultiChannelStateSequence::getChannelState ( int  channelIndex,
int  phaseIndex 
) const
pure virtual

◆ getSwitchTime()

virtual float MultiChannelStateSequence::getSwitchTime ( int  phaseIndex) const
pure virtual

values in the (0..1] range which refer to points within the period at at which pin state should be changed So, in the simplest case we turn pin off at 0.3 and turn it on at 1 - that would give us a 70% duty cycle PWM

Implemented in MultiChannelStateSequenceWithData< max_phase >, MultiChannelStateSequenceWithData< 2 >, and MultiChannelStateSequenceWithData< PWM_PHASE_MAX_COUNT >.

Referenced by checkSwitchTimes(), findAngleMatch(), and findInsertionAngle().

Here is the caller graph for this function:

Field Documentation

◆ phaseCount

uint16_t MultiChannelStateSequence::phaseCount = 0

◆ waveCount

uint16_t MultiChannelStateSequence::waveCount = 0

The documentation for this class was generated from the following files: