21 { 3, 100, 20, 2, 3 } } };
45 TEST_ASSERT_EQUAL(4, relay.
get_pin());
56 TEST_ASSERT_EQUAL(4, relay.
get_pin());
67 TEST_ASSERT_EQUAL(4, relay.
get_pin());
77 TEST_ASSERT_EQUAL(2,
relays.get_relay(0).get_pin());
78 TEST_ASSERT_EQUAL(3,
relays.get_relay(1).get_pin());
86 TEST_ASSERT_EQUAL(1000,
relays.get_relay(0).get_surplusThreshold());
87 TEST_ASSERT_EQUAL(100,
relays.get_relay(1).get_surplusThreshold());
95 TEST_ASSERT_EQUAL(200,
relays.get_relay(0).get_importThreshold());
96 TEST_ASSERT_EQUAL(20,
relays.get_relay(1).get_importThreshold());
104 TEST_ASSERT_EQUAL(1 * 60,
relays.get_relay(0).get_minON());
105 TEST_ASSERT_EQUAL(2 * 60,
relays.get_relay(1).get_minON());
113 TEST_ASSERT_EQUAL(1 * 60,
relays.get_relay(0).get_minOFF());
114 TEST_ASSERT_EQUAL(3 * 60,
relays.get_relay(1).get_minOFF());
122 TEST_ASSERT_FALSE(
relays.get_relay(1).isRelayON());
130 const auto& my_relay{
relays.get_relay(1) };
132 TEST_ASSERT_FALSE(my_relay.isRelayON());
135 const auto surplus{ -my_relay.get_surplusThreshold() - 1 };
137 TEST_ASSERT_FALSE(my_relay.proceed_relay(surplus));
139 TEST_ASSERT_FALSE(my_relay.isRelayON());
141 for (uint8_t timer = 0; timer < my_relay.get_minOFF() - 1; ++timer)
143 my_relay.inc_duration();
145 TEST_ASSERT_FALSE(my_relay.proceed_relay(surplus));
148 my_relay.inc_duration();
150 TEST_ASSERT_TRUE(my_relay.proceed_relay(surplus));
151 TEST_ASSERT_TRUE(my_relay.isRelayON());
159 const auto& my_relay{
relays.get_relay(1) };
161 TEST_ASSERT_TRUE(my_relay.isRelayON());
164 const auto consum{ my_relay.get_importThreshold() + 1 };
166 TEST_ASSERT_FALSE(my_relay.proceed_relay(consum));
168 TEST_ASSERT_TRUE(my_relay.isRelayON());
170 for (uint8_t timer = 0; timer < my_relay.get_minON() - 1; ++timer)
172 my_relay.inc_duration();
174 TEST_ASSERT_FALSE(my_relay.proceed_relay(consum));
177 my_relay.inc_duration();
179 TEST_ASSERT_TRUE(my_relay.proceed_relay(consum));
180 TEST_ASSERT_FALSE(my_relay.isRelayON());
198 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.