mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
264 stable. Dallas bug fixed!
This commit is contained in:
@@ -24,6 +24,7 @@ class LineParsing {
|
||||
String _int;
|
||||
String _cnt;
|
||||
String _val;
|
||||
String _index;
|
||||
|
||||
public:
|
||||
LineParsing() :
|
||||
@@ -44,7 +45,8 @@ class LineParsing {
|
||||
_type{""},
|
||||
_int{""},
|
||||
_cnt{""},
|
||||
_val{""}
|
||||
_val{""},
|
||||
_index{""}
|
||||
|
||||
{};
|
||||
|
||||
@@ -98,6 +100,9 @@ class LineParsing {
|
||||
if (arg.indexOf("val[") != -1) {
|
||||
_val = extractInner(arg);
|
||||
}
|
||||
if (arg.indexOf("index[") != -1) {
|
||||
_index = extractInner(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,6 +166,10 @@ class LineParsing {
|
||||
String gval() {
|
||||
return _val;
|
||||
}
|
||||
String gindex() {
|
||||
return _index;
|
||||
}
|
||||
|
||||
|
||||
void clear() {
|
||||
_key = "";
|
||||
@@ -180,6 +189,7 @@ class LineParsing {
|
||||
_int = "";
|
||||
_cnt = "";
|
||||
_val = "";
|
||||
_index = "";
|
||||
}
|
||||
|
||||
String extractInnerDigit(String str) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "Global.h"
|
||||
|
||||
class Scenario {
|
||||
protected:
|
||||
protected:
|
||||
String _scenarioTmp;
|
||||
String _condition;
|
||||
String _conditionParam;
|
||||
@@ -15,16 +15,16 @@ class Scenario {
|
||||
String _eventParam;
|
||||
String _eventValue;
|
||||
|
||||
public:
|
||||
Scenario() : _scenarioTmp{""},
|
||||
_condition{""},
|
||||
_conditionParam{""},
|
||||
_conditionSign{""},
|
||||
_conditionValue{""},
|
||||
_scenBlok{""},
|
||||
_event{""},
|
||||
_eventParam{""},
|
||||
_eventValue{""} {};
|
||||
public:
|
||||
Scenario() : _scenarioTmp{ "" },
|
||||
_condition{ "" },
|
||||
_conditionParam{ "" },
|
||||
_conditionSign{ "" },
|
||||
_conditionValue{ "" },
|
||||
_scenBlok{ "" },
|
||||
_event{ "" },
|
||||
_eventParam{ "" },
|
||||
_eventValue{ "" } {};
|
||||
|
||||
void load() {
|
||||
_scenarioTmp = scenario;
|
||||
@@ -69,22 +69,28 @@ class Scenario {
|
||||
|
||||
if (_conditionSign == "=") {
|
||||
flag = _eventValue == _conditionValue;
|
||||
} else if (_conditionSign == "!=") {
|
||||
}
|
||||
else if (_conditionSign == "!=") {
|
||||
flag = _eventValue != _conditionValue;
|
||||
} else if (_conditionSign == "<") {
|
||||
}
|
||||
else if (_conditionSign == "<") {
|
||||
flag = _eventValue.toFloat() < _conditionValue.toFloat();
|
||||
} else if (_conditionSign == ">") {
|
||||
}
|
||||
else if (_conditionSign == ">") {
|
||||
flag = _eventValue.toFloat() > _conditionValue.toFloat();
|
||||
} else if (_conditionSign == ">=") {
|
||||
}
|
||||
else if (_conditionSign == ">=") {
|
||||
flag = _eventValue.toFloat() >= _conditionValue.toFloat();
|
||||
} else if (_conditionSign == "<=") {
|
||||
}
|
||||
else if (_conditionSign == "<=") {
|
||||
flag = _eventValue.toFloat() <= _conditionValue.toFloat();
|
||||
}
|
||||
|
||||
Serial.println("event Value: " + _eventValue);
|
||||
Serial.println("cond Value: " + _conditionValue);
|
||||
|
||||
if (flag) Serial.println("I Scenario event: " + _condition);
|
||||
if (flag) {
|
||||
//SerialPrint("I", "Scenario", "event value: " + _eventValue);
|
||||
//SerialPrint("I", "Scenario", "condition value: " + _conditionValue);
|
||||
SerialPrint("I", "Scenario", "event: " + _condition);
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
@@ -100,7 +106,12 @@ class Scenario {
|
||||
this->calculate2();
|
||||
if (this->isConditionSatisfied()) { //если вошедшее событие выполняет условие сценария
|
||||
_scenBlok = deleteBeforeDelimiter(_scenBlok, "\n");
|
||||
Serial.println(" [>] Making: " + _scenBlok);
|
||||
String forPrint = _scenBlok;
|
||||
forPrint.replace("end", "");
|
||||
forPrint.replace("\r\n", "");
|
||||
forPrint.replace("\r", "");
|
||||
forPrint.replace("\n", "");
|
||||
SerialPrint("I", "Scenario", "making: " + forPrint);
|
||||
spaceCmdExecute(_scenBlok);
|
||||
}
|
||||
}
|
||||
@@ -113,4 +124,5 @@ class Scenario {
|
||||
return jsonReadBool(configSetupJson, "scen") && eventBuf != "";
|
||||
}
|
||||
};
|
||||
|
||||
extern Scenario* myScenario;
|
||||
@@ -3,7 +3,7 @@
|
||||
//===========Firmware=============================================================================================================================================
|
||||
#ifdef ESP8266
|
||||
#define FIRMWARE_NAME "esp8266-iotm"
|
||||
#define FIRMWARE_VERSION 263
|
||||
#define FIRMWARE_VERSION 264
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
#define FIRMWARE_NAME "esp32-iotm"
|
||||
|
||||
@@ -71,7 +71,7 @@ extern int impulsEnterCounter;
|
||||
// Sensors
|
||||
extern String sensorReadingMap10sec;
|
||||
extern String sensorReadingMap30sec;
|
||||
extern int8_t dallasEnterCounter;
|
||||
|
||||
|
||||
extern String loggingKeyList;
|
||||
extern int enter_to_logging_counter;
|
||||
|
||||
@@ -10,26 +10,27 @@ class SensorDallas;
|
||||
typedef std::vector<SensorDallas> MySensorDallasVector;
|
||||
|
||||
class SensorDallas {
|
||||
public:
|
||||
public:
|
||||
|
||||
SensorDallas(unsigned long period,unsigned int pin, uint8_t deviceAddress, String key);
|
||||
SensorDallas(unsigned long interval, unsigned int pin, unsigned int index, String key);
|
||||
~SensorDallas();
|
||||
|
||||
void loop();
|
||||
void readDallas();
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
unsigned long currentMillis;
|
||||
unsigned long prevMillis;
|
||||
unsigned long _period;
|
||||
unsigned long _interval;
|
||||
String _key;
|
||||
unsigned int _pin;
|
||||
uint8_t _deviceAddress;
|
||||
|
||||
void readDallas();
|
||||
unsigned int _index;
|
||||
|
||||
};
|
||||
|
||||
extern MySensorDallasVector* mySensorDallas2;
|
||||
|
||||
extern void dallas();
|
||||
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "items/SensorConvertingClass.h"
|
||||
|
||||
extern DallasTemperature sensors;
|
||||
extern OneWire* oneWire;
|
||||
class SensorDallasClass : public SensorConvertingClass {
|
||||
public:
|
||||
SensorDallasClass() : SensorConvertingClass() {};
|
||||
|
||||
void SensorDallasInit() {
|
||||
oneWire = new OneWire((uint8_t)_pin.toInt());
|
||||
sensors.setOneWire(oneWire);
|
||||
sensors.begin();
|
||||
sensors.setResolution(48);
|
||||
|
||||
sensorReadingMap10sec += _key + ",";
|
||||
dallasEnterCounter++;
|
||||
|
||||
jsonWriteInt(configOptionJson, _key + "_num", dallasEnterCounter);
|
||||
jsonWriteStr(configOptionJson, _key + "_map", _map);
|
||||
jsonWriteStr(configOptionJson, _key + "_с", _c);
|
||||
}
|
||||
|
||||
void SensorDallasRead(String key) {
|
||||
float value;
|
||||
byte num = sensors.getDS18Count();
|
||||
sensors.requestTemperatures();
|
||||
|
||||
int cnt = jsonReadInt(configOptionJson, key + "_num");
|
||||
|
||||
for (byte i = 0; i < num; i++) {
|
||||
if (i == cnt) {
|
||||
value = sensors.getTempCByIndex(i);
|
||||
//value = this->mapping(key, value);
|
||||
float valueFl = this->correction(key, value);
|
||||
eventGen(key, "");
|
||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||
publishStatus(key, String(valueFl));
|
||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
extern SensorDallasClass mySensorDallas;
|
||||
Reference in New Issue
Block a user