minor progress
This commit is contained in:
parent
d205bf7635
commit
c2fa1cea78
|
@ -157,7 +157,7 @@ void prepareEventAngles(TriggerWaveform *shape,
|
||||||
if (triggerShapeSynchPointIndex == EFI_ERROR_CODE) {
|
if (triggerShapeSynchPointIndex == EFI_ERROR_CODE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float firstAngle = shape->getAngle(triggerShapeSynchPointIndex);
|
angle_t firstAngle = shape->getAngle(triggerShapeSynchPointIndex);
|
||||||
assertAngleRange(firstAngle, "firstAngle", CUSTOM_TRIGGER_SYNC_ANGLE);
|
assertAngleRange(firstAngle, "firstAngle", CUSTOM_TRIGGER_SYNC_ANGLE);
|
||||||
|
|
||||||
int riseOnlyIndex = 0;
|
int riseOnlyIndex = 0;
|
||||||
|
|
|
@ -28,10 +28,10 @@ class cyclic_buffer
|
||||||
public:
|
public:
|
||||||
void add(T value);
|
void add(T value);
|
||||||
T get(int index) const;
|
T get(int index) const;
|
||||||
T sum(int length) const;
|
T sum(size_t length) const;
|
||||||
T maxValue(int length) const;
|
T maxValue(size_t length) const;
|
||||||
T minValue(int length) const;
|
T minValue(size_t length) const;
|
||||||
void setSize(unsigned int size);
|
void setSize(size_t size);
|
||||||
bool contains(T value) const;
|
bool contains(T value) const;
|
||||||
int getSize() const;
|
int getSize() const;
|
||||||
int getCount() const;
|
int getCount() const;
|
||||||
|
@ -44,7 +44,7 @@ class cyclic_buffer
|
||||||
/**
|
/**
|
||||||
* number of elements added into this buffer, would be eventually bigger then size
|
* number of elements added into this buffer, would be eventually bigger then size
|
||||||
*/
|
*/
|
||||||
volatile unsigned count;
|
volatile size_t count;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, size_t maxSize>
|
template<typename T, size_t maxSize>
|
||||||
|
@ -83,7 +83,7 @@ bool cyclic_buffer<T, maxSize>::contains(T value) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, size_t maxSize>
|
template<typename T, size_t maxSize>
|
||||||
void cyclic_buffer<T, maxSize>::setSize(unsigned int size) {
|
void cyclic_buffer<T, maxSize>::setSize(size_t size) {
|
||||||
clear();
|
clear();
|
||||||
this->size = size < maxSize ? size : maxSize;
|
this->size = size < maxSize ? size : maxSize;
|
||||||
}
|
}
|
||||||
|
@ -110,14 +110,14 @@ T cyclic_buffer<T, maxSize>::get(int index) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, size_t maxSize>
|
template<typename T, size_t maxSize>
|
||||||
T cyclic_buffer<T, maxSize>::maxValue(int length) const {
|
T cyclic_buffer<T, maxSize>::maxValue(size_t length) const {
|
||||||
if (length > count) {
|
if (length > count) {
|
||||||
// not enough data in buffer
|
// not enough data in buffer
|
||||||
length = count;
|
length = count;
|
||||||
}
|
}
|
||||||
int ci = currentIndex; // local copy to increase thread-safety
|
int ci = currentIndex; // local copy to increase thread-safety
|
||||||
T result = std::numeric_limits<T>::min();
|
T result = std::numeric_limits<T>::min();
|
||||||
for (int i = 0; i < length; ++i) {
|
for (size_t i = 0; i < length; ++i) {
|
||||||
int index = ci - i - 1;
|
int index = ci - i - 1;
|
||||||
while (index < 0) {
|
while (index < 0) {
|
||||||
index += size;
|
index += size;
|
||||||
|
@ -131,13 +131,13 @@ T cyclic_buffer<T, maxSize>::maxValue(int length) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, size_t maxSize>
|
template<typename T, size_t maxSize>
|
||||||
T cyclic_buffer<T, maxSize>::minValue(int length) const {
|
T cyclic_buffer<T, maxSize>::minValue(size_t length) const {
|
||||||
if (length > count) {
|
if (length > count) {
|
||||||
length = count;
|
length = count;
|
||||||
}
|
}
|
||||||
int ci = currentIndex; // local copy to increase thread-safety
|
int ci = currentIndex; // local copy to increase thread-safety
|
||||||
T result = std::numeric_limits<T>::max();
|
T result = std::numeric_limits<T>::max();
|
||||||
for (int i = 0; i < length; ++i) {
|
for (size_t i = 0; i < length; ++i) {
|
||||||
int index = ci - i - 1;
|
int index = ci - i - 1;
|
||||||
while (index < 0) {
|
while (index < 0) {
|
||||||
index += size;
|
index += size;
|
||||||
|
@ -151,7 +151,7 @@ T cyclic_buffer<T, maxSize>::minValue(int length) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, size_t maxSize>
|
template<typename T, size_t maxSize>
|
||||||
T cyclic_buffer<T, maxSize>::sum(int length) const {
|
T cyclic_buffer<T, maxSize>::sum(size_t length) const {
|
||||||
if (length > count) {
|
if (length > count) {
|
||||||
length = count;
|
length = count;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ T cyclic_buffer<T, maxSize>::sum(int length) const {
|
||||||
int ci = currentIndex; // local copy to increase thread-safety
|
int ci = currentIndex; // local copy to increase thread-safety
|
||||||
T result = 0;
|
T result = 0;
|
||||||
|
|
||||||
for (int i = 0; i < length; ++i) {
|
for (size_t i = 0; i < length; ++i) {
|
||||||
int index = ci - i - 1;
|
int index = ci - i - 1;
|
||||||
while (index < 0) {
|
while (index < 0) {
|
||||||
index += size;
|
index += size;
|
||||||
|
|
Loading…
Reference in New Issue