@@ -60,63 +60,6 @@ class CommQueue {
60
60
return N;
61
61
}
62
62
63
- protected:
64
- struct QueueElement {
65
- Inverter<> *iv;
66
- uint8_t cmd;
67
- uint8_t attempts;
68
- uint8_t attemptsMax;
69
- uint32_t ts;
70
- bool isDevControl;
71
-
72
- QueueElement ()
73
- : iv {nullptr }
74
- , cmd {0 }
75
- , attempts {0 }
76
- , attemptsMax {0 }
77
- , ts {0 }
78
- , isDevControl {false }
79
- {}
80
-
81
- QueueElement (Inverter<> *iv, uint8_t cmd, bool devCtrl)
82
- : iv {iv}
83
- , cmd {cmd}
84
- , attempts {DefaultAttempts}
85
- , attemptsMax {DefaultAttempts}
86
- , ts {0 }
87
- , isDevControl {devCtrl}
88
- {}
89
-
90
- QueueElement (const QueueElement &other) // copy constructor
91
- : iv {other.iv }
92
- , cmd {other.cmd }
93
- , attempts {other.attempts }
94
- , attemptsMax {other.attemptsMax }
95
- , ts {other.ts }
96
- , isDevControl {other.isDevControl }
97
- {}
98
-
99
- void changeCmd (uint8_t cmd) {
100
- this ->cmd = cmd;
101
- this ->isDevControl = false ;
102
- }
103
-
104
- void setTs (const uint32_t ts) {
105
- this ->ts = ts;
106
- }
107
-
108
- void setAttempt () {
109
- if (this ->attempts )
110
- this ->attempts --;
111
- }
112
-
113
- void incrAttempt (uint8_t attempts = 1 ) {
114
- this ->attempts += attempts;
115
- if (this ->attempts > this ->attemptsMax )
116
- this ->attemptsMax = this ->attempts ;
117
- }
118
- };
119
-
120
63
protected:
121
64
void add (QueueElement q) {
122
65
xSemaphoreTake (this ->mutex , portMAX_DELAY);
@@ -148,13 +91,10 @@ class CommQueue {
148
91
}
149
92
}
150
93
151
- void cmdDone (QueueElement *q, bool keep = false ) {
152
- if (keep) {
153
- q->attempts = DefaultAttempts;
154
- q->attemptsMax = DefaultAttempts;
155
- add (q); // add to the end again
156
- }
157
- // inc(&this->rdPtr);
94
+ void cmdReset (QueueElement *q) {
95
+ q->attempts = DefaultAttempts;
96
+ q->attemptsMax = DefaultAttempts;
97
+ add (q); // add to the end again
158
98
}
159
99
160
100
private:
@@ -183,6 +123,63 @@ class CommQueue {
183
123
return false ;
184
124
}
185
125
126
+ protected:
127
+ struct QueueElement {
128
+ Inverter<> *iv;
129
+ uint8_t cmd;
130
+ uint8_t attempts;
131
+ uint8_t attemptsMax;
132
+ uint32_t ts;
133
+ bool isDevControl;
134
+
135
+ QueueElement ()
136
+ : iv {nullptr }
137
+ , cmd {0 }
138
+ , attempts {0 }
139
+ , attemptsMax {0 }
140
+ , ts {0 }
141
+ , isDevControl {false }
142
+ {}
143
+
144
+ QueueElement (Inverter<> *iv, uint8_t cmd, bool devCtrl)
145
+ : iv {iv}
146
+ , cmd {cmd}
147
+ , attempts {DefaultAttempts}
148
+ , attemptsMax {DefaultAttempts}
149
+ , ts {0 }
150
+ , isDevControl {devCtrl}
151
+ {}
152
+
153
+ QueueElement (const QueueElement &other) // copy constructor
154
+ : iv {other.iv }
155
+ , cmd {other.cmd }
156
+ , attempts {other.attempts }
157
+ , attemptsMax {other.attemptsMax }
158
+ , ts {other.ts }
159
+ , isDevControl {other.isDevControl }
160
+ {}
161
+
162
+ void changeCmd (uint8_t cmd) {
163
+ this ->cmd = cmd;
164
+ this ->isDevControl = false ;
165
+ }
166
+
167
+ void setTs (const uint32_t ts) {
168
+ this ->ts = ts;
169
+ }
170
+
171
+ void setAttempt () {
172
+ if (this ->attempts )
173
+ this ->attempts --;
174
+ }
175
+
176
+ void incrAttempt (uint8_t attempts = 1 ) {
177
+ this ->attempts += attempts;
178
+ if (this ->attempts > this ->attemptsMax )
179
+ this ->attemptsMax = this ->attempts ;
180
+ }
181
+ };
182
+
186
183
protected:
187
184
std::array<QueueElement, N> mQueue ;
188
185
0 commit comments