添加设备管理功能,增加原图保存功能

master
bobpan 5 years ago
parent 69aee070bd
commit 4c079d612a

@ -6,9 +6,6 @@ algorithm::algorithm(class IDetectorEngine* pDE) : m_pDE(pDE)
m_pRunSolution = NULL; m_pRunSolution = NULL;
m_nCount = 0; m_nCount = 0;
m_nTaskCount = 0; m_nTaskCount = 0;
// m_pDBMgr = NULL;
// m_pDB = NULL;
m_bResetSolution = false; m_bResetSolution = false;
m_pRunCopySolution = NULL; m_pRunCopySolution = NULL;
@ -24,11 +21,6 @@ algorithm::algorithm(class IDetectorEngine* pDE) : m_pDE(pDE)
m_pDE->GetDataInterface(DEVICEMGR, &p); m_pDE->GetDataInterface(DEVICEMGR, &p);
m_pDeviceMgr = (IDetectorDeviceMgr*)p; m_pDeviceMgr = (IDetectorDeviceMgr*)p;
// m_pDE->GetDataInterface(DBMGR, &p);
// m_pDBMgr = (IDBPool*)p;
// m_pDB = m_pDBMgr->GetDBConnByName("Conn0");
m_pSolutionMgr->RegistSink(this); m_pSolutionMgr->RegistSink(this);
return; return;
@ -165,7 +157,9 @@ bool algorithm::RunTask(class IImageObject* pImgObj, IDetectorTask* pTask, cv::M
map.insert(lppOutParam[j]->strName, lppOutParam[j]->value); map.insert(lppOutParam[j]->strName, lppOutParam[j]->value);
} }
} }
map.insert("taskID", pTask->GetID());
map.insert("originImage", EngineBase::convMat2QImage(imgSrc));
map.insert("tasktime", pTask->ExecTime());
pImgObj->IVariantMapToUI(map); pImgObj->IVariantMapToUI(map);
delete[] lppOutParam; delete[] lppOutParam;
} }
@ -244,8 +238,6 @@ bool algorithm::RunTask(class IImageObject* pImgObj, IDetectorTask* pTask, cv::M
map.insert("originImage", EngineBase::convMat2QImage(imgSrc)); map.insert("originImage", EngineBase::convMat2QImage(imgSrc));
map.insert("tasktime", pTask->ExecTime()); map.insert("tasktime", pTask->ExecTime());
pImgObj->IVariantMapToUI(map); pImgObj->IVariantMapToUI(map);
//pTask->SaveOutParam2DB(m_pDB);
} }
} }

@ -41,10 +41,10 @@ void QDiskCleanThread::run()
//qWarning() << "Start Scan Disk ..."; //qWarning() << "Start Scan Disk ...";
QString strDisk = m_strImgStorageFolder.left(2); QString strDisk = m_strImgStorageFolder.left(2);
int space = solarCell::SolarCellHelper::GetDiskFreeSpace(strDisk); int space = solarCell::SolarCellHelper::GetDiskFreeSpace(strDisk);
if (space < 1024 * 10) if (space < 1024 * nMiniSize)
{ {
isUse = true; isUse = true;
m_nDay = 3; m_nDay = 1;
} }
//qWarning() << "spacesize =" << space; //qWarning() << "spacesize =" << space;
@ -75,7 +75,7 @@ void QDiskCleanThread::run()
} }
} }
space = solarCell::SolarCellHelper::GetDiskFreeSpace(strDisk); space = solarCell::SolarCellHelper::GetDiskFreeSpace(strDisk);
qWarning() << "Delete Imgs ..."; //qWarning() << "Delete Imgs ...";
} }

@ -258,9 +258,9 @@ QStringList Station::modelList()
void Station::revResult() void Station::revResult()
{ {
emit(sgaddRevCount(1)); emit(sgaddRevCount(1));
if (m_pWfCtrl->IBatchModel()) { // if (m_pWfCtrl->IBatchModel()) {
//
} // }
} }
bool Station::trigImage() bool Station::trigImage()

@ -25,11 +25,12 @@ CWfCtrl::CWfCtrl(ICoreCtrl* p1, WfColossus* p3)
QSettings systemIniFile("systemInfo.ini", QSettings::IniFormat); QSettings systemIniFile("systemInfo.ini", QSettings::IniFormat);
m_nOnlineMode = systemIniFile.value("OnlineMode").toBool(); m_nOnlineMode = systemIniFile.value("OnlineMode").toBool();
{ {
QString strErrorPath = QCoreApplication::applicationDirPath()+"/errorImage/"; QString strSrcImgPath = QCoreApplication::applicationDirPath() + "/DBFiles/SrcImages/";
QDiskCleanThread *pDCleanThread = new QDiskCleanThread; QDiskCleanThread *pDCleanThread = new QDiskCleanThread;
pDCleanThread->setModel(CleanDir);
pDCleanThread->setUseFlag(lpSysConfig::instance()->m_CheckEnable); pDCleanThread->setUseFlag(lpSysConfig::instance()->m_CheckEnable);
pDCleanThread->setDays(lpSysConfig::instance()->m_CheckFileDays); pDCleanThread->setDays(lpSysConfig::instance()->m_CheckFileDays);
pDCleanThread->SetImgStorageFolder(strErrorPath); pDCleanThread->SetImgStorageFolder(strSrcImgPath);
pDCleanThread->setMiniSize(lpSysConfig::instance()->m_MinSpaceSizeG); pDCleanThread->setMiniSize(lpSysConfig::instance()->m_MinSpaceSizeG);
pDCleanThread->start(); pDCleanThread->start();
m_pDCThreadList.append(pDCleanThread); m_pDCThreadList.append(pDCleanThread);
@ -37,7 +38,6 @@ CWfCtrl::CWfCtrl(ICoreCtrl* p1, WfColossus* p3)
QString strRltImgPath = QCoreApplication::applicationDirPath() + "/DBFiles/Images/"; QString strRltImgPath = QCoreApplication::applicationDirPath() + "/DBFiles/Images/";
QDiskCleanThread *pCleanDir = new QDiskCleanThread; QDiskCleanThread *pCleanDir = new QDiskCleanThread;
pCleanDir->setModel(CleanDir); pCleanDir->setModel(CleanDir);
pCleanDir->setSleepS(3600);
pCleanDir->setUseFlag(lpSysConfig::instance()->m_CheckEnable); pCleanDir->setUseFlag(lpSysConfig::instance()->m_CheckEnable);
pCleanDir->setDays(lpSysConfig::instance()->m_CheckFileDays); pCleanDir->setDays(lpSysConfig::instance()->m_CheckFileDays);
pCleanDir->SetImgStorageFolder(strRltImgPath); pCleanDir->SetImgStorageFolder(strRltImgPath);

@ -126,12 +126,6 @@ CMainWin::CMainWin(QWidget *parent)
CMainWin::~CMainWin() CMainWin::~CMainWin()
{ {
// if (m_pDesignerMgr)
// {
// delete m_pDesignerMgr;
// m_pDesignerMgr = nullptr;
// }
DELETE_POINTER(m_pCameraTrig); DELETE_POINTER(m_pCameraTrig);
DELETE_POINTER(m_pWfCtrl); DELETE_POINTER(m_pWfCtrl);
DELETE_POINTER(m_pColossus); DELETE_POINTER(m_pColossus);
@ -150,7 +144,11 @@ CMainWin::~CMainWin()
delete m_pSerialPort; delete m_pSerialPort;
m_pSerialPort = NULL; m_pSerialPort = NULL;
} }
// if (m_pDesignerMgr)
// {
// delete m_pDesignerMgr;
// m_pDesignerMgr = nullptr;
// }
if (m_pDllDetectorEngine) if (m_pDllDetectorEngine)
{ {
delete m_pDllDetectorEngine; delete m_pDllDetectorEngine;
@ -162,6 +160,7 @@ CMainWin::~CMainWin()
delete m_pDllCoreCtrl; delete m_pDllCoreCtrl;
m_pDllCoreCtrl = nullptr; m_pDllCoreCtrl = nullptr;
} }
lpSysConfig::uninstance();
rmTranslator(); rmTranslator();
lpSysLog::uninstance(); lpSysLog::uninstance();
} }
@ -181,6 +180,8 @@ void CMainWin::IVariantMapToUI(emTpUiDataType dataType, const QString& camKey, c
if (!vMap.contains("angle")) { if (!vMap.contains("angle")) {
qWarning() << "no angle result"; qWarning() << "no angle result";
} }
QImage srcImg = vMap.value("originImage").value<QImage>();
double dAngle = vMap.contains("angle") ? vMap.value("angle").toDouble() : 365; double dAngle = vMap.contains("angle") ? vMap.value("angle").toDouble() : 365;
int errorType = vMap.contains("error") ? vMap.value("error").toInt() : 16; int errorType = vMap.contains("error") ? vMap.value("error").toInt() : 16;
double matchScore = vMap.value("score").toDouble() * 100; double matchScore = vMap.value("score").toDouble() * 100;
@ -208,6 +209,8 @@ void CMainWin::IVariantMapToUI(emTpUiDataType dataType, const QString& camKey, c
int ID = pStation->stationId(); int ID = pStation->stationId();
QString strModelName = QString("%1_%2").arg(ID).arg(str2); QString strModelName = QString("%1_%2").arg(ID).arg(str2);
QString strImgPath = genSavePath(strModelName, image); QString strImgPath = genSavePath(strModelName, image);
if(lpSysConfig::instance()->m_bSaveSrcImg == true)
genSaveSrcImgPath(strModelName, srcImg);
Struct2SaveData nStructData; Struct2SaveData nStructData;
nStructData.dAngle = dAngle; nStructData.dAngle = dAngle;
nStructData.errorType = errorType; nStructData.errorType = errorType;
@ -220,12 +223,11 @@ void CMainWin::IVariantMapToUI(emTpUiDataType dataType, const QString& camKey, c
qWarning() << "Add Result to DB,cam=" << camKey; qWarning() << "Add Result to DB,cam=" << camKey;
m_db->addData2DB(nStructData); m_db->addData2DB(nStructData);
} }
else { // else {
qWarning() << "can not find station key=" << camKey; // qWarning() << "can not find station key=" << camKey;
qWarning() << "framework, camera kyes:" << m_pCoreCtrl->ICameraKeys(); // qWarning() << "framework, camera kyes:" << m_pCoreCtrl->ICameraKeys();
qWarning() << "wf ctrl, camera kyes:" << m_pWfCtrl->IGetStationKeys(); // qWarning() << "wf ctrl, camera kyes:" << m_pWfCtrl->IGetStationKeys();
} // }
qDebug() << "variant 2 ui, end";
} }
QVariant CMainWin::IGetVariantById(int id) QVariant CMainWin::IGetVariantById(int id)
@ -237,6 +239,24 @@ QVariant CMainWin::IGetVariantById(int id)
return QVariant(); return QVariant();
} }
QString CMainWin::genSaveSrcImgPath(QString modelName, QImage &img)
{
QString strApp = QApplication::applicationDirPath();
QString targetPath = "/DBFiles/SrcImages";
QString strData = QDateTime::currentDateTime().toString("yyyyMMdd");
QString strFileName = QDateTime::currentDateTime().toString("yyyy_MM_dd_hhmmsszzz") + ".bmp";
targetPath = targetPath + "/" + strData + "/" + modelName;
QDir dir;
dir.mkpath(strApp + targetPath);
targetPath = targetPath + "/" + strFileName;
if (!img.isNull()) {
QString strImg = strApp + targetPath;
img.save(strImg);
}
return targetPath;
}
QString CMainWin::genSavePath(QString modelName, QImage &img) QString CMainWin::genSavePath(QString modelName, QImage &img)
{ {
QString strApp = QApplication::applicationDirPath(); QString strApp = QApplication::applicationDirPath();

@ -47,6 +47,7 @@ public:
virtual void IAlgorithmResult(const QVariantMap& varMap) {}; virtual void IAlgorithmResult(const QVariantMap& varMap) {};
virtual void IVariantMapToUI(emTpUiDataType dataType, const QString& camKey, const QVariantMap& vMap); virtual void IVariantMapToUI(emTpUiDataType dataType, const QString& camKey, const QVariantMap& vMap);
virtual QVariant IGetVariantById(int id); virtual QVariant IGetVariantById(int id);
virtual void IIoStatesChanged(int nOldState, int nNewState) {}; virtual void IIoStatesChanged(int nOldState, int nNewState) {};
virtual void ICommAchieved(const char* szCom, int nCmd, BYTE* pData, int nDataLen) {}; virtual void ICommAchieved(const char* szCom, int nCmd, BYTE* pData, int nDataLen) {};
virtual WORD IGetWorkState() { return 0; };//心跳包中发送的用来控制是否触发的值返回0不触发返回1触发 virtual WORD IGetWorkState() { return 0; };//心跳包中发送的用来控制是否触发的值返回0不触发返回1触发
@ -57,6 +58,7 @@ public:
Q_SLOT void onShowLog(int nID, QString strMsg); Q_SLOT void onShowLog(int nID, QString strMsg);
Q_SLOT void onActionClicked(); Q_SLOT void onActionClicked();
QString genSavePath(QString modelName, QImage &img); QString genSavePath(QString modelName, QImage &img);
QString genSaveSrcImgPath(QString modelName, QImage &img);
protected: protected:
virtual void timerEvent(QTimerEvent *event); virtual void timerEvent(QTimerEvent *event);
virtual void closeEvent(QCloseEvent *event); virtual void closeEvent(QCloseEvent *event);

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1028</width> <width>1022</width>
<height>705</height> <height>705</height>
</rect> </rect>
</property> </property>
@ -149,12 +149,6 @@
<height>372</height> <height>372</height>
</size> </size>
</property> </property>
<property name="maximumSize">
<size>
<width>492</width>
<height>372</height>
</size>
</property>
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::Panel</enum> <enum>QFrame::Panel</enum>
</property> </property>
@ -188,19 +182,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
@ -236,12 +217,6 @@
<height>372</height> <height>372</height>
</size> </size>
</property> </property>
<property name="maximumSize">
<size>
<width>492</width>
<height>372</height>
</size>
</property>
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::Panel</enum> <enum>QFrame::Panel</enum>
</property> </property>

@ -1,11 +1,49 @@
#include "QDeviceMgrUI.h" #include "QDeviceMgrUI.h"
#include "lpSysConfig.h"
#include "QTipWidget.h"
#pragma execution_character_set("utf-8")
QDeviceMgrUI::QDeviceMgrUI(QWidget *parent) QDeviceMgrUI::QDeviceMgrUI(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
ui.setupUi(this); ui.setupUi(this);
connect(ui.m_pbOK, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
} }
QDeviceMgrUI::~QDeviceMgrUI() QDeviceMgrUI::~QDeviceMgrUI()
{ {
} }
Q_SLOT void QDeviceMgrUI::onButtonClicked()
{
getParam();
lpSysConfig::instance()->writeConfig();
ShowMessage(QObject::tr("²ÎÊýÒѱ£´æ"));
}
void QDeviceMgrUI::setParam()
{
ui.m_lineEdit_ComName->setText(lpSysConfig::instance()->m_ComName);
ui.m_lineEdit_Baute->setText(QString("%1").arg(lpSysConfig::instance()->m_Baut));
ui.checkBox->setChecked(lpSysConfig::instance()->m_bSaveSrcImg);
ui.checkBox_2->setChecked(lpSysConfig::instance()->m_CheckEnable);
ui.spinBox->setValue(lpSysConfig::instance()->m_MinSpaceSizeG);
ui.spinBox_2->setValue(lpSysConfig::instance()->m_CheckFileDays);
}
void QDeviceMgrUI::getParam()
{
lpSysConfig::instance()->m_ComName = ui.m_lineEdit_ComName->text();
lpSysConfig::instance()->m_Baut = ui.m_lineEdit_Baute->text().toInt();
lpSysConfig::instance()->m_bSaveSrcImg = ui.checkBox->isChecked();
lpSysConfig::instance()->m_CheckEnable = ui.checkBox_2->isChecked();
lpSysConfig::instance()->m_MinSpaceSizeG = ui.spinBox->value();
lpSysConfig::instance()->m_CheckFileDays = ui.spinBox_2->value();
}
void QDeviceMgrUI::showEvent(QShowEvent *event)
{
setParam();
}

@ -12,6 +12,11 @@ public:
QDeviceMgrUI(QWidget *parent = Q_NULLPTR); QDeviceMgrUI(QWidget *parent = Q_NULLPTR);
~QDeviceMgrUI(); ~QDeviceMgrUI();
Q_SLOT void onButtonClicked();
void setParam();
void getParam();
virtual void showEvent(QShowEvent *event);
private: private:
Ui::QDeviceMgrUI ui; Ui::QDeviceMgrUI ui;
}; };

@ -6,13 +6,260 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>516</width>
<height>300</height> <height>195</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>设备管理</string> <string>设备管理</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="m_pbOK">
<property name="minimumSize">
<size>
<width>100</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>确定并应用</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="title">
<string>通讯设备配置:</string>
</property>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>串口名:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="m_lineEdit_ComName">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_18">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>波特率:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="m_lineEdit_Baute">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="title">
<string>其他相关:</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>是否保存原图功能</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_2">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>是否启用定期删除功能</string>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>预留磁盘大小:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="suffix">
<string>G</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>超期天数:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_2">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="suffix">
<string>天</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>360</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<resources/> <resources/>

@ -25,6 +25,8 @@ void lpSysConfig::readConfig()
m_MinSpaceSizeG = setting.value("CheckThread/spacesize", 10).toInt();//G m_MinSpaceSizeG = setting.value("CheckThread/spacesize", 10).toInt();//G
m_TrigerFilter = setting.value("TrigDetector/FilterTime", 10).toInt(); m_TrigerFilter = setting.value("TrigDetector/FilterTime", 10).toInt();
m_bSaveSrcImg = setting.value("Image/Save", false).toBool();
} }
void lpSysConfig::writeConfig() void lpSysConfig::writeConfig()
@ -40,4 +42,6 @@ void lpSysConfig::writeConfig()
setting.setValue("CheckThread/spacesize", m_MinSpaceSizeG);//G setting.setValue("CheckThread/spacesize", m_MinSpaceSizeG);//G
setting.setValue("TrigDetector/FilterTime", m_TrigerFilter); setting.setValue("TrigDetector/FilterTime", m_TrigerFilter);
setting.setValue("Image/Save", m_bSaveSrcImg);
} }

@ -27,6 +27,8 @@ public:
int m_MinSpaceSizeG{ 10 };//G int m_MinSpaceSizeG{ 10 };//G
int m_TrigerFilter{ 10 }; int m_TrigerFilter{ 10 };
bool m_bSaveSrcImg{ false };
private: private:
QString m_CfgPath; QString m_CfgPath;
}; };

Loading…
Cancel
Save