|
@@ -1,5 +1,6 @@
|
|
|
#include "mainwindow.h"
|
|
|
#include "ui_mainwindow.h"
|
|
|
+#include "iostream"
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
: QMainWindow(parent)
|
|
@@ -23,6 +24,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
ModuleFun funupdate = std::bind(&MainWindow::ListenBrainStateMsg,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
|
|
|
shmBrainState.mpa = iv::modulecomm::RegisterRecvPlus(shmBrainState.mstrmsgname,funupdate);
|
|
|
|
|
|
+ QObject::connect(this,&MainWindow::refreshHMI_Signal,this,&MainWindow::refreshHMI_Slot);
|
|
|
QObject::connect(&signalSendTimer,&QTimer::timeout,this,&MainWindow::signalSend_Timeout);
|
|
|
if(signalSendTimer.isActive() == false)signalSendTimer.start(50);
|
|
|
}
|
|
@@ -46,6 +48,32 @@ void MainWindow::ListenBrainStateMsg(const char * strdata,const unsigned int nSi
|
|
|
|
|
|
FSMState = xdata.mbfsm_state(); //0:待命停车 1:任务中 2:人工接管 3:停工停车 4:返程 5:返库
|
|
|
|
|
|
+ emit refreshHMI_Signal();
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::signalSend_Timeout(void)
|
|
|
+{
|
|
|
+ iv::brain::fsm_skip_cmd xmsg;
|
|
|
+ xmsg.set_timestamp(QDateTime::currentMSecsSinceEpoch());
|
|
|
+ xmsg.set_missioncmd(missionCMD);
|
|
|
+ xmsg.set_workcmd(workCMD);
|
|
|
+ xmsg.set_remotectrlcmd(remoteCtrlCMD);
|
|
|
+ xmsg.set_waitingstationarrived(waitingStationArrived);
|
|
|
+ xmsg.set_maintainstationarrived(maintainStationArrived);
|
|
|
+
|
|
|
+ int ndatasize = xmsg.ByteSize();
|
|
|
+ char * str = new char[ndatasize];
|
|
|
+ std::shared_ptr<char> pstr;pstr.reset(str);
|
|
|
+ if(!xmsg.SerializeToArray(str,ndatasize))
|
|
|
+ {
|
|
|
+ std::cout<<"FSMSkipCommand serialize error."<<std::endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ iv::modulecomm::ModuleSendMsg(shmFSMSkipCMD.mpa,str,ndatasize);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::refreshHMI_Slot(void)
|
|
|
+{
|
|
|
switch (FSMState) {
|
|
|
case 0:
|
|
|
ui->FSMStateTextBrowser->setText("0待命停车");
|
|
@@ -131,27 +159,6 @@ void MainWindow::ListenBrainStateMsg(const char * strdata,const unsigned int nSi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void MainWindow::signalSend_Timeout(void)
|
|
|
-{
|
|
|
- iv::brain::fsm_skip_cmd xmsg;
|
|
|
- xmsg.set_timestamp(QDateTime::currentMSecsSinceEpoch());
|
|
|
- xmsg.set_missioncmd(missionCMD);
|
|
|
- xmsg.set_workcmd(workCMD);
|
|
|
- xmsg.set_remotectrlcmd(remoteCtrlCMD);
|
|
|
- xmsg.set_waitingstationarrived(waitingStationArrived);
|
|
|
- xmsg.set_maintainstationarrived(maintainStationArrived);
|
|
|
-
|
|
|
- int ndatasize = xmsg.ByteSize();
|
|
|
- char * str = new char[ndatasize];
|
|
|
- std::shared_ptr<char> pstr;pstr.reset(str);
|
|
|
- if(!xmsg.SerializeToArray(str,ndatasize))
|
|
|
- {
|
|
|
- std::cout<<"FSMSkipCommand serialize error."<<std::endl;
|
|
|
- return;
|
|
|
- }
|
|
|
- iv::modulecomm::ModuleSendMsg(shmFSMSkipCMD.mpa,str,ndatasize);
|
|
|
-}
|
|
|
-
|
|
|
void MainWindow::on_missionStaButton_clicked(bool checked)
|
|
|
{
|
|
|
if(checked)
|
|
@@ -214,87 +221,23 @@ void MainWindow::on_comboBox_activated(int index)
|
|
|
{
|
|
|
FSMState = index; //0:待命停车 1:任务中 2:人工接管 3:停工停车 4:返程 5:返库
|
|
|
|
|
|
- switch (FSMState) {
|
|
|
- case 0:
|
|
|
- ui->FSMStateTextBrowser->setText("0待命停车");
|
|
|
- if(missionCMD == iv::brain::MissionCMD::MISSIOH_FINISH \
|
|
|
- || missionCMD == iv::brain::MissionCMD::MISSION_CANCEL)
|
|
|
- {
|
|
|
- missionCMD = iv::brain::MissionCMD::MISSION_RESERVED;
|
|
|
- ui->missionResButton->setChecked(true);
|
|
|
- }
|
|
|
- if(workCMD == iv::brain::WorkCMD::WORK_START)
|
|
|
- {
|
|
|
- workCMD = iv::brain::WorkCMD::WORK_RESERVED;
|
|
|
- ui->workResButton->setChecked(true);
|
|
|
- }
|
|
|
- if(remoteCtrlCMD == iv::brain::RemoteCtrlCMD::REMOTE_CTRL_EXIT)
|
|
|
- {
|
|
|
- remoteCtrlCMD = iv::brain::RemoteCtrlCMD::REMOTE_CTRL_RESERVED;
|
|
|
- ui->remoteResButton->setChecked(true);
|
|
|
- }
|
|
|
- if(waitingStationArrived == true)
|
|
|
- {
|
|
|
- waitingStationArrived = false;
|
|
|
- ui->waitSta_checkBox->setChecked(false);
|
|
|
- }
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- ui->FSMStateTextBrowser->setText("1任务中");
|
|
|
- if(missionCMD == iv::brain::MissionCMD::MISSION_START)
|
|
|
- {
|
|
|
- missionCMD = iv::brain::MissionCMD::MISSION_RESERVED;
|
|
|
- ui->missionResButton->setChecked(true);
|
|
|
- }
|
|
|
- if(remoteCtrlCMD == iv::brain::RemoteCtrlCMD::REMOTE_CTRL_EXIT)
|
|
|
- {
|
|
|
- remoteCtrlCMD = iv::brain::RemoteCtrlCMD::REMOTE_CTRL_RESERVED;
|
|
|
- ui->remoteResButton->setChecked(true);
|
|
|
- }
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- ui->FSMStateTextBrowser->setText("2人工接管");
|
|
|
- if(remoteCtrlCMD == iv::brain::RemoteCtrlCMD::REMOTE_CTRL_ENTER)
|
|
|
- {
|
|
|
- remoteCtrlCMD = iv::brain::RemoteCtrlCMD::REMOTE_CTRL_RESERVED;
|
|
|
- ui->remoteResButton->setChecked(true);
|
|
|
- }
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- ui->FSMStateTextBrowser->setText("3停工停车");
|
|
|
- if(remoteCtrlCMD == iv::brain::RemoteCtrlCMD::REMOTE_CTRL_EXIT)
|
|
|
- {
|
|
|
- remoteCtrlCMD = iv::brain::RemoteCtrlCMD::REMOTE_CTRL_RESERVED;
|
|
|
- ui->remoteResButton->setChecked(true);
|
|
|
- }
|
|
|
- if(maintainStationArrived == true)
|
|
|
- {
|
|
|
- maintainStationArrived = false;
|
|
|
- ui->maintainSta_checkBox->setChecked(false);
|
|
|
- }
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- ui->FSMStateTextBrowser->setText("4返程");
|
|
|
- if(remoteCtrlCMD == iv::brain::RemoteCtrlCMD::REMOTE_CTRL_EXIT)
|
|
|
- {
|
|
|
- remoteCtrlCMD = iv::brain::RemoteCtrlCMD::REMOTE_CTRL_RESERVED;
|
|
|
- ui->remoteResButton->setChecked(true);
|
|
|
- }
|
|
|
- break;
|
|
|
- case 5:
|
|
|
- ui->FSMStateTextBrowser->setText("5返库");
|
|
|
- if(workCMD == iv::brain::WorkCMD::WORK_STOP)
|
|
|
- {
|
|
|
- workCMD = iv::brain::WorkCMD::WORK_RESERVED;
|
|
|
- ui->workResButton->setChecked(true);
|
|
|
- }
|
|
|
- if(remoteCtrlCMD == iv::brain::RemoteCtrlCMD::REMOTE_CTRL_EXIT)
|
|
|
- {
|
|
|
- remoteCtrlCMD = iv::brain::RemoteCtrlCMD::REMOTE_CTRL_RESERVED;
|
|
|
- ui->remoteResButton->setChecked(true);
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
+ emit refreshHMI_Signal();
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_missionResButton_clicked(bool checked)
|
|
|
+{
|
|
|
+ if(checked)
|
|
|
+ missionCMD = iv::brain::MissionCMD::MISSION_RESERVED;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_workResButton_clicked(bool checked)
|
|
|
+{
|
|
|
+ if(checked)
|
|
|
+ workCMD = iv::brain::WorkCMD::WORK_RESERVED;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_remoteResButton_clicked(bool checked)
|
|
|
+{
|
|
|
+ if(checked)
|
|
|
+ remoteCtrlCMD = iv::brain::RemoteCtrlCMD::REMOTE_CTRL_RESERVED;
|
|
|
}
|