diff --git a/BaseModules/Hd_MvCamera_module/CMakeLists.txt b/BaseModules/Hd_MvCamera_module_GENTL/CMakeLists.txt similarity index 100% rename from BaseModules/Hd_MvCamera_module/CMakeLists.txt rename to BaseModules/Hd_MvCamera_module_GENTL/CMakeLists.txt diff --git a/BaseModules/Hd_MvCamera_module/base.h b/BaseModules/Hd_MvCamera_module_GENTL/base.h similarity index 100% rename from BaseModules/Hd_MvCamera_module/base.h rename to BaseModules/Hd_MvCamera_module_GENTL/base.h diff --git a/BaseModules/Hd_MvCamera_module/hd_mvcamera_module.cpp b/BaseModules/Hd_MvCamera_module_GENTL/hd_mvcamera_module.cpp similarity index 94% rename from BaseModules/Hd_MvCamera_module/hd_mvcamera_module.cpp rename to BaseModules/Hd_MvCamera_module_GENTL/hd_mvcamera_module.cpp index d70d32f5..7be55055 100644 --- a/BaseModules/Hd_MvCamera_module/hd_mvcamera_module.cpp +++ b/BaseModules/Hd_MvCamera_module_GENTL/hd_mvcamera_module.cpp @@ -2,7 +2,7 @@ #include #include #include -QQueue matQueue; +std::vector matVec; std::mutex queueMutex;//掉线é”� std::mutex moduleMutex;//掉线é”� @@ -166,7 +166,8 @@ void __stdcall ImageCallBackEx(unsigned char* pData0, MV_FRAME_OUT_INFO_EX* pFra qDebug() << "[INFO] " << " srcImage Exist,Time:" << (time_End - time_Start) / 1000.0 << "s" << "--CameraName:" << QString::fromStdString(Username); } queueMutex.lock(); - matQueue.append(srcImage); + matVec.push_back(srcImage); + srcImage.release(); queueMutex.unlock(); pData0 = { 0 }; } @@ -174,7 +175,7 @@ void __stdcall ImageCallBackEx(unsigned char* pData0, MV_FRAME_OUT_INFO_EX* pFra //æ�œç´¢æ‰€æœ‰è®¾å¤‡ int SearchDevice() { - int nRet=MV_OK; + int nRet = MV_OK; MV_GENTL_IF_INFO_LIST pstIFList; if (m_stDevList.nDeviceNum == 0) { @@ -183,7 +184,7 @@ int SearchDevice() // ch:枚举å­�网内所有设备 | en:Enumerate all devices within subnet //nRet = MV_CC_EnumDevices(MV_GIGE_DEVICE || MV_USB_DEVICE, &m_stDevList); nRet = MV_CC_EnumInterfacesByGenTL(&pstIFList, ".//config//MvFGProducerCML.cti"); - nRet = MV_CC_EnumDevicesByGenTL(pstIFList.pIFInfo[pstIFList.nInterfaceNum-1], &m_stDevList); + nRet = MV_CC_EnumDevicesByGenTL(pstIFList.pIFInfo[pstIFList.nInterfaceNum - 1], &m_stDevList); } for (int i = 0; i < m_stDevList.nDeviceNum; i++) { @@ -265,22 +266,32 @@ bool Hd_MvCamera_module::sendData(std::vector& mat, QByteArray& data) } } + else if (command == "DigitalShift") + { + int nRet = MV_CC_SetFloatValue(handle, "DigitalShift", value.toFloat()); + if (nRet != MV_OK) + { + cout << "DigitalShift" << inputString.toStdString() << endl; + + } + } } else { int cnt = 0; - while (matQueue.size()==0) + while (matVec.size() <= 1) { cnt++; QThread::msleep(1); - if(cnt>3000) + if (cnt > 10000) return false; } queueMutex.lock(); - while (matQueue.size() != 0) - mat.push_back(matQueue.dequeue()); + for(auto matImg: matVec) + mat.push_back(matImg); + //mat.push_back(matQueue.dequeue()); - matQueue.clear(); + matVec.clear(); queueMutex.unlock(); } @@ -297,7 +308,7 @@ bool Hd_MvCamera_module::reciveData(std::vector& mat, QByteArray& data) bool Hd_MvCamera_module::initParas(QByteArray&) { - return true; + return true; if (!Username.compare("dummy")) { qDebug() << "[INFO] " << " start" << "--UserName: dummy creat sucess"; @@ -347,6 +358,7 @@ bool Hd_MvCamera_module::initParas(QByteArray&) bool Hd_MvCamera_module::run() { qDebug() << "[INFO] " << " run start" << QString::fromStdString(Username); + return true; try { srcImage.release(); @@ -354,7 +366,7 @@ bool Hd_MvCamera_module::run() int reconnectSign = reconnectCount; while (true) { - if(reconnectCount!= reconnectSign) + if (reconnectCount != reconnectSign) m_thread->start(); if (m_flag) { diff --git a/BaseModules/Hd_MvCamera_module/hd_mvcamera_module.h b/BaseModules/Hd_MvCamera_module_GENTL/hd_mvcamera_module.h similarity index 100% rename from BaseModules/Hd_MvCamera_module/hd_mvcamera_module.h rename to BaseModules/Hd_MvCamera_module_GENTL/hd_mvcamera_module.h diff --git a/BaseModules/Hd_MvCamera_module1/CMakeLists.txt b/BaseModules/Hd_MvCamera_module_GIGE/CMakeLists.txt similarity index 100% rename from BaseModules/Hd_MvCamera_module1/CMakeLists.txt rename to BaseModules/Hd_MvCamera_module_GIGE/CMakeLists.txt diff --git a/BaseModules/Hd_MvCamera_module1/base.h b/BaseModules/Hd_MvCamera_module_GIGE/base.h similarity index 100% rename from BaseModules/Hd_MvCamera_module1/base.h rename to BaseModules/Hd_MvCamera_module_GIGE/base.h diff --git a/BaseModules/Hd_MvCamera_module1/hd_mvcamera_module.cpp b/BaseModules/Hd_MvCamera_module_GIGE/hd_mvcamera_module.cpp similarity index 86% rename from BaseModules/Hd_MvCamera_module1/hd_mvcamera_module.cpp rename to BaseModules/Hd_MvCamera_module_GIGE/hd_mvcamera_module.cpp index b57c8e2f..fc9b61c4 100644 --- a/BaseModules/Hd_MvCamera_module1/hd_mvcamera_module.cpp +++ b/BaseModules/Hd_MvCamera_module_GIGE/hd_mvcamera_module.cpp @@ -1,5 +1,23 @@ #include "hd_mvcamera_module.h" std::mutex moduleMutex;//掉线é”� + +QByteArray MV_CC_DeviceInfoListToQByteArray(const MV_CC_DEVICE_INFO_LIST& deviceInfoList) { + QByteArray byteArray; + byteArray.resize(sizeof(MV_CC_DEVICE_INFO_LIST)); + memcpy(byteArray.data(), &deviceInfoList, sizeof(MV_CC_DEVICE_INFO_LIST)); + return byteArray; +} +MV_CC_DEVICE_INFO_LIST QByteArrayToMV_CC_DeviceInfoList(const QByteArray& byteArray) { + MV_CC_DEVICE_INFO_LIST deviceInfoList; + if (byteArray.size() == sizeof(MV_CC_DEVICE_INFO_LIST)) { + memcpy(&deviceInfoList, byteArray.constData(), sizeof(MV_CC_DEVICE_INFO_LIST)); + } + else { + qDebug() << "Invalid size of QByteArray for MV_CC_DEVICE_INFO_LIST!"; + } + return deviceInfoList; +} + int reconnectCount = 0; int SearchDevice(); void __stdcall ImageCallBackEx(unsigned char* pData0, MV_FRAME_OUT_INFO_EX* pFrameInfo0, void* pUser0); @@ -172,9 +190,11 @@ int SearchDevice() int nRet = MV_CC_EnumDevices(MV_GIGE_DEVICE || MV_USB_DEVICE, &m_stDevList); for (int i = 0; i < m_stDevList.nDeviceNum; i++) { - unsigned char* name = m_stDevList.pDeviceInfo[i]->SpecialInfo.stGigEInfo.chSerialNumber; - string serialNumber = static_cast((LPCSTR)name); - if (Username == serialNumber) + unsigned char* serialNumber = m_stDevList.pDeviceInfo[i]->SpecialInfo.stGigEInfo.chSerialNumber; + unsigned char* userDefineName = m_stDevList.pDeviceInfo[i]->SpecialInfo.stGigEInfo.chUserDefinedName; + string serialNumberStr = static_cast((LPCSTR)serialNumber); + string userDefineNameStr = static_cast((LPCSTR)userDefineName); + if (Username == serialNumberStr || Username == userDefineNameStr) { index = i; break; @@ -186,18 +206,17 @@ int SearchDevice() } return -1; } - -Hd_MvCamera_module::Hd_MvCamera_module() -{ - m_thread = new MyThread; -} - void CloseDevice() { MV_CC_StopGrabbing(handle); MV_CC_CloseDevice(handle); MV_CC_DestroyHandle(handle); } +Hd_MvCamera_module::Hd_MvCamera_module() +{ + m_thread = new MyThread; +} + Hd_MvCamera_module::~Hd_MvCamera_module() { CloseDevice(); @@ -253,23 +272,21 @@ bool Hd_MvCamera_module::sendData(std::vector& mat, QByteArray& data) bool Hd_MvCamera_module::reciveData(std::vector& mat, QByteArray& data) { + if (data.size() > 1000) + m_stDevList = QByteArrayToMV_CC_DeviceInfoList(data); + else + Username = data.toStdString(); m_flag = false; - Username = data.toStdString(); return true; } bool Hd_MvCamera_module::initParas(QByteArray&) { - if (!Username.compare("dummy")) - { - qDebug() << "[INFO] " << " start" << "--UserName: dummy creat sucess"; - return true; - } SearchDevice(); unsigned char* serialNumber = m_stDevList.pDeviceInfo[index]->SpecialInfo.stGigEInfo.chSerialNumber; - string userName = static_cast((LPCSTR)serialNumber); - qDebug() << "[INFO] " << " start" << "--UserName:" << QString::fromStdString(userName); + string userNameStr = static_cast((LPCSTR)serialNumber); + qDebug() << "[INFO] " << " start" << "--UserName:" << QString::fromStdString(userNameStr); if (handle != NULL) { MV_CC_StopGrabbing(handle); @@ -279,11 +296,11 @@ bool Hd_MvCamera_module::initParas(QByteArray&) } //打开相机 - MV_CC_CreateHandle(&handle, m_stDevList.pDeviceInfo[index]); - int nRet = MV_CC_OpenDevice(handle); + unsigned int nRet = MV_CC_CreateHandle(&handle, m_stDevList.pDeviceInfo[index]); + nRet = MV_CC_OpenDevice(handle); ////触å�‘模å¼� - MV_CC_SetEnumValue(handle, "TriggerSource", MV_TRIGGER_SOURCE_SOFTWARE); - MV_CC_SetEnumValue(handle, "TriggerMode", MV_TRIGGER_MODE_ON); + nRet = MV_CC_SetEnumValue(handle, "TriggerSource", MV_TRIGGER_SOURCE_SOFTWARE); + nRet = MV_CC_SetEnumValue(handle, "TriggerMode", MV_TRIGGER_MODE_ON); // //加载用户集 nRet = MV_CC_SetEnumValueByString(handle, "UserSetSelector", "UserSet1"); if (MV_OK != nRet) diff --git a/BaseModules/Hd_MvCamera_module1/hd_mvcamera_module.h b/BaseModules/Hd_MvCamera_module_GIGE/hd_mvcamera_module.h similarity index 100% rename from BaseModules/Hd_MvCamera_module1/hd_mvcamera_module.h rename to BaseModules/Hd_MvCamera_module_GIGE/hd_mvcamera_module.h diff --git a/HanddleAI/HandleAiUi-new/CMakeLists.txt b/HanddleAI/HandleAiUi-new/CMakeLists.txt index 394c5d61..1b747944 100644 --- a/HanddleAI/HandleAiUi-new/CMakeLists.txt +++ b/HanddleAI/HandleAiUi-new/CMakeLists.txt @@ -5,7 +5,7 @@ message( " model start : " ${CURRENT_FOLDER}:${RUN_TIME}) -set(DLL_NAMES "halcon" "opencv" "3DAI""algo""sqlite" "handdleAI""myTools") +set(DLL_NAMES "halcon" "opencv" "sqlite" "handdleAI""myTools" "mvs" "algo2") foreach(child ${DLL_NAMES}) LIST(APPEND ENV_INCLUDE ${${child}_include}) LIST(APPEND ENV_LIB ${${child}_lib}) diff --git a/HanddleAI/HandleAiUi-new/back/algorithmThread.cpp b/HanddleAI/HandleAiUi-new/back/algorithmThread.cpp index b02f01b0..b96a3438 100644 --- a/HanddleAI/HandleAiUi-new/back/algorithmThread.cpp +++ b/HanddleAI/HandleAiUi-new/back/algorithmThread.cpp @@ -1,5 +1,4 @@ #include -#include #include "camera_thread.h" #include "myiothread.h" #include "FrontendBackendBridge.h" diff --git a/HanddleAI/HandleAiUi-new/back/algorithmThread.h b/HanddleAI/HandleAiUi-new/back/algorithmThread.h index 99908fb6..49c396b0 100644 --- a/HanddleAI/HandleAiUi-new/back/algorithmThread.h +++ b/HanddleAI/HandleAiUi-new/back/algorithmThread.h @@ -1,10 +1,10 @@ #include +#include #include #include #include #include #include -#include #include #include #include @@ -13,7 +13,9 @@ #include . #include #include +#include using namespace std; +using namespace HalconCpp; enum ngTypeEnum { OK, @@ -97,7 +99,7 @@ public: } cv::Rect boundingBox = cv::boundingRect(contour); cv::Point mid(boundingBox.x + boundingBox.width / 2, boundingBox.y + boundingBox.height / 2); - int sideLength = std::max(std::max(boundingBox.width, boundingBox.height), 128); + int sideLength = max(max(boundingBox.width, boundingBox.height), 128); cv::Mat squareImage(sideLength, sideLength, imgInput.type(), cv::Scalar(0, 0, 0)); cv::Rect expectRect(mid.x - sideLength / 2, mid.y - sideLength / 2, sideLength, sideLength); int xOffset = 0; @@ -132,7 +134,7 @@ public: return cv::Mat(); } cv::Point mid(boundingBox.x + boundingBox.width / 2, boundingBox.y + boundingBox.height / 2); - int sideLength = std::max(std::max(boundingBox.width, boundingBox.height), 128); + int sideLength = max(max(boundingBox.width, boundingBox.height), 128); cv::Mat squareImage(sideLength, sideLength, imgInput.type(), cv::Scalar(0, 0, 0)); cv::Rect expectRect(mid.x - sideLength / 2, mid.y - sideLength / 2, sideLength, sideLength); int xOffset = 0; @@ -611,7 +613,7 @@ public: static bool isContoursOverlap(const std::vector& contour1, const std::vector& contour2, double thresholdPercent = 0) { cv::Rect rect1 = cv::boundingRect(contour1); cv::Rect rect2 = cv::boundingRect(contour2); - cv::Size tempImgSize(std::max(rect1.x + rect1.width, rect2.x + rect2.width), max(rect1.y + rect1.height, rect2.y + rect2.height)); + cv::Size tempImgSize(max(rect1.x + rect1.width, rect2.x + rect2.width), max(rect1.y + rect1.height, rect2.y + rect2.height)); cv::Mat binaryImage = cv::Mat::zeros(tempImgSize,CV_8U); // »­³öÄ¿±êÂÖÀª @@ -640,7 +642,7 @@ public: cv::Rect intersection = rect1 & rect2; if (thresholdPercent != 0)//Èç¹ûÓÐãÐÖµ { - int maxCnotourArea = std::max(rect1.area(), rect2.area()); + int maxCnotourArea = max(rect1.area(), rect2.area()); if (intersection.area() / maxCnotourArea < thresholdPercent) return false; } @@ -1046,7 +1048,7 @@ public: { flag = true; data2.contour = simpleAlgo::contourPlusContour(data.contour, data2.contour);//ÈÚºÏ - data2.ngType = std::max(data.ngType, data2.ngType); + data2.ngType = max(data.ngType, data2.ngType); } } if (flag == false)// ·ñ @@ -1072,7 +1074,7 @@ public: { flag = true; data2.contour = simpleAlgo::contourPlusContour(data.contour, data2.contour);//ÈÚºÏ - data2.ngType = std::max(data.ngType, data2.ngType); + data2.ngType = max(data.ngType, data2.ngType); } } if (flag == false)// ·ñ diff --git a/HanddleAI/HandleAiUi-new/back/backEndController.cpp b/HanddleAI/HandleAiUi-new/back/backEndController.cpp index c236877a..5844785d 100644 --- a/HanddleAI/HandleAiUi-new/back/backEndController.cpp +++ b/HanddleAI/HandleAiUi-new/back/backEndController.cpp @@ -1,8 +1,25 @@ #include #include - +#include +#include +#include backEndController::backEndController() { + _jsonConfiguration = new jsonConfiguration(); _triggerController = new triggerController(); - _triggerController->init(this); + _cameraController = new cameraController(); + std::vector> futures;//Òì²½³õʼ»¯ + futures.push_back(std::async(std::launch::async, &triggerController::init, _triggerController, this)); + futures.push_back(std::async(std::launch::async, &cameraController::init, _cameraController, this)); + for (auto& future : futures) { + future.wait(); + } + /*_triggerController->init(this); + _cameraController->init(this);*/ +} +backEndController::~backEndController() +{ + delete _triggerController; + delete _cameraController; + delete _jsonConfiguration; } \ No newline at end of file diff --git a/HanddleAI/HandleAiUi-new/back/backEndController.h b/HanddleAI/HandleAiUi-new/back/backEndController.h index 4591af94..f7d96101 100644 --- a/HanddleAI/HandleAiUi-new/back/backEndController.h +++ b/HanddleAI/HandleAiUi-new/back/backEndController.h @@ -4,13 +4,17 @@ #include class triggerController; class cameraController; +class jsonConfiguration; class backEndController :public QObject { Q_OBJECT public: bool init = false; triggerController* _triggerController;//´¥·¢Æ÷ + cameraController* _cameraController; + jsonConfiguration* _jsonConfiguration; backEndController(); + ~backEndController(); signals: void sendErrorToMainwindow(backEndError); }; diff --git a/HanddleAI/HandleAiUi-new/back/cameraController.cpp b/HanddleAI/HandleAiUi-new/back/cameraController.cpp index e69de29b..160f25c8 100644 --- a/HanddleAI/HandleAiUi-new/back/cameraController.cpp +++ b/HanddleAI/HandleAiUi-new/back/cameraController.cpp @@ -0,0 +1,162 @@ +#include +#include +#include +#include +#include + +#include +#include +static QByteArray MV_CC_DeviceInfoListToQByteArray(const MV_CC_DEVICE_INFO_LIST& deviceInfoList) { + QByteArray byteArray; + byteArray.resize(sizeof(MV_CC_DEVICE_INFO_LIST)); + memcpy(byteArray.data(), &deviceInfoList, sizeof(MV_CC_DEVICE_INFO_LIST)); + return byteArray; +} +static MV_CC_DEVICE_INFO_LIST QByteArrayToMV_CC_DeviceInfoList(const QByteArray& byteArray) { + MV_CC_DEVICE_INFO_LIST deviceInfoList; + if (byteArray.size() == sizeof(MV_CC_DEVICE_INFO_LIST)) { + memcpy(&deviceInfoList, byteArray.constData(), sizeof(MV_CC_DEVICE_INFO_LIST)); + } + else { + qDebug() << "Invalid size of QByteArray for MV_CC_DEVICE_INFO_LIST!"; + } + return deviceInfoList; +} +static MV_CC_DEVICE_INFO_LIST searchMvDevice() +{ + MV_CC_DEVICE_INFO_LIST m_stDevList; + memset(&m_stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST)); + int nRet = MV_CC_EnumDevices(MV_GIGE_DEVICE || MV_USB_DEVICE, &m_stDevList); + return m_stDevList; +} + +cameraController::~cameraController() +{ + for (auto module : camerasVec) + { + Base* base_ptr = module.module_ptr; + delete base_ptr; + } +} +void cameraController::init(backEndController* input) +{ + _backEndController = input; +#pragma region ¼ÓÔØÏà»údll + for (auto val = 0; val < input->_jsonConfiguration->camera.cameraList.size(); val++) + { + QString camera_key = input->_jsonConfiguration->camera.cameraList[val].connectionName; + QString moduleName = input->_jsonConfiguration->camera.cameraList[val].moduleName; // Ïà»úÄ£¿éÃû + QVector surfaceVec; + QByteArray init_Byte; + // ¼ÓÔØÏà»úÄ£¿é + if (!loadModule(camera_key, moduleName, init_Byte)) + { + qCritical() << "[Error] " << " moduleName:" << moduleName << " load camera module failed! "; + return; + } + } +#pragma endregion + + //·Çº£¿µÏà»ú¿ÉÌø¹ý + MV_CC_DEVICE_INFO_LIST m_stDevList = searchMvDevice(); + QByteArray mvDevices = MV_CC_DeviceInfoListToQByteArray(m_stDevList); + + for (auto i = 0; i < camerasVec.size(); i++) + { + cameraModule m_module = camerasVec.at(i); + QString moduleName = m_module.moduleName; + QString key = m_module.key; + //´«µÝ³õʼ»¯²ÎÊý + QByteArray initByte = m_module.m_initByte; + QByteArray m_keyByte = key.toUtf8(); + //±éÀúÊÇ·ñÓÐÏàͬkeyµÄÏà»ú£¬Èç¹ûÓÐÖ±½Ó¸´ÖÆÖ¸Õë + for (int count = 0; count < camerasVec.size(); count++) + if (!camerasVec[count].key.compare(m_module.key) && count < i) + m_module.module_ptr = camerasVec[count].module_ptr; + m_module.module_ptr->reciveData(vec_mat, m_keyByte); //³õʼ»¯Ïà»ú + + //·Çº£¿µÏà»ú¿ÉÌø¹ý + for (int i = 0; i < m_stDevList.nDeviceNum; i++) + { + std::string userDefineName = static_cast((LPCSTR)m_stDevList.pDeviceInfo[i]->SpecialInfo.stGigEInfo.chUserDefinedName); + std::string serialNumber = static_cast((LPCSTR)m_stDevList.pDeviceInfo[i]->SpecialInfo.stGigEInfo.chSerialNumber); + if (!serialNumber.compare(m_module.key.toStdString()) || !userDefineName.compare(m_module.key.toStdString())) + { + m_module.module_ptr->reciveData(vec_mat, mvDevices); + break; + } + } + + if (m_module.module_ptr->initParas(initByte)) + { + camera* _camera = new camera(m_module); + cameras.insert(std::make_pair(m_module.key, _camera)); + qDebug() << "[INFO] " << " initParas success!"; + } + else + qCritical() << "[Error] " << " moduleName:" << m_module.moduleName << " initParas failed!"; + } +} +bool cameraController::loadModule(QString keyName, QString moduleName, QByteArray initByte) +{ + QString task_thread_index = 0; + try + { + QString module_path = "./" + moduleName; + qDebug() << "[INFO] " << " module_path:" << module_path; + + /////// ×Ô¶¯¿½±´ÖØÓÃdll + if (QString(module_path.at(module_path.size() - 1)).toInt() > 0) { + //ÃüÃû¸ñʽ£º Ä£¿éÃû+1/2/3... + QString path_model = module_path.mid(0, module_path.size() - 1); + if (QFile::exists(path_model + ".dll")) { + QFile::remove(module_path + ".dll"); + QFile::copy(path_model + ".dll", module_path + ".dll"); + + qDebug() << "[INFO] " << "copy dll " << module_path; + } + + } + /// ¶¯Ì¬¼ÓÔØdll + + QLibrary* m_lib = new QLibrary(module_path); + lib_list.append(m_lib); + bool flag = m_lib->load(); + if (!m_lib->isLoaded()) + { + + qDebug() << "[Error] " << " Loaded error:" << m_lib->errorString(); + return false; + } + + CreateFunction createFun = (CreateFunction)m_lib->resolve("create"); + ReleaseFunction releaseFun = (ReleaseFunction)m_lib->resolve("destory"); + if (createFun && releaseFun) + { + cameraModule m_module; + m_module.key = keyName; + m_module.m_initByte = initByte; + m_module.moduleName = moduleName; + m_module.module_ptr = createFun(); + m_module.destory_ptr = releaseFun; + + if (!task_thread_index.isEmpty()) + m_module.task_thread_index = task_thread_index; + + camerasVec.push_back(m_module); + } + else + { + delete m_lib; + m_lib = nullptr; + return false; + } + } + catch (QString event) + { + qCritical() << "[Error] " << " event:" << event; + return false; + } + return true; +} + diff --git a/HanddleAI/HandleAiUi-new/back/cameraController.h b/HanddleAI/HandleAiUi-new/back/cameraController.h index 4119e773..2bf56b51 100644 --- a/HanddleAI/HandleAiUi-new/back/cameraController.h +++ b/HanddleAI/HandleAiUi-new/back/cameraController.h @@ -2,11 +2,76 @@ #define CAMERACONTROLLER_H #include #include +#include +#include +#include +#include +#include +#include +#include + class backEndController; +class camera : public QThread +{ +public: + QString cameraName; + camera(cameraModule cameraModulePtrIn) + { + cameraModulePtr=cameraModulePtrIn; + cameraName = cameraModulePtr.key; + this->start(); + } + void run() + { + std::vectorcamera_mat; + while (runFlag) + { + getCameraImg(camera_mat); + if (camera_mat.size() > 0) + { + for (auto img : camera_mat) + imgQueue.enqueue(img); + } + QThread::msleep(100); + } + } + + void getCameraImg(std::vector& mats) + { + QByteArray task_name; + if (!cameraModulePtr.module_ptr->sendData(mats, task_name)) + qCritical() << "[Error] " << " camera_mat is error! "; + qDebug() << __FUNCTION__ << " line:" << __LINE__ << "camera_mat size:" << mats.size(); + } + bool trigger() + { + if (!cameraModulePtr.module_ptr->run()) + { + qCritical() << "[Error] " << " m_name:" << cameraName << " run failed!"; + return false; + } + return true; + } + void getImgQueueSize(); +private: + cameraModule cameraModulePtr; + QQueueimgQueue; + + bool runFlag = true; +}; class cameraController { public: + void init(backEndController*); + ~cameraController(); + std::unordered_mapcameras;//key Ïà»úÃû +private: + bool loadModule(QString keyName, QString moduleName, QByteArray initByte); + backEndController* _backEndController; + std::vectorcamerasVec;//ÓÃÓÚ³õʼ»¯ºÍÏú»Ù + std::vector vec_mat;//ûɶÓã¬Ò»Ö±±£³ÖΪ¿Õ¾ÍºÃ + QList lib_list; }; #endif \ No newline at end of file diff --git a/HanddleAI/HandleAiUi-new/back/myiothread.cpp b/HanddleAI/HandleAiUi-new/back/myiothread.cpp index 231e0116..49c2f7f7 100644 --- a/HanddleAI/HandleAiUi-new/back/myiothread.cpp +++ b/HanddleAI/HandleAiUi-new/back/myiothread.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include diff --git a/HanddleAI/HandleAiUi-new/back/taskthread.cpp b/HanddleAI/HandleAiUi-new/back/taskthread.cpp index ac82efe9..75630dbd 100644 --- a/HanddleAI/HandleAiUi-new/back/taskthread.cpp +++ b/HanddleAI/HandleAiUi-new/back/taskthread.cpp @@ -102,7 +102,7 @@ bool taskThread::processTask() return true; } processExecData(); - Sleep(5); + _sleep(5); } } diff --git a/HanddleAI/HandleAiUi-new/back/threadPoolController.cpp b/HanddleAI/HandleAiUi-new/back/threadPoolController.cpp index e8d741bb..c2b97494 100644 --- a/HanddleAI/HandleAiUi-new/back/threadPoolController.cpp +++ b/HanddleAI/HandleAiUi-new/back/threadPoolController.cpp @@ -1,5 +1,4 @@ #include -#include #include "camera_thread.h" #include "myiothread.h" #include diff --git a/HanddleAI/HandleAiUi-new/back/threadPoolController.h b/HanddleAI/HandleAiUi-new/back/threadPoolController.h index a78789fd..99766e93 100644 --- a/HanddleAI/HandleAiUi-new/back/threadPoolController.h +++ b/HanddleAI/HandleAiUi-new/back/threadPoolController.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include diff --git a/HanddleAI/HandleAiUi-new/back/triggerController.h b/HanddleAI/HandleAiUi-new/back/triggerController.h index 2ac609b9..cde71301 100644 --- a/HanddleAI/HandleAiUi-new/back/triggerController.h +++ b/HanddleAI/HandleAiUi-new/back/triggerController.h @@ -58,7 +58,6 @@ private: class triggerController : public QThread { public: - backEndController* _backEndController; QString triggerFileName = QString("Hd_SocketModule_ModbusTcp"); ~triggerController() { @@ -124,6 +123,7 @@ public: return true; } private: + backEndController* _backEndController; triggerLockerT tLocker;//·ÀÖ¹ÖØ¸´´¥·¢,ÿ´ÎÊÕµ½Êý¾Ýʱ¼ì²éÊý¾ÝÊÇ·ñÓëÉÏ´ÎÏàͬ£¬Èç¹ûÏàͬcheckTrigger»á·µ»Øfalse /// /// ¼ì²âQByteArrayÖÐijλÖõÄÖµÊÇ·ñºÍÊäÈëÒ»Ñù£¬Ê¹ÓÃÁ˾ø¶ÔλÖà diff --git a/HanddleAI/HandleAiUi-new/front/pages/logPageWidget.h b/HanddleAI/HandleAiUi-new/front/pages/logPageWidget.h index 537e45ef..0b5994b5 100644 --- a/HanddleAI/HandleAiUi-new/front/pages/logPageWidget.h +++ b/HanddleAI/HandleAiUi-new/front/pages/logPageWidget.h @@ -15,8 +15,10 @@ #include static QTextEdit* globalQtTextEdit=nullptr; -static QTextStream globalQtlogFile; -static QTextStream globalStdlogFile; +static QFile* qtLogFile; +static QFile* stdLogFile; +static QTextStream* globalQtlogFile = nullptr; +static QTextStream* globalStdlogFile = nullptr; static void MessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg) { @@ -40,12 +42,13 @@ static void MessageHandler(QtMsgType type, const QMessageLogContext& context, co break; } logStr.append(QString("%1%2:\n-->%3\n").arg(context.line).arg(context.function).arg(msg)); - QFile logFile(QString("./Log/%1QtLog.log").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd"))); - if (logFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { - globalQtlogFile.setCodec("UTF-8"); - globalQtlogFile.setDevice(&logFile); - globalQtlogFile << logStr << endl; - } + *globalQtlogFile << logStr << endl; + //QFile logFile(QString("./Log/%1QtLog.log").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd"))); + //if (logFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { + // globalQtlogFile.setCodec("UTF-8"); + // globalQtlogFile.setDevice(&logFile); + // globalQtlogFile << logStr << endl; + //} //if (globalQtTextEdit != nullptr) { // globalQtTextEdit->moveCursor(QTextCursor::End); // globalQtTextEdit->insertPlainText(logStr + "\n"); @@ -76,12 +79,7 @@ protected: QString logStr = (QDateTime::currentDateTime().toString(u8"(yyyy-MM-dd hh:mm:ss dddd)")).toUtf8(); logStr.append(QString("-->%1\n").arg(text)); - QFile logFile(QString("./Log/%1StdLog.log").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd"))); - if (logFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { - globalQtlogFile.setCodec("UTF-8"); - globalQtlogFile.setDevice(&logFile); - globalQtlogFile << logStr << endl; - } + *globalStdlogFile << logStr << endl; return n; } @@ -145,7 +143,6 @@ public: Layout->addWidget(widgets); } - void addConfigWidget(QString btnText,QTextEdit* textWidget, logType type) { QPalette palette; @@ -201,10 +198,21 @@ public: if(type==stdConsle) { stdConsoleRedirector _stdConsoleRedirector(std::cout, textWidget); - std::cout << "Test" << std::endl; + stdLogFile = new QFile(QString("./Log/%1StdLog.log").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd"))); + if (stdLogFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { + globalStdlogFile = new QTextStream(); + globalStdlogFile->setCodec("UTF-8"); + globalStdlogFile->setDevice(stdLogFile); + } } else if (type == qtConsle) { + qtLogFile =new QFile(QString("./Log/%1QtLog.log").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd"))); + if (qtLogFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { + globalQtlogFile = new QTextStream(); + globalQtlogFile->setCodec("UTF-8"); + globalQtlogFile->setDevice(qtLogFile); + } globalQtTextEdit = textWidget; //globalQtTextEdit->setUpdatesEnabled(false); diff --git a/HanddleAI/HandleAiUi-new/uiModule/uiModule_dumpToExcel.h b/HanddleAI/HandleAiUi-new/uiModule/uiModule_dumpToExcel.h index a539e29b..ccff664a 100644 --- a/HanddleAI/HandleAiUi-new/uiModule/uiModule_dumpToExcel.h +++ b/HanddleAI/HandleAiUi-new/uiModule/uiModule_dumpToExcel.h @@ -25,7 +25,7 @@ public: { int time1 = startTimeEdit->time().hour() * 60 + startTimeEdit->time().minute(); int time2 = endTimeEdit->time().hour() * 60 + startTimeEdit->time().minute(); - return { std::min(time1,time2),std::max(time1,time2) }; + return { min(time1,time2),max(time1,time2) }; } QTime getStartTime() const { diff --git a/README.md b/README.md index f55c863f..8debc631 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ #还未完æˆ�的功能 +!日志æœ�务 日志过滤 日志字符串匹é…� é…�置功能完善 diff --git a/lib/Hd_MvCamera_module_GENTL.exp b/lib/Hd_MvCamera_module_GENTL.exp new file mode 100644 index 00000000..588ebc79 Binary files /dev/null and b/lib/Hd_MvCamera_module_GENTL.exp differ diff --git a/lib/Hd_MvCamera_module_GENTL.lib b/lib/Hd_MvCamera_module_GENTL.lib new file mode 100644 index 00000000..578b535e Binary files /dev/null and b/lib/Hd_MvCamera_module_GENTL.lib differ diff --git a/lib/Hd_MvCamera_module_GIGE.exp b/lib/Hd_MvCamera_module_GIGE.exp new file mode 100644 index 00000000..0c571208 Binary files /dev/null and b/lib/Hd_MvCamera_module_GIGE.exp differ diff --git a/lib/Hd_MvCamera_module_GIGE.lib b/lib/Hd_MvCamera_module_GIGE.lib new file mode 100644 index 00000000..f5ba12df Binary files /dev/null and b/lib/Hd_MvCamera_module_GIGE.lib differ