From 224bb29776703c5177f0abf70e78c5ee01286b62 Mon Sep 17 00:00:00 2001 From: James Foster Date: Thu, 26 Dec 2024 10:19:23 -0800 Subject: [PATCH 01/10] Consolidate all the setup into the `instance()` method. --- examples/TankController/TankController.ino | 4 +- .../device_client/lib/components/display.dart | 2 +- extras/device_client/lib/model/version.dart | 2 +- src/TankController.cpp | 73 ++++++++++--------- src/TankController.h | 2 +- src/Version.h | 2 +- src/wrappers/SD_TC.cpp | 2 +- 7 files changed, 47 insertions(+), 40 deletions(-) diff --git a/examples/TankController/TankController.ino b/examples/TankController/TankController.ino index 052e37278..5e5c06b33 100644 --- a/examples/TankController/TankController.ino +++ b/examples/TankController/TankController.ino @@ -27,8 +27,8 @@ void serialEvent1() { // if the hardware serial port_1 receives a char tank->serialEvent1(); } void setup() { - // the install process is followed by a reset and we get two startups - delay(500); + // the install process is followed by a reset and we can get two startups + delay(2000); tank = TankController::instance(remoteLogName, pushingBoxID, tzOffsetHrs); tank->setup(); } diff --git a/extras/device_client/lib/components/display.dart b/extras/device_client/lib/components/display.dart index 902473e83..bac39a8de 100644 --- a/extras/device_client/lib/components/display.dart +++ b/extras/device_client/lib/components/display.dart @@ -27,7 +27,7 @@ class Display extends StatelessWidget { color: Colors.grey.shade800, boxShadow: [ BoxShadow( - color: Colors.black.withOpacity(0.5), + color: Colors.black.withValues(alpha: 0.5), spreadRadius: 5, blurRadius: 7, offset: const Offset(0, 3), diff --git a/extras/device_client/lib/model/version.dart b/extras/device_client/lib/model/version.dart index 8110b31e6..52716efbc 100644 --- a/extras/device_client/lib/model/version.dart +++ b/extras/device_client/lib/model/version.dart @@ -1 +1 @@ -const String gitVersion = 'v24.10.2-3-g06a+'; +const String gitVersion = 'v24.10.2-3-gc0c+'; diff --git a/src/TankController.cpp b/src/TankController.cpp index 1daeaae49..c3202b3e1 100644 --- a/src/TankController.cpp +++ b/src/TankController.cpp @@ -37,9 +37,29 @@ TankController *TankController::_instance = nullptr; */ TankController *TankController::instance(const char *remoteLogName, const char *pushingBoxID, int tzOffsetHrs) { if (!_instance) { - _instance = new TankController(remoteLogName); + serial(F("\r\n##############\r\nTankController %s"), TANK_CONTROLLER_VERSION); + _instance = new TankController(); + unsigned long start = millis(); + SD_TC::instance()->setRemoteLogName(remoteLogName); + EEPROM_TC::instance(); + Keypad_TC::instance(); + LiquidCrystal_TC::instance(TANK_CONTROLLER_VERSION); + DataLogger::instance(); + DateTime_TC::rtc(); + Ethernet_TC::instance(); + EthernetServer_TC::instance(); + ThermalProbe_TC::instance(); + ThermalControl::instance(); + PHProbe::instance(); + PHControl::instance(); + PID_TC::instance(); + pinMode(LED_BUILTIN, OUTPUT); + _instance->state = new MainMenu(); PushingBox::instance(pushingBoxID); GetTime::instance(tzOffsetHrs); + serial(F("Free memory = %i"), _instance->freeMemory()); + wdt_enable(WDTO_8S); + serial(F("TankController::instance() - took %lu ms"), millis() - start); } return _instance; } @@ -58,25 +78,8 @@ void TankController::deleteInstance() { /** * Constructor */ -TankController::TankController(const char *remoteLogName) { - serial(F("\r\n#################\r\nTankController::TankController() - version %s"), TANK_CONTROLLER_VERSION); +TankController::TankController() { assert(!_instance); - // ensure we have instances - SD_TC::instance()->setRemoteLogName(remoteLogName); - EEPROM_TC::instance(); - Keypad_TC::instance(); - LiquidCrystal_TC::instance(TANK_CONTROLLER_VERSION); - DataLogger::instance(); - DateTime_TC::rtc(); - Ethernet_TC::instance(); - EthernetServer_TC::instance(); - ThermalProbe_TC::instance(); - ThermalControl::instance(); - PHProbe::instance(); - PHControl::instance(); - PID_TC::instance(); - state = new MainMenu(); - pinMode(LED_BUILTIN, OUTPUT); } /** @@ -158,25 +161,31 @@ void TankController::handleUI() { /** * This is one of two public instance functions. * It is called repeatedly while the board is on. - * (It appears to be called about once every 15 ms.) */ void TankController::loop(bool report_loop_delay) { static unsigned long lastTime = 0; unsigned long thisTime = millis(); if (report_loop_delay && lastTime && thisTime - lastTime > 500) { - // report unusual delay serial(F("unexpected delay of %i ms"), thisTime - lastTime); } - lastTime = thisTime; + unsigned long start = millis(); wdt_reset(); - blink(); // blink the on-board LED to show that we are running - updateControls(); // turn CO2 and temperature controls on or off - handleUI(); // look at keypad, update LCD (~90ms) - DataLogger::instance()->loop(); // record current data to SD and serial - GetTime::instance()->loop(); // update the time - PushingBox::instance()->loop(); // write data to Google Sheets (~1130ms every report) - Ethernet_TC::instance()->loop(); // renew DHCP lease - EthernetServer_TC::instance()->loop(); // handle any HTTP requests + blink(); // blink the on-board LED to show that we are running (0ms) + updateControls(); // turn CO2 and temperature controls on or off (~90ms) + handleUI(); // look at keypad, update LCD (~10ms) + DataLogger::instance()->loop(); // record current data to SD and serial (~80ms) + GetTime::instance()->loop(); // update the time (~0ms) + PushingBox::instance()->loop(); // write data to Google Sheets (~0ms; ~1130ms every report) + Ethernet_TC::instance()->loop(); // renew DHCP lease (~0ms) + EthernetServer_TC::instance()->loop(); // handle any HTTP requests (~0ms) + if (report_loop_delay) { + static long int count = 0; + unsigned long loopTime = millis() - start; + if (+count % 10000 == 1 || loopTime > 200) { // first time through and periodically thereafter + serial(F("TankController::loop() - took %lu ms (at %lu sec uptime)"), loopTime, start / 1000); + } + lastTime = millis(); + } } /** @@ -211,9 +220,7 @@ void TankController::setNextState(UIState *newState, bool update) { * Here we do any one-time startup initialization. */ void TankController::setup() { - serial(F("TankController::setup()")); - serial(F("Free memory = %i"), freeMemory()); - wdt_enable(WDTO_8S); + // all the setup happens in the instance() function } /** diff --git a/src/TankController.h b/src/TankController.h index e569b9694..a2ebfab8a 100644 --- a/src/TankController.h +++ b/src/TankController.h @@ -42,7 +42,7 @@ class TankController { char nextKey = 0; // instance methods - TankController(const char* remoteLogName); + TankController(); ~TankController(); void blink(); void handleUI(); diff --git a/src/Version.h b/src/Version.h index 2da54c12f..3512881b0 100644 --- a/src/Version.h +++ b/src/Version.h @@ -1 +1 @@ -#define VERSION "v24.10.2-3-g06a+" +#define VERSION "v24.10.2-3-gc0c+" diff --git a/src/wrappers/SD_TC.cpp b/src/wrappers/SD_TC.cpp index e9e5cadad..b003d8f40 100644 --- a/src/wrappers/SD_TC.cpp +++ b/src/wrappers/SD_TC.cpp @@ -36,7 +36,7 @@ void SD_TC::deleteInstance() { * constructor */ SD_TC::SD_TC() { - Serial.println(F("SD_TC()")); // Serial_TC might not be ready yet + Serial.println(F("SD_TC")); // Serial_TC might not be ready yet assert(_instance == nullptr); if (!sd.begin(SD_SELECT_PIN)) { Serial.println(F("SD_TC failed to initialize!")); From 2409e71f5c58c85902aead20ffd728088f799439 Mon Sep 17 00:00:00 2001 From: James Foster Date: Thu, 26 Dec 2024 10:38:12 -0800 Subject: [PATCH 02/10] Update Flutter version. --- .github/workflows/device-client.yaml | 2 +- .github/workflows/log_file_client.yaml | 2 +- .github/workflows/log_file_server.yaml | 2 +- extras/device_client/lib/model/version.dart | 2 +- src/Version.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/device-client.yaml b/.github/workflows/device-client.yaml index d9cd374dc..1242ef74a 100644 --- a/.github/workflows/device-client.yaml +++ b/.github/workflows/device-client.yaml @@ -43,7 +43,7 @@ jobs: - name: install flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.24.3' + flutter-version: '3.27.1' channel: 'stable' - name: use cache uses: actions/cache@v3 diff --git a/.github/workflows/log_file_client.yaml b/.github/workflows/log_file_client.yaml index 3e6b0d816..0b543ef29 100644 --- a/.github/workflows/log_file_client.yaml +++ b/.github/workflows/log_file_client.yaml @@ -43,7 +43,7 @@ - name: install flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.24.3' + flutter-version: '3.27.1' channel: 'stable' - name: use cache uses: actions/cache@v3 diff --git a/.github/workflows/log_file_server.yaml b/.github/workflows/log_file_server.yaml index 8e1bb5ee3..70514e12b 100644 --- a/.github/workflows/log_file_server.yaml +++ b/.github/workflows/log_file_server.yaml @@ -42,7 +42,7 @@ - name: install flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.24.3' + flutter-version: '3.27.1' channel: 'stable' - name: use cache uses: actions/cache@v3 diff --git a/extras/device_client/lib/model/version.dart b/extras/device_client/lib/model/version.dart index 52716efbc..f2a6cd665 100644 --- a/extras/device_client/lib/model/version.dart +++ b/extras/device_client/lib/model/version.dart @@ -1 +1 @@ -const String gitVersion = 'v24.10.2-3-gc0c+'; +const String gitVersion = 'v24.10.2-4-g224+'; diff --git a/src/Version.h b/src/Version.h index 3512881b0..0990e5ed8 100644 --- a/src/Version.h +++ b/src/Version.h @@ -1 +1 @@ -#define VERSION "v24.10.2-3-gc0c+" +#define VERSION "v24.10.2-4-g224+" From 3e77338a568c7867802a268ca59046e68d977dbb Mon Sep 17 00:00:00 2001 From: James Foster Date: Thu, 26 Dec 2024 10:45:01 -0800 Subject: [PATCH 03/10] Add debugging to JSONBuilderTest.cpp to see how far it gets. --- extras/device_client/lib/model/version.dart | 2 +- src/Version.h | 2 +- test/JSONBuilderTest.cpp | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/extras/device_client/lib/model/version.dart b/extras/device_client/lib/model/version.dart index f2a6cd665..b0419b9ff 100644 --- a/extras/device_client/lib/model/version.dart +++ b/extras/device_client/lib/model/version.dart @@ -1 +1 @@ -const String gitVersion = 'v24.10.2-4-g224+'; +const String gitVersion = 'v24.10.2-5-g240+'; diff --git a/src/Version.h b/src/Version.h index 0990e5ed8..c86f68ab5 100644 --- a/src/Version.h +++ b/src/Version.h @@ -1 +1 @@ -#define VERSION "v24.10.2-4-g224+" +#define VERSION "v24.10.2-5-g240+" diff --git a/test/JSONBuilderTest.cpp b/test/JSONBuilderTest.cpp index ef535b473..5d1cb54c6 100644 --- a/test/JSONBuilderTest.cpp +++ b/test/JSONBuilderTest.cpp @@ -17,6 +17,7 @@ */ unittest(currentData) { + assertTrue(1 > 0); // Fake DateTime DateTime_TC feb(2022, 2, 22, 20, 50, 00); feb.setAsCurrent(); @@ -24,13 +25,16 @@ unittest(currentData) { PHProbe::instance()->setPhSlope(); // actual PHControl::instance()->setBaseTargetPh(8.25); // target PHControl::instance()->enablePID(1); + assertTrue(2 > 0); ThermalProbe_TC::instance()->setTemperature(99.99, true); // actual ThermalControl::instance()->setSineAmplitudeAndHours(0, 0); ThermalControl::instance()->setRampDurationHours(0); ThermalControl::instance()->setThermalTarget(98.88); // target EEPROM_TC::instance()->setHeat(0); PID_TC::instance()->setTunings(100001.1, 100002.2, 100003.3); + assertTrue(3 > 0); TankController::instance()->loop(false); // recognize and apply the targets + assertTrue(4 > 0); JSONBuilder builder; int size = builder.buildCurrentValues(); assertTrue(size > 200); From a63381233871a3dcf66b4f290e2b0c870f8c26f4 Mon Sep 17 00:00:00 2001 From: James Foster Date: Thu, 26 Dec 2024 11:43:06 -0800 Subject: [PATCH 04/10] Further debugging of JSONBuilderTest. Don't expect float to be exactly zero. --- extras/device_client/lib/model/version.dart | 2 +- src/Version.h | 2 +- src/model/JSONBuilder.cpp | 4 ++-- test/JSONBuilderTest.cpp | 6 +----- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/extras/device_client/lib/model/version.dart b/extras/device_client/lib/model/version.dart index b0419b9ff..6f85477e3 100644 --- a/extras/device_client/lib/model/version.dart +++ b/extras/device_client/lib/model/version.dart @@ -1 +1 @@ -const String gitVersion = 'v24.10.2-5-g240+'; +const String gitVersion = 'v24.10.2-6-g3e7+'; diff --git a/src/Version.h b/src/Version.h index c86f68ab5..3e74e30d9 100644 --- a/src/Version.h +++ b/src/Version.h @@ -1 +1 @@ -#define VERSION "v24.10.2-5-g240+" +#define VERSION "v24.10.2-6-g3e7+" diff --git a/src/model/JSONBuilder.cpp b/src/model/JSONBuilder.cpp index dc2ed9b82..a51cafa34 100644 --- a/src/model/JSONBuilder.cpp +++ b/src/model/JSONBuilder.cpp @@ -44,7 +44,7 @@ int JSONBuilder::buildCurrentValues() { char pHSlope[20]; float pHSineAmplitude = 0.0; if ((EEPROM_TC::instance()->getPhSinePeriod() / 3600.0) > 0) { - pHSineAmplitude = (PHControl::instance()->getAmplitude() ? PHControl::instance()->getAmplitude() : 0); + pHSineAmplitude = (PHControl::instance()->getAmplitude() > 0.01 ? PHControl::instance()->getAmplitude() : 0.0); } int pHSineAmplitude_f = (int)(pHSineAmplitude * 1000 + 0.5) % 1000; while (pHSineAmplitude_f && pHSineAmplitude_f % 10 == 0) { @@ -111,7 +111,7 @@ int JSONBuilder::buildCurrentValues() { float pH_SinePeriodHours = 0.0; int pH_SinePeriodHours_f = 0; // if sine amplitude is nonzero, then we are in sine mode and display the sine period - if (pHSineAmplitude != 0) { + if (pHSineAmplitude > 0.01) { pH_SinePeriodHours = EEPROM_TC::instance()->getPhSinePeriod() / 3600.0; } if (pH_SinePeriodHours > 0) { diff --git a/test/JSONBuilderTest.cpp b/test/JSONBuilderTest.cpp index 5d1cb54c6..54beee453 100644 --- a/test/JSONBuilderTest.cpp +++ b/test/JSONBuilderTest.cpp @@ -16,8 +16,7 @@ * Test correctness of JSON output from JSONBuilder */ -unittest(currentData) { - assertTrue(1 > 0); +unittest(JSONBuilderTest_currentData) { // Fake DateTime DateTime_TC feb(2022, 2, 22, 20, 50, 00); feb.setAsCurrent(); @@ -25,16 +24,13 @@ unittest(currentData) { PHProbe::instance()->setPhSlope(); // actual PHControl::instance()->setBaseTargetPh(8.25); // target PHControl::instance()->enablePID(1); - assertTrue(2 > 0); ThermalProbe_TC::instance()->setTemperature(99.99, true); // actual ThermalControl::instance()->setSineAmplitudeAndHours(0, 0); ThermalControl::instance()->setRampDurationHours(0); ThermalControl::instance()->setThermalTarget(98.88); // target EEPROM_TC::instance()->setHeat(0); PID_TC::instance()->setTunings(100001.1, 100002.2, 100003.3); - assertTrue(3 > 0); TankController::instance()->loop(false); // recognize and apply the targets - assertTrue(4 > 0); JSONBuilder builder; int size = builder.buildCurrentValues(); assertTrue(size > 200); From 25d2a02dcc6396ba4273203b35d08d1f0f3802c4 Mon Sep 17 00:00:00 2001 From: James Foster Date: Thu, 26 Dec 2024 11:46:26 -0800 Subject: [PATCH 05/10] Show test class in some tests. --- extras/device_client/lib/model/version.dart | 2 +- src/Version.h | 2 +- test/GetTimeTest.cpp | 2 +- test/KeypadTest.cpp | 2 +- test/LiquidCrystalTest.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extras/device_client/lib/model/version.dart b/extras/device_client/lib/model/version.dart index 6f85477e3..ba9a213d5 100644 --- a/extras/device_client/lib/model/version.dart +++ b/extras/device_client/lib/model/version.dart @@ -1 +1 @@ -const String gitVersion = 'v24.10.2-6-g3e7+'; +const String gitVersion = 'v24.10.2-7-ga63+'; diff --git a/src/Version.h b/src/Version.h index 3e74e30d9..21f9cf2b4 100644 --- a/src/Version.h +++ b/src/Version.h @@ -1 +1 @@ -#define VERSION "v24.10.2-6-g3e7+" +#define VERSION "v24.10.2-7-ga63+" diff --git a/test/GetTimeTest.cpp b/test/GetTimeTest.cpp index 0de5cb856..9eeb74a5c 100644 --- a/test/GetTimeTest.cpp +++ b/test/GetTimeTest.cpp @@ -35,7 +35,7 @@ unittest_teardown() { EthernetClient::stopMockServer(pGetTime->getServerDomain(), (uint32_t)0, 80); } -unittest(without_DHCP) { +unittest(GetTimeTest_without_DHCP) { Ethernet.mockDHCP(IPAddress((uint32_t)0)); assertFalse(Ethernet_TC::instance(true)->isConnectedToNetwork()); EthernetClient::startMockServer(pGetTime->getServerDomain(), (uint32_t)0, 80); diff --git a/test/KeypadTest.cpp b/test/KeypadTest.cpp index 951ab5b6b..a5fdb0cf6 100644 --- a/test/KeypadTest.cpp +++ b/test/KeypadTest.cpp @@ -3,7 +3,7 @@ #include "Keypad_TC.h" -unittest(constructor) { +unittest(KeypadTest_constructor) { // Test singleton Keypad_TC* singleton1 = nullptr; singleton1 = Keypad_TC::instance(); diff --git a/test/LiquidCrystalTest.cpp b/test/LiquidCrystalTest.cpp index 2d87c7a39..529e99d7b 100644 --- a/test/LiquidCrystalTest.cpp +++ b/test/LiquidCrystalTest.cpp @@ -7,7 +7,7 @@ #include "TankController.h" #include "Version.h" -unittest(loop) { +unittest(LiquidCrystalTest_loop) { TankController* tank = TankController::instance(); LiquidCrystal_TC* lcd = LiquidCrystal_TC::instance(); assertTrue(tank != nullptr); From 9636fd35c54fde591431701aa81cbf8f1162d905 Mon Sep 17 00:00:00 2001 From: James Foster Date: Fri, 27 Dec 2024 08:20:31 -0800 Subject: [PATCH 06/10] Fix Codacy issue (bug). --- extras/device_client/lib/model/version.dart | 2 +- src/TankController.cpp | 2 +- src/Version.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extras/device_client/lib/model/version.dart b/extras/device_client/lib/model/version.dart index ba9a213d5..d7f49a436 100644 --- a/extras/device_client/lib/model/version.dart +++ b/extras/device_client/lib/model/version.dart @@ -1 +1 @@ -const String gitVersion = 'v24.10.2-7-ga63+'; +const String gitVersion = 'v24.10.2-8-g25d+'; diff --git a/src/TankController.cpp b/src/TankController.cpp index c3202b3e1..6fb49c5d7 100644 --- a/src/TankController.cpp +++ b/src/TankController.cpp @@ -181,7 +181,7 @@ void TankController::loop(bool report_loop_delay) { if (report_loop_delay) { static long int count = 0; unsigned long loopTime = millis() - start; - if (+count % 10000 == 1 || loopTime > 200) { // first time through and periodically thereafter + if (++count % 10000 == 1 || loopTime > 200) { // first time through and periodically thereafter serial(F("TankController::loop() - took %lu ms (at %lu sec uptime)"), loopTime, start / 1000); } lastTime = millis(); diff --git a/src/Version.h b/src/Version.h index 21f9cf2b4..c9a425d48 100644 --- a/src/Version.h +++ b/src/Version.h @@ -1 +1 @@ -#define VERSION "v24.10.2-7-ga63+" +#define VERSION "v24.10.2-8-g25d+" From 60660977b6915d548823e25ad1a705cf3ed47121 Mon Sep 17 00:00:00 2001 From: James Foster Date: Fri, 27 Dec 2024 09:20:02 -0800 Subject: [PATCH 07/10] Switch default to hide loop delay for easier testing. --- examples/TankController/TankController.ino | 2 +- extras/device_client/lib/model/version.dart | 2 +- extras/mockUI/libTC.cpp | 2 +- src/TankController.h | 2 +- src/Version.h | 2 +- test/DataLoggerTest.cpp | 18 ++-- test/EnablePIDTest.cpp | 12 +-- test/EthernetServerTest.cpp | 10 +-- test/GetTimeTest.cpp | 10 +-- test/JSONBuilderTest.cpp | 2 +- test/MenuTest.cpp | 14 +-- test/PHCalibrationHighTest.cpp | 6 +- test/PHCalibrationLowTest.cpp | 12 +-- test/PHCalibrationMidTest.cpp | 30 +++---- test/PHCalibrationPromptTest.cpp | 24 ++--- test/PHCalibrationWarningTest.cpp | 32 +++---- test/PHControlTest.cpp | 82 ++++++++--------- test/PushingBoxTest.cpp | 16 ++-- test/ResetPHCalibrationTest.cpp | 2 +- test/ResetThermalCalibrationTest.cpp | 6 +- test/SDTest.cpp | 16 ++-- test/SeeDeviceAddressTest.cpp | 8 +- test/SeeDeviceUptimeTest.cpp | 14 +-- test/SeeFreeMemoryTest.cpp | 2 +- test/SeeGoogleMinsTest.cpp | 2 +- test/SeeLogFileTest.cpp | 4 +- test/SeePHCalibrationTest.cpp | 10 +-- test/SeePIDConstantsTest.cpp | 12 +-- test/SeePhTest.cpp | 14 +-- test/SeeTankIDTest.cpp | 2 +- test/SeeThermalCorrectionTest.cpp | 2 +- test/SeeVersionTest.cpp | 4 +- test/SerialTest.cpp | 6 +- test/SetChillOrHeatTest.cpp | 18 ++-- test/SetGoogleSheetIntervalTest.cpp | 6 +- test/SetKDTest.cpp | 6 +- test/SetKITest.cpp | 6 +- test/SetKPTest.cpp | 6 +- test/SetPHSineWaveTest.cpp | 6 +- test/SetPHTargetTest.cpp | 12 +-- test/SetTankIDTest.cpp | 6 +- test/SetThermalSineWaveTest.cpp | 6 +- test/SetThermalTargetTest.cpp | 6 +- test/SetTimeTest.cpp | 6 +- test/TCLibTest.cpp | 12 +-- test/ThermalCalibrationTest.cpp | 4 +- test/ThermalControlTest.cpp | 98 ++++++++++----------- 47 files changed, 292 insertions(+), 288 deletions(-) diff --git a/examples/TankController/TankController.ino b/examples/TankController/TankController.ino index 5e5c06b33..10558338b 100644 --- a/examples/TankController/TankController.ino +++ b/examples/TankController/TankController.ino @@ -34,5 +34,5 @@ void setup() { } void loop() { - tank->loop(); + tank->loop(true); } diff --git a/extras/device_client/lib/model/version.dart b/extras/device_client/lib/model/version.dart index d7f49a436..63c130c15 100644 --- a/extras/device_client/lib/model/version.dart +++ b/extras/device_client/lib/model/version.dart @@ -1 +1 @@ -const String gitVersion = 'v24.10.2-8-g25d+'; +const String gitVersion = 'v24.10.2-9-g963+'; diff --git a/extras/mockUI/libTC.cpp b/extras/mockUI/libTC.cpp index bd5979366..c1d250d8c 100644 --- a/extras/mockUI/libTC.cpp +++ b/extras/mockUI/libTC.cpp @@ -125,7 +125,7 @@ void loop() { if (msBehind) { delay(msBehind); } - TankController::instance()->loop(); + TankController::instance()->loop(true); } uint32_t millisecondsSinceEpoch() { diff --git a/src/TankController.h b/src/TankController.h index a2ebfab8a..2f0bc14e8 100644 --- a/src/TankController.h +++ b/src/TankController.h @@ -20,7 +20,7 @@ class TankController { // instance methods bool isInCalibration(); int freeMemory(); - void loop(bool report_loop_delay = true); + void loop(bool report_loop_delay = false); void serialEvent(); void serialEvent1(); void setNextState(UIState* newState, bool update = false); diff --git a/src/Version.h b/src/Version.h index c9a425d48..7a5d7a75c 100644 --- a/src/Version.h +++ b/src/Version.h @@ -1 +1 @@ -#define VERSION "v24.10.2-8-g25d+" +#define VERSION "v24.10.2-9-g963+" diff --git a/test/DataLoggerTest.cpp b/test/DataLoggerTest.cpp index 9ed568fea..fb082114b 100644 --- a/test/DataLoggerTest.cpp +++ b/test/DataLoggerTest.cpp @@ -38,7 +38,7 @@ unittest(loop) { assertEqual("", sd->mostRecentRemoteLogEntry); // initial loop - tc->loop(false); + tc->loop(); assertEqual("", sd->mostRecentDataLogHeader); assertEqual("", sd->mostRecentDataLogLine); assertEqual("heater turned on at 6 after 6 ms", serialPort->getBuffer()); @@ -47,10 +47,10 @@ unittest(loop) { // data log after one second delay(1000); - tc->loop(false); // write to data log - tc->loop(false); // should not write to serial log - tc->loop(false); // should not write data to remote log - tc->loop(false); // should not write warning to remote log + tc->loop(); // write to data log + tc->loop(); // should not write to serial log + tc->loop(); // should not write data to remote log + tc->loop(); // should not write warning to remote log assertEqual("time,tankid,temp,temp setpoint,pH,pH setpoint,upTime,Kp,Ki,Kd", sd->mostRecentDataLogHeader); assertEqual("08/15/2023 00:00:01, 0, 0.00, 20.00, 0.000, 8.100, 1, 100000.0, 0.0, 0.0", sd->mostRecentDataLogLine); @@ -59,13 +59,13 @@ unittest(loop) { // serial log after one minute delay(59000); - tc->loop(false); // write to data log - tc->loop(false); // write to serial log + tc->loop(); // write to data log + tc->loop(); // write to serial log assertEqual("00:01 pH=0.000 temp= 0.00", serialPort->getBuffer()); // remote log entry after one minute assertFalse(0.0 == thermalProbe->getSampleMean()); - tc->loop(false); // write info to remote log + tc->loop(); // write info to remote log assertTrue(isnan(thermalProbe->getSampleMean())); // thermal sample has been collected assertTrue(isnan(thermalProbe->getSampleStandardDeviation())); // thermal sample has been reset char infoString[512] = ""; @@ -89,7 +89,7 @@ unittest(writeWarningToLog) { dl->writeWarningSoon(); assertTrue(dl->getShouldWriteWarning()); delay(19000); - tc->loop(false); // write the warning + tc->loop(); // write the warning char warningString[512] = ""; snprintf(warningString, sizeof(warningString), "%s\t%s", VERSION, "0\tW\t2023-08-15 " diff --git a/test/EnablePIDTest.cpp b/test/EnablePIDTest.cpp index c1de7dfd6..ffb6fc060 100644 --- a/test/EnablePIDTest.cpp +++ b/test/EnablePIDTest.cpp @@ -26,11 +26,11 @@ unittest(DisablePID) { test->setValue(9.0); assertFalse(PHControl::instance()->getUsePID()); assertEqual("EnablePID", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // after the delay, Wait will call setNextState - tc->loop(false); // now transition back to main + tc->loop(); // after the delay, Wait will call setNextState + tc->loop(); // now transition back to main assertEqual("MainMenu", tc->stateName()); } @@ -42,11 +42,11 @@ unittest(EnablePID) { test->setValue(1.0); assertTrue(PHControl::instance()->getUsePID()); assertEqual("EnablePID", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // after the delay, Wait will call setNextState - tc->loop(false); // now transition back to main + tc->loop(); // after the delay, Wait will call setNextState + tc->loop(); // now transition back to main assertEqual("MainMenu", tc->stateName()); } diff --git a/test/EthernetServerTest.cpp b/test/EthernetServerTest.cpp index d3fcfe1b9..df7a6a9dd 100644 --- a/test/EthernetServerTest.cpp +++ b/test/EthernetServerTest.cpp @@ -80,7 +80,7 @@ unittest(display) { server->loop(); EthernetClient_CI client = server->getClient(); TankController* tc = TankController::instance(); - tc->loop(false); // for main menu to idle + tc->loop(); // for main menu to idle const char request[] = "GET /api/1/display HTTP/1.1\r\n" "Host: localhost:80\r\n" @@ -89,7 +89,7 @@ unittest(display) { "Accept-Language: en-US\r\n" "\r\n"; client.pushToReadBuffer(request); - tc->loop(false); // for targets to take effect + tc->loop(); // for targets to take effect deque* pBuffer = client.writeBuffer(); assertTrue(pBuffer->size() > 100); String response; @@ -147,10 +147,10 @@ unittest(keypress) { "\r\n"; assertEqual(expectedResponse, response); assertEqual(FINISHED, server->getState()); - tc->loop(false); // Loop to handle the UI press + tc->loop(); // Loop to handle the UI press assertEqual("Change settings ", lcd->getLines().at(0)); delay(60000); // IDLE_TIMEOUT - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); assertEqual(NOT_CONNECTED, server->getState()); client.stop(); @@ -171,7 +171,7 @@ unittest(currentData) { ThermalControl::instance()->setThermalTarget(21.75); // target EEPROM_TC::instance()->setHeat(0); PID_TC::instance()->setTunings(5000.5, 1234.46, 987.44); - TankController::instance()->loop(false); // for targets to take effect + TankController::instance()->loop(); // for targets to take effect EthernetServer_TC* server = EthernetServer_TC::instance(); server->setHasClientCalling(true); diff --git a/test/GetTimeTest.cpp b/test/GetTimeTest.cpp index 9eeb74a5c..d6fa11fd9 100644 --- a/test/GetTimeTest.cpp +++ b/test/GetTimeTest.cpp @@ -41,7 +41,7 @@ unittest(GetTimeTest_without_DHCP) { EthernetClient::startMockServer(pGetTime->getServerDomain(), (uint32_t)0, 80); assertFalse(pClient->connected()); delay(45 * 1000); // wait for 45 seconds to ensure we do not send - tc->loop(false); + tc->loop(); assertFalse(pClient->connected()); } @@ -55,10 +55,10 @@ unittest(with_DHCP) { "\r\n"); assertFalse(pClient->connected()); // not yet connected! delay(15 * 1000); // Allow bubbler to be turned off - tc->loop(false); + tc->loop(); delay(30 * 1000); // Wait for time query assertEqual("2021-06-08 15:26", DateTime_TC::now().as16CharacterString()); - tc->loop(false); + tc->loop(); assertEqual("2023-07-18 21:18", DateTime_TC::now().as16CharacterString()); assertTrue(pClient->connected()); pClient->stop(); // clears the readBuffer (but not the write buffer!?) @@ -72,10 +72,10 @@ unittest(with_DHCP) { "\r\n"); assertFalse(pClient->connected()); // not yet connected! delay(23 * 60 * 60 * 1000); // should not be any change - tc->loop(false); + tc->loop(); assertEqual("2023-07-19 20:18", DateTime_TC::now().as16CharacterString()); delay(1 * 60 * 60 * 1000); // now should change - tc->loop(false); + tc->loop(); assertEqual("2023-07-20 07:18", DateTime_TC::now().as16CharacterString()); assertTrue(pClient->connected()); pClient->stop(); // clears the readBuffer (but not the write buffer!?) diff --git a/test/JSONBuilderTest.cpp b/test/JSONBuilderTest.cpp index 54beee453..50024cd2e 100644 --- a/test/JSONBuilderTest.cpp +++ b/test/JSONBuilderTest.cpp @@ -30,7 +30,7 @@ unittest(JSONBuilderTest_currentData) { ThermalControl::instance()->setThermalTarget(98.88); // target EEPROM_TC::instance()->setHeat(0); PID_TC::instance()->setTunings(100001.1, 100002.2, 100003.3); - TankController::instance()->loop(false); // recognize and apply the targets + TankController::instance()->loop(); // recognize and apply the targets JSONBuilder builder; int size = builder.buildCurrentValues(); assertTrue(size > 200); diff --git a/test/MenuTest.cpp b/test/MenuTest.cpp index 531b2e8c9..1cb461727 100644 --- a/test/MenuTest.cpp +++ b/test/MenuTest.cpp @@ -20,7 +20,7 @@ Keypad* keypad = Keypad_TC::instance()->_getPuppet(); // reduce duplicate code and make it more explicit void enterKey(char key) { keypad->push_back(key); - tc->loop(false); // recognize and apply the key entry + tc->loop(); // recognize and apply the key entry } unittest_setup() { @@ -30,7 +30,7 @@ unittest_setup() { ThermalControl::enableHeater(true); ThermalControl::instance()->setThermalTarget(15.75); ThermalProbe_TC::instance()->setTemperature(12.25, true); - tc->loop(false); // recognize and apply the targets + tc->loop(); // recognize and apply the targets enterKey('D'); } @@ -49,11 +49,11 @@ unittest(MainMenu) { assertEqual("pH=0.000 8.100", lc->getLines().at(0)); assertEqual("T=12.23 H 15.75 ", lc->getLines().at(1)); delay(1000); - tc->loop(false); + tc->loop(); assertEqual("pH 0.000 8.100", lc->getLines().at(0)); assertEqual("T 12.23 H 15.75 ", lc->getLines().at(1)); delay(1000); - tc->loop(false); + tc->loop(); assertEqual("pH=0.000 8.100", lc->getLines().at(0)); assertEqual("T=12.23 H 15.75 ", lc->getLines().at(1)); } @@ -113,10 +113,10 @@ unittest(ViewTime) { enterKey('6'); assertEqual(DateTime_TC::now().as16CharacterString(), lc->getLines().at(0).c_str()); delay(6000); - tc->loop(false); + tc->loop(); assertEqual("SeeDeviceUptime", tc->stateName()); delay(55000); // idle timeout should return to main menu - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); } @@ -129,7 +129,7 @@ unittest(DisableTimeout) { enterKey('6'); assertEqual("PHCalibrationPrompt", tc->stateName()); delay(65000); // wait for over 60 seconds to verify that it does not return to main menu - tc->loop(false); + tc->loop(); assertEqual("PHCalibrationPrompt", tc->stateName()); } diff --git a/test/PHCalibrationHighTest.cpp b/test/PHCalibrationHighTest.cpp index a60267d3f..5aa4dd2bb 100644 --- a/test/PHCalibrationHighTest.cpp +++ b/test/PHCalibrationHighTest.cpp @@ -17,13 +17,13 @@ unittest(test) { std::vector lines = LiquidCrystal_TC::instance()->getLines(); assertEqual("High = 12.345 ", lines[1]); assertEqual("PHCalibrationHigh", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(2000); assertTrue(tc->isInCalibration()); delay(1000); - tc->loop(false); // after the delay, Wait will call setNextState to prepare to go to PHCalibrationLow - tc->loop(false); // updateState to PHCalibrationLow + tc->loop(); // after the delay, Wait will call setNextState to prepare to go to PHCalibrationLow + tc->loop(); // updateState to PHCalibrationLow assertEqual("PHCalibrationLow", tc->stateName()); assertTrue(tc->isInCalibration()); } diff --git a/test/PHCalibrationLowTest.cpp b/test/PHCalibrationLowTest.cpp index cde5251f3..6cb840c2d 100644 --- a/test/PHCalibrationLowTest.cpp +++ b/test/PHCalibrationLowTest.cpp @@ -16,13 +16,13 @@ unittest(twoPointLow) { std::vector lines = LiquidCrystal_TC::instance()->getLines(); assertEqual("Lower = 12.345 ", lines[1]); assertEqual("PHCalibrationLower", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(2000); assertTrue(tc->isInCalibration()); delay(1000); - tc->loop(false); // after the delay, Wait will call setNextState to prepare to go to SeePHCalibration - tc->loop(false); // updateState to SeePHCalibration + tc->loop(); // after the delay, Wait will call setNextState to prepare to go to SeePHCalibration + tc->loop(); // updateState to SeePHCalibration assertEqual("SeePHCalibration", tc->stateName()); assertTrue(tc->isInCalibration()); } @@ -38,13 +38,13 @@ unittest(threePointLow) { std::vector lines = LiquidCrystal_TC::instance()->getLines(); assertEqual("Low = 12.345 ", lines[1]); assertEqual("PHCalibrationLow", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(2000); assertTrue(tc->isInCalibration()); delay(1000); - tc->loop(false); // after the delay, Wait will call setNextState to prepare to go to SeePHCalibration - tc->loop(false); // updateState to SeePHCalibration + tc->loop(); // after the delay, Wait will call setNextState to prepare to go to SeePHCalibration + tc->loop(); // updateState to SeePHCalibration assertEqual("SeePHCalibration", tc->stateName()); assertTrue(tc->isInCalibration()); } diff --git a/test/PHCalibrationMidTest.cpp b/test/PHCalibrationMidTest.cpp index 9342708e0..f73ac739e 100644 --- a/test/PHCalibrationMidTest.cpp +++ b/test/PHCalibrationMidTest.cpp @@ -23,7 +23,7 @@ unittest(onePointMid) { pHProbe->setPh(7.325); lines = LiquidCrystal_TC::instance()->getLines(); assertEqual(" 0 ", lines.at(1)); - tc->loop(false); + tc->loop(); lines = LiquidCrystal_TC::instance()->getLines(); assertEqual(" 0 ", lines.at(1)); // setValue @@ -32,13 +32,13 @@ unittest(onePointMid) { lines = LiquidCrystal_TC::instance()->getLines(); assertEqual("Buffer = 12.345 ", lines.at(1)); assertEqual("PHCalibrationOnly", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(2000); assertTrue(tc->isInCalibration()); delay(1000); - tc->loop(false); // after the delay, Wait will call setNextState to prepare to go to SeePHCalibration - tc->loop(false); // updateState to SeePHCalibration + tc->loop(); // after the delay, Wait will call setNextState to prepare to go to SeePHCalibration + tc->loop(); // updateState to SeePHCalibration assertEqual("SeePHCalibration", tc->stateName()); assertTrue(tc->isInCalibration()); } @@ -60,7 +60,7 @@ unittest(twoPointMid) { pHProbe->setPh(7.325); lines = LiquidCrystal_TC::instance()->getLines(); assertEqual(" 0 ", lines.at(1)); - tc->loop(false); + tc->loop(); lines = LiquidCrystal_TC::instance()->getLines(); assertEqual(" 0 ", lines.at(1)); // setValue @@ -69,13 +69,13 @@ unittest(twoPointMid) { lines = LiquidCrystal_TC::instance()->getLines(); assertEqual("Higher = 12.345 ", lines.at(1)); assertEqual("PHCalibrationHigher", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(2000); assertTrue(tc->isInCalibration()); delay(1000); - tc->loop(false); // after the delay, Wait will call setNextState to prepare to go to PHCalibrationLower - tc->loop(false); // updateState to PHCalibrationLower + tc->loop(); // after the delay, Wait will call setNextState to prepare to go to PHCalibrationLower + tc->loop(); // updateState to PHCalibrationLower assertEqual("PHCalibrationLower", tc->stateName()); assertTrue(tc->isInCalibration()); } @@ -97,7 +97,7 @@ unittest(threePointMid) { pHProbe->setPh(7.325); lines = LiquidCrystal_TC::instance()->getLines(); assertEqual(" 0 ", lines.at(1)); - tc->loop(false); + tc->loop(); lines = LiquidCrystal_TC::instance()->getLines(); assertEqual(" 0 ", lines.at(1)); // setValue @@ -106,13 +106,13 @@ unittest(threePointMid) { lines = LiquidCrystal_TC::instance()->getLines(); assertEqual("Mid = 12.345 ", lines.at(1)); assertEqual("PHCalibrationMid", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(2000); assertTrue(tc->isInCalibration()); delay(1000); - tc->loop(false); // after the delay, Wait will call setNextState to prepare to go to PHCalibrationHigh - tc->loop(false); // updateState to PHCalibrationHigh + tc->loop(); // after the delay, Wait will call setNextState to prepare to go to PHCalibrationHigh + tc->loop(); // updateState to PHCalibrationHigh assertEqual("PHCalibrationHigh", tc->stateName()); assertTrue(tc->isInCalibration()); } @@ -133,17 +133,17 @@ unittest(keyEntry) { assertEqual(" 0 ", lc->getLines().at(1)); pHProbe->setPh(7.325); assertEqual(" 0 ", lc->getLines().at(1)); - tc->loop(false); + tc->loop(); assertEqual(" 0 ", lc->getLines().at(1)); // See whether a typed '7' causes the display to update correctly test->handleKey('7'); - tc->loop(false); + tc->loop(); assertEqual(" 7 ", lc->getLines().at(1)); // See whether a typed 'D' causes the calibration status to be shown test->handleKey('D'); - tc->loop(false); + tc->loop(); assertEqual("SeePHCalibration", tc->stateName()); assertTrue(tc->isInCalibration()); } diff --git a/test/PHCalibrationPromptTest.cpp b/test/PHCalibrationPromptTest.cpp index b873dc494..9b241b938 100644 --- a/test/PHCalibrationPromptTest.cpp +++ b/test/PHCalibrationPromptTest.cpp @@ -17,13 +17,13 @@ unittest(onePoint) { assertEqual("1, 2 or 3 point?", lines[0]); assertEqual("1-pt pH calib...", lines[1]); assertEqual("PHCalibrationPrompt", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(1000); assertTrue(tc->isInCalibration()); delay(1000); - tc->loop(false); // after the delay, Wait will call setNextState to prepare to go to PHCalibrationOnly - tc->loop(false); // updateState to PHCalibrationOnly + tc->loop(); // after the delay, Wait will call setNextState to prepare to go to PHCalibrationOnly + tc->loop(); // updateState to PHCalibrationOnly assertEqual("PHCalibrationOnly", tc->stateName()); } @@ -39,13 +39,13 @@ unittest(twoPoint) { assertEqual("1, 2 or 3 point?", lines[0]); assertEqual("2-pt pH calib...", lines[1]); assertEqual("PHCalibrationPrompt", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(1000); assertTrue(tc->isInCalibration()); delay(1000); - tc->loop(false); // after the delay, Wait will call setNextState to prepare to go to PHCalibrationHigher - tc->loop(false); // updateState to PHCalibrationHigher + tc->loop(); // after the delay, Wait will call setNextState to prepare to go to PHCalibrationHigher + tc->loop(); // updateState to PHCalibrationHigher assertEqual("PHCalibrationHigher", tc->stateName()); } @@ -61,13 +61,13 @@ unittest(threePoint) { assertEqual("1, 2 or 3 point?", lines[0]); assertEqual("3-pt pH calib...", lines[1]); assertEqual("PHCalibrationPrompt", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(1000); assertTrue(tc->isInCalibration()); delay(1000); - tc->loop(false); // after the delay, Wait will call setNextState to prepare to go to PHCalibrationMid - tc->loop(false); // updateState to PHCalibrationMid + tc->loop(); // after the delay, Wait will call setNextState to prepare to go to PHCalibrationMid + tc->loop(); // updateState to PHCalibrationMid assertEqual("PHCalibrationMid", tc->stateName()); } @@ -83,11 +83,11 @@ unittest(badEntry) { assertEqual("1, 2 or 3 point?", lines[0]); assertEqual("Invalid entry ", lines[1]); assertEqual("PHCalibrationPrompt", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // after the delay, Wait will call setNextState to prepare to go to MainMenu - tc->loop(false); // updateState to MainMenu + tc->loop(); // after the delay, Wait will call setNextState to prepare to go to MainMenu + tc->loop(); // updateState to MainMenu assertEqual("MainMenu", tc->stateName()); } diff --git a/test/PHCalibrationWarningTest.cpp b/test/PHCalibrationWarningTest.cpp index ff2a4974b..dbda783c8 100644 --- a/test/PHCalibrationWarningTest.cpp +++ b/test/PHCalibrationWarningTest.cpp @@ -22,23 +22,23 @@ unittest(Display) { assertTrue(tc->isInCalibration()); // Test the display - tc->loop(false); + tc->loop(); assertEqual("BAD CALIBRATION?", display->getLines().at(0)); assertEqual("99.7,100.3,-0.89", display->getLines().at(1)); delay(700); - tc->loop(false); + tc->loop(); assertEqual(" ", display->getLines().at(0)); assertEqual("99.7,100.3,-0.89", display->getLines().at(1)); delay(300); - tc->loop(false); + tc->loop(); assertEqual("BAD CALIBRATION?", display->getLines().at(0)); assertEqual("99.7,100.3,-0.89", display->getLines().at(1)); delay(4000); - tc->loop(false); + tc->loop(); assertEqual("A: Accept/ignore", display->getLines().at(0)); assertEqual("C: Clear calibra", display->getLines().at(1)); delay(3000); - tc->loop(false); + tc->loop(); assertEqual("BAD CALIBRATION?", display->getLines().at(0)); assertEqual("99.7,100.3,-0.89", display->getLines().at(1)); } @@ -58,13 +58,13 @@ unittest(Accept) { // Type 'D' Keypad_TC::instance()->_getPuppet()->push_back('D'); - tc->loop(false); + tc->loop(); assertEqual("PHCalibrationWarning", tc->stateName()); // Type 'A' Keypad_TC::instance()->_getPuppet()->push_back('A'); - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); assertEqual("MainMenu", tc->stateName()); assertEqual("", GODMODE()->serialPort[1].dataOut); assertTrue(EEPROM_TC::instance()->getIgnoreBadPHSlope()); @@ -84,13 +84,13 @@ unittest(Clear) { // Type 'B' Keypad_TC::instance()->_getPuppet()->push_back('B'); - tc->loop(false); + tc->loop(); assertEqual("PHCalibrationWarning", tc->stateName()); // Type 'C' assertEqual("", GODMODE()->serialPort[1].dataOut); Keypad_TC::instance()->_getPuppet()->push_back('C'); - tc->loop(false); + tc->loop(); assertEqual("SeePHCalibration", tc->stateName()); assertEqual("Cal,clear\rCAL,?\rSLOPE,?\r", GODMODE()->serialPort[1].dataOut); assertFalse(EEPROM_TC::instance()->getIgnoreBadPHSlope()); @@ -106,15 +106,15 @@ unittest(CatchBadCalibration) { assertFalse(pHProbe->shouldWarnAboutCalibration()); tc->setNextState(new MainMenu()); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); assertFalse(tc->isInCalibration()); pHProbe->setPhSlope("?SLOPE,99.7,0"); // 0% base slope is outside range assertTrue(pHProbe->slopeIsBad()); assertTrue(pHProbe->shouldWarnAboutCalibration()); assertEqual("MainMenu", tc->stateName()); - tc->loop(false); // catch flag and queue next state - tc->loop(false); // make new state active + tc->loop(); // catch flag and queue next state + tc->loop(); // make new state active assertEqual("PHCalibrationWarning", tc->stateName()); } @@ -131,15 +131,15 @@ unittest(IgnoreBadCalibration) { assertTrue(eeprom->getIgnoreBadPHSlope()); tc->setNextState(new MainMenu()); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); assertFalse(tc->isInCalibration()); pHProbe->setPhSlope("?SLOPE,99.7,0"); // 0% base slope is outside range assertTrue(pHProbe->slopeIsBad()); assertFalse(pHProbe->shouldWarnAboutCalibration()); assertEqual("MainMenu", tc->stateName()); - tc->loop(false); // ignore bad calibration flag - tc->loop(false); // continue to ignore flag + tc->loop(); // ignore bad calibration flag + tc->loop(); // continue to ignore flag assertEqual("MainMenu", tc->stateName()); } diff --git a/test/PHControlTest.cpp b/test/PHControlTest.cpp index 26713db25..9eac1a240 100644 --- a/test/PHControlTest.cpp +++ b/test/PHControlTest.cpp @@ -33,7 +33,7 @@ void reset() { controlSolenoid->setBaseTargetPh(7.50); controlSolenoid->setRampDurationHours(0); // No ramp state->serialPort[0].dataOut = ""; // the history of data written - tc->loop(false); + tc->loop(); } unittest_setup() { @@ -50,7 +50,7 @@ unittest(bubblerTurnsOnAndOff) { assertEqual(TURN_SOLENOID_OFF, state->digitalPin[PH_CONTROL_PIN]); assertFalse(controlSolenoid->isOn()); pHProbe->setPh(8.0); - tc->loop(false); // update the controls based on the current readings + tc->loop(); // update the controls based on the current readings assertEqual(13, millis()); assertEqual(TURN_SOLENOID_ON, state->digitalPin[PH_CONTROL_PIN]); assertTrue(controlSolenoid->isOn()); @@ -71,7 +71,7 @@ unittest(bubblerTurnsOnAndOff) { assertEqual("CO2 bubbler turned on after 10 ms", line); assertEqual(13, millis()); delay(9500); - tc->loop(false); // solenoid should turn off briefly at end of window + tc->loop(); // solenoid should turn off briefly at end of window assertEqual(TURN_SOLENOID_OFF, state->digitalPin[PH_CONTROL_PIN]); assertFalse(controlSolenoid->isOn()); } @@ -81,17 +81,17 @@ unittest(afterTenSecondsButPhStillHigher) { assertFalse(controlSolenoid->isOn()); controlSolenoid->setBaseTargetPh(7.50); pHProbe->setPh(8.5); - tc->loop(false); // update the controls based on the current readings + tc->loop(); // update the controls based on the current readings assertEqual(TURN_SOLENOID_ON, state->digitalPin[PH_CONTROL_PIN]); assertTrue(controlSolenoid->isOn()); delay(8000); pHProbe->setPh(8.5); - tc->loop(false); // update the controls based on the current readings + tc->loop(); // update the controls based on the current readings assertEqual(TURN_SOLENOID_ON, state->digitalPin[PH_CONTROL_PIN]); assertTrue(controlSolenoid->isOn()); delay(2000); pHProbe->setPh(7.75); - tc->loop(false); // update the controls based on the current readings + tc->loop(); // update the controls based on the current readings assertEqual(TURN_SOLENOID_ON, state->digitalPin[PH_CONTROL_PIN]); assertTrue(controlSolenoid->isOn()); } @@ -102,25 +102,25 @@ unittest(afterTenSecondsAndPhIsLower) { assertEqual("pH 7.500 7.500", lc->getLines().at(0)); controlSolenoid->setBaseTargetPh(7.50); pHProbe->setPh(8.5); - tc->loop(false); // update the controls based on the current readings + tc->loop(); // update the controls based on the current readings assertEqual(TURN_SOLENOID_ON, state->digitalPin[PH_CONTROL_PIN]); assertTrue(controlSolenoid->isOn()); assertEqual("CO2 bubbler turned on after 6 ms\r\n", state->serialPort[0].dataOut); - tc->loop(false); + tc->loop(); assertEqual("pH 8.500 B 7.500", lc->getLines().at(0)); delay(8000); - tc->loop(false); + tc->loop(); assertEqual(TURN_SOLENOID_ON, state->digitalPin[PH_CONTROL_PIN]); assertTrue(controlSolenoid->isOn()); state->serialPort[0].dataOut = ""; // the history of data written delay(1000); - tc->loop(false); + tc->loop(); assertEqual("CO2 bubbler turned off after 9004 ms\r\n", state->serialPort[0].dataOut); // after 10 seconds assertEqual(TURN_SOLENOID_OFF, state->digitalPin[PH_CONTROL_PIN]); assertFalse(controlSolenoid->isOn()); delay(1000); pHProbe->setPh(7.25); - tc->loop(false); // update the controls based on the current readings + tc->loop(); // update the controls based on the current readings assertEqual(TURN_SOLENOID_OFF, state->digitalPin[PH_CONTROL_PIN]); assertFalse(controlSolenoid->isOn()); } @@ -136,12 +136,12 @@ unittest(beforeTenSecondsButPhIsLower) { delay(1000); controlSolenoid->setBaseTargetPh(7.50); pHProbe->setPh(8.5); - tc->loop(false); // update the controls based on the current readings + tc->loop(); // update the controls based on the current readings assertEqual(TURN_SOLENOID_ON, state->digitalPin[PH_CONTROL_PIN]); assertTrue(controlSolenoid->isOn()); delay(7500); pHProbe->setPh(7.25); - tc->loop(false); // update the controls based on the current readings + tc->loop(); // update the controls based on the current readings assertEqual(TURN_SOLENOID_OFF, state->digitalPin[PH_CONTROL_PIN]); assertFalse(controlSolenoid->isOn()); } @@ -151,7 +151,7 @@ unittest(PhEvenWithTarget) { assertFalse(controlSolenoid->isOn()); controlSolenoid->setBaseTargetPh(7.50); pHProbe->setPh(7.5); - tc->loop(false); // update the controls based on the current readings + tc->loop(); // update the controls based on the current readings assertEqual(TURN_SOLENOID_OFF, state->digitalPin[PH_CONTROL_PIN]); assertFalse(controlSolenoid->isOn()); } @@ -170,20 +170,20 @@ unittest(disableDuringCalibration) { assertFalse(controlSolenoid->isOn()); controlSolenoid->setBaseTargetPh(7.50); pHProbe->setPh(8.5); - tc->loop(false); // update the controls based on the current readings + tc->loop(); // update the controls based on the current readings assertEqual(TURN_SOLENOID_OFF, state->digitalPin[PH_CONTROL_PIN]); assertFalse(controlSolenoid->isOn()); - tc->loop(false); + tc->loop(); // device remains off between calibration states test->setValue(7.00); - tc->loop(false); + tc->loop(); assertEqual("Wait", tc->stateName()); delay(2000); - tc->loop(false); + tc->loop(); assertEqual(TURN_SOLENOID_OFF, state->digitalPin[PH_CONTROL_PIN]); assertFalse(controlSolenoid->isOn()); - tc->loop(false); + tc->loop(); } unittest(RampGreaterThanZero) { @@ -194,7 +194,7 @@ unittest(RampGreaterThanZero) { controlSolenoid->setBaseTargetPh(7.00); controlSolenoid->setRampDurationHours(1.5); // 90 minutes assertEqual(PHControl::RAMP_TYPE, controlSolenoid->getPHFunctionType()); - tc->loop(false); + tc->loop(); assertEqual(8.5, controlSolenoid->getCurrentTargetPh()); assertEqual("pH=8.500 8.500", lc->getLines().at(0)); // mock arduino restarting @@ -202,8 +202,8 @@ unittest(RampGreaterThanZero) { controlSolenoid = PHControl::instance(); // takes 1.5 hours to get to pH of 7 delay(1800000); // delay 30 minutes - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); assertTrue(8.0 <= controlSolenoid->getCurrentTargetPh() && controlSolenoid->getCurrentTargetPh() <= 8.01); assertEqual("pH=8.500 B 8.000", lc->getLines().at(0)); assertEqual("01/15/2021 02:18:35, 0, 0.00, 20.00, 8.500, 8.000, 1811, 100000.0, 0.0, 0.0", @@ -211,15 +211,15 @@ unittest(RampGreaterThanZero) { delay(1800000); // delay 30 minutes // First loop triggers SD logging (DataLogger) and PushingBox // Second loop triggers Serial logging (DataLogger) - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); assertTrue(7.5 <= controlSolenoid->getCurrentTargetPh() && controlSolenoid->getCurrentTargetPh() <= 7.51); assertEqual("pH=8.500 B 7.500", lc->getLines().at(0)); assertEqual("01/15/2021 02:48:35, 0, 0.00, 20.00, 8.500, 7.500, 3611, 100000.0, 0.0, 0.0", dataLog->getBuffer()); delay(1800000); // delay 30 minutes - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); assertEqual(7, controlSolenoid->getCurrentTargetPh()); assertEqual("pH=8.500 B 7.000", lc->getLines().at(0)); assertEqual("01/15/2021 03:18:35, 0, 0.00, 20.00, 8.500, 7.000, 5411, 100000.0, 0.0, 0.0", @@ -227,8 +227,8 @@ unittest(RampGreaterThanZero) { // ramp time no longer used after it ends delay(1800000); // delay 30 minutes delay(1800000); // delay 30 minutes - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); assertEqual(7, controlSolenoid->getCurrentTargetPh()); assertEqual("pH=8.500 B 7.000", lc->getLines().at(0)); assertEqual("01/15/2021 04:18:35, 0, 0.00, 20.00, 8.500, 7.000, 9011, 100000.0, 0.0, 0.0", @@ -239,15 +239,15 @@ unittest(ChangeRampToZero) { assertEqual(TURN_SOLENOID_OFF, state->digitalPin[PH_CONTROL_PIN]); assertFalse(controlSolenoid->isOn()); pHProbe->setPh(8.5); - tc->loop(false); // update the controls based on the current readings + tc->loop(); // update the controls based on the current readings controlSolenoid->setBaseTargetPh(7.00); controlSolenoid->setRampDurationHours(1.5); assertEqual(PHControl::RAMP_TYPE, controlSolenoid->getPHFunctionType()); - tc->loop(false); + tc->loop(); assertEqual(8.5, controlSolenoid->getCurrentTargetPh()); controlSolenoid->setRampDurationHours(0); assertEqual(PHControl::FLAT_TYPE, controlSolenoid->getPHFunctionType()); - tc->loop(false); + tc->loop(); assertEqual(7, controlSolenoid->getCurrentTargetPh()); } @@ -255,39 +255,39 @@ unittest(sineTest) { assertEqual(TURN_SOLENOID_OFF, state->digitalPin[PH_CONTROL_PIN]); assertFalse(controlSolenoid->isOn()); pHProbe->setPh(7.0); - tc->loop(false); // update the controls based on the current readings + tc->loop(); // update the controls based on the current readings controlSolenoid->setBaseTargetPh(7.00); controlSolenoid->setSineAmplitudeAndHours(1.5, 2); assertEqual(PHControl::SINE_TYPE, controlSolenoid->getPHFunctionType()); - tc->loop(false); + tc->loop(); assertEqual(7, controlSolenoid->getCurrentTargetPh()); // mock arduino restarting PHControl::clearInstance(); controlSolenoid = PHControl::instance(); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(8.5, controlSolenoid->getCurrentTargetPh()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(7, controlSolenoid->getCurrentTargetPh()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(5.5, controlSolenoid->getCurrentTargetPh()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(7, controlSolenoid->getCurrentTargetPh()); // make sure sine wave continues delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(8.5, controlSolenoid->getCurrentTargetPh()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(7, controlSolenoid->getCurrentTargetPh()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(5.5, controlSolenoid->getCurrentTargetPh()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(7, controlSolenoid->getCurrentTargetPh()); } diff --git a/test/PushingBoxTest.cpp b/test/PushingBoxTest.cpp index 35202b2b3..ec24e51d6 100644 --- a/test/PushingBoxTest.cpp +++ b/test/PushingBoxTest.cpp @@ -51,11 +51,11 @@ unittest(NoTankID) { EEPROM_TC::instance()->setTankID(0); delay(30 * 1000); // allow 30 seconds for time update - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); state->serialPort[0].dataOut = ""; delay(40 * 1000); // allow 70 seconds (30 + 40) for PushingBox update - tc->loop(false); // Trigger SD logging and Serial (DataLogger) and PushingBox + tc->loop(); // Trigger SD logging and Serial (DataLogger) and PushingBox char expected[] = "Set Tank ID in order to send data to PushingBox"; assertEqual(expected, Serial_TC::instance()->getBuffer()); } @@ -69,10 +69,10 @@ unittest(SendData) { (const uint8_t *)"[PushingBox response]\r\n"); assertFalse(pClient->connected()); // not yet connected! delay(60 * 1000); // allow for time update - tc->loop(false); + tc->loop(); state->serialPort[0].dataOut = ""; delay(10 * 1000); // allow for PushingBox update - tc->loop(false); + tc->loop(); char expected[] = "New info written to remote log\r\n" "GET /pushingbox?devid=PushingBoxIdentifier&tankid=99&tempData=20.25&pHdata=7.125 HTTP/1.1\r\n" @@ -92,7 +92,7 @@ unittest(inCalibration) { EthernetClient::startMockServer(pPushingBox->getServerDomain(), (uint32_t)0, 80); assertFalse(pClient->connected()); delay(60 * 20 * 1000); // wait for 20 minutes to ensure we send again - tc->loop(false); + tc->loop(); assertTrue(pClient->connected()); assertNotNull(pClient->writeBuffer()); deque buffer = *(pClient->writeBuffer()); @@ -114,7 +114,7 @@ unittest(without_DHCP) { EthernetClient::startMockServer(pPushingBox->getServerDomain(), (uint32_t)0, 80); assertFalse(pClient->connected()); delay(60 * 20 * 1000); // wait for 20 minutes to ensure we still do not send - tc->loop(false); + tc->loop(); assertFalse(pClient->connected()); } @@ -123,7 +123,7 @@ unittest(NoDeviceID) { EthernetClient::startMockServer(pPushingBox->getServerDomain(), (uint32_t)0, 80); assertFalse(pClient->connected()); delay(60 * 20 * 1000); // wait for 20 minutes to ensure we still do not send - tc->loop(false); + tc->loop(); assertFalse(pClient->connected()); } diff --git a/test/ResetPHCalibrationTest.cpp b/test/ResetPHCalibrationTest.cpp index 1f58ac9ed..12a4cda5b 100644 --- a/test/ResetPHCalibrationTest.cpp +++ b/test/ResetPHCalibrationTest.cpp @@ -14,7 +14,7 @@ Keypad* keypad = Keypad_TC::instance()->_getPuppet(); // reduce duplicate code and make it more explicit void enterKey(char key) { keypad->push_back(key); - tc->loop(false); // recognize and apply the key entry + tc->loop(); // recognize and apply the key entry } unittest(test) { diff --git a/test/ResetThermalCalibrationTest.cpp b/test/ResetThermalCalibrationTest.cpp index e69bb2d3e..25ce2839a 100644 --- a/test/ResetThermalCalibrationTest.cpp +++ b/test/ResetThermalCalibrationTest.cpp @@ -14,7 +14,7 @@ Keypad* keypad = Keypad_TC::instance()->_getPuppet(); // reduce duplicate code and make it more explicit void enterKey(char key) { keypad->push_back(key); - tc->loop(false); // recognize and apply the key entry + tc->loop(); // recognize and apply the key entry } unittest(test) { @@ -25,8 +25,8 @@ unittest(test) { assertEqual("Cleared TempCali", lines2[1]); assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SDTest.cpp b/test/SDTest.cpp index 91d08fdbc..6cc1cc3b0 100644 --- a/test/SDTest.cpp +++ b/test/SDTest.cpp @@ -30,11 +30,11 @@ unittest(tankControllerLoop) { DateTime_TC d1(2021, 4, 15); d1.setAsCurrent(); assertFalse(SD_TC::instance()->exists("20210415.csv")); - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); delay(1000); - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); assertTrue(SD_TC::instance()->exists("20210415.csv")); File file = SD_TC::instance()->open("20210415.csv"); assertTrue(file.size() < sizeof(data)); @@ -59,11 +59,11 @@ unittest(loopInCalibration) { DateTime_TC d1(2021, 4, 15); d1.setAsCurrent(); assertFalse(SD_TC::instance()->exists("20210415.csv")); - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); delay(3000); - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); assertTrue(SD_TC::instance()->exists("20210415.csv")); File file = SD_TC::instance()->open("20210415.csv"); assertTrue(file.size() < sizeof(data)); diff --git a/test/SeeDeviceAddressTest.cpp b/test/SeeDeviceAddressTest.cpp index 66bd820cc..10029e817 100644 --- a/test/SeeDeviceAddressTest.cpp +++ b/test/SeeDeviceAddressTest.cpp @@ -16,7 +16,7 @@ unittest(testOutput) { assertEqual("SeeDeviceAddress", tc->stateName()); // Test the output - tc->loop(false); + tc->loop(); assertEqual("192.168.1.10 ", display->getLines().at(0)); char buffer[8]; strscpy(buffer, display->getLines().at(1).c_str(), sizeof(buffer)); @@ -26,16 +26,16 @@ unittest(testOutput) { GODMODE()->resetClock(); delay(1); Keypad_TC::instance()->_getPuppet()->push_back('C'); - tc->loop(false); + tc->loop(); assertEqual("90A2:DAFC:F7F2 ", display->getLines().at(1)); delay(1); Keypad_TC::instance()->_getPuppet()->push_back('C'); - tc->loop(false); + tc->loop(); assertEqual("90A2:DA00:FBF6 ", display->getLines().at(1)); // Return to mainMenu Keypad_TC::instance()->_getPuppet()->push_back('D'); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SeeDeviceUptimeTest.cpp b/test/SeeDeviceUptimeTest.cpp index 9b42691b4..84b88239e 100644 --- a/test/SeeDeviceUptimeTest.cpp +++ b/test/SeeDeviceUptimeTest.cpp @@ -15,29 +15,29 @@ unittest(testWaitState) { delay(((((1 * 24 + 2) * 60) + 3) * 60 + 4) * 1000); // 1 day, 2 hours, 3 minutes, 4 seconds SeeDeviceUptime* test = new SeeDeviceUptime(); tc->setNextState(test, true); // MainMenu -> SeeDeviceUptime nextState: Wait - tc->loop(false); + tc->loop(); assertEqual("SeeDeviceUptime", tc->stateName()); // during the delay we showed the expected two lines assertEqual(DateTime_TC::now().as16CharacterString(), display->getLines().at(0).c_str()); assertEqual("Up d:01 02:03:04", display->getLines().at(1)); delay(1000); - tc->loop(false); + tc->loop(); assertEqual(DateTime_TC::now().as16CharacterString(), display->getLines().at(0).c_str()); assertEqual("Up d:01 02:03:05", display->getLines().at(1)); delay(1000); - tc->loop(false); + tc->loop(); assertEqual("Up d:01 02:03:06", display->getLines().at(1)); delay(1000); - tc->loop(false); + tc->loop(); assertEqual("Up d:01 02:03:07", display->getLines().at(1)); delay(1000); - tc->loop(false); + tc->loop(); assertEqual("Up d:01 02:03:08", display->getLines().at(1)); delay(1000); - tc->loop(false); + tc->loop(); assertEqual("Up d:01 02:03:09", display->getLines().at(1)); delay(1000); - tc->loop(false); + tc->loop(); assertEqual("Up d:01 02:03:10", display->getLines().at(1)); } diff --git a/test/SeeFreeMemoryTest.cpp b/test/SeeFreeMemoryTest.cpp index a437cce59..fae0d8c2d 100644 --- a/test/SeeFreeMemoryTest.cpp +++ b/test/SeeFreeMemoryTest.cpp @@ -22,7 +22,7 @@ unittest(testOutput) { assertEqual(0, strcmp("1024 bytes ", line2.c_str())); // Return to mainMenu Keypad_TC::instance()->_getPuppet()->push_back('D'); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SeeGoogleMinsTest.cpp b/test/SeeGoogleMinsTest.cpp index 5f1396547..29c9d24fb 100644 --- a/test/SeeGoogleMinsTest.cpp +++ b/test/SeeGoogleMinsTest.cpp @@ -23,7 +23,7 @@ unittest(testOutput) { assertEqual("Google Mins: ", display->getLines().at(0)); assertEqual("60 ", display->getLines().at(1)); Keypad_TC::instance()->_getPuppet()->push_back('D'); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); // Clean up diff --git a/test/SeeLogFileTest.cpp b/test/SeeLogFileTest.cpp index 694453c6c..e106e65e5 100644 --- a/test/SeeLogFileTest.cpp +++ b/test/SeeLogFileTest.cpp @@ -19,12 +19,12 @@ unittest(testOutput) { // Test the output char reference[17]; snprintf_P(reference, sizeof(reference), (PGM_P)F("%4i%02i%02i.csv "), now.year(), now.month(), now.day()); - tc->loop(false); + tc->loop(); assertEqual("Current Log File", display->getLines().at(0)); assertEqual(reference, display->getLines().at(1).c_str()); // Return to mainMenu Keypad_TC::instance()->_getPuppet()->push_back('D'); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SeePHCalibrationTest.cpp b/test/SeePHCalibrationTest.cpp index c5fe5440e..dd31c90a2 100644 --- a/test/SeePHCalibrationTest.cpp +++ b/test/SeePHCalibrationTest.cpp @@ -21,7 +21,7 @@ unittest(testOutput) { assertFalse(tc->isInCalibration()); // Test the output - tc->loop(false); + tc->loop(); assertEqual("PH Calibration ", display->getLines().at(0)); assertEqual("Requesting... ", display->getLines().at(1)); pHProbe->setCalibration(2); @@ -30,7 +30,7 @@ unittest(testOutput) { assertEqual("99.7,100.3,-0.89", display->getLines().at(1)); // Return to mainMenu Keypad_TC::instance()->_getPuppet()->push_back('D'); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); } @@ -47,12 +47,12 @@ unittest(testTimeout) { pHProbe->setCalibration(2); delay(55000); - tc->loop(false); + tc->loop(); assertTrue(tc->isInCalibration()); assertEqual("SeePHCalibration", tc->stateName()); delay(5000); - tc->loop(false); // Set next state - tc->loop(false); // Loop again to switch states + tc->loop(); // Set next state + tc->loop(); // Loop again to switch states assertEqual("MainMenu", tc->stateName()); assertFalse(tc->isInCalibration()); } diff --git a/test/SeePIDConstantsTest.cpp b/test/SeePIDConstantsTest.cpp index 09dd50aa2..436696ffb 100644 --- a/test/SeePIDConstantsTest.cpp +++ b/test/SeePIDConstantsTest.cpp @@ -25,32 +25,32 @@ unittest(TestVerticalScroll) { // Transition states assertEqual("MainMenu", tc->stateName()); tc->setNextState(test, true); // MainMenu -> SeePIDConstants nextState: Wait - tc->loop(false); + tc->loop(); assertEqual("SeePIDConstants", tc->stateName()); // during the delay we cycle through kp,ki, and kd assertEqual("Kp: 10001.0 ", display->getLines().at(0)); assertEqual("Ki: 10002.0 ", display->getLines().at(1)); delay(1000); - tc->loop(false); + tc->loop(); assertEqual("Kp: 10001.0 ", display->getLines().at(0)); assertEqual("Ki: 10002.0 ", display->getLines().at(1)); delay(2000); - tc->loop(false); + tc->loop(); assertEqual("Kd: 10003.0 ", display->getLines().at(0)); assertEqual("PID: ON ", display->getLines().at(1)); PHControl::instance()->enablePID(false); delay(3000); - tc->loop(false); + tc->loop(); assertEqual("Kp: 10001.0 ", display->getLines().at(0)); assertEqual("Ki: 10002.0 ", display->getLines().at(1)); delay(3000); - tc->loop(false); + tc->loop(); assertEqual("Kd: 10003.0 ", display->getLines().at(0)); assertEqual("PID: OFF ", display->getLines().at(1)); Keypad_TC::instance()->_getPuppet()->push_back('D'); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); // Clean up diff --git a/test/SeePhTest.cpp b/test/SeePhTest.cpp index 40cae587e..5723dd89c 100644 --- a/test/SeePhTest.cpp +++ b/test/SeePhTest.cpp @@ -30,7 +30,7 @@ unittest(TestVerticalScrollWithFlatSet) { // Transition states assertEqual("MainMenu", tc->stateName()); tc->setNextState(test, true); // MainMenu -> SeePh nextState: Wait - tc->loop(false); + tc->loop(); assertEqual("SeePh", tc->stateName()); // Set up @@ -57,7 +57,7 @@ unittest(TestVerticalScrollWithFlatSet) { assertEqual("7.06 7.062 7.062", lc->getLines().at(1)); Keypad_TC::instance()->_getPuppet()->push_back('D'); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); } @@ -70,7 +70,7 @@ unittest(TestVerticalScrollWithRampSet) { // Transition states assertEqual("MainMenu", tc->stateName()); tc->setNextState(test, true); // MainMenu -> SeePh nextState: Wait - tc->loop(false); + tc->loop(); assertEqual("SeePh", tc->stateName()); // Set up @@ -104,7 +104,7 @@ unittest(TestVerticalScrollWithRampSet) { assertEqual("Now Next Goal ", lc->getLines().at(0)); assertEqual("7.67 7.000 7.000", lc->getLines().at(1)); delay(3000); - tc->loop(false); + tc->loop(); assertEqual("type: ramp ", lc->getLines().at(0)); assertEqual("left: 0:0:0 ", lc->getLines().at(1)); delay(3000); @@ -113,7 +113,7 @@ unittest(TestVerticalScrollWithRampSet) { assertEqual("7.00 7.000 7.000", lc->getLines().at(1)); Keypad_TC::instance()->_getPuppet()->push_back('D'); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); } @@ -126,7 +126,7 @@ unittest(TestVerticalScrollWithSineSet) { // Transition states assertEqual("MainMenu", tc->stateName()); tc->setNextState(test, true); // MainMenu -> SeePh nextState: Wait - tc->loop(false); + tc->loop(); assertEqual("SeePh", tc->stateName()); // Set up @@ -153,7 +153,7 @@ unittest(TestVerticalScrollWithSineSet) { assertEqual("p=0.125 a=1.500 ", lc->getLines().at(1)); Keypad_TC::instance()->_getPuppet()->push_back('D'); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SeeTankIDTest.cpp b/test/SeeTankIDTest.cpp index a6f42bfd4..1a398dbf7 100644 --- a/test/SeeTankIDTest.cpp +++ b/test/SeeTankIDTest.cpp @@ -22,7 +22,7 @@ unittest(testOutput) { assertEqual("12 ", display->getLines().at(1)); // Return to mainMenu Keypad_TC::instance()->_getPuppet()->push_back('D'); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SeeThermalCorrectionTest.cpp b/test/SeeThermalCorrectionTest.cpp index a94e332da..04373c235 100644 --- a/test/SeeThermalCorrectionTest.cpp +++ b/test/SeeThermalCorrectionTest.cpp @@ -21,7 +21,7 @@ unittest(testOutput) { assertEqual("0.00000 ", display->getLines().at(1)); // Return to mainMenu Keypad_TC::instance()->_getPuppet()->push_back('D'); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SeeVersionTest.cpp b/test/SeeVersionTest.cpp index 2a0a904e2..71655be11 100644 --- a/test/SeeVersionTest.cpp +++ b/test/SeeVersionTest.cpp @@ -16,12 +16,12 @@ unittest(testOutput) { assertEqual("SeeVersion", tc->stateName()); // Test the output - tc->loop(false); + tc->loop(); assertEqual("Software Version", display->getLines().at(0)); assertEqual(VERSION, display->getLines().at(1)); // Return to mainMenu Keypad_TC::instance()->_getPuppet()->push_back('D'); - tc->loop(false); + tc->loop(); assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SerialTest.cpp b/test/SerialTest.cpp index 7808a3083..47e2a40ff 100644 --- a/test/SerialTest.cpp +++ b/test/SerialTest.cpp @@ -58,9 +58,13 @@ unittest(report_loop_delay) { assertEqual("New info written to remote log\r\n", state->serialPort[0].dataOut); state->serialPort[0].dataOut = ""; // clear serial output + tc->loop(true); // to get the first loop delay message + assertEqual("TankController::loop() - took 0 ms (at 60 sec uptime)\r\n", state->serialPort[0].dataOut); + state->serialPort[0].dataOut = ""; // clear serial output + delay(505); assertEqual(605, millis() / 100); - tc->loop(); + tc->loop(true); assertEqual("", state->serialPort[0].dataIn); assertEqual("unexpected delay of 505 ms\r\n", state->serialPort[0].dataOut); } diff --git a/test/SetChillOrHeatTest.cpp b/test/SetChillOrHeatTest.cpp index fd09ccffb..787049e95 100644 --- a/test/SetChillOrHeatTest.cpp +++ b/test/SetChillOrHeatTest.cpp @@ -13,10 +13,10 @@ unittest(ignoreInvalidValues) { assertTrue(EEPROM_TC::instance()->getHeat()); test->setValue(2.0); assertTrue(EEPROM_TC::instance()->getHeat()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu // now we should be back to the main menu assertEqual("MainMenu", tc->stateName()); } @@ -29,10 +29,10 @@ unittest(switchToHeat) { assertEqual(1, test->getCurrentValue()); test->setValue(9.0); assertTrue(EEPROM_TC::instance()->getHeat()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu // now we should be back to the main menu assertEqual("MainMenu", tc->stateName()); } @@ -49,11 +49,11 @@ unittest(switchToChill) { std::vector lines = LiquidCrystal_TC::instance()->getLines(); assertEqual("Use chiller ", lines[1]); assertEqual("SetChillOrHeat", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu // now we should be back to the main menu assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SetGoogleSheetIntervalTest.cpp b/test/SetGoogleSheetIntervalTest.cpp index 700e156c2..3ad3ba636 100644 --- a/test/SetGoogleSheetIntervalTest.cpp +++ b/test/SetGoogleSheetIntervalTest.cpp @@ -25,11 +25,11 @@ unittest(test) { assertEqual("New interval=30 ", lines[1]); assertEqual("SetGoogleSheetInterval", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SetKDTest.cpp b/test/SetKDTest.cpp index af8357afb..a2aac00b6 100644 --- a/test/SetKDTest.cpp +++ b/test/SetKDTest.cpp @@ -22,11 +22,11 @@ unittest(test) { assertEqual("New KD=12345.5 ", lines[1]); assertEqual("SetKD", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SetKITest.cpp b/test/SetKITest.cpp index 7a274f148..ceb0133da 100644 --- a/test/SetKITest.cpp +++ b/test/SetKITest.cpp @@ -22,11 +22,11 @@ unittest(test) { assertEqual("New KI=12345.5 ", lines[1]); assertEqual("SetKI", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SetKPTest.cpp b/test/SetKPTest.cpp index 2085b493e..0e532c10a 100644 --- a/test/SetKPTest.cpp +++ b/test/SetKPTest.cpp @@ -25,11 +25,11 @@ unittest(test) { assertEqual("New KP=123456.5 ", lines[1]); assertEqual("SetKP", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SetPHSineWaveTest.cpp b/test/SetPHSineWaveTest.cpp index e43891605..9aa54d724 100644 --- a/test/SetPHSineWaveTest.cpp +++ b/test/SetPHSineWaveTest.cpp @@ -56,11 +56,11 @@ unittest(test) { assertEqual("New pH=7.125 ", lines[0]); assertEqual("A=2.125 P=1.500 ", lines[1]); assertEqual("SetPHSineWave", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu // now we should be back to the main menu assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SetPHTargetTest.cpp b/test/SetPHTargetTest.cpp index fb9d0ad26..ae7aea1ff 100644 --- a/test/SetPHTargetTest.cpp +++ b/test/SetPHTargetTest.cpp @@ -53,11 +53,11 @@ unittest(test_target_of_7_125_with_ramp_of_4_125) { assertEqual("New pH=7.125 ", lines[0]); assertEqual("New ramp=4.125 ", lines[1]); assertEqual("SetPHTarget", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu // now we should be back to the main menu assertEqual("MainMenu", tc->stateName()); } @@ -82,11 +82,11 @@ unittest(test_target_of_14_with_ramp_of_0) { // complete cycle back to main menu assertEqual("SetPHTarget", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu // now we should be back to the main menu assertEqual("MainMenu", tc->stateName()); // note that the following shows only two digits after the decimal diff --git a/test/SetTankIDTest.cpp b/test/SetTankIDTest.cpp index b961a0d59..ae5ccfa54 100644 --- a/test/SetTankIDTest.cpp +++ b/test/SetTankIDTest.cpp @@ -22,11 +22,11 @@ unittest(test) { std::vector lines = LiquidCrystal_TC::instance()->getLines(); assertEqual("Tank ID = 12 ", lines[1]); assertEqual("SetTankID", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu // now we should be back to the main menu assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SetThermalSineWaveTest.cpp b/test/SetThermalSineWaveTest.cpp index 9ee070db1..4be82db79 100644 --- a/test/SetThermalSineWaveTest.cpp +++ b/test/SetThermalSineWaveTest.cpp @@ -58,11 +58,11 @@ unittest(test) { assertEqual("New Temp=25.00 ", lines[0]); assertEqual("A=2.12 P=1.500 ", lines[1]); assertEqual("SetThermalSineWave", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu // now we should be back to the main menu assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SetThermalTargetTest.cpp b/test/SetThermalTargetTest.cpp index d9244e949..402d5b4c8 100644 --- a/test/SetThermalTargetTest.cpp +++ b/test/SetThermalTargetTest.cpp @@ -54,11 +54,11 @@ unittest(test) { assertEqual("New Temp=50.25 ", lines[0]); assertEqual("New ramp=4.125 ", lines[1]); assertEqual("SetThermalTarget", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu // now we should be back to the main menu assertEqual("MainMenu", tc->stateName()); } diff --git a/test/SetTimeTest.cpp b/test/SetTimeTest.cpp index cbef88321..b89c2f33a 100644 --- a/test/SetTimeTest.cpp +++ b/test/SetTimeTest.cpp @@ -54,11 +54,11 @@ unittest(test) { // a year ago ensures that it precedes the compile time assertEqual("2020-03-18 13:15", DateTime_TC::now().as16CharacterString()); assertEqual("SetTime", tc->stateName()); - tc->loop(false); // transition to Wait + tc->loop(); // transition to Wait assertEqual("Wait", tc->stateName()); delay(3000); - tc->loop(false); // queue MainMenu to be next - tc->loop(false); // transition to MainMenu + tc->loop(); // queue MainMenu to be next + tc->loop(); // transition to MainMenu // now we should be back to the main menu assertEqual("MainMenu", tc->stateName()); } diff --git a/test/TCLibTest.cpp b/test/TCLibTest.cpp index f5d23953e..23a94670b 100644 --- a/test/TCLibTest.cpp +++ b/test/TCLibTest.cpp @@ -59,7 +59,7 @@ unittest(basicOperation) { float avgTemp = static_cast((thermalProbe->getRunningAverage() * 100.0 + 0.5)) / 100.0; assertEqual(16.75, avgTemp); assertEqual(7.125, pHProbe->getPh()); - tc->loop(false); + tc->loop(); assertEqual(TURN_SOLENOID_OFF, state->digitalPin[TEMP_PIN]); // solenoid off assertEqual(TURN_SOLENOID_OFF, state->digitalPin[PH_PIN]); // solenoid off @@ -69,9 +69,9 @@ unittest(basicOperation) { // verify that solonoids are on delay(1000); - tc->loop(false); + tc->loop(); delay(1000); - tc->loop(false); + tc->loop(); assertEqual(TURN_SOLENOID_ON, state->digitalPin[TEMP_PIN]); // solenoid on assertEqual(TURN_SOLENOID_ON, state->digitalPin[PH_PIN]); // solenoid on @@ -81,9 +81,9 @@ unittest(basicOperation) { // verify that solonoids are off delay(1000); - tc->loop(false); + tc->loop(); delay(1000); - tc->loop(false); + tc->loop(); assertEqual(TURN_SOLENOID_OFF, state->digitalPin[TEMP_PIN]); assertEqual(TURN_SOLENOID_OFF, state->digitalPin[PH_PIN]); } @@ -95,7 +95,7 @@ unittest(storeDataToSD) { delay(10000); for (size_t i = 0; i < 4; ++i) { delay(500); - tc->loop(false); + tc->loop(); } /* time,tankid,temp,temp setpoint,pH,pH setpoint,upTime,Kp,Ki,Kd diff --git a/test/ThermalCalibrationTest.cpp b/test/ThermalCalibrationTest.cpp index ba1687c4c..00f57cdfa 100644 --- a/test/ThermalCalibrationTest.cpp +++ b/test/ThermalCalibrationTest.cpp @@ -53,8 +53,8 @@ unittest(test) { assertTrue(0.49 < temperature && temperature < 0.51); // test for https://github.com/Open-Acidification/TankController/issues/174 - tc->loop(false); - tc->loop(false); // second loop needed to set the next state + tc->loop(); + tc->loop(); // second loop needed to set the next state test = new ThermalCalibration(); tc->setNextState(test, true); test->setValue(16.0); diff --git a/test/ThermalControlTest.cpp b/test/ThermalControlTest.cpp index 74e5e5e80..0b025a58a 100644 --- a/test/ThermalControlTest.cpp +++ b/test/ThermalControlTest.cpp @@ -93,7 +93,7 @@ unittest(AfterIntervalAndOutsideDelta) { assertTrue(control->isOn()); assertEqual(TURN_SOLENOID_ON, state->digitalPin[THERMAL_CONTROL_PIN]); assertEqual("chiller turned on at 31006 after 31006 ms", Serial_TC::instance()->getBuffer()); - tc->loop(false); + tc->loop(); assertEqual("T=20.02 C 20.00 ", lc->getLines().at(1)); state->serialPort[0].dataOut = ""; // the history of data written delay(31012); @@ -101,8 +101,8 @@ unittest(AfterIntervalAndOutsideDelta) { assertFalse(control->isOn()); assertEqual(TURN_SOLENOID_OFF, state->digitalPin[THERMAL_CONTROL_PIN]); assertEqual("chiller turned off at 62024 after 31018 ms", Serial_TC::instance()->getBuffer()); - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); assertEqual("T 20.02 c 20.00 ", lc->getLines().at(1)); assertEqual("01/15/2021 01:49:26, 0, 20.02, 20.00, 0.000, 8.100, 62, 100000.0, 0.0, 0.0", dataLog->getBuffer()); @@ -155,7 +155,7 @@ unittest(OutsideDelta) { assertTrue(control->isOn()); assertEqual(TURN_SOLENOID_ON, state->digitalPin[THERMAL_CONTROL_PIN]); assertEqual("heater turned on at 0 after 0 ms", Serial_TC::instance()->getBuffer()); - tc->loop(false); + tc->loop(); assertEqual("T 20.00 H 20.00 ", lc->getLines().at(1)); state->serialPort[0].dataOut = ""; // the history of data written delay(300); @@ -163,7 +163,7 @@ unittest(OutsideDelta) { assertFalse(control->isOn()); assertEqual(TURN_SOLENOID_OFF, state->digitalPin[THERMAL_CONTROL_PIN]); assertEqual("heater turned off at 306 after 306 ms", Serial_TC::instance()->getBuffer()); - tc->loop(false); + tc->loop(); assertEqual("T 20.00 h 20.00 ", lc->getLines().at(1)); } @@ -195,7 +195,7 @@ unittest(RampGreaterThanZero) { control->setRampDurationHours(1.5); assertEqual(ThermalControl::thermalFunctionTypes::RAMP_TYPE, control->getThermalFunctionType()); assertEqual("", dataLog->getBuffer()); // data left over from previous tests is cleared - tc->loop(false); + tc->loop(); char* pBuffer = dataLog->getBuffer(); int i = 0; int tabCount = 0; @@ -249,8 +249,8 @@ unittest(RampGreaterThanZero) { dataLog->clearBuffer(); assertEqual("", dataLog->getBuffer()); // data left over from previous tests is cleared control->updateControl(thermalProbe->getRunningAverage()); - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); target = control->getCurrentThermalTarget(); assertTrue(abs(20 - target) < 0.1); assertEqual("T 20.00 c 20.00 ", lc->getLines().at(1)); @@ -261,24 +261,24 @@ unittest(RampGreaterThanZero) { control = ThermalControl::instance(); // takes 1.5 hours to get to Temp of 7 delay(1800000); // delay 30 minutes - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); target = control->getCurrentThermalTarget(); assertTrue(16.6 <= target && target <= 16.8); assertEqual("T=20.00 C 16.61 ", lc->getLines().at(1)); assertEqual("01/15/2021 02:18:55, 0, 20.00, 16.61, 0.000, 8.100, 1831, 100000.0, 0.0, 0.0", dataLog->getBuffer()); delay(1800000); // delay 30 minutes - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); target = control->getCurrentThermalTarget(); assertTrue(13.2 <= target && target <= 13.4); assertEqual("T=20.00 C 13.28 ", lc->getLines().at(1)); assertEqual("01/15/2021 02:48:55, 0, 20.00, 13.28, 0.000, 8.100, 3631, 100000.0, 0.0, 0.0", dataLog->getBuffer()); delay(1800000); // delay 30 minutes - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); assertEqual(10, control->getCurrentThermalTarget()); assertEqual("T=20.01 C 10.00 ", lc->getLines().at(1)); assertEqual("01/15/2021 03:18:55, 0, 20.01, 10.00, 0.000, 8.100, 5431, 100000.0, 0.0, 0.0", @@ -286,8 +286,8 @@ unittest(RampGreaterThanZero) { // ramp time no longer used after it ends delay(1800000); // delay 30 minutes delay(1800000); // delay 30 minutes - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); assertEqual(10, control->getCurrentThermalTarget()); assertEqual("T=20.01 C 10.00 ", lc->getLines().at(1)); assertEqual("01/15/2021 04:18:55, 0, 20.01, 10.00, 0.000, 8.100, 9031, 100000.0, 0.0, 0.0", @@ -299,8 +299,8 @@ unittest(RampGreaterThanZero) { control->setThermalTarget(30); control->setRampDurationHours(1.5); control->updateControl(thermalProbe->getRunningAverage()); - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); target = control->getCurrentThermalTarget(); assertTrue(20 <= target && target <= 20.03); assertEqual("T 20.01 h 20.01 ", lc->getLines().at(1)); @@ -311,30 +311,30 @@ unittest(RampGreaterThanZero) { control = ThermalControl::instance(); // takes 1.5 hours to get to Temp of 7 delay(1800000); // delay 30 minutes - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); target = control->getCurrentThermalTarget(); assertTrue(23.3 <= target && target <= 23.4); assertEqual("T 20.01 H 23.34 ", lc->getLines().at(1)); assertEqual("01/15/2021 04:49:26, 0, 20.01, 23.34, 0.000, 8.100, 10862, 100000.0, 0.0, 0.0", dataLog->getBuffer()); delay(1800000); // delay 30 minutes - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); target = control->getCurrentThermalTarget(); assertTrue(26.6 <= target && target <= 26.7); assertEqual("T 20.01 H 26.67 ", lc->getLines().at(1)); assertEqual("01/15/2021 05:19:26, 0, 20.01, 26.67, 0.000, 8.100, 12662, 100000.0, 0.0, 0.0", dataLog->getBuffer()); delay(1800000); // delay 30 minutes - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); assertEqual(30, control->getCurrentThermalTarget()); // ramp time no longer used after it ends delay(1800000); // delay 30 minutes delay(1800000); // delay 30 minutes - tc->loop(false); - tc->loop(false); + tc->loop(); + tc->loop(); assertEqual(30, control->getCurrentThermalTarget()); assertEqual("T 20.02 H 30.00 ", lc->getLines().at(1)); assertEqual("01/15/2021 06:49:26, 0, 20.02, 30.00, 0.000, 8.100, 18062, 100000.0, 0.0, 0.0", @@ -347,23 +347,23 @@ unittest(ChangeRampToZero) { assertFalse(control->isOn()); control->setThermalTarget(10); control->setRampDurationHours(1.5); - tc->loop(false); + tc->loop(); assertTrue(20 <= control->getCurrentThermalTarget() && control->getCurrentThermalTarget() <= 20.03); control->setRampDurationHours(0); - tc->loop(false); + tc->loop(); assertEqual(10, control->getCurrentThermalTarget()); ThermalControl::enableHeater(true); control = ThermalControl::instance(); assertFalse(control->isOn()); control->setThermalTarget(30); control->setRampDurationHours(1.5); - tc->loop(false); + tc->loop(); assertTrue(20 <= control->getCurrentThermalTarget() && control->getCurrentThermalTarget() <= 20.03); control->setRampDurationHours(0); assertEqual(ThermalControl::thermalFunctionTypes::FLAT_TYPE, control->getThermalFunctionType()); - tc->loop(false); + tc->loop(); assertEqual(30, control->getCurrentThermalTarget()); - tc->loop(false); + tc->loop(); assertEqual(30, control->getCurrentThermalTarget()); } @@ -374,35 +374,35 @@ unittest(sineTest) { control->setThermalTarget(10); control->setSineAmplitudeAndHours(1.5, 2); assertEqual(ThermalControl::thermalFunctionTypes::SINE_TYPE, control->getThermalFunctionType()); - tc->loop(false); + tc->loop(); assertEqual(10, control->getCurrentThermalTarget()); // mock arduino restarting ThermalControl::clearInstance(); control = ThermalControl::instance(); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(11.5, control->getCurrentThermalTarget()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(10, control->getCurrentThermalTarget()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(8.5, control->getCurrentThermalTarget()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(10, control->getCurrentThermalTarget()); // make sure sine wave continues delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(11.5, control->getCurrentThermalTarget()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(10, control->getCurrentThermalTarget()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(8.5, control->getCurrentThermalTarget()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(10, control->getCurrentThermalTarget()); ThermalControl::enableHeater(true); control = ThermalControl::instance(); @@ -410,35 +410,35 @@ unittest(sineTest) { control->setThermalTarget(30); control->setSineAmplitudeAndHours(1.5, 2); assertEqual(ThermalControl::thermalFunctionTypes::SINE_TYPE, control->getThermalFunctionType()); - tc->loop(false); + tc->loop(); assertEqual(30, control->getCurrentThermalTarget()); // mock arduino restarting ThermalControl::clearInstance(); control = ThermalControl::instance(); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(31.5, control->getCurrentThermalTarget()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(30, control->getCurrentThermalTarget()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(28.5, control->getCurrentThermalTarget()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(30, control->getCurrentThermalTarget()); // make sure sine wave continues delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(31.5, control->getCurrentThermalTarget()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(30, control->getCurrentThermalTarget()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(28.5, control->getCurrentThermalTarget()); delay(1800000); // delay 30 minutes - tc->loop(false); + tc->loop(); assertEqual(30, control->getCurrentThermalTarget()); } From 981577b7285b538bc64d3090a6c48e08b6f938de Mon Sep 17 00:00:00 2001 From: James Foster Date: Fri, 27 Dec 2024 09:21:46 -0800 Subject: [PATCH 08/10] Formatting. --- extras/device_client/lib/model/version.dart | 2 +- src/Version.h | 2 +- test/DataLoggerTest.cpp | 2 +- test/PushingBoxTest.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extras/device_client/lib/model/version.dart b/extras/device_client/lib/model/version.dart index 63c130c15..b9eaa7b72 100644 --- a/extras/device_client/lib/model/version.dart +++ b/extras/device_client/lib/model/version.dart @@ -1 +1 @@ -const String gitVersion = 'v24.10.2-9-g963+'; +const String gitVersion = 'v24.10.2-10-g60+'; diff --git a/src/Version.h b/src/Version.h index 7a5d7a75c..1cafaa431 100644 --- a/src/Version.h +++ b/src/Version.h @@ -1 +1 @@ -#define VERSION "v24.10.2-9-g963+" +#define VERSION "v24.10.2-10-g60+" diff --git a/test/DataLoggerTest.cpp b/test/DataLoggerTest.cpp index fb082114b..b90e8da62 100644 --- a/test/DataLoggerTest.cpp +++ b/test/DataLoggerTest.cpp @@ -65,7 +65,7 @@ unittest(loop) { // remote log entry after one minute assertFalse(0.0 == thermalProbe->getSampleMean()); - tc->loop(); // write info to remote log + tc->loop(); // write info to remote log assertTrue(isnan(thermalProbe->getSampleMean())); // thermal sample has been collected assertTrue(isnan(thermalProbe->getSampleStandardDeviation())); // thermal sample has been reset char infoString[512] = ""; diff --git a/test/PushingBoxTest.cpp b/test/PushingBoxTest.cpp index ec24e51d6..6839c87ff 100644 --- a/test/PushingBoxTest.cpp +++ b/test/PushingBoxTest.cpp @@ -55,7 +55,7 @@ unittest(NoTankID) { tc->loop(); state->serialPort[0].dataOut = ""; delay(40 * 1000); // allow 70 seconds (30 + 40) for PushingBox update - tc->loop(); // Trigger SD logging and Serial (DataLogger) and PushingBox + tc->loop(); // Trigger SD logging and Serial (DataLogger) and PushingBox char expected[] = "Set Tank ID in order to send data to PushingBox"; assertEqual(expected, Serial_TC::instance()->getBuffer()); } From 1a52806306590e060df4d1f9c4271378816966a3 Mon Sep 17 00:00:00 2001 From: James Foster Date: Mon, 6 Jan 2025 20:04:22 -0800 Subject: [PATCH 09/10] Changes based on code review. --- extras/device_client/lib/model/version.dart | 2 +- src/TankController.cpp | 24 ++++++++++++--------- src/Version.h | 2 +- src/model/JSONBuilder.cpp | 2 +- test/SerialTest.cpp | 2 +- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/extras/device_client/lib/model/version.dart b/extras/device_client/lib/model/version.dart index b9eaa7b72..0f56a0190 100644 --- a/extras/device_client/lib/model/version.dart +++ b/extras/device_client/lib/model/version.dart @@ -1 +1 @@ -const String gitVersion = 'v24.10.2-10-g60+'; +const String gitVersion = 'v24.10.2-11-g98+'; diff --git a/src/TankController.cpp b/src/TankController.cpp index 6fb49c5d7..62fefbf99 100644 --- a/src/TankController.cpp +++ b/src/TankController.cpp @@ -159,16 +159,19 @@ void TankController::handleUI() { } /** - * This is one of two public instance functions. + * This is one of two public instance functions (the other is setup()). * It is called repeatedly while the board is on. + * We monitor two elapsed times: + * 1. the time it takes to run the loop() function (our code); and, + * 2. the time from one loop start to the next (including the board delay). */ void TankController::loop(bool report_loop_delay) { - static unsigned long lastTime = 0; - unsigned long thisTime = millis(); - if (report_loop_delay && lastTime && thisTime - lastTime > 500) { - serial(F("unexpected delay of %i ms"), thisTime - lastTime); + static unsigned long previousLoopStart = 0; + unsigned long currentLoopStart = millis(); + if (report_loop_delay && previousLoopStart && currentLoopStart - previousLoopStart > 300) { + serial(F("unexpected overall delay of %i ms (at %lu sec uptime)"), + currentLoopStart - previousLoopStart, millis() / 1000); } - unsigned long start = millis(); wdt_reset(); blink(); // blink the on-board LED to show that we are running (0ms) updateControls(); // turn CO2 and temperature controls on or off (~90ms) @@ -180,12 +183,13 @@ void TankController::loop(bool report_loop_delay) { EthernetServer_TC::instance()->loop(); // handle any HTTP requests (~0ms) if (report_loop_delay) { static long int count = 0; - unsigned long loopTime = millis() - start; - if (++count % 10000 == 1 || loopTime > 200) { // first time through and periodically thereafter - serial(F("TankController::loop() - took %lu ms (at %lu sec uptime)"), loopTime, start / 1000); + unsigned long currentLoopTime = millis() - currentLoopStart; + if (++count % 10000 == 1 || currentLoopTime > 200) { // first time through and periodically thereafter + serial(F("TankController::loop() - took %lu ms (at %lu sec uptime)"), + currentLoopTime, millis() / 1000); } - lastTime = millis(); } + previousLoopStart = currentLoopStart; } /** diff --git a/src/Version.h b/src/Version.h index 1cafaa431..e684fba38 100644 --- a/src/Version.h +++ b/src/Version.h @@ -1 +1 @@ -#define VERSION "v24.10.2-10-g60+" +#define VERSION "v24.10.2-11-g98+" diff --git a/src/model/JSONBuilder.cpp b/src/model/JSONBuilder.cpp index a51cafa34..61eb05962 100644 --- a/src/model/JSONBuilder.cpp +++ b/src/model/JSONBuilder.cpp @@ -44,7 +44,7 @@ int JSONBuilder::buildCurrentValues() { char pHSlope[20]; float pHSineAmplitude = 0.0; if ((EEPROM_TC::instance()->getPhSinePeriod() / 3600.0) > 0) { - pHSineAmplitude = (PHControl::instance()->getAmplitude() > 0.01 ? PHControl::instance()->getAmplitude() : 0.0); + pHSineAmplitude = PHControl::instance()->getAmplitude(); } int pHSineAmplitude_f = (int)(pHSineAmplitude * 1000 + 0.5) % 1000; while (pHSineAmplitude_f && pHSineAmplitude_f % 10 == 0) { diff --git a/test/SerialTest.cpp b/test/SerialTest.cpp index 47e2a40ff..09e3755da 100644 --- a/test/SerialTest.cpp +++ b/test/SerialTest.cpp @@ -66,7 +66,7 @@ unittest(report_loop_delay) { assertEqual(605, millis() / 100); tc->loop(true); assertEqual("", state->serialPort[0].dataIn); - assertEqual("unexpected delay of 505 ms\r\n", state->serialPort[0].dataOut); + assertEqual("unexpected overall delay of 505 ms (at 60 sec uptime)\r\n", state->serialPort[0].dataOut); } unittest_main() From 3173ce90769f0f74e564448eb6e0ed2dda3e10b7 Mon Sep 17 00:00:00 2001 From: James Foster Date: Mon, 6 Jan 2025 20:06:03 -0800 Subject: [PATCH 10/10] Format. --- extras/device_client/lib/model/version.dart | 2 +- src/TankController.cpp | 7 +++---- src/Version.h | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/extras/device_client/lib/model/version.dart b/extras/device_client/lib/model/version.dart index 0f56a0190..0f0219137 100644 --- a/extras/device_client/lib/model/version.dart +++ b/extras/device_client/lib/model/version.dart @@ -1 +1 @@ -const String gitVersion = 'v24.10.2-11-g98+'; +const String gitVersion = 'v24.10.2-12-g1a+'; diff --git a/src/TankController.cpp b/src/TankController.cpp index 62fefbf99..6d372e20a 100644 --- a/src/TankController.cpp +++ b/src/TankController.cpp @@ -169,8 +169,8 @@ void TankController::loop(bool report_loop_delay) { static unsigned long previousLoopStart = 0; unsigned long currentLoopStart = millis(); if (report_loop_delay && previousLoopStart && currentLoopStart - previousLoopStart > 300) { - serial(F("unexpected overall delay of %i ms (at %lu sec uptime)"), - currentLoopStart - previousLoopStart, millis() / 1000); + serial(F("unexpected overall delay of %i ms (at %lu sec uptime)"), currentLoopStart - previousLoopStart, + millis() / 1000); } wdt_reset(); blink(); // blink the on-board LED to show that we are running (0ms) @@ -185,8 +185,7 @@ void TankController::loop(bool report_loop_delay) { static long int count = 0; unsigned long currentLoopTime = millis() - currentLoopStart; if (++count % 10000 == 1 || currentLoopTime > 200) { // first time through and periodically thereafter - serial(F("TankController::loop() - took %lu ms (at %lu sec uptime)"), - currentLoopTime, millis() / 1000); + serial(F("TankController::loop() - took %lu ms (at %lu sec uptime)"), currentLoopTime, millis() / 1000); } } previousLoopStart = currentLoopStart; diff --git a/src/Version.h b/src/Version.h index e684fba38..f2a7a142d 100644 --- a/src/Version.h +++ b/src/Version.h @@ -1 +1 @@ -#define VERSION "v24.10.2-11-g98+" +#define VERSION "v24.10.2-12-g1a+"