-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from Negusbuk/master
first test version of pump station control software
- Loading branch information
Showing
40 changed files
with
1,873 additions
and
493 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<?eclipse-pydev version="1.0"?><pydev_project> | ||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> | ||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property> | ||
</pydev_project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#ifndef FIFO_H | ||
#define FIFO_H | ||
|
||
#include <iostream> | ||
|
||
#include <QVector> | ||
|
||
template <class T> class Fifo | ||
{ | ||
public: | ||
|
||
typedef T value_type; | ||
|
||
Fifo(int N) { | ||
buffer_.resize(N); | ||
size_ = 0; | ||
capacity_ = N; | ||
currentFirstIndex_ = 0; | ||
} | ||
|
||
int size() const { | ||
return size_; | ||
} | ||
|
||
virtual void push(const T& value) { | ||
if (size_<capacity_) { | ||
buffer_[size_] = value; | ||
size_++; | ||
currentFirstIndex_ = size_ - 1; | ||
} else { | ||
currentFirstIndex_++; | ||
if (currentFirstIndex_>=capacity_) currentFirstIndex_ = 0; | ||
buffer_[currentFirstIndex_] = value; | ||
} | ||
} | ||
|
||
const T & at(int i) const { | ||
if (i>=size_) return last(); | ||
int idx = currentFirstIndex_ - i; | ||
if (idx<0) idx += size_; | ||
return buffer_[idx]; | ||
} | ||
|
||
T & first() { | ||
return buffer_[currentFirstIndex_]; | ||
} | ||
|
||
const T & first() const { | ||
return buffer_[currentFirstIndex_]; | ||
} | ||
|
||
T & last() { | ||
int idx = currentFirstIndex_; | ||
if (size_<capacity_) { | ||
idx = 0; | ||
} else { | ||
idx++; | ||
if (idx>=capacity_) idx = 0; | ||
} | ||
return buffer_[idx]; | ||
} | ||
|
||
const T & last() const { | ||
int idx = currentFirstIndex_; | ||
if (size_<capacity_) { | ||
idx = 0; | ||
} else { | ||
idx++; | ||
if (idx>=capacity_) idx = 0; | ||
} | ||
return buffer_[idx]; | ||
} | ||
|
||
protected: | ||
|
||
int size_; | ||
int capacity_; | ||
int currentFirstIndex_; | ||
|
||
QVector<T> buffer_; | ||
}; | ||
|
||
#endif // RINGBUFFER_H |
Oops, something went wrong.