diff --git a/.gitignore b/.gitignore
index a5909d5..4fc5ac0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,3 +25,8 @@
/othersoft/TemperatureControler/project/cmake-build-debug-towersif/
/DEB/
/cmake-build-debug-nanopi/
+/othersoft/GPSLog/project/cmake-build-debug/
+/othersoft/GPSLog/project/cmake-build-debug-nanopi_sif/
+/othersoft/GPSLog/build/
+/othersoft/GPSLog/.idea/
+/othersoft/calibration_console/cmake-build-debug/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b12238b..3f83605 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.5)
-project(TowerOptoSifAndSpectral)
+project(AirOptoSifAndSpectral)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
@@ -26,17 +26,17 @@ include_directories("source/Uploader")
link_directories("source/OSIF/DLib")
link_directories("/home/pi/SeaBrease/lib")
-add_executable( TowerOptoSifAndSpectral
+add_executable( AirOptoSifAndSpectral
main.cpp
${HDR_LIST}
${SRC_LIST}
)
IF (WIN32)
- target_link_libraries(TowerOptoSifAndSpectral SeaBreeze)
+ target_link_libraries(AirOptoSifAndSpectral SeaBreeze)
ELSE ()
- target_link_libraries(TowerOptoSifAndSpectral seabreeze usb stdc++ m)
+ target_link_libraries(AirOptoSifAndSpectral seabreeze usb stdc++ m)
ENDIF ()
-qt5_use_modules(TowerOptoSifAndSpectral ${QT})
-set_target_properties(TowerOptoSifAndSpectral PROPERTIES AUTOMOC ON)
+qt5_use_modules(AirOptoSifAndSpectral ${QT})
+set_target_properties(AirOptoSifAndSpectral PROPERTIES AUTOMOC ON)
diff --git a/deb_pack.sh b/deb_pack.sh
index 6896626..fecec9b 100755
--- a/deb_pack.sh
+++ b/deb_pack.sh
@@ -7,7 +7,7 @@
# exit 1
#fi
-VERSION=2.1.3
+VERSION=2.1.5
sh install.sh
thispwd=$(pwd)
@@ -52,9 +52,9 @@ cp ../ChangeLog.md ./home/data/ChangeLog.md
#cd /home/pi/
cd $thispwd
-sudo dpkg -b $DebDirectory TowerSif_V${VERSION}.deb
+sudo dpkg -b $DebDirectory AIRSif_V${VERSION}.deb
mkdir -p DEB
-cp TowerSif_V${VERSION}.deb DEB/
+cp AIRSif_V${VERSION}.deb DEB/
rm -r $DebDirectory
#sudo dpkg -r TowerSif
diff --git a/html/config.html b/html/config.html
index f0db299..0e1504a 100644
--- a/html/config.html
+++ b/html/config.html
@@ -37,7 +37,7 @@
开始时间
|
时间间隔
- |
+
停止时间
|
diff --git a/html/index.html b/html/index.html
index faef173..2d8f94d 100644
--- a/html/index.html
+++ b/html/index.html
@@ -13,7 +13,7 @@
| 程序运行状态 |
- |
+ |
|
|
@@ -37,7 +37,7 @@
开始时间
|
时间间隔
- |
+
停止时间
|
diff --git a/html/php/GetSata.php b/html/php/GetSata.php
index 350b33a..84dacbe 100644
--- a/html/php/GetSata.php
+++ b/html/php/GetSata.php
@@ -1,10 +1,16 @@
0)
+if ( count($output)>0&& count($output1)>0 )
{
- echo '';
-}else{
- echo '';
+ echo 'READY
';
+}else if(count($output)==0&& count($output1)>0){
+ echo 'SIF NOT WORK
';}
+else if(count($output)>0&& count($output1)==0){
+ echo 'GPS NOT WORK
';
+}
+else{
+ echo 'NO APPLOCATION WOKR
';
}
\ No newline at end of file
diff --git a/html/php/reboot.php b/html/php/reboot.php
index 36a6fa2..6855194 100644
--- a/html/php/reboot.php
+++ b/html/php/reboot.php
@@ -1,8 +1,12 @@
>log.txt &
-
+/root/Mywathdogtemp.sh &
diff --git a/main.cpp b/main.cpp
index 038b673..f304719 100644
--- a/main.cpp
+++ b/main.cpp
@@ -60,6 +60,8 @@ int main(int argc, char *argv[])
iRet0 = system("gpio mode 1 out");
iRet1 = system("gpio mode 4 out");
iRet2 = system("gpio mode 5 out");
+ system("gpio mode 13 input");
+ system("gpio write 13 0");
iRet3 = system("gpio write 1 1");//上电
qDebug() << "gpio 1;4;5; ready"<<" Ret:"<< iRet0<< iRet1<< iRet2<< endl;
@@ -128,7 +130,7 @@ int main(int argc, char *argv[])
m_pqUploaderThreadHolder->start();
m_mdgGrabber.Init_Self();
- m_sTimer.Preheating();
+ //m_sTimer.Preheating();
m_sTimer.SelfStart();
//////////////////////////////////////////////////////////////////////////test
// DataFileProcessor testdp;
diff --git a/othersoft/GPSLog/project/CMakeLists.txt b/othersoft/GPSLog/project/CMakeLists.txt
new file mode 100644
index 0000000..d158a12
--- /dev/null
+++ b/othersoft/GPSLog/project/CMakeLists.txt
@@ -0,0 +1,28 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(GPSLog)
+
+set(CMAKE_CXX_STANDARD 11)
+
+# Qt 5.12 需要手动指定 Qt 模块
+set(QT_MODULES Core SerialPort)
+
+find_package(Qt5 COMPONENTS ${QT_MODULES} REQUIRED)
+
+include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5SerialPort_INCLUDE_DIRS})
+include_directories("../src/Logger")
+
+# Source files
+file(GLOB SOURCES "../src/*.cpp" "../src/*.h")
+
+# Tell CMake to run moc when necessary
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+
+message(STATUS "SOURCES: ${SOURCES}")
+
+add_executable(GPSLog ${SOURCES})
+
+qt5_use_modules(GPSLog Core SerialPort)
+
+target_link_libraries(GPSLog Qt5::Core Qt5::SerialPort)
\ No newline at end of file
diff --git a/othersoft/GPSLog/src/DataLogger.cpp b/othersoft/GPSLog/src/DataLogger.cpp
new file mode 100644
index 0000000..1e35e17
--- /dev/null
+++ b/othersoft/GPSLog/src/DataLogger.cpp
@@ -0,0 +1,36 @@
+#include "DataLogger.h"
+#include
+
+DataLogger::DataLogger(const QString &filePath, QObject *parent)
+ : QObject(parent),
+ m_filePath(filePath),
+ m_file(filePath)
+{
+ m_stream.setDevice(&m_file);
+}
+
+bool DataLogger::openFile()
+{
+ if (m_file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
+ qDebug() << "Data log file opened: " << m_filePath;
+ return true;
+ } else {
+ qDebug() << "Failed to open data log file: " << m_filePath << ", error: " << m_file.errorString();
+ return false;
+ }
+}
+
+void DataLogger::closeFile()
+{
+ if (m_file.isOpen()) {
+ m_stream.flush();
+ m_file.close();
+ qDebug() << "Data log file closed: " << m_filePath;
+ }
+}
+
+void DataLogger::logData(const QString &computerTime, const QString &gpsTime, double latitude, double longitude, double altitude)
+{
+ m_stream << computerTime << "," << gpsTime << "," << latitude << "," << longitude << "," << altitude << "\n";
+ m_stream.flush();
+}
\ No newline at end of file
diff --git a/othersoft/GPSLog/src/DataLogger.h b/othersoft/GPSLog/src/DataLogger.h
new file mode 100644
index 0000000..c821af7
--- /dev/null
+++ b/othersoft/GPSLog/src/DataLogger.h
@@ -0,0 +1,25 @@
+#ifndef DATALOGGER_H
+#define DATALOGGER_H
+
+#include
+#include
+#include
+#include
+
+class DataLogger : public QObject
+{
+ Q_OBJECT
+public:
+ explicit DataLogger(const QString &filePath, QObject *parent = nullptr);
+
+ bool openFile();
+ void closeFile();
+ void logData(const QString &computerTime, const QString &gpsTime, double latitude, double longitude, double altitude);
+
+private:
+ QString m_filePath;
+ QFile m_file;
+ QTextStream m_stream;
+};
+
+#endif // DATALOGGER_H
\ No newline at end of file
diff --git a/othersoft/GPSLog/src/GPSDataParser.cpp b/othersoft/GPSLog/src/GPSDataParser.cpp
new file mode 100644
index 0000000..3a1b568
--- /dev/null
+++ b/othersoft/GPSLog/src/GPSDataParser.cpp
@@ -0,0 +1,105 @@
+#include "GPSDataParser.h"
+#include
+#include
+#include
+#include
+
+GPSDataParser::GPSDataParser(QObject *parent)
+ : QObject(parent),
+ m_latitude(0.0),
+ m_longitude(0.0),
+ m_altitude(0.0)
+{
+}
+
+long timeshasrecive=0;
+float alttiude_last=0.0;
+void GPSDataParser::parse(const QByteArray &nmeaData)
+{
+ if (timeshasrecive>=2000)timeshasrecive=0;
+ timeshasrecive++;
+ if (timeshasrecive<10)
+ qDebug() << "Received NMEA data: " << nmeaData;
+
+
+ QString nmeaString = QString::fromUtf8(nmeaData);
+ QStringList nmeaParts = nmeaString.split(",");
+
+ // if (nmeaParts.size() < 11) {
+ // qDebug() << "Invalid NMEA data: " << nmeaString;
+ // return;
+ // }
+
+ // Parse GPGGA sentence
+ // qDebug() << " first " << nmeaParts[0];
+ if (nmeaParts[0] == "$GPGGA"|| nmeaParts[0] == "$GNGGA") {
+ // qDebug() << " GGA data: " << nmeaString;
+ if (nmeaParts.size() < 10) {
+ qDebug() << "Invalid GGA data: " << nmeaString;
+ return;
+ }
+ QString utcTime = nmeaParts[1];
+
+ bool ok;
+ double latitudeDegrees = nmeaParts[2].toDouble(&ok);
+ if (!ok) return;
+ char latitudeDirection = nmeaParts[3].at(0).toLatin1();
+
+ double longitudeDegrees = nmeaParts[4].toDouble(&ok);
+ if (!ok) return;
+ char longitudeDirection = nmeaParts[5].at(0).toLatin1();
+
+ double altitude = nmeaParts[9].toDouble(&ok);
+ if (!ok) return;
+
+ double latitude = convertToDecimalDegrees(latitudeDegrees, latitudeDirection);
+ double longitude = convertToDecimalDegrees(longitudeDegrees, longitudeDirection);
+ //emit dataParsed(utcTime, latitude, longitude, altitude);
+ alttiude_last=altitude;
+ } else if (nmeaParts[0] == "$GPRMC"|| nmeaParts[0] == "$GNRMC") {
+
+ // qDebug() << "valid RMC data: " << nmeaString;
+ if (nmeaParts.size() < 7) {
+ qDebug() << "Invalid RMC data: " << nmeaString;
+ return;
+ }
+ QString utcTime = nmeaParts[1];
+ char status = nmeaParts[2].at(0).toLatin1();
+ if (status == 'A') {
+
+ bool ok;
+ double latitudeDegrees = nmeaParts[3].toDouble(&ok);
+ if (!ok) return;
+ char latitudeDirection = nmeaParts[4].at(0).toLatin1();
+
+ double longitudeDegrees = nmeaParts[5].toDouble(&ok);
+ if (!ok) return;
+ char longitudeDirection = nmeaParts[6].at(0).toLatin1();
+
+ double latitude = convertToDecimalDegrees(latitudeDegrees, latitudeDirection);
+ double longitude = convertToDecimalDegrees(longitudeDegrees, longitudeDirection);
+ double altitude = 0.0; // RMC doesn't have altitude
+ emit dataParsed(utcTime, latitude, longitude, alttiude_last);
+ // // 输出utc lat long alt
+ // qDebug()<< "RMC Parsed Data - UTC Time:" << utcTime
+ // << "Latitude:" << latitude
+ // << "Longitude:" << longitude
+ // << "Altitude:" << altitude;
+ system("gpio mode 13 out");
+ }
+ } else {
+ // qDebug() << "other NMEA data: " << nmeaString;
+ }
+}
+double GPSDataParser::convertToDecimalDegrees(double degreesMinutes, char direction)
+{
+ double degrees = int(degreesMinutes / 100);
+ double minutes = degreesMinutes - (degrees * 100);
+ double decimalDegrees = degrees + (minutes / 60);
+
+ if (direction == 'S' || direction == 'W') {
+ decimalDegrees *= -1;
+ }
+
+ return decimalDegrees;
+}
\ No newline at end of file
diff --git a/othersoft/GPSLog/src/GPSDataParser.h b/othersoft/GPSLog/src/GPSDataParser.h
new file mode 100644
index 0000000..c730953
--- /dev/null
+++ b/othersoft/GPSLog/src/GPSDataParser.h
@@ -0,0 +1,36 @@
+#ifndef GPSDATAPARSER_H
+#define GPSDATAPARSER_H
+
+#include
+#include
+#include
+
+class GPSDataParser : public QObject
+{
+ Q_OBJECT
+public:
+ explicit GPSDataParser(QObject *parent = nullptr);
+
+ void parse(const QByteArray &nmeaData);
+
+signals:
+ void dataParsed(const QString &gpsTime, double latitude, double longitude, double altitude);
+
+
+private:
+ double convertToDecimalDegrees(double degreesMinutes, char direction);
+
+private:
+ QString m_utcTime;
+ double m_latitude;
+ double m_longitude;
+ double m_altitude;
+
+public:
+ inline QString getUTCTime() const { return m_utcTime; }
+ inline double getLatitude() const { return m_latitude; }
+ inline double getLongitude() const { return m_longitude; }
+ inline double getAltitude() const { return m_altitude; }
+};
+
+#endif // GPSDATAPARSER_H
\ No newline at end of file
diff --git a/othersoft/GPSLog/src/Logger/Logger.h b/othersoft/GPSLog/src/Logger/Logger.h
new file mode 100644
index 0000000..3f7cb81
--- /dev/null
+++ b/othersoft/GPSLog/src/Logger/Logger.h
@@ -0,0 +1,94 @@
+//
+// Created by xin on 2021/8/17.
+//edit by zz.
+//fixed code page problem;added a new initialize function; --20211101
+#pragma once
+
+#include
+#include
+#include
+#include "qmutex.h"
+#include "QtMsgHandler"
+#include
+#include
+namespace QT_LOG
+{
+ static int m_LogLevel = 1;
+ static QString m_LogFile = QString("%1_GPS.log").arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmss"));
+ QMutex m_LogMutex;
+
+ void customMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+ {
+ if (type < m_LogLevel)
+ {
+ return;
+ }
+
+ QString log_info;
+ switch (type)
+ {
+ case QtDebugMsg:
+ log_info = QString("%1:%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"),msg);
+ break;
+
+ case QtWarningMsg:
+ log_info = QString("%1[Warning]:%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"),msg);
+ break;
+
+ case QtCriticalMsg:
+ log_info = QString("%1[Critical]:%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"),msg);
+ break;
+
+ case QtFatalMsg:
+ log_info = QString("%1[Fatal]:%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"),msg);
+ abort();
+ }
+
+ m_LogMutex.lock();
+
+ QFile outFile(m_LogFile);
+ outFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text);
+ QTextStream ts(&outFile);
+ ts << log_info << endl;
+
+ std::cout< 3))
+ {
+ m_LogLevel = 1;
+ }
+ else
+ {
+ m_LogLevel = logLevel;
+ }
+
+ if (!logFile.isEmpty())
+ {
+ m_LogFile = logFile+"/"+m_LogFile;
+ }
+
+ qInstallMessageHandler(customMessageHandler);
+ //qInstallMsgHandler(customMessageHandler);
+#endif
+ }
+
+ //added by IRIS_ZZ initialize from main
+ void InitLogger(QString qstrDir)
+ {
+ QDir qdLogFolder;
+ qdLogFolder.mkdir(qstrDir);
+ qDebug() << QT_LOG::m_LogFile;
+ QT_LOG::logInit(qstrDir);
+ }
+};
+
+
+
diff --git a/othersoft/GPSLog/src/SerialPortReader.cpp b/othersoft/GPSLog/src/SerialPortReader.cpp
new file mode 100644
index 0000000..031994c
--- /dev/null
+++ b/othersoft/GPSLog/src/SerialPortReader.cpp
@@ -0,0 +1,58 @@
+#include "SerialPortReader.h"
+
+SerialPortReader::SerialPortReader(const QString &portName, int baudRate, QObject *parent)
+ : QObject(parent),
+ m_portName(portName),
+ m_baudRate(baudRate),
+ m_serialPort(new QSerialPort(this))
+{
+ m_serialPort->setPortName(m_portName);
+ m_serialPort->setBaudRate(115200);
+
+ connect(m_serialPort, &QSerialPort::readyRead, this, &SerialPortReader::readData);
+}
+
+SerialPortReader::~SerialPortReader()
+{
+ closePort();
+}
+
+bool SerialPortReader::openPort()
+{
+ if (m_serialPort->open(QIODevice::ReadOnly)) {
+ qDebug() << "Serial port opened: " << m_portName;
+ return true;
+ } else {
+ qDebug() << "Failed to open serial port: " << m_portName << ", error: " << m_serialPort->errorString();
+ return false;
+ }
+}
+
+void SerialPortReader::closePort()
+{
+ if (m_serialPort->isOpen()) {
+ m_serialPort->close();
+ qDebug() << "Serial port closed: " << m_portName;
+ }
+}
+
+void SerialPortReader::start()
+{
+ if (!openPort()) {
+ return;
+ }
+}
+
+void SerialPortReader::readData()
+{
+ QByteArray newData = m_serialPort->readAll();
+ m_buffer.append(newData);
+
+ int nmeaEndIndex = m_buffer.indexOf("\r\n");
+ while (nmeaEndIndex != -1) {
+ QByteArray nmeaData = m_buffer.left(nmeaEndIndex);
+ m_buffer.remove(0, nmeaEndIndex + 2);
+ nmeaEndIndex = m_buffer.indexOf("\r\n");
+ emit dataReceived(nmeaData);
+ }
+}
\ No newline at end of file
diff --git a/othersoft/GPSLog/src/SerialPortReader.h b/othersoft/GPSLog/src/SerialPortReader.h
new file mode 100644
index 0000000..b4b9785
--- /dev/null
+++ b/othersoft/GPSLog/src/SerialPortReader.h
@@ -0,0 +1,35 @@
+#ifndef SERIALPORTREADER_H
+#define SERIALPORTREADER_H
+
+#include
+#include
+#include
+#include
+#include
+
+class SerialPortReader : public QObject
+{
+ Q_OBJECT
+public:
+ explicit SerialPortReader(const QString &portName, int baudRate, QObject *parent = nullptr);
+ ~SerialPortReader();
+
+ bool openPort();
+ void closePort();
+
+ void start();
+
+signals:
+ void dataReceived(const QByteArray &data);
+
+private slots:
+ void readData();
+
+private:
+ QString m_portName;
+ int m_baudRate;
+ QSerialPort *m_serialPort;
+ QByteArray m_buffer;
+};
+
+#endif // SERIALPORTREADER_H
\ No newline at end of file
diff --git a/othersoft/GPSLog/src/main.cpp b/othersoft/GPSLog/src/main.cpp
new file mode 100644
index 0000000..750d522
--- /dev/null
+++ b/othersoft/GPSLog/src/main.cpp
@@ -0,0 +1,62 @@
+#include
+#include
+#include
+#include
+#include
+
+#include "SerialPortReader.h"
+#include "GPSDataParser.h"
+#include "DataLogger.h"
+#include "Logger/Logger.h"
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication a(argc, argv);
+ system("gpio mode 13 input");
+ QT_LOG::InitLogger("/home/data/Log/");
+
+ // 1. 查找可用的串口
+ QString serialPortName;
+ const auto serialPortInfos = QSerialPortInfo::availablePorts();
+ if (!serialPortInfos.isEmpty()) {
+ for (const QSerialPortInfo &serialPortInfo : serialPortInfos) {
+ qDebug() << "Available serial port: " << serialPortInfo.portName();
+ }
+ // 默认使用第一个串口
+ serialPortName = serialPortInfos.first().portName();
+ } else {
+ qDebug() << "No serial port found.";
+ return 1;
+ }
+
+ // 3. 创建 SerialPortReader, GPSDataParser, DataLogger
+ SerialPortReader serialPortReader("/dev/ttyS2", 115200);
+ GPSDataParser gpsDataParser;
+ QDateTime datenow=QDateTime::currentDateTime();
+ QString fileparenth=QString("/home/data/GPS_Data/%1").arg(datenow.toString("yyyyMMdd"));
+ QString command=QString("mkdir -p %1").arg(fileparenth);
+ system(command.toStdString().c_str());
+ QString filePath = fileparenth+QString("/%1_gps.csv").arg( datenow.toString("yyyyMMdd_HHmmss"));
+ DataLogger dataLogger(filePath);
+ if (!dataLogger.openFile()) {
+ return 1;
+ }
+
+ // 4. 连接信号和槽
+ QObject::connect(&serialPortReader, &SerialPortReader::dataReceived, &gpsDataParser, &GPSDataParser::parse);
+ QObject::connect(&gpsDataParser, &GPSDataParser::dataParsed, [&](const QString &gpsTime, double latitude, double longitude, double altitude) {
+ QString computerTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz");
+ dataLogger.logData(computerTime, gpsTime, latitude, longitude, altitude);
+ });
+
+ // 5. 启动串口读取
+ serialPortReader.start();
+
+ // 6. 启动应用程序事件循环
+ int result = a.exec();
+
+ // 7. 关闭文件
+ dataLogger.closeFile();
+
+ return result;
+}
\ No newline at end of file
diff --git a/othersoft/install.sh b/othersoft/install.sh
index 248af59..bc46203 100644
--- a/othersoft/install.sh
+++ b/othersoft/install.sh
@@ -7,10 +7,24 @@ cmake ../../movingliner
make -j4
mkdir /home/pi/bin
cp ./movingliner /home/pi/bin
+echo beging build GPSlog
+
+cd ../
+sudo killall Mywathdogtemp.sh
+sudo killall GPSLog
+mkdir -p GPSlog
+cd GPSlog
+cmake ../../GPSLog/project/
+make -j4
+mkdir /home/pi/bin
+cp ./GPSLog /home/pi/bin
+
echo beging build shuttercali
cd ../
+
+
mkdir -p shuttercali
cd shuttercali
cmake ../../shuttercali/project/LocationCali
@@ -34,12 +48,13 @@ make -j4
cp ./ocean_optics_calibration_console /home/pi/bin
cd ../
sudo killall Mywathdog.sh
-sudo killall TowerOptoSifAndSpectral
+sudo killall AirOptoSifAndSpectral
+
cd ../../
cp -r ./html/* /var/www/html
chmod +x /var/www/html/php/*.sh
cd ./build
-cp TowerOptoSifAndSpectral /home/pi/bin
+cp AirOptoSifAndSpectral /home/pi/bin
cd ../
cp ./root/Mywathdog.sh /root
cp ./root/start.sh /root
diff --git a/root/Mywathdog.sh b/root/Mywathdog.sh
index fa13e97..de03f29 100644
--- a/root/Mywathdog.sh
+++ b/root/Mywathdog.sh
@@ -5,17 +5,17 @@ do
echo $time
if [[ "$time" > "01:00:01" ]] && [[ "$time" < "22:30:00" ]]
then
- ps -ef | grep "TowerOptoSifAndSpectral" | grep -v "grep"
+ ps -ef | grep "AirOptoSifAndSpectral" | grep -v "grep"
if [ "$?" -eq 1 ]
then
- /home/pi/bin/TowerOptoSifAndSpectral &
+ /home/pi/bin/AirOptoSifAndSpectral &
echo "process has been restarted!" > /home/data/log.txt
else
echo "process already started!"
sleep 60
fi
else
- pid=$(ps -ef | grep "TowerOptoSifAndSpectral" | grep -v "grep" | awk '{print $2}')
+ pid=$(ps -ef | grep "AirOptoSifAndSpectral" | grep -v "grep" | awk '{print $2}')
if [ -z "$pid" ]
then
sleep 60
diff --git a/root/Mywathdogtemp.sh b/root/Mywathdogtemp.sh
index ff2035a..f4bfda7 100644
--- a/root/Mywathdogtemp.sh
+++ b/root/Mywathdogtemp.sh
@@ -5,23 +5,23 @@ do
echo $time
if [[ "$time" > "01:00:01" ]] && [[ "$time" < "22:30:00" ]]
then
- ps -ef | grep "TemperatureControler" | grep -v "grep"
+ ps -ef | grep "GPSLog" | grep -v "grep"
if [ "$?" -eq 1 ]
then
- /home/pi/bin/TemperatureControler &
+ /home/pi/bin/GPSLog &
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}')
+ pid=$(ps -ef | grep "GPSLog" | grep -v "grep" | awk '{print $2}')
if [ -z "$pid" ]
then
sleep 60
else
echo "$?"
- echo "time to kill the task" > /home/data/log.txt
+ echo "time to kill the task" > /home/data/gpslog.txt
kill "$pid"
fi
fi
diff --git a/root/start.sh b/root/start.sh
index f78e95f..c88124d 100644
--- a/root/start.sh
+++ b/root/start.sh
@@ -8,5 +8,5 @@ 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 &
+/home/pi/bin/AirOptoSifAndSpectral > /root/templog.log &
diff --git a/source/CaptureThread/AbstractFSController.cpp b/source/CaptureThread/AbstractFSController.cpp
index 4921351..57eccfc 100644
--- a/source/CaptureThread/AbstractFSController.cpp
+++ b/source/CaptureThread/AbstractFSController.cpp
@@ -1,6 +1,12 @@
#include "AbstractFSController.h"
#include "ZZ_Math_HDRONLY.h"
#include
+void Delay_MSec(ZZ_U16 usMS)
+{
+ QEventLoop qeLoop;
+ QTimer::singleShot(usMS, &qeLoop, SLOT(quit()));
+ qeLoop.exec();
+}
CAbstractFSController::CAbstractFSController(QObject* parent /*= nullptr*/)
{
iFlagInit = 0;
@@ -13,6 +19,11 @@ CAbstractFSController::CAbstractFSController(QObject* parent /*= nullptr*/)
m_qstrCalFilePath = "/home/data/Cal";
m_vecNonLinearCalP.clear();
+ for (int i=0;i<10;i++) {
+ m_taginfolast.ITtimeChange[i] =true;
+ m_taginfolast.LastMAXValue[i] = 0;
+ m_taginfolast.lastITTIME[i] = 0;
+ }
}
CAbstractFSController::~CAbstractFSController()
@@ -21,6 +32,7 @@ CAbstractFSController::~CAbstractFSController()
{
delete m_pFSCtrl;
}
+
}
int CAbstractFSController::SetRunParas(int iThreadID, FSInfo fsInfo)
@@ -135,8 +147,19 @@ int CAbstractFSController::GetDeviceAttr(DeviceAttribute &daAttr)
return 0;
}
-int CAbstractFSController::PerformAutoExposure()
+int CAbstractFSController::PerformAutoExposure(int position)
{
+ if (position!=0) {
+ // m_taginfolast.ITtimeChange[position] = true;
+ m_taginfolast.lastITTIME[position] = m_taginfolast.lastITTIME[0]*0.5 ;
+ m_pFSCtrl->SetExposureTime(m_taginfolast.lastITTIME[position] );
+ return 0;
+ }
+
+
+
+
+
qDebug() << "--------------------------Starting PerformAutoExposure" << " Thread ID:" << m_iThreadID;
using namespace ZZ_MATH;
float fPredictedExposureTime;
@@ -153,7 +176,7 @@ int CAbstractFSController::PerformAutoExposure()
bool bIsValueOverflow = false;
bool bIsLastValueOverflow = false;
- int iExposureTime = 0;
+ int iExposureTime = 1000;
float fTempExposureTime = 0;
double fLastExposureTime = 0.1;
int iRepeatCount = 0;
@@ -177,9 +200,9 @@ int CAbstractFSController::PerformAutoExposure()
break;
}
//m_pFSCtrl->SetExposureTime(5000);
- m_pFSCtrl->GetExposureTime(iExposureTime);
- qDebug() << "Current ExpTime:" << iExposureTime << " Thread ID:" << m_iThreadID;
- //m_pFSCtrl->SetExposureTime(2500);
+ // m_pFSCtrl->GetExposureTime(iExposureTime);
+ // qDebug() << "Current ExpTime:" << iExposureTime << " Thread ID:" << m_iThreadID;
+ m_pFSCtrl->SetExposureTime(iExposureTime);
//fExposureTime = (float)m_daDeviceAttr.iMinIntegrationTimeInMS;
fTempExposureTime = iExposureTime;
@@ -270,7 +293,8 @@ int CAbstractFSController::PerformAutoExposure()
// {
// qDebug() << "Success:PerformAutoExposure. Value" << iExposureTime << " Thread ID:" << m_iThreadID;
// }
-
+ m_taginfolast.ITtimeChange[position] = true;
+ m_taginfolast.lastITTIME[position] = m_daDeviceAttr.iMinIntegrationTimeInMS;
iRes = m_pFSCtrl->SetExposureTime(m_daDeviceAttr.iMinIntegrationTimeInMS);
if (iRes != 0)
{
@@ -301,7 +325,8 @@ int CAbstractFSController::PerformAutoExposure()
//{
//qDebug() << "Warning:PerformAutoExposure exceed max integration time.Will be limited to 30sec";
//}
-
+ m_taginfolast.ITtimeChange[position] = true;
+ m_taginfolast.lastITTIME[position] =m_daDeviceAttr.iMaxIntegrationTimeInMS - 1;
iRes = m_pFSCtrl->SetExposureTime(m_daDeviceAttr.iMaxIntegrationTimeInMS - 1);
if (iRes != 0)
{
@@ -315,7 +340,8 @@ int CAbstractFSController::PerformAutoExposure()
break;
}
-
+ m_taginfolast.ITtimeChange[position] = true;
+ m_taginfolast.lastITTIME[position] =(int)iExposureTime;
iRes = m_pFSCtrl->SetExposureTime((int)iExposureTime);
if (iRes != 0)
{
@@ -335,11 +361,69 @@ int CAbstractFSController::PerformAutoExposure()
return 0;
}
-int CAbstractFSController::TakeDarkFrame()
-{
- qDebug() << "Starting TakeDarkFrame" << " Thread ID:" << m_iThreadID;
+int CAbstractFSController::ComputExposure(int position) {
+ if (position==0) {
- m_vecDataFrameDark.push_back(TakeOneFrame());
+
+ int lastittime=m_taginfolast.lastITTIME[position];
+ int lastmaxvalue=m_taginfolast.LastMAXValue[position];
+
+ int maxallowvalue=m_fsInfo.lDepth * m_fsInfo.fMaxFactor;
+ int minallowvalue=m_fsInfo.lDepth * m_fsInfo.fMinFactor;
+ if (lastmaxvalue>maxallowvalue) {
+ if (lastmaxvalue>=m_fsInfo.lDepth) {
+ lastittime=lastittime/2;
+
+ }else {
+ lastittime=lastittime*(maxallowvalue*1.0/lastmaxvalue)*0.95;
+ }
+
+ m_taginfolast.ITtimeChange[position]=true;
+ m_taginfolast.lastITTIME[position]=lastittime;
+ m_pFSCtrl->SetExposureTime(lastittime);
+ qDebug()<< "Set exposure time for position"<=60000) {
+ lastittime=60000;
+ }
+ m_taginfolast.ITtimeChange[position]=true;
+ m_taginfolast.lastITTIME[position]=lastittime;
+ m_pFSCtrl->SetExposureTime(lastittime);
+ qDebug()<< "Set exposure time for position"<SetExposureTime(lastittime);
+ qDebug()<< "Set exposure time for position"<GetExposureTime(lasttimeindev);
+
+ m_pFSCtrl->SetExposureTime(m_taginfolast.lastITTIME[0]*0.5);
+ if (lasttimeindev!=m_taginfolast.lastITTIME[0]*0.5) {
+ Delay_MSec(lasttimeindev);
+ }
+ qDebug()<< "Set exposure time for position"<GetExposureTime(shuttertime);
+ qDebug() << "Starting TakeDarkFrame" << " position ID:" << position<<" ITtime:"<maxvalue) {
+ maxvalue=pData[i];
+ }
+ }
+ return maxvalue;
+
+ // if (number <= 10) {
+ // // 如果数据量小,直接排序计算
+ // int sum = 0;
+ // for (int i = 0; i < number; i++) {
+ // sum += pData[i];
+ // }
+ // return number > 0 ? sum / number : 0;
+ // }
+ //
+ // // 复制数据(或者直接操作原数组如果允许修改)
+ // std::vector temp(pData, pData + number);
+ //
+ // // 使用nth_element找到第10大的元素
+ // std::nth_element(temp.begin(), temp.begin() + 9, temp.end(), std::greater());
+ //
+ // // 计算前10个最大值的平均
+ // int sum = 0;
+ // for (int i = 0; i < 10; i++) {
+ // sum += temp[i];
+ // }
+ //
+ // return sum / 10;
+
+
+
+
+ // int maxvalue[10]={0};
+ // ZZ_S32 *pData=Data.lData;
+ // int number=4096;
+ // //获取pdata中最大的10个值
+ // for (int i=0;imaxvalue[j]) {
+ // //插入到maxvalue中
+ // for (int k=9;k>j;k--) {
+ // maxvalue[k]=maxvalue[k-1];
+ // }
+ // maxvalue[j]=val;
+ // break;
+ // }
+ // }
+ // }
+
+}
+int CAbstractFSController::TakeSignalFrame(int position)
{
- qDebug() << "Starting TakeSignal" << " Thread ID:" << m_iThreadID;
+ int shuttertime = 0;
+ m_pFSCtrl->GetExposureTime(shuttertime);
+ qDebug() << "Starting TakeSignal" << " position" << position<<" ITtime:"<=65535) {
+ m_vecDataFrameSignal.at(m_vecDataFrameSignal.size()-1).bIsValid=false;
+ }
qDebug() << "Stop TakeSignal" << " Thread ID:" << m_iThreadID;
+ qDebug()<< "Max 10 Average Value:" << m_taginfolast.LastMAXValue[position] << " Thread ID:" << m_iThreadID;
//emit SignalAcqFinished(m_iThreadID, 1);
return 0;
}
@@ -417,6 +565,8 @@ DataFrame CAbstractFSController::TakeOneFrame()
// return dfTemp;
}
+
+
int CAbstractFSController::SaveDataFile()
{
return 0;
@@ -460,7 +610,7 @@ int CAbstractFSController::LoadQEProLinearCalibrationFile()
return 0;
}
-int CAbstractFSController::StartAcquisitionSignal()
+int CAbstractFSController::StartAcquisitionSignal(int position)
{
//
qDebug() << "Starting acq Signal" << " Thread ID:" << m_iThreadID;
@@ -471,18 +621,24 @@ int CAbstractFSController::StartAcquisitionSignal()
// m_pFSCtrl->GetExposureTime(iii);
// m_pFSCtrl->SingleShot(struDF);
- PerformAutoExposure();
- TakeSignalFrame();
+ if (m_taginfolast.lastITTIME[position]==0) {
+ PerformAutoExposure(position);
+ }else {
+ ComputExposure(position);
+ }
+
+
+ TakeSignalFrame(position);
qDebug() << "Stop acq Signal" << " Thread ID:" << m_iThreadID;
emit SignalAcqFinished_Signal(m_iThreadID, 1);
return 0;
}
-int CAbstractFSController::StartAcquisitionDark()
+int CAbstractFSController::StartAcquisitionDark(int position)
{
qDebug() << "Starting acq Dark" << " Thread ID:" << m_iThreadID;
- TakeDarkFrame();
+ TakeDarkFrame(position);
qDebug() << "Stop acq Dark"<< " Thread ID:" << m_iThreadID;
emit SignalAcqFinished_Dark(m_iThreadID, 1);
diff --git a/source/CaptureThread/AbstractFSController.h b/source/CaptureThread/AbstractFSController.h
index eab21b6..301b0f4 100644
--- a/source/CaptureThread/AbstractFSController.h
+++ b/source/CaptureThread/AbstractFSController.h
@@ -15,6 +15,15 @@ typedef struct tagFSInfo
float fMaxFactor;
}FSInfo;
+struct tagINFOOFLOST {
+ int LastMAXValue[10];
+ int lastITTIME[10];
+ bool ITtimeChange[10];
+ DataFrame LastDarkframe[10];
+
+};
+
+
class CAbstractFSController :public QObject
{
Q_OBJECT
@@ -34,6 +43,8 @@ public:
//sync info
virtual int GetDeviceAttr(DeviceAttribute &daAttr);
//DataFrame GetLastDataFrame();
+ tagINFOOFLOST m_taginfolast;
+ int positionnow=0;
private:
CIrisFSBase *m_pFSCtrl;
@@ -48,17 +59,19 @@ private:
QString m_qstrCalFilePath;
std::vector m_vecNonLinearCalP;
private:
- int PerformAutoExposure();
- int TakeDarkFrame();
- int TakeSignalFrame();
+ int PerformAutoExposure(int position);
+ int ComputExposure(int position);
+ int TakeDarkFrame(int position);
+ int TakeSignalFrame(int position);
DataFrame TakeOneFrame();
+ int ComputeMaxValue(DataFrame Data);
int SaveDataFile();
//QE NLC
int LoadQEProLinearCalibrationFile();
public slots:
- virtual int StartAcquisitionSignal();
- virtual int StartAcquisitionDark();
+ virtual int StartAcquisitionSignal(int position);
+ virtual int StartAcquisitionDark(int position);
virtual int StopAcquisition();
virtual int ClearBuffer();
virtual int GetBuffer(std::vector &pvecDataFrameDark, std::vector &pvecDataFrameSignal);
diff --git a/source/CaptureThread/MainDataGrabber.cpp b/source/CaptureThread/MainDataGrabber.cpp
index 1cc512d..2adff42 100644
--- a/source/CaptureThread/MainDataGrabber.cpp
+++ b/source/CaptureThread/MainDataGrabber.cpp
@@ -467,7 +467,7 @@ int CMainDataGrabber::GrabOnceFinished()
if (m_iFlagIsCapturing)
{
- qDebug() << "Fatal Warning.Last capture not finished.New acquisition will not start";
+ // qDebug() << "Fatal Warning.Last capture not finished.New acquisition will not start";
return 1000;
}
m_iFlagIsCapturing = 1;
@@ -521,7 +521,7 @@ int CMainDataGrabber::GrabOnceFinished()
qDebug() << qstrCMD_A;
qDebug() << qstrCMD_B;
- Delay_MSec(500);
+ Delay_MSec(200);
}
else if (/*i==1*/i%2==1)
{
@@ -537,7 +537,7 @@ int CMainDataGrabber::GrabOnceFinished()
qDebug() << qstrCMD_A;
qDebug() << qstrCMD_B;
- Delay_MSec(500);
+ Delay_MSec(200);
}
@@ -545,6 +545,7 @@ int CMainDataGrabber::GrabOnceFinished()
}
else
{
+ //线性马达
qDebug() << "Start ILMES_MoveToPos:" << i + 1;
if (i == 0)
{
@@ -563,10 +564,10 @@ int CMainDataGrabber::GrabOnceFinished()
// m_struAcqPosSetting.iPosition[i + 1];
m_iFlagIsCapturing_Signal = 1;
- emit SignalStartGrabOnce_Signal();
+ emit SignalStartGrabOnce_Signal(i);
while (m_iFlagIsCapturing_Signal)
{
- Delay_MSec(1000);
+ Delay_MSec(100);
}
@@ -586,6 +587,7 @@ int CMainDataGrabber::GrabOnceFinished()
qDebug() << qstrCMD_A;
qDebug() << qstrCMD_B;
+ Delay_MSec(200);
}
}
else
@@ -598,10 +600,10 @@ int CMainDataGrabber::GrabOnceFinished()
//m_struAcqPosSetting.iPosition[0];
m_iFlagIsCapturing_Dark = 1;
// todo : 机载时是否有实时采集暗电流
- emit SignalStartGrabOnce_Dark();
+ emit SignalStartGrabOnce_Dark(i);
while (m_iFlagIsCapturing_Dark)
{
- Delay_MSec(1000);
+ Delay_MSec(100);
}
}
@@ -632,6 +634,7 @@ int CMainDataGrabber::GrabOnceFinished()
for (size_t j=0;j< vecDark.size();j++)
{
SubDataFrame(vecSignal[j], vecDark[j], m_struDeviceContext.usPixels[i]);
+ vecDark[j].bIsValid=vecSignal[j].bIsValid;
}
vecData.push_back(vecSignal);
if (savedarkfile) {
@@ -658,7 +661,9 @@ int CMainDataGrabber::GrabOnceFinished()
m_pdfpSaver->WriteDarkDataFile();
}
}
-
+ system("gpio write 13 1");
+ Delay_MSec(100);
+ system("gpio write 13 0");
m_iFlagIsCapturing = 0;
// qDebug() << "-------------------------------------------busy" << QTime::currentTime().toString();
diff --git a/source/CaptureThread/MainDataGrabber.h b/source/CaptureThread/MainDataGrabber.h
index ee4f316..2d394a6 100644
--- a/source/CaptureThread/MainDataGrabber.h
+++ b/source/CaptureThread/MainDataGrabber.h
@@ -89,8 +89,8 @@ public slots:
int GrabOnceFinished();
signals:
- void SignalStartGrabOnce_Signal();
- void SignalStartGrabOnce_Dark();
+ void SignalStartGrabOnce_Signal(int position);
+ void SignalStartGrabOnce_Dark(int position);
void SignalGrabOnceFinished_Signal();
void SignalGrabOnceFinished_Dark();
diff --git a/source/CaptureThread/Scheduler.cpp b/source/CaptureThread/Scheduler.cpp
index ddfc68a..354e3fb 100644
--- a/source/CaptureThread/Scheduler.cpp
+++ b/source/CaptureThread/Scheduler.cpp
@@ -54,10 +54,10 @@ void Scheduler::StartAsPlanned()
}
int iIntervalInMS = m_struAcqTime.qtInterval.hour() * 3600 * 1000 + m_struAcqTime.qtInterval.minute() * 60 * 1000 + m_struAcqTime.qtInterval.second() * 1000;
-
+ //iIntervalInMS =1000;
m_GrabTimer->start(iIntervalInMS);
- QThread::msleep(5000);
+ QThread::msleep(1000);
qDebug() << "it's time to start work.";
emit SignalGrabOnce();
//this->OnTimeCounter();
@@ -74,7 +74,7 @@ int Scheduler::OnTimeCounter()
}
- qDebug() << "it's time to work...work work.";
+ // qDebug() << "it's time to work...work work.";
emit SignalGrabOnce();
return 0;
}
diff --git a/source/FS/ATPControl_Serial_QT.cpp b/source/FS/ATPControl_Serial_QT.cpp
index 6fc07fe..8dac880 100644
--- a/source/FS/ATPControl_Serial_QT.cpp
+++ b/source/FS/ATPControl_Serial_QT.cpp
@@ -728,6 +728,7 @@ int ZZ_ATPControl_Serial_Qt::SetExposureTime(int iExposureTimeInMS)
//return 1;
}
+
return 0;
}
diff --git a/source/FS/DataFileProcessor.cpp b/source/FS/DataFileProcessor.cpp
index c78d998..3d9eeb2 100644
--- a/source/FS/DataFileProcessor.cpp
+++ b/source/FS/DataFileProcessor.cpp
@@ -275,7 +275,9 @@ bool DataFileProcessor::WriteData(QString path)
qstrTemp = QString("_P%1").arg(j + 1);
qfData.write(qstrTemp.toLatin1());
qfData.write(",");
- if ((m_vecData[i][j].fTemperature < 5) /*&& (m_vecData[i][j].fTemperature> -5)*/)
+ // if ((m_vecData[i][j].fTemperature < 5) /*&& (m_vecData[i][j].fTemperature> -5)*/)
+ if (m_vecDarkData[i][j].bIsValid)
+
{
qfData.write("valid");
}
@@ -327,7 +329,8 @@ bool DataFileProcessor::WriteDarkData(QString path)
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)*/)
+ // if ((m_vecDarkData[i][j].fTemperature < 5&&m_vecDarkData[i][j].bIsValid) /*&& (m_vecDarkData[i][j].fTemperature> -5)*/)
+ if (m_vecDarkData[i][j].bIsValid)
{
qfData.write("valid");
}
diff --git a/source/FS/ZZ_Types.h b/source/FS/ZZ_Types.h
index 7ea2e98..c6fcc35 100644
--- a/source/FS/ZZ_Types.h
+++ b/source/FS/ZZ_Types.h
@@ -27,6 +27,7 @@ namespace ZZ_MISCDEF
ZZ_S32 lData[4096] = {0};
float fTemperature = 0;
double dTimes = 0;
+ bool bIsValid = true;
}DataFrame;
diff --git a/source/Settings/SystemConfigger.cpp b/source/Settings/SystemConfigger.cpp
index 2926f09..2833e1b 100644
--- a/source/Settings/SystemConfigger.cpp
+++ b/source/Settings/SystemConfigger.cpp
@@ -235,11 +235,11 @@
{
qstrTemp = "0" + qstrTemp;
}
- m_struAcqTime.qtInterval = QTime::fromString(qstrTemp, "mm");
+ m_struAcqTime.qtInterval = QTime::fromString(qstrTemp, "mm:ss");
}
else
{
- m_struAcqTime.qtInterval = QTime::fromString(m_qjoJObj.value("IntervalTime").toString(), "mm");
+ m_struAcqTime.qtInterval = QTime::fromString(m_qjoJObj.value("IntervalTime").toString(), "mm:ss");
}
if (!m_struAcqTime.qtInterval.isValid())
{
diff --git a/source/Uploader/MainDataUploader.cpp b/source/Uploader/MainDataUploader.cpp
index a1a20ba..7ebd776 100644
--- a/source/Uploader/MainDataUploader.cpp
+++ b/source/Uploader/MainDataUploader.cpp
@@ -117,6 +117,7 @@ int CMainDataUploader::Initialize()
int CMainDataUploader::SlotPushOneDataFrame()
{
+ return 0;
Calibration();
UploadData();
m_vecData.clear();