mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
standalone test for memory optimizations (200+ entities)
This commit is contained in:
@@ -542,6 +542,7 @@ void Shell::process_command() {
|
|||||||
line_buffer_.clear();
|
line_buffer_.clear();
|
||||||
cursor_ = 0;
|
cursor_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandLine command_line{line1};
|
CommandLine command_line{line1};
|
||||||
|
|
||||||
println();
|
println();
|
||||||
|
|||||||
@@ -185,7 +185,6 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i
|
|||||||
register_device_values();
|
register_device_values();
|
||||||
|
|
||||||
if (System::test_set_all_active()) {
|
if (System::test_set_all_active()) {
|
||||||
Serial.println("DEBUG TEST: adding a fake hc");
|
|
||||||
// if we're just dumping out values, create a single dummy hc1
|
// if we're just dumping out values, create a single dummy hc1
|
||||||
register_device_values_hc(std::make_shared<emsesp::Thermostat::HeatingCircuit>(1, model)); // hc=1
|
register_device_values_hc(std::make_shared<emsesp::Thermostat::HeatingCircuit>(1, model)); // hc=1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,20 +239,23 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
EMSESP::watch(EMSESP::Watch::WATCH_RAW); // raw
|
EMSESP::watch(EMSESP::Watch::WATCH_RAW); // raw
|
||||||
|
|
||||||
std::string command(20, '\0');
|
std::string command(20, '\0');
|
||||||
|
|
||||||
if ((cmd.empty()) || (cmd == "default")) {
|
if ((cmd.empty()) || (cmd == "default")) {
|
||||||
command = EMSESP_DEBUG_DEFAULT;
|
command = EMSESP_DEBUG_DEFAULT;
|
||||||
} else {
|
} else {
|
||||||
command = cmd;
|
command = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/emsesp/EMS-ESP32/issues/869
|
||||||
if (command == "memory") {
|
if (command == "memory") {
|
||||||
|
EMSESP::logger().notice("Testing memory by adding lots of devices and entities...");
|
||||||
shell.printfln("Testing memory by adding lots of devices and entities...");
|
shell.printfln("Testing memory by adding lots of devices and entities...");
|
||||||
|
|
||||||
System::test_set_all_active(true);
|
System::test_set_all_active(true);
|
||||||
|
|
||||||
add_device(0x08, 123); // Nefit Trendline
|
// simulate HansRemmerswaal's setup - see https://github.com/emsesp/EMS-ESP32/issues/859
|
||||||
add_device(0x18, 157); // Bosch CR100
|
add_device(0x08, 172); // 160 entities - boiler: Enviline/Compress 6000AW/Hybrid 3000-7000iAW/SupraEco/Geo 5xx/WLW196i
|
||||||
|
add_device(0x10, 158); // 62 entities - thermostat: RC300/RC310/Moduline 3000/1010H/CW400/Sense II/HPC410
|
||||||
|
add_device(0x38, 200); // 4 entities - thermostat: RC100H
|
||||||
|
|
||||||
shell.invoke_command("show values");
|
shell.invoke_command("show values");
|
||||||
|
|
||||||
@@ -1669,6 +1672,16 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
#endif // EMSES_STANDALONE
|
#endif // EMSES_STANDALONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// loop console. simulates what EMSESP::loop() does
|
||||||
|
void Test::refresh() {
|
||||||
|
#if defined(EMSESP_STANDALONE)
|
||||||
|
uuid::loop();
|
||||||
|
EMSESP::rxservice_.loop();
|
||||||
|
EMSESP::mqtt_.loop();
|
||||||
|
Shell::loop_all();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// simulates a telegram in the Rx queue, but without the CRC which is added automatically
|
// simulates a telegram in the Rx queue, but without the CRC which is added automatically
|
||||||
void Test::rx_telegram(const std::vector<uint8_t> & rx_data) {
|
void Test::rx_telegram(const std::vector<uint8_t> & rx_data) {
|
||||||
uint8_t len = rx_data.size();
|
uint8_t len = rx_data.size();
|
||||||
@@ -1680,6 +1693,8 @@ void Test::rx_telegram(const std::vector<uint8_t> & rx_data) {
|
|||||||
}
|
}
|
||||||
data[i] = EMSESP::rxservice_.calculate_crc(data, i);
|
data[i] = EMSESP::rxservice_.calculate_crc(data, i);
|
||||||
EMSESP::rxservice_.add(data, len + 1);
|
EMSESP::rxservice_.add(data, len + 1);
|
||||||
|
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// simulates a telegram straight from UART, but without the CRC which is added automatically
|
// simulates a telegram straight from UART, but without the CRC which is added automatically
|
||||||
@@ -1693,6 +1708,8 @@ void Test::uart_telegram(const std::vector<uint8_t> & rx_data) {
|
|||||||
}
|
}
|
||||||
data[i] = EMSESP::rxservice_.calculate_crc(data, i);
|
data[i] = EMSESP::rxservice_.calculate_crc(data, i);
|
||||||
EMSESP::incoming_telegram(data, i + 1);
|
EMSESP::incoming_telegram(data, i + 1);
|
||||||
|
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// takes raw string, assuming it contains the CRC. This is what is output from 'watch raw'
|
// takes raw string, assuming it contains the CRC. This is what is output from 'watch raw'
|
||||||
@@ -1730,6 +1747,8 @@ void Test::uart_telegram_withCRC(const char * rx_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EMSESP::incoming_telegram(data, count + 1);
|
EMSESP::incoming_telegram(data, count + 1);
|
||||||
|
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// takes raw string, adds CRC to end
|
// takes raw string, adds CRC to end
|
||||||
@@ -1769,11 +1788,11 @@ void Test::uart_telegram(const char * rx_data) {
|
|||||||
data[count + 1] = EMSESP::rxservice_.calculate_crc(data, count + 1); // add CRC
|
data[count + 1] = EMSESP::rxservice_.calculate_crc(data, count + 1); // add CRC
|
||||||
|
|
||||||
EMSESP::incoming_telegram(data, count + 2);
|
EMSESP::incoming_telegram(data, count + 2);
|
||||||
|
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sends version telegram. Version is hardcoded to 1.0
|
|
||||||
void Test::add_device(uint8_t device_id, uint8_t product_id) {
|
void Test::add_device(uint8_t device_id, uint8_t product_id) {
|
||||||
// Send version: 09 0B 02 00 PP V1 V2
|
|
||||||
uart_telegram({device_id, EMSESP_DEFAULT_EMS_BUS_ID, EMSdevice::EMS_TYPE_VERSION, 0, product_id, 1, 0});
|
uart_telegram({device_id, EMSESP_DEFAULT_EMS_BUS_ID, EMSdevice::EMS_TYPE_VERSION, 0, product_id, 1, 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ class Test {
|
|||||||
static void uart_telegram_withCRC(const char * rx_data);
|
static void uart_telegram_withCRC(const char * rx_data);
|
||||||
static void add_device(uint8_t device_id, uint8_t product_id);
|
static void add_device(uint8_t device_id, uint8_t product_id);
|
||||||
static void debug(uuid::console::Shell & shell, const std::string & command);
|
static void debug(uuid::console::Shell & shell, const std::string & command);
|
||||||
|
static void refresh();
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
static void listDir(fs::FS & fs, const char * dirname, uint8_t levels);
|
static void listDir(fs::FS & fs, const char * dirname, uint8_t levels);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user