avoid some misc shadowing

This commit is contained in:
Matthew Kennedy 2023-11-01 13:58:39 -07:00
parent 1e86dc2fd4
commit ce2198270e
8 changed files with 38 additions and 29 deletions

View File

@ -208,7 +208,7 @@ bool PrimaryTriggerConfiguration::isVerboseTriggerSynchDetails() const {
trigger_config_s VvtTriggerConfiguration::getType() const {
// Convert from VVT type to trigger_config_s
return { getVvtTriggerType(engineConfiguration->vvtMode[index]), 0, 0 };
return { getVvtTriggerType(engineConfiguration->vvtMode[m_index]), 0, 0 };
}
bool VvtTriggerConfiguration::isVerboseTriggerSynchDetails() const {

View File

@ -249,20 +249,20 @@ bool LimpManager::allowTriggerInput() const {
LimpState LimpManager::allowInjection() const {
if (!m_allowInjection) {
return {false, m_allowInjection.clearReason};
return {false, m_allowInjection.why()};
}
if (!m_transientAllowInjection) {
return {false, m_transientAllowInjection.clearReason};
return {false, m_transientAllowInjection.why()};
}
return {true, ClearReason::None};
}
LimpState LimpManager::allowIgnition() const {
if (!m_allowIgnition) {
return {false, m_allowIgnition.clearReason};
return {false, m_allowIgnition.why()};
}
if (!m_transientAllowIgnition) {
return {false, m_transientAllowIgnition.clearReason};
return {false, m_transientAllowIgnition.why()};
}
return {true, ClearReason::None};
}

View File

@ -50,14 +50,14 @@ public:
Clearable() : m_value(true) {}
Clearable(bool value) : m_value(value) {
if (!m_value) {
clearReason = ClearReason::Settings;
m_clearReason = ClearReason::Settings;
}
}
void clear(ClearReason clearReason) {
if (m_value) {
m_value = false;
this->clearReason = clearReason;
m_clearReason = clearReason;
}
}
@ -65,9 +65,13 @@ public:
return m_value;
}
ClearReason clearReason = ClearReason::None;
ClearReason why() const {
return m_clearReason;
}
private:
bool m_value = true;
ClearReason m_clearReason = ClearReason::None;
};
struct LimpState {

View File

@ -14,8 +14,8 @@ struct CanFilter {
CanBusIndex Bus;
int Callback;
bool accept(int Id) {
return (Id & this->Mask) == this->Id;
bool accept(int id) {
return (id & this->Mask) == this->Id;
}
};

View File

@ -48,7 +48,7 @@
#include "trigger_simulator.h"
TriggerDecoderBase::TriggerDecoderBase(const char* name)
: name(name)
: m_name(name)
{
resetState();
}
@ -293,11 +293,11 @@ case SHAFT_SECONDARY_RISING:
}
void VvtTriggerDecoder::onNotEnoughTeeth(int actual, int expected) {
warning(ObdCode::CUSTOM_CAM_NOT_ENOUGH_TEETH, "cam %s trigger error: not enough teeth between sync points: actual %d expected %d", name, actual, expected);
warning(ObdCode::CUSTOM_CAM_NOT_ENOUGH_TEETH, "cam %s trigger error: not enough teeth between sync points: actual %d expected %d", m_name, actual, expected);
}
void VvtTriggerDecoder::onTooManyTeeth(int actual, int expected) {
warning(ObdCode::CUSTOM_CAM_TOO_MANY_TEETH, "cam %s trigger error: too many teeth between sync points: %d > %d", name, actual, expected);
warning(ObdCode::CUSTOM_CAM_TOO_MANY_TEETH, "cam %s trigger error: too many teeth between sync points: %d > %d", m_name, actual, expected);
}
bool TriggerDecoderBase::validateEventCounters(const TriggerWaveform& triggerShape) const {

View File

@ -47,14 +47,18 @@ protected:
class VvtTriggerConfiguration final : public TriggerConfiguration {
public:
const int index;
VvtTriggerConfiguration(const char * prefix, const int index) : TriggerConfiguration(prefix), index(index) {
VvtTriggerConfiguration(const char * prefix, const int index)
: TriggerConfiguration(prefix)
, m_index(index)
{
}
protected:
bool isVerboseTriggerSynchDetails() const override;
trigger_config_s getType() const override;
private:
const int m_index;
};
typedef struct {
@ -133,7 +137,6 @@ public:
efitick_t toothed_previous_time;
current_cycle_state_s currentCycle;
const char* const name;
/**
* how many times since ECU reboot we had unexpected number of teeth in trigger cycle
@ -170,6 +173,8 @@ protected:
virtual void onNotEnoughTeeth(int, int) { }
virtual void onTooManyTeeth(int, int) { }
const char* const m_name;
private:
void resetCurrentCycleState();
bool isSyncPoint(const TriggerWaveform& triggerShape, trigger_type_e triggerType) const;

View File

@ -40,7 +40,7 @@ class cyclic_buffer
uint16_t currentIndex;
protected:
uint16_t size;
size_t m_size;
/**
* number of elements added into this buffer, would be eventually bigger then size
*/
@ -64,7 +64,7 @@ void cyclic_buffer<T, maxSize>::add(T value) {
((T &)elements[idx]) = value;
if (++idx == size) {
if (++idx == m_size) {
idx = 0;
}
currentIndex = idx;
@ -85,12 +85,12 @@ bool cyclic_buffer<T, maxSize>::contains(T value) const {
template<typename T, size_t maxSize>
void cyclic_buffer<T, maxSize>::setSize(size_t size) {
clear();
this->size = size < maxSize ? size : maxSize;
m_size = size < maxSize ? size : maxSize;
}
template<typename T, size_t maxSize>
int cyclic_buffer<T, maxSize>::getSize() const {
return size;
return m_size;
}
template<typename T, size_t maxSize>
@ -101,10 +101,10 @@ int cyclic_buffer<T, maxSize>::getCount() const {
template<typename T, size_t maxSize>
T cyclic_buffer<T, maxSize>::get(int index) const {
while (index < 0) {
index += size;
index += m_size;
}
while (index >= size) {
index -= size;
while (index >= m_size) {
index -= m_size;
}
return elements[index];
}
@ -120,7 +120,7 @@ T cyclic_buffer<T, maxSize>::maxValue(size_t length) const {
for (size_t i = 0; i < length; ++i) {
int index = ci - i - 1;
while (index < 0) {
index += size;
index += m_size;
}
if (elements[index] > result) {
@ -140,7 +140,7 @@ T cyclic_buffer<T, maxSize>::minValue(size_t length) const {
for (size_t i = 0; i < length; ++i) {
int index = ci - i - 1;
while (index < 0) {
index += size;
index += m_size;
}
if (elements[index] < result) {
@ -162,7 +162,7 @@ T cyclic_buffer<T, maxSize>::sum(size_t length) const {
for (size_t i = 0; i < length; ++i) {
int index = ci - i - 1;
while (index < 0) {
index += size;
index += m_size;
}
result += elements[index];

View File

@ -25,7 +25,7 @@ class fifo_buffer : public cyclic_buffer<T, maxSize> {
using cyclic_buffer<T, maxSize>::add;
using cyclic_buffer<T, maxSize>::getSize;
using cyclic_buffer<T, maxSize>::elements;
using cyclic_buffer<T, maxSize>::size, cyclic_buffer<T, maxSize>::count;
using cyclic_buffer<T, maxSize>::m_size, cyclic_buffer<T, maxSize>::count;
public:
fifo_buffer() : currentIndexRead(0) {
@ -84,7 +84,7 @@ template<typename T, size_t maxSize>
T fifo_buffer<T, maxSize>::get() {
T &ret = (T &)elements[currentIndexRead];
if (!isEmpty()) {
currentIndexRead = (currentIndexRead + 1) % size;
currentIndexRead = (currentIndexRead + 1) % m_size;
count--;
}
return ret;