#include "items/vInOutput.h" #include #include "Class/LineParsing.h" #include "Global.h" #include "BufferExecute.h" //this class save date to flash InOutput::InOutput(String key, String widget) { _key = key; String value = jsonReadStr(configStoreJson, key); if (value == "") { if (widget.indexOf("Digit") != -1) { value = "52"; } if (widget.indexOf("Time") != -1) { value = "12:00"; } } this->execute(value); } InOutput::~InOutput() {} void InOutput::execute(String value) { eventGen2(_key, value); jsonWriteStr(configStoreJson, _key, value); saveStore(); publishStatus(_key, value); } MyInOutputVector* myInOutput = nullptr; void inOutput() { myLineParsing.update(); String widget = myLineParsing.gfile(); String key = myLineParsing.gkey(); myLineParsing.clear(); inOutput_EnterCounter++; addKey(key, inOutput_KeyList, inOutput_EnterCounter); static bool firstTime = true; if (firstTime) myInOutput = new MyInOutputVector(); firstTime = false; myInOutput->push_back(InOutput(key, widget)); sCmd.addCommand(key.c_str(), inOutputExecute); } void inOutputExecute() { String key = sCmd.order(); String value = sCmd.next(); if (!isDigitStr(value)) { //если значение - текст if (value.indexOf(":") == -1) { //если этот текст не время value = getValue(value); } } int number = getKeyNum(key, inOutput_KeyList); if (myInOutput != nullptr) { if (number != -1) { myInOutput->at(number).execute(value); } } }