add,计划采集15:
优化定时采集:界面和模型
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,6 +8,7 @@ HPPA - 副本.ui
|
|||||||
icon
|
icon
|
||||||
ignore_*
|
ignore_*
|
||||||
resources
|
resources
|
||||||
|
*.bkp
|
||||||
|
|
||||||
## Ignore Visual Studio temporary files, build results, and
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
## files generated by popular Visual Studio add-ons.
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|||||||
@ -593,26 +593,35 @@ HPPA::HPPA(QWidget* parent)
|
|||||||
|
|
||||||
void HPPA::initTimedDataCollection()
|
void HPPA::initTimedDataCollection()
|
||||||
{
|
{
|
||||||
TimedDataCollection mTimedDataCollectionWindow;
|
if (m_tdc)
|
||||||
|
{
|
||||||
|
m_tdc->show();
|
||||||
|
m_tdc->activateWindow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_tmc->onConnectMotor();
|
m_tdc = new TimedDataCollection(this);
|
||||||
|
|
||||||
|
m_tdc->setWindowFlags(m_tdc->windowFlags() | Qt::Tool);
|
||||||
|
m_tdc->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
|
m_tmc->connectMotor(false);
|
||||||
|
|
||||||
// 定时采集控制器 → 相机/马达
|
// 定时采集控制器 → 相机/马达
|
||||||
connect(&mTimedDataCollectionWindow, &TimedDataCollection::hyperCamParm, this, &HPPA::setTimedDataCollectionHyperCamParm);
|
connect(m_tdc, &TimedDataCollection::hyperCamParm, this, &HPPA::setTimedDataCollectionHyperCamParm);
|
||||||
connect(&mTimedDataCollectionWindow, &TimedDataCollection::camParm, this, &HPPA::setTimedDataCollectionCamParm);
|
connect(m_tdc, &TimedDataCollection::camParm, this, &HPPA::setTimedDataCollectionCamParm);
|
||||||
connect(&mTimedDataCollectionWindow, &TimedDataCollection::motorParm, this, &HPPA::setTimedDataCollectionMotorParm);
|
connect(m_tdc, &TimedDataCollection::motorParm, this, &HPPA::setTimedDataCollectionMotorParm);
|
||||||
connect(&mTimedDataCollectionWindow, &TimedDataCollection::startRecordSignal, this, &HPPA::onStartTimedDataCollection);
|
connect(m_tdc, &TimedDataCollection::startRecordSignal, this, &HPPA::onStartTimedDataCollection);
|
||||||
|
|
||||||
connect(&mTimedDataCollectionWindow, &TimedDataCollection::switchHalogenLampSignal, m_pc3D, &PowerControl3D::switchHalogenLampPower);
|
connect(m_tdc, &TimedDataCollection::switchHalogenLampSignal, m_pc3D, &PowerControl3D::switchHalogenLampPower);
|
||||||
connect(&mTimedDataCollectionWindow, &TimedDataCollection::switchD65LampSignal, m_pc3D, &PowerControl3D::switchD65LampPower);
|
connect(m_tdc, &TimedDataCollection::switchD65LampSignal, m_pc3D, &PowerControl3D::switchD65LampPower);
|
||||||
connect(&mTimedDataCollectionWindow, &TimedDataCollection::switchSlrSignal, m_pc3D, &PowerControl3D::switchSlrPower);
|
connect(m_tdc, &TimedDataCollection::switchSlrSignal, m_pc3D, &PowerControl3D::switchSlrPower);
|
||||||
|
|
||||||
// 相机/马达 → 定时采集控制器
|
// 相机/马达 → 定时采集控制器
|
||||||
connect(m_tmc, &TwoMotorControl::sequenceComplete, &mTimedDataCollectionWindow, &TimedDataCollection::subTaskCompleted);
|
connect(m_tmc, &TwoMotorControl::sequenceComplete, m_tdc, &TimedDataCollection::subTaskCompleted);
|
||||||
connect(m_tmc, &TwoMotorControl::back2OriginSignal_TimedDataCollection, &mTimedDataCollectionWindow, &TimedDataCollection::onBack2Origin);
|
connect(m_tmc, &TwoMotorControl::back2OriginSignal_TimedDataCollection, m_tdc, &TimedDataCollection::onBack2Origin);
|
||||||
|
|
||||||
mTimedDataCollectionWindow.show();
|
m_tdc->show();
|
||||||
mTimedDataCollectionWindow.exec();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HPPA::setTimedDataCollectionHyperCamParm(int camType, double f, double e, QString filePath, QString fileName)
|
void HPPA::setTimedDataCollectionHyperCamParm(int camType, double f, double e, QString filePath, QString fileName)
|
||||||
@ -1709,7 +1718,7 @@ void HPPA::onStartRecordStep1()
|
|||||||
//判断光谱仪
|
//判断光谱仪
|
||||||
if(!testImagerVality())
|
if(!testImagerVality())
|
||||||
{
|
{
|
||||||
showMessageBox(QString::fromLocal8Bit("找不到光谱仪!"));
|
showMessageBox(QString::fromLocal8Bit("找不到高光谱仪!"));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2275,7 +2284,7 @@ void HPPA::onconnect()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool res = showResultMessageBox(QString::fromLocal8Bit("相机连接"), QString::fromLocal8Bit("确定要重连相机吗?"));
|
bool res = showResultMessageBox(QString::fromLocal8Bit("高光谱仪连接"), QString::fromLocal8Bit("确定要重连高光谱仪吗?"));
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
disconnectImagerAndCleanup();
|
disconnectImagerAndCleanup();
|
||||||
@ -2311,7 +2320,7 @@ void HPPA::onconnect()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
showMessageBox(QString::fromLocal8Bit("请选择相机类型!"));
|
showMessageBox(QString::fromLocal8Bit("请选择高光谱仪类型!"));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2392,7 +2401,7 @@ void HPPA::onconnect()
|
|||||||
delete m_Imager;
|
delete m_Imager;
|
||||||
m_Imager = nullptr;
|
m_Imager = nullptr;
|
||||||
|
|
||||||
showMessageBox(QString::fromLocal8Bit("请连接相机!"));
|
showMessageBox(QString::fromLocal8Bit("请连接高光谱仪!"));
|
||||||
}
|
}
|
||||||
catch (int e)//ximea相机异常
|
catch (int e)//ximea相机异常
|
||||||
{
|
{
|
||||||
@ -2401,7 +2410,7 @@ void HPPA::onconnect()
|
|||||||
delete m_Imager;
|
delete m_Imager;
|
||||||
m_Imager = nullptr;
|
m_Imager = nullptr;
|
||||||
|
|
||||||
showMessageBox(QString::fromLocal8Bit("请连接相机!"));
|
showMessageBox(QString::fromLocal8Bit("请连接高光谱仪!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
#include <QChart>
|
#include <QChart>
|
||||||
#include <QChartView>
|
#include <QChartView>
|
||||||
#include <QValueAxis>
|
#include <QValueAxis>
|
||||||
|
#include <QPointer>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
@ -296,6 +297,7 @@ private:
|
|||||||
RobotArmControl* m_rac;
|
RobotArmControl* m_rac;
|
||||||
OneMotorControl* m_omc;
|
OneMotorControl* m_omc;
|
||||||
TwoMotorControl* m_tmc;
|
TwoMotorControl* m_tmc;
|
||||||
|
QPointer<TimedDataCollection> m_tdc;
|
||||||
|
|
||||||
View3DModelManager* m_view3DModelManager;
|
View3DModelManager* m_view3DModelManager;
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ TaskTreeNode::TaskTreeNode(TaskTreeNode* parent)
|
|||||||
TaskTreeNode::~TaskTreeNode()
|
TaskTreeNode::~TaskTreeNode()
|
||||||
{
|
{
|
||||||
qDeleteAll(m_children);
|
qDeleteAll(m_children);
|
||||||
|
m_children.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskTreeNode::appendChild(TaskTreeNode* child)
|
void TaskTreeNode::appendChild(TaskTreeNode* child)
|
||||||
@ -20,6 +21,13 @@ void TaskTreeNode::appendChild(TaskTreeNode* child)
|
|||||||
m_children.append(child);
|
m_children.append(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TaskTreeNode::removeChild(int index)
|
||||||
|
{
|
||||||
|
if (index < 0 || index >= m_children.size())
|
||||||
|
return;
|
||||||
|
delete m_children.takeAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
TaskTreeNode* TaskTreeNode::child(int row)
|
TaskTreeNode* TaskTreeNode::child(int row)
|
||||||
{
|
{
|
||||||
if (row < 0 || row >= m_children.size())
|
if (row < 0 || row >= m_children.size())
|
||||||
@ -352,7 +360,8 @@ void TaskTreeModel::clearTree()
|
|||||||
{
|
{
|
||||||
// 删除所有子节点
|
// 删除所有子节点
|
||||||
while (m_rootNode->childCount() > 0) {
|
while (m_rootNode->childCount() > 0) {
|
||||||
delete m_rootNode->child(0);
|
//delete m_rootNode->child(0);
|
||||||
|
m_rootNode->removeChild(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,7 @@ public:
|
|||||||
~TaskTreeNode();
|
~TaskTreeNode();
|
||||||
|
|
||||||
void appendChild(TaskTreeNode* child);
|
void appendChild(TaskTreeNode* child);
|
||||||
|
void removeChild(int index);
|
||||||
TaskTreeNode* child(int row);
|
TaskTreeNode* child(int row);
|
||||||
int childCount() const;
|
int childCount() const;
|
||||||
int row() const;
|
int row() const;
|
||||||
|
|||||||
@ -17,8 +17,22 @@ TimedDataCollection::TimedDataCollection(QWidget* parent)
|
|||||||
|
|
||||||
setupConnections();
|
setupConnections();
|
||||||
|
|
||||||
// 读取任务文件
|
// 连接按钮信号
|
||||||
readTimedTaskFromFile("D:/0tmp/3Dtest/task.json");
|
connect(ui.start_btn, &QPushButton::clicked, this, &TimedDataCollection::startScheduler);
|
||||||
|
connect(ui.stop_btn, &QPushButton::clicked, this, &TimedDataCollection::stopScheduler);
|
||||||
|
|
||||||
|
connect(ui.expandAll_btn, &QPushButton::clicked, ui.taskTreeView, &QTreeView::expandAll);
|
||||||
|
connect(ui.collapseAll_btn, &QPushButton::clicked, ui.taskTreeView, &QTreeView::collapseAll);
|
||||||
|
|
||||||
|
connect(ui.taskFileSelect_btn, &QPushButton::clicked, this, &TimedDataCollection::onSelectTaskFile);
|
||||||
|
|
||||||
|
// 树视图交互信号
|
||||||
|
connect(ui.taskTreeView, &QTreeView::clicked,
|
||||||
|
this, &TimedDataCollection::onTreeItemClicked);
|
||||||
|
connect(ui.taskTreeView, &QTreeView::doubleClicked,
|
||||||
|
this, &TimedDataCollection::onTreeItemDoubleClicked);
|
||||||
|
connect(ui.taskTreeView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||||
|
this, &TimedDataCollection::onTreeSelectionChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimedDataCollection::setupUI()
|
void TimedDataCollection::setupUI()
|
||||||
@ -70,23 +84,6 @@ void TimedDataCollection::setupUI()
|
|||||||
" font-size: 12px;"
|
" font-size: 12px;"
|
||||||
"}"
|
"}"
|
||||||
);
|
);
|
||||||
|
|
||||||
// 连接按钮信号
|
|
||||||
connect(ui.start_btn, &QPushButton::clicked, this, &TimedDataCollection::startScheduler);
|
|
||||||
connect(ui.stop_btn, &QPushButton::clicked, this, &TimedDataCollection::stopScheduler);
|
|
||||||
connect(ui.refresh_btn, &QPushButton::clicked, this, [this]() {
|
|
||||||
readTimedTaskFromFile("D:/0tmp/3Dtest/task.json");
|
|
||||||
});
|
|
||||||
connect(ui.expandAll_btn, &QPushButton::clicked, ui.taskTreeView, &QTreeView::expandAll);
|
|
||||||
connect(ui.collapseAll_btn, &QPushButton::clicked, ui.taskTreeView, &QTreeView::collapseAll);
|
|
||||||
|
|
||||||
// 树视图交互信号
|
|
||||||
connect(ui.taskTreeView, &QTreeView::clicked,
|
|
||||||
this, &TimedDataCollection::onTreeItemClicked);
|
|
||||||
connect(ui.taskTreeView, &QTreeView::doubleClicked,
|
|
||||||
this, &TimedDataCollection::onTreeItemDoubleClicked);
|
|
||||||
connect(ui.taskTreeView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
|
||||||
this, &TimedDataCollection::onTreeSelectionChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimedDataCollection::setupConnections()
|
void TimedDataCollection::setupConnections()
|
||||||
@ -135,6 +132,26 @@ TimedDataCollection::~TimedDataCollection()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TimedDataCollection::onSelectTaskFile()
|
||||||
|
{
|
||||||
|
if (m_scheduler->isRunning())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString filePath = QFileDialog::getOpenFileName(this,
|
||||||
|
tr("Select Task File"),
|
||||||
|
QString(),
|
||||||
|
tr("JSON Files (*.json);;All Files (*)"));
|
||||||
|
|
||||||
|
if (filePath.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.taskFileSelect_lineEdit->setText(filePath);
|
||||||
|
readTimedTaskFromFile(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== 任务状态更新槽实现 ====================
|
// ==================== 任务状态更新槽实现 ====================
|
||||||
|
|
||||||
void TimedDataCollection::onTaskStarted(int taskId)
|
void TimedDataCollection::onTaskStarted(int taskId)
|
||||||
@ -142,8 +159,6 @@ void TimedDataCollection::onTaskStarted(int taskId)
|
|||||||
m_currentTaskId = taskId;
|
m_currentTaskId = taskId;
|
||||||
m_currentSubTaskIndex = -1;
|
m_currentSubTaskIndex = -1;
|
||||||
|
|
||||||
m_taskModel->updateTaskStatus(taskId, TaskStatus::Running);
|
|
||||||
|
|
||||||
// 展开当前运行的任务
|
// 展开当前运行的任务
|
||||||
expandRunningTask();
|
expandRunningTask();
|
||||||
|
|
||||||
@ -153,9 +168,6 @@ void TimedDataCollection::onTaskStarted(int taskId)
|
|||||||
|
|
||||||
void TimedDataCollection::onTaskFinished(int taskId, bool success)
|
void TimedDataCollection::onTaskFinished(int taskId, bool success)
|
||||||
{
|
{
|
||||||
TaskStatus status = success ? TaskStatus::Finished : TaskStatus::Skiped;
|
|
||||||
m_taskModel->updateTaskStatus(taskId, status);
|
|
||||||
|
|
||||||
if (m_currentTaskId == taskId) {
|
if (m_currentTaskId == taskId) {
|
||||||
m_currentTaskId = -1;
|
m_currentTaskId = -1;
|
||||||
m_currentSubTaskIndex = -1;
|
m_currentSubTaskIndex = -1;
|
||||||
@ -169,7 +181,7 @@ void TimedDataCollection::onSubTaskStarted(int taskId, int subTaskIndex)
|
|||||||
{
|
{
|
||||||
m_currentSubTaskIndex = subTaskIndex;
|
m_currentSubTaskIndex = subTaskIndex;
|
||||||
|
|
||||||
m_taskModel->updateSubTaskStatusAndProgress(taskId, subTaskIndex, TaskStatus::Running);
|
m_taskModel->updateProgress(taskId);
|
||||||
|
|
||||||
// 滚动到当前子任务
|
// 滚动到当前子任务
|
||||||
QModelIndex subTaskIndex_model = m_taskModel->getSubTaskIndex(taskId, subTaskIndex);
|
QModelIndex subTaskIndex_model = m_taskModel->getSubTaskIndex(taskId, subTaskIndex);
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QFileDialog>
|
||||||
#include "ui_TimedDataCollection_ui.h"
|
#include "ui_TimedDataCollection_ui.h"
|
||||||
#include "TimedDataCollectionDataStructures.h"
|
#include "TimedDataCollectionDataStructures.h"
|
||||||
#include "TaskTreeModel.h"
|
#include "TaskTreeModel.h"
|
||||||
@ -64,6 +65,8 @@ private:
|
|||||||
void updateStatusBar();
|
void updateStatusBar();
|
||||||
void expandRunningTask();
|
void expandRunningTask();
|
||||||
|
|
||||||
|
void onSelectTaskFile();
|
||||||
|
|
||||||
Ui::TimedDataCollection_ui ui;
|
Ui::TimedDataCollection_ui ui;
|
||||||
|
|
||||||
TaskTreeModel* m_taskModel; // 任务树形模型
|
TaskTreeModel* m_taskModel; // 任务树形模型
|
||||||
|
|||||||
@ -6,19 +6,23 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1008</width>
|
<width>1182</width>
|
||||||
<height>576</height>
|
<height>576</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>定时采集</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0" colspan="3">
|
<item row="0" column="0" colspan="3">
|
||||||
<widget class="QTreeView" name="taskTreeView"/>
|
<widget class="QTreeView" name="taskTreeView"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLineEdit" name="taskFileSelect_lineEdit"/>
|
<widget class="QLineEdit" name="taskFileSelect_lineEdit">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QPushButton" name="taskFileSelect_btn">
|
<widget class="QPushButton" name="taskFileSelect_btn">
|
||||||
@ -27,13 +31,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
|
||||||
<widget class="QPushButton" name="refresh_btn">
|
|
||||||
<property name="text">
|
|
||||||
<string>刷新</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QPushButton" name="start_btn">
|
<widget class="QPushButton" name="start_btn">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|||||||
@ -292,12 +292,21 @@ TwoMotorControl::~TwoMotorControl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TwoMotorControl::onConnectMotor()
|
void TwoMotorControl::onConnectMotor()
|
||||||
|
{
|
||||||
|
connectMotor(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TwoMotorControl::connectMotor(bool isNotification)
|
||||||
{
|
{
|
||||||
if (getMotorsConnectionStatus())
|
if (getMotorsConnectionStatus())
|
||||||
{
|
{
|
||||||
QMessageBox msgBox;
|
if (isNotification)
|
||||||
msgBox.setText(QString::fromLocal8Bit("马达已连接!"));
|
{
|
||||||
msgBox.exec();
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText(QString::fromLocal8Bit("马达已连接!"));
|
||||||
|
msgBox.exec();
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,8 @@ public:
|
|||||||
bool getMotorsConnectionStatus();
|
bool getMotorsConnectionStatus();
|
||||||
|
|
||||||
void readRecordLineFile(QString RecordLineFilePath);
|
void readRecordLineFile(QString RecordLineFilePath);
|
||||||
|
|
||||||
|
void connectMotor(bool isNotification);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ImagerOperationBase* m_Imager;
|
ImagerOperationBase* m_Imager;
|
||||||
|
|||||||
Reference in New Issue
Block a user