diff --git a/HPPA/HPPA.cpp b/HPPA/HPPA.cpp index 99dc4e7..def4d20 100644 --- a/HPPA/HPPA.cpp +++ b/HPPA/HPPA.cpp @@ -417,7 +417,6 @@ void HPPA::onStartRecordStep1() return; } - //开始采集 m_RecordState += 1; @@ -454,10 +453,15 @@ void HPPA::onStartRecordStep1() //删除所有tab ui.ImageViewerTabWidget->clear(); + //创建记录x马达位置的文件 + string x_location = directory + "\\" + m_FilenameLineEdit->text().toStdString() + "x_location.pos"; + m_hTimesFile = fopen(x_location.c_str(), "w+"); + //开始循环 m_ForLoopControl->setLoopCount(m_pathPlan->getRecordLineTableWidget()->rowCount());//为循环控制线程设置循环次数 emit StartLoopSignal(); + //所有行设置为灰色 for (size_t i = 0; i < m_pathPlan->getRecordLineTableWidget()->rowCount(); i++) { @@ -521,6 +525,8 @@ void HPPA::onStartRecordStep2(int lineNumber) m_yMotor->SettingSpeed(m_lManualSpeedOfYMotor); m_yMotor->MoveToLocation(ymotorPositionOfLine1); m_timerYmotorLocationFeedBackAfterRecord->start(500); + + fclose(m_hTimesFile); } else if (lineNumber == -2) { @@ -529,6 +535,7 @@ void HPPA::onStartRecordStep2(int lineNumber) //停止y马达运动 m_yMotor->StopMotormove(); + fclose(m_hTimesFile); } } @@ -1258,6 +1265,10 @@ void HPPA::ontimerMoveXmotor() } ByteBack MotorState = m_xMotor->GetState(); + //获取系统时间和x马达的位置,并发送 + long long timeOs = getNanosecondsSinceMidnight(); + BroadcastXMotorPosSignal(timeOs, MotorState.Location); + fprintf(m_hTimesFile, "%lld,%d\n", timeOs, MotorState.Location); //将x马达的位置反馈到slider上 if (MotorState.Speed != 0) @@ -1271,8 +1282,7 @@ void HPPA::ontimerMoveXmotor() } //采集结束,x马达返回初始位置(开始采集前记录的位置:m_lXmotorLocationOfStartRecord) - if (MotorState.Speed == 0 && MotorState.Location != m_lXmotorLocationOfStartRecord //x马达位置处于最大值(接近开关),帧数没有采集完 - || !m_Imager->getRecordControlState())//当相机停止采集需要马达配合回到初始位置:(1)点击停止采集;(2)帧数采集完了,马达还在运动 + if (MotorState.Speed == 0 && MotorState.Location != m_lXmotorLocationOfStartRecord)//x马达位置处于最大值(接近开关),帧数没有采集完 { //光谱仪停止采集 m_Imager->setRecordControlState(false); @@ -1280,7 +1290,21 @@ void HPPA::ontimerMoveXmotor() //x马达返回采集前的位置 m_xMotor->SettingSpeed(m_lManualSpeedOfXMotor); m_xMotor->MoveToLocation(m_lXmotorLocationOfStartRecord); + + //qDebug() << "x马达位置还原:x马达位置处于最大值(接近开关),帧数没有采集完,相机停止采集。"; + qDebug() << "11111111111111111111111111111111111111111111111111"; } + if (!m_Imager->getRecordControlState())//当相机停止采集,需要马达配合回到初始位置:(1)点击停止采集;(2)帧数采集完了,马达还在运动 + { + //x马达返回采集前的位置 + m_xMotor->SettingSpeed(m_lManualSpeedOfXMotor); + m_xMotor->MoveToLocation(m_lXmotorLocationOfStartRecord); + + //qDebug() << "x马达位置还原:(1)点击停止相机采集;(2)帧数采集完了,马达还在运动。"; + qDebug() << "222222222222222222222222222222222222222222222222222222"; + } + + //进行下一条采集线的采集过程 if (MotorState.Speed == 0 && MotorState.Location == m_lXmotorLocationOfStartRecord//当x马达返回初始位置 diff --git a/HPPA/HPPA.h b/HPPA/HPPA.h index 04e0dcd..669e1b0 100644 --- a/HPPA/HPPA.h +++ b/HPPA/HPPA.h @@ -242,6 +242,8 @@ private: PathPlan* m_pathPlan; + FILE* m_hTimesFile; + public Q_SLOTS: void onPlotHyperspectralImageRgbImage(); void PlotSpectral(int state); @@ -337,6 +339,7 @@ signals: void StartLoopSignal(); void StartRecordSignal(); void CopyFileThreadSignal(QString, QString); + void BroadcastXMotorPosSignal(long long, int); void RecordWhiteSignal(); void RecordDarlSignal(); diff --git a/HPPA/ImagerOperationBase.cpp b/HPPA/ImagerOperationBase.cpp index a03121f..ecd9efb 100644 --- a/HPPA/ImagerOperationBase.cpp +++ b/HPPA/ImagerOperationBase.cpp @@ -208,17 +208,21 @@ void ImagerOperationBase::start_record() string directory = fileOperation->getDirectoryFromString(); string imgPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter); - FILE* m_fImage = fopen(imgPath.c_str(), "w+b"); + FILE* m_fImage = fopen((imgPath + ".bil").c_str(), "w+b"); size_t x; double pixelValueTmp; + string timesFile = imgPath + ".times"; + FILE* hTimesFile = fopen(timesFile.c_str(), "w+"); + imagerStartCollect(); while (m_bRecordControlState) { m_iFrameCounter++; getFrame(buffer); + long long timeOs = getNanosecondsSinceMidnight(); //减去暗电流,应为buffer和dark都是unsigned short,所以当dark>buffer时,buffer-dark=65535 if (m_HasDark) @@ -259,6 +263,7 @@ void ImagerOperationBase::start_record() } x = fwrite(buffer, 2, m_FrameSize, m_fImage); + fprintf(hTimesFile, "%d\n", timeOs); //将rgb波段提取出来,以便在界面中显示 m_RgbImage->FillRgbImage(buffer);//?????????????????????????????????????????????????????????????????????????????????????????????????????? @@ -298,6 +303,7 @@ void ImagerOperationBase::start_record() //QThread::msleep(1001); fclose(m_fImage); + fclose(hTimesFile); } void ImagerOperationBase::setFrameNumber(int FrameNumber) diff --git a/HPPA/ImagerOperationBase.h b/HPPA/ImagerOperationBase.h index 4aaecc4..d4a079b 100644 --- a/HPPA/ImagerOperationBase.h +++ b/HPPA/ImagerOperationBase.h @@ -7,6 +7,7 @@ #include #include #include "ImagerOperationBase.h" +#include "utility_tc.h" class ImagerOperationBase :public QObject { diff --git a/HPPA/PathPlan.cpp b/HPPA/PathPlan.cpp index 1c40561..f61d028 100644 --- a/HPPA/PathPlan.cpp +++ b/HPPA/PathPlan.cpp @@ -247,7 +247,7 @@ void PathPlan::onReadRecordLineFile_btn() return; } - FILE* RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "r"); + FILE* RecordLineFileHandle = fopen(RecordLineFilePath.toStdString().c_str(), "rb"); double height, fov, swath, offset, repetitiveRate, LastLineThreshold, number; //读取数据 diff --git a/HPPA/ResononNirImager.cpp b/HPPA/ResononNirImager.cpp index eac5d56..94f79f7 100644 --- a/HPPA/ResononNirImager.cpp +++ b/HPPA/ResononNirImager.cpp @@ -287,13 +287,16 @@ void ResononNirImager::start_record() FileOperation* fileOperation = new FileOperation(); string directory = fileOperation->getDirectoryFromString(); - string imgPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter)+".bil"; + string imgPath = directory + "\\" + m_FileName2Save + "_" + std::to_string(m_FileSavedCounter); - FILE* m_fImage = fopen(imgPath.c_str(), "w+b"); + FILE* m_fImage = fopen((imgPath + ".bil").c_str(), "w+b"); size_t x; double pixelValueTmp; + string timesFile = imgPath + ".times"; + FILE* hTimesFile = fopen(timesFile.c_str(), "w+"); + reConnectImage();//nir第二次采集时需要重新连接相机,否则函数imagerStartCollect()会报错。。。。。。 imagerStartCollect(); while (m_bRecordControlState) @@ -301,6 +304,8 @@ void ResononNirImager::start_record() m_iFrameCounter++; getFrame(buffer); + long long timeOs = getNanosecondsSinceMidnight(); + //qDebug() << "time ns-------------------: " << timeOs; //减去暗电流,应为buffer和dark都是unsigned short,所以当dark>buffer时,buffer-dark=65535 if (m_HasDark) @@ -341,6 +346,7 @@ void ResononNirImager::start_record() } x = fwrite(buffer, 2, m_FrameSize, m_fImage); + fprintf(hTimesFile, "%lld\n", timeOs); //将rgb波段提取出来,以便在界面中显示 m_RgbImage->FillRgbImage(buffer);//?????????????????????????????????????????????????????????????????????????????????????????????????????? @@ -356,6 +362,7 @@ void ResononNirImager::start_record() if (m_iFrameCounter >= m_iFrameNumber) { break; + //qDebug() << "相机停止采集:帧数限制到达。"; } } @@ -380,6 +387,7 @@ void ResononNirImager::start_record() //QThread::msleep(1001); fclose(m_fImage); + fclose(hTimesFile); } void ResononNirImager::WriteHdr() diff --git a/HPPA/about.ui b/HPPA/about.ui index aea0e4f..b1d6f75 100644 --- a/HPPA/about.ui +++ b/HPPA/about.ui @@ -70,7 +70,7 @@ - 鐗堟湰锛1.8.2 + 鐗堟湰锛1.8.4 diff --git a/HPPA/utility_tc.cpp b/HPPA/utility_tc.cpp index 153a037..482660f 100644 --- a/HPPA/utility_tc.cpp +++ b/HPPA/utility_tc.cpp @@ -121,3 +121,28 @@ QList getFileInfo(QString file) return result; } + +long long getNanosecondsSinceMidnight() +{ + // 鑾峰彇褰撳墠绯荤粺鏃堕棿 + auto now = std::chrono::system_clock::now(); + + // 杞崲涓 time_t锛堢绾у埆鐨勬椂闂存埑锛 + std::time_t t = std::chrono::system_clock::to_time_t(now); + std::tm local_tm = *std::localtime(&t); // 鑾峰彇鏈湴鏃堕棿缁撴瀯 + + // 灏嗘椂闂寸粨鏋勮皟鏁村埌褰撳ぉ 00:00:00 + local_tm.tm_hour = 0; + local_tm.tm_min = 0; + local_tm.tm_sec = 0; + local_tm.tm_isdst = -1; // 璁 mktime 鑷姩鍒ゆ柇澶忎护鏃 + + // 鑾峰彇褰撳ぉ 00:00:00 鐨勬椂闂寸偣 + auto midnight = std::chrono::system_clock::from_time_t(std::mktime(&local_tm)); + + // 璁$畻浠庡綋澶 00:00:00 鍒扮幇鍦ㄧ殑鏃堕棿宸 + auto nanoseconds_since_midnight = std::chrono::duration_cast(now - midnight); + + // 杩斿洖绾崇鏁 + return nanoseconds_since_midnight.count(); +} diff --git a/HPPA/utility_tc.h b/HPPA/utility_tc.h index 0857f16..fb3ab27 100644 --- a/HPPA/utility_tc.h +++ b/HPPA/utility_tc.h @@ -6,6 +6,7 @@ #include #include +#include QString getFileNameBaseOnTime(); @@ -20,4 +21,6 @@ bool createDir(QString fullPath); QList getFileInfo(QString file); +long long getNanosecondsSinceMidnight(); + #endif // UTILITY_TC_H diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..a80be98 --- /dev/null +++ b/readme.txt @@ -0,0 +1,28 @@ +1銆丠PPA鎷兼帴 +姣忔潯鑸嚎鐨勫紑濮嬪抚鐨勪綅缃笉涓鏍凤紝鏃犳硶鐩存帴灏嗙浉閭昏埅绾挎嫾鎺ヤ竴璧凤紝鍚﹀垯鑸悜鏈夐敊浣嶃 +1.1 姝ラ +锛1锛夐噰闆嗘瘡甯х殑鍚屾椂锛岃幏鍙栫嚎鎬у钩鍙扮殑浣嶇疆锛屽苟鍐欏叆鏂囦欢锛 +锛2锛夋牴鎹綅缃俊鎭尮閰嶅抚鍙凤紝鐒跺悗杩涜鎷兼帴锛 +1.2 瀛樺湪鐨勯棶棰樺強瑙e喅鍔炴硶 +锛1锛夐┈杈惧簱涓嶇煡閬撴槸鍚﹁兘澶熸敮鎸20hz鍙婁互涓婄殑璁块棶棰戠巼锛 +鎴栬呮寜鐓т竴瀹氶鐜囬噰闆嗙嚎鎬у钩鍙颁綅缃紝閫氳繃鏃堕棿杩涜鎻掑艰幏鍙栨瘡甯т綅缃紱 +锛2锛夊垪涔嬮棿鐨勯噸鍙 +閫氳繃涓涓彲璋冨弬鏁拌繘琛屾梺鍚戞嫾鎺ヨ缃紱 +1.3 鎷兼帴鍚庤鍓 + +1.4 鏍规嵁姣忎釜鍍忕礌鐨剎y鍧愭爣杩涜鎷兼帴锛氭斁寮 + +2銆乥ug淇 +锛1锛夊弽灏勭巼鍥惧儚鏉$汗锛氱櫧鏉垮拰鏆楃數娴侀兘閲囬泦30甯ц繘琛屽钩鍧囷紱 +锛2锛夎建杩2浣嶅皬鏁 +锛3锛夐熷害杈撳叆鎺ュ彈灏忔暟 + +3銆乭ppa鍗囬檷妗屾棤绾挎帶鍒舵ā鍧 +濡傛灉娌℃湁閰嶇疆杩囷紝閭d箞榛樿ip涓篽ttp://192.168.1.254锛屼笖榛樿wifi浠ris1寮澶达紝榛樿wifi瀵嗙爜涓123456789銆 +閰嶇疆缃戦〉涓篽ttp://192.168.1.254/wificonfig.html锛岄厤缃瘑鐮佹槸licahk******* + +濡傛灉宸茬粡閰嶇疆涓252锛岄偅涔堝彲鐢ㄤ笅闈㈢綉鍧鎺у埗 +http://192.168.1.252/stopnow +http://192.168.1.252/set_up +http://192.168.1.252/set_down +http://192.168.1.252/wificonfig.html \ No newline at end of file