diff --git a/lib/polymech-base/src/components/PressCylinder.cpp b/lib/polymech-base/src/components/PressCylinder.cpp index a2522fc9..0aacb658 100644 --- a/lib/polymech-base/src/components/PressCylinder.cpp +++ b/lib/polymech-base/src/components/PressCylinder.cpp @@ -223,8 +223,6 @@ void PressCylinder::onError(int error_code) m_error_code.update(error_code); _last_error_code = (E_PC_ErrorCode)error_code; m_mode.update(DEFAULT_AUTO_MODE_STOPPED); - // L_ERROR("PressCylinder aborting: %s (%d)", getErrorString(error_code), error_code); - JsonDocument doc; doc["type"] = "error"; doc["source"] = this->name; diff --git a/lib/polymech-base/src/components/PressCylinder.h b/lib/polymech-base/src/components/PressCylinder.h index 2117d895..042f72cd 100644 --- a/lib/polymech-base/src/components/PressCylinder.h +++ b/lib/polymech-base/src/components/PressCylinder.h @@ -129,7 +129,7 @@ public: E_PC_OP_CHECK_MULTI_TIMEOUT = 1 << 5, // E_PC_OP_ENABLE_DOUBLE_CLICK = 1 << 6, // Removed // E_PC_OP_ALL = E_PC_OP_CHECK_MAX_TIME | E_PC_OP_CHECK_STALLED | E_PC_OP_CHECK_BALANCE | E_PC_OP_CHECK_LOADCELL, - E_PC_OP_ALL = E_PC_OP_CHECK_MAX_TIME | E_PC_OP_CHECK_LOADCELL + E_PC_OP_ALL = E_PC_OP_CHECK_MAX_TIME }; enum E_PC_OutputMode { diff --git a/lib/polymech-base/src/profiles/TemperatureProfile.h b/lib/polymech-base/src/profiles/TemperatureProfile.h index 81446542..011594fc 100644 --- a/lib/polymech-base/src/profiles/TemperatureProfile.h +++ b/lib/polymech-base/src/profiles/TemperatureProfile.h @@ -16,7 +16,7 @@ class ModbusTCP; -#define TEMPERATURE_PROFILE_LOOP_INTERVAL_MS 1000 +#define TEMPERATURE_PROFILE_LOOP_INTERVAL_MS 500 #define TEMP_PROFILE_ID_BASE 2000 #define TEMP_REGISTER_NAME_PREFIX "TProf" #define TEMP_MAX_LAG 1000 * 60 * 5 // 5 minutes diff --git a/src/PHApp-Profiles.cpp b/src/PHApp-Profiles.cpp index 57fcfb91..73a856b5 100644 --- a/src/PHApp-Profiles.cpp +++ b/src/PHApp-Profiles.cpp @@ -978,22 +978,14 @@ void PHApp::onTemperatureProfileStarted(PlotBase *profile) L_INFO(F("PHApp::onTemperatureProfileStarted() - Starting temperature profile %d with temperature %d."), profile->slot, temp); tempProfile->setStatus(PlotStatus::INITIALIZING); setPIDs(tempProfile->slot, temp); + } - if (appSettings->get("ALWAYS_USE_SEQUENTIAL_HEATING", false)) - { - stopPids(tempProfile->slot); + if (appSettings->get("ALWAYS_USE_SEQUENTIAL_HEATING", false)) + { + stopPids(tempProfile->slot); #if ENABLED(ENABLE_AMPERAGE_BUDGET_MANAGER) - pidManagerAmperage->reset(); - if (!pidManagerAmperage->enabled()) - { - // pidManagerAmperage->enable(); - } + pidManagerAmperage->reset(); #endif - } - else - { - startPids(tempProfile->slot); - } } else { diff --git a/src/PHAppWeb.cpp b/src/PHAppWeb.cpp index f80005b0..f2180c4e 100644 --- a/src/PHAppWeb.cpp +++ b/src/PHAppWeb.cpp @@ -918,61 +918,53 @@ short PHApp::registerWebSocketHandlers(RESTServer *instance) */ void PHApp::getSignalPlotsHandler(AsyncWebServerRequest *request) { - String response = "{\"signalplots\":["; - bool first = true; + AsyncResponseStream *response = request->beginResponseStream("application/json"); + JsonDocument doc; + JsonArray plotsArray = doc.to(); for (int i = 0; i < PROFILE_SIGNAL_PLOT_COUNT; ++i) { SignalPlot *profile = this->signalPlots[i]; if (profile) { - if (!first) - response += ","; - first = false; + JsonObject plotObj = plotsArray.add(); + plotObj["slot"] = i; + plotObj["name"] = profile->name; + plotObj["duration"] = profile->getDuration(); + plotObj["status"] = (int)profile->getCurrentStatus(); + plotObj["enabled"] = profile->enabled(); + plotObj["elapsed"] = profile->getElapsedMs(); + plotObj["remaining"] = profile->getRemainingTime(); - response += "{\"slot\":" + String(i); - response += ",\"name\":\"" + String(profile->name) + "\""; - response += ",\"duration\":" + String(profile->getDuration()); - response += ",\"status\":" + String((int)profile->getCurrentStatus()); - response += ",\"enabled\":" + String(profile->enabled() ? "true" : "false"); - response += ",\"elapsed\":" + String(profile->getElapsedMs()); - response += ",\"remaining\":" + String(profile->getRemainingTime()); - - response += ",\"controlPoints\":["; + JsonArray pointsArray = plotObj["controlPoints"].to(); const S_SignalControlPoint *points = profile->getControlPoints(); uint8_t numPoints = profile->getNumControlPoints(); for (uint8_t j = 0; j < numPoints; ++j) { - if (j > 0) - response += ","; + JsonObject pointObj = pointsArray.add(); const S_SignalControlPoint &cp = points[j]; - response += "{\"id\":" + String(cp.id); - response += ",\"time\":" + String(cp.time); - response += ",\"name\":\"" + String(cp.name) + "\""; - response += ",\"description\":\"" + String(cp.description) + "\""; - response += ",\"state\":" + String((int16_t)cp.state); - response += ",\"type\":" + String((int16_t)cp.type); - response += ",\"arg_0\":" + String(cp.arg_0); - response += ",\"arg_1\":" + String(cp.arg_1); - response += ",\"arg_2\":" + String(cp.arg_2) + "}"; + pointObj["id"] = cp.id; + pointObj["time"] = cp.time; + pointObj["name"] = cp.name; + pointObj["description"] = cp.description; + pointObj["state"] = (int16_t)cp.state; + pointObj["type"] = (int16_t)cp.type; + pointObj["arg_0"] = cp.arg_0; + pointObj["arg_1"] = cp.arg_1; + pointObj["arg_2"] = cp.arg_2; } - response += "]"; - response += ",\"children\":["; + JsonArray childrenArray = plotObj["children"].to(); const ushort *children = profile->getChildren(); for (uint8_t j = 0; j < MAX_PLOTS; j++) { - if (j > 0) - response += ","; - response += String(children[j]); + childrenArray.add(children[j]); } - response += "]}"; } } - response += "]}"; - - request->send(200, "application/json", response); + serializeJson(doc, *response); + request->send(response); } /** diff --git a/src/tmp.md b/src/tmp.md deleted file mode 100644 index f5630fba..00000000 --- a/src/tmp.md +++ /dev/null @@ -1,15 +0,0 @@ -INFO: [OmronE5[10]:630] - -commandwrite off ( device ) -OmronE5[10]::_log_binary - STATUS_HIGH(hex): 0x0100, STATUS_HIGH(bin): 0000000100000000 -INFO: OmronE5[10]::_log_binary - STATUS_LOW(hex): 0x0002, STATUS_LOW(bin): 0000000000000010 - -stop -> run - -INFO: [OmronE5[10]:630] OmronE5[10]::_log_binary - STATUS_HIGH(hex): 0x0200, STATUS_HIGH(bin): 0000001000000000 -INFO: [OmronE5[10]:630] OmronE5[10]::_log_binary - STATUS_LOW(hex): 0x0100, STATUS_LOW(bin): 0000000100000000 - -run to stop - -INFO: [OmronE5[10]:630] OmronE5[10]::_log_binary - STATUS_HIGH(hex): 0x0300, STATUS_HIGH(bin): 0000001100000000 -INFO: [OmronE5[10]:630] OmronE5[10]::_log_binary - STATUS_LOW(hex): 0x0002, STATUS_LOW(bin): 0000000000000010 diff --git a/src/version.h b/src/version.h index ee509485..07d0284a 100644 --- a/src/version.h +++ b/src/version.h @@ -1,5 +1,5 @@ #ifndef VERSION_H #define VERSION_H -#define VERSION "0.9.0|piq-last|0101cd9fa165e0f5faedd5c4e361d362093642f7" +#define VERSION "0.9.0|piq-last|06711e05bf741268fe2feb829263a10b70050385" #define PACKAGE_URL "https://polymech.info/en/resources/cassandra/" #endif \ No newline at end of file