9 { 3, 100, 20, 2, 3 } } };
24 TEST_ASSERT_EQUAL(4, relay.
get_pin());
32 TEST_ASSERT_EQUAL(4, relay.
get_pin());
40 TEST_ASSERT_EQUAL(4, relay.
get_pin());
47 TEST_ASSERT_EQUAL(2,
relays.get_relay(0).get_pin());
48 TEST_ASSERT_EQUAL(3,
relays.get_relay(1).get_pin());
53 TEST_ASSERT_EQUAL(1000,
relays.get_relay(0).get_surplusThreshold());
54 TEST_ASSERT_EQUAL(100,
relays.get_relay(1).get_surplusThreshold());
59 TEST_ASSERT_EQUAL(200,
relays.get_relay(0).get_importThreshold());
60 TEST_ASSERT_EQUAL(20,
relays.get_relay(1).get_importThreshold());
65 TEST_ASSERT_EQUAL(1 * 60,
relays.get_relay(0).get_minON());
66 TEST_ASSERT_EQUAL(2 * 60,
relays.get_relay(1).get_minON());
71 TEST_ASSERT_EQUAL(1 * 60,
relays.get_relay(0).get_minOFF());
72 TEST_ASSERT_EQUAL(3 * 60,
relays.get_relay(1).get_minOFF());
77 TEST_ASSERT_FALSE(
relays.get_relay(1).isRelayON());
82 const auto& my_relay{
relays.get_relay(1) };
84 TEST_ASSERT_FALSE(my_relay.isRelayON());
87 const auto surplus{ -my_relay.get_surplusThreshold() - 1 };
89 TEST_ASSERT_FALSE(my_relay.proceed_relay(surplus));
91 TEST_ASSERT_FALSE(my_relay.isRelayON());
93 for (uint8_t timer = 0; timer < my_relay.get_minOFF() - 1; ++timer)
95 my_relay.inc_duration();
97 TEST_ASSERT_FALSE(my_relay.proceed_relay(surplus));
100 my_relay.inc_duration();
102 TEST_ASSERT_TRUE(my_relay.proceed_relay(surplus));
103 TEST_ASSERT_TRUE(my_relay.isRelayON());
108 const auto& my_relay{
relays.get_relay(1) };
110 TEST_ASSERT_TRUE(my_relay.isRelayON());
113 const auto consum{ my_relay.get_importThreshold() + 1 };
115 TEST_ASSERT_FALSE(my_relay.proceed_relay(consum));
117 TEST_ASSERT_TRUE(my_relay.isRelayON());
119 for (uint8_t timer = 0; timer < my_relay.get_minON() - 1; ++timer)
121 my_relay.inc_duration();
123 TEST_ASSERT_FALSE(my_relay.proceed_relay(consum));
126 my_relay.inc_duration();
128 TEST_ASSERT_TRUE(my_relay.proceed_relay(consum));
129 TEST_ASSERT_FALSE(my_relay.isRelayON());
141 TEST_ASSERT_EQUAL(2,
relays.get_size());
Manages a collection of relays and their behavior based on surplus and import thresholds.
Represents a single relay configuration and its behavior.
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.
constexpr RelayEngine relays
void test_get_minOFF(void)
void test_proceed_relay(void)
void test_isRelayON(void)
void test_relay_turnOFF(void)
void test_get_minON(void)
void test_get_surplusThreshold(void)
void test_relay_initialization_with_positive_thresholds(void)
void test_get_importThreshold(void)
void test_relay_initialization(void)
void test_relay_turnON(void)
void test_relay_initialization_with_negative_thresholds(void)
Some utility functions for pins manipulation.
Some utility functions for the relay output feature.