diff --git a/HaoGaoCOrrect修改记录.txt b/HaoGaoCOrrect修改记录.txt index 280e538..14a61fd 100644 --- a/HaoGaoCOrrect修改记录.txt +++ b/HaoGaoCOrrect修改记录.txt @@ -8,6 +8,10 @@ 2021年7月31日 1.增加3399 板子g100 g200 校正及配置功能 +2021年9月14日 +1、增加G300/G400速率可配置 +2、处理G300/G400不能出图问题 + 2021年8月17日 1. 界面增加速度模式配置功能; 2. 增加明场暗场校正最大明场值配置; diff --git a/HuaGoCorrect/A3.cpp b/HuaGoCorrect/A3.cpp index 6df90bd..c119825 100644 --- a/HuaGoCorrect/A3.cpp +++ b/HuaGoCorrect/A3.cpp @@ -60,6 +60,13 @@ BOOL CA3::OnInitDialog() { m_cmbSpeedmode.InsertString(i, speedmodeMapString[i]); } + speedemodelen = speedmodeMap.size() + G300G400speedmodeMapString.size(); + size_t j = 1; + for (size_t i = speedmodeMap.size(); i < speedemodelen; i++) + { + m_cmbSpeedmode.InsertString(i, G300G400speedmodeMapString[j]); + ++j; + } return TRUE; // return TRUE unless you set the focus to a control // 쳣: OCX ҳӦ FALSE } @@ -288,35 +295,77 @@ void CA3::updatespeedmode(bool get) auto parent = (CHuaGoCorrectDlg*)GetParent(); if (parent != NULL) { - if (parent->m_drv.get() && parent->m_drv->IsConnected()) { + if (parent->m_drv.get() && parent->m_drv->IsConnected()) + { int speedmode; + std::string ver = parent->m_drv->GetFWVersion(); + if (!ver.empty()) + { + ver = ver.substr(0, 2); + } if (get) { parent->m_drv->GetSpeedMode(speedmode, true); bool bfound = false; - for (size_t i = 0; i < speedmodeMap.size(); i++) + if (ver != "G3" && ver != "G4") { - if (speedmodeMap[i].Speedmode == speedmode) + for (size_t i = 0; i < speedmodeMap.size(); i++) { - m_cmbSpeedmode.SetCurSel(i); - OnGetOrSetSp(true, 0);//»Ҷsp - OnGetOrSetSp(true, 1);//²ɫsp - bfound = true; - break; + if (speedmodeMap[i].Speedmode == speedmode) + { + m_cmbSpeedmode.SetCurSel(i); + OnGetOrSetSp(true, 0);//»Ҷsp + OnGetOrSetSp(true, 1);//²ɫsp + bfound = true; + break; + } } } + else + { + size_t j = 1; + for (size_t i = speedmodeMap.size(); i < speedemodelen; i++) + { + if (j == speedmode) + { + m_cmbSpeedmode.SetCurSel(i); + bfound = true; + break; + } + ++j; + } + } + + if (!bfound) MessageBox(L"δҵӦٶģʽ", L"ʾ", MB_OK | MB_ICONINFORMATION); } else { int cmbindex = m_cmbSpeedmode.GetCurSel(); - if (cmbindex != -1) + if (cmbindex != -1 && cmbindex < speedmodeMap.size()) { - auto t_speedmode = speedmodeMap[cmbindex]; - parent->m_drv->GetSpeedMode(t_speedmode.Speedmode, false); - parent->m_drv->SetSptime(0, t_speedmode.GraySp); - parent->m_drv->SetSptime(1, t_speedmode.ColorSp); + if (ver == "G3" || ver == "G4") + { + MessageBox(L"豸кǰλΪG3/G4ȷ豸", L"ѡ", MB_OK | MB_ICONINFORMATION); + return; + } + + auto t_speedmode = speedmodeMap[cmbindex]; + parent->m_drv->GetSpeedMode(t_speedmode.Speedmode, false); + parent->m_drv->SetSptime(0, t_speedmode.GraySp); + parent->m_drv->SetSptime(1, t_speedmode.ColorSp); + + } + else + { + if (ver != "G3" && ver != "G4") + { + MessageBox(L"豸кǰλΪG3/G4ȷ豸", L"ѡ", MB_OK | MB_ICONINFORMATION); + return; + } + cmbindex = cmbindex - speedmodeMap.size() + 1; + parent->m_drv->GetSpeedMode(cmbindex, false); } } } diff --git a/HuaGoCorrect/A3.h b/HuaGoCorrect/A3.h index f66a329..fc9fdea 100644 --- a/HuaGoCorrect/A3.h +++ b/HuaGoCorrect/A3.h @@ -51,24 +51,35 @@ private: unsigned int ColorSp; unsigned int GraySp; }; + int speedemodelen; std::map speedmodeMap = { {0,{70,0x42d,0xc88}}, {1,{80,0x37f,0xa7f}}, {2,{90,0x2b6,0x882}}, - {3,{100,0x27c,0x775}}, - {4,{110,0x27c,0x775}}, - {5,{120,0x27c,0x775}}, - {6,{130,0x27c,0x775}} + {3,{110,0x24e,0x706}}, + {4,{100,0x27c,0x775}}, + {5,{110,0x27c,0x775}}, + {6,{120,0x27c,0x775}}, + {7,{130,0x27c,0x775}} }; std::map speedmodeMapString = { {0,L"G100_70PPM"}, {1,L"G100_80PPM"}, {2,L"G100_90PPM"}, - {3,L"G200_100PPM"}, - {4,L"G200_110PPM"}, - {5,L"G200_120PPM"}, - {6,L"G200_130PPM"} + {3,L"G100_110PPM"}, + {4,L"G200_100PPM"}, + {5,L"G200_110PPM"}, + {6,L"G200_120PPM"}, + {7,L"G200_130PPM"} + }; + + std::map G300G400speedmodeMapString = { + {1,L"G300/G400_40PPM"}, + {2,L"G300/G400_50PPM"}, + {3,L"G300/G400_60PPM"}, + {4,L"G300/G400_70PPM"}, + {5,L"G400_80PPM"}, }; CComboBox m_cmbSpeedmode; }; diff --git a/HuaGoCorrect/ImageMatQueue.cpp b/HuaGoCorrect/ImageMatQueue.cpp index 1b103c7..f57aacd 100644 --- a/HuaGoCorrect/ImageMatQueue.cpp +++ b/HuaGoCorrect/ImageMatQueue.cpp @@ -4,6 +4,8 @@ #include "filetools.h" #include "imageprocess.h" #include +#include +using namespace std; static int imgindex = 0; ImageMatQueue::ImageMatQueue(void) { @@ -111,11 +113,13 @@ void ImageMatQueue::proc() { if (pixType != -1) { - std::string csName; + //string csName; SYSTEMTIME st = { 0 }; GetLocalTime(&st); //ȡǰʱ ɾȷms - //csName.Format("%02d%02d%02d-%d.bmp", st.wHour, st.wMinute, st.wSecond,++imgindex); - + //csName.Format(_T("%02d%02d%02d-%d.bmp"), st.wHour, st.wMinute, st.wSecond,++imgindex); + char szDateTime[20] = { 0 }; + sprintf(szDateTime,"%02d%02d%02d-%d.bmp", st.wHour, st.wMinute, st.wSecond, ++imgindex); + string csName(szDateTime); cv::Mat matPicImage; cv::Mat matFront, matBack; //vector mats; @@ -138,13 +142,16 @@ void ImageMatQueue::proc() case 4://G500 ͼһͼϣҪͼ { std::string csImage; - csImage = csPath + "\\G300" + csName; + csImage = csPath + "\\G300"+ csName; + //cv::Mat mat = m_pImages.Take().getMat(pixType); //matPicImage = mat(cv::Rect(0, 0, mat.cols, mat.rows)); ////mats.push_back(matPicImage); //IplImage qqImg; //qqImg = IplImage(matPicImage); // cv::Mat -> IplImage //cvSaveImage(csImage, &qqImg); + cv::Mat mat = m_pImages.Take().getMat(pixType);//1 color 6 gray + cv::imwrite(csImage, mat); m_images.Put(csImage); } break; diff --git a/HuaGoCorrect/gscn_drv.cpp b/HuaGoCorrect/gscn_drv.cpp index 31bb80d..f5cbd58 100644 --- a/HuaGoCorrect/gscn_drv.cpp +++ b/HuaGoCorrect/gscn_drv.cpp @@ -238,6 +238,23 @@ void GScn_Drv::SetFlatCallback(std::function func) void GScn_Drv::GetSpeedMode(int& speedmode, bool get) { + if (m_usb.get() && m_usb->is_connected()) + { + if (get) + { + + USBCB usb = { GET_SPEED_MODE ,speedmode,0 }; + m_usb->write_bulk(&usb, sizeof(usb)); + m_usb->read_bulk(&usb, sizeof(usb)); + speedmode = usb.u32_Data; + } + else + { + USBCB usb = { SET_SPEED_MODE,speedmode,0 }; + m_usb->write_bulk(&usb, sizeof(usb)); + } + } + } void GScn_Drv::reset()