mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-19 19:49:42 +08:00
任立新 温控系统
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -21,3 +21,5 @@
|
|||||||
/othersoft/movingliner/cmake-build-release/
|
/othersoft/movingliner/cmake-build-release/
|
||||||
/othersoft/TemperatureControler/project/cmake-build-debug/
|
/othersoft/TemperatureControler/project/cmake-build-debug/
|
||||||
/othersoft/calibration_console/cmake-build-debug/
|
/othersoft/calibration_console/cmake-build-debug/
|
||||||
|
/othersoft/TemperatureControler/project/cmake-build-debug-towersif/
|
||||||
|
/othersoft/TemperatureControler/project/cmake-build-debug-towersif/
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.3)
|
|
||||||
|
|
||||||
project(TowerOptoSifAndSpectral)
|
|
||||||
set(CMAKE_AUTOMOC ON)
|
|
||||||
set(CMAKE_AUTOUIC ON)
|
|
||||||
set(CMAKE_AUTORCC ON)
|
|
||||||
set(QT Core Network WebSockets SerialPort Widgets)
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
|
||||||
|
|
||||||
find_package(Qt5 REQUIRED ${QT})
|
|
||||||
|
|
||||||
|
|
||||||
file(GLOB_RECURSE HDR_LIST "source/*.h")
|
|
||||||
file(GLOB_RECURSE SRC_LIST "source/*.cpp")
|
|
||||||
|
|
||||||
include_directories("source")
|
|
||||||
include_directories("source/FS")
|
|
||||||
include_directories("source/Logger")
|
|
||||||
include_directories("source/ZZ_SDK")
|
|
||||||
include_directories("source/Settings")
|
|
||||||
include_directories("source/CaptureThread")
|
|
||||||
include_directories("source/LinearShutter")
|
|
||||||
include_directories("source/OSIF/include")
|
|
||||||
include_directories("source/Misc_Detector")
|
|
||||||
include_directories("source/Uploader")
|
|
||||||
|
|
||||||
link_directories("source/OSIF/DLib")
|
|
||||||
link_directories("/home/pi/SeaBrease/lib")
|
|
||||||
add_executable( TowerOptoSifAndSpectral
|
|
||||||
main.cpp
|
|
||||||
${HDR_LIST}
|
|
||||||
${SRC_LIST}
|
|
||||||
)
|
|
||||||
IF (WIN32)
|
|
||||||
target_link_libraries(TowerOptoSifAndSpectral SeaBreeze)
|
|
||||||
ELSE ()
|
|
||||||
target_link_libraries(TowerOptoSifAndSpectral seabreeze usb stdc++ m)
|
|
||||||
ENDIF ()
|
|
||||||
qt5_use_modules(TowerOptoSifAndSpectral ${QT})
|
|
||||||
set_target_properties(TowerOptoSifAndSpectral PROPERTIES AUTOMOC ON)
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"TimeConfig": {
|
||||||
|
"StartTime": "00:00:00",
|
||||||
|
"EndTime": "23:59:00",
|
||||||
|
"IntervalTime": 10
|
||||||
|
},
|
||||||
|
"TemperatureConfig": {
|
||||||
|
"PortName": "ttyS2",
|
||||||
|
"BaudRate": 115200,
|
||||||
|
"Pin": {
|
||||||
|
"TG": {
|
||||||
|
"Pin_H": 7,
|
||||||
|
"Pin_L": 10
|
||||||
|
},
|
||||||
|
"Fan": {
|
||||||
|
"Pin": 11
|
||||||
|
},
|
||||||
|
"HOT": {
|
||||||
|
"Pin": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Constant_Temperature": {
|
||||||
|
"MaxTemp": 35,
|
||||||
|
"MinTemp": 30
|
||||||
|
},
|
||||||
|
"Temperature": {
|
||||||
|
"index_x": 0,
|
||||||
|
"index_y": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -10,13 +10,14 @@ include_directories("../src/json")
|
|||||||
include_directories("../src/TimeWorker")
|
include_directories("../src/TimeWorker")
|
||||||
include_directories("../src/Temperature")
|
include_directories("../src/Temperature")
|
||||||
include_directories("../src/controler")
|
include_directories("../src/controler")
|
||||||
|
set(CMAKE_MOC_VERBOSE TRUE)
|
||||||
add_executable(TemperatureControler
|
add_executable(TemperatureControler
|
||||||
tempmain.cpp
|
tempmain.cpp
|
||||||
../src/TimeWorker/TimeWorker.cpp
|
../src/TimeWorker/TimeWorker.cpp
|
||||||
../src/json/logout.cpp
|
../src/json/logout.cpp
|
||||||
../src/Temperature/TemperaTureWoker.cpp
|
../src/Temperature/TemperaTureWoker.cpp
|
||||||
../src/controler/controler.cpp
|
../src/Temperature/TG_Manager.cpp
|
||||||
|
../src/Temperature/TemperatureRegulator.cpp
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"TimeConfig": {
|
||||||
|
"StartTime": "00:00:00",
|
||||||
|
"EndTime": "23:59:00",
|
||||||
|
"IntervalTime": 10
|
||||||
|
},
|
||||||
|
"TemperatureConfig": {
|
||||||
|
"PortName": "ttyS2",
|
||||||
|
"BaudRate": 115200,
|
||||||
|
"Pin": {
|
||||||
|
"TG": {
|
||||||
|
"Pin_H": 7,
|
||||||
|
"Pin_L": 10
|
||||||
|
},
|
||||||
|
"Fan": {
|
||||||
|
"Pin": 11
|
||||||
|
},
|
||||||
|
"HOT": {
|
||||||
|
"Pin": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Constant_Temperature": {
|
||||||
|
"MaxTemp": 35,
|
||||||
|
"MinTemp": 30
|
||||||
|
},
|
||||||
|
"Temperature": {
|
||||||
|
"index_x": 0,
|
||||||
|
"index_y": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,14 +2,31 @@
|
|||||||
// Created by xin on 24-12-11.
|
// Created by xin on 24-12-11.
|
||||||
//
|
//
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <TemperaTureWoker.h>
|
#include <TemperatureRegulator.h>
|
||||||
|
#include <TimeWorker.h>
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <qthread.h>
|
#include <qthread.h>
|
||||||
|
#include <fstream>
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication aaaaa(argc, argv);
|
QCoreApplication aaaaa(argc, argv);
|
||||||
std::cout<<"Hello World";
|
std::cout<<"Hello World"<<std::flush;
|
||||||
TemperaTureWoker *pTemperaTureWoker = new TemperaTureWoker();
|
json j;
|
||||||
|
std::ifstream i("/home/data/Setting/Constant_Temperature_Config.json");
|
||||||
|
|
||||||
|
|
||||||
|
i>>j;
|
||||||
|
json timeconfig=j["TimeConfig"];
|
||||||
|
json tempconfig=j["TemperatureConfig"];
|
||||||
|
TemperatureRegulator *temperature_regulator=new TemperatureRegulator();
|
||||||
|
temperature_regulator->setconfig(tempconfig);
|
||||||
|
TimeWorker *timeWorker=new TimeWorker();
|
||||||
|
timeWorker->ReadConfig(timeconfig);
|
||||||
|
timeWorker->SetTask(TemperatureRegulator::looptask);
|
||||||
|
timeWorker->Start();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
137
othersoft/TemperatureControler/src/Temperature/TG_Manager.cpp
Normal file
137
othersoft/TemperatureControler/src/Temperature/TG_Manager.cpp
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
//
|
||||||
|
// Created by xin on 25-3-31.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "TG_Manager.h"
|
||||||
|
#include "string"
|
||||||
|
void TG_Manager::SetPin(int pin1_H, int pin1_L, int pin2_H, int pin2_L)
|
||||||
|
{
|
||||||
|
this->pin1_H = pin1_H;
|
||||||
|
this->pin1_L = pin1_L;
|
||||||
|
this->pin2_H = pin2_H;
|
||||||
|
this->pin2_L = pin2_L;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TG_Manager::SetTuiGan(int IS_High)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (IS_High)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
{std::string comand1 = "gpio write " + std::to_string(pin1_H) + " 0";
|
||||||
|
std::string comand2 = "gpio write " + std::to_string(pin1_L) + " 0";
|
||||||
|
system(comand1.c_str());
|
||||||
|
system(comand2.c_str());
|
||||||
|
break;}
|
||||||
|
case 1:
|
||||||
|
{std::string comand3 = "gpio write " + std::to_string(pin1_H) + " 1";
|
||||||
|
std::string comand4 = "gpio write " + std::to_string(pin1_L) + " 0";
|
||||||
|
system(comand3.c_str());
|
||||||
|
system(comand4.c_str());
|
||||||
|
break;}
|
||||||
|
case 0:
|
||||||
|
{std::string comand3 = "gpio write " + std::to_string(pin1_H) + " 0";
|
||||||
|
std::string comand4 = "gpio write " + std::to_string(pin1_L) + " 1";
|
||||||
|
system(comand3.c_str());
|
||||||
|
system(comand4.c_str());
|
||||||
|
break;}
|
||||||
|
default:
|
||||||
|
{std::string comand1 = "gpio write " + std::to_string(pin1_H) + " 0";
|
||||||
|
std::string comand2 = "gpio write " + std::to_string(pin1_L) + " 0";
|
||||||
|
system(comand1.c_str());
|
||||||
|
system(comand2.c_str());
|
||||||
|
break;}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_High)
|
||||||
|
{
|
||||||
|
std::string comand1 = "gpio write " + std::to_string(pin1_H) + " 1";
|
||||||
|
std::string comand2 = "gpio write " + std::to_string(pin1_L) + " 0";
|
||||||
|
system(comand1.c_str());
|
||||||
|
system(comand2.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string comand1 = "gpio write " + std::to_string(pin1_H) + " 0";
|
||||||
|
std::string comand2 = "gpio write " + std::to_string(pin1_L) + " 1";
|
||||||
|
system(comand1.c_str());
|
||||||
|
system(comand2.c_str());
|
||||||
|
}
|
||||||
|
return IS_High;
|
||||||
|
}
|
||||||
|
void TG_Manager::InitManger()
|
||||||
|
{
|
||||||
|
std::string comand1 = "gpio mode " + std::to_string(pin1_H) + " out";
|
||||||
|
std::string comand2 = "gpio mode " + std::to_string(pin1_L) + " out";
|
||||||
|
std::string comand3 = "gpio mode " + std::to_string(pin2_H) + " out";
|
||||||
|
std::string comand4 = "gpio mode " + std::to_string(pin2_L) + " out";
|
||||||
|
system(comand1.c_str());
|
||||||
|
system(comand2.c_str());
|
||||||
|
system(comand3.c_str());
|
||||||
|
system(comand4.c_str());
|
||||||
|
SetTuiGan(0);
|
||||||
|
SetSwitch1Status(0);
|
||||||
|
SetSwitch2Status(0);
|
||||||
|
}
|
||||||
|
bool TG_Manager::SetSwitch1Status(bool status)
|
||||||
|
{
|
||||||
|
if (status)
|
||||||
|
{
|
||||||
|
std::string comand1 = "gpio write " + std::to_string(pin2_H) + " 1";
|
||||||
|
system(comand1.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string comand1 = "gpio write " + std::to_string(pin2_H) + " 0";
|
||||||
|
system(comand1.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
bool TG_Manager::SetSwitch2Status(bool status)
|
||||||
|
{
|
||||||
|
if (status)
|
||||||
|
{
|
||||||
|
std::string comand1 = "gpio write " + std::to_string(pin2_L) + " 1";
|
||||||
|
system(comand1.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string comand1 = "gpio write " + std::to_string(pin2_L) + " 0";
|
||||||
|
system(comand1.c_str());
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TG_Manager::Heating()
|
||||||
|
{
|
||||||
|
printf("Heating\n");
|
||||||
|
SetTuiGan(true);
|
||||||
|
SetSwitch1Status(true);
|
||||||
|
SetSwitch2Status(false);
|
||||||
|
WorkingStatus = HEATING;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool TG_Manager::Cooling()
|
||||||
|
{
|
||||||
|
printf("Cooling\n");
|
||||||
|
SetTuiGan(false);
|
||||||
|
SetSwitch1Status(false);
|
||||||
|
SetSwitch2Status(true);
|
||||||
|
WorkingStatus = COOLING;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TG_Manager::Stop(){
|
||||||
|
SetTuiGan(2);
|
||||||
|
SetSwitch1Status(false);
|
||||||
|
SetSwitch2Status(false);
|
||||||
|
WorkingStatus = NotWroking;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int TG_Manager::GetManagerStatus(){
|
||||||
|
return WorkingStatus;
|
||||||
|
}
|
||||||
|
|
44
othersoft/TemperatureControler/src/Temperature/TG_Manager.h
Normal file
44
othersoft/TemperatureControler/src/Temperature/TG_Manager.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// Created by xin on 25-3-31.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef TG_MANAGER_H
|
||||||
|
#define TG_MANAGER_H
|
||||||
|
|
||||||
|
enum WORKINGSTATUS{
|
||||||
|
HEATING=1,
|
||||||
|
COOLING=2,
|
||||||
|
NotWroking=0
|
||||||
|
};
|
||||||
|
|
||||||
|
class TG_Manager {
|
||||||
|
public:
|
||||||
|
|
||||||
|
void SetPin(int pin1_H=7, int pin1_L=10, int pin2_H=2, int pin2_L=4);
|
||||||
|
void InitManger();
|
||||||
|
|
||||||
|
bool Heating();
|
||||||
|
bool Cooling();
|
||||||
|
bool Stop();
|
||||||
|
int GetManagerStatus();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool SetTuiGan(int IS_High);
|
||||||
|
bool SetSwitch1Status(bool status);
|
||||||
|
bool SetSwitch2Status(bool status);
|
||||||
|
int pin1_H=7;
|
||||||
|
int pin1_L=10;
|
||||||
|
int pin2_H=2;
|
||||||
|
int pin2_L=4;
|
||||||
|
bool ping1_status=false;
|
||||||
|
int WorkingStatus=NotWroking;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //TG_MANAGER_H
|
@ -6,42 +6,66 @@
|
|||||||
#include "fstream"
|
#include "fstream"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <qthread.h>
|
#include <qthread.h>
|
||||||
|
#include <QDebug>
|
||||||
TemperaTureWoker::TemperaTureWoker() {
|
TemperaTureWoker::TemperaTureWoker() {
|
||||||
m_SerialPort = new QSerialPort();
|
|
||||||
json jsonconfig;
|
}
|
||||||
std::ifstream i("/home/data/Setting/tempreature.json");
|
//
|
||||||
//<2F>ж<EFBFBD><D0B6>ļ<EFBFBD><C4BC>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
// TemperaTureWoker::TemperaTureWoker(json jsonconfig) {
|
||||||
if (!i.is_open())
|
//
|
||||||
|
// if(jsonconfig.contains("portname")&&jsonconfig["portname"].is_string())
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// }else {
|
||||||
|
// jsonconfig["portname"] = "ttyS2";
|
||||||
|
// }
|
||||||
|
// if(jsonconfig.contains("baudrate")&&jsonconfig["baudrate"].is_number()) {
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// jsonconfig["baudrate"] = 115200;
|
||||||
|
// }
|
||||||
|
// m_SerialPort->setPortName(jsonconfig["portname"].get<std::string>().c_str());
|
||||||
|
// m_SerialPort->setBaudRate(jsonconfig["baudrate"].get<int>());
|
||||||
|
// if (!m_SerialPort->open(QIODevice::ReadWrite))
|
||||||
|
// {
|
||||||
|
// std::cout << "Error open serial port" << std::endl;
|
||||||
|
// m_isInit = false;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// std::cout << "Open serial port success" << std::endl;
|
||||||
|
// m_isInit = true;
|
||||||
|
// }
|
||||||
|
// tempera_group temp1;
|
||||||
|
// tempera_group temp2;
|
||||||
|
// tempera_group temp3;
|
||||||
|
// tempera_group temp4;
|
||||||
|
// m_Tempreaturegroups.append(temp1);
|
||||||
|
// m_Tempreaturegroups.append(temp2);
|
||||||
|
// m_Tempreaturegroups.append(temp3);
|
||||||
|
// m_Tempreaturegroups.append(temp4);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// ReadTempreature();
|
||||||
|
// }
|
||||||
|
|
||||||
|
void TemperaTureWoker::OpenCom(QString portname, int baudrate) {
|
||||||
|
if (m_SerialPort== nullptr)
|
||||||
{
|
{
|
||||||
std::cout << "Error open file" << std::endl;
|
m_SerialPort=new QSerialPort();
|
||||||
jsonconfig["portname"] = "ttyS2";
|
|
||||||
jsonconfig["baudrate"] = 115200;
|
|
||||||
|
|
||||||
|
|
||||||
}else {
|
|
||||||
i >> jsonconfig;
|
|
||||||
if(jsonconfig.contains("portname")&&jsonconfig["portname"].is_string())
|
|
||||||
{
|
|
||||||
|
|
||||||
}else {
|
|
||||||
jsonconfig["portname"] = "ttyS2";
|
|
||||||
}
|
|
||||||
if(jsonconfig.contains("baudrate")&&jsonconfig["baudrate"].is_number()) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
jsonconfig["baudrate"] = 115200;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
m_SerialPort->setPortName(jsonconfig["portname"].get<std::string>().c_str());
|
m_SerialPort->setPortName(portname);
|
||||||
m_SerialPort->setBaudRate(jsonconfig["baudrate"].get<int>());
|
m_SerialPort->setBaudRate(baudrate);
|
||||||
if (!m_SerialPort->open(QIODevice::ReadWrite))
|
if (!m_SerialPort->open(QIODevice::ReadWrite))
|
||||||
{
|
{
|
||||||
std::cout << "Error open serial port" << std::endl;
|
// std::cout << "Error open serial port" << std::endl;
|
||||||
|
qDebug()<< "Error open serial port";
|
||||||
m_isInit = false;
|
m_isInit = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cout << "Open serial port success" << std::endl;
|
//std::cout << "Open serial port success" << std::endl;
|
||||||
|
qDebug()<< "Open serial port success";
|
||||||
m_isInit = true;
|
m_isInit = true;
|
||||||
}
|
}
|
||||||
tempera_group temp1;
|
tempera_group temp1;
|
||||||
@ -55,9 +79,6 @@ TemperaTureWoker::TemperaTureWoker() {
|
|||||||
|
|
||||||
|
|
||||||
ReadTempreature();
|
ReadTempreature();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemperaTureWoker::ReadTempreature() {
|
void TemperaTureWoker::ReadTempreature() {
|
||||||
@ -79,10 +100,12 @@ void TemperaTureWoker::ReadTempreature() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lenth==0) {
|
if (lenth==0) {
|
||||||
std::cout << "No data" << std::endl;
|
//std::cout << "No data" << std::endl;
|
||||||
|
qDebug()<< "No data";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::cout << data.toStdString() << std::endl;
|
std::cout << data.toStdString();
|
||||||
|
//qDebug() << data;
|
||||||
json jsondata = json::parse(data.toStdString());
|
json jsondata = json::parse(data.toStdString());
|
||||||
for (int j = 0; j < 4; ++j) {
|
for (int j = 0; j < 4; ++j) {
|
||||||
if(jsondata.contains("Temperature"+std::to_string(j+1))) {
|
if(jsondata.contains("Temperature"+std::to_string(j+1))) {
|
||||||
@ -101,15 +124,19 @@ void TemperaTureWoker::ReadTempreature() {
|
|||||||
std::cout << "Group " << i << ":\t|";
|
std::cout << "Group " << i << ":\t|";
|
||||||
for (int j = 0; j < 8; ++j) {
|
for (int j = 0; j < 8; ++j) {
|
||||||
// <20><><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD>Ϊ 10<31><30>ʹ<EFBFBD>ÿո<C3BF><D5B8><EFBFBD><EFBFBD>䣬<EFBFBD><E4A3AC>ͨ<EFBFBD><CDA8> std::internal ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD>
|
// <20><><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD>Ϊ 10<31><30>ʹ<EFBFBD>ÿո<C3BF><D5B8><EFBFBD><EFBFBD>䣬<EFBFBD><E4A3AC>ͨ<EFBFBD><CDA8> std::internal ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD>
|
||||||
|
//std::cout << std::setw(10) << std::setfill(' ') << std::internal
|
||||||
|
// qDebug().noquote().nospace()<< m_Tempreaturegroups[i].tempera[j] << ":\t|";
|
||||||
std::cout << std::setw(10) << std::setfill(' ') << std::internal
|
std::cout << std::setw(10) << std::setfill(' ') << std::internal
|
||||||
<< m_Tempreaturegroups[i].tempera[j] << "\t|";
|
<< m_Tempreaturegroups[i].tempera[j] << "\t|";
|
||||||
}
|
}
|
||||||
|
//qDebug() <<"\n";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Serial port is not init" << std::endl;
|
//std::cout << "Serial port is not init" << std::endl;
|
||||||
|
qDebug()<< "Serial port is not init";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,12 @@ class TemperaTureWoker:public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TemperaTureWoker();
|
TemperaTureWoker();
|
||||||
|
// TemperaTureWoker(json jconfig);
|
||||||
|
void OpenCom(QString portname,int baudrate);
|
||||||
QList<tempera_group> m_Tempreaturegroups;
|
QList<tempera_group> m_Tempreaturegroups;
|
||||||
void ReadTempreature();
|
void ReadTempreature();
|
||||||
private:
|
private:
|
||||||
QSerialPort *m_SerialPort;
|
QSerialPort *m_SerialPort= nullptr;
|
||||||
bool m_isInit=false;
|
bool m_isInit=false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,137 @@
|
|||||||
|
//
|
||||||
|
// Created by xin on 25-4-2.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "TemperatureRegulator.h"
|
||||||
|
#include "logout.h"
|
||||||
|
TemperatureRegulator *g_tempretureRegulator;
|
||||||
|
TemperatureRegulator::TemperatureRegulator(){
|
||||||
|
|
||||||
|
g_tempretureRegulator=this;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
"PortName": "ttyS2",
|
||||||
|
"BaudRate": 115200,
|
||||||
|
"Pin": {
|
||||||
|
"TG": {
|
||||||
|
"Pin_H": 7,
|
||||||
|
"Pin_L": 10
|
||||||
|
},
|
||||||
|
"Fan": {
|
||||||
|
"Pin": 11
|
||||||
|
},
|
||||||
|
"HOT": {
|
||||||
|
"Pin": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Constant_Temperature": {
|
||||||
|
"MaxTemp": 30,
|
||||||
|
"MinTemp": 0
|
||||||
|
},
|
||||||
|
"Temperature": {
|
||||||
|
"index_x": 0,
|
||||||
|
"index_y": 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
**/
|
||||||
|
void TemperatureRegulator::setconfig(json jconfig) {
|
||||||
|
QString Port_Name="ttyS2";
|
||||||
|
int BaudRate=115200;
|
||||||
|
|
||||||
|
if (jconfig.contains("PortName")) {
|
||||||
|
Port_Name=QString::fromStdString(jconfig["PortName"]);
|
||||||
|
}
|
||||||
|
if (jconfig.contains("BaudRate")) {
|
||||||
|
BaudRate=jconfig["BaudRate"];
|
||||||
|
}
|
||||||
|
m_TemperaTureWoker=new TemperaTureWoker();
|
||||||
|
m_TemperaTureWoker->OpenCom(Port_Name,BaudRate);
|
||||||
|
int pin1_H=7;
|
||||||
|
int pin1_L=10;
|
||||||
|
int pin2_H=2;
|
||||||
|
int pin2_L=4;
|
||||||
|
if (jconfig.contains("Pin")) {
|
||||||
|
if (jconfig["Pin"].contains("TG")) {
|
||||||
|
if (jconfig["Pin"]["TG"].contains("Pin_H")) {
|
||||||
|
pin1_H=jconfig["Pin"]["TG"]["Pin_H"];
|
||||||
|
}
|
||||||
|
if (jconfig["Pin"]["TG"].contains("Pin_L")) {
|
||||||
|
pin1_L=jconfig["Pin"]["TG"]["Pin_L"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (jconfig["Pin"].contains("Fan")) {
|
||||||
|
if (jconfig["Pin"]["Fan"].contains("Pin")) {
|
||||||
|
pin2_H=jconfig["Pin"]["Fan"]["Pin"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (jconfig["Pin"].contains("HOT")) {
|
||||||
|
if (jconfig["Pin"]["HOT"].contains("Pin")) {
|
||||||
|
pin2_L=jconfig["Pin"]["HOT"]["Pin"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_TG_Manager=new TG_Manager();
|
||||||
|
m_TG_Manager->SetPin(pin1_H,pin1_L,pin2_H,pin2_L);
|
||||||
|
|
||||||
|
if (jconfig.contains("Constant_Temperature")) {
|
||||||
|
if (jconfig["Constant_Temperature"].contains("MaxTemp")) {
|
||||||
|
M_Targert_Max_Tempreature=jconfig["Constant_Temperature"]["MaxTemp"];
|
||||||
|
}
|
||||||
|
if (jconfig["Constant_Temperature"].contains("MinTemp")) {
|
||||||
|
M_Targert_Min_Tempreature=jconfig["Constant_Temperature"]["MinTemp"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (jconfig.contains("Temperature")) {
|
||||||
|
if (jconfig["Temperature"].contains("index_x")) {
|
||||||
|
m_target_index=jconfig["Temperature"]["index_x"];
|
||||||
|
}
|
||||||
|
if (jconfig["Temperature"].contains("index_y")) {
|
||||||
|
m_target_indey=jconfig["Temperature"]["index_y"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
isinit=true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TemperatureRegulator::SetTartGetX_Y(int x,int y){
|
||||||
|
m_target_index=x;
|
||||||
|
m_target_indey=y;
|
||||||
|
}
|
||||||
|
void TemperatureRegulator::init(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
void TemperatureRegulator::loop(){
|
||||||
|
if (!isinit) return;
|
||||||
|
m_TemperaTureWoker->ReadTempreature();
|
||||||
|
float tempreture=m_TemperaTureWoker->m_Tempreaturegroups[m_target_index].tempera[m_target_indey];
|
||||||
|
//printf("current tempreture is %f\n",tempreture);
|
||||||
|
logout("Temp","current tempreture is "+QString::number(tempreture),6);
|
||||||
|
// qDebug()<< "current tempreture is " << tempreture;
|
||||||
|
if (tempreture>M_Targert_Max_Tempreature)
|
||||||
|
{
|
||||||
|
m_TG_Manager->Cooling();
|
||||||
|
}
|
||||||
|
else if (tempreture<M_Targert_Min_Tempreature)
|
||||||
|
{
|
||||||
|
m_TG_Manager->Heating();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_TG_Manager->Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TemperatureRegulator::looptask() {
|
||||||
|
g_tempretureRegulator->loop();
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// Created by xin on 25-4-2.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef TEMPERATUREREGULATOR_H
|
||||||
|
#define TEMPERATUREREGULATOR_H
|
||||||
|
#include "TG_Manager.h"
|
||||||
|
#include "TemperaTureWoker.h"
|
||||||
|
#include "QObject"
|
||||||
|
|
||||||
|
class TemperatureRegulator :public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TemperatureRegulator();
|
||||||
|
void setconfig(json j);
|
||||||
|
void SetTartGetX_Y(int x,int y);
|
||||||
|
void init();
|
||||||
|
void loop();
|
||||||
|
static bool looptask();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
TemperaTureWoker *m_TemperaTureWoker;
|
||||||
|
TG_Manager *m_TG_Manager;
|
||||||
|
float M_Targert_Max_Tempreature=35;
|
||||||
|
float M_Targert_Min_Tempreature=25;
|
||||||
|
int m_target_index=0;
|
||||||
|
int m_target_indey=0;
|
||||||
|
bool isinit=false;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //TEMPERATUREREGULATOR_H
|
@ -135,3 +135,13 @@ try
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TimeWorker::ReadConfig(json j) {
|
||||||
|
if (j.contains("StartTime")&&j["StartTime"].is_string())
|
||||||
|
m_StartTime=QTime::fromString(QString::fromStdString(j["StartTime"]),"hh:mm:ss");
|
||||||
|
if(j.contains("EndTime")&&j["EndTime"].is_string())
|
||||||
|
m_EndTime=QTime::fromString(QString::fromStdString(j["EndTime"]),"hh:mm:ss");
|
||||||
|
if (j.contains("IntervalTime")&&j["IntervalTime"].is_number())
|
||||||
|
SetIntervalTime(j["IntervalTime"].get<int>()*1000);
|
||||||
|
logout("TimeWorker","ReadjsonConfig success: StartTime:"+m_StartTime.toString("hh:mm:ss")+" EndTime:"+m_EndTime.toString("hh:mm:ss")+" IntervalTime:"+QString::number(m_IntervalTime)+"ms",6);
|
||||||
|
}
|
||||||
|
@ -33,6 +33,7 @@ public:
|
|||||||
void SetWorkTime(QTime start,QTime end);
|
void SetWorkTime(QTime start,QTime end);
|
||||||
void SetWorkTime(QString start,QString end);
|
void SetWorkTime(QString start,QString end);
|
||||||
void ReadjsonConfig(QString path);
|
void ReadjsonConfig(QString path);
|
||||||
|
void ReadConfig(json j);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -17,6 +17,13 @@ cmake ../../shuttercali/project/LocationCali
|
|||||||
make -j4
|
make -j4
|
||||||
cp ./shutter_calibrate /home/pi/bin
|
cp ./shutter_calibrate /home/pi/bin
|
||||||
|
|
||||||
|
cd ../
|
||||||
|
mkdir TemperatureControler
|
||||||
|
cd TemperatureControler
|
||||||
|
cmake ../../TemperatureControler/project
|
||||||
|
make -j4
|
||||||
|
cp ./TemperatureControler /home/pi/bin
|
||||||
|
cp ../TemperatureControler/temperature_controler_config.json /home/data/Setting
|
||||||
cd ../
|
cd ../
|
||||||
|
|
||||||
mkdir console
|
mkdir console
|
||||||
@ -47,5 +54,5 @@ sudo apt-get install -y timedatectl
|
|||||||
timedatectl set-timezone Asia/Shanghai
|
timedatectl set-timezone Asia/Shanghai
|
||||||
date -R
|
date -R
|
||||||
sudo hwclock -w -f /dev/rtc0
|
sudo hwclock -w -f /dev/rtc0
|
||||||
sudo reboot
|
#sudo reboot
|
||||||
#tc
|
#tc
|
||||||
|
@ -6,4 +6,5 @@ chmod +x /root/ffwatch.sh
|
|||||||
mount /dev/mmcblk1p1 /home/data/
|
mount /dev/mmcblk1p1 /home/data/
|
||||||
chmod +x /root/Mywathdog.sh
|
chmod +x /root/Mywathdog.sh
|
||||||
bash /root/Mywathdog.sh &
|
bash /root/Mywathdog.sh &
|
||||||
|
/home/pi/bin/TemperatureControler &
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user