From dd9e78f96b66066be94f5bf8d84c095d279ded5a Mon Sep 17 00:00:00 2001 From: Sven Bursch-Osewold Date: Sat, 11 Apr 2020 17:32:45 +0200 Subject: [PATCH] [Imp] Bessere Dokumentierung der Laufzeiten der Loop-Anweisungen --- decoder/Controller.cpp | 43 ++++++++++++++------------------ decoder/Controller.h | 4 +-- decoder/InternalStatusAsJson.cpp | 2 +- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/decoder/Controller.cpp b/decoder/Controller.cpp index 2d57a5a..daab72e 100644 --- a/decoder/Controller.cpp +++ b/decoder/Controller.cpp @@ -51,15 +51,18 @@ void Controller::doLoops() { nextRun.add(0); } // Run and save the new execute time - unsigned long now = millis(); + unsigned long loopstarted = millis(); for (idx = 0; idx < loops.size(); idx++) { - if (nextRun.get(idx) <= now) { - int wait = loops.get(idx)->loop(); - nextRun.set(idx, millis() + wait); + if (nextRun.get(idx) <= loopstarted) { +// unsigned long started = millis(); + ILoop* loop = loops.get(idx); + int wait = loop ->loop(); +// unsigned long stopped = millis(); + nextRun.set(idx, loopstarted + wait); } delay(0); } - logLoop(millis() - now); + logLoop(millis() - loopstarted); if (dnsServer) { dnsServer->processNextRequest(); @@ -364,25 +367,10 @@ void Controller::sendContent(String s) { } void Controller::logLoop(unsigned long now) { -// if (now > 99) { -// now = 99; -// } -// l[now]++; -// if (next <= millis()) { -// Serial.print(" 0: "); -// for (int i = 0; i < 99; i++) { -// Serial.printf(" %7d", l[i]); -// if (i % 10 == 9) { -// Serial.printf("\r\n%2d: ", (i + 1)); -// } -// } -// Serial.println(); -// next = millis() + 5000; -// } -// if (now > longestLoop) { -// longestLoop = now; -// Serial.println("Gesamt " + String(longestLoop)); -// } + if (now > 99) { + now = 99; + } + l[now]++; } String Controller::getInternalStatus(String modul, String key) { @@ -446,6 +434,13 @@ void Controller::internalStatusObjStatus(IInternalStatusCallback* cb, String mod } } } + if (modul.equals("timing") || modul.equals("*")) { + for (int idx = 0; idx < 100; idx++) { + if (l[idx] > 0) { + cb->send("timing", String(idx) , String(l[idx])); + } + } + } } Controller::Items* Controller::getLocData() { diff --git a/decoder/Controller.h b/decoder/Controller.h index 5e212d2..f3c908a 100644 --- a/decoder/Controller.h +++ b/decoder/Controller.h @@ -120,8 +120,8 @@ class Controller { void logLoop(unsigned long d); InternalStatusAsString statusAsString; InternalStatusAsJson statusAsJson; -// unsigned int l[100]; -// unsigned long next; + unsigned int l[100]; + unsigned long next; }; #endif /* CONTROLLER_H_ */ diff --git a/decoder/InternalStatusAsJson.cpp b/decoder/InternalStatusAsJson.cpp index 83ee716..eb4fc7a 100644 --- a/decoder/InternalStatusAsJson.cpp +++ b/decoder/InternalStatusAsJson.cpp @@ -20,7 +20,7 @@ void InternalStatusAsJson::reset() { delete(doc); } doc = new DynamicJsonDocument(2048); - (*doc)["Hallo"] = "Hallo"; + (*doc)["version"] = "1"; } void InternalStatusAsJson::send(String modul, String key, String value) {