Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
20848bef1a | |||
f6138dd2ed |
320
HPPA/HPPA.cpp
320
HPPA/HPPA.cpp
@ -267,7 +267,8 @@ HPPA::HPPA(QWidget *parent)
|
||||
//<2F>켣<EFBFBD>滮
|
||||
m_pathPlan = new PathPlan(m_xMotor, m_yMotor, ui.xmotor_location_slider, ui.ymotor_location_slider);
|
||||
QDockWidget* dock_pathPlan = new QDockWidget(QString::fromLocal8Bit("<EFBFBD>켣<EFBFBD>滮"), this);
|
||||
dock_pathPlan->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
dock_pathPlan->setObjectName("mDockPathPlan");
|
||||
dock_pathPlan->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
|
||||
dock_pathPlan->setWidget(m_pathPlan);
|
||||
tabifyDockWidget(ui.mDockWidgetLinearStage, dock_pathPlan);
|
||||
mPanelMenu->addAction(dock_pathPlan->toggleViewAction());
|
||||
@ -276,6 +277,7 @@ HPPA::HPPA(QWidget *parent)
|
||||
adjustTable* adt = new adjustTable();
|
||||
|
||||
QDockWidget* dock_adt = new QDockWidget(QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), this);
|
||||
dock_adt->setObjectName("mDockAdjustTable");
|
||||
dock_adt->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
dock_adt->setWidget(adt);
|
||||
tabifyDockWidget(dock_pathPlan, dock_adt);
|
||||
@ -285,6 +287,7 @@ HPPA::HPPA(QWidget *parent)
|
||||
PowerControl* pc = new PowerControl();
|
||||
|
||||
QDockWidget* dock_pc = new QDockWidget(QString::fromLocal8Bit("<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), this);
|
||||
dock_pc->setObjectName("mDockPowerControl");
|
||||
dock_pc->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
dock_pc->setWidget(pc);
|
||||
tabifyDockWidget(dock_adt, dock_pc);
|
||||
@ -292,20 +295,50 @@ HPPA::HPPA(QWidget *parent)
|
||||
connect(pc, &PowerControl::powerOpened, this, &HPPA::newMotor);
|
||||
connect(pc, &PowerControl::powerClosed, this, &HPPA::deleteMotor);
|
||||
|
||||
//<2F><>е<EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD>
|
||||
rac = new RobotArmControl();
|
||||
connect(rac->robotController, SIGNAL(hsiRecordSignal(int)), this, SLOT(recordFromRobotArm(int)));
|
||||
QDockWidget* dock_rac = new QDockWidget(QString::fromLocal8Bit("<EFBFBD><EFBFBD>е<EFBFBD>ۿ<EFBFBD><EFBFBD><EFBFBD>"), this);
|
||||
dock_rac->setObjectName("mDockRobotArmControl");
|
||||
dock_rac->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
dock_rac->setWidget(rac);
|
||||
tabifyDockWidget(dock_adt, dock_rac);
|
||||
mPanelMenu->addAction(dock_rac->toggleViewAction());
|
||||
|
||||
createActionGroups();
|
||||
connect(mImagerGroup, &QActionGroup::triggered, this, &HPPA::selectingImager);
|
||||
|
||||
connect(this->ui.mAction_is_motor_enable, SIGNAL(triggered()), this, SLOT(onMotorSwitch()));
|
||||
QSettings settings;
|
||||
bool isMotorEnable = settings.value("isMotorEnable").toBool();
|
||||
this->ui.mAction_is_motor_enable->setChecked(isMotorEnable);
|
||||
createMoveplatformActionGroup();
|
||||
connect(moveplatformActionGroup, &QActionGroup::triggered, this, &HPPA::selectingMoveplatform);
|
||||
}
|
||||
|
||||
void HPPA::onMotorSwitch()
|
||||
void HPPA::recordFromRobotArm(int fileCounter)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("isMotorEnable", this->ui.mAction_is_motor_enable->isChecked());
|
||||
settings.sync();
|
||||
qDebug() << "recordFromRobotArm" << fileCounter;
|
||||
|
||||
if (fileCounter == -1)
|
||||
{
|
||||
m_Imager->setRecordControlState(false);
|
||||
|
||||
ui.action_start_recording->setText(QString::fromLocal8Bit("<EFBFBD>ɼ<EFBFBD>"));
|
||||
ui.mainToolBar->widgetForAction(ui.action_start_recording)->setStyleSheet("QWidget{background-color:rgb(0,255,0);}");
|
||||
qDebug() << "recordFromRobotArm: 1111111111111111111111";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (fileCounter - 1 == 0)
|
||||
{
|
||||
ui.ImageViewerTabWidget->clear();
|
||||
}
|
||||
|
||||
onCreateTab(fileCounter-1);
|
||||
m_numberOfRecording = fileCounter - 1;
|
||||
emit StartRecordSignal();
|
||||
|
||||
ui.action_start_recording->setText(QString::fromLocal8Bit("<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>"));
|
||||
ui.mainToolBar->widgetForAction(ui.action_start_recording)->setStyleSheet("QWidget{background-color:rgb(255,0,0);}");
|
||||
qDebug() << "recordFromRobotArm: 2222222222222222222222";
|
||||
}
|
||||
|
||||
void HPPA::createActionGroups()
|
||||
@ -349,6 +382,39 @@ void HPPA::selectingImager(QAction* selectedAction)
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
void HPPA::createMoveplatformActionGroup()
|
||||
{
|
||||
moveplatformActionGroup = new QActionGroup(this);
|
||||
moveplatformActionGroup->addAction(ui.mAction_is_no_motor);
|
||||
moveplatformActionGroup->addAction(ui.mAction_2AxisMotor);
|
||||
moveplatformActionGroup->addAction(ui.mAction_RobotArm);
|
||||
|
||||
// <20><>ȡ<EFBFBD>ϴ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>
|
||||
QSettings settings;
|
||||
QString lastSelectedAction = settings.value("LastSelectedMoveplatform").toString();
|
||||
|
||||
// <20>ָ<EFBFBD><D6B8>ϴ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>
|
||||
if (lastSelectedAction == "mAction_is_no_motor")
|
||||
{
|
||||
ui.mAction_is_no_motor->setChecked(true);
|
||||
}
|
||||
else if (lastSelectedAction == "mAction_2AxisMotor")
|
||||
{
|
||||
ui.mAction_2AxisMotor->setChecked(true);
|
||||
}
|
||||
else if (lastSelectedAction == "mAction_RobotArm")
|
||||
{
|
||||
ui.mAction_RobotArm->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void HPPA::selectingMoveplatform(QAction* selectedAction)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("LastSelectedMoveplatform", selectedAction->objectName());
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
HPPA::~HPPA()
|
||||
{
|
||||
QString strPath = QCoreApplication::applicationDirPath() + "/UILayout.ini";
|
||||
@ -412,40 +478,52 @@ void HPPA::CalculateIntegratioinTimeRange()
|
||||
|
||||
void HPPA::onStartRecordStep1()
|
||||
{
|
||||
bool isMotorEnable = this->ui.mAction_is_motor_enable->isChecked();
|
||||
if (!isMotorEnable)//ͣ<><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFA3AC><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
QAction* checked = moveplatformActionGroup->checkedAction();
|
||||
if (!checked)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>ɨ<EFBFBD><EFBFBD>ƽ̨<EFBFBD><EFBFBD>"));
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
//<2F>ж<EFBFBD><D0B6>ǷǴ<F1B8B2B8><C7B4>ڵ<EFBFBD><DAB5>ļ<EFBFBD>
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryFromString();
|
||||
//string imgPath = directory + "\\tmp_image";
|
||||
string imgPath = directory + "\\" + m_FilenameLineEdit->text().toStdString();
|
||||
int x = _access(imgPath.c_str(), 0);
|
||||
if (!x)//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ھ<EFBFBD>ִ<EFBFBD>д<EFBFBD>if<69>Ĵ<EFBFBD><C4B4><EFBFBD>
|
||||
{
|
||||
enum QMessageBox::StandardButton response = QMessageBox::question(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD>Ƿǣ<EFBFBD>"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);;
|
||||
if (response == QMessageBox::Yes)//
|
||||
{
|
||||
//std::cout << "<22><><EFBFBD><EFBFBD>" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
//std::cout << "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
|
||||
//m_RecordState -= 1;//<2F><><EFBFBD><EFBFBD><EFBFBD>ǵĻ<C7B5><C4BB><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_Imager->setFrameNumber(this->frame_number->text().toInt());
|
||||
m_Imager->setFileName2Save(imgPath);
|
||||
|
||||
QString checkedName = checked->objectName();
|
||||
|
||||
if (checkedName == "mAction_is_no_motor")
|
||||
{
|
||||
m_RecordState += 1;
|
||||
|
||||
if (m_RecordState % 2 == 1)
|
||||
{
|
||||
//<2F>ж<EFBFBD><D0B6>ǷǴ<F1B8B2B8><C7B4>ڵ<EFBFBD><DAB5>ļ<EFBFBD>
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryFromString();
|
||||
//string imgPath = directory + "\\tmp_image";
|
||||
string imgPath = directory + "\\" + m_FilenameLineEdit->text().toStdString() + "_" + std::to_string(1) + ".bil";
|
||||
int x = _access(imgPath.c_str(), 0);
|
||||
if (!x)//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ھ<EFBFBD>ִ<EFBFBD>д<EFBFBD>if<69>Ĵ<EFBFBD><C4B4><EFBFBD>
|
||||
{
|
||||
enum QMessageBox::StandardButton response = QMessageBox::question(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD>Ƿǣ<EFBFBD>"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);;
|
||||
if (response == QMessageBox::Yes)//
|
||||
{
|
||||
//std::cout << "<22><><EFBFBD><EFBFBD>" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
//std::cout << "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
|
||||
m_RecordState -= 1;//<2F><><EFBFBD><EFBFBD><EFBFBD>ǵĻ<C7B5><C4BB><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ui.ImageViewerTabWidget->clear();
|
||||
|
||||
onCreateTab(0);
|
||||
m_numberOfRecording = 0;
|
||||
m_Imager->setFrameNumber(this->frame_number->text().toInt());
|
||||
m_Imager->setFileName2Save(imgPath);
|
||||
|
||||
emit StartRecordSignal();//<2F><><EFBFBD>俪ʼ<E4BFAA>ɼ<EFBFBD><C9BC>ź<EFBFBD>
|
||||
|
||||
ui.action_start_recording->setText(QString::fromLocal8Bit("ֹͣ<EFBFBD>ɼ<EFBFBD>"));
|
||||
@ -460,98 +538,84 @@ void HPPA::onStartRecordStep1()
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//ȷ<><C8B7>x<EFBFBD><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> С<><D0A1> x<><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
int validLineCount = 0;
|
||||
for (size_t i = 0; i < m_pathPlan->getRecordLineTableWidget()->rowCount(); i++)
|
||||
else if (checkedName == "mAction_2AxisMotor")
|
||||
{
|
||||
//xx = xx + ui.xmotor_location_slider->value() < m_pathPlan->getRecordLineTableWidget()->item(i, 1)->text().toDouble();
|
||||
|
||||
if (ui.xmotor_location_slider->value() < m_pathPlan->getRecordLineTableWidget()->item(i, 1)->text().toDouble())
|
||||
{
|
||||
validLineCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (validLineCount < m_pathPlan->getRecordLineTableWidget()->rowCount())
|
||||
{
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD>켣x<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
||||
return;
|
||||
}
|
||||
|
||||
//ȷ<><C8B7><EFBFBD>ɼ<EFBFBD><C9BC>ߴ<EFBFBD><DFB4><EFBFBD>
|
||||
if (m_pathPlan->getRecordLineTableWidget()->rowCount() <= 0)
|
||||
{
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ켣<EFBFBD><EFBFBD>"));
|
||||
return;
|
||||
}
|
||||
|
||||
//<2F><>ʼ<EFBFBD>ɼ<EFBFBD>
|
||||
m_RecordState += 1;
|
||||
|
||||
if (m_RecordState % 2 == 1)
|
||||
{
|
||||
//<2F>ж<EFBFBD><D0B6>ǷǴ<F1B8B2B8><C7B4>ڵ<EFBFBD><DAB5>ļ<EFBFBD>
|
||||
FileOperation * fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryFromString();
|
||||
//string imgPath = directory + "\\tmp_image";
|
||||
string imgPath = directory + "\\" + m_FilenameLineEdit->text().toStdString();
|
||||
int x = _access(imgPath.c_str(), 0);
|
||||
if (!x)//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ھ<EFBFBD>ִ<EFBFBD>д<EFBFBD>if<69>Ĵ<EFBFBD><C4B4><EFBFBD>
|
||||
{
|
||||
enum QMessageBox::StandardButton response = QMessageBox::question(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><EFBFBD>Ƿǣ<EFBFBD>"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);;
|
||||
if (response == QMessageBox::Yes)//
|
||||
{
|
||||
//std::cout << "<22><><EFBFBD><EFBFBD>" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
//std::cout << "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" << std::endl;
|
||||
m_RecordState -= 1;//<2F><><EFBFBD><EFBFBD><EFBFBD>ǵĻ<C7B5><C4BB><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
operateWidget = QObject::sender()->objectName();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_Imager->setFileName2Save(imgPath);
|
||||
|
||||
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>tab
|
||||
ui.ImageViewerTabWidget->clear();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼x<C2BC><78><EFBFBD><EFBFBD>λ<EFBFBD>õ<EFBFBD><C3B5>ļ<EFBFBD>
|
||||
string x_location = removeFileExtension(imgPath) + "x_location.pos";
|
||||
m_hTimesFile = fopen(x_location.c_str(), "w+");
|
||||
|
||||
//<2F><>ʼѭ<CABC><D1AD>
|
||||
m_ForLoopControl->setLoopCount(m_pathPlan->getRecordLineTableWidget()->rowCount());//Ϊѭ<CEAA><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
emit StartLoopSignal();
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ɫ
|
||||
//ȷ<EFBFBD><EFBFBD>x<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD> С<><D0A1> x<><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
int validLineCount = 0;
|
||||
for (size_t i = 0; i < m_pathPlan->getRecordLineTableWidget()->rowCount(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < m_pathPlan->getRecordLineTableWidget()->columnCount(); j++)
|
||||
//xx = xx + ui.xmotor_location_slider->value() < m_pathPlan->getRecordLineTableWidget()->item(i, 1)->text().toDouble();
|
||||
|
||||
if (ui.xmotor_location_slider->value() < m_pathPlan->getRecordLineTableWidget()->item(i, 1)->text().toDouble())
|
||||
{
|
||||
m_pathPlan->getRecordLineTableWidget()->item(i, j)->setBackgroundColor(QColor(240, 240, 240));
|
||||
validLineCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ui.action_start_recording->setText(QString::fromLocal8Bit("ֹͣ<EFBFBD>ɼ<EFBFBD>"));
|
||||
ui.mainToolBar->widgetForAction(ui.action_start_recording)->setStyleSheet("QWidget{background-color:rgb(255,0,0);}");
|
||||
if (validLineCount < m_pathPlan->getRecordLineTableWidget()->rowCount())
|
||||
{
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD>켣x<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
||||
return;
|
||||
}
|
||||
|
||||
//ȷ<><C8B7><EFBFBD>ɼ<EFBFBD><C9BC>ߴ<EFBFBD><DFB4><EFBFBD>
|
||||
if (m_pathPlan->getRecordLineTableWidget()->rowCount() <= 0)
|
||||
{
|
||||
QMessageBox::information(this, QString::fromLocal8Bit("<EFBFBD><EFBFBD>ʾ"), QString::fromLocal8Bit("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ켣<EFBFBD><EFBFBD>"));
|
||||
return;
|
||||
}
|
||||
|
||||
//<2F><>ʼ<EFBFBD>ɼ<EFBFBD>
|
||||
m_RecordState += 1;
|
||||
|
||||
if (m_RecordState % 2 == 1)
|
||||
{
|
||||
//
|
||||
operateWidget = QObject::sender()->objectName();
|
||||
|
||||
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>tab
|
||||
ui.ImageViewerTabWidget->clear();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼x<C2BC><78><EFBFBD><EFBFBD>λ<EFBFBD>õ<EFBFBD><C3B5>ļ<EFBFBD>
|
||||
string x_location = removeFileExtension(imgPath) + "x_location.pos";
|
||||
m_hTimesFile = fopen(x_location.c_str(), "w+");
|
||||
|
||||
//<2F><>ʼѭ<CABC><D1AD>
|
||||
m_ForLoopControl->setLoopCount(m_pathPlan->getRecordLineTableWidget()->rowCount());//Ϊѭ<CEAA><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
emit StartLoopSignal();
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ɫ
|
||||
for (size_t i = 0; i < m_pathPlan->getRecordLineTableWidget()->rowCount(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < m_pathPlan->getRecordLineTableWidget()->columnCount(); j++)
|
||||
{
|
||||
m_pathPlan->getRecordLineTableWidget()->item(i, j)->setBackgroundColor(QColor(240, 240, 240));
|
||||
}
|
||||
}
|
||||
|
||||
ui.action_start_recording->setText(QString::fromLocal8Bit("ֹͣ<EFBFBD>ɼ<EFBFBD>"));
|
||||
ui.mainToolBar->widgetForAction(ui.action_start_recording)->setStyleSheet("QWidget{background-color:rgb(255,0,0);}");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Imager->setRecordControlState(false);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
|
||||
m_ForLoopControl->m_boolQuitLoop = true;//ѭ<><D1AD>ֹͣ
|
||||
|
||||
ui.action_start_recording->setText(QString::fromLocal8Bit("<EFBFBD>ɼ<EFBFBD>"));
|
||||
ui.mainToolBar->widgetForAction(ui.action_start_recording)->setStyleSheet("QWidget{background-color:rgb(0,255,0);}");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
else if (checkedName == "mAction_RobotArm")
|
||||
{
|
||||
m_Imager->setRecordControlState(false);//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<EFBFBD>ɼ<EFBFBD>
|
||||
//<2F><><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>к<EFBFBD><D0BA><EFBFBD>RobotArmControl::executeTask<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾbug
|
||||
rac->executeTaskWithHyperImager();
|
||||
|
||||
m_ForLoopControl->m_boolQuitLoop = true;//ѭ<><D1AD>ֹͣ
|
||||
|
||||
ui.action_start_recording->setText(QString::fromLocal8Bit("<EFBFBD>ɼ<EFBFBD>"));
|
||||
ui.mainToolBar->widgetForAction(ui.action_start_recording)->setStyleSheet("QWidget{background-color:rgb(0,255,0);}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -796,7 +860,7 @@ void HPPA::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (m_xMotor == nullptr || m_yMotor == nullptr)
|
||||
{
|
||||
qDebug() << "Motor pointer is null!!!!!";
|
||||
//qDebug() << "Motor pointer is null!!!!!";
|
||||
|
||||
xmotor_state_label1->setStyleSheet("QLabel{background-color:rgb(255,0,0);}");
|
||||
SetXMotorWidgetEnable(false);
|
||||
@ -814,7 +878,7 @@ void HPPA::timerEvent(QTimerEvent *event)
|
||||
}
|
||||
ByteBack xMotorState = m_xMotor->GetState();//ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
std::cout << "------------------------------------------x<><78><EFBFBD><EFBFBD><EFBFBD>ٶȣ<D9B6>" << xMotorState.Speed << std::endl;
|
||||
//std::cout << "------------------------------------------x<><78><EFBFBD><EFBFBD><EFBFBD>ٶȣ<D9B6>" << xMotorState.Speed << std::endl;
|
||||
|
||||
if (xMotorState.Speed == -1000000)
|
||||
{
|
||||
@ -1706,7 +1770,7 @@ void HPPA::onconnect()
|
||||
}
|
||||
else if (imagerSelected == "mActionPika_XC2")
|
||||
{
|
||||
|
||||
m_Imager = new ResononPicaLImager();
|
||||
}
|
||||
else if (imagerSelected == "mActionCorning_410")
|
||||
{
|
||||
@ -1903,7 +1967,7 @@ void HPPA::onReference()
|
||||
msgBox.setText(QString::fromLocal8Bit("<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>"));
|
||||
msgBox.exec();
|
||||
|
||||
bool isMotorEnable = this->ui.mAction_is_motor_enable->isChecked();
|
||||
bool isMotorEnable = this->ui.mAction_2AxisMotor->isChecked();
|
||||
if (isMotorEnable)
|
||||
{
|
||||
//<2F>ƶ<EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD>
|
||||
@ -1925,7 +1989,7 @@ void HPPA::recordWhiteFinish()
|
||||
{
|
||||
ui.mainToolBar->widgetForAction(ui.action_reference)->setStyleSheet("QWidget{background-color:rgb(0,255,0);}");
|
||||
|
||||
bool isMotorEnable = this->ui.mAction_is_motor_enable->isChecked();
|
||||
bool isMotorEnable = this->ui.mAction_2AxisMotor->isChecked();
|
||||
if (isMotorEnable)
|
||||
{
|
||||
//<2F>ƶ<EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD>
|
||||
@ -1940,6 +2004,7 @@ void HPPA::recordWhiteFinish()
|
||||
|
||||
void HPPA::onPlotHyperspectralImageRgbImage()
|
||||
{
|
||||
//return;
|
||||
//<2F><>ȡ<EFBFBD><C8A1>ͼ<EFBFBD>ؼ<EFBFBD>
|
||||
QWidget* currentWidget = ui.ImageViewerTabWidget->widget(m_numberOfRecording);
|
||||
QList<ImageViewer *> currentImageViewer = currentWidget->findChildren<ImageViewer *>();
|
||||
@ -2062,6 +2127,19 @@ void HPPA::onRecordFinishedSignal_WhenFrameNumberMeet()
|
||||
|
||||
void HPPA::onRecordFinishedSignal_WhenFrameNumberNotMeet()
|
||||
{
|
||||
QAction* checked = moveplatformActionGroup->checkedAction();
|
||||
QString checkedName;
|
||||
if (checked)
|
||||
{
|
||||
checkedName = checked->objectName();
|
||||
}
|
||||
|
||||
if (checkedName == "mAction_RobotArm")//<2F><>е<EFBFBD>ۻ<EFBFBD><DBBB><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><CBB2><EFBFBD>ֿ<EFBFBD>ʼ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ui.action_start_recording<6E><67>ʾ<EFBFBD>쳣
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
std::cout << "ֹͣ<EFBFBD>ɼ<EFBFBD>ԭ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>֡<EFBFBD><EFBFBD>û<EFBFBD>вɼ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ﵽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ֹͣ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>" << std::endl;
|
||||
|
||||
ui.action_start_recording->setText(QString::fromLocal8Bit("<EFBFBD>ɼ<EFBFBD>"));
|
||||
|
10
HPPA/HPPA.h
10
HPPA/HPPA.h
@ -33,6 +33,7 @@
|
||||
#include "adjustTable.h"
|
||||
#include "PowerControl.h"
|
||||
#include "PathPlan.h"
|
||||
#include "RobotArmControl.h"
|
||||
|
||||
#include "hppaConfigFile.h"
|
||||
#include "path_tc.h"
|
||||
@ -238,6 +239,11 @@ private:
|
||||
QActionGroup* mImagerGroup = nullptr;
|
||||
void createActionGroups();
|
||||
void selectingImager(QAction* selectedAction);
|
||||
QActionGroup* moveplatformActionGroup = nullptr;
|
||||
void createMoveplatformActionGroup();
|
||||
void selectingMoveplatform(QAction* selectedAction);
|
||||
RobotArmControl* rac;
|
||||
|
||||
|
||||
PathPlan* m_pathPlan;
|
||||
|
||||
@ -321,8 +327,6 @@ public Q_SLOTS:
|
||||
void ontimerMoveXmotor();
|
||||
void ontimerMoveYmotor();
|
||||
|
||||
void onMotorSwitch();
|
||||
|
||||
//
|
||||
void onimagerSimulatorMove(int x, int y);
|
||||
void OnSendLogToCallClass(QString str);
|
||||
@ -335,6 +339,8 @@ public Q_SLOTS:
|
||||
|
||||
void requestFinished(QNetworkReply* reply);
|
||||
|
||||
void recordFromRobotArm(int fileCounter);
|
||||
|
||||
signals:
|
||||
void StartFocusSignal();
|
||||
void StartLoopSignal();
|
||||
|
37
HPPA/HPPA.ui
37
HPPA/HPPA.ui
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1120</width>
|
||||
<height>675</height>
|
||||
<width>1194</width>
|
||||
<height>834</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -46,7 +46,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_4">
|
||||
<attribute name="title">
|
||||
@ -84,7 +84,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1120</width>
|
||||
<width>1194</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -166,7 +166,9 @@ color:white;
|
||||
<property name="title">
|
||||
<string>扫描平台</string>
|
||||
</property>
|
||||
<addaction name="mAction_is_motor_enable"/>
|
||||
<addaction name="mAction_is_no_motor"/>
|
||||
<addaction name="mAction_2AxisMotor"/>
|
||||
<addaction name="mAction_RobotArm"/>
|
||||
</widget>
|
||||
<addaction name="file"/>
|
||||
<addaction name="menuspectrometer"/>
|
||||
@ -1550,18 +1552,37 @@ QDockWidget::title {
|
||||
<string>马达</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mAction_is_motor_enable">
|
||||
<action name="mAction_is_no_motor">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>开启</string>
|
||||
<string>无</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mAction_2AxisMotor">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>2 轴线性马达</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mAction_RobotArm">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>机械臂</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
|
@ -86,7 +86,7 @@
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@ -116,6 +116,7 @@
|
||||
<ClCompile Include="resononImager.cpp" />
|
||||
<ClCompile Include="ResononNirImager.cpp" />
|
||||
<ClCompile Include="RgbCameraOperation.cpp" />
|
||||
<ClCompile Include="RobotArmControl.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
@ -139,6 +140,7 @@
|
||||
<ClCompile Include="main.cpp" />
|
||||
<QtUic Include="PathPlan.ui" />
|
||||
<QtUic Include="PowerControl.ui" />
|
||||
<QtUic Include="RobotArmControl.ui" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="fileOperation.h" />
|
||||
@ -153,6 +155,7 @@
|
||||
<QtMoc Include="adjustTable.h" />
|
||||
<QtMoc Include="PowerControl.h" />
|
||||
<QtMoc Include="PathPlan.h" />
|
||||
<QtMoc Include="RobotArmControl.h" />
|
||||
<ClInclude Include="utility_tc.h" />
|
||||
<QtMoc Include="aboutWindow.h" />
|
||||
<ClInclude Include="hppaConfigFile.h" />
|
||||
|
@ -106,6 +106,9 @@
|
||||
<ClCompile Include="PathPlan.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RobotArmControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="fileOperation.h">
|
||||
@ -153,6 +156,9 @@
|
||||
<QtMoc Include="PathPlan.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="RobotArmControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="imageProcessor.h">
|
||||
@ -196,6 +202,9 @@
|
||||
<QtUic Include="PathPlan.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="RobotArmControl.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
|
@ -287,7 +287,7 @@ void ImagerOperationBase::start_record()
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼǰ<CDBC><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//m_RgbImage
|
||||
emit PlotSignal();//<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><EFBFBD>ɼ<EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>ȫ
|
||||
//emit PlotSignal();//<2F><>1<EFBFBD><31><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>λ<EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><EFBFBD>ɼ<EFBFBD>֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ʵı<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>ʹ<EFBFBD>û<EFBFBD>е<EFBFBD>۲ɼ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD>俪ʼ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᵼ<EFBFBD><EFBFBD><EFBFBD>ϴβɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD>źŵ<EFBFBD><EFBFBD>õIJۺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>˼<EFBFBD><EFBFBD>ݣ<EFBFBD>ע<EFBFBD>͵<EFBFBD>
|
||||
|
||||
if (m_iFrameCounter >= m_iFrameNumber)
|
||||
{
|
||||
|
639
HPPA/RobotArmControl.cpp
Normal file
639
HPPA/RobotArmControl.cpp
Normal file
@ -0,0 +1,639 @@
|
||||
#include "RobotArmControl.h"
|
||||
|
||||
RobotArmControl::RobotArmControl(QWidget* parent): QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
robotController = new RobotController(this);
|
||||
|
||||
connect(ui.get_task_list_btn, SIGNAL(clicked()), this, SLOT(getTaskList()));
|
||||
connect(ui.get_pose_btn, SIGNAL(clicked()), this, SLOT(getPose()));
|
||||
connect(ui.connect2arm_btn, SIGNAL(clicked()), this, SLOT(connectRobotArm()));
|
||||
|
||||
connect(ui.execute_task_btn, SIGNAL(clicked()), this, SLOT(executeTaskWithoutHyperImager()));
|
||||
connect(ui.pause_task_btn, SIGNAL(clicked()), this, SLOT(pauseTask()));
|
||||
connect(ui.continue_task_btn, SIGNAL(clicked()), this, SLOT(continueTask()));
|
||||
|
||||
robotMonitor = new EC8056;
|
||||
connect(robotMonitor, &EC8056::dataReceived, this, &RobotArmControl::monitorRobotArm);
|
||||
|
||||
|
||||
m_pModel = new QStringListModel(ui.taskList_listView);
|
||||
|
||||
ui.taskList_listView->setModel(m_pModel);
|
||||
}
|
||||
|
||||
RobotArmControl::~RobotArmControl()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RobotArmControl::monitorRobotArm(const ECData& data)
|
||||
{
|
||||
double x = data.machinePose[0];
|
||||
double y = data.machinePose[1];
|
||||
double z = data.machinePose[2];
|
||||
|
||||
ui.pose_x_label->setText(QString::number(x));
|
||||
ui.pose_y_label->setText(QString::number(y));
|
||||
ui.pose_z_label->setText(QString::number(z));
|
||||
}
|
||||
|
||||
void RobotArmControl::onCommandResponse(QString str, const QJsonObject& response)
|
||||
{
|
||||
//qDebug() << "response:" << response;
|
||||
|
||||
QString re;
|
||||
if (response.contains("result"))
|
||||
{
|
||||
re = response["result"].toVariant().toString();
|
||||
ui.textEdit->append(str + " Result: " + re);
|
||||
}
|
||||
else if (response.contains("error"))
|
||||
{
|
||||
//auto delete11 = response["error"].toObject();
|
||||
//qDebug() << "response[\"error\"]:" << delete11;
|
||||
|
||||
auto errorStr = response["error"].toObject()["message"].toString();
|
||||
|
||||
ui.textEdit->append(str + " Error: " + errorStr);
|
||||
}
|
||||
}
|
||||
|
||||
void RobotArmControl::getTaskList()
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
|
||||
QString pythonScript = QString::fromStdString(directory) + "\\get_jbi_filename.py";
|
||||
|
||||
QProcess process;
|
||||
|
||||
process.start("python.exe", QStringList() << pythonScript);
|
||||
process.waitForFinished();
|
||||
QString output = process.readAllStandardOutput();
|
||||
|
||||
QStringList files;
|
||||
//files.append("tc20250324down.jbi");
|
||||
//files.append("tc20250324circle.jbi");
|
||||
//files.append("tc20250324side.jbi");
|
||||
QStringList lines = output.split('\n', QString::SkipEmptyParts);
|
||||
for (const QString& line : lines)
|
||||
{
|
||||
files.append(line.trimmed());
|
||||
}
|
||||
|
||||
////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//for (size_t i = 0; i < files.length(); i++)
|
||||
//{
|
||||
// int row = m_pModel->rowCount();
|
||||
// m_pModel->insertRow(row);
|
||||
// QModelIndex index = m_pModel->index(row);
|
||||
// m_pModel->setData(index, files[i]);
|
||||
//}
|
||||
|
||||
m_pModel->setStringList(files);
|
||||
}
|
||||
|
||||
void RobotArmControl::getPose()
|
||||
{
|
||||
QJsonObject response;
|
||||
bool x = robotController->getRobotPose(response);
|
||||
onCommandResponse("getPose", response);
|
||||
}
|
||||
|
||||
void RobotArmControl::connectRobotArm()
|
||||
{
|
||||
bool re = robotController->connectToRobot("192.168.1.100");
|
||||
robotMonitor->connectToHost("192.168.1.100");
|
||||
}
|
||||
|
||||
void RobotArmControl::executeTaskWithHyperImager()
|
||||
{
|
||||
QModelIndex index = ui.taskList_listView->currentIndex();
|
||||
if (-1 == index.row())
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>û<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>ļ<EFBFBD>
|
||||
ui.textEdit->append("Please select file on the left!");
|
||||
return;
|
||||
}
|
||||
QString fileName = index.data(Qt::DisplayRole).toString();
|
||||
|
||||
QJsonObject response;
|
||||
bool x;
|
||||
|
||||
x = robotController->checkJbiExist(fileName, response);
|
||||
onCommandResponse("checkJbiExist", response);
|
||||
if (!x)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
x = robotController->setServoStatus(1, response);
|
||||
onCommandResponse("setServoStatus", response);
|
||||
if (!x)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
x = robotController->runJbi(fileName, response, true);
|
||||
onCommandResponse("runJbi", response);
|
||||
if (!x)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void RobotArmControl::executeTaskWithoutHyperImager()
|
||||
{
|
||||
QModelIndex index = ui.taskList_listView->currentIndex();
|
||||
if (-1 == index.row())
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>û<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>ļ<EFBFBD>
|
||||
ui.textEdit->append("Please select file on the left!");
|
||||
return;
|
||||
}
|
||||
QString fileName = index.data(Qt::DisplayRole).toString();
|
||||
|
||||
QJsonObject response;
|
||||
bool x;
|
||||
|
||||
x = robotController->checkJbiExist(fileName, response);
|
||||
onCommandResponse("checkJbiExist", response);
|
||||
if (!x)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
x = robotController->setServoStatus(1, response);
|
||||
onCommandResponse("setServoStatus", response);
|
||||
if (!x)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
x = robotController->runJbi(fileName, response, false);
|
||||
onCommandResponse("runJbi", response);
|
||||
if (!x)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void RobotArmControl::pauseTask()
|
||||
{
|
||||
QJsonObject response;
|
||||
bool x;
|
||||
|
||||
x = robotController->pauseTask(response);
|
||||
onCommandResponse("pauseTask", response);
|
||||
}
|
||||
|
||||
void RobotArmControl::continueTask()
|
||||
{
|
||||
QJsonObject response;
|
||||
bool x;
|
||||
|
||||
x = robotController->continueTask(response);
|
||||
onCommandResponse("continueTask", response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RobotController::RobotController(QObject* parent) : QObject(parent), socket(new QTcpSocket(this))
|
||||
{
|
||||
//connect(socket, &QTcpSocket::readyRead, this, &RobotController::onReadyRead);
|
||||
|
||||
m_timer = new QTimer(this);
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(getPoint()));
|
||||
}
|
||||
|
||||
RobotController::~RobotController()
|
||||
{
|
||||
disconnectFromRobot();
|
||||
}
|
||||
|
||||
bool RobotController::connectToRobot(const QString& ip, quint16 port)
|
||||
{
|
||||
socket->setProxy(QNetworkProxy::NoProxy);
|
||||
|
||||
socket->connectToHost(ip, port);
|
||||
|
||||
if (!socket->waitForConnected(3000)) {
|
||||
qDebug() << "Connection failed:" << socket->errorString();
|
||||
return false;
|
||||
}
|
||||
qDebug() << "Connected successfully!";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RobotController::disconnectFromRobot()
|
||||
{
|
||||
if (socket->isOpen())
|
||||
{
|
||||
socket->close();
|
||||
}
|
||||
}
|
||||
|
||||
bool RobotController::processResponse(QJsonObject response, QString& result)
|
||||
{
|
||||
//qDebug() << "response:" << response;
|
||||
|
||||
if (response.contains("result"))
|
||||
{
|
||||
result = response["result"].toVariant().toString();
|
||||
|
||||
//qDebug() << "result1:" << result;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (response.contains("error"))
|
||||
{
|
||||
result = response["error"].toObject()["message"].toString();
|
||||
//qDebug() << "result2:" << result;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool RobotController::processResponse_getJbiState(QJsonObject response, QString& result)
|
||||
{
|
||||
//qDebug() << "response:" << response;
|
||||
|
||||
if (response.contains("result"))
|
||||
{
|
||||
QString resultStr = response["result"].toString();
|
||||
|
||||
QJsonDocument resultDoc = QJsonDocument::fromJson(resultStr.toUtf8());
|
||||
QJsonObject resultObj = resultDoc.object();
|
||||
//qDebug() << "resultObj:" << resultObj;
|
||||
|
||||
int runState = resultObj["runState"].toInt();
|
||||
//qDebug() << "runState:" << runState;
|
||||
|
||||
result = QString::number(runState);
|
||||
//qDebug() << "result:" << result;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (response.contains("error"))
|
||||
{
|
||||
result = response["error"].toObject()["message"].toString();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void RobotController::getPoint()
|
||||
{
|
||||
QJsonObject response;
|
||||
getJbiState(response);//0 ֹͣ״̬,1 <20><>ͣ״̬,2 <20><>ͣ״̬,3 <20><><EFBFBD><EFBFBD>״̬,4 <20><><EFBFBD><EFBFBD>״̬
|
||||
QString result;
|
||||
bool x = processResponse_getJbiState(response, result);
|
||||
//qDebug() << "getJbiState:" << result;
|
||||
|
||||
if (result.toInt() != 3)
|
||||
{
|
||||
m_timer->stop();
|
||||
|
||||
m_iCurrentJbiJobLine = 0;
|
||||
m_iFileCounter = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
emit hsiRecordSignal(-1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject response2;
|
||||
getCurrentJobLine(response2);
|
||||
QString result2;
|
||||
bool x2 = processResponse(response2, result2);
|
||||
|
||||
int m_iCurrentJbiJobLine_tmp = result2.toInt();
|
||||
|
||||
|
||||
if (m_iCurrentJbiJobLine_tmp != m_iCurrentJbiJobLine)
|
||||
{
|
||||
m_iFileCounter++;
|
||||
|
||||
qDebug() << "Changed! CurrentJobLine:" << m_iCurrentJbiJobLine_tmp;
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3>ɼ<EFBFBD>
|
||||
emit hsiRecordSignal(-1);
|
||||
|
||||
m_iCurrentJbiJobLine = m_iCurrentJbiJobLine_tmp;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ɼ<EFBFBD>
|
||||
emit hsiRecordSignal(m_iFileCounter);
|
||||
}
|
||||
}
|
||||
|
||||
void RobotController::sendCommand(const QString& cmd, const QJsonValue& params, int id)
|
||||
{
|
||||
QJsonObject request;
|
||||
request["method"] = cmd;
|
||||
request["params"] = params;
|
||||
request["jsonrpc"] = "2.0";
|
||||
request["id"] = id;
|
||||
|
||||
QJsonDocument doc(request);
|
||||
QByteArray data = doc.toJson(QJsonDocument::Compact) + "\n";
|
||||
//qDebug() << "send command:" << data.constData();
|
||||
|
||||
socket->write(data);
|
||||
socket->waitForBytesWritten();
|
||||
}
|
||||
|
||||
bool RobotController::onReadyRead(QJsonObject& re)
|
||||
{
|
||||
QByteArray data = socket->readAll();
|
||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
||||
if (!doc.isNull() && doc.isObject())
|
||||
{
|
||||
re = doc.object();
|
||||
//qDebug() << "Received all:" << re;
|
||||
|
||||
if (re.contains("result"))
|
||||
{
|
||||
//qDebug() << "Received result:" << re["result"].toVariant();
|
||||
return true;
|
||||
}
|
||||
else if (re.contains("error"))
|
||||
{
|
||||
//qDebug() << "Received error:" << re["error"];
|
||||
return false;
|
||||
}
|
||||
|
||||
//emit commandResponse(true, doc.object());
|
||||
}
|
||||
else
|
||||
{
|
||||
//emit commandResponse(false, QJsonObject());
|
||||
|
||||
re = QJsonObject();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool RobotController::getRobotPose(QJsonObject& re)
|
||||
{
|
||||
sendCommand("getRobotPose");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::getRobotState(QJsonObject& re)
|
||||
{
|
||||
sendCommand("getRobotState");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::getJbiState(QJsonObject& re)
|
||||
{
|
||||
sendCommand("getJbiState");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::getCurrentJobLine(QJsonObject& re)
|
||||
{
|
||||
sendCommand("getCurrentJobLine");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::getRobotMode(QJsonObject& re)
|
||||
{
|
||||
sendCommand("getRobotMode");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::checkJbiExist(const QString& jbiFilename, QJsonObject& re)
|
||||
{
|
||||
QJsonObject paramsRunJbi;
|
||||
paramsRunJbi["filename"] = jbiFilename;//ʹ<>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ṹ
|
||||
|
||||
sendCommand("checkJbiExist", paramsRunJbi);
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::setServoStatus(int status, QJsonObject& re)
|
||||
{
|
||||
QJsonObject params_set_servo_status;
|
||||
params_set_servo_status["status"] = status;//ʹ<>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ṹ
|
||||
|
||||
sendCommand("set_servo_status", params_set_servo_status);
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::runJbi(const QString& jbiFilename, QJsonObject& re, bool isRecordHsi)
|
||||
{
|
||||
QJsonObject paramsRunJbi;
|
||||
paramsRunJbi["filename"] = jbiFilename;//ʹ<>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>ṹ
|
||||
|
||||
sendCommand("runJbi", paramsRunJbi);
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
if (isRecordHsi)
|
||||
{
|
||||
m_timer->start(1000);
|
||||
}
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::pauseTask(QJsonObject& re)
|
||||
{
|
||||
sendCommand("pause");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::run(QJsonObject& re)
|
||||
{
|
||||
sendCommand("run");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::continueTask(QJsonObject& re)
|
||||
{
|
||||
sendCommand("run");
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
bool RobotController::setRobotPowerStatus(int status, QJsonObject& re)
|
||||
{
|
||||
sendCommand("set_robot_power_status", QJsonArray{ status });
|
||||
socket->waitForReadyRead(m_iTimeout);
|
||||
|
||||
return onReadyRead(re);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
EC8056::EC8056(QObject* parent) : QObject(parent), socket(new QTcpSocket(this))
|
||||
{
|
||||
connect(socket, &QTcpSocket::readyRead, this, &EC8056::onReadyRead);
|
||||
/*connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QTcpSocket::errorOccurred),
|
||||
this, &EC8056::onSocketError);*/
|
||||
//connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
|
||||
// this, SLOT(onSocketError(QAbstractSocket::SocketError)));
|
||||
}
|
||||
|
||||
void EC8056::connectToHost(const QString& host, quint16 port)
|
||||
{
|
||||
socket->setProxy(QNetworkProxy::NoProxy);
|
||||
|
||||
socket->connectToHost(QHostAddress(host), port);
|
||||
|
||||
if (!socket->waitForConnected(3000)) {
|
||||
qDebug() << "Connection failed:" << socket->errorString();
|
||||
return;
|
||||
}
|
||||
qDebug() << "Connected successfully!";
|
||||
}
|
||||
|
||||
quint8 EC8056::readUInt8(const QByteArray& buf, int& offset)
|
||||
{
|
||||
return static_cast<quint8>(buf[offset++]);
|
||||
}
|
||||
|
||||
quint32 EC8056::readUInt32(const QByteArray& buf, int& offset)
|
||||
{
|
||||
quint32 val;
|
||||
memcpy(&val, buf.constData() + offset, sizeof(val));
|
||||
offset += sizeof(val);
|
||||
return qFromBigEndian(val);
|
||||
}
|
||||
|
||||
qint32 EC8056::readInt32(const QByteArray& buf, int& offset)
|
||||
{
|
||||
qint32 val;
|
||||
memcpy(&val, buf.constData() + offset, sizeof(val));
|
||||
offset += sizeof(val);
|
||||
return qFromBigEndian(val);
|
||||
}
|
||||
|
||||
quint64 EC8056::readUInt64(const QByteArray& buf, int& offset)
|
||||
{
|
||||
quint64 val;
|
||||
memcpy(&val, buf.constData() + offset, sizeof(val));
|
||||
offset += sizeof(val);
|
||||
return qFromBigEndian(val);
|
||||
}
|
||||
|
||||
double EC8056::readDouble(const QByteArray& buf, int& offset)
|
||||
{
|
||||
QByteArray b = buf.mid(offset, sizeof(double));
|
||||
offset += sizeof(double);
|
||||
if (QSysInfo::ByteOrder == QSysInfo::LittleEndian)
|
||||
std::reverse(b.begin(), b.end());
|
||||
|
||||
double val;
|
||||
memcpy(&val, b.constData(), sizeof(double));
|
||||
return val;
|
||||
}
|
||||
|
||||
void EC8056::onReadyRead()
|
||||
{
|
||||
buffer.append(socket->readAll());
|
||||
|
||||
if (buffer.size() < 1024)
|
||||
return;
|
||||
|
||||
int offset = 0;
|
||||
ECData data;
|
||||
|
||||
data.msgSize = readUInt32(buffer, offset);
|
||||
offset = 1020;
|
||||
data.matchingWord = readUInt32(buffer, offset);
|
||||
|
||||
if ((data.msgSize == 1024)/* && (data.matchingWord == 3967833836)*/)
|
||||
{
|
||||
offset = 0;
|
||||
|
||||
data.msgSize = readUInt32(buffer, offset);
|
||||
data.timeStamp = readUInt64(buffer, offset);
|
||||
data.auto_cycle = readUInt8(buffer, offset);
|
||||
|
||||
for (int i = 0; i < 8; ++i) data.machinePos[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.machinePose[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.machineUserPose[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 8; ++i) data.torque[i] = readDouble(buffer, offset);
|
||||
|
||||
data.robotState = readUInt32(buffer, offset);
|
||||
data.servoReady = readUInt32(buffer, offset);
|
||||
data.can_motor_run = readUInt32(buffer, offset);
|
||||
|
||||
for (int i = 0; i < 8; ++i) data.motor_speed[i] = readInt32(buffer, offset);
|
||||
|
||||
data.robotMode = readUInt32(buffer, offset);
|
||||
|
||||
for (int i = 0; i < 3; ++i) data.analog_ioInput[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 5; ++i) data.analog_ioOutput[i] = readDouble(buffer, offset);
|
||||
|
||||
data.digital_ioInput = readUInt64(buffer, offset);
|
||||
data.digital_ioOutput = readUInt64(buffer, offset);
|
||||
|
||||
data.collision = readUInt8(buffer, offset);
|
||||
|
||||
for (int i = 0; i < 6; ++i) data.machineFlangePose[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.machineUserFlangePose[i] = readDouble(buffer, offset);
|
||||
|
||||
data.emergencyStopState = readUInt8(buffer, offset);
|
||||
data.tcpSpeed = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 8; ++i) data.joIntSpeed[i] = readDouble(buffer, offset);
|
||||
data.tcpAcc = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 8; ++i) data.joIntAcc[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.joIntTemperature[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.joIntTorque[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.extJoIntTorques[i] = readDouble(buffer, offset);
|
||||
for (int i = 0; i < 6; ++i) data.exTcpForceIntool[i] = readDouble(buffer, offset);
|
||||
|
||||
data.dragState = readUInt8(buffer, offset);
|
||||
data.sensor_connected_state = readUInt8(buffer, offset);
|
||||
data.reserved = readUInt8(buffer, offset);
|
||||
data.matchingWord = readUInt32(buffer, offset);
|
||||
|
||||
/*if (data.msgSize != 1024 || data.matchingWord != 0xec8056ec) {
|
||||
buffer.clear();
|
||||
emit errorOccurred("Invalid packet received");
|
||||
return;
|
||||
}*/
|
||||
|
||||
emit dataReceived(data);
|
||||
}
|
||||
|
||||
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
void EC8056::onSocketError(QAbstractSocket::SocketError socketError)
|
||||
{
|
||||
Q_UNUSED(socketError)
|
||||
emit errorOccurred(socket->errorString());
|
||||
}
|
164
HPPA/RobotArmControl.h
Normal file
164
HPPA/RobotArmControl.h
Normal file
@ -0,0 +1,164 @@
|
||||
#pragma once
|
||||
#include <qdialog.h>
|
||||
#include <QTcpSocket>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
#include <QNetworkProxy>
|
||||
#include <QtEndian>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QAuthenticator>
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
#include <QProcess>
|
||||
#include <QStringListModel>
|
||||
#include <QTimer>
|
||||
|
||||
#include "ui_RobotArmControl.h"
|
||||
#include "fileOperation.h"
|
||||
|
||||
|
||||
struct ECData
|
||||
{
|
||||
quint32 msgSize;
|
||||
quint64 timeStamp;
|
||||
quint8 auto_cycle;
|
||||
double machinePos[8];//<2F>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double machinePose[6];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double machineUserPose[6];//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
double torque[8];//<2F>ؽڶ<DAB6><EEB6A8><EFBFBD>ذٷֱ<D9B7>
|
||||
quint32 robotState;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
quint32 servoReady;//<2F>ŷ<EFBFBD>ʹ<EFBFBD><CAB9>״̬
|
||||
quint32 can_motor_run;//ͬ<><CDAC>״̬
|
||||
qint32 motor_speed[8];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
|
||||
quint32 robotMode;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ
|
||||
double analog_ioInput[3];//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
double analog_ioOutput[5];//ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
quint64 digital_ioInput;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĶ<DDB5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||
quint64 digital_ioOutput;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĶ<DDB5><C4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||
quint8 collision;//<2F><>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD>״̬
|
||||
double machineFlangePose[6];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µķ<C2B5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
double machineUserFlangePose[6];//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µķ<C2B5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
quint8 emergencyStopState;//<2F><>ǰ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڼ<EFBFBD>ͣ״̬
|
||||
double tcpSpeed;//tcp<63>˶<EFBFBD><CBB6>ٶ<EFBFBD>
|
||||
double joIntSpeed[8];//<2F>ؽ<EFBFBD><D8BD>˶<EFBFBD><CBB6>¸<EFBFBD><C2B8>ؽ<EFBFBD><D8BD>˶<EFBFBD><CBB6>ٶ<EFBFBD>
|
||||
double tcpAcc;//tcp<63><70><EFBFBD>ٶ<EFBFBD>
|
||||
double joIntAcc[8];//<2F>ؽ<EFBFBD><D8BD>˶<EFBFBD><CBB6>¸<EFBFBD><C2B8>ؽڼ<D8BD><DABC>ٶ<EFBFBD>
|
||||
double joIntTemperature[6];//<2F>¶<EFBFBD>
|
||||
double joIntTorque[6];//<2F><><EFBFBD><EFBFBD>Ť<EFBFBD><C5A4>
|
||||
double extJoIntTorques[6];//<2F>ⲿ<EFBFBD>ؽ<EFBFBD>Ť<EFBFBD><C5A4>ֵ
|
||||
double exTcpForceIntool[6];//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>µ<EFBFBD><C2B5>ⲿĩ<E2B2BF><C4A9><EFBFBD><EFBFBD>/<2F><><EFBFBD>ع<EFBFBD><D8B9><EFBFBD>ֵ
|
||||
quint8 dragState;//<2F>϶<EFBFBD>ʹ<EFBFBD><CAB9>״̬
|
||||
quint8 sensor_connected_state;//<2F><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||
quint8 reserved;
|
||||
quint32 matchingWord;
|
||||
};
|
||||
|
||||
class EC8056 : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EC8056(QObject* parent = nullptr);
|
||||
void connectToHost(const QString& host, quint16 port= 8056);
|
||||
|
||||
signals:
|
||||
void dataReceived(const ECData& data);
|
||||
void errorOccurred(const QString& error);
|
||||
|
||||
private slots:
|
||||
void onReadyRead();
|
||||
void onSocketError(QAbstractSocket::SocketError socketError);
|
||||
|
||||
private:
|
||||
QTcpSocket* socket;
|
||||
QByteArray buffer;
|
||||
|
||||
double readDouble(const QByteArray& buf, int& offset);
|
||||
quint64 readUInt64(const QByteArray& buf, int& offset);
|
||||
quint32 readUInt32(const QByteArray& buf, int& offset);
|
||||
qint32 readInt32(const QByteArray& buf, int& offset);
|
||||
quint8 readUInt8(const QByteArray& buf, int& offset);
|
||||
};
|
||||
|
||||
class RobotController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RobotController(QObject* parent = nullptr);
|
||||
~RobotController();
|
||||
|
||||
bool connectToRobot(const QString& ip, quint16 port = 8055);
|
||||
void disconnectFromRobot();
|
||||
void sendCommand(const QString& cmd, const QJsonValue& params = QJsonArray(), int id = 1);
|
||||
bool processResponse(QJsonObject response, QString& re);
|
||||
bool processResponse_getJbiState(QJsonObject response, QString& result);
|
||||
|
||||
bool getRobotPose(QJsonObject& re);
|
||||
bool getRobotState(QJsonObject& re);//ֹͣ״̬ 0<><30><EFBFBD><EFBFBD>ͣ״̬ 1<><31><EFBFBD><EFBFBD>ͣ״̬ 2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ 3<><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ 4<><34><EFBFBD><EFBFBD>ײ״̬ 5
|
||||
bool getJbiState(QJsonObject& re);//0 ֹͣ״̬,1 <20><>ͣ״̬,2 <20><>ͣ״̬,3 <20><><EFBFBD><EFBFBD>״̬,4 <20><><EFBFBD><EFBFBD>״̬
|
||||
bool getCurrentJobLine(QJsonObject& re);
|
||||
bool getRobotMode(QJsonObject& re);//ʾ<><CABE>ģʽ 0<><30><EFBFBD>Զ<EFBFBD>ģʽ 1<><31>Զ<EFBFBD><D4B6>ģʽ 2
|
||||
bool checkJbiExist(const QString& jbiFilename, QJsonObject& re);
|
||||
bool setServoStatus(int status, QJsonObject& re);
|
||||
bool runJbi(const QString& jbiFilename, QJsonObject& re, bool isRecordHsi);
|
||||
bool pauseTask(QJsonObject& re);
|
||||
bool run(QJsonObject& re);
|
||||
bool continueTask(QJsonObject& re);
|
||||
bool setRobotPowerStatus(int status, QJsonObject& re);
|
||||
|
||||
bool onReadyRead(QJsonObject& re);
|
||||
|
||||
private:
|
||||
QTcpSocket* socket;
|
||||
|
||||
QTimer* m_timer;
|
||||
int m_iTimeout = 3000;
|
||||
int m_iCurrentJbiJobLine = 0;
|
||||
int m_iFileCounter = 0;
|
||||
|
||||
signals:
|
||||
void commandResponse(bool success, const QJsonObject& response);
|
||||
void hsiRecordSignal(int);
|
||||
|
||||
private slots:
|
||||
void getPoint();
|
||||
};
|
||||
|
||||
class RobotArmControl : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RobotArmControl(QWidget* parent = nullptr);
|
||||
~RobotArmControl();
|
||||
RobotController* robotController;
|
||||
|
||||
void onCommandResponse(QString str, const QJsonObject& response);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
void getTaskList();
|
||||
void getPose();
|
||||
|
||||
void connectRobotArm();
|
||||
void executeTaskWithHyperImager();
|
||||
void executeTaskWithoutHyperImager();
|
||||
void pauseTask();
|
||||
void continueTask();
|
||||
|
||||
void monitorRobotArm(const ECData& data);
|
||||
|
||||
signals:
|
||||
//void Opened();
|
||||
//void Closed();
|
||||
|
||||
private:
|
||||
Ui::RobotArmControl_UI ui;
|
||||
|
||||
EC8056* robotMonitor;
|
||||
QStringListModel* m_pModel;
|
||||
};
|
138
HPPA/RobotArmControl.ui
Normal file
138
HPPA/RobotArmControl.ui
Normal file
@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RobotArmControl_UI</class>
|
||||
<widget class="QDialog" name="RobotArmControl_UI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>424</width>
|
||||
<height>364</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="pause_task_btn">
|
||||
<property name="text">
|
||||
<string>暂停任务</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="connect2arm_btn">
|
||||
<property name="text">
|
||||
<string>连接机械臂</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="execute_task_btn">
|
||||
<property name="text">
|
||||
<string>执行任务</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="get_pose_btn">
|
||||
<property name="text">
|
||||
<string>获取pose</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="continue_task_btn">
|
||||
<property name="text">
|
||||
<string>继续任务</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QTextEdit" name="textEdit"/>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="6">
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="get_task_list_btn">
|
||||
<property name="text">
|
||||
<string>获取任务列表</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QListView" name="taskList_listView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="pose_z_label">
|
||||
<property name="text">
|
||||
<string>z</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="pose_x_label">
|
||||
<property name="text">
|
||||
<string>x</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="pose_y_label">
|
||||
<property name="text">
|
||||
<string>y</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -70,7 +70,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>版本:1.8.7</string>
|
||||
<string>版本:1.8.8</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
|
Reference in New Issue
Block a user