|
|
|
@ -6,34 +6,28 @@ SmokeBoxIdentification::SmokeBoxIdentification(QWidget *parent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
qRegisterMetaType<QVector<ImageInfo> >("QVector<ImageInfo>");
|
|
|
|
qRegisterMetaType<QVector<ImageInfo> >("QVector<ImageInfo>");
|
|
|
|
qRegisterMetaType<QMap<QString, int> >("QMap<QString,int>");
|
|
|
|
qRegisterMetaType<QMap<QString, int> >("QMap<QString,int>");
|
|
|
|
qRegisterMetaType<lightCtrl>("lightCtrl");
|
|
|
|
qRegisterMetaType<QMap<QString, int> >("QMap<QString,int>");
|
|
|
|
ui.setupUi(this);
|
|
|
|
ui.setupUi(this);
|
|
|
|
this->setWindowTitle(tr("ÑÌÏä¼ì²âϵͳ"));
|
|
|
|
this->setWindowTitle(tr("ÑÌÏä¼ì²âϵͳ"));
|
|
|
|
//m_pShowRltImgLabel = ui.label_showImg;
|
|
|
|
//m_pShowRltImgLabel = ui.label_showImg;
|
|
|
|
//m_pCameraControl = new CameraControl();
|
|
|
|
|
|
|
|
//m_pCaptureThread = new QThread();
|
|
|
|
|
|
|
|
//m_pCameraControl->moveToThread(m_pCaptureThread);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(this, &SmokeBoxIdentification::sgCapture, CameraControl::instance(), &CameraControl::onCapture);
|
|
|
|
connect(this, &SmokeBoxIdentification::sgCapture, CameraControl::instance(), &CameraControl::onCapture);
|
|
|
|
connect(CameraControl::instance(), &CameraControl::sgCapturedImage, this, &SmokeBoxIdentification::onCapturedImage);
|
|
|
|
connect(CameraControl::instance(), &CameraControl::sgCapturedImage, this, &SmokeBoxIdentification::onCapturedImage);
|
|
|
|
//connect(m_pCaptureThread, &QThread::finished, m_pCameraControl, &QObject::deleteLater);
|
|
|
|
|
|
|
|
//m_pCaptureThread->start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString applicationDirPath = QCoreApplication::applicationDirPath();
|
|
|
|
QString applicationDirPath = QCoreApplication::applicationDirPath();
|
|
|
|
QtConcurrent::run([=]()
|
|
|
|
QtConcurrent::run([=]()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//readCameraConfig();
|
|
|
|
|
|
|
|
//m_bCamerasInit = initCamera();
|
|
|
|
|
|
|
|
if (decodeSmokeInfoCsv(applicationDirPath + SMOKEINFO_XLSX_CONFIG))
|
|
|
|
if (decodeSmokeInfoCsv(applicationDirPath + SMOKEINFO_XLSX_CONFIG))
|
|
|
|
matchSmokeNameAndTemplateFolderName(applicationDirPath + NUM_TEMPLATE_PATH);
|
|
|
|
matchSmokeNameAndTemplateFolderName(applicationDirPath + NUM_TEMPLATE_PATH);
|
|
|
|
m_pDataProcess = std::make_shared<dataPreProcessing>();
|
|
|
|
m_pDataProcess = std::make_shared<dataPreProcessing>();
|
|
|
|
|
|
|
|
|
|
|
|
if (m_pDataProcess)
|
|
|
|
if (m_pDataProcess)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//dataPreProcessing * t = (dataPreProcessing*)m_pDataProcess.get();
|
|
|
|
//dataPreProcessing * t = (dataPreProcessing*)m_pDataProcess.get();
|
|
|
|
m_pDataProcess->getFileDir(applicationDirPath + NUM_TEMPLATE_PATH);
|
|
|
|
m_pDataProcess->getFileDir(applicationDirPath + NUM_TEMPLATE_PATH);
|
|
|
|
m_pDataProcess->transmitFilePathForSampleWithItsCorresLabel();
|
|
|
|
m_pDataProcess->transmitFilePathForSampleWithItsCorresLabel();
|
|
|
|
m_pDataProcess->setWinSize(170);
|
|
|
|
m_pDataProcess->setWinSize(170);
|
|
|
|
ADModule::instance()->setDataProcessObj(m_pDataProcess);
|
|
|
|
//ADModule::instance()->setDataProcessObj(m_pDataProcess);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@ -67,12 +61,13 @@ SmokeBoxIdentification::SmokeBoxIdentification(QWidget *parent)
|
|
|
|
, &lpSerialStation::onStartEmptyPlaceCheck);
|
|
|
|
, &lpSerialStation::onStartEmptyPlaceCheck);
|
|
|
|
connect(this, &SmokeBoxIdentification::sgStopEmptyPlaceCheck, lpSerialStation::instance()
|
|
|
|
connect(this, &SmokeBoxIdentification::sgStopEmptyPlaceCheck, lpSerialStation::instance()
|
|
|
|
, &lpSerialStation::onStopEmptyPlaceCheck);
|
|
|
|
, &lpSerialStation::onStopEmptyPlaceCheck);
|
|
|
|
connect(this, &SmokeBoxIdentification::sgMonitorSensorTriggerStart, ADModule::instance()
|
|
|
|
connect(this, &SmokeBoxIdentification::sgNumDataCollectStart, ADModule::instance()
|
|
|
|
, &ADModule::onDataRequestStart);
|
|
|
|
, &ADModule::onDataRequestStart);
|
|
|
|
connect(this, &SmokeBoxIdentification::sgMonitorSensorTriggerStop, ADModule::instance()
|
|
|
|
connect(this, &SmokeBoxIdentification::sgNumDataCollectStop, ADModule::instance()
|
|
|
|
, &ADModule::onDataRequestStop);
|
|
|
|
, &ADModule::onDataRequestStop);
|
|
|
|
connect(this, &SmokeBoxIdentification::sgSendData2AndAlgo, ADModule::instance(), &ADModule::onSendData2Algo);
|
|
|
|
connect(ADModule::instance(), &ADModule::sgNewNumData, this, &SmokeBoxIdentification::onNewNumData);
|
|
|
|
connect(this, &SmokeBoxIdentification::sgSaveSensorData2Local, ADModule::instance(), &ADModule::onSaveData2File);
|
|
|
|
//connect(this, &SmokeBoxIdentification::sgSendData2AndAlgo, ADModule::instance(), &ADModule::onSendData2Algo);
|
|
|
|
|
|
|
|
//connect(this, &SmokeBoxIdentification::sgSaveSensorData2Local, ADModule::instance(), &ADModule::onSaveData2File);
|
|
|
|
connect(this, &SmokeBoxIdentification::sgSendStockCheckMsg, this, &SmokeBoxIdentification::onSendStockCheckResults, Qt::QueuedConnection);
|
|
|
|
connect(this, &SmokeBoxIdentification::sgSendStockCheckMsg, this, &SmokeBoxIdentification::onSendStockCheckResults, Qt::QueuedConnection);
|
|
|
|
connect(ui.action_templateNum, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
connect(ui.action_templateNum, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
emit sgControlSideLight(lightCtrl::emTurnOnLight);
|
|
|
|
emit sgControlSideLight(lightCtrl::emTurnOnLight);
|
|
|
|
@ -82,160 +77,9 @@ SmokeBoxIdentification::~SmokeBoxIdentification()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
emit sgControlSideLight(lightCtrl::emTurnOffLight);
|
|
|
|
emit sgControlSideLight(lightCtrl::emTurnOffLight);
|
|
|
|
DELETE_POINTER(m_pNetControl);
|
|
|
|
DELETE_POINTER(m_pNetControl);
|
|
|
|
//m_pCaptureThread->quit();
|
|
|
|
|
|
|
|
//m_pCaptureThread->wait();
|
|
|
|
|
|
|
|
//DELETE_POINTER(m_pCaptureThread);
|
|
|
|
|
|
|
|
//DELETE_POINTER(m_pCameraControl);
|
|
|
|
|
|
|
|
DELETE_POINTER(m_pCategoryMatcher);
|
|
|
|
DELETE_POINTER(m_pCategoryMatcher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//bool SmokeBoxIdentification::readCameraConfig()
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// m_mapIdCameraInfoSide.clear();
|
|
|
|
|
|
|
|
// m_mapIdCameraInfoTop.clear();
|
|
|
|
|
|
|
|
// m_mapSerialNumberIdSide.clear();
|
|
|
|
|
|
|
|
// m_mapSerialNumberIdTop.clear();
|
|
|
|
|
|
|
|
// QString filePath = QCoreApplication::applicationDirPath() + CAMERA_CONFIG;
|
|
|
|
|
|
|
|
// QFile file(filePath);
|
|
|
|
|
|
|
|
// if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// qWarning() << "打开文件失败!";
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// QByteArray arr = file.readAll();
|
|
|
|
|
|
|
|
// file.close();
|
|
|
|
|
|
|
|
// if (arr.isEmpty())
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// qWarning() << "内容为空";
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// QJsonParseError err;
|
|
|
|
|
|
|
|
// QJsonDocument doc = QJsonDocument::fromJson(arr, &err);
|
|
|
|
|
|
|
|
// if (doc.isEmpty())
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// qWarning() << err.errorString(); //打印失败信息
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// QJsonObject jsonObj = doc.object();
|
|
|
|
|
|
|
|
// auto getCameraType = [](int type)-> CameraType
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// CameraType cameraType;
|
|
|
|
|
|
|
|
// switch (type)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// case 100:
|
|
|
|
|
|
|
|
// cameraType = CameraType::Virtual;
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// case 140:
|
|
|
|
|
|
|
|
// cameraType = CameraType::Hik;
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// case 190:
|
|
|
|
|
|
|
|
// cameraType = CameraType::Basler;
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// default:
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return cameraType;
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// QJsonObject topObj = jsonObj.value("top").toObject();
|
|
|
|
|
|
|
|
// int topStartId, topEndId;
|
|
|
|
|
|
|
|
// if (!topObj.isEmpty())
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// topStartId = topObj.value("startID").toInt();
|
|
|
|
|
|
|
|
// topEndId = topObj.value("endID").toInt();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// qWarning() << "top id error";
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// QJsonObject sideObj = jsonObj.value("side").toObject();
|
|
|
|
|
|
|
|
// int sideStartId, sideEndId;
|
|
|
|
|
|
|
|
// if (!sideObj.isEmpty())
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// sideStartId = sideObj.value("startID").toInt();
|
|
|
|
|
|
|
|
// sideEndId = sideObj.value("endID").toInt();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// qWarning() << "side id error";
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// QJsonObject devicesObj = jsonObj.value("devices").toObject();
|
|
|
|
|
|
|
|
// if (!devicesObj.isEmpty()) {
|
|
|
|
|
|
|
|
// CameraInfo cameraInfo;
|
|
|
|
|
|
|
|
// QStringList devicesLabelList = devicesObj.keys();
|
|
|
|
|
|
|
|
// for each (QString deviceLabel in devicesLabelList)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// cameraInfo.cameraLabel = deviceLabel;
|
|
|
|
|
|
|
|
// QStringList strList = deviceLabel.split(' ');
|
|
|
|
|
|
|
|
// if (strList.length() != 2)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// qWarning() << "Device label: " << deviceLabel << " syntax error!";
|
|
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// cameraInfo.modelName = strList.at(0);
|
|
|
|
|
|
|
|
// cameraInfo.serialNumber = strList.at(1);
|
|
|
|
|
|
|
|
// QJsonObject deviceObj = devicesObj.value(deviceLabel).toObject();
|
|
|
|
|
|
|
|
// if (!deviceObj.isEmpty())
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// cameraInfo.cameraType = getCameraType(deviceObj.value("type").toInt());
|
|
|
|
|
|
|
|
// cameraInfo.exposure = deviceObj.value("exposure").toDouble();
|
|
|
|
|
|
|
|
// cameraInfo.imageHeight = deviceObj.value("height").toInt();
|
|
|
|
|
|
|
|
// cameraInfo.imageWidth = deviceObj.value("width").toInt();
|
|
|
|
|
|
|
|
// cameraInfo.saveImgSuffix = deviceObj.value("save_img_suffix").toString();
|
|
|
|
|
|
|
|
// int id = deviceObj.value("id").toInt();
|
|
|
|
|
|
|
|
// if (id >= topStartId && id <= topEndId)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// m_mapIdCameraInfoTop[id] = cameraInfo;
|
|
|
|
|
|
|
|
// m_mapSerialNumberIdTop[cameraInfo.serialNumber] = id;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else if (id >= sideStartId && id <= sideEndId)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// m_mapIdCameraInfoSide[id] = cameraInfo;
|
|
|
|
|
|
|
|
// m_mapSerialNumberIdSide[cameraInfo.serialNumber] = id;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//bool SmokeBoxIdentification::initCamera()
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// QList<CameraInfo> cameraInfoList = m_mapIdCameraInfoSide.values();
|
|
|
|
|
|
|
|
// cameraInfoList.append(m_mapIdCameraInfoTop.values());
|
|
|
|
|
|
|
|
// if (!m_pCameraControl->loadCamera(cameraInfoList))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// qWarning() << "Load camera failed";
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else {
|
|
|
|
|
|
|
|
// QStringList serialNumberList = m_mapSerialNumberIdSide.keys();
|
|
|
|
|
|
|
|
// serialNumberList.append(m_mapSerialNumberIdTop.keys());
|
|
|
|
|
|
|
|
// if (!m_pCameraControl->openCamera(serialNumberList))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// qWarning() << "Open camera failed";
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else {
|
|
|
|
|
|
|
|
// if (!m_pCameraControl->startCamera(serialNumberList))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// qWarning() << "Start camera failed";
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else {
|
|
|
|
|
|
|
|
// if (!m_pCameraControl->setSoftwareTrigger(serialNumberList))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// qWarning() << "Set software trigger failed";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void SmokeBoxIdentification::onActionClicked()
|
|
|
|
Q_SLOT void SmokeBoxIdentification::onActionClicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QString strObj = sender()->objectName();
|
|
|
|
QString strObj = sender()->objectName();
|
|
|
|
@ -260,38 +104,6 @@ void SmokeBoxIdentification::captureSide()
|
|
|
|
emit sgCapture(eCameraLocation::emSide);
|
|
|
|
emit sgCapture(eCameraLocation::emSide);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//bool SmokeBoxIdentification::getSaveImgNameInfo(QString serialNumber, FileInfo& fileInfo)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// QString imgSaveBaseName;
|
|
|
|
|
|
|
|
// auto iter = m_mapSerialNumberIdSide.find(serialNumber);
|
|
|
|
|
|
|
|
// if (iter == m_mapSerialNumberIdSide.end())
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// iter = m_mapSerialNumberIdTop.find(serialNumber);
|
|
|
|
|
|
|
|
// if (iter != m_mapSerialNumberIdTop.end())
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// int id = iter.value();
|
|
|
|
|
|
|
|
// QString suffix = m_mapIdCameraInfoTop.value(id).saveImgSuffix;
|
|
|
|
|
|
|
|
// fileInfo.suffix = suffix;
|
|
|
|
|
|
|
|
// fileInfo.baseName = QString::number(id);
|
|
|
|
|
|
|
|
// fileInfo.name = fileInfo.baseName + suffix;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// qWarning() << "Can not find " << serialNumber;
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// int id = iter.value();
|
|
|
|
|
|
|
|
// QString suffix = m_mapIdCameraInfoSide.value(id).saveImgSuffix;
|
|
|
|
|
|
|
|
// fileInfo.suffix = suffix;
|
|
|
|
|
|
|
|
// fileInfo.baseName = QString::number(id);
|
|
|
|
|
|
|
|
// fileInfo.name = fileInfo.baseName + suffix;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SmokeBoxIdentification::saveImage(const cv::Mat& imgMat, const QString& filePath)
|
|
|
|
void SmokeBoxIdentification::saveImage(const cv::Mat& imgMat, const QString& filePath)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (imgMat.empty())
|
|
|
|
if (imgMat.empty())
|
|
|
|
@ -617,29 +429,29 @@ Q_SLOT void SmokeBoxIdentification::onShowImage(QLabel* labelPtr, const QImage&
|
|
|
|
labelPtr->setPixmap(QPixmap::fromImage(imgShow));
|
|
|
|
labelPtr->setPixmap(QPixmap::fromImage(imgShow));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void SmokeBoxIdentification::onMonitorSensorTriggerStart(eSideID sideId)
|
|
|
|
Q_SLOT void SmokeBoxIdentification::onMonitorSensorTriggerStart(int sideId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_workMode == WorkMode::StockCheck)
|
|
|
|
if (m_workMode == WorkMode::StockCheck)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
qDebug() << "start collect data";
|
|
|
|
qDebug() << "start collect data";
|
|
|
|
emit sgMonitorSensorTriggerStart(sideId);
|
|
|
|
emit sgNumDataCollectStart(sideId);
|
|
|
|
m_bDataCollection = true;
|
|
|
|
m_bDataCollection = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void SmokeBoxIdentification::onMonitorSensorTriggerStop(eSideID)
|
|
|
|
Q_SLOT void SmokeBoxIdentification::onMonitorSensorTriggerStop(int sideId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_workMode == WorkMode::StockCheck)
|
|
|
|
if (m_workMode == WorkMode::StockCheck)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
qDebug() << "stop collect data";
|
|
|
|
qDebug() << "stop collect data";
|
|
|
|
emit sgMonitorSensorTriggerStop();
|
|
|
|
emit sgNumDataCollectStop();
|
|
|
|
m_bDataCollection = false;
|
|
|
|
m_bDataCollection = false;
|
|
|
|
emit sgSendData2AndAlgo();
|
|
|
|
//emit sgSendData2AndAlgo();
|
|
|
|
QString dataSaveFolder = QString("%1\\%2\\%3\\%4").arg(FILE_STORAGE_PATH)
|
|
|
|
//QString dataSaveFolder = QString("%1\\%2\\%3\\%4").arg(FILE_STORAGE_PATH)
|
|
|
|
.arg(m_currtStockCheckInfo.stockNum).arg(m_currtStockCheckInfo.taskNum)
|
|
|
|
// .arg(m_currtStockCheckInfo.stockNum).arg(m_currtStockCheckInfo.taskNum)
|
|
|
|
.arg(m_currtStockCheckInfo.smokeQuantity);
|
|
|
|
// .arg(m_currtStockCheckInfo.smokeQuantity);
|
|
|
|
dataPreProcessing::mkDir(dataSaveFolder);
|
|
|
|
//dataPreProcessing::mkDir(dataSaveFolder);
|
|
|
|
emit sgSaveSensorData2Local(dataSaveFolder);
|
|
|
|
//emit sgSaveSensorData2Local(dataSaveFolder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -746,3 +558,63 @@ Q_SLOT void SmokeBoxIdentification::onSendEmptyCheckResults(const QMap<QString,
|
|
|
|
m_pNetControl->sendMsg(emptyResult);
|
|
|
|
m_pNetControl->sendMsg(emptyResult);
|
|
|
|
qDebug() << "send msg: " << emptyResult;
|
|
|
|
qDebug() << "send msg: " << emptyResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void SmokeBoxIdentification::onNewNumData(const QVector<QVector<double>>& vec, const QVector<QString>& strVec, int side)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (vec[0].size() <= 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qWarning() << "signal stopped but i didnt get data";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QString szSide = side == emTopLeft ? "left" : "right";
|
|
|
|
|
|
|
|
m_pDataProcess->sensorValTransformationTemp(vec, szSide);
|
|
|
|
|
|
|
|
QString dataSaveFolder = QString("%1\\%2\\%3\\%4").arg(FILE_STORAGE_PATH)
|
|
|
|
|
|
|
|
.arg(m_currtStockCheckInfo.stockNum).arg(m_currtStockCheckInfo.taskNum)
|
|
|
|
|
|
|
|
.arg(m_currtStockCheckInfo.smokeQuantity);
|
|
|
|
|
|
|
|
dataPreProcessing::mkDir(dataSaveFolder);
|
|
|
|
|
|
|
|
saveData2File(strVec, dataSaveFolder, side);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SmokeBoxIdentification::saveData2File(const QVector<QString>& strVec, QString folderPath, int side)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!QDir(folderPath).exists())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qWarning() << folderPath << " is not exist";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString timeStr = QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss");
|
|
|
|
|
|
|
|
if (strVec.size() <= 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qWarning() << "sensor raw data is empty";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto savefile = [&](const QString& path, QVector<QString>& vec)->bool
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ofstream mfile;
|
|
|
|
|
|
|
|
mfile.open(path.toStdString(), std::ios::out | std::ios::app | std::ios::ate);
|
|
|
|
|
|
|
|
if (!mfile.is_open()) return false;
|
|
|
|
|
|
|
|
for (int i = 0; i < vec.size(); ++i)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const QString& ls = vec[i];
|
|
|
|
|
|
|
|
std::string ss = ls.toStdString() + "\n";
|
|
|
|
|
|
|
|
//std::string ss = ls.toStdString();
|
|
|
|
|
|
|
|
mfile << ss;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
mfile.flush();
|
|
|
|
|
|
|
|
mfile.close();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString strSide = side == emTopLeft ? "left" : "right";
|
|
|
|
|
|
|
|
QString filePath = QString("%1\\%2_%3.txt").arg(folderPath).arg(timeStr).arg(strSide);
|
|
|
|
|
|
|
|
qDebug() << "find path" << filePath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strVec.size() >= mimumDataSize)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QVector<QString> vec;
|
|
|
|
|
|
|
|
m_pDataProcess->sensorValTransformationTemp(strVec, vec, strSide);
|
|
|
|
|
|
|
|
savefile(filePath, vec);
|
|
|
|
|
|
|
|
qDebug() << "save " << strSide << " data to txt successfully";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|