mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
stability of san
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
//===========Firmware=============================================================================================================================================
|
||||
#define FIRMWARE_VERSION 271
|
||||
//#define FLASH_SIZE_1MB
|
||||
//#define FLASH_SIZE_1MB true
|
||||
#ifdef ESP8266
|
||||
#define FIRMWARE_NAME "esp8266-iotm"
|
||||
#endif
|
||||
@@ -121,4 +121,10 @@ enum ConfigType_t {
|
||||
//Flash: [===== ] 54.5% (used 569296 bytes from 1044464 bytes)
|
||||
|
||||
//RAM: [===== ] 45.6% (used 37336 bytes from 81920 bytes)
|
||||
//Flash: [====== ] 55.3% (used 577396 bytes from 1044464 bytes)
|
||||
//Flash: [====== ] 55.3% (used 577396 bytes from 1044464 bytes)
|
||||
|
||||
|
||||
//eventBuf - буфер событий которые проверяются в сценариях,
|
||||
//и если событие удовлетворяет какому нибудь условию то выполняются указанные команды
|
||||
|
||||
//orderBuf - буфер команд которые выполняются сейчас же
|
||||
@@ -17,6 +17,7 @@ boolean publishChart(const String& topic, const String& data);
|
||||
boolean publishControl(String id, String topic, String state);
|
||||
boolean publishChart_test(const String& topic, const String& data);
|
||||
boolean publishStatus(const String& topic, const String& data);
|
||||
boolean publishEvent(const String& topic, const String& data);
|
||||
boolean publishInfo(const String& topic, const String& data);
|
||||
|
||||
void publishWidgets();
|
||||
|
||||
@@ -1,83 +1,85 @@
|
||||
//#pragma once
|
||||
//#include <Arduino.h>
|
||||
//#include <ModbusMaster.h>
|
||||
//#include <SoftwareSerial.h>
|
||||
//
|
||||
//#include "Class/LineParsing.h"
|
||||
//#include "Global.h"
|
||||
//#include "items/SensorConvertingClass.h"
|
||||
//
|
||||
//ModbusMaster modbus1;
|
||||
//SoftwareSerial uart(13, 12); // RX, TX
|
||||
//
|
||||
//class SensorModbusClass : public SensorConvertingClass {
|
||||
// public:
|
||||
// SensorModbusClass() : SensorConvertingClass(){};
|
||||
//
|
||||
// void SensorModbusInit() {
|
||||
// uart.begin(9600);
|
||||
// jsonWriteStr(configOptionJson, _key + "_map", _map);
|
||||
// jsonWriteStr(configOptionJson, _key + "_с", _c);
|
||||
// sensorReadingMap10sec += _key + " " + _addr + " " + _reg + ",";
|
||||
// Serial.println(sensorReadingMap10sec);
|
||||
// }
|
||||
//
|
||||
// void SensorModbusRead(String key, uint8_t slaveAddress, uint16_t regAddress) {
|
||||
// int value;
|
||||
//
|
||||
// modbus1.begin(slaveAddress, uart);
|
||||
// uint16_t reqisterValue = modbus1.readHoldingRegisters(regAddress, 1);
|
||||
// if (getResultMsg(&modbus1, reqisterValue)) {
|
||||
// reqisterValue = modbus1.getResponseBuffer(0);
|
||||
// value = reqisterValue;
|
||||
// } else {
|
||||
// value = NULL;
|
||||
// }
|
||||
//
|
||||
// int valueFl = this->correction(key, value);
|
||||
// eventGen2(key, String(valueFl));
|
||||
// jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||
// publishStatus(key, String(valueFl));
|
||||
// SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl) + ", Slave dev addr: " + String(slaveAddress) + ", Register: " + String(regAddress));
|
||||
// }
|
||||
//
|
||||
// bool getResultMsg(ModbusMaster* modbus1, uint16_t result) {
|
||||
// String tmpstr;
|
||||
// switch (result) {
|
||||
// case modbus1->ku8MBSuccess:
|
||||
// return true;
|
||||
// tmpstr += "Ok";
|
||||
// break;
|
||||
// case modbus1->ku8MBIllegalFunction:
|
||||
// tmpstr += "Illegal Function";
|
||||
// break;
|
||||
// case modbus1->ku8MBIllegalDataAddress:
|
||||
// tmpstr += "Illegal Data Address";
|
||||
// break;
|
||||
// case modbus1->ku8MBIllegalDataValue:
|
||||
// tmpstr += "Illegal Data Value";
|
||||
// break;
|
||||
// case modbus1->ku8MBSlaveDeviceFailure:
|
||||
// tmpstr += "Slave Device Failure";
|
||||
// break;
|
||||
// case modbus1->ku8MBInvalidSlaveID:
|
||||
// tmpstr += "Invalid Slave ID";
|
||||
// break;
|
||||
// case modbus1->ku8MBInvalidFunction:
|
||||
// tmpstr += "Invalid Function";
|
||||
// break;
|
||||
// case modbus1->ku8MBResponseTimedOut:
|
||||
// tmpstr += "Response Timed Out";
|
||||
// break;
|
||||
// case modbus1->ku8MBInvalidCRC:
|
||||
// tmpstr += "Invalid CRC";
|
||||
// break;
|
||||
// default:
|
||||
// tmpstr += "Unknown error: " + String(result);
|
||||
// break;
|
||||
// }
|
||||
// SerialPrint("I", "Modbus", tmpstr);
|
||||
// return false;
|
||||
// }
|
||||
//};
|
||||
//extern SensorModbusClass mySensorModbus;
|
||||
#ifdef modbus
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include <ModbusMaster.h>
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "items/SensorConvertingClass.h"
|
||||
|
||||
ModbusMaster modbus1;
|
||||
SoftwareSerial uart(13, 12); // RX, TX
|
||||
|
||||
class SensorModbusClass : public SensorConvertingClass {
|
||||
public:
|
||||
SensorModbusClass() : SensorConvertingClass(){};
|
||||
|
||||
void SensorModbusInit() {
|
||||
uart.begin(9600);
|
||||
jsonWriteStr(configOptionJson, _key + "_map", _map);
|
||||
jsonWriteStr(configOptionJson, _key + "_с", _c);
|
||||
sensorReadingMap10sec += _key + " " + _addr + " " + _reg + ",";
|
||||
Serial.println(sensorReadingMap10sec);
|
||||
}
|
||||
|
||||
void SensorModbusRead(String key, uint8_t slaveAddress, uint16_t regAddress) {
|
||||
int value;
|
||||
|
||||
modbus1.begin(slaveAddress, uart);
|
||||
uint16_t reqisterValue = modbus1.readHoldingRegisters(regAddress, 1);
|
||||
if (getResultMsg(&modbus1, reqisterValue)) {
|
||||
reqisterValue = modbus1.getResponseBuffer(0);
|
||||
value = reqisterValue;
|
||||
} else {
|
||||
value = NULL;
|
||||
}
|
||||
|
||||
int valueFl = this->correction(key, value);
|
||||
eventGen2(key, String(valueFl));
|
||||
jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||
publishStatus(key, String(valueFl));
|
||||
SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl) + ", Slave dev addr: " + String(slaveAddress) + ", Register: " + String(regAddress));
|
||||
}
|
||||
|
||||
bool getResultMsg(ModbusMaster* modbus1, uint16_t result) {
|
||||
String tmpstr;
|
||||
switch (result) {
|
||||
case modbus1->ku8MBSuccess:
|
||||
return true;
|
||||
tmpstr += "Ok";
|
||||
break;
|
||||
case modbus1->ku8MBIllegalFunction:
|
||||
tmpstr += "Illegal Function";
|
||||
break;
|
||||
case modbus1->ku8MBIllegalDataAddress:
|
||||
tmpstr += "Illegal Data Address";
|
||||
break;
|
||||
case modbus1->ku8MBIllegalDataValue:
|
||||
tmpstr += "Illegal Data Value";
|
||||
break;
|
||||
case modbus1->ku8MBSlaveDeviceFailure:
|
||||
tmpstr += "Slave Device Failure";
|
||||
break;
|
||||
case modbus1->ku8MBInvalidSlaveID:
|
||||
tmpstr += "Invalid Slave ID";
|
||||
break;
|
||||
case modbus1->ku8MBInvalidFunction:
|
||||
tmpstr += "Invalid Function";
|
||||
break;
|
||||
case modbus1->ku8MBResponseTimedOut:
|
||||
tmpstr += "Response Timed Out";
|
||||
break;
|
||||
case modbus1->ku8MBInvalidCRC:
|
||||
tmpstr += "Invalid CRC";
|
||||
break;
|
||||
default:
|
||||
tmpstr += "Unknown error: " + String(result);
|
||||
break;
|
||||
}
|
||||
SerialPrint("I", "Modbus", tmpstr);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
extern SensorModbusClass mySensorModbus;
|
||||
#endif
|
||||
@@ -1,49 +0,0 @@
|
||||
//#pragma once
|
||||
//#include <Arduino.h>
|
||||
//
|
||||
//#include "Class/LineParsing.h"
|
||||
//#include "Global.h"
|
||||
//#include "items/SensorConvertingClass.h"
|
||||
//#include "GyverFilters.h"
|
||||
//
|
||||
//GMedian<6, int> testFilter;
|
||||
//
|
||||
//class SensorUltrasonic : public SensorConvertingClass {
|
||||
// public:
|
||||
// SensorUltrasonic() : SensorConvertingClass(){};
|
||||
// void init() {
|
||||
// sensorReadingMap10sec += _key + ",";
|
||||
// String trig = selectFromMarkerToMarker(_pin, ",", 0);
|
||||
// String echo = selectFromMarkerToMarker(_pin, ",", 1);
|
||||
// pinMode(trig.toInt(), OUTPUT);
|
||||
// pinMode(echo.toInt(), INPUT);
|
||||
// jsonWriteStr(configOptionJson, _key + "_trig", trig);
|
||||
// jsonWriteStr(configOptionJson, _key + "_echo", echo);
|
||||
// jsonWriteStr(configOptionJson, _key + "_map", _map);
|
||||
// jsonWriteStr(configOptionJson, _key + "_с", _c);
|
||||
// }
|
||||
//
|
||||
// void SensorUltrasonicRead(String key) {
|
||||
// int trig = jsonReadStr(configOptionJson, key + "_trig").toInt();
|
||||
// int echo = jsonReadStr(configOptionJson, key + "_echo").toInt();
|
||||
// int value;
|
||||
//
|
||||
// digitalWrite(trig, LOW);
|
||||
// delayMicroseconds(2);
|
||||
// digitalWrite(trig, HIGH);
|
||||
// delayMicroseconds(10);
|
||||
// digitalWrite(trig, LOW);
|
||||
// long duration_ = pulseIn(echo, HIGH, 30000); // 3000 µs = 50cm // 30000 µs = 5 m
|
||||
// value = duration_ / 29 / 2;
|
||||
//
|
||||
// value = testFilter.filtered(value);
|
||||
//
|
||||
// value = this->mapping(key, value);
|
||||
// float valueFl = this->correction(key, value);
|
||||
// eventGen2(key, String(valueFl));
|
||||
// jsonWriteStr(configLiveJson, key, String(valueFl));
|
||||
// publishStatus(key, String(valueFl));
|
||||
// SerialPrint("I", "Sensor", "'" + key + "' data: " + String(valueFl));
|
||||
// }
|
||||
//};
|
||||
//extern SensorUltrasonic mySensorUltrasonic;
|
||||
@@ -8,8 +8,6 @@ class SensorUltrasonic;
|
||||
|
||||
typedef std::vector<SensorUltrasonic> MySensorUltrasonicVector;
|
||||
|
||||
|
||||
|
||||
class SensorUltrasonic : public SensorConvertingClass {
|
||||
public:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user