mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 10:49:42 +02:00
Make performance profiling configurable from webserver
This commit is contained in:
parent
dc4aa95109
commit
13df59f806
8 changed files with 74 additions and 74 deletions
|
@ -297,7 +297,7 @@ void handle_BMSpower() {
|
|||
|
||||
if (periodic_bms_reset) {
|
||||
// Check if 24 hours have passed since the last power removal
|
||||
if ((currentTime + bmsResetTimeOffset) - lastPowerRemovalTime >= powerRemovalInterval) {
|
||||
if (currentTime - lastPowerRemovalTime >= powerRemovalInterval) {
|
||||
start_bms_reset();
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +329,6 @@ void start_bms_reset() {
|
|||
if (!datalayer.system.status.BMS_reset_in_progress) {
|
||||
lastPowerRemovalTime = currentTime; // Record the time when BMS reset was started
|
||||
// we are now resetting at the correct time. We don't need to offset anymore
|
||||
bmsResetTimeOffset = 0;
|
||||
// Set a flag to let the rest of the system know we are cutting power to the BMS.
|
||||
// The battery CAN sending routine will then know not to try guto send anything towards battery while active
|
||||
datalayer.system.status.BMS_reset_in_progress = true;
|
||||
|
|
|
@ -144,6 +144,7 @@ void init_stored_settings() {
|
|||
remote_bms_reset = settings.getBool("REMBMSRESET", false);
|
||||
use_canfd_as_can = settings.getBool("CANFDASCAN", false);
|
||||
|
||||
datalayer.system.info.performance_measurement_active = settings.getBool("PERFPROFILE", false);
|
||||
datalayer.system.info.CAN_usb_logging_active = settings.getBool("CANLOGUSB", false);
|
||||
datalayer.system.info.usb_logging_active = settings.getBool("USBENABLED", false);
|
||||
datalayer.system.info.web_logging_active = settings.getBool("WEBENABLED", false);
|
||||
|
|
|
@ -259,12 +259,13 @@ struct DATALAYER_SYSTEM_INFO_TYPE {
|
|||
bool can_native_send_fail = false;
|
||||
/** bool, MCP2515 CAN failed to send flag */
|
||||
bool can_2515_send_fail = false;
|
||||
/** uint16_t, MCP2518 CANFD failed to send flag */
|
||||
/** bool, MCP2518 CANFD failed to send flag */
|
||||
bool can_2518_send_fail = false;
|
||||
/** bool, determines if detailed performance measurement should be shown on webserver */
|
||||
bool performance_measurement_active = false;
|
||||
};
|
||||
|
||||
struct DATALAYER_SYSTEM_STATUS_TYPE {
|
||||
#ifdef FUNCTION_TIME_MEASUREMENT
|
||||
/** Core task measurement variable */
|
||||
int64_t core_task_max_us = 0;
|
||||
/** Core task measurement variable, reset each 10 seconds */
|
||||
|
@ -305,7 +306,6 @@ struct DATALAYER_SYSTEM_STATUS_TYPE {
|
|||
* This will show the performance of CAN TX when the total time reached a new worst case
|
||||
*/
|
||||
int64_t time_snap_cantx_us = 0;
|
||||
#endif
|
||||
/** uint8_t */
|
||||
/** A counter set each time a new message comes from inverter.
|
||||
* This value then gets decremented every second. Incase we reach 0
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
/** Start time measurement in microseconds
|
||||
* Input parameter must be a unique "tag", e.g: START_TIME_MEASUREMENT(wifi);
|
||||
*/
|
||||
#ifdef FUNCTION_TIME_MEASUREMENT
|
||||
#define START_TIME_MEASUREMENT(x) int64_t start_time_##x = esp_timer_get_time()
|
||||
/** End time measurement in microseconds
|
||||
* Input parameters are the unique tag and the name of the ALREADY EXISTING
|
||||
|
@ -21,10 +20,5 @@
|
|||
* This will log the maximum value in the destination variable.
|
||||
*/
|
||||
#define END_TIME_MEASUREMENT_MAX(x, y) y = MAX(y, esp_timer_get_time() - start_time_##x)
|
||||
#else
|
||||
#define START_TIME_MEASUREMENT(x) ;
|
||||
#define END_TIME_MEASUREMENT(x, y) ;
|
||||
#define END_TIME_MEASUREMENT_MAX(x, y) ;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -283,6 +283,10 @@ String settings_processor(const String& var, BatteryEmulatorSettingsStore& setti
|
|||
return settings.getBool("WIFIAPENABLED", wifiap_enabled) ? "checked" : "";
|
||||
}
|
||||
|
||||
if (var == "PERFPROFILE") {
|
||||
return settings.getBool("PERFPROFILE") ? "checked" : "";
|
||||
}
|
||||
|
||||
if (var == "CANLOGUSB") {
|
||||
return settings.getBool("CANLOGUSB") ? "checked" : "";
|
||||
}
|
||||
|
@ -970,6 +974,9 @@ const char* getCANInterfaceName(CAN_Interface interface) {
|
|||
<label>Custom hostname: </label>
|
||||
<input type='text' name='HOSTNAME' value="%HOSTNAME%" />
|
||||
|
||||
<label>Enable performance profiling: </label>
|
||||
<input type='checkbox' name='PERFPROFILE' value='on' style='margin-left: 0;' %PERFPROFILE% />
|
||||
|
||||
<label>Enable CAN logging via USB serial: </label>
|
||||
<input type='checkbox' name='CANLOGUSB' value='on' style='margin-left: 0;' %CANLOGUSB% />
|
||||
|
||||
|
|
|
@ -411,7 +411,7 @@ void init_webserver() {
|
|||
const char* boolSettingNames[] = {
|
||||
"DBLBTR", "CNTCTRL", "CNTCTRLDBL", "PWMCNTCTRL", "PERBMSRESET", "SDLOGENABLED", "REMBMSRESET",
|
||||
"USBENABLED", "CANLOGUSB", "WEBENABLED", "CANFDASCAN", "CANLOGSD", "WIFIAPENABLED", "MQTTENABLED",
|
||||
"HADISC", "MQTTTOPICS", "INVICNT", "GTWRHD", "DIGITALHVIL",
|
||||
"HADISC", "MQTTTOPICS", "INVICNT", "GTWRHD", "DIGITALHVIL", "PERFPROFILE",
|
||||
};
|
||||
|
||||
// Handles the form POST from UI to save settings of the common image
|
||||
|
@ -914,23 +914,24 @@ String processor(const String& var) {
|
|||
#endif // HW_STARK
|
||||
content += " @ " + String(datalayer.system.info.CPU_temperature, 1) + " °C</h4>";
|
||||
content += "<h4>Uptime: " + get_uptime() + "</h4>";
|
||||
#ifdef FUNCTION_TIME_MEASUREMENT
|
||||
// Load information
|
||||
content += "<h4>Core task max load: " + String(datalayer.system.status.core_task_max_us) + " us</h4>";
|
||||
content += "<h4>Core task max load last 10 s: " + String(datalayer.system.status.core_task_10s_max_us) + " us</h4>";
|
||||
content +=
|
||||
"<h4>MQTT function (MQTT task) max load last 10 s: " + String(datalayer.system.status.mqtt_task_10s_max_us) +
|
||||
" us</h4>";
|
||||
content +=
|
||||
"<h4>WIFI function (MQTT task) max load last 10 s: " + String(datalayer.system.status.wifi_task_10s_max_us) +
|
||||
" us</h4>";
|
||||
content += "<h4>Max load @ worst case execution of core task:</h4>";
|
||||
content += "<h4>10ms function timing: " + String(datalayer.system.status.time_snap_10ms_us) + " us</h4>";
|
||||
content += "<h4>Values function timing: " + String(datalayer.system.status.time_snap_values_us) + " us</h4>";
|
||||
content += "<h4>CAN/serial RX function timing: " + String(datalayer.system.status.time_snap_comm_us) + " us</h4>";
|
||||
content += "<h4>CAN TX function timing: " + String(datalayer.system.status.time_snap_cantx_us) + " us</h4>";
|
||||
content += "<h4>OTA function timing: " + String(datalayer.system.status.time_snap_ota_us) + " us</h4>";
|
||||
#endif // FUNCTION_TIME_MEASUREMENT
|
||||
if (datalayer.system.info.performance_measurement_active) {
|
||||
// Load information
|
||||
content += "<h4>Core task max load: " + String(datalayer.system.status.core_task_max_us) + " us</h4>";
|
||||
content +=
|
||||
"<h4>Core task max load last 10 s: " + String(datalayer.system.status.core_task_10s_max_us) + " us</h4>";
|
||||
content +=
|
||||
"<h4>MQTT function (MQTT task) max load last 10 s: " + String(datalayer.system.status.mqtt_task_10s_max_us) +
|
||||
" us</h4>";
|
||||
content +=
|
||||
"<h4>WIFI function (MQTT task) max load last 10 s: " + String(datalayer.system.status.wifi_task_10s_max_us) +
|
||||
" us</h4>";
|
||||
content += "<h4>Max load @ worst case execution of core task:</h4>";
|
||||
content += "<h4>10ms function timing: " + String(datalayer.system.status.time_snap_10ms_us) + " us</h4>";
|
||||
content += "<h4>Values function timing: " + String(datalayer.system.status.time_snap_values_us) + " us</h4>";
|
||||
content += "<h4>CAN/serial RX function timing: " + String(datalayer.system.status.time_snap_comm_us) + " us</h4>";
|
||||
content += "<h4>CAN TX function timing: " + String(datalayer.system.status.time_snap_cantx_us) + " us</h4>";
|
||||
content += "<h4>OTA function timing: " + String(datalayer.system.status.time_snap_ota_us) + " us</h4>";
|
||||
}
|
||||
|
||||
wl_status_t status = WiFi.status();
|
||||
// Display ssid of network connected to and, if connected to the WiFi, its own IP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue