From 87a35f5dd45eb242bf0dfe0320381425a56b464c Mon Sep 17 00:00:00 2001 From: tangchao0503 <735056338@qq.com> Date: Thu, 13 Oct 2022 16:30:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20+=20=E4=BF=AE=E6=94=B9=201?= =?UTF-8?q?.=20=E5=88=86=E7=A6=BB=E7=A9=BA=E9=97=B4=E7=BB=B4=EF=BC=88?= =?UTF-8?q?=E6=B0=B4=E5=B9=B3=EF=BC=89=E5=92=8C=E5=85=89=E8=B0=B1=E7=BB=B4?= =?UTF-8?q?=EF=BC=88=E5=9E=82=E7=9B=B4=EF=BC=89=E7=9A=84bin1=E5=92=8Cbin2?= =?UTF-8?q?=E6=9C=89=E6=95=88=E7=AA=97=E5=8F=A3=E7=9A=84=E5=8F=82=E6=95=B0?= =?UTF-8?q?=EF=BC=9Aconfigfile.cpp=E5=92=8Cximeaimager.cpp=E9=83=BD?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E4=BF=AE=E6=94=B9=E7=9B=B8=E5=BA=94=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=9B=202.=20=E4=B8=BA=E4=BA=86=E5=87=8F=E5=B0=91?= =?UTF-8?q?=E5=85=89=E8=B0=B1=E4=BB=AA=E7=9A=84=E7=83=AD=E9=87=8F=E7=B4=AF?= =?UTF-8?q?=E7=A7=AF=EF=BC=8C=E5=8A=A0=E5=85=A5=E4=BA=86usb=E5=BC=80?= =?UTF-8?q?=E7=94=B5=E3=80=81=E6=96=AD=E7=94=B5=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?udpserver.cpp=E9=9C=80=E8=A6=81=E5=A2=9E=E5=8A=A0=E7=9B=B8?= =?UTF-8?q?=E5=BA=94=E5=BC=80=E7=94=B5=E3=80=81=E6=96=AD=E7=94=B5=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=9A=203.=20=E4=BD=BF=E7=94=A8=E4=BA=86=E4=BA=91?= =?UTF-8?q?=E4=B8=80=E5=B3=B0=E7=9A=84=E6=96=B0=E6=9D=BF=E5=AD=90=EF=BC=8C?= =?UTF-8?q?linux=E8=AF=86=E5=88=AB=E7=9A=84=E6=83=AF=E5=AF=BC=E4=B8=B2?= =?UTF-8?q?=E5=8F=A3=E5=8F=B7=E6=94=B9=E5=8F=98=EF=BC=9Asbgrecorder.cpp?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +- Header_Files/configfile.h | 3 +- Source_Files/configfile.cpp | 145 ++++++++++++++++++++++++----------- Source_Files/sbgrecorder.cpp | 2 +- Source_Files/udpserver.cpp | 7 ++ Source_Files/ximeaimager.cpp | 16 ++-- 6 files changed, 123 insertions(+), 54 deletions(-) diff --git a/.gitignore b/.gitignore index 4afcf19..4a618cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .idea -build \ No newline at end of file +build +/温度测试 +扩展板接口.txt diff --git a/Header_Files/configfile.h b/Header_Files/configfile.h index 56d2af2..bfdbd29 100644 --- a/Header_Files/configfile.h +++ b/Header_Files/configfile.h @@ -27,7 +27,8 @@ public: bool isConfigfileExist(); bool parseConfigfile(); - bool getBin(int &bin); + bool getSpectralBin(int &spectralBin); + bool getspatialBin(int &spatialBin); bool getEffectiveWindow(int &width, int &offsetx, int &height, int &offsety); bool getEffectiveWindowRoi(int &width, int &offsetx); bool getGainOffset(float &gain, float &offset); diff --git a/Source_Files/configfile.cpp b/Source_Files/configfile.cpp index e450b72..406d063 100644 --- a/Source_Files/configfile.cpp +++ b/Source_Files/configfile.cpp @@ -43,17 +43,32 @@ bool Configfile::parseConfigfile() } } -bool Configfile::getBin(int &bin) +bool Configfile::getSpectralBin(int &spectralBin) { try { - bin = cfg.lookup("bin"); + spectralBin = cfg.lookup("spectralBin"); return true; } catch(const SettingNotFoundException &nfex) { - cerr << "No 'bin' setting in configuration file." << endl; + cerr << "No 'spectralBin' setting in configuration file." << endl; + return false; + } +} + +bool Configfile::getspatialBin(int &spatialBin) +{ + try + { + spatialBin = cfg.lookup("spatialBin"); + + return true; + } + catch(const SettingNotFoundException &nfex) + { + cerr << "No 'spatialBin' setting in configuration file." << endl; return false; } } @@ -62,22 +77,41 @@ bool Configfile::getEffectiveWindow(int &width, int &offsetx, int &height, int & { const Setting& root = cfg.getRoot(); - // Output a list of all books in the inventory. try { - const Setting &effective_window = root["effective_window"]; - int count = effective_window.getLength(); + int spatialBin; + int spectralBin; + getspatialBin(spatialBin); + getSpectralBin(spectralBin); - int bin; - getBin(bin); + string spatialBinString; + if(spatialBin == 1) + { + spatialBinString = "bin1"; + } + else + { + spatialBinString = "bin2"; + } + const Setting &spatialArgument = root["effective_window"][spatialBinString]["spatial"]; + if(!(spatialArgument.lookupValue("width", width) + && spatialArgument.lookupValue("offsetx", offsetx))) + { + return false; + } - const Setting &window = effective_window[bin-1]; - string name = window.getName(); - - if(!(window.lookupValue("width", width) - && window.lookupValue("offsetx", offsetx) - && window.lookupValue("height", height) - && window.lookupValue("offsety", offsety))) + string spectralBinString; + if(spectralBin == 1) + { + spectralBinString = "bin1"; + } + else + { + spectralBinString = "bin2"; + } + const Setting &spectralArgument = root["effective_window"][spectralBinString]["spectral"]; + if(!(spectralArgument.lookupValue("height", height) + && spectralArgument.lookupValue("offsety", offsety))) { return false; } @@ -95,16 +129,25 @@ bool Configfile::getEffectiveWindowRoi(int &width, int &offsetx) { const Setting& root = cfg.getRoot(); - // Output a list of all books in the inventory. try { const Setting &effective_window = root["effective_window_roi"]; int count = effective_window.getLength(); - int bin; - getBin(bin); + int spatialBin; + getspatialBin(spatialBin); - const Setting &window = effective_window[bin-1]; + string spatialBinString; + if(spatialBin == 1) + { + spatialBinString = "spatialBin1"; + } + else + { + spatialBinString = "spatialBin2"; + } + + const Setting &window = effective_window[spatialBinString]; string name = window.getName(); if(!(window.lookupValue("width", width) @@ -127,16 +170,25 @@ bool Configfile::getGainOffset(float &gain, float &offset) { const Setting& root = cfg.getRoot(); - // Output a list of all books in the inventory. try { const Setting &gainOffset = root["gainOffset"]; int count = gainOffset.getLength(); - int bin; - getBin(bin); + int spectralBin; + getSpectralBin(spectralBin); - const Setting &gainOffsetSetting = gainOffset[bin-1]; + string spectralBinString; + if(spectralBin == 1) + { + spectralBinString = "spectralBin1"; + } + else + { + spectralBinString = "spectralBin2"; + } + + const Setting &gainOffsetSetting = gainOffset[spectralBinString]; string name = gainOffsetSetting.getName(); if(!(gainOffsetSetting.lookupValue("gain", gain) @@ -164,46 +216,51 @@ bool Configfile::createConfigFile() Setting &root = cfg.getRoot(); // Add some settings to the configuration. - Setting &bin = root.add("bin", Setting::TypeInt) = 1; Setting &SN = root.add("SN", Setting::TypeString) = "0098"; + Setting &spatialBin = root.add("spatialBin", Setting::TypeInt) = 1; + Setting &SpectralBin = root.add("spectralBin", Setting::TypeInt) = 2; Setting &effective_window = root.add("effective_window", Setting::TypeGroup); Setting &effective_window_Bin1 = effective_window.add("bin1", Setting::TypeGroup); + Setting &effective_window_Bin1_spatial = effective_window_Bin1.add("spatial", Setting::TypeGroup); + Setting &effective_window_Bin1_Spectral = effective_window_Bin1.add("spectral", Setting::TypeGroup); Setting &effective_window_Bin2 = effective_window.add("bin2", Setting::TypeGroup); + Setting &effective_window_Bin2_spatial = effective_window_Bin2.add("spatial", Setting::TypeGroup); + Setting &effective_window_Bin2_Spectral = effective_window_Bin2.add("spectral", Setting::TypeGroup); - effective_window_Bin1.add("width", Setting::TypeInt) = 1392; - effective_window_Bin1.add("offsetx", Setting::TypeInt) = 272; - effective_window_Bin1.add("height", Setting::TypeInt) = 300; - effective_window_Bin1.add("offsety", Setting::TypeInt) = 348; + effective_window_Bin1_spatial.add("width", Setting::TypeInt) = 1392; + effective_window_Bin1_spatial.add("offsetx", Setting::TypeInt) = 272; + effective_window_Bin1_Spectral.add("height", Setting::TypeInt) = 300; + effective_window_Bin1_Spectral.add("offsety", Setting::TypeInt) = 348; - effective_window_Bin2.add("width", Setting::TypeInt) = 712; - effective_window_Bin2.add("offsetx", Setting::TypeInt) = 128; - effective_window_Bin2.add("height", Setting::TypeInt) = 151; - effective_window_Bin2.add("offsety", Setting::TypeInt) = 174; + effective_window_Bin2_spatial.add("width", Setting::TypeInt) = 712; + effective_window_Bin2_spatial.add("offsetx", Setting::TypeInt) = 128; + effective_window_Bin2_Spectral.add("height", Setting::TypeInt) = 150; + effective_window_Bin2_Spectral.add("offsety", Setting::TypeInt) = 174; Setting &effective_window_roi = root.add("effective_window_roi", Setting::TypeGroup); - Setting &effective_window_roi_Bin1 = effective_window_roi.add("bin1", Setting::TypeGroup); - Setting &effective_window_roi_Bin2 = effective_window_roi.add("bin2", Setting::TypeGroup); + Setting &effective_window_roi_spatialBin1 = effective_window_roi.add("spatialBin1", Setting::TypeGroup); + Setting &effective_window_roi_spatialBin2 = effective_window_roi.add("spatialBin2", Setting::TypeGroup); - effective_window_roi_Bin1.add("width", Setting::TypeInt) = 1364; - effective_window_roi_Bin1.add("offsetx", Setting::TypeInt) = 14; + effective_window_roi_spatialBin1.add("width", Setting::TypeInt) = 1364; + effective_window_roi_spatialBin1.add("offsetx", Setting::TypeInt) = 14; // effective_window_roi_Bin1.add("height", Setting::TypeInt) = 300; // effective_window_roi_Bin1.add("offsety", Setting::TypeInt) = 348; - effective_window_roi_Bin2.add("width", Setting::TypeInt) = 682; - effective_window_roi_Bin2.add("offsetx", Setting::TypeInt) = 15; + effective_window_roi_spatialBin2.add("width", Setting::TypeInt) = 682; + effective_window_roi_spatialBin2.add("offsetx", Setting::TypeInt) = 15; // effective_window_roi_Bin2.add("height", Setting::TypeInt) = 151; // effective_window_roi_Bin2.add("offsety", Setting::TypeInt) = 174; Setting &gainOffset = root.add("gainOffset", Setting::TypeGroup); - Setting &gainOffsetBin1 = gainOffset.add("bin1", Setting::TypeGroup); - Setting &gainOffsetBin2 = gainOffset.add("bin2", Setting::TypeGroup); + Setting &gainOffsetSpectralBin1 = gainOffset.add("spectralBin1", Setting::TypeGroup); + Setting &gainOffsetSpectralBin2 = gainOffset.add("spectralBin2", Setting::TypeGroup); - gainOffsetBin1.add("gain", Setting::TypeFloat) = 2.00313433; - gainOffsetBin1.add("offset", Setting::TypeFloat) = -300.46283157590585; + gainOffsetSpectralBin1.add("gain", Setting::TypeFloat) = 2.00313433; + gainOffsetSpectralBin1.add("offset", Setting::TypeFloat) = -300.46283157590585; - gainOffsetBin2.add("gain", Setting::TypeFloat) = 4.00626868; - gainOffsetBin2.add("offset", Setting::TypeFloat) = -299.46126663407176; + gainOffsetSpectralBin2.add("gain", Setting::TypeFloat) = 4.00626868; + gainOffsetSpectralBin2.add("offset", Setting::TypeFloat) = -299.46126663407176; // Write out the new configuration. diff --git a/Source_Files/sbgrecorder.cpp b/Source_Files/sbgrecorder.cpp index 1a1c6a4..e75e7af 100644 --- a/Source_Files/sbgrecorder.cpp +++ b/Source_Files/sbgrecorder.cpp @@ -53,7 +53,7 @@ void sbgtc::SbgRecorder::openSerialPort() } // QString portname = "sbg_serial_port"; - QString portname = "ttyS4"; + QString portname = "ttyUSB2"; m_serial->setPortName(portname); m_serial->open(QIODevice::ReadWrite); diff --git a/Source_Files/udpserver.cpp b/Source_Files/udpserver.cpp index 4b5a98a..27d49dc 100644 --- a/Source_Files/udpserver.cpp +++ b/Source_Files/udpserver.cpp @@ -88,6 +88,10 @@ void UdpServer::processPendingDatagrams() case 1://启动系统: 打开sbg串口并采集数据,打开光谱仪 { std::cout<<"1代表启动系统!"<