Skip to content

Commit

Permalink
[Imp] Bessere Dokumentierung der Laufzeiten der Loop-Anweisungen
Browse files Browse the repository at this point in the history
  • Loading branch information
littleyoda committed Apr 11, 2020
1 parent e04b318 commit dd9e78f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 27 deletions.
43 changes: 19 additions & 24 deletions decoder/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions decoder/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
2 changes: 1 addition & 1 deletion decoder/InternalStatusAsJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit dd9e78f

Please sign in to comment.