mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
add logging class (not working version)
This commit is contained in:
46
.vscode/settings.json
vendored
46
.vscode/settings.json
vendored
@@ -2,6 +2,48 @@
|
|||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.tcc": "cpp",
|
"*.tcc": "cpp",
|
||||||
"string": "cpp",
|
"string": "cpp",
|
||||||
"functional": "cpp"
|
"functional": "cpp",
|
||||||
}
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"bitset": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"chrono": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"list": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"mutex": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"ratio": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"regex": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"typeinfo": "cpp"
|
||||||
|
},
|
||||||
|
"cmake.configureOnOpen": true
|
||||||
}
|
}
|
||||||
26
include/items/LoggingClass.h
Normal file
26
include/items/LoggingClass.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
|
class LoggingClass {
|
||||||
|
public:
|
||||||
|
LoggingClass(unsigned long period, unsigned int maxPoints, String key);
|
||||||
|
~LoggingClass();
|
||||||
|
|
||||||
|
void loop();
|
||||||
|
void writeDate();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
unsigned long currentMillis;
|
||||||
|
unsigned long prevMillis;
|
||||||
|
unsigned long difference;
|
||||||
|
|
||||||
|
unsigned long _period;
|
||||||
|
unsigned int _maxPoints;
|
||||||
|
String _key;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern std::vector<LoggingClass*> myLogging;
|
||||||
|
//extern LoggingClass* myLogging;
|
||||||
25
src/items/LoggingClass.cpp
Normal file
25
src/items/LoggingClass.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include "items/LoggingClass.h"
|
||||||
|
|
||||||
|
LoggingClass::LoggingClass(unsigned long period, unsigned int maxPoints, String key) {
|
||||||
|
_period = period;
|
||||||
|
_maxPoints = maxPoints;
|
||||||
|
_key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoggingClass::~LoggingClass() {}
|
||||||
|
|
||||||
|
void LoggingClass::loop() {
|
||||||
|
currentMillis = millis();
|
||||||
|
difference = currentMillis - prevMillis;
|
||||||
|
if (difference >= _period) {
|
||||||
|
prevMillis = millis();
|
||||||
|
writeDate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoggingClass::writeDate() {
|
||||||
|
SerialPrint("I", "Logging", _key);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<LoggingClass*> myLogging;
|
||||||
|
//LoggingClass* myLogging;
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "Utils/Timings.h"
|
#include "Utils/Timings.h"
|
||||||
#include "Utils/WebUtils.h"
|
#include "Utils/WebUtils.h"
|
||||||
#include "items/ButtonInClass.h"
|
#include "items/ButtonInClass.h"
|
||||||
|
#include "items/LoggingClass.h"
|
||||||
//#include "RemoteOrdersUdp.h"
|
//#include "RemoteOrdersUdp.h"
|
||||||
#include "Bus.h"
|
#include "Bus.h"
|
||||||
|
|
||||||
@@ -95,6 +96,9 @@ void setup() {
|
|||||||
|
|
||||||
just_load = false;
|
just_load = false;
|
||||||
initialized = true; //this second POST makes the data to be processed (you don't need to connect as "keep-alive" for that to work)
|
initialized = true; //this second POST makes the data to be processed (you don't need to connect as "keep-alive" for that to work)
|
||||||
|
|
||||||
|
myLogging = new LoggingClass[1](5000, 200, "array");
|
||||||
|
//myLogging = new LoggingClass(5000, 200, "test");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
@@ -116,4 +120,6 @@ void loop() {
|
|||||||
|
|
||||||
myNotAsyncActions->loop();
|
myNotAsyncActions->loop();
|
||||||
ts.update();
|
ts.update();
|
||||||
|
|
||||||
|
myLogging->loop();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user