mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
Working version
This commit is contained in:
@@ -154,6 +154,12 @@
|
|||||||
{
|
{
|
||||||
"type": "hr"
|
"type": "hr"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "button",
|
||||||
|
"title": "Очистить графики и сбросить введенные данные",
|
||||||
|
"action": "/set?cleanlog",
|
||||||
|
"class": "btn btn-block btn-default"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "link",
|
"type": "link",
|
||||||
"title": "Ручная настройка",
|
"title": "Ручная настройка",
|
||||||
@@ -166,12 +172,6 @@
|
|||||||
"action": "https://github.com/IoTManagerProject/IoTManager/wiki",
|
"action": "https://github.com/IoTManagerProject/IoTManager/wiki",
|
||||||
"class": "btn btn-block btn-default"
|
"class": "btn btn-block btn-default"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "button",
|
|
||||||
"title": "Очистить графики и сбросить введенные данные",
|
|
||||||
"action": "/set?cleanlog",
|
|
||||||
"class": "btn btn-block btn-default"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "hr"
|
"type": "hr"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -114,3 +114,7 @@ enum ConfigType_t {
|
|||||||
//13.11.2020 (SSDP OFF, UDP OFF)
|
//13.11.2020 (SSDP OFF, UDP OFF)
|
||||||
//RAM: [===== ] 46.6% (used 38208 bytes from 81920 bytes)
|
//RAM: [===== ] 46.6% (used 38208 bytes from 81920 bytes)
|
||||||
//Flash: [===== ] 54.2% (used 566388 bytes from 1044464 bytes)
|
//Flash: [===== ] 54.2% (used 566388 bytes from 1044464 bytes)
|
||||||
|
|
||||||
|
//15.11.2020 (SSDP OFF, UDP OFF)
|
||||||
|
//RAM: [===== ] 46.1% (used 37780 bytes from 81920 bytes)
|
||||||
|
//Flash: [===== ] 54.3% (used 566656 bytes from 1044464 bytes)
|
||||||
@@ -49,3 +49,5 @@ int getOffsetInMinutes(int timezone);
|
|||||||
* Разбивает время на составляющие
|
* Разбивает время на составляющие
|
||||||
*/
|
*/
|
||||||
void breakEpochToTime(unsigned long epoch, Time_t& tm);
|
void breakEpochToTime(unsigned long epoch, Time_t& tm);
|
||||||
|
|
||||||
|
void handle_time_init();
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include "Class/LineParsing.h"
|
|
||||||
#include "Global.h"
|
|
||||||
|
|
||||||
//class InputClass : public LineParsing {
|
|
||||||
// public:
|
|
||||||
// InputClass() : LineParsing(){};
|
|
||||||
//
|
|
||||||
// void inputSetDefaultFloat() {
|
|
||||||
// inputSetFloat(_key, _state);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void inputSetDefaultStr() {
|
|
||||||
// inputSetStr(_key, _state);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void inputSetFloat(String key, String state) {
|
|
||||||
// eventGen2(key, state);
|
|
||||||
// jsonWriteFloat(configLiveJson, key, state.toFloat());
|
|
||||||
// publishStatus(key, state);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void inputSetStr(String key, String state) {
|
|
||||||
// eventGen2(key, state);
|
|
||||||
// jsonWriteStr(configLiveJson, key, state);
|
|
||||||
// publishStatus(key, state);
|
|
||||||
// }
|
|
||||||
//};
|
|
||||||
//
|
|
||||||
//extern InputClass myInput;
|
|
||||||
@@ -10,17 +10,15 @@ typedef std::vector<Input> MyInputVector;
|
|||||||
class Input {
|
class Input {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Input(String key);
|
Input(String key, String widget);
|
||||||
|
|
||||||
~Input();
|
~Input();
|
||||||
|
|
||||||
void execute(String state);
|
void execute(String value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
String _key;
|
String _key;
|
||||||
|
|
||||||
void addNewDelOldData(const String filename, size_t maxPoints, String payload);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MyInputVector* myInput;
|
extern MyInputVector* myInput;
|
||||||
|
|||||||
@@ -31,4 +31,4 @@ extern MyLoggingVector* myLogging;
|
|||||||
|
|
||||||
extern void choose_log_date_and_send();
|
extern void choose_log_date_and_send();
|
||||||
extern void sendLogData(String file, String topic);
|
extern void sendLogData(String file, String topic);
|
||||||
extern void clean_log_date();
|
extern void cleanLogAndData();
|
||||||
|
|||||||
@@ -45,12 +45,9 @@ void csvCmdExecute(String& cmdStr) {
|
|||||||
else if (order == F("button-in")) {
|
else if (order == F("button-in")) {
|
||||||
sCmd.addCommand(order.c_str(), buttonIn);
|
sCmd.addCommand(order.c_str(), buttonIn);
|
||||||
}
|
}
|
||||||
else if (order == F("input-digit")) {
|
else if (order == F("input")) {
|
||||||
sCmd.addCommand(order.c_str(), input);
|
sCmd.addCommand(order.c_str(), input);
|
||||||
}
|
}
|
||||||
else if (order == F("input-time")) {
|
|
||||||
//sCmd.addCommand(order.c_str(), inputTime);
|
|
||||||
}
|
|
||||||
else if (order == F("output-text")) {
|
else if (order == F("output-text")) {
|
||||||
sCmd.addCommand(order.c_str(), textOut);
|
sCmd.addCommand(order.c_str(), textOut);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ void addPreset(String name) {
|
|||||||
void delAllItems() {
|
void delAllItems() {
|
||||||
removeFile(DEVICE_CONFIG_FILE);
|
removeFile(DEVICE_CONFIG_FILE);
|
||||||
addFile(DEVICE_CONFIG_FILE, String(firstLine));
|
addFile(DEVICE_CONFIG_FILE, String(firstLine));
|
||||||
|
removeFile(DEVICE_SCENARIO_FILE);
|
||||||
|
addFile(DEVICE_SCENARIO_FILE, "//");
|
||||||
removeFile("id.txt");
|
removeFile("id.txt");
|
||||||
removeFile("order.txt");
|
removeFile("order.txt");
|
||||||
removeFile("pins.txt");
|
removeFile("pins.txt");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "Utils/TimeUtils.h"
|
#include "Utils/TimeUtils.h"
|
||||||
|
#include "Global.h"
|
||||||
#include "Utils/StringUtils.h"
|
#include "Utils/StringUtils.h"
|
||||||
|
|
||||||
static const uint8_t days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
static const uint8_t days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||||
@@ -211,3 +211,17 @@ void breakEpochToTime(unsigned long epoch, Time_t& tm) {
|
|||||||
tm.day_of_month = time + 1; // day of month
|
tm.day_of_month = time + 1; // day of month
|
||||||
tm.valid = (epoch > MIN_DATETIME);
|
tm.valid = (epoch > MIN_DATETIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handle_time_init() {
|
||||||
|
ts.add(
|
||||||
|
TIME, 1000, [&](void*) {
|
||||||
|
String timenow = timeNow->getTimeWOsec();
|
||||||
|
static String prevTime;
|
||||||
|
if (prevTime != timenow) {
|
||||||
|
prevTime = timenow;
|
||||||
|
jsonWriteStr(configLiveJson, "timenow", timenow);
|
||||||
|
eventGen2("timenow", timenow);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
nullptr, true);
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ void web_init() {
|
|||||||
|
|
||||||
#ifdef LOGGING_ENABLED
|
#ifdef LOGGING_ENABLED
|
||||||
if (request->hasArg("cleanlog")) {
|
if (request->hasArg("cleanlog")) {
|
||||||
clean_log_date();
|
cleanLogAndData();
|
||||||
request->send(200);
|
request->send(200);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
//#include "BufferExecute.h"
|
|
||||||
//#include "items/InputClass.h"
|
|
||||||
////==========================================Модуль ввода цифровых значений==================================
|
|
||||||
////input-digit digit1 inputDigit Ввод Введите.цифру 4 st[60]
|
|
||||||
////==========================================================================================================
|
|
||||||
//InputClass myInputDigit;
|
|
||||||
//void inputDigit() {
|
|
||||||
// myInputDigit.update();
|
|
||||||
// String key = myInputDigit.gkey();
|
|
||||||
// sCmd.addCommand(key.c_str(), inputDigitSet);
|
|
||||||
// myInputDigit.inputSetDefaultFloat();
|
|
||||||
// myInputDigit.clear();
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void inputDigitSet() {
|
|
||||||
// String key = sCmd.order();
|
|
||||||
// String state = sCmd.next();
|
|
||||||
// myInputDigit.inputSetFloat(key, state);
|
|
||||||
//}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#include "BufferExecute.h"
|
|
||||||
#include "items/InputClass.h"
|
|
||||||
//==========================================Модуль ввода времени============================================
|
|
||||||
//==========================================================================================================
|
|
||||||
//InputClass myInputTime;
|
|
||||||
//void inputTime() {
|
|
||||||
// myInputTime.update();
|
|
||||||
// String key = myInputTime.gkey();
|
|
||||||
// sCmd.addCommand(key.c_str(), inputTimeSet);
|
|
||||||
// myInputTime.inputSetDefaultStr();
|
|
||||||
// myInputTime.clear();
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//void inputTimeSet() {
|
|
||||||
// String key = sCmd.order();
|
|
||||||
// String state = sCmd.next();
|
|
||||||
// myInputTime.inputSetStr(key, state);
|
|
||||||
//}
|
|
||||||
|
|
||||||
void handle_time_init() {
|
|
||||||
ts.add(
|
|
||||||
TIME, 1000, [&](void*) {
|
|
||||||
String timenow = timeNow->getTimeWOsec();
|
|
||||||
static String prevTime;
|
|
||||||
if (prevTime != timenow) {
|
|
||||||
prevTime = timenow;
|
|
||||||
jsonWriteStr(configLiveJson, "timenow", timenow);
|
|
||||||
eventGen2("timenow", timenow);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
nullptr, true);
|
|
||||||
}
|
|
||||||
@@ -6,24 +6,35 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "BufferExecute.h"
|
#include "BufferExecute.h"
|
||||||
|
|
||||||
Input::Input(String key) {
|
Input::Input(String key, String widget) {
|
||||||
_key = key;
|
_key = key;
|
||||||
String value = jsonReadStr(configLiveJson, key);
|
String value = jsonReadStr(configLiveJson, key);
|
||||||
|
|
||||||
|
if (value == "") {
|
||||||
|
if (widget.indexOf("Digit") != -1) {
|
||||||
|
value = "52";
|
||||||
|
}
|
||||||
|
if (widget.indexOf("Time") != -1) {
|
||||||
|
value = "12:00";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->execute(value);
|
this->execute(value);
|
||||||
}
|
}
|
||||||
Input::~Input() {}
|
Input::~Input() {}
|
||||||
|
|
||||||
void Input::execute(String state) {
|
void Input::execute(String value) {
|
||||||
eventGen2(_key, state);
|
eventGen2(_key, value);
|
||||||
jsonWriteInt(configLiveJson, _key, state.toInt());
|
jsonWriteStr(configLiveJson, _key, value);
|
||||||
saveLive();
|
saveLive();
|
||||||
publishStatus(_key, state);
|
publishStatus(_key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
MyInputVector* myInput = nullptr;
|
MyInputVector* myInput = nullptr;
|
||||||
|
|
||||||
void input() {
|
void input() {
|
||||||
myLineParsing.update();
|
myLineParsing.update();
|
||||||
|
String widget = myLineParsing.gfile();
|
||||||
String key = myLineParsing.gkey();
|
String key = myLineParsing.gkey();
|
||||||
myLineParsing.clear();
|
myLineParsing.clear();
|
||||||
|
|
||||||
@@ -33,20 +44,20 @@ void input() {
|
|||||||
static bool firstTime = true;
|
static bool firstTime = true;
|
||||||
if (firstTime) myInput = new MyInputVector();
|
if (firstTime) myInput = new MyInputVector();
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
myInput->push_back(Input(key));
|
myInput->push_back(Input(key, widget));
|
||||||
|
|
||||||
sCmd.addCommand(key.c_str(), inputExecute);
|
sCmd.addCommand(key.c_str(), inputExecute);
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputExecute() {
|
void inputExecute() {
|
||||||
String key = sCmd.order();
|
String key = sCmd.order();
|
||||||
String state = sCmd.next();
|
String value = sCmd.next();
|
||||||
|
|
||||||
int number = getKeyNum(key, input_KeyList);
|
int number = getKeyNum(key, input_KeyList);
|
||||||
|
|
||||||
if (myInput != nullptr) {
|
if (myInput != nullptr) {
|
||||||
if (number != -1) {
|
if (number != -1) {
|
||||||
myInput->at(number).execute(state);
|
myInput->at(number).execute(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ void sendLogData(String file, String topic) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clean_log_date() {
|
void cleanLogAndData() {
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
auto dir = LittleFS.openDir("logs");
|
auto dir = LittleFS.openDir("logs");
|
||||||
while (dir.next()) {
|
while (dir.next()) {
|
||||||
@@ -121,5 +121,6 @@ void clean_log_date() {
|
|||||||
removeFile("logs/" + fname);
|
removeFile("logs/" + fname);
|
||||||
}
|
}
|
||||||
removeFile("live.json");
|
removeFile("live.json");
|
||||||
|
configLiveJson = "";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user