mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-12-17 03:53:32 +08:00
v2.1.3
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -24,3 +24,4 @@
|
|||||||
/othersoft/TemperatureControler/project/cmake-build-debug-towersif/
|
/othersoft/TemperatureControler/project/cmake-build-debug-towersif/
|
||||||
/othersoft/TemperatureControler/project/cmake-build-debug-towersif/
|
/othersoft/TemperatureControler/project/cmake-build-debug-towersif/
|
||||||
/DEB/
|
/DEB/
|
||||||
|
/cmake-build-debug-nanopi/
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.3)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
project(TowerOptoSifAndSpectral)
|
project(TowerOptoSifAndSpectral)
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
|||||||
4
ChangeLog.md
Normal file
4
ChangeLog.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# 更新日志
|
||||||
|
|
||||||
|
#### v2.1.2 修改了温控模块 修改了calibrate时名称修改为.dat
|
||||||
|
#### v2.1.3 将预热放置到timer开启前
|
||||||
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
31
deb_pack.sh
31
deb_pack.sh
@ -7,7 +7,7 @@
|
|||||||
# exit 1
|
# exit 1
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
VERSION=2.1
|
VERSION=2.1.3
|
||||||
sh install.sh
|
sh install.sh
|
||||||
|
|
||||||
thispwd=$(pwd)
|
thispwd=$(pwd)
|
||||||
@ -25,11 +25,30 @@ cp /home/pi/bin/* .
|
|||||||
cd ../../..
|
cd ../../..
|
||||||
mkdir DEBIAN
|
mkdir DEBIAN
|
||||||
cd DEBIAN
|
cd DEBIAN
|
||||||
echo "Package: TowerSif
|
#echo "Package: TowerSif
|
||||||
Version: $VERSION
|
#Version: $VERSION
|
||||||
Architecture: armhf
|
#Architecture: armhf
|
||||||
Maintainer: rlx, tc
|
#Maintainer: rlx, tc
|
||||||
Description: test" > control
|
#Description: test" > control
|
||||||
|
cp ../../dpkg/* ./
|
||||||
|
echo "Version:${VERSION}"
|
||||||
|
echo "Version:${VERSION}" >> ./control
|
||||||
|
echo "echo \"V${VERSION}\" > /home/data/version" >> ./postinst
|
||||||
|
chmod +x ./post*
|
||||||
|
chmod +x ./control
|
||||||
|
cd ../
|
||||||
|
#复制root文件
|
||||||
|
mkdir -p ./root
|
||||||
|
cp ../root/* ./root/
|
||||||
|
chmod +x ./root/*.sh
|
||||||
|
#复制html文件
|
||||||
|
mkdir -p ./var/www/html/
|
||||||
|
cp -r ../html/* ./var/www/html/
|
||||||
|
chmod +x ./var/www/html/php/*.sh
|
||||||
|
mkdir -p ./home/data/
|
||||||
|
cp ../ChangeLog.md ./home/data/ChangeLog.md
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#cd /home/pi/
|
#cd /home/pi/
|
||||||
cd $thispwd
|
cd $thispwd
|
||||||
|
|||||||
4
dpkg/control
Normal file
4
dpkg/control
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Package: TowerSif
|
||||||
|
Architecture: armhf
|
||||||
|
Maintainer: rlx, tc
|
||||||
|
Description: test
|
||||||
34
dpkg/postinst
Normal file
34
dpkg/postinst
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
##安装完执行
|
||||||
|
echo "install airbornesystem ok"
|
||||||
|
sed -i '/\/root\/start/d' /etc/rc.local
|
||||||
|
sed -i '/^exit 0/i/root/start.sh &' /etc/rc.local
|
||||||
|
sudo apt-get install -y timedatectl
|
||||||
|
timedatectl set-timezone Asia/Shanghai
|
||||||
|
date -R
|
||||||
|
sudo hwclock -w -f /dev/rtc0
|
||||||
|
#echo "/home/pi/AirbroneSystem/lib" > /etc/ld.so.conf.d/mylib.conf
|
||||||
|
#echo "/home/pi/AirbroneSystem/libreh" > /etc/ld.so.conf.d/mylib1.conf
|
||||||
|
## 获取系统内存信息,并提取总内存大小
|
||||||
|
#total_memory=$(free -m | awk 'NR==2{print $2}')
|
||||||
|
#
|
||||||
|
## 设置阈值,3GB对应的是3072MB
|
||||||
|
#threshold=3072
|
||||||
|
#
|
||||||
|
## 判断总内存是否大于3GB
|
||||||
|
#if [ "$total_memory" -gt "$threshold" ]; then
|
||||||
|
# echo "Memory is greater than 3GB"
|
||||||
|
# rm /etc/udev/rules.d/12*
|
||||||
|
# echo 'ACTION=="add",KERNELS=="6-1:1.0",SUBSYSTEMS=="usb",MODE:="0777",SYMLINK+="ttySBGport"' > /etc/udev/rules.d/12-mybasem.rules
|
||||||
|
#else
|
||||||
|
# echo "Memory is not greater than 3GB Mybe M4B"
|
||||||
|
# rm /etc/udev/rules.d/12*
|
||||||
|
# echo 'ACTION=="add",KERNELS=="3-1:1.0",SUBSYSTEMS=="usb",MODE:="0777",SYMLINK+="ttySBGport"' > /etc/udev/rules.d/12-mybasem4b.rules
|
||||||
|
#
|
||||||
|
#fi
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# ldconfig
|
||||||
|
#
|
||||||
3
dpkg/postrm
Normal file
3
dpkg/postrm
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
echo "thank you for use"
|
||||||
|
#软件卸载后,执行该Shell脚本
|
||||||
@ -46,13 +46,13 @@ if ($position==1)
|
|||||||
{
|
{
|
||||||
if($sensorType=="OSIFAlpha"||$sensorType=="OSIFBeta")
|
if($sensorType=="OSIFAlpha"||$sensorType=="OSIFBeta")
|
||||||
{
|
{
|
||||||
$cmd = 'sudo /home/pi/bin/ocean_optics_calibration_console --deviceType OceanOptics -t 30 -slfs IrrLamp.txt --cfon FSN'.$sensorType.$position.'.data --position '.$position.' --integratingSphereDetectorValue '.$nite;
|
$cmd = 'sudo /home/pi/bin/ocean_optics_calibration_console --deviceType OceanOptics -t 30 -slfs IrrLamp.txt --cfon FSN'.$sensorType.$position.'.dat --position '.$position.' --integratingSphereDetectorValue '.$nite;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$port=$ini['FS'.($i+1)]['Port'];
|
$port=$ini['FS'.($i+1)]['Port'];
|
||||||
getonestring($port,'/');
|
getonestring($port,'/');
|
||||||
getonestring($port,'/');
|
getonestring($port,'/');
|
||||||
$cmd = 'sudo /home/pi/bin/ocean_optics_calibration_console --deviceType OPTOSKY --serialPort '.$port.' -t 30 -slfs IrrLamp.txt --cfon FSN'.$sensorType.$position.'.data --position '.$position.' --integratingSphereDetectorValue '.$nite;
|
$cmd = 'sudo /home/pi/bin/ocean_optics_calibration_console --deviceType OPTOSKY --serialPort '.$port.' -t 30 -slfs IrrLamp.txt --cfon FSN'.$sensorType.$position.'.dat --position '.$position.' --integratingSphereDetectorValue '.$nite;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,12 +62,12 @@ else
|
|||||||
{
|
{
|
||||||
if($sensorType=="OSIFAlpha"||$sensorType=="OSIFBeta")
|
if($sensorType=="OSIFAlpha"||$sensorType=="OSIFBeta")
|
||||||
{
|
{
|
||||||
$cmd = 'sudo /home/pi/bin/ocean_optics_calibration_console --deviceType OceanOptics -t 30 -slfs RadLamp.txt --cfon FSN'.$sensorType.$position.'.data --position '.$position.' --integratingSphereDetectorValue '.$nite;
|
$cmd = 'sudo /home/pi/bin/ocean_optics_calibration_console --deviceType OceanOptics -t 30 -slfs RadLamp.txt --cfon FSN'.$sensorType.$position.'.dat --position '.$position.' --integratingSphereDetectorValue '.$nite;
|
||||||
}else{
|
}else{
|
||||||
$port=$ini['FS'.($i+1)]['Port'];
|
$port=$ini['FS'.($i+1)]['Port'];
|
||||||
getonestring($port,'/');
|
getonestring($port,'/');
|
||||||
getonestring($port,'/');
|
getonestring($port,'/');
|
||||||
$cmd = 'sudo /home/pi/bin/ocean_optics_calibration_console --deviceType OPTOSKY --serialPort '.$port.' -t 30 -slfs RadLamp.txt --cfon FSN'.$sensorType.$position.'.data --position '.$position.' --integratingSphereDetectorValue '.$nite;
|
$cmd = 'sudo /home/pi/bin/ocean_optics_calibration_console --deviceType OPTOSKY --serialPort '.$port.' -t 30 -slfs RadLamp.txt --cfon FSN'.$sensorType.$position.'.dat --position '.$position.' --integratingSphereDetectorValue '.$nite;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
main.cpp
3
main.cpp
@ -94,7 +94,7 @@ int main(int argc, char *argv[])
|
|||||||
//m_mduUploader.Initialize();
|
//m_mduUploader.Initialize();
|
||||||
m_ctrlHumitureDetector.Initialize(m_struHumitureDI.qstrInterfaceName.toStdString());
|
m_ctrlHumitureDetector.Initialize(m_struHumitureDI.qstrInterfaceName.toStdString());
|
||||||
//////////////////////////////////////////////////////////////////////////prepare
|
//////////////////////////////////////////////////////////////////////////prepare
|
||||||
m_sTimer.Preheating();
|
|
||||||
m_ctrlHumitureDetector.GetHumiture_retry(m_fChassisTemp, m_fChassisHum);
|
m_ctrlHumitureDetector.GetHumiture_retry(m_fChassisTemp, m_fChassisHum);
|
||||||
m_ctrlHumitureDetector.GetHumiture_retry(m_fChassisTemp, m_fChassisHum);
|
m_ctrlHumitureDetector.GetHumiture_retry(m_fChassisTemp, m_fChassisHum);
|
||||||
|
|
||||||
@ -128,6 +128,7 @@ int main(int argc, char *argv[])
|
|||||||
m_pqUploaderThreadHolder->start();
|
m_pqUploaderThreadHolder->start();
|
||||||
|
|
||||||
m_mdgGrabber.Init_Self();
|
m_mdgGrabber.Init_Self();
|
||||||
|
m_sTimer.Preheating();
|
||||||
m_sTimer.SelfStart();
|
m_sTimer.SelfStart();
|
||||||
//////////////////////////////////////////////////////////////////////////test
|
//////////////////////////////////////////////////////////////////////////test
|
||||||
// DataFileProcessor testdp;
|
// DataFileProcessor testdp;
|
||||||
|
|||||||
@ -1,32 +0,0 @@
|
|||||||
{
|
|
||||||
"TimeConfig": {
|
|
||||||
"StartTime": "00:00:00",
|
|
||||||
"EndTime": "23:59:00",
|
|
||||||
"IntervalTime": 60
|
|
||||||
},
|
|
||||||
"TemperatureConfig": {
|
|
||||||
"PortName": "ttyS2",
|
|
||||||
"BaudRate": 115200,
|
|
||||||
"Pin": {
|
|
||||||
"TG": {
|
|
||||||
"Pin_H": 7,
|
|
||||||
"Pin_L": 10
|
|
||||||
},
|
|
||||||
"Fan": {
|
|
||||||
"Pin": 11
|
|
||||||
},
|
|
||||||
"HOT": {
|
|
||||||
"Pin": 12
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Constant_Temperature": {
|
|
||||||
"MaxTemp": 35,
|
|
||||||
"MinTemp": 10
|
|
||||||
},
|
|
||||||
"Temperature": {
|
|
||||||
"index_x": 0,
|
|
||||||
"index_y": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"TimeConfig": {
|
"TimeConfig": {
|
||||||
"StartTime": "00:00:00",
|
"StartTime": "00:00:00",
|
||||||
"EndTime": "23:59:00",
|
"EndTime": "23:59:00",
|
||||||
@ -8,15 +8,20 @@
|
|||||||
"PortName": "ttyS2",
|
"PortName": "ttyS2",
|
||||||
"BaudRate": 115200,
|
"BaudRate": 115200,
|
||||||
"Pin": {
|
"Pin": {
|
||||||
"TG": {
|
"COOLER": {
|
||||||
"Pin_H": 2,
|
"Pin": 24
|
||||||
"Pin_L": 3
|
|
||||||
},
|
},
|
||||||
"Fan": {
|
"Fan": {
|
||||||
"Pin": 10
|
"Pin_H": 3,
|
||||||
|
"Pin_L": 2
|
||||||
},
|
},
|
||||||
"HOT": {
|
"HOT": {
|
||||||
"Pin": 7
|
"Pin": 19
|
||||||
|
},
|
||||||
|
"WINDOWS": {
|
||||||
|
"Pin_H": 7,
|
||||||
|
"Pin_L": 10,
|
||||||
|
"WaitTime": 40
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Constant_Temperature": {
|
"Constant_Temperature": {
|
||||||
|
|||||||
@ -7,21 +7,88 @@
|
|||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <qthread.h>
|
#include <qthread.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include "logout.h"
|
||||||
|
|
||||||
|
|
||||||
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::flush;
|
std::cout<<"Hello World"<<std::flush;
|
||||||
|
|
||||||
|
|
||||||
json j;
|
json j;
|
||||||
std::ifstream i("/home/data/Setting/Constant_Temperature_Config.json");
|
std::ifstream i("/home/data/Setting/Constant_Temperature_Config.json");
|
||||||
|
//如果配置文件不存在则创建一个默认配置文件
|
||||||
|
if (!i.is_open()) {
|
||||||
|
logout("main","config file not exist,create default config file",10);
|
||||||
|
std::ofstream o("/home/data/Setting/Constant_Temperature_Config.json");
|
||||||
|
json jdefault={
|
||||||
|
{"TimeConfig",
|
||||||
|
{
|
||||||
|
{"StartTime","00:00:00"},
|
||||||
|
{"EndTime","23:59:00"},
|
||||||
|
{"IntervalTime",10}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{"TemperatureConfig",
|
||||||
|
{
|
||||||
|
{"PortName","ttyS2"},
|
||||||
|
{"BaudRate",115200},
|
||||||
|
{"Pin",
|
||||||
|
{
|
||||||
|
{"COOLER", {{"Pin",24}}},
|
||||||
|
{"Fan", {{"Pin_H",3},{"Pin_L",2}}},
|
||||||
|
{"HOT", {{"Pin",19}}},
|
||||||
|
{"WINDOWS", {{"Pin_H",10},{"Pin_L",7},{"WaitTime",60}}}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{"Constant_Temperature",
|
||||||
|
{
|
||||||
|
{"CoolBegin_Temp_Insight",20},
|
||||||
|
{"CoolBegin_Diff_Temp",5},
|
||||||
|
{"HeatingBegin_Temp_Insight",0},
|
||||||
|
{"IsCoolInDaylight",false}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{"Location",
|
||||||
|
{
|
||||||
|
{"latitude",0},
|
||||||
|
{"longitude",0}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{"IndexInfo",
|
||||||
|
{
|
||||||
|
{"Insight",{ {{"x",7},{"y",1}}, {{"x",8},{"y",1}} }},
|
||||||
|
{"Outside",{ {{"x",1},{"y",1}}, {{"x",2},{"y",1}} }}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
o << std::setw(4) << jdefault << std::endl;
|
||||||
|
o.close();
|
||||||
|
logout("main","default config file created,please modify the config file and restart the program",10);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
logout("main","prepare to read config data,if error please check file /home/data/Setting/Constant_Temperature_Config.json",10);
|
||||||
i>>j;
|
i>>j;
|
||||||
|
logout("main","config data read finish",10);
|
||||||
json timeconfig=j["TimeConfig"];
|
json timeconfig=j["TimeConfig"];
|
||||||
json tempconfig=j["TemperatureConfig"];
|
json tempconfig=j["TemperatureConfig"];
|
||||||
TemperatureRegulator *temperature_regulator=new TemperatureRegulator();
|
TemperatureRegulator *temperature_regulator=new TemperatureRegulator();
|
||||||
temperature_regulator->setconfig(tempconfig);
|
temperature_regulator->setconfig(tempconfig);
|
||||||
TimeWorker *timeWorker=new TimeWorker();
|
TimeWorker *timeWorker=new TimeWorker();
|
||||||
|
|
||||||
timeWorker->ReadConfig(timeconfig);
|
timeWorker->ReadConfig(timeconfig);
|
||||||
|
|
||||||
|
|
||||||
timeWorker->SetTask(TemperatureRegulator::looptask);
|
timeWorker->SetTask(TemperatureRegulator::looptask);
|
||||||
timeWorker->Start();
|
timeWorker->Start();
|
||||||
|
|
||||||
|
|||||||
@ -4,15 +4,32 @@
|
|||||||
|
|
||||||
#include "TG_Manager.h"
|
#include "TG_Manager.h"
|
||||||
#include "string"
|
#include "string"
|
||||||
|
#include "QThread"
|
||||||
void TG_Manager::SetPin(int pin1_H, int pin1_L, int pin2_H, int pin2_L)
|
void TG_Manager::SetPin(int pin1_H, int pin1_L, int pin2_H, int pin2_L)
|
||||||
{
|
{
|
||||||
this->pin1_H = pin1_H;
|
// this->pin1_H = pin1_H;
|
||||||
this->pin1_L = pin1_L;
|
// this->pin1_L = pin1_L;
|
||||||
this->pin2_H = pin2_H;
|
// this->pin2_H = pin2_H;
|
||||||
this->pin2_L = pin2_L;
|
// this->pin2_L = pin2_L;
|
||||||
InitManger();
|
InitManger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TG_Manager::SetPin_V2(int Windows_Pin_H, int Windows_Pin_L, int COOLER_Pin_EN, int HOT_Pin_EN, int Fan_Pin_H,
|
||||||
|
int Fan_Pin_L) {
|
||||||
|
this->Windows_Pin_H=Windows_Pin_H;
|
||||||
|
this->Windows_Pin_L=Windows_Pin_L;
|
||||||
|
this->COOLER_Pin_EN=COOLER_Pin_EN;
|
||||||
|
this->HOT_Pin_EN=HOT_Pin_EN;
|
||||||
|
this->Fan_Pin_H=Fan_Pin_H;
|
||||||
|
this->Fan_Pin_L=Fan_Pin_L;
|
||||||
|
InitManger();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TG_Manager::Set_Waite_time_for_Windows(int time_in_seconds) {
|
||||||
|
m_time_for_wait_windows = time_in_seconds;
|
||||||
|
}
|
||||||
|
|
||||||
bool TG_Manager::SetTuiGan(int IS_High)
|
bool TG_Manager::SetTuiGan(int IS_High)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -62,17 +79,43 @@ bool TG_Manager::SetTuiGan(int IS_High)
|
|||||||
}
|
}
|
||||||
void TG_Manager::InitManger()
|
void TG_Manager::InitManger()
|
||||||
{
|
{
|
||||||
std::string comand1 = "gpio mode " + std::to_string(pin1_H) + " out";
|
// std::string comand1 = "gpio mode " + std::to_string(pin1_H) + " out";
|
||||||
std::string comand2 = "gpio mode " + std::to_string(pin1_L) + " 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 comand3 = "gpio mode " + std::to_string(pin2_H) + " out";
|
||||||
std::string comand4 = "gpio mode " + std::to_string(pin2_L) + " 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);
|
||||||
|
std::string comand1 = "gpio mode " + std::to_string(Windows_Pin_H) + " out";
|
||||||
|
std::string comand2 = "gpio mode " + std::to_string(Windows_Pin_L) + " out";
|
||||||
|
std::string comand3 = "gpio mode " + std::to_string(COOLER_Pin_EN) + " out";
|
||||||
|
std::string comand4 = "gpio mode " + std::to_string(HOT_Pin_EN) + " out";
|
||||||
|
std::string comand5 = "gpio mode " + std::to_string(Fan_Pin_H) + " out";
|
||||||
|
std::string comand6 = "gpio mode " + std::to_string(Fan_Pin_L) + " out";
|
||||||
system(comand1.c_str());
|
system(comand1.c_str());
|
||||||
system(comand2.c_str());
|
system(comand2.c_str());
|
||||||
system(comand3.c_str());
|
system(comand3.c_str());
|
||||||
system(comand4.c_str());
|
system(comand4.c_str());
|
||||||
SetTuiGan(0);
|
system(comand5.c_str());
|
||||||
SetSwitch1Status(0);
|
system(comand6.c_str());
|
||||||
SetSwitch2Status(0);
|
comand1 = "gpio write " + std::to_string(Windows_Pin_H) + " 0";
|
||||||
|
system(comand1.c_str());
|
||||||
|
comand1 = "gpio write " + std::to_string(Windows_Pin_L) + " 0";
|
||||||
|
system(comand1.c_str());
|
||||||
|
comand1 = "gpio write " + std::to_string(COOLER_Pin_EN) + " 0";
|
||||||
|
system(comand1.c_str());
|
||||||
|
comand1 = "gpio write " + std::to_string(HOT_Pin_EN) + " 0";
|
||||||
|
system(comand1.c_str());
|
||||||
|
comand1 = "gpio write " + std::to_string(Fan_Pin_H) + " 0";
|
||||||
|
system(comand1.c_str());
|
||||||
|
comand1 = "gpio write " + std::to_string(Fan_Pin_L) + " 0";
|
||||||
|
system(comand1.c_str());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
bool TG_Manager::SetSwitch1Status(bool status)
|
bool TG_Manager::SetSwitch1Status(bool status)
|
||||||
{
|
{
|
||||||
@ -104,29 +147,57 @@ bool TG_Manager::SetSwitch2Status(bool status)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TG_Manager::Heating()
|
bool TG_Manager::Heating(bool isworking)
|
||||||
{
|
{
|
||||||
printf("Heating\n");
|
|
||||||
SetTuiGan(true);
|
|
||||||
SetSwitch1Status(true);
|
|
||||||
SetSwitch2Status(false);
|
|
||||||
WorkingStatus = HEATING;
|
WorkingStatus = HEATING;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool TG_Manager::Cooling()
|
bool TG_Manager::Cooling(bool isworking)
|
||||||
{
|
{
|
||||||
printf("Cooling\n");
|
|
||||||
SetTuiGan(false);
|
|
||||||
SetSwitch1Status(false);
|
|
||||||
SetSwitch2Status(true);
|
|
||||||
WorkingStatus = COOLING;
|
WorkingStatus = COOLING;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TG_Manager::Windows_Open() {
|
||||||
|
std::string comment="gpio write " + std::to_string(Windows_Pin_H) + " 1";
|
||||||
|
std::string comment1="gpio write " + std::to_string(Windows_Pin_L) + " 0";
|
||||||
|
system(comment.c_str());
|
||||||
|
system(comment1.c_str());
|
||||||
|
//休息40秒
|
||||||
|
QThread::sleep(m_time_for_wait_windows);
|
||||||
|
|
||||||
|
comment="gpio write " + std::to_string(Windows_Pin_H) + " 0";
|
||||||
|
comment1="gpio write " + std::to_string(Windows_Pin_L) + " 0";
|
||||||
|
system(comment.c_str());
|
||||||
|
system(comment1.c_str());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TG_Manager::Windows_Close() {
|
||||||
|
std::string comment="gpio write " + std::to_string(Windows_Pin_H) + " 0";
|
||||||
|
std::string comment1="gpio write " + std::to_string(Windows_Pin_L) + " 1";
|
||||||
|
system(comment.c_str());
|
||||||
|
system(comment1.c_str());
|
||||||
|
//休息40秒
|
||||||
|
QThread::sleep(m_time_for_wait_windows);
|
||||||
|
|
||||||
|
comment="gpio write " + std::to_string(Windows_Pin_H) + " 0";
|
||||||
|
comment1="gpio write " + std::to_string(Windows_Pin_L) + " 0";
|
||||||
|
system(comment.c_str());
|
||||||
|
system(comment1.c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool TG_Manager::Stop(){
|
bool TG_Manager::Stop(){
|
||||||
SetTuiGan(2);
|
std::string comment="gpio write " + std::to_string(Windows_Pin_H) + " 0";
|
||||||
SetSwitch1Status(false);
|
std::string comment1="gpio write " + std::to_string(Windows_Pin_L) + " 0";
|
||||||
SetSwitch2Status(false);
|
system(comment.c_str());
|
||||||
|
system(comment1.c_str());
|
||||||
|
|
||||||
WorkingStatus = NotWroking;
|
WorkingStatus = NotWroking;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@ -4,21 +4,36 @@
|
|||||||
|
|
||||||
#ifndef TG_MANAGER_H
|
#ifndef TG_MANAGER_H
|
||||||
#define TG_MANAGER_H
|
#define TG_MANAGER_H
|
||||||
|
#include <QObject>
|
||||||
enum WORKINGSTATUS{
|
enum WORKINGSTATUS{
|
||||||
HEATING=1,
|
HEATING=1,
|
||||||
COOLING=2,
|
COOLING=2,
|
||||||
|
WINDOWS_OPEN=3,
|
||||||
|
WINDOWS_CLOSE=4,
|
||||||
|
|
||||||
NotWroking=0
|
NotWroking=0
|
||||||
};
|
};
|
||||||
|
// enum WINDOWS_STATUS{
|
||||||
class TG_Manager {
|
// WINDOWS_IS_READY_OPEN=1,
|
||||||
|
// WINDOWS_IS_CLOSE=2,
|
||||||
|
// WINDOWS_IS_OPENING=3,
|
||||||
|
// WINDOWS_IS_CLOSING=4,
|
||||||
|
// WINDOWS_IS_STOP=5
|
||||||
|
// };
|
||||||
|
class TG_Manager:public QObject {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void SetPin(int pin1_H=7, int pin1_L=10, int pin2_H=2, int pin2_L=4);
|
void SetPin(int pin1_H=7, int pin1_L=10, int pin2_H=2, int pin2_L=4);
|
||||||
|
void SetPin_V2(int Windows_Pin_H, int Windows_Pin_L, int COOLER_Pin_EN, int HOT_Pin_EN, int Fan_Pin_H, int Fan_Pin_L);
|
||||||
|
void Set_Waite_time_for_Windows(int time_in_seconds);
|
||||||
|
// void SetPin_V2
|
||||||
void InitManger();
|
void InitManger();
|
||||||
|
|
||||||
bool Heating();
|
bool Heating(bool isworking);
|
||||||
bool Cooling();
|
bool Cooling(bool isworking);
|
||||||
|
bool Windows_Open();
|
||||||
|
bool Windows_Close();
|
||||||
bool Stop();
|
bool Stop();
|
||||||
int GetManagerStatus();
|
int GetManagerStatus();
|
||||||
|
|
||||||
@ -29,10 +44,35 @@ private:
|
|||||||
bool SetTuiGan(int IS_High);
|
bool SetTuiGan(int IS_High);
|
||||||
bool SetSwitch1Status(bool status);
|
bool SetSwitch1Status(bool status);
|
||||||
bool SetSwitch2Status(bool status);
|
bool SetSwitch2Status(bool status);
|
||||||
|
int m_time_for_wait_windows=40;
|
||||||
int pin1_H=7;
|
int pin1_H=7;
|
||||||
int pin1_L=10;
|
int pin1_L=10;
|
||||||
int pin2_H=2;
|
int pin2_H=2;
|
||||||
int pin2_L=4;
|
int pin2_L=4;
|
||||||
|
/* "Pin": {
|
||||||
|
"COOLER": {
|
||||||
|
"Pin": 24
|
||||||
|
},
|
||||||
|
"Fan": {
|
||||||
|
"Pin_H": 3,
|
||||||
|
"Pin_L": 2
|
||||||
|
},
|
||||||
|
"HOT": {
|
||||||
|
"Pin": 19
|
||||||
|
},
|
||||||
|
"WINDOWS": {
|
||||||
|
"Pin_H": 7,
|
||||||
|
"Pin_L": 10
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
int Windows_Pin_H=7;
|
||||||
|
int Windows_Pin_L=10;
|
||||||
|
int COOLER_Pin_EN=24;
|
||||||
|
int HOT_Pin_EN=19;
|
||||||
|
int Fan_Pin_H=3;
|
||||||
|
int Fan_Pin_L=2;
|
||||||
|
|
||||||
|
|
||||||
bool ping1_status=false;
|
bool ping1_status=false;
|
||||||
int WorkingStatus=NotWroking;
|
int WorkingStatus=NotWroking;
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <qthread.h>
|
#include <qthread.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <logout.h>
|
||||||
TemperaTureWoker::TemperaTureWoker() {
|
TemperaTureWoker::TemperaTureWoker() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -102,10 +103,21 @@ void TemperaTureWoker::ReadTempreature() {
|
|||||||
if (lenth==0) {
|
if (lenth==0) {
|
||||||
//std::cout << "No data" << std::endl;
|
//std::cout << "No data" << std::endl;
|
||||||
qDebug()<< "No data";
|
qDebug()<< "No data";
|
||||||
|
logout("TemperaSersor","no data from tempera sensor",10);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::cout << data.toStdString();
|
std::cout << data.toStdString()<< std::endl;
|
||||||
//qDebug() << data;
|
logout("TemperaSersor",data.toHex(),5);
|
||||||
|
qDebug() << data;
|
||||||
|
try {
|
||||||
|
json::parse(data.toStdString());
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
logout("TemperaSersor","data from tempera sensor parse error",3);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
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))) {
|
||||||
@ -119,11 +131,11 @@ void TemperaTureWoker::ReadTempreature() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//<2F><>ӡm_Tempreaturegroups
|
//<2F><>ӡm_Tempreaturegroups
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
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><EFBFBD>ͨ<EFBFBD><EFBFBD> std::internal ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD>
|
// <20><><EFBFBD>ÿ<EFBFBD><C3BF>Ϊ 10<31><30>ʹ<EFBFBD>ÿո<C3BF><D5B8><EFBFBD>䣬<EFBFBD><E4A3AC>ͨ<EFBFBD><CDA8> std::internal ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD>
|
||||||
//std::cout << std::setw(10) << std::setfill(' ') << std::internal
|
//std::cout << std::setw(10) << std::setfill(' ') << std::internal
|
||||||
// qDebug().noquote().nospace()<< m_Tempreaturegroups[i].tempera[j] << ":\t|";
|
// 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
|
||||||
|
|||||||
@ -53,33 +53,92 @@ void TemperatureRegulator::setconfig(json jconfig) {
|
|||||||
}
|
}
|
||||||
m_TemperaTureWoker=new TemperaTureWoker();
|
m_TemperaTureWoker=new TemperaTureWoker();
|
||||||
m_TemperaTureWoker->OpenCom(Port_Name,BaudRate);
|
m_TemperaTureWoker->OpenCom(Port_Name,BaudRate);
|
||||||
int pin1_H=7;
|
// int pin1_H=7;
|
||||||
int pin1_L=10;
|
// int pin1_L=10;
|
||||||
int pin2_H=2;
|
// int pin2_H=2;
|
||||||
int pin2_L=4;
|
// int pin2_L=4;
|
||||||
if (jconfig.contains("Pin")) {
|
// if (jconfig.contains("Pin")) {
|
||||||
if (jconfig["Pin"].contains("TG")) {
|
// if (jconfig["Pin"].contains("")) {
|
||||||
if (jconfig["Pin"]["TG"].contains("Pin_H")) {
|
// if (jconfig["Pin"]["TG"].contains("Pin_H")) {
|
||||||
pin1_H=jconfig["Pin"]["TG"]["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"];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
/*
|
||||||
|
* "Pin": {
|
||||||
|
"COOLER": {
|
||||||
|
"Pin": 24
|
||||||
|
},
|
||||||
|
"Fan": {
|
||||||
|
"Pin_H": 3,
|
||||||
|
"Pin_L": 2
|
||||||
|
},
|
||||||
|
"HOT": {
|
||||||
|
"Pin": 19
|
||||||
|
},
|
||||||
|
"WINDOWS": {
|
||||||
|
"Pin_H": 7,
|
||||||
|
"Pin_L": 10,
|
||||||
|
"WaitTime": 40
|
||||||
}
|
}
|
||||||
if (jconfig["Pin"]["TG"].contains("Pin_L")) {
|
},
|
||||||
pin1_L=jconfig["Pin"]["TG"]["Pin_L"];
|
*/
|
||||||
|
int Cooler_Pin_EN=24;
|
||||||
|
int Fan_Pin_H=3;
|
||||||
|
int Fan_Pin_L=2;
|
||||||
|
int Hot_Pin_EN=19;
|
||||||
|
int Windows_Pin_H=7;
|
||||||
|
int Windows_Pin_L=10;
|
||||||
|
int Windows_WaitTime=40;
|
||||||
|
if (jconfig.contains("Pin")) {
|
||||||
|
if (jconfig["Pin"].contains("COOLER")) {
|
||||||
|
if (jconfig["Pin"]["COOLER"].contains("Pin")) {
|
||||||
|
Cooler_Pin_EN=jconfig["Pin"]["COOLER"]["Pin"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (jconfig["Pin"].contains("Fan")) {
|
if (jconfig["Pin"].contains("Fan")) {
|
||||||
if (jconfig["Pin"]["Fan"].contains("Pin")) {
|
if (jconfig["Pin"]["Fan"].contains("Pin_H")) {
|
||||||
pin2_H=jconfig["Pin"]["Fan"]["Pin"];
|
Fan_Pin_H=jconfig["Pin"]["Fan"]["Pin_H"];
|
||||||
|
}
|
||||||
|
if (jconfig["Pin"]["Fan"].contains("Pin_L")) {
|
||||||
|
Fan_Pin_L=jconfig["Pin"]["Fan"]["Pin_L"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (jconfig["Pin"].contains("HOT")) {
|
if (jconfig["Pin"].contains("HOT")) {
|
||||||
if (jconfig["Pin"]["HOT"].contains("Pin")) {
|
if (jconfig["Pin"]["HOT"].contains("Pin")) {
|
||||||
pin2_L=jconfig["Pin"]["HOT"]["Pin"];
|
Hot_Pin_EN=jconfig["Pin"]["HOT"]["Pin"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (jconfig["Pin"].contains("WINDOWS")) {
|
||||||
|
if (jconfig["Pin"]["WINDOWS"].contains("Pin_H")) {
|
||||||
|
Windows_Pin_H=jconfig["Pin"]["WINDOWS"]["Pin_H"];
|
||||||
|
}
|
||||||
|
if (jconfig["Pin"]["WINDOWS"].contains("Pin_L")) {
|
||||||
|
Windows_Pin_L=jconfig["Pin"]["WINDOWS"]["Pin_L"];
|
||||||
|
}
|
||||||
|
if (jconfig["Pin"]["WINDOWS"].contains("WaitTime")) {
|
||||||
|
Windows_WaitTime=jconfig["Pin"]["WINDOWS"]["WaitTime"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_TG_Manager=new TG_Manager();
|
m_TG_Manager=new TG_Manager();
|
||||||
m_TG_Manager->SetPin(pin1_H,pin1_L,pin2_H,pin2_L);
|
m_TG_Manager->SetPin_V2(Windows_Pin_H,Windows_Pin_L,Cooler_Pin_EN,Hot_Pin_EN,Fan_Pin_H,Fan_Pin_L);
|
||||||
|
// m_TG_Manager->SetPin(pin1_H,pin1_L,pin2_H,pin2_L);
|
||||||
if (jconfig.contains("Constant_Temperature")) {
|
if (jconfig.contains("Constant_Temperature")) {
|
||||||
if (jconfig["Constant_Temperature"].contains("CoolBegin_Temp_Insight")) {
|
if (jconfig["Constant_Temperature"].contains("CoolBegin_Temp_Insight")) {
|
||||||
m_CoolBegin_Temp_Insight=jconfig["Constant_Temperature"]["CoolBegin_Temp_Insight"];
|
m_CoolBegin_Temp_Insight=jconfig["Constant_Temperature"]["CoolBegin_Temp_Insight"];
|
||||||
@ -238,10 +297,68 @@ void TemperatureRegulator::init(){
|
|||||||
void TemperatureRegulator::PanduanCooling() {
|
void TemperatureRegulator::PanduanCooling() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
int timesforlog=0;
|
||||||
|
void TemperatureRegulator::loopsample() {
|
||||||
|
if (!isinit) return;
|
||||||
|
m_TemperaTureWoker->ReadTempreature();
|
||||||
|
// todo <20><>savedata<74><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼temperature
|
||||||
|
QString datastr="";
|
||||||
|
for (int i = 0; i < m_TemperaTureWoker->m_Tempreaturegroups.size(); ++i) {
|
||||||
|
for (int j = 0; j < 8; ++j) {
|
||||||
|
datastr+=QString::number(m_TemperaTureWoker->m_Tempreaturegroups[i].tempera[j])+",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
saveDataToFile("Tempratrue",datastr);
|
||||||
|
QDateTime currentTime=QDateTime::currentDateTime();
|
||||||
|
int year=currentTime.date().year();
|
||||||
|
int month=currentTime.date().month();
|
||||||
|
int day=currentTime.date().day();
|
||||||
|
int nowhour=currentTime.time().hour();
|
||||||
|
int nowminute=currentTime.time().minute();
|
||||||
|
long nowminuteofday=nowhour*60+nowminute;
|
||||||
|
SunInfo sunInfo=calculateSunriseSunset(year,month,day,m_Latitude,m_Longitude);
|
||||||
|
float sunrise_minte=sunInfo.sunrise_h*60+sunInfo.sunrise_m;
|
||||||
|
float sunset_minte=sunInfo.sunset_h*60+sunInfo.sunset_m;
|
||||||
|
|
||||||
|
if (timesforlog%60==0) {
|
||||||
|
logout("Temp","now minute of day is "+QString::number(nowminuteofday)+
|
||||||
|
" sunrise minute is "+QString::number(sunrise_minte)+
|
||||||
|
" sunset minute is "+QString::number(sunset_minte),6);
|
||||||
|
|
||||||
|
}
|
||||||
|
timesforlog++ ;
|
||||||
|
//<2F>ų<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ǰһ<C7B0><D2BB>Сʱ
|
||||||
|
if (nowminuteofday>60) {
|
||||||
|
if (last_time_in_today_minute<sunrise_minte&&nowminuteofday>=sunrise_minte&&nowminuteofday<sunset_minte) {
|
||||||
|
//sunrise happened
|
||||||
|
logout("Temp","sunrise happened",6);
|
||||||
|
m_TG_Manager->Windows_Close();
|
||||||
|
// m_TG_Manager->Stop();
|
||||||
|
}
|
||||||
|
if (last_time_in_today_minute<sunset_minte&&nowminuteofday>=sunset_minte) {
|
||||||
|
//sunset happened
|
||||||
|
logout("Temp","sunset happened",6);
|
||||||
|
m_TG_Manager->Windows_Open();
|
||||||
|
// m_TG_Manager->Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
last_time_in_today_minute=nowminuteofday;
|
||||||
|
};
|
||||||
void TemperatureRegulator::loop(){
|
void TemperatureRegulator::loop(){
|
||||||
if (!isinit) return;
|
if (!isinit) return;
|
||||||
m_TemperaTureWoker->ReadTempreature();
|
m_TemperaTureWoker->ReadTempreature();
|
||||||
// todo <20><>savedata<74><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼temperature
|
// todo <20><>savedata<74><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼temperature
|
||||||
|
QString datastr="";
|
||||||
|
for (int i = 0; i < m_TemperaTureWoker->m_Tempreaturegroups.size(); ++i) {
|
||||||
|
for (int j = 0; j < 8; ++j) {
|
||||||
|
datastr+=QString::number(m_TemperaTureWoker->m_Tempreaturegroups[i].tempera[j])+",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
saveDataToFile("Tempratrue",datastr);
|
||||||
QDateTime currentTime=QDateTime::currentDateTime();
|
QDateTime currentTime=QDateTime::currentDateTime();
|
||||||
int year=currentTime.date().year();
|
int year=currentTime.date().year();
|
||||||
int month=currentTime.date().month();
|
int month=currentTime.date().month();
|
||||||
@ -267,7 +384,7 @@ void TemperatureRegulator::loop(){
|
|||||||
if (diff>m_CoolBegin_Diff_Temp) {
|
if (diff>m_CoolBegin_Diff_Temp) {
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰinsight<68>¶ȴ<C2B6><C8B4><EFBFBD><EFBFBD>趨<EFBFBD><E8B6A8>ʼֵ
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰinsight<68>¶ȴ<C2B6><C8B4><EFBFBD><EFBFBD>趨<EFBFBD><E8B6A8>ʼֵ
|
||||||
if (maxinsighttemp>m_CoolBegin_Temp_Insight) {
|
if (maxinsighttemp>m_CoolBegin_Temp_Insight) {
|
||||||
m_TG_Manager->Cooling();
|
m_TG_Manager->Cooling(true);
|
||||||
logout("Temp","current max insight temp is "+QString::number(maxinsighttemp),6);
|
logout("Temp","current max insight temp is "+QString::number(maxinsighttemp),6);
|
||||||
} else {
|
} else {
|
||||||
m_TG_Manager->Stop();
|
m_TG_Manager->Stop();
|
||||||
@ -295,7 +412,7 @@ void TemperatureRegulator::loop(){
|
|||||||
//<2F>ڶ<EFBFBD><DAB6><EFBFBD> <20><>m_HeatingBeginTemp_Insight<68>Ƚ<EFBFBD>
|
//<2F>ڶ<EFBFBD><DAB6><EFBFBD> <20><>m_HeatingBeginTemp_Insight<68>Ƚ<EFBFBD>
|
||||||
if (mininsighttemp<m_HeatingBegin_Temp_Insight)
|
if (mininsighttemp<m_HeatingBegin_Temp_Insight)
|
||||||
{
|
{
|
||||||
m_TG_Manager->Heating();
|
m_TG_Manager->Heating(true);
|
||||||
logout("Temp","current min insight temp is "+QString::number(mininsighttemp),6);
|
logout("Temp","current min insight temp is "+QString::number(mininsighttemp),6);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -316,7 +433,7 @@ void TemperatureRegulator::loop(){
|
|||||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD>¶<EFBFBD>С<EFBFBD><D0A1><EFBFBD>ڲ<EFBFBD><DAB2>¶<EFBFBD>
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD>¶<EFBFBD>С<EFBFBD><D0A1><EFBFBD>ڲ<EFBFBD><DAB2>¶<EFBFBD>
|
||||||
if (maxinsighttemp>minoutsighttemp)
|
if (maxinsighttemp>minoutsighttemp)
|
||||||
{
|
{
|
||||||
m_TG_Manager->Cooling();
|
m_TG_Manager->Cooling(true);
|
||||||
logout("Temp","current max insight temp is "+QString::number(maxinsighttemp),6);
|
logout("Temp","current max insight temp is "+QString::number(maxinsighttemp),6);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -337,11 +454,11 @@ void TemperatureRegulator::loop(){
|
|||||||
// qDebug()<< "current tempreture is " << tempreture;
|
// qDebug()<< "current tempreture is " << tempreture;
|
||||||
if (tempreture>M_Targert_Max_Tempreature)
|
if (tempreture>M_Targert_Max_Tempreature)
|
||||||
{
|
{
|
||||||
m_TG_Manager->Cooling();
|
m_TG_Manager->Cooling(true);
|
||||||
}
|
}
|
||||||
else if (tempreture<M_Targert_Min_Tempreature)
|
else if (tempreture<M_Targert_Min_Tempreature)
|
||||||
{
|
{
|
||||||
m_TG_Manager->Heating();
|
m_TG_Manager->Heating(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -352,7 +469,7 @@ void TemperatureRegulator::loop(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TemperatureRegulator::looptask() {
|
bool TemperatureRegulator::looptask() {
|
||||||
g_tempretureRegulator->loop();
|
g_tempretureRegulator->loopsample();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -56,6 +56,7 @@ public:
|
|||||||
float GetMin_of_Vector(int Data_type=INSIGHT_TEMPERATURE);
|
float GetMin_of_Vector(int Data_type=INSIGHT_TEMPERATURE);
|
||||||
void init();
|
void init();
|
||||||
void loop();
|
void loop();
|
||||||
|
void loopsample();
|
||||||
static bool looptask();
|
static bool looptask();
|
||||||
void PanduanCooling();
|
void PanduanCooling();
|
||||||
|
|
||||||
@ -77,6 +78,7 @@ private:
|
|||||||
bool isinit=false;
|
bool isinit=false;
|
||||||
float m_Latitude=39.9;
|
float m_Latitude=39.9;
|
||||||
float m_Longitude=116.4;
|
float m_Longitude=116.4;
|
||||||
|
long long last_time_in_today_minute=0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -74,11 +74,11 @@ void TimeWorker::onTimerTrigger() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_isWork=true;
|
m_isWork=true;
|
||||||
logout("TimeWorker","Task is working");
|
// logout("TimeWorker","Task is working");
|
||||||
int taskid=0;
|
int taskid=0;
|
||||||
foreach (auto task, m_TaskList) {
|
foreach (auto task, m_TaskList) {
|
||||||
task();
|
task();
|
||||||
logout("TimeWorker","Task "+QString::number(taskid)+" is finished",6);
|
//logout("TimeWorker","Task "+QString::number(taskid)+" is finished",6);
|
||||||
taskid++;
|
taskid++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#include "logout.h"
|
#include "logout.h"
|
||||||
#include "iostream"
|
#include "iostream"
|
||||||
extern FILE *file=NULL;
|
extern FILE *file=NULL;
|
||||||
|
FILE *datafile=NULL;
|
||||||
#define _DEBUG
|
#define _DEBUG
|
||||||
void (*pFunction)(QString message)= nullptr;
|
void (*pFunction)(QString message)= nullptr;
|
||||||
QString colorcode = "\033[";
|
QString colorcode = "\033[";
|
||||||
@ -105,8 +106,8 @@ void writelogtofile(QString sender,QString qstr)
|
|||||||
}
|
}
|
||||||
if (file==NULL)
|
if (file==NULL)
|
||||||
{
|
{
|
||||||
QString path="/home/iris/log/"+currentTime.toString("yyyy_MM_dd")+".log";
|
QString path="/home/data/Log/"+currentTime.toString("yyyy_MM_dd_hh_mm_ss")+"_Temptrue.log";
|
||||||
system("mkdir -p /home/iris/log");
|
system("mkdir -p /home/data/Log");
|
||||||
file=fopen(path.toStdString().c_str(),"a+");
|
file=fopen(path.toStdString().c_str(),"a+");
|
||||||
fprintf(file,"\n\n\n\nstart---------------------------------------------------------------------------------\n");
|
fprintf(file,"\n\n\n\nstart---------------------------------------------------------------------------------\n");
|
||||||
}
|
}
|
||||||
@ -122,22 +123,22 @@ void saveData(QString sender,QString qstr)
|
|||||||
QString datestr=currentTime.toString("yyyy_MM_dd");
|
QString datestr=currentTime.toString("yyyy_MM_dd");
|
||||||
if (lastdatestr!=datestr)
|
if (lastdatestr!=datestr)
|
||||||
{
|
{
|
||||||
if (file!=NULL)
|
if (datafile!=NULL)
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
file=NULL;
|
datafile=NULL;
|
||||||
}
|
}
|
||||||
lastdatestr=datestr;
|
lastdatestr=datestr;
|
||||||
}
|
}
|
||||||
if (file==NULL)
|
if (datafile==NULL)
|
||||||
{
|
{
|
||||||
QString path="/home/iris/TempData/"+currentTime.toString("yyyy_MM_dd")+".csv";
|
QString path="/home/data/TempData/"+currentTime.toString("yyyy_MM_dd_hh_mm_ss")+".csv";
|
||||||
system("mkdir -p /home/iris/TempData");
|
system("mkdir -p /home/data/TempData");
|
||||||
file=fopen(path.toStdString().c_str(),"a+");
|
datafile=fopen(path.toStdString().c_str(),"a+");
|
||||||
fprintf(file,QString::fromLocal8Bit("日期, 数据类型, 日期~n").toStdString().c_str());
|
fprintf(datafile,QString::fromLocal8Bit("日期, 数据类型, 日期~n").toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fprintf(file,"%s,%s,%s\n",currentTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString().c_str(),sender.toStdString().c_str(),qstr.toStdString().c_str());
|
fprintf(datafile,"%s,%s,%s\n",currentTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString().c_str(),sender.toStdString().c_str(),qstr.toStdString().c_str());
|
||||||
fflush(file);
|
fflush(datafile);
|
||||||
}
|
}
|
||||||
@ -19,7 +19,7 @@ void logout(T str)
|
|||||||
std::cout<<qstr.toStdString()<<std::endl<<std::flush;
|
std::cout<<qstr.toStdString()<<std::endl<<std::flush;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
void saveData(QString sender,QString qstr);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
||||||
void saveDataToFile(QString typeofdata,T str) {
|
void saveDataToFile(QString typeofdata,T str) {
|
||||||
@ -35,7 +35,7 @@ void saveDataToFile(QString typeofdata,T str) {
|
|||||||
QDateTime currentTime = QDateTime::currentDateTime();
|
QDateTime currentTime = QDateTime::currentDateTime();
|
||||||
std::cout<<green<<currentTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString()<<" "<<magenta<<typeofdata.toStdString()<<reset<<": "<<qstr11.toStdString()<<std::endl<<std::flush;
|
std::cout<<green<<currentTime.toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString()<<" "<<magenta<<typeofdata.toStdString()<<reset<<": "<<qstr11.toStdString()<<std::endl<<std::flush;
|
||||||
QString qstr=QString(str);
|
QString qstr=QString(str);
|
||||||
writelogtofile(typeofdata,str);
|
saveData(typeofdata,str);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,10 +21,10 @@ cd ../
|
|||||||
mkdir -p TemperatureControler
|
mkdir -p TemperatureControler
|
||||||
cd TemperatureControler
|
cd TemperatureControler
|
||||||
cmake ../../TemperatureControler/project
|
cmake ../../TemperatureControler/project
|
||||||
make -j4
|
make
|
||||||
cp ./TemperatureControler /home/pi/bin
|
cp ./TemperatureControler /home/pi/bin
|
||||||
mkdir -p /home/data/Setting
|
mkdir -p /home/data/Setting
|
||||||
cp ../../TemperatureControler/Constant_Temperature_Config.json /home/data/Setting
|
cp ../../TemperatureControler/project/Constant_Temperature_Config.json /home/data/Setting
|
||||||
cd ../
|
cd ../
|
||||||
|
|
||||||
mkdir -p console
|
mkdir -p console
|
||||||
@ -46,7 +46,7 @@ cp ./root/start.sh /root
|
|||||||
chmod +x /root/start.sh
|
chmod +x /root/start.sh
|
||||||
mkdir -p /home/data
|
mkdir -p /home/data
|
||||||
cd ../
|
cd ../
|
||||||
rm -rf ./TowerOptoSifAndSpectral
|
#rm -rf ./TowerOptoSifAndSpectral
|
||||||
cd /root/filebrew
|
cd /root/filebrew
|
||||||
chmod +x ./filebrowser
|
chmod +x ./filebrowser
|
||||||
./filebrowser config set -a 0.0.0.0
|
./filebrowser config set -a 0.0.0.0
|
||||||
|
|||||||
29
root/Mywathdogtemp.sh
Normal file
29
root/Mywathdogtemp.sh
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
time=`date +%H:%M:%S`
|
||||||
|
echo $time
|
||||||
|
if [[ "$time" > "01:00:01" ]] && [[ "$time" < "22:30:00" ]]
|
||||||
|
then
|
||||||
|
ps -ef | grep "TemperatureControler" | grep -v "grep"
|
||||||
|
if [ "$?" -eq 1 ]
|
||||||
|
then
|
||||||
|
/home/pi/bin/TemperatureControler &
|
||||||
|
echo "process has been restarted!" > /home/data/log.txt
|
||||||
|
else
|
||||||
|
echo "process already started!"
|
||||||
|
sleep 60
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
pid=$(ps -ef | grep "TemperatureControler" | grep -v "grep" | awk '{print $2}')
|
||||||
|
if [ -z "$pid" ]
|
||||||
|
then
|
||||||
|
sleep 60
|
||||||
|
else
|
||||||
|
echo "$?"
|
||||||
|
echo "time to kill the task" > /home/data/log.txt
|
||||||
|
kill "$pid"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
sleep 30
|
||||||
|
done
|
||||||
@ -5,6 +5,8 @@ chmod +x /root/ffwatch.sh
|
|||||||
/root/ffwatch.sh &
|
/root/ffwatch.sh &
|
||||||
mount /dev/mmcblk1p1 /home/data/
|
mount /dev/mmcblk1p1 /home/data/
|
||||||
chmod +x /root/Mywathdog.sh
|
chmod +x /root/Mywathdog.sh
|
||||||
|
chmod +x /root/Mywathdogtemp.sh
|
||||||
bash /root/Mywathdog.sh &
|
bash /root/Mywathdog.sh &
|
||||||
|
bash /root/Mywathdogtemp.sh &
|
||||||
/home/pi/bin/TemperatureControler > /root/templog.log &
|
/home/pi/bin/TemperatureControler > /root/templog.log &
|
||||||
|
|
||||||
|
|||||||
@ -562,6 +562,7 @@ int CMainDataGrabber::GrabOnceFinished()
|
|||||||
|
|
||||||
// m_struAcqPosSetting.iPosition[i + 1];
|
// m_struAcqPosSetting.iPosition[i + 1];
|
||||||
m_iFlagIsCapturing_Signal = 1;
|
m_iFlagIsCapturing_Signal = 1;
|
||||||
|
|
||||||
emit SignalStartGrabOnce_Signal();
|
emit SignalStartGrabOnce_Signal();
|
||||||
while (m_iFlagIsCapturing_Signal)
|
while (m_iFlagIsCapturing_Signal)
|
||||||
{
|
{
|
||||||
@ -596,6 +597,7 @@ int CMainDataGrabber::GrabOnceFinished()
|
|||||||
|
|
||||||
//m_struAcqPosSetting.iPosition[0];
|
//m_struAcqPosSetting.iPosition[0];
|
||||||
m_iFlagIsCapturing_Dark = 1;
|
m_iFlagIsCapturing_Dark = 1;
|
||||||
|
// todo : 机载时是否有实时采集暗电流
|
||||||
emit SignalStartGrabOnce_Dark();
|
emit SignalStartGrabOnce_Dark();
|
||||||
while (m_iFlagIsCapturing_Dark)
|
while (m_iFlagIsCapturing_Dark)
|
||||||
{
|
{
|
||||||
@ -619,6 +621,9 @@ int CMainDataGrabber::GrabOnceFinished()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::vector<DataFrame>> vecData;
|
std::vector<std::vector<DataFrame>> vecData;
|
||||||
|
bool savedarkfile=true;
|
||||||
|
|
||||||
|
std::vector<std::vector<DataFrame>> vecDarkData;
|
||||||
|
|
||||||
for (ZZ_U8 i = 0; i < m_struDeviceContext.ucDeviceNumber; i++)
|
for (ZZ_U8 i = 0; i < m_struDeviceContext.ucDeviceNumber; i++)
|
||||||
{
|
{
|
||||||
@ -629,6 +634,10 @@ int CMainDataGrabber::GrabOnceFinished()
|
|||||||
SubDataFrame(vecSignal[j], vecDark[j], m_struDeviceContext.usPixels[i]);
|
SubDataFrame(vecSignal[j], vecDark[j], m_struDeviceContext.usPixels[i]);
|
||||||
}
|
}
|
||||||
vecData.push_back(vecSignal);
|
vecData.push_back(vecSignal);
|
||||||
|
if (savedarkfile) {
|
||||||
|
vecDarkData.push_back(vecDark);
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << "ucDeviceNumber" << i << " Data Size" << vecSignal.size();
|
qDebug() << "ucDeviceNumber" << i << " Data Size" << vecSignal.size();
|
||||||
//vecData[i].push_back();
|
//vecData[i].push_back();
|
||||||
}
|
}
|
||||||
@ -639,8 +648,15 @@ int CMainDataGrabber::GrabOnceFinished()
|
|||||||
m_pmduUploader->SetData(vecData);
|
m_pmduUploader->SetData(vecData);
|
||||||
emit SignalPushOneDataFrame();
|
emit SignalPushOneDataFrame();
|
||||||
m_pdfpSaver->SetData(vecData);
|
m_pdfpSaver->SetData(vecData);
|
||||||
|
if (savedarkfile) {
|
||||||
|
m_pdfpSaver->SetDarkData(vecDarkData);
|
||||||
|
|
||||||
|
}
|
||||||
qDebug() << "Thread Data Server: WriteDataFile Called";
|
qDebug() << "Thread Data Server: WriteDataFile Called";
|
||||||
m_pdfpSaver->WriteDataFile();
|
m_pdfpSaver->WriteDataFile();
|
||||||
|
if (savedarkfile) {
|
||||||
|
m_pdfpSaver->WriteDarkDataFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_iFlagIsCapturing = 0;
|
m_iFlagIsCapturing = 0;
|
||||||
|
|||||||
@ -4,8 +4,10 @@ DataFileProcessor::DataFileProcessor(QObject* parent /*= nullptr*/)
|
|||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
m_qstrFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/Data";
|
m_qstrFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/Data";
|
||||||
|
m_qstrDarkFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/Dark";
|
||||||
#else
|
#else
|
||||||
m_qstrFilePath = "/home/data/Data";
|
m_qstrFilePath = "/home/data/Data";
|
||||||
|
m_qstrDarkFilePath="/home/data/Dark";
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -33,21 +35,40 @@ void DataFileProcessor::SetData(std::vector<std::vector<DataFrame>> vecData)
|
|||||||
{
|
{
|
||||||
m_vecData.clear();
|
m_vecData.clear();
|
||||||
m_vecData = vecData;
|
m_vecData = vecData;
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
void DataFileProcessor::SetDarkData(std::vector<std::vector<DataFrame>> vecData) {
|
||||||
|
m_vecDarkData.clear();
|
||||||
|
m_vecDarkData = vecData;
|
||||||
|
}
|
||||||
bool DataFileProcessor::WriteDataFile()
|
bool DataFileProcessor::WriteDataFile()
|
||||||
{
|
{
|
||||||
//qDebug() << "start Thread Data Server GenerateFilePath";
|
//qDebug() << "start Thread Data Server GenerateFilePath";
|
||||||
GenerateFilePath();
|
GenerateFilePath();
|
||||||
|
|
||||||
//qDebug() << "start Thread Data Server WriteEnvironmentInfo";
|
//qDebug() << "start Thread Data Server WriteEnvironmentInfo";
|
||||||
WriteEnvironmentInfo();
|
WriteEnvironmentInfo(m_qstrFullFileName);
|
||||||
|
|
||||||
//qDebug() << "start Thread Data Server WriteDeviceInfo";
|
//qDebug() << "start Thread Data Server WriteDeviceInfo";
|
||||||
WriteDeviceInfo();
|
WriteDeviceInfo(m_qstrFullFileName);
|
||||||
|
|
||||||
//qDebug() << "start Thread Data Server WriteData";
|
//qDebug() << "start Thread Data Server WriteData";
|
||||||
WriteData();
|
WriteData(m_qstrFullFileName);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
bool DataFileProcessor::WriteDarkDataFile()
|
||||||
|
{
|
||||||
|
//qDebug() << "start Thread Data Server GenerateFilePath";
|
||||||
|
// GenerateFilePath();
|
||||||
|
|
||||||
|
//qDebug() << "start Thread Data Server WriteEnvironmentInfo";
|
||||||
|
WriteEnvironmentInfo(m_qstrDarkFileName);
|
||||||
|
|
||||||
|
//qDebug() << "start Thread Data Server WriteDeviceInfo";
|
||||||
|
WriteDeviceInfo(m_qstrDarkFileName);
|
||||||
|
|
||||||
|
//qDebug() << "start Thread Data Server WriteData";
|
||||||
|
WriteDarkData(m_qstrDarkFileName);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,13 +81,15 @@ void DataFileProcessor::GenerateFilePath()
|
|||||||
m_struEC.qstrUTCDateTime = m_qdtTime.toUTC().toString("yyyy_MM_dd hh:mm:ss");
|
m_struEC.qstrUTCDateTime = m_qdtTime.toUTC().toString("yyyy_MM_dd hh:mm:ss");
|
||||||
|
|
||||||
m_qstrFullFileName = m_qstrFilePath + qstrAddYMD;
|
m_qstrFullFileName = m_qstrFilePath + qstrAddYMD;
|
||||||
|
m_qstrDarkFileName = m_qstrDarkFilePath + qstrAddYMD;
|
||||||
QString qstrTemp= m_qstrFullFileName;
|
QString qstrTemp= m_qstrFullFileName;
|
||||||
|
QString qstrTempDark = m_qstrDarkFileName;
|
||||||
if (m_struEC.qstrLocation=="")
|
if (m_struEC.qstrLocation=="")
|
||||||
{
|
{
|
||||||
m_struEC.qstrLocation = "Unknown";
|
m_struEC.qstrLocation = "Unknown";
|
||||||
}
|
}
|
||||||
m_qstrFullFileName= m_qstrFullFileName+"/"+m_struEC.qstrLocation + qstrAddHMS+".csv";
|
m_qstrFullFileName = m_qstrFullFileName+"/"+m_struEC.qstrLocation + qstrAddHMS+".csv";
|
||||||
|
m_qstrDarkFileName =m_qstrDarkFileName+"/"+m_struEC.qstrLocation+"_dark" + qstrAddHMS+".csv";
|
||||||
QDir qdirPath(qstrTemp);
|
QDir qdirPath(qstrTemp);
|
||||||
if (!qdirPath.exists())
|
if (!qdirPath.exists())
|
||||||
{
|
{
|
||||||
@ -76,12 +99,22 @@ void DataFileProcessor::GenerateFilePath()
|
|||||||
qDebug() << "DataFileProcessor mkdir Failed.";
|
qDebug() << "DataFileProcessor mkdir Failed.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QDir qdirPathDark(qstrTempDark);
|
||||||
|
if (!qdirPathDark.exists()) {
|
||||||
|
bool bRes = qdirPathDark.mkpath(qstrTempDark);
|
||||||
|
if (!bRes) {
|
||||||
|
qDebug()<< "DataDarkFileProcessor mkdir Failed.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataFileProcessor::WriteEnvironmentInfo()
|
bool DataFileProcessor::WriteEnvironmentInfo(QString path)
|
||||||
{
|
{
|
||||||
|
if (path=="")
|
||||||
|
{path=m_qstrFullFileName;}
|
||||||
bool bRes = true;
|
bool bRes = true;
|
||||||
QFile qfData(m_qstrFullFileName);
|
QFile qfData(path);
|
||||||
bRes = qfData.open(QFile::WriteOnly|QFile::Text|QFile::Truncate);
|
bRes = qfData.open(QFile::WriteOnly|QFile::Text|QFile::Truncate);
|
||||||
if (!bRes)
|
if (!bRes)
|
||||||
{
|
{
|
||||||
@ -145,9 +178,11 @@ bool DataFileProcessor::WriteEnvironmentInfo()
|
|||||||
return bRes;
|
return bRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFileProcessor::WriteDeviceInfo()
|
void DataFileProcessor::WriteDeviceInfo(QString path)
|
||||||
{
|
{
|
||||||
QFile qfData(m_qstrFullFileName);
|
if (path=="")
|
||||||
|
{path=m_qstrFullFileName;}
|
||||||
|
QFile qfData(path);
|
||||||
bool bRes = qfData.open(QFile::WriteOnly | QFile::Text | QIODevice::Append);
|
bool bRes = qfData.open(QFile::WriteOnly | QFile::Text | QIODevice::Append);
|
||||||
if (!bRes)
|
if (!bRes)
|
||||||
{
|
{
|
||||||
@ -215,9 +250,11 @@ void DataFileProcessor::WriteDeviceInfo()
|
|||||||
qfData.close();
|
qfData.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataFileProcessor::WriteData()
|
bool DataFileProcessor::WriteData(QString path)
|
||||||
{
|
{
|
||||||
QFile qfData(m_qstrFullFileName);
|
if (path=="")
|
||||||
|
{path=m_qstrFullFileName;}
|
||||||
|
QFile qfData(path);
|
||||||
bool bRes = qfData.open(QFile::WriteOnly | QFile::Text | QIODevice::Append);
|
bool bRes = qfData.open(QFile::WriteOnly | QFile::Text | QIODevice::Append);
|
||||||
if (!bRes)
|
if (!bRes)
|
||||||
{
|
{
|
||||||
@ -260,6 +297,59 @@ bool DataFileProcessor::WriteData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
qfData.close();
|
||||||
|
bool res = true;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataFileProcessor::WriteDarkData(QString path)
|
||||||
|
{
|
||||||
|
if (path=="")
|
||||||
|
{path=m_qstrDarkFileName;}
|
||||||
|
QFile qfData(path);
|
||||||
|
bool bRes = qfData.open(QFile::WriteOnly | QFile::Text | QIODevice::Append);
|
||||||
|
if (!bRes)
|
||||||
|
{
|
||||||
|
qDebug() << "WriteData open Failed.";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
QString qstrTemp;
|
||||||
|
qfData.write("Data Section");
|
||||||
|
qfData.write("\n");
|
||||||
|
|
||||||
|
using namespace ZZ_MISCDEF::IRIS;
|
||||||
|
for (int i=0;i<m_struDeviceContext.ucDeviceNumber;i++)
|
||||||
|
{
|
||||||
|
for (int j=0;j<m_vecDarkData[i].size();j++)
|
||||||
|
{
|
||||||
|
qstrTemp = QString::fromStdString(GetDeviceModelName(m_struDeviceContext.ucDeviceModel[i]));
|
||||||
|
qfData.write(qstrTemp.toLatin1());
|
||||||
|
qstrTemp = QString("_P%1").arg(j + 1);
|
||||||
|
qfData.write(qstrTemp.toLatin1());
|
||||||
|
qfData.write(",");
|
||||||
|
if ((m_vecDarkData[i][j].fTemperature < 5) /*&& (m_vecDarkData[i][j].fTemperature> -5)*/)
|
||||||
|
{
|
||||||
|
qfData.write("valid");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qfData.write("invalid");
|
||||||
|
}
|
||||||
|
|
||||||
|
qfData.write(",");
|
||||||
|
qstrTemp = QString::number(m_vecDarkData[i][j].usExposureTimeInMS);
|
||||||
|
qfData.write(qstrTemp.toLatin1());
|
||||||
|
for (int k=0;k< m_struDeviceContext.usPixels[i];k++)
|
||||||
|
{
|
||||||
|
qfData.write(",");
|
||||||
|
qstrTemp = QString::number(m_vecDarkData[i][j].lData[k]);
|
||||||
|
qfData.write(qstrTemp.toLatin1());
|
||||||
|
}
|
||||||
|
qfData.write("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
qfData.close();
|
||||||
bool res = true;
|
bool res = true;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,19 +16,23 @@ public:
|
|||||||
void SetManmadeEnviromentalContext(MEContext struMEC);
|
void SetManmadeEnviromentalContext(MEContext struMEC);
|
||||||
void SetDeviceInfo(FSContext struDeviceContext);
|
void SetDeviceInfo(FSContext struDeviceContext);
|
||||||
void SetData(std::vector<std::vector<DataFrame>> vecData);
|
void SetData(std::vector<std::vector<DataFrame>> vecData);
|
||||||
|
void SetDarkData(std::vector<std::vector<DataFrame>> vecData);
|
||||||
bool WriteDataFile();
|
bool WriteDataFile();
|
||||||
|
bool WriteDarkDataFile();
|
||||||
private:
|
private:
|
||||||
void GenerateFilePath();
|
void GenerateFilePath();
|
||||||
bool WriteEnvironmentInfo();
|
bool WriteEnvironmentInfo(QString path="");
|
||||||
void WriteDeviceInfo();
|
void WriteDeviceInfo(QString path="");
|
||||||
bool WriteData();
|
bool WriteData(QString path="");
|
||||||
|
bool WriteDarkData(QString path="");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
private:
|
private:
|
||||||
QString m_qstrFullFileName;
|
QString m_qstrFullFileName;
|
||||||
|
QString m_qstrDarkFileName;
|
||||||
QString m_qstrFileName;
|
QString m_qstrFileName;
|
||||||
QString m_qstrFilePath;
|
QString m_qstrFilePath;
|
||||||
|
QString m_qstrDarkFilePath;
|
||||||
|
|
||||||
QDateTime m_qdtTime;
|
QDateTime m_qdtTime;
|
||||||
|
|
||||||
@ -36,4 +40,5 @@ private:
|
|||||||
MEContext m_struMEC;
|
MEContext m_struMEC;
|
||||||
FSContext m_struDeviceContext;
|
FSContext m_struDeviceContext;
|
||||||
std::vector<std::vector<DataFrame>> m_vecData;
|
std::vector<std::vector<DataFrame>> m_vecData;
|
||||||
|
std::vector<std::vector<DataFrame>> m_vecDarkData;
|
||||||
};
|
};
|
||||||
@ -1,5 +1,5 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ļ<EFBFBD>
|
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ļ<EFBFBD>
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
@ -106,7 +106,7 @@ namespace ZZ_MISCDEF
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//ATPָ<50><D6B8>ת<EFBFBD><D7AA>
|
//ATPָ<50><D6B8>ת<EFBFBD><D7AA>
|
||||||
namespace ATP
|
namespace ATP
|
||||||
{
|
{
|
||||||
const int MAX_SPECTRUM_SIZE = 4096;
|
const int MAX_SPECTRUM_SIZE = 4096;
|
||||||
@ -145,7 +145,7 @@ namespace ZZ_MISCDEF
|
|||||||
ATP6500
|
ATP6500
|
||||||
};
|
};
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
|
//<2F><><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
|
||||||
typedef struct tagATPDataFrame
|
typedef struct tagATPDataFrame
|
||||||
{
|
{
|
||||||
unsigned short usExposureTime;
|
unsigned short usExposureTime;
|
||||||
@ -154,14 +154,14 @@ namespace ZZ_MISCDEF
|
|||||||
double dTimes = 0;
|
double dTimes = 0;
|
||||||
}ATPDataFrame;
|
}ATPDataFrame;
|
||||||
|
|
||||||
//<2F>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
//<2F>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||||
typedef struct tagATPDeviceInfo
|
typedef struct tagATPDeviceInfo
|
||||||
{
|
{
|
||||||
std::string strPN;
|
std::string strPN;
|
||||||
std::string strSN;
|
std::string strSN;
|
||||||
}ATPDeviceInfo;
|
}ATPDeviceInfo;
|
||||||
|
|
||||||
//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
typedef struct tagATPDeviceAttribute
|
typedef struct tagATPDeviceAttribute
|
||||||
{
|
{
|
||||||
int iPixels;
|
int iPixels;
|
||||||
@ -176,7 +176,7 @@ namespace ZZ_MISCDEF
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//<2F><><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
//<2F><><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
||||||
namespace ZZ_RUNPARAMS
|
namespace ZZ_RUNPARAMS
|
||||||
{
|
{
|
||||||
typedef struct tagErrorInfo
|
typedef struct tagErrorInfo
|
||||||
@ -236,6 +236,7 @@ namespace ZZ_MISCDEF
|
|||||||
FSContext fscParams;
|
FSContext fscParams;
|
||||||
AcqTimeSettings atsParams;
|
AcqTimeSettings atsParams;
|
||||||
AcqPosSettings apsParams;
|
AcqPosSettings apsParams;
|
||||||
|
bool issavedark;
|
||||||
}RunTimeGrabberParams;
|
}RunTimeGrabberParams;
|
||||||
|
|
||||||
typedef struct tagATPCalibrationSettings
|
typedef struct tagATPCalibrationSettings
|
||||||
@ -246,7 +247,7 @@ namespace ZZ_MISCDEF
|
|||||||
}ATPCalibrationSettings;
|
}ATPCalibrationSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ṹ
|
//ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ṹ
|
||||||
namespace ZZ_DATAFILE
|
namespace ZZ_DATAFILE
|
||||||
{
|
{
|
||||||
typedef struct tagEnvironmentalContext
|
typedef struct tagEnvironmentalContext
|
||||||
|
|||||||
@ -49,6 +49,9 @@ namespace QT_LOG
|
|||||||
outFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text);
|
outFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text);
|
||||||
QTextStream ts(&outFile);
|
QTextStream ts(&outFile);
|
||||||
ts << log_info << endl;
|
ts << log_info << endl;
|
||||||
|
|
||||||
|
std::cout<<log_info.toStdString()<<std::endl;
|
||||||
|
|
||||||
outFile.close();
|
outFile.close();
|
||||||
|
|
||||||
m_LogMutex.unlock();
|
m_LogMutex.unlock();
|
||||||
@ -56,7 +59,7 @@ namespace QT_LOG
|
|||||||
void logInit(QString logFile = "",int logLevel = 0)
|
void logInit(QString logFile = "",int logLevel = 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef _Debug
|
||||||
if ((logLevel < 0) || (logLevel > 3))
|
if ((logLevel < 0) || (logLevel > 3))
|
||||||
{
|
{
|
||||||
m_LogLevel = 1;
|
m_LogLevel = 1;
|
||||||
|
|||||||
@ -125,6 +125,39 @@
|
|||||||
struGrabberRTParams.fscParams = m_struFSContext;
|
struGrabberRTParams.fscParams = m_struFSContext;
|
||||||
struGrabberRTParams.lscParam = m_struLSContext;
|
struGrabberRTParams.lscParam = m_struLSContext;
|
||||||
struGrabberRTParams.apsParams = m_struAcqPosition;
|
struGrabberRTParams.apsParams = m_struAcqPosition;
|
||||||
|
|
||||||
|
|
||||||
|
struGrabberRTParams.issavedark=false;
|
||||||
|
// if (m_qjoJObj!= NULL) 判断m_qjoJObj是否有值
|
||||||
|
if (m_qjoJObj.contains("savedark")== true) {
|
||||||
|
QJsonValue savedarkValue = m_qjoJObj.value("savedark");
|
||||||
|
// 判断 QJsonValue 的类型,并提取布尔值
|
||||||
|
if (savedarkValue.isBool()) {
|
||||||
|
struGrabberRTParams.issavedark = savedarkValue.toBool();
|
||||||
|
qDebug() << "Found 'savedark' as boolean. Set issavedark to:" << struGrabberRTParams.issavedark;
|
||||||
|
} else if (savedarkValue.isString()) {
|
||||||
|
// 如果 JSON 中存储的是字符串 "true" 或 "false"
|
||||||
|
QString savedarkStr = savedarkValue.toString();
|
||||||
|
if (savedarkStr.compare("true", Qt::CaseInsensitive) == 0) {
|
||||||
|
struGrabberRTParams.issavedark = true;
|
||||||
|
qDebug() << "Found 'savedark' as string 'true'. Set issavedark to:" << struGrabberRTParams.issavedark;
|
||||||
|
} else if (savedarkStr.compare("false", Qt::CaseInsensitive) == 0) {
|
||||||
|
struGrabberRTParams.issavedark = false;
|
||||||
|
qDebug() << "Found 'savedark' as string 'false'. Set issavedark to:" << struGrabberRTParams.issavedark;
|
||||||
|
} else {
|
||||||
|
qDebug() << "Warning: 'savedark' field has an unexpected string value:" << savedarkStr;
|
||||||
|
// 如果值不是 "true" 或 "false",可以保持默认值或根据业务逻辑处理
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "Warning: 'savedark' field is neither boolean nor string. Value type:" << savedarkValue.type();
|
||||||
|
// 可以选择保持默认值,或者根据需要抛出错误
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
qDebug()<<"warning no savedark fied";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,7 @@ ZZ_HttpTransfer::~ZZ_HttpTransfer()
|
|||||||
|
|
||||||
int ZZ_HttpTransfer::SendData()
|
int ZZ_HttpTransfer::SendData()
|
||||||
{
|
{
|
||||||
|
return 0;
|
||||||
if (m_pNetworkManagerThread == nullptr)
|
if (m_pNetworkManagerThread == nullptr)
|
||||||
{
|
{
|
||||||
m_pNetworkManagerThread = new QNetworkAccessManager();
|
m_pNetworkManagerThread = new QNetworkAccessManager();
|
||||||
@ -83,6 +84,7 @@ int ZZ_HttpTransfer::SendData()
|
|||||||
|
|
||||||
int ZZ_HttpTransfer::SendInfo()
|
int ZZ_HttpTransfer::SendInfo()
|
||||||
{
|
{
|
||||||
|
return 0;
|
||||||
if (m_pNetworkManager == nullptr)
|
if (m_pNetworkManager == nullptr)
|
||||||
{
|
{
|
||||||
m_pNetworkManager = new QNetworkAccessManager();
|
m_pNetworkManager = new QNetworkAccessManager();
|
||||||
@ -156,6 +158,7 @@ int ZZ_HttpTransfer::SendInfo()
|
|||||||
|
|
||||||
int ZZ_HttpTransfer::SendErr()
|
int ZZ_HttpTransfer::SendErr()
|
||||||
{
|
{
|
||||||
|
return 0;
|
||||||
if (m_pNetworkManager == nullptr)
|
if (m_pNetworkManager == nullptr)
|
||||||
{
|
{
|
||||||
m_pNetworkManager = new QNetworkAccessManager();
|
m_pNetworkManager = new QNetworkAccessManager();
|
||||||
|
|||||||
Reference in New Issue
Block a user