3-phase PV router
Loading...
Searching...
No Matches
test_main.cpp
Go to the documentation of this file.
1#include <Arduino.h>
2
3#include <unity.h>
4
5#include "utils_pins.h"
6#include "utils_relay.h"
7
8constexpr RelayEngine relays{ { { 2, 1000, 200, 1, 1 },
9 { 3, 100, 20, 2, 3 } } };
10
11void setUp(void)
12{
13 // Setup for each test
14}
15
16void tearDown(void)
17{
18 // clean stuff up here
19}
20
22{
23 relayOutput relay(4, 500, 100);
24 TEST_ASSERT_EQUAL(4, relay.get_pin());
25 TEST_ASSERT_EQUAL(500, relay.get_surplusThreshold());
26 TEST_ASSERT_EQUAL(100, relay.get_importThreshold());
27}
28
30{
31 relayOutput relay(4, 500, 100);
32 TEST_ASSERT_EQUAL(4, relay.get_pin());
33 TEST_ASSERT_EQUAL(500, relay.get_surplusThreshold());
34 TEST_ASSERT_EQUAL(100, relay.get_importThreshold());
35}
36
38{
39 relayOutput relay(4, -500, -100);
40 TEST_ASSERT_EQUAL(4, relay.get_pin());
41 TEST_ASSERT_EQUAL(500, relay.get_surplusThreshold());
42 TEST_ASSERT_EQUAL(-100, relay.get_importThreshold());
43}
44
45void test_get_pin(void)
46{
47 TEST_ASSERT_EQUAL(2, relays.get_relay(0).get_pin());
48 TEST_ASSERT_EQUAL(3, relays.get_relay(1).get_pin());
49}
50
52{
53 TEST_ASSERT_EQUAL(1000, relays.get_relay(0).get_surplusThreshold());
54 TEST_ASSERT_EQUAL(100, relays.get_relay(1).get_surplusThreshold());
55}
56
58{
59 TEST_ASSERT_EQUAL(200, relays.get_relay(0).get_importThreshold());
60 TEST_ASSERT_EQUAL(20, relays.get_relay(1).get_importThreshold());
61}
62
64{
65 TEST_ASSERT_EQUAL(1 * 60, relays.get_relay(0).get_minON());
66 TEST_ASSERT_EQUAL(2 * 60, relays.get_relay(1).get_minON());
67}
68
70{
71 TEST_ASSERT_EQUAL(1 * 60, relays.get_relay(0).get_minOFF());
72 TEST_ASSERT_EQUAL(3 * 60, relays.get_relay(1).get_minOFF());
73}
74
76{
77 TEST_ASSERT_FALSE(relays.get_relay(1).isRelayON());
78}
79
81{
82 const auto& my_relay{ relays.get_relay(1) };
83
84 TEST_ASSERT_FALSE(my_relay.isRelayON());
85
86 /* The relay is OFF, test the "TurnON" case */
87 const auto surplus{ -my_relay.get_surplusThreshold() - 1 };
88 uint16_t overrideBitmask = 0; // No override active
89
90 TEST_ASSERT_FALSE(my_relay.proceed_relay(surplus, overrideBitmask));
91 delay(100);
92 TEST_ASSERT_FALSE(my_relay.isRelayON());
93
94 for (uint8_t timer = 0; timer < my_relay.get_minOFF() - 1; ++timer)
95 {
96 my_relay.inc_duration();
97 }
98 overrideBitmask = 0; // Reset bitmask
99 TEST_ASSERT_FALSE(my_relay.proceed_relay(surplus, overrideBitmask));
100 delay(100);
101
102 my_relay.inc_duration();
103
104 overrideBitmask = 0; // Reset bitmask
105 TEST_ASSERT_TRUE(my_relay.proceed_relay(surplus, overrideBitmask));
106 TEST_ASSERT_TRUE(my_relay.isRelayON());
107}
108
110{
111 const auto& my_relay{ relays.get_relay(1) };
112
113 TEST_ASSERT_TRUE(my_relay.isRelayON());
114
115 /* The relay is ON, test the "TurnOFF" case */
116 const auto consum{ my_relay.get_importThreshold() + 1 };
117 uint16_t overrideBitmask = 0; // No override active
118
119 TEST_ASSERT_FALSE(my_relay.proceed_relay(consum, overrideBitmask));
120 delay(100);
121 TEST_ASSERT_TRUE(my_relay.isRelayON());
122
123 for (uint8_t timer = 0; timer < my_relay.get_minON() - 1; ++timer)
124 {
125 my_relay.inc_duration();
126 }
127 overrideBitmask = 0; // Reset bitmask
128 TEST_ASSERT_FALSE(my_relay.proceed_relay(consum, overrideBitmask));
129 delay(100);
130
131 my_relay.inc_duration();
132
133 overrideBitmask = 0; // Reset bitmask
134 TEST_ASSERT_TRUE(my_relay.proceed_relay(consum, overrideBitmask));
135 TEST_ASSERT_FALSE(my_relay.isRelayON());
136}
137
139{
140 const auto& my_relay{ relays.get_relay(1) };
141
142 // Ensure relay is OFF initially
143 TEST_ASSERT_FALSE(my_relay.isRelayON());
144
145 // Test override with insufficient surplus (would normally not turn ON)
146 const auto insufficient_surplus{ -my_relay.get_surplusThreshold() + 100 };
147
148 // Test at half the minimum OFF time - should still be blocked
149 for (uint8_t timer = 0; timer < my_relay.get_minOFF() / 2; ++timer)
150 {
151 my_relay.inc_duration();
152 }
153
154 uint16_t overrideBitmask = (1U << my_relay.get_pin());
155 TEST_ASSERT_FALSE(my_relay.proceed_relay(insufficient_surplus, overrideBitmask));
156 TEST_ASSERT_FALSE(my_relay.isRelayON());
157 TEST_ASSERT_EQUAL(0, overrideBitmask & (1U << my_relay.get_pin())); // Bit cleared
158
159 // Increment to just before minimum OFF time is reached
160 for (uint8_t timer = my_relay.get_minOFF() / 2; timer < my_relay.get_minOFF() - 1; ++timer)
161 {
162 my_relay.inc_duration();
163 }
164
165 overrideBitmask = (1U << my_relay.get_pin());
166 TEST_ASSERT_FALSE(my_relay.proceed_relay(insufficient_surplus, overrideBitmask));
167 TEST_ASSERT_FALSE(my_relay.isRelayON());
168 TEST_ASSERT_EQUAL(0, overrideBitmask & (1U << my_relay.get_pin())); // Bit cleared
169
170 // Increment one more time - now minimum OFF time is reached
171 my_relay.inc_duration();
172
173 overrideBitmask = (1U << my_relay.get_pin());
174 TEST_ASSERT_TRUE(my_relay.proceed_relay(insufficient_surplus, overrideBitmask));
175 TEST_ASSERT_TRUE(my_relay.isRelayON());
176 TEST_ASSERT_EQUAL(0, overrideBitmask & (1U << my_relay.get_pin())); // Bit cleared
177}
178
180{
181 const auto& my_relay{ relays.get_relay(1) };
182
183 // Relay should be ON from previous test
184 TEST_ASSERT_TRUE(my_relay.isRelayON());
185
186 // Test that relay respects minimum ON time even after override is released
187 const auto high_import{ my_relay.get_importThreshold() + 100 }; // High import should turn OFF relay
188 uint16_t overrideBitmask = 0; // No override active anymore
189
190 // Test at half the minimum ON time - should NOT turn OFF yet
191 for (uint8_t timer = 0; timer < my_relay.get_minON() / 2; ++timer)
192 {
193 my_relay.inc_duration();
194 }
195
196 TEST_ASSERT_FALSE(my_relay.proceed_relay(high_import, overrideBitmask));
197 TEST_ASSERT_TRUE(my_relay.isRelayON()); // Should stay ON
198
199 // Test just before minimum ON time is reached
200 for (uint8_t timer = my_relay.get_minON() / 2; timer < my_relay.get_minON() - 1; ++timer)
201 {
202 my_relay.inc_duration();
203 }
204
205 TEST_ASSERT_FALSE(my_relay.proceed_relay(high_import, overrideBitmask));
206 TEST_ASSERT_TRUE(my_relay.isRelayON()); // Should still stay ON
207
208 // Increment one more time - now minimum ON time is reached
209 my_relay.inc_duration();
210
211 TEST_ASSERT_TRUE(my_relay.proceed_relay(high_import, overrideBitmask));
212 TEST_ASSERT_FALSE(my_relay.isRelayON()); // Now it can turn OFF
213}
214
216{
217 RUN_TEST(test_relay_turnON);
218 delay(100);
219 RUN_TEST(test_relay_turnOFF);
220 delay(100);
222 delay(100);
224}
225
227{
228 TEST_ASSERT_EQUAL(2, relays.size());
229}
230
231// ============================================================================
232// RelayEngine settle_change tests
233// ============================================================================
234
235// Use a different D parameter (1 minute instead of 10) to:
236// 1. Create a separate EWMA instance (different template instantiation)
237// 2. Have faster EWMA convergence (fewer samples needed)
238// EWMA window = D * 60 / DATALOG_PERIOD_IN_SECONDS = 1 * 60 / 5 = 12 samples
240 { { 8, 500, 100, 1, 1 },
241 { 9, 800, 150, 1, 1 } } };
242
244{
245 // RelayEngine initializes settle_change to 60 seconds
246 // proceed_relays() should return early and not change any relay state
247
248 // Ensure relays are OFF initially
249 TEST_ASSERT_FALSE(settleTestRelays.get_relay(0).isRelayON());
250 TEST_ASSERT_FALSE(settleTestRelays.get_relay(1).isRelayON());
251
252 // Feed surplus power - need enough samples for EWMA to converge
253 // With D=1, window is 12 samples, so ~50 samples should be enough
254 for (uint8_t i = 0; i < 50; ++i)
255 {
256 settleTestRelays.update_average(-600); // 600W surplus
257 }
258
259 // Try to proceed relays - should be blocked by settle_change
260 uint16_t overrideBitmask = 0;
261 settleTestRelays.proceed_relays(overrideBitmask);
262
263 // Relays should still be OFF because settle_change blocks changes
264 TEST_ASSERT_FALSE(settleTestRelays.get_relay(0).isRelayON());
265 TEST_ASSERT_FALSE(settleTestRelays.get_relay(1).isRelayON());
266}
267
269{
270 // After 60 calls to inc_duration(), settle_change should reach 0
271 // and allow relay state changes
272
273 // Wait for minOFF to elapse (60 seconds) AND settle_change to reach 0
274 for (uint8_t i = 0; i < 60; ++i)
275 {
276 settleTestRelays.inc_duration();
277 }
278
279 // Feed more surplus to ensure EWMA is well below threshold
280 for (uint8_t i = 0; i < 50; ++i)
281 {
282 settleTestRelays.update_average(-600); // 600W surplus > 500W threshold
283 }
284
285 // Now proceed_relays should be able to turn ON relay 0
286 uint16_t overrideBitmask = 0;
287 settleTestRelays.proceed_relays(overrideBitmask);
288
289 // Relay 0 should now be ON (it has the lower threshold)
290 TEST_ASSERT_TRUE(settleTestRelays.get_relay(0).isRelayON());
291 TEST_ASSERT_FALSE(settleTestRelays.get_relay(1).isRelayON());
292}
293
295{
296 // After a relay changes state, settle_change is reset to 60
297 // This should block the next relay from changing immediately
298
299 // Relay 0 is ON from previous test
300 TEST_ASSERT_TRUE(settleTestRelays.get_relay(0).isRelayON());
301
302 // Feed more surplus to try to turn ON relay 1
303 for (uint8_t i = 0; i < 50; ++i)
304 {
305 settleTestRelays.update_average(-1000); // 1000W surplus > 800W threshold
306 }
307
308 // Try to proceed relays immediately - should be blocked by settle_change
309 uint16_t overrideBitmask = 0;
310 settleTestRelays.proceed_relays(overrideBitmask);
311
312 // Relay 1 should still be OFF because settle_change was reset to 60
313 TEST_ASSERT_FALSE(settleTestRelays.get_relay(1).isRelayON());
314
315 // Wait for settle_change to elapse (60 seconds)
316 for (uint8_t i = 0; i < 60; ++i)
317 {
318 settleTestRelays.inc_duration();
319 }
320
321 // Keep feeding surplus
322 for (uint8_t i = 0; i < 50; ++i)
323 {
324 settleTestRelays.update_average(-1000);
325 }
326
327 // Now relay 1 should be able to turn ON
328 overrideBitmask = 0;
329 settleTestRelays.proceed_relays(overrideBitmask);
330
331 TEST_ASSERT_TRUE(settleTestRelays.get_relay(0).isRelayON());
332 TEST_ASSERT_TRUE(settleTestRelays.get_relay(1).isRelayON());
333}
334
336{
337 // Both relays are ON from previous test
338 TEST_ASSERT_TRUE(settleTestRelays.get_relay(0).isRelayON());
339 TEST_ASSERT_TRUE(settleTestRelays.get_relay(1).isRelayON());
340
341 // Feed import power to try to turn OFF relays
342 for (uint8_t i = 0; i < 50; ++i)
343 {
344 settleTestRelays.update_average(300); // 300W import > both import thresholds
345 }
346
347 // Try to proceed relays immediately - should be blocked
348 uint16_t overrideBitmask = 0;
349 settleTestRelays.proceed_relays(overrideBitmask);
350
351 // Both relays should still be ON (blocked by settle_change)
352 TEST_ASSERT_TRUE(settleTestRelays.get_relay(0).isRelayON());
353 TEST_ASSERT_TRUE(settleTestRelays.get_relay(1).isRelayON());
354
355 // Wait for settle_change AND minON to elapse
356 for (uint8_t i = 0; i < 60; ++i)
357 {
358 settleTestRelays.inc_duration();
359 }
360
361 // Keep feeding import
362 for (uint8_t i = 0; i < 50; ++i)
363 {
364 settleTestRelays.update_average(300);
365 }
366
367 // Now relay 1 should turn OFF first (reverse order for import)
368 overrideBitmask = 0;
369 settleTestRelays.proceed_relays(overrideBitmask);
370
371 TEST_ASSERT_TRUE(settleTestRelays.get_relay(0).isRelayON()); // Still ON
372 TEST_ASSERT_FALSE(settleTestRelays.get_relay(1).isRelayON()); // Turned OFF
373}
374
385
386// ============================================================================
387// Relay ordering tests
388// ============================================================================
389
390// Use 3 relays to clearly demonstrate ordering behavior
391// D=3 for separate EWMA instance
392// All relays have same thresholds to focus on ordering, not threshold differences
394 { { 11, 500, 100, 1, 1 },
395 { 12, 500, 100, 1, 1 },
396 { 13, 500, 100, 1, 1 } } };
397
399{
400 // Feed enough samples for EWMA to converge to surplus
401 for (uint8_t i = 0; i < 50; ++i)
402 {
403 orderingTestRelays.update_average(-600); // 600W surplus
404 }
405}
406
408{
409 // Feed enough samples for EWMA to converge to import
410 for (uint8_t i = 0; i < 50; ++i)
411 {
412 orderingTestRelays.update_average(200); // 200W import
413 }
414}
415
417{
418 // Wait for settle_change (60s) and minON/minOFF (60s) to elapse
419 for (uint8_t i = 0; i < 60; ++i)
420 {
421 orderingTestRelays.inc_duration();
422 }
423}
424
426{
427 // With surplus power, relays should turn ON in ascending order: 0 → 1 → 2
428 // This ensures lower-priority loads are activated first
429
430 // Verify all relays start OFF
431 TEST_ASSERT_FALSE(orderingTestRelays.get_relay(0).isRelayON());
432 TEST_ASSERT_FALSE(orderingTestRelays.get_relay(1).isRelayON());
433 TEST_ASSERT_FALSE(orderingTestRelays.get_relay(2).isRelayON());
434
435 // Wait for initial settle_change to expire
437
438 // Feed surplus power
440
441 // First proceed_relays call - relay 0 should turn ON
442 uint16_t overrideBitmask = 0;
443 orderingTestRelays.proceed_relays(overrideBitmask);
444
445 TEST_ASSERT_TRUE(orderingTestRelays.get_relay(0).isRelayON()); // ON first
446 TEST_ASSERT_FALSE(orderingTestRelays.get_relay(1).isRelayON());
447 TEST_ASSERT_FALSE(orderingTestRelays.get_relay(2).isRelayON());
448
449 // Wait for settle_change to expire
452
453 // Second proceed_relays call - relay 1 should turn ON
454 overrideBitmask = 0;
455 orderingTestRelays.proceed_relays(overrideBitmask);
456
457 TEST_ASSERT_TRUE(orderingTestRelays.get_relay(0).isRelayON());
458 TEST_ASSERT_TRUE(orderingTestRelays.get_relay(1).isRelayON()); // ON second
459 TEST_ASSERT_FALSE(orderingTestRelays.get_relay(2).isRelayON());
460
461 // Wait for settle_change to expire
464
465 // Third proceed_relays call - relay 2 should turn ON
466 overrideBitmask = 0;
467 orderingTestRelays.proceed_relays(overrideBitmask);
468
469 TEST_ASSERT_TRUE(orderingTestRelays.get_relay(0).isRelayON());
470 TEST_ASSERT_TRUE(orderingTestRelays.get_relay(1).isRelayON());
471 TEST_ASSERT_TRUE(orderingTestRelays.get_relay(2).isRelayON()); // ON third
472}
473
475{
476 // With import power, relays should turn OFF in descending order: 2 → 1 → 0
477 // This ensures higher-priority loads stay on longer
478
479 // All relays are ON from previous test
480 TEST_ASSERT_TRUE(orderingTestRelays.get_relay(0).isRelayON());
481 TEST_ASSERT_TRUE(orderingTestRelays.get_relay(1).isRelayON());
482 TEST_ASSERT_TRUE(orderingTestRelays.get_relay(2).isRelayON());
483
484 // Wait for settle_change to expire
486
487 // Feed import power
489
490 // First proceed_relays call - relay 2 should turn OFF (last ON, first OFF)
491 uint16_t overrideBitmask = 0;
492 orderingTestRelays.proceed_relays(overrideBitmask);
493
494 TEST_ASSERT_TRUE(orderingTestRelays.get_relay(0).isRelayON());
495 TEST_ASSERT_TRUE(orderingTestRelays.get_relay(1).isRelayON());
496 TEST_ASSERT_FALSE(orderingTestRelays.get_relay(2).isRelayON()); // OFF first
497
498 // Wait for settle_change to expire
501
502 // Second proceed_relays call - relay 1 should turn OFF
503 overrideBitmask = 0;
504 orderingTestRelays.proceed_relays(overrideBitmask);
505
506 TEST_ASSERT_TRUE(orderingTestRelays.get_relay(0).isRelayON());
507 TEST_ASSERT_FALSE(orderingTestRelays.get_relay(1).isRelayON()); // OFF second
508 TEST_ASSERT_FALSE(orderingTestRelays.get_relay(2).isRelayON());
509
510 // Wait for settle_change to expire
513
514 // Third proceed_relays call - relay 0 should turn OFF
515 overrideBitmask = 0;
516 orderingTestRelays.proceed_relays(overrideBitmask);
517
518 TEST_ASSERT_FALSE(orderingTestRelays.get_relay(0).isRelayON()); // OFF third
519 TEST_ASSERT_FALSE(orderingTestRelays.get_relay(1).isRelayON());
520 TEST_ASSERT_FALSE(orderingTestRelays.get_relay(2).isRelayON());
521}
522
529
530// ============================================================================
531// Duration overflow tests
532// ============================================================================
533
534// Use D=2 to create a separate EWMA instance from other tests
535// Using pin 10 to avoid conflicts with other tests
537 { { 10, 500, 100, 1, 1 } } };
538
540{
541 // Test that duration saturates at UINT16_MAX and doesn't wrap to 0.
542 // If it wrapped, the relay would be incorrectly blocked after overflow.
543 //
544 // The inc_duration() function has this protection:
545 // if (duration < UINT16_MAX) { ++duration; }
546
547 const auto& relay = overflowTestRelays.get_relay(0);
548
549 // Ensure relay is OFF initially
550 TEST_ASSERT_FALSE(relay.isRelayON());
551
552 // Increment duration to UINT16_MAX (65535 iterations)
553 // This takes only a few seconds on Arduino - no actual waiting involved
554 for (uint32_t i = 0; i < UINT16_MAX; ++i)
555 {
556 relay.inc_duration();
557 }
558
559 // At this point duration == UINT16_MAX (65535)
560 // Relay should be able to turn ON (duration >> minOFF which is 60)
561 uint16_t overrideBitmask = 0;
562 const int32_t surplus = -600; // 600W surplus > 500W threshold
563 TEST_ASSERT_TRUE(relay.proceed_relay(surplus, overrideBitmask));
564 TEST_ASSERT_TRUE(relay.isRelayON());
565}
566
568{
569 // After reaching UINT16_MAX, further increments should not wrap to 0
570 // The relay should remain functional
571
572 const auto& relay = overflowTestRelays.get_relay(0);
573
574 // Relay is ON from previous test
575 TEST_ASSERT_TRUE(relay.isRelayON());
576
577 // Increment many more times beyond UINT16_MAX
578 // If there was no saturation check, this would wrap duration to ~1000
579 // and block the relay from turning OFF (duration < minON)
580 for (uint16_t i = 0; i < 1000; ++i)
581 {
582 relay.inc_duration();
583 }
584
585 // Relay should still be able to turn OFF
586 // If duration wrapped to ~1000, this would still work (1000 > 60)
587 // So we need a more precise test...
588 const int32_t import = 200; // 200W import > 100W threshold
589 uint16_t overrideBitmask = 0;
590 TEST_ASSERT_TRUE(relay.proceed_relay(import, overrideBitmask));
591 TEST_ASSERT_FALSE(relay.isRelayON());
592}
593
595{
596 // This test proves that without saturation, wrapping WOULD cause issues.
597 // We increment exactly to where a wrap would put duration below minOFF,
598 // then verify the relay still works (proving no wrap occurred).
599
600 const auto& relay = overflowTestRelays.get_relay(0);
601
602 // Relay is OFF from previous test
603 TEST_ASSERT_FALSE(relay.isRelayON());
604
605 // Increment to UINT16_MAX
606 for (uint32_t i = 0; i < UINT16_MAX; ++i)
607 {
608 relay.inc_duration();
609 }
610
611 // Now increment 50 more times
612 // If duration wrapped: (65535 + 50) % 65536 = 49, which is < minOFF (60)
613 // If duration saturates: it stays at 65535, which is > minOFF (60)
614 for (uint8_t i = 0; i < 50; ++i)
615 {
616 relay.inc_duration();
617 }
618
619 // Try to turn ON the relay
620 // If wrapped to 49: would FAIL (49 < 60, blocked by minOFF)
621 // If saturated at 65535: should SUCCEED (65535 > 60)
622 uint16_t overrideBitmask = 0;
623 const int32_t surplus = -600;
624 TEST_ASSERT_TRUE(relay.proceed_relay(surplus, overrideBitmask));
625 TEST_ASSERT_TRUE(relay.isRelayON());
626
627 // Similarly test turn OFF
628 // Increment to UINT16_MAX again
629 for (uint32_t i = 0; i < UINT16_MAX; ++i)
630 {
631 relay.inc_duration();
632 }
633
634 // Increment 50 more times (would wrap to 49 if not saturating)
635 for (uint8_t i = 0; i < 50; ++i)
636 {
637 relay.inc_duration();
638 }
639
640 // Try to turn OFF
641 // If wrapped to 49: would FAIL (49 < 60, blocked by minON)
642 // If saturated: should SUCCEED
643 const int32_t import = 200;
644 overrideBitmask = 0;
645 TEST_ASSERT_TRUE(relay.proceed_relay(import, overrideBitmask));
646 TEST_ASSERT_FALSE(relay.isRelayON());
647}
648
657
658void setup()
659{
660 delay(1000);
661
662 UNITY_BEGIN(); // IMPORTANT LINE!
663}
664
665void loop()
666{
670
671 RUN_TEST(test_get_size);
672
673 RUN_TEST(test_get_pin);
674
676 RUN_TEST(test_get_importThreshold);
677
678 RUN_TEST(test_get_minON);
679 RUN_TEST(test_get_minOFF);
680
681 RUN_TEST(test_isRelayON);
682
683 RUN_TEST(test_proceed_relay);
684
686
687 RUN_TEST(test_relay_ordering);
688
689 RUN_TEST(test_duration_overflow);
690
691 UNITY_END(); // stop unit testing
692}
Manages a collection of relays and their behavior based on surplus and import thresholds.
Represents a single relay configuration and its behavior.
Definition utils_relay.h:41
constexpr auto get_surplusThreshold() const
Get the surplus threshold which will turns ON the relay.
constexpr auto get_importThreshold() const
Get the import threshold which will turns OFF the relay.
constexpr auto get_pin() const
Get the control pin of the relay.
Definition utils_relay.h:92
constexpr RelayEngine relays
Definition config.h:126
void setup()
void setUp(void)
Definition test_main.cpp:15
void tearDown(void)
Definition test_main.cpp:19
void loop()
uint8_t i
Definition test_main.cpp:92
void test_duration_overflow_wrap_would_block_relay(void)
void test_relay_ordering(void)
void feed_surplus_to_ordering_relays(void)
void test_duration_overflow(void)
void test_get_pin(void)
Definition test_main.cpp:45
void test_get_minOFF(void)
Definition test_main.cpp:69
void test_relay_override_turnON(void)
void test_proceed_relay(void)
void test_relay_ordering_import_turns_off_descending(void)
constexpr RelayEngine< 3, 3 > orderingTestRelays
void test_settle_change_blocks_initial_relay_changes(void)
void test_isRelayON(void)
Definition test_main.cpp:75
void wait_for_relay_change_allowed(void)
void test_relay_turnOFF(void)
constexpr RelayEngine< 2, 1 > settleTestRelays
void test_get_size(void)
void test_get_minON(void)
Definition test_main.cpp:63
void test_duration_overflow_stays_at_max_after_more_increments(void)
void test_proceed_settle_change(void)
void feed_import_to_ordering_relays(void)
constexpr RelayEngine< 1, 2 > overflowTestRelays
void test_get_surplusThreshold(void)
Definition test_main.cpp:51
void test_relay_override_minimum_ON_time(void)
void test_relay_initialization_with_positive_thresholds(void)
Definition test_main.cpp:29
void test_settle_change_blocks_turn_off_as_well(void)
void test_get_importThreshold(void)
Definition test_main.cpp:57
void test_settle_change_allows_changes_after_60_seconds(void)
void test_relay_initialization(void)
Definition test_main.cpp:21
void test_relay_ordering_surplus_turns_on_ascending(void)
void test_settle_change_resets_after_relay_change(void)
void test_relay_turnON(void)
Definition test_main.cpp:80
void test_relay_initialization_with_negative_thresholds(void)
Definition test_main.cpp:37
void test_duration_overflow_saturates_at_uint16_max(void)
Some utility functions for pins manipulation.
Some utility functions for the relay output feature.