mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-04 03:31:42 +02:00
0.8.115
* fix inverter communication with manual time sync #1603 * improved queue, only add new object once they not exist * added option to reset values on communication start (sunrise)
This commit is contained in:
parent
4fe5c8eef8
commit
84ac10531a
10 changed files with 60 additions and 18 deletions
|
@ -19,13 +19,19 @@ template <uint8_t N=100>
|
|||
class CommQueue {
|
||||
public:
|
||||
void addImportant(Inverter<> *iv, uint8_t cmd) {
|
||||
dec(&mRdPtr);
|
||||
mQueue[mRdPtr] = queue_s(iv, cmd, true);
|
||||
queue_s q(iv, cmd, true);
|
||||
if(!isIncluded(&q)) {
|
||||
dec(&mRdPtr);
|
||||
mQueue[mRdPtr] = q;
|
||||
}
|
||||
}
|
||||
|
||||
void add(Inverter<> *iv, uint8_t cmd) {
|
||||
mQueue[mWrPtr] = queue_s(iv, cmd, false);
|
||||
inc(&mWrPtr);
|
||||
queue_s q(iv, cmd, false);
|
||||
if(!isIncluded(&q)) {
|
||||
mQueue[mWrPtr] = q;
|
||||
inc(&mWrPtr);
|
||||
}
|
||||
}
|
||||
|
||||
void chgCmd(Inverter<> *iv, uint8_t cmd) {
|
||||
|
@ -117,6 +123,19 @@ class CommQueue {
|
|||
--(*ptr);
|
||||
}
|
||||
|
||||
private:
|
||||
bool isIncluded(const queue_s *q) {
|
||||
uint8_t ptr = mRdPtr;
|
||||
while (ptr != mWrPtr) {
|
||||
if(mQueue[ptr].cmd == q->cmd) {
|
||||
if(mQueue[ptr].iv->id == q->iv->id)
|
||||
return true;
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::array<queue_s, N> mQueue;
|
||||
uint8_t mWrPtr = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue