docs & names

This commit is contained in:
rusefi 2018-02-06 01:16:34 +03:00
parent eaf6440530
commit 3d5e93534d
6 changed files with 31 additions and 17 deletions

View File

@ -148,7 +148,7 @@ void hwHandleVvtCamSignal(trigger_value_e front) {
* let's increase the trigger event counter, that would adjust the state of
* virtual crank-based trigger
*/
tc->triggerState.intTotalEventCounter();
tc->triggerState.incrementTotalEventCounter();
#if EFI_PROD_CODE || defined(__DOXYGEN__)
if (engineConfiguration->debugMode == DBG_VVT) {
tsOutputChannels.debugIntField1++;
@ -160,7 +160,7 @@ void hwHandleVvtCamSignal(trigger_value_e front) {
if (isEven) {
// see above comment
#if EFI_PROD_CODE || defined(__DOXYGEN__)
tc->triggerState.intTotalEventCounter();
tc->triggerState.incrementTotalEventCounter();
if (engineConfiguration->debugMode == DBG_VVT) {
tsOutputChannels.debugIntField1++;
}
@ -172,7 +172,7 @@ void hwHandleVvtCamSignal(trigger_value_e front) {
* NB2 is a symmetrical crank, there are four phases total
*/
while (tc->triggerState.getTotalRevolutionCounter() % 4 != engineConfiguration->nbVvtIndex) {
tc->triggerState.intTotalEventCounter();
tc->triggerState.incrementTotalEventCounter();
}
}
@ -468,7 +468,7 @@ void triggerInfo(void) {
scheduleMsg(logger, "trigger type=%d/need2ndChannel=%s", engineConfiguration->trigger.type,
boolToString(TRIGGER_SHAPE(needSecondTriggerInput)));
scheduleMsg(logger, "expected duty #0=%.2f/#1=%.2f", TRIGGER_SHAPE(dutyCycle[0]), TRIGGER_SHAPE(dutyCycle[1]));
scheduleMsg(logger, "expected duty #0=%.2f/#1=%.2f", TRIGGER_SHAPE(expectedDutyCycle[0]), TRIGGER_SHAPE(expectedDutyCycle[1]));
scheduleMsg(logger, "synchronizationNeeded=%s/isError=%s/total errors=%d ord_err=%d/total revolutions=%d/self=%s",
boolToString(ts->isSynchronizationNeeded),

View File

@ -114,12 +114,12 @@ static trigger_value_e eventType[6] = { TV_FALL, TV_RISE, TV_FALL, TV_RISE, TV_F
}
#define nextRevolution() { \
if (cycleCallback != NULL) { \
cycleCallback(this); \
if (triggerCycleCallback != NULL) { \
triggerCycleCallback(this); \
} \
startOfCycleNt = nowNt; \
resetCurrentCycleState(); \
intTotalEventCounter(); \
incrementTotalEventCounter(); \
runningRevolutionCounter++; \
totalEventCountBase += TRIGGER_SHAPE(size); \
}
@ -645,7 +645,7 @@ uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerShape * shape,
*
* todo: add a comment why are we doing '2 * shape->getSize()' here?
*/
state->cycleCallback = onFindIndex;
state->triggerCycleCallback = onFindIndex;
helper.assertSyncPositionAndSetDutyCycle(syncIndex, state, shape, triggerConfig PASS_ENGINE_PARAMETER_SUFFIX);

View File

@ -41,23 +41,29 @@ typedef struct {
uint32_t totalTimeNt[PWM_PHASE_MAX_WAVE_PER_PWM];
} current_cycle_state_s;
/**
* @see TriggerShape for trigger wheel shape deginition
*/
class TriggerState {
public:
TriggerState();
/**
* current trigger processing index, between zero and #size
*/
int getCurrentIndex();
int getTotalRevolutionCounter();
/**
* this is important for crank-based virtual trigger and VVT magic
*/
bool isEvenRevolution();
void intTotalEventCounter();
void incrementTotalEventCounter();
efitime_t getTotalEventCounter();
efitime_t getStartOfRevolutionIndex();
void decodeTriggerEvent(trigger_event_e const signal, efitime_t nowUs DECLARE_ENGINE_PARAMETER_SUFFIX);
bool isValidIndex(DECLARE_ENGINE_PARAMETER_SIGNATURE);
float getTriggerDutyCycle(int index);
TriggerStateCallback cycleCallback;
TriggerStateCallback triggerCycleCallback;
/**
* TRUE if we know where we are

View File

@ -96,7 +96,7 @@ void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(const uint32_t s
shape->shapeDefinitionError = false;
for (int i = 0; i < PWM_PHASE_MAX_WAVE_PER_PWM; i++) {
shape->dutyCycle[i] = 1.0 * state->expectedTotalTime[i] / SIMULATION_CYCLE_PERIOD;
shape->expectedDutyCycle[i] = 1.0 * state->expectedTotalTime[i] / SIMULATION_CYCLE_PERIOD;
}
}

View File

@ -101,7 +101,7 @@ void TriggerShape::calculateTriggerSynchPoint(TriggerState *state DECLARE_ENGINE
void TriggerShape::initialize(operation_mode_e operationMode, bool needSecondTriggerInput) {
isSynchronizationNeeded = true; // that's default value
this->needSecondTriggerInput = needSecondTriggerInput;
memset(dutyCycle, 0, sizeof(dutyCycle));
memset(expectedDutyCycle, 0, sizeof(expectedDutyCycle));
memset(eventAngles, 0, sizeof(eventAngles));
// memset(triggerIndexByAngle, 0, sizeof(triggerIndexByAngle));
setTriggerSynchronizationGap(2);
@ -171,7 +171,7 @@ TriggerState::TriggerState() {
}
void TriggerState::reset() {
cycleCallback = NULL;
triggerCycleCallback = NULL;
shaft_is_synchronized = false;
toothed_previous_time = 0;
toothed_previous_duration = 0;
@ -271,7 +271,7 @@ int TriggerState::getTotalRevolutionCounter() {
}
void TriggerState::intTotalEventCounter() {
void TriggerState::incrementTotalEventCounter() {
totalRevolutionCounter++;
}
@ -419,7 +419,7 @@ void TriggerShape::addEvent2(angle_t angle, trigger_wheel_e const waveIndex, tri
int index = wave.waveIndertionAngle(angle, size);
// shifting existing data
// todo: does this logic actually work? I think it does not!
// todo: does this logic actually work? I think it does not! due to broken state handling
for (int i = size - 1; i >= index; i--) {
for (int j = 0; j < PWM_PHASE_MAX_WAVE_PER_PWM; j++) {
wave.waves[j].pinStates[i + 1] = wave.getChannelState(j, index);

View File

@ -47,6 +47,7 @@ class TriggerState;
/**
* @brief Trigger shape has all the fields needed to describe and decode trigger signal.
* @see TriggerState for trigger decoder state which works based on this trigger shape model
*/
class TriggerShape {
public:
@ -56,7 +57,14 @@ public:
event_trigger_position_s *position, angle_t angleOffset DECLARE_ENGINE_PARAMETER_SUFFIX);
bool isSynchronizationNeeded;
/**
* this flag tells us if we should ignore events on second input channel
* that's the way to ignore noise from the disconnected wire
*/
bool needSecondTriggerInput;
/**
* true value here means that we do not have a valid trigger configuration
*/
bool shapeDefinitionError;
/**
@ -68,7 +76,7 @@ public:
/**
* duty cycle for each individual trigger channel
*/
float dutyCycle[PWM_PHASE_MAX_WAVE_PER_PWM];
float expectedDutyCycle[PWM_PHASE_MAX_WAVE_PER_PWM];
/**
* These angles are in event coordinates - with synchronization point located at angle zero.
@ -94,7 +102,6 @@ public:
float thirdSyncRatioFrom;
float thirdSyncRatioTo;
/**
* Trigger indexes within trigger cycle are counted from synchronization point, and all
* engine processes are defined in angles from TDC.
@ -199,6 +206,7 @@ private:
/**
* This variable is used to confirm that events are added in the right order.
* todo: this variable is pribably not needed, could be reimplemented by accessing by index
*/
angle_t previousAngle;
/**