From 9d92cc80c5088d72f024d1db20682f4e6448b08d Mon Sep 17 00:00:00 2001 From: Tester23 Date: Wed, 20 Nov 2024 12:02:39 +0100 Subject: [PATCH] selftest fix --- src/selftest/selftest_energyMeter.c | 6 ++++++ src/win_main.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/selftest/selftest_energyMeter.c b/src/selftest/selftest_energyMeter.c index b23aa2020..058bca17d 100644 --- a/src/selftest/selftest_energyMeter.c +++ b/src/selftest/selftest_energyMeter.c @@ -211,6 +211,7 @@ void Test_EnergyMeter_TurnOffScript() { CMD_ExecuteCommand("SetupTestPower 230 0.01 0.5 0", 0); int prevChannel10 = CHANNEL_Get(10); for (int i = 0; i < 10; i++) { + Test_Power_RunEverySecond(); Sim_RunSeconds(1.5f, false); int now10 = CHANNEL_Get(10); SELFTEST_ASSERT(now10 > prevChannel10); @@ -220,6 +221,7 @@ void Test_EnergyMeter_TurnOffScript() { // now reset will kick in CMD_ExecuteCommand("SetupTestPower 230 0.01 1.5 0", 0); for (int i = 0; i < 10; i++) { + Test_Power_RunEverySecond(); Sim_RunSeconds(1.5f, false); int now10 = CHANNEL_Get(10); SELFTEST_ASSERT(now10 == 0); @@ -231,6 +233,7 @@ void Test_EnergyMeter_TurnOffScript() { Sim_RunSeconds(1.5f, false); prevChannel10 = CHANNEL_Get(10); for (int i = 0; i < 10; i++) { + Test_Power_RunEverySecond(); Sim_RunSeconds(1.5f, false); int now10 = CHANNEL_Get(10); SELFTEST_ASSERT(now10 > prevChannel10); @@ -240,6 +243,7 @@ void Test_EnergyMeter_TurnOffScript() { // now reset will kick in CMD_ExecuteCommand("SetupTestPower 230 0.01 1.5 0", 0); for (int i = 0; i < 10; i++) { + Test_Power_RunEverySecond(); Sim_RunSeconds(1.5f, false); int now10 = CHANNEL_Get(10); SELFTEST_ASSERT(now10 == 0); @@ -249,6 +253,7 @@ void Test_EnergyMeter_TurnOffScript() { CMD_ExecuteCommand("SetupTestPower 230 0.01 0.5 0", 0); prevChannel10 = CHANNEL_Get(10); for (int i = 0; i < 12; i++) { + Test_Power_RunEverySecond(); Sim_RunSeconds(1.5f, false); int now10 = CHANNEL_Get(10); SELFTEST_ASSERT(now10 > prevChannel10); @@ -258,6 +263,7 @@ void Test_EnergyMeter_TurnOffScript() { // this loop should trigger turn off prevChannel10 = CHANNEL_Get(10); for (int i = 0; i < 3; i++) { + Test_Power_RunEverySecond(); Sim_RunSeconds(1.5f, false); int now10 = CHANNEL_Get(10); SELFTEST_ASSERT(now10 > prevChannel10); diff --git a/src/win_main.c b/src/win_main.c index f29781843..d592bfc1d 100644 --- a/src/win_main.c +++ b/src/win_main.c @@ -139,6 +139,7 @@ void Win_DoUnitTests() { Test_Command_If_Else(); Test_MQTT(); Test_ChargeLimitDriver(); + Test_EnergyMeter(); // this is slowest Test_TuyaMCU_Basic(); Test_TuyaMCU_Mult(); @@ -171,7 +172,6 @@ void Win_DoUnitTests() { Test_MultiplePinsOnChannel(); Test_Flags(); Test_DHT(); - Test_EnergyMeter(); Test_Tasmota(); Test_NTP(); Test_NTP_SunsetSunrise();