This commit is contained in:
xin
2025-11-04 17:19:32 +08:00
parent 030381aa5c
commit 7c9b5728b9
37 changed files with 677 additions and 191 deletions

1
.gitignore vendored
View File

@ -24,3 +24,4 @@
/othersoft/TemperatureControler/project/cmake-build-debug-towersif/
/othersoft/TemperatureControler/project/cmake-build-debug-towersif/
/DEB/
/cmake-build-debug-nanopi/

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.5)
project(TowerOptoSifAndSpectral)
set(CMAKE_AUTOMOC ON)

4
ChangeLog.md Normal file
View 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

View File

@ -7,7 +7,7 @@
# exit 1
#fi
VERSION=2.1
VERSION=2.1.3
sh install.sh
thispwd=$(pwd)
@ -25,11 +25,30 @@ cp /home/pi/bin/* .
cd ../../..
mkdir DEBIAN
cd DEBIAN
echo "Package: TowerSif
Version: $VERSION
Architecture: armhf
Maintainer: rlx, tc
Description: test" > control
#echo "Package: TowerSif
#Version: $VERSION
#Architecture: armhf
#Maintainer: rlx, tc
#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 $thispwd

4
dpkg/control Normal file
View File

@ -0,0 +1,4 @@
Package: TowerSif
Architecture: armhf
Maintainer: rlx, tc
Description: test

34
dpkg/postinst Normal file
View 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
View File

@ -0,0 +1,3 @@
#!/bin/sh
echo "thank you for use"
#软件卸载后,执行该Shell脚本

View File

@ -46,13 +46,13 @@ if ($position==1)
{
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{
$port=$ini['FS'.($i+1)]['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")
{
$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{
$port=$ini['FS'.($i+1)]['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;
}
}

View File

@ -94,7 +94,7 @@ int main(int argc, char *argv[])
//m_mduUploader.Initialize();
m_ctrlHumitureDetector.Initialize(m_struHumitureDI.qstrInterfaceName.toStdString());
//////////////////////////////////////////////////////////////////////////prepare
m_sTimer.Preheating();
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_mdgGrabber.Init_Self();
m_sTimer.Preheating();
m_sTimer.SelfStart();
//////////////////////////////////////////////////////////////////////////test
// DataFileProcessor testdp;

View File

@ -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
}
}
}

View File

@ -1,4 +1,4 @@
{
{
"TimeConfig": {
"StartTime": "00:00:00",
"EndTime": "23:59:00",
@ -8,15 +8,20 @@
"PortName": "ttyS2",
"BaudRate": 115200,
"Pin": {
"TG": {
"Pin_H": 2,
"Pin_L": 3
"COOLER": {
"Pin": 24
},
"Fan": {
"Pin": 10
"Pin_H": 3,
"Pin_L": 2
},
"HOT": {
"Pin": 7
"Pin": 19
},
"WINDOWS": {
"Pin_H": 7,
"Pin_L": 10,
"WaitTime": 40
}
},
"Constant_Temperature": {

View File

@ -7,21 +7,88 @@
#include <QtCore/QCoreApplication>
#include <qthread.h>
#include <fstream>
#include "logout.h"
int main(int argc, char* argv[])
{
QCoreApplication aaaaa(argc, argv);
std::cout<<"Hello World"<<std::flush;
json j;
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;
logout("main","config data read finish",10);
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();

View File

@ -4,15 +4,32 @@
#include "TG_Manager.h"
#include "string"
#include "QThread"
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;
// this->pin1_H = pin1_H;
// this->pin1_L = pin1_L;
// this->pin2_H = pin2_H;
// this->pin2_L = pin2_L;
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)
{
@ -62,17 +79,43 @@ bool TG_Manager::SetTuiGan(int 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";
// 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);
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(comand2.c_str());
system(comand3.c_str());
system(comand4.c_str());
SetTuiGan(0);
SetSwitch1Status(0);
SetSwitch2Status(0);
system(comand5.c_str());
system(comand6.c_str());
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)
{
@ -104,29 +147,57 @@ bool TG_Manager::SetSwitch2Status(bool status)
return status;
}
bool TG_Manager::Heating()
bool TG_Manager::Heating(bool isworking)
{
printf("Heating\n");
SetTuiGan(true);
SetSwitch1Status(true);
SetSwitch2Status(false);
WorkingStatus = HEATING;
return true;
}
bool TG_Manager::Cooling()
bool TG_Manager::Cooling(bool isworking)
{
printf("Cooling\n");
SetTuiGan(false);
SetSwitch1Status(false);
SetSwitch2Status(true);
WorkingStatus = COOLING;
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(){
SetTuiGan(2);
SetSwitch1Status(false);
SetSwitch2Status(false);
std::string comment="gpio write " + std::to_string(Windows_Pin_H) + " 0";
std::string comment1="gpio write " + std::to_string(Windows_Pin_L) + " 0";
system(comment.c_str());
system(comment1.c_str());
WorkingStatus = NotWroking;
return true;

View File

@ -4,21 +4,36 @@
#ifndef TG_MANAGER_H
#define TG_MANAGER_H
#include <QObject>
enum WORKINGSTATUS{
HEATING=1,
COOLING=2,
WINDOWS_OPEN=3,
WINDOWS_CLOSE=4,
NotWroking=0
};
class TG_Manager {
// enum WINDOWS_STATUS{
// 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:
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();
bool Heating();
bool Cooling();
bool Heating(bool isworking);
bool Cooling(bool isworking);
bool Windows_Open();
bool Windows_Close();
bool Stop();
int GetManagerStatus();
@ -29,10 +44,35 @@ private:
bool SetTuiGan(int IS_High);
bool SetSwitch1Status(bool status);
bool SetSwitch2Status(bool status);
int m_time_for_wait_windows=40;
int pin1_H=7;
int pin1_L=10;
int pin2_H=2;
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;
int WorkingStatus=NotWroking;

View File

@ -7,6 +7,7 @@
#include <iostream>
#include <qthread.h>
#include <QDebug>
#include <logout.h>
TemperaTureWoker::TemperaTureWoker() {
}
@ -102,10 +103,21 @@ void TemperaTureWoker::ReadTempreature() {
if (lenth==0) {
//std::cout << "No data" << std::endl;
qDebug()<< "No data";
logout("TemperaSersor","no data from tempera sensor",10);
return;
}
std::cout << data.toStdString();
//qDebug() << data;
std::cout << data.toStdString()<< std::endl;
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());
for (int j = 0; j < 4; ++j) {
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) {
std::cout << "Group " << i << ":\t|";
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
// qDebug().noquote().nospace()<< m_Tempreaturegroups[i].tempera[j] << ":\t|";
std::cout << std::setw(10) << std::setfill(' ') << std::internal

View File

@ -53,33 +53,92 @@ void TemperatureRegulator::setconfig(json jconfig) {
}
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"];
// int pin1_H=7;
// int pin1_L=10;
// int pin2_H=2;
// int pin2_L=4;
// if (jconfig.contains("Pin")) {
// if (jconfig["Pin"].contains("")) {
// 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"];
// }
// }
// }
/*
* "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"]["Fan"].contains("Pin")) {
pin2_H=jconfig["Pin"]["Fan"]["Pin"];
if (jconfig["Pin"]["Fan"].contains("Pin_H")) {
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"]["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->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["Constant_Temperature"].contains("CoolBegin_Temp_Insight")) {
m_CoolBegin_Temp_Insight=jconfig["Constant_Temperature"]["CoolBegin_Temp_Insight"];
@ -238,10 +297,68 @@ void TemperatureRegulator::init(){
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(){
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();
@ -267,7 +384,7 @@ void TemperatureRegulator::loop(){
if (diff>m_CoolBegin_Diff_Temp) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰinsight<68>¶ȴ<C2B6><C8B4><EFBFBD><EFBFBD><EFBFBD><E8B6A8>ʼֵ
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);
} else {
m_TG_Manager->Stop();
@ -295,7 +412,7 @@ void TemperatureRegulator::loop(){
//<2F>ڶ<EFBFBD><DAB6><EFBFBD> <20><>m_HeatingBeginTemp_Insight<68>Ƚ<EFBFBD>
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);
}
else
@ -316,7 +433,7 @@ void TemperatureRegulator::loop(){
// <20><><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>
if (maxinsighttemp>minoutsighttemp)
{
m_TG_Manager->Cooling();
m_TG_Manager->Cooling(true);
logout("Temp","current max insight temp is "+QString::number(maxinsighttemp),6);
}
else
@ -337,11 +454,11 @@ void TemperatureRegulator::loop(){
// qDebug()<< "current tempreture is " << tempreture;
if (tempreture>M_Targert_Max_Tempreature)
{
m_TG_Manager->Cooling();
m_TG_Manager->Cooling(true);
}
else if (tempreture<M_Targert_Min_Tempreature)
{
m_TG_Manager->Heating();
m_TG_Manager->Heating(true);
}
else
{
@ -352,7 +469,7 @@ void TemperatureRegulator::loop(){
}
bool TemperatureRegulator::looptask() {
g_tempretureRegulator->loop();
g_tempretureRegulator->loopsample();
}

View File

@ -56,6 +56,7 @@ public:
float GetMin_of_Vector(int Data_type=INSIGHT_TEMPERATURE);
void init();
void loop();
void loopsample();
static bool looptask();
void PanduanCooling();
@ -77,6 +78,7 @@ private:
bool isinit=false;
float m_Latitude=39.9;
float m_Longitude=116.4;
long long last_time_in_today_minute=0;
};

View File

@ -74,11 +74,11 @@ void TimeWorker::onTimerTrigger() {
return;
}
m_isWork=true;
logout("TimeWorker","Task is working");
// logout("TimeWorker","Task is working");
int taskid=0;
foreach (auto task, m_TaskList) {
task();
logout("TimeWorker","Task "+QString::number(taskid)+" is finished",6);
//logout("TimeWorker","Task "+QString::number(taskid)+" is finished",6);
taskid++;
}

View File

@ -1,6 +1,7 @@
#include "logout.h"
#include "iostream"
extern FILE *file=NULL;
FILE *datafile=NULL;
#define _DEBUG
void (*pFunction)(QString message)= nullptr;
QString colorcode = "\033[";
@ -105,8 +106,8 @@ void writelogtofile(QString sender,QString qstr)
}
if (file==NULL)
{
QString path="/home/iris/log/"+currentTime.toString("yyyy_MM_dd")+".log";
system("mkdir -p /home/iris/log");
QString path="/home/data/Log/"+currentTime.toString("yyyy_MM_dd_hh_mm_ss")+"_Temptrue.log";
system("mkdir -p /home/data/Log");
file=fopen(path.toStdString().c_str(),"a+");
fprintf(file,"\n\n\n\nstart---------------------------------------------------------------------------------\n");
}
@ -122,22 +123,22 @@ void saveData(QString sender,QString qstr)
QString datestr=currentTime.toString("yyyy_MM_dd");
if (lastdatestr!=datestr)
{
if (file!=NULL)
if (datafile!=NULL)
{
fclose(file);
file=NULL;
datafile=NULL;
}
lastdatestr=datestr;
}
if (file==NULL)
if (datafile==NULL)
{
QString path="/home/iris/TempData/"+currentTime.toString("yyyy_MM_dd")+".csv";
system("mkdir -p /home/iris/TempData");
file=fopen(path.toStdString().c_str(),"a+");
fprintf(file,QString::fromLocal8Bit("日期, 数据类型, 日期~n").toStdString().c_str());
QString path="/home/data/TempData/"+currentTime.toString("yyyy_MM_dd_hh_mm_ss")+".csv";
system("mkdir -p /home/data/TempData");
datafile=fopen(path.toStdString().c_str(),"a+");
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());
fflush(file);
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(datafile);
}

View File

@ -19,7 +19,7 @@ void logout(T str)
std::cout<<qstr.toStdString()<<std::endl<<std::flush;
#endif
}
void saveData(QString sender,QString qstr);
template <typename T>
void saveDataToFile(QString typeofdata,T str) {
@ -35,7 +35,7 @@ void saveDataToFile(QString typeofdata,T str) {
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;
QString qstr=QString(str);
writelogtofile(typeofdata,str);
saveData(typeofdata,str);
}

View File

@ -21,10 +21,10 @@ cd ../
mkdir -p TemperatureControler
cd TemperatureControler
cmake ../../TemperatureControler/project
make -j4
make
cp ./TemperatureControler /home/pi/bin
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 ../
mkdir -p console
@ -46,7 +46,7 @@ cp ./root/start.sh /root
chmod +x /root/start.sh
mkdir -p /home/data
cd ../
rm -rf ./TowerOptoSifAndSpectral
#rm -rf ./TowerOptoSifAndSpectral
cd /root/filebrew
chmod +x ./filebrowser
./filebrowser config set -a 0.0.0.0

29
root/Mywathdogtemp.sh Normal file
View 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

View File

@ -5,6 +5,8 @@ chmod +x /root/ffwatch.sh
/root/ffwatch.sh &
mount /dev/mmcblk1p1 /home/data/
chmod +x /root/Mywathdog.sh
chmod +x /root/Mywathdogtemp.sh
bash /root/Mywathdog.sh &
bash /root/Mywathdogtemp.sh &
/home/pi/bin/TemperatureControler > /root/templog.log &

View File

@ -562,6 +562,7 @@ int CMainDataGrabber::GrabOnceFinished()
// m_struAcqPosSetting.iPosition[i + 1];
m_iFlagIsCapturing_Signal = 1;
emit SignalStartGrabOnce_Signal();
while (m_iFlagIsCapturing_Signal)
{
@ -596,6 +597,7 @@ int CMainDataGrabber::GrabOnceFinished()
//m_struAcqPosSetting.iPosition[0];
m_iFlagIsCapturing_Dark = 1;
// todo : 机载时是否有实时采集暗电流
emit SignalStartGrabOnce_Dark();
while (m_iFlagIsCapturing_Dark)
{
@ -619,6 +621,9 @@ int CMainDataGrabber::GrabOnceFinished()
}
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++)
{
@ -629,6 +634,10 @@ int CMainDataGrabber::GrabOnceFinished()
SubDataFrame(vecSignal[j], vecDark[j], m_struDeviceContext.usPixels[i]);
}
vecData.push_back(vecSignal);
if (savedarkfile) {
vecDarkData.push_back(vecDark);
}
qDebug() << "ucDeviceNumber" << i << " Data Size" << vecSignal.size();
//vecData[i].push_back();
}
@ -639,8 +648,15 @@ int CMainDataGrabber::GrabOnceFinished()
m_pmduUploader->SetData(vecData);
emit SignalPushOneDataFrame();
m_pdfpSaver->SetData(vecData);
if (savedarkfile) {
m_pdfpSaver->SetDarkData(vecDarkData);
}
qDebug() << "Thread Data Server: WriteDataFile Called";
m_pdfpSaver->WriteDataFile();
if (savedarkfile) {
m_pdfpSaver->WriteDarkDataFile();
}
}
m_iFlagIsCapturing = 0;

View File

@ -4,8 +4,10 @@ DataFileProcessor::DataFileProcessor(QObject* parent /*= nullptr*/)
{
#ifdef _DEBUG
m_qstrFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/Data";
m_qstrDarkFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/Dark";
#else
m_qstrFilePath = "/home/data/Data";
m_qstrDarkFilePath="/home/data/Dark";
#endif // DEBUG
}
@ -33,21 +35,40 @@ void DataFileProcessor::SetData(std::vector<std::vector<DataFrame>> vecData)
{
m_vecData.clear();
m_vecData = vecData;
}
}
void DataFileProcessor::SetDarkData(std::vector<std::vector<DataFrame>> vecData) {
m_vecDarkData.clear();
m_vecDarkData = vecData;
}
bool DataFileProcessor::WriteDataFile()
{
//qDebug() << "start Thread Data Server GenerateFilePath";
GenerateFilePath();
//qDebug() << "start Thread Data Server WriteEnvironmentInfo";
WriteEnvironmentInfo();
WriteEnvironmentInfo(m_qstrFullFileName);
//qDebug() << "start Thread Data Server WriteDeviceInfo";
WriteDeviceInfo();
WriteDeviceInfo(m_qstrFullFileName);
//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;
}
@ -60,13 +81,15 @@ void DataFileProcessor::GenerateFilePath()
m_struEC.qstrUTCDateTime = m_qdtTime.toUTC().toString("yyyy_MM_dd hh:mm:ss");
m_qstrFullFileName = m_qstrFilePath + qstrAddYMD;
m_qstrDarkFileName = m_qstrDarkFilePath + qstrAddYMD;
QString qstrTemp= m_qstrFullFileName;
QString qstrTempDark = m_qstrDarkFileName;
if (m_struEC.qstrLocation=="")
{
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);
if (!qdirPath.exists())
{
@ -76,12 +99,22 @@ void DataFileProcessor::GenerateFilePath()
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;
QFile qfData(m_qstrFullFileName);
QFile qfData(path);
bRes = qfData.open(QFile::WriteOnly|QFile::Text|QFile::Truncate);
if (!bRes)
{
@ -145,9 +178,11 @@ bool DataFileProcessor::WriteEnvironmentInfo()
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);
if (!bRes)
{
@ -215,9 +250,11 @@ void DataFileProcessor::WriteDeviceInfo()
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);
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;
return res;
}

View File

@ -16,19 +16,23 @@ public:
void SetManmadeEnviromentalContext(MEContext struMEC);
void SetDeviceInfo(FSContext struDeviceContext);
void SetData(std::vector<std::vector<DataFrame>> vecData);
void SetDarkData(std::vector<std::vector<DataFrame>> vecData);
bool WriteDataFile();
bool WriteDarkDataFile();
private:
void GenerateFilePath();
bool WriteEnvironmentInfo();
void WriteDeviceInfo();
bool WriteData();
bool WriteEnvironmentInfo(QString path="");
void WriteDeviceInfo(QString path="");
bool WriteData(QString path="");
bool WriteDarkData(QString path="");
public:
private:
QString m_qstrFullFileName;
QString m_qstrDarkFileName;
QString m_qstrFileName;
QString m_qstrFilePath;
QString m_qstrDarkFilePath;
QDateTime m_qdtTime;
@ -36,4 +40,5 @@ private:
MEContext m_struMEC;
FSContext m_struDeviceContext;
std::vector<std::vector<DataFrame>> m_vecData;
std::vector<std::vector<DataFrame>> m_vecDarkData;
};

View File

@ -1,5 +1,5 @@
//////////////////////////////////////////////////////////////////////////
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ļ<EFBFBD>
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ļ<EFBFBD>
//////////////////////////////////////////////////////////////////////////
#pragma once
#include "pch.h"
@ -106,7 +106,7 @@ namespace ZZ_MISCDEF
};
//ATPָ<50><D6B8>ת<EFBFBD><D7AA>
//ATPָ<50><D6B8>ת<EFBFBD><D7AA>
namespace ATP
{
const int MAX_SPECTRUM_SIZE = 4096;
@ -145,7 +145,7 @@ namespace ZZ_MISCDEF
ATP6500
};
//<2F><><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
typedef struct tagATPDataFrame
{
unsigned short usExposureTime;
@ -154,14 +154,14 @@ namespace ZZ_MISCDEF
double dTimes = 0;
}ATPDataFrame;
//<2F><EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
//<2F><EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
typedef struct tagATPDeviceInfo
{
std::string strPN;
std::string strSN;
}ATPDeviceInfo;
//<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
typedef struct tagATPDeviceAttribute
{
int iPixels;
@ -176,7 +176,7 @@ namespace ZZ_MISCDEF
}
//<2F><><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
//<2F><><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
namespace ZZ_RUNPARAMS
{
typedef struct tagErrorInfo
@ -236,6 +236,7 @@ namespace ZZ_MISCDEF
FSContext fscParams;
AcqTimeSettings atsParams;
AcqPosSettings apsParams;
bool issavedark;
}RunTimeGrabberParams;
typedef struct tagATPCalibrationSettings
@ -246,7 +247,7 @@ namespace ZZ_MISCDEF
}ATPCalibrationSettings;
}
//ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>
//ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>
namespace ZZ_DATAFILE
{
typedef struct tagEnvironmentalContext

View File

@ -49,6 +49,9 @@ namespace QT_LOG
outFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text);
QTextStream ts(&outFile);
ts << log_info << endl;
std::cout<<log_info.toStdString()<<std::endl;
outFile.close();
m_LogMutex.unlock();
@ -56,7 +59,7 @@ namespace QT_LOG
void logInit(QString logFile = "",int logLevel = 0)
{
#ifndef DEBUG
#ifndef _Debug
if ((logLevel < 0) || (logLevel > 3))
{
m_LogLevel = 1;

View File

@ -125,6 +125,39 @@
struGrabberRTParams.fscParams = m_struFSContext;
struGrabberRTParams.lscParam = m_struLSContext;
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;
}

View File

@ -26,6 +26,7 @@ ZZ_HttpTransfer::~ZZ_HttpTransfer()
int ZZ_HttpTransfer::SendData()
{
return 0;
if (m_pNetworkManagerThread == nullptr)
{
m_pNetworkManagerThread = new QNetworkAccessManager();
@ -83,6 +84,7 @@ int ZZ_HttpTransfer::SendData()
int ZZ_HttpTransfer::SendInfo()
{
return 0;
if (m_pNetworkManager == nullptr)
{
m_pNetworkManager = new QNetworkAccessManager();
@ -156,6 +158,7 @@ int ZZ_HttpTransfer::SendInfo()
int ZZ_HttpTransfer::SendErr()
{
return 0;
if (m_pNetworkManager == nullptr)
{
m_pNetworkManager = new QNetworkAccessManager();