电机控制项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

694 lines
23 KiB

  1. /******************************motorcontroll.cpp文件说明**********************************
  2. * Descript :源文件,包含主窗口的页面设计、函数的实现、信号的连接
  3. * Author :caitiancheng
  4. * Date :2021_12_19
  5. *******************************************************************************/
  6. /***********************************头文件****************************************/
  7. #include "motorcontroll.h"
  8. #include "ui_motorcontroll.h"
  9. #include<QDateTime>
  10. #include <QCloseEvent>
  11. /***********************************类的声明和继承****************************************/
  12. MotorControll::MotorControll(QWidget *parent) :
  13. QMainWindow(parent),
  14. ui(new Ui::MotorControll)
  15. {
  16. ui->setupUi(this);
  17. //从站连接状态定时器
  18. StatuTimer=new QTimer;
  19. //时间显示定时器
  20. TimeShow=new QTimer;
  21. //监视栏定时器
  22. Monitor=new QTimer;
  23. //控件连接的信号和槽函数
  24. InitConnect();
  25. //状态栏界面设置初始化函数
  26. InitBarStatus();
  27. //监视栏舒适化函数
  28. InitMonitor();
  29. //未进行通信连接时设置按钮不可按
  30. //基础配置的按钮(3个)
  31. ui->pushButton_2->setEnabled(false);
  32. ui->pushButton_3->setEnabled(false);
  33. ui->pushButton_4->setEnabled(false);
  34. //点动的按钮(6个)
  35. ui->DotKeepRunBtn->setEnabled(false);
  36. ui->DotPositiveBtn->setEnabled(false);
  37. ui->DotReverseBtn->setEnabled(false);
  38. ui->DotSpeedUpdataBtn->setEnabled(false);
  39. ui->DotStepUpdataBtn->setEnabled(false);
  40. ui->DotStopRunBtn->setEnabled(false);
  41. //基础运动的按钮(8个)
  42. ui->RunKeepBtn->setEnabled(false);
  43. ui->RunPlaceUpdataBtn->setEnabled(false);
  44. ui->RunSpeedUpdataBtn->setEnabled(false);
  45. ui->RunStartAbsolutBtn->setEnabled(false);
  46. ui->RunStartPlaceModifyBtn->setEnabled(false);
  47. ui->RunStartRelativeBtn->setEnabled(false);
  48. ui->RunStopBtn->setEnabled(false);
  49. ui->RunTimeUpdataBtn->setEnabled(false);
  50. //多段运动的按钮(5个)+1个多选框
  51. ui->RunMoreAddRunBtn->setEnabled(false);
  52. ui->RunMoreDataUpdataBtn->setEnabled(false);
  53. ui->RunMoreKeepBtn->setEnabled(false);
  54. ui->RunMoreModelBox->setEnabled(false);
  55. ui->RunMoreStartBtn->setEnabled(false);
  56. ui->RunMoreStopBtn->setEnabled(false);
  57. }
  58. /******************************************************析构函数*****************************************************/
  59. MotorControll::~MotorControll()
  60. {
  61. //销毁状态栏显示相关
  62. delete ConStatusText;
  63. delete ConStatusImg;
  64. delete SalveStatusText;
  65. delete SalveStatusShow;
  66. //销毁定时器
  67. delete StatuTimer;
  68. delete TimeShow;
  69. delete Monitor;
  70. //销毁监视栏的监视对象
  71. int MonitorLogsLen=MonitorLogs.length();
  72. for(int i=0;i<MonitorLogsLen;i++)
  73. {
  74. delete MonitorLogs.at(i);
  75. }
  76. delete MonitorSM2001;
  77. delete MonitorSM2010;
  78. delete MonitorSM2011;
  79. delete MonitorSM2012;
  80. delete MonitorSD2042;
  81. delete MonitorSD2040;
  82. delete MonitorSD2001;
  83. delete MonitorSD2010;
  84. delete MonitorSD2008;
  85. delete MonitorSD2030;
  86. delete MonitorSD2032;
  87. delete MonitorSD2034;
  88. delete MonitorSD2036;
  89. delete ui;
  90. }
  91. /****************************InitBarStatus函数*********************************
  92. Function :初始化界面状态栏,进行相应的设置
  93. Output :
  94. *********************************************************************/
  95. void MotorControll::InitBarStatus()
  96. {
  97. ui->statusBar->setStyleSheet(QString("QStatusBar::item{border:0px}"));
  98. ConStatusText=new QLabel;
  99. ConStatusText->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
  100. ConStatusText->setText(QStringLiteral("通信状态:"));
  101. ui->statusBar->addPermanentWidget(ConStatusText);
  102. ConStatusImg=new QLabel;
  103. ConStatusImg->setStyleSheet(m_red_SheetStyle);
  104. ConStatusImg->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
  105. ui->statusBar->addPermanentWidget(ConStatusImg);
  106. SalveStatusText=new QLabel;
  107. SalveStatusText->setMinimumWidth(100);
  108. SalveStatusText->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
  109. SalveStatusText->setText(QStringLiteral("从站状态:"));
  110. ui->statusBar->addPermanentWidget(SalveStatusText);
  111. SalveStatusShow=new QLabel;
  112. SalveStatusShow->setMinimumWidth(60);
  113. SalveStatusShow->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
  114. SalveStatusShow->setText(QStringLiteral("其它"));
  115. ui->statusBar->addPermanentWidget(SalveStatusShow);
  116. }
  117. /****************************InitConnect函数*********************************
  118. Function :主窗口界面涉及的槽函数和信号的连接
  119. Output :
  120. *********************************************************************/
  121. void MotorControll::InitConnect()
  122. {
  123. connect(&Xcon,SIGNAL(CloseWin()),this,SLOT(Slot_ShowWin()));
  124. connect(&Apar,SIGNAL(CloseWin()),this,SLOT(Slot_ShowWin()));
  125. connect(&Movement,SIGNAL(CloseWin()),this,SLOT(Slot_ShowWin()));
  126. connect(StatuTimer,SIGNAL(timeout()),this,SLOT(Slot_Status()));
  127. connect(Monitor,SIGNAL(timeout()),this,SLOT(Slot_Monitor()));
  128. //开启从站连接状态定时器
  129. StatuTimer->start(1000);
  130. //开启监视栏定时器
  131. Monitor->start(500);
  132. //开启时间显示定时器
  133. TimeShow->start(1000);
  134. //连接定时器和timeout信号
  135. connect(TimeShow,&QTimer::timeout,[=](){
  136. ui->statusBar->showMessage(QDateTime::currentDateTime().toString( "yyyy年MM月dd日 hh:mm:ss"));
  137. });
  138. //多段运动启动与停止绑定
  139. connect(ui->RunMoreStopBtn,SIGNAL(clicked()),this,SLOT(on_RunStopBtn_clicked()));
  140. connect(ui->RunMoreKeepBtn,SIGNAL(clicked()),this,SLOT(on_RunKeepBtn_clicked()));
  141. }
  142. /****************************Slot_Status函数*********************************
  143. Function :从站状态显示函数
  144. Output :
  145. *********************************************************************/
  146. void MotorControll::Slot_Status()
  147. {
  148. //如果从站连接成功,变为绿色,开启按钮;否则是红色,关闭按钮
  149. if(ConStatus())
  150. {
  151. ConStatusImg->setStyleSheet(m_green_SheetStyle);
  152. //基础配置的按钮(3个)
  153. ui->pushButton_2->setEnabled(true);
  154. ui->pushButton_3->setEnabled(true);
  155. ui->pushButton_4->setEnabled(true);
  156. //点动的按钮(6个)
  157. ui->DotKeepRunBtn->setEnabled(true);
  158. ui->DotPositiveBtn->setEnabled(true);
  159. ui->DotReverseBtn->setEnabled(true);
  160. ui->DotSpeedUpdataBtn->setEnabled(true);
  161. ui->DotStepUpdataBtn->setEnabled(true);
  162. ui->DotStopRunBtn->setEnabled(true);
  163. //基础运动的按钮(8个)
  164. ui->RunKeepBtn->setEnabled(true);
  165. ui->RunPlaceUpdataBtn->setEnabled(true);
  166. ui->RunSpeedUpdataBtn->setEnabled(true);
  167. ui->RunStartAbsolutBtn->setEnabled(true);
  168. ui->RunStartPlaceModifyBtn->setEnabled(true);
  169. ui->RunStartRelativeBtn->setEnabled(true);
  170. ui->RunStopBtn->setEnabled(true);
  171. ui->RunTimeUpdataBtn->setEnabled(true);
  172. //多段运动的按钮(5个)+1个多选框
  173. ui->RunMoreAddRunBtn->setEnabled(true);
  174. ui->RunMoreDataUpdataBtn->setEnabled(true);
  175. ui->RunMoreKeepBtn->setEnabled(true);
  176. ui->RunMoreModelBox->setEnabled(true);
  177. ui->RunMoreStartBtn->setEnabled(true);
  178. ui->RunMoreStopBtn->setEnabled(true);
  179. }
  180. else
  181. {
  182. ConStatusImg->setStyleSheet(m_red_SheetStyle);
  183. //基础配置的按钮(3个)
  184. ui->pushButton_2->setEnabled(false);
  185. ui->pushButton_3->setEnabled(false);
  186. ui->pushButton_4->setEnabled(false);
  187. //点动的按钮(6个)
  188. ui->DotKeepRunBtn->setEnabled(false);
  189. ui->DotPositiveBtn->setEnabled(false);
  190. ui->DotReverseBtn->setEnabled(false);
  191. ui->DotSpeedUpdataBtn->setEnabled(false);
  192. ui->DotStepUpdataBtn->setEnabled(false);
  193. ui->DotStopRunBtn->setEnabled(false);
  194. //基础运动的按钮(8个)
  195. ui->RunKeepBtn->setEnabled(false);
  196. ui->RunPlaceUpdataBtn->setEnabled(false);
  197. ui->RunSpeedUpdataBtn->setEnabled(false);
  198. ui->RunStartAbsolutBtn->setEnabled(false);
  199. ui->RunStartPlaceModifyBtn->setEnabled(false);
  200. ui->RunStartRelativeBtn->setEnabled(false);
  201. ui->RunStopBtn->setEnabled(false);
  202. ui->RunTimeUpdataBtn->setEnabled(false);
  203. //多段运动的按钮(5个)+1个多选框
  204. ui->RunMoreAddRunBtn->setEnabled(false);
  205. ui->RunMoreDataUpdataBtn->setEnabled(false);
  206. ui->RunMoreKeepBtn->setEnabled(false);
  207. ui->RunMoreModelBox->setEnabled(false);
  208. ui->RunMoreStartBtn->setEnabled(false);
  209. ui->RunMoreStopBtn->setEnabled(false);
  210. }
  211. //显示对应的从站状态
  212. switch (SalveStatus()) {
  213. case 1:
  214. {
  215. SalveStatusShow->setText(QStringLiteral("INIT"));
  216. break;
  217. }
  218. case 2:
  219. {
  220. SalveStatusShow->setText(QStringLiteral("PreOP"));
  221. break;
  222. }
  223. case 4:
  224. {
  225. SalveStatusShow->setText(QStringLiteral("SafeOP"));
  226. break;
  227. }
  228. case 8:
  229. {
  230. SalveStatusShow->setText(QStringLiteral("OP"));
  231. break;
  232. }
  233. default:
  234. SalveStatusShow->setText(QStringLiteral("其它"));
  235. break;
  236. }
  237. }
  238. /****************************Slot_ShowWin函数*********************************
  239. Function :设置对话框为模态窗口
  240. Output :
  241. *********************************************************************/
  242. void MotorControll::Slot_ShowWin()
  243. {
  244. this->setWindowModality(Qt::ApplicationModal);
  245. }
  246. /****************************InitMonitor函数*********************************
  247. Function :初始化监视窗口的函数
  248. Output :
  249. *********************************************************************/
  250. void MotorControll::InitMonitor()
  251. {
  252. //添加表头
  253. QStringList TableHeadTitle;
  254. int TableHeadTitleLength;
  255. TableHeadTitle.push_back(QStringLiteral("寄存器"));
  256. TableHeadTitle.push_back(QStringLiteral("监控值"));
  257. TableHeadTitle.push_back(QStringLiteral("备注"));
  258. TableHeadTitleLength=TableHeadTitle.length();
  259. ui->DataMonitorTableWidget->setColumnCount(TableHeadTitleLength);
  260. ui->DataMonitorTableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
  261. for(int i=0;i<TableHeadTitleLength;i++)
  262. {
  263. TableHeadItem.push_back(new QTableWidgetItem(TableHeadTitle[i]));
  264. ui->DataMonitorTableWidget->setHorizontalHeaderItem(i,TableHeadItem[i]);
  265. }
  266. //添加监控值初始数据
  267. AddMonitorVal(&MonitorSM2001,"false","SM2001","轴运动标识");
  268. AddMonitorVal(&MonitorSM2010,"false","SM2010","使能标识");
  269. AddMonitorVal(&MonitorSM2011,"false","SM2011","正向点动标识");
  270. AddMonitorVal(&MonitorSM2012,"false","SM2012","反向点动标识");
  271. AddMonitorVal(&MonitorSD2042,"0","SD2042","点动速度");
  272. AddMonitorVal(&MonitorSD2040,"0","SD2040","点动步长");
  273. AddMonitorVal(&MonitorSD2001,"0","SD2001","运行模式");
  274. AddMonitorVal(&MonitorSD2010,"0","SD2010","当前运行速度");
  275. AddMonitorVal(&MonitorSD2008,"0","SD2008","当前位置");
  276. AddMonitorVal(&MonitorSD2030,"0","SD2030","设定位置");
  277. AddMonitorVal(&MonitorSD2032,"0","SD2032","设定速度");
  278. AddMonitorVal(&MonitorSD2034,"0","SD2034","设定加速时间");
  279. AddMonitorVal(&MonitorSD2036,"0","SD2036","设定减速时间");
  280. }
  281. /****************************AddMonitorVal函数*********************************
  282. Function :添加监视栏数据
  283. Output :
  284. *********************************************************************/
  285. void MotorControll::AddMonitorVal(QTableWidgetItem **Item,QString Value,QString QStrName,QString QStrVal)
  286. {
  287. int Row=ui->DataMonitorTableWidget->rowCount();
  288. ui->DataMonitorTableWidget->insertRow(Row);
  289. MonitorLogs.push_back(new QTableWidgetItem(QStrName));
  290. MonitorLogs.at(MonitorLogs.length()-1)->setTextAlignment(Qt::AlignCenter);
  291. ui->DataMonitorTableWidget->setItem(Row,0,MonitorLogs.at(MonitorLogs.length()-1));
  292. (*Item)=new QTableWidgetItem(Value);
  293. (*Item)->setTextAlignment(Qt::AlignCenter);
  294. ui->DataMonitorTableWidget->setItem(Row,1,*Item);
  295. MonitorLogs.push_back(new QTableWidgetItem(QStrVal));
  296. MonitorLogs.at(MonitorLogs.length()-1)->setTextAlignment(Qt::AlignCenter);
  297. ui->DataMonitorTableWidget->setItem(Row,2,MonitorLogs.at(MonitorLogs.length()-1));
  298. }
  299. /****************************SetMonitorVal函数*********************************
  300. Function :将需要监控的对象加入到监视表中
  301. Output :
  302. *********************************************************************/
  303. void MotorControll::SetMonitorVal(QTableWidgetItem *Item,bool Type,int addr)
  304. {
  305. if(Type)
  306. {
  307. Item->setText(QString::number(ReadSDShort(addr)));
  308. }else
  309. {
  310. if(ReadSMBool(addr))
  311. {
  312. Item->setText("true");
  313. }else
  314. {
  315. Item->setText("false");
  316. }
  317. }
  318. }
  319. /****************************Slot_Monitor函数*********************************
  320. Function :信号,当触发该信号时,将需要监视的对象设置到监视表中
  321. Output :
  322. *********************************************************************/
  323. void MotorControll::Slot_Monitor()
  324. {
  325. SetMonitorVal(MonitorSM2001,false,2001);
  326. SetMonitorVal(MonitorSM2010,false,2010);
  327. SetMonitorVal(MonitorSM2011,false,2011);
  328. SetMonitorVal(MonitorSM2012,false,2012);
  329. SetMonitorVal(MonitorSD2042,true,2042);
  330. SetMonitorVal(MonitorSD2040,true,2040);
  331. SetMonitorVal(MonitorSD2001,true,2001);
  332. SetMonitorVal(MonitorSD2010,true,2010);
  333. SetMonitorVal(MonitorSD2008,true,2008);
  334. SetMonitorVal(MonitorSD2030,true,2030);
  335. SetMonitorVal(MonitorSD2032,true,2032);
  336. SetMonitorVal(MonitorSD2034,true,2034);
  337. SetMonitorVal(MonitorSD2036,true,2036);
  338. }
  339. /****************************通信连接按钮的槽函数函数*********************************
  340. Function :点击通信连接按钮,会触发该槽函数
  341. Output :
  342. *********************************************************************/
  343. void MotorControll::on_pushButton_clicked()
  344. {
  345. Xcon.setWindowFlags(Qt::Dialog|Qt::WindowCloseButtonHint);
  346. Xcon.setWindowModality(Qt::ApplicationModal);
  347. Xcon.show();
  348. }
  349. /****************************C运动相关参数配置的槽函数*********************************
  350. Function :点击C运动参数配置按钮,会触发该槽函数
  351. Output :
  352. *********************************************************************/
  353. void MotorControll::on_pushButton_2_clicked()
  354. {
  355. Apar.setWindowFlags(Qt::Dialog|Qt::WindowCloseButtonHint|Qt::WindowMaximizeButtonHint);
  356. Apar.setWindowModality(Qt::ApplicationModal);
  357. Apar.show();
  358. }
  359. /****************************************************点动模块*****************************************************/
  360. /****************************开启电机的槽函数*********************************
  361. Function :点击开启电机按钮,会触发该槽函数
  362. Output :
  363. *********************************************************************/
  364. void MotorControll::on_pushButton_3_clicked()
  365. {
  366. //关闭
  367. WriteMBool(5,false);
  368. WriteMBool(10,false);
  369. WriteMBool(15,false);
  370. WriteMBool(20,false);
  371. WriteMBool(25,false);
  372. WriteMBool(30,false);
  373. WriteMBool(35,false);
  374. //使能
  375. WriteMBool(0,true);
  376. }
  377. /****************************关闭电机的槽函数*********************************
  378. Function :点击关闭电机按钮,会触发该槽函数
  379. Output :
  380. *********************************************************************/
  381. void MotorControll::on_pushButton_4_clicked()
  382. {
  383. //关闭
  384. WriteMBool(5,false);
  385. WriteMBool(10,false);
  386. WriteMBool(15,false);
  387. WriteMBool(20,false);
  388. WriteMBool(25,false);
  389. WriteMBool(30,false);
  390. WriteMBool(35,false);
  391. WriteMBool(0,false);
  392. }
  393. /****************************更新步长的槽函数*********************************
  394. Function :点击更新步长按钮,会触发该槽函数
  395. Output :
  396. *********************************************************************/
  397. void MotorControll::on_DotStepUpdataBtn_clicked()
  398. {
  399. short value=ui->DotStepLedit->text().toShort();
  400. WriteDShort(0,value);
  401. }
  402. /****************************更新点动速度的槽函数*********************************
  403. Function :点击更新点动速度按钮,会触发该槽函数
  404. Output :
  405. *********************************************************************/
  406. void MotorControll::on_DotSpeedUpdataBtn_clicked()
  407. {
  408. short value=ui->DotSpeedLedit->text().toShort();
  409. WriteDShort(50,value);
  410. }
  411. /****************************正向点动的槽函数*********************************
  412. Function :点击正向点动按钮,会触发该槽函数
  413. Output :
  414. *********************************************************************/
  415. void MotorControll::on_DotPositiveBtn_clicked()
  416. {
  417. WriteMBool(10,false);
  418. WriteMBool(5,true);
  419. }
  420. /****************************反向点动的槽函数*********************************
  421. Function :点击反向点动按钮,会触发该槽函数
  422. Output :
  423. *********************************************************************/
  424. void MotorControll::on_DotReverseBtn_clicked()
  425. {
  426. WriteMBool(5,false);
  427. WriteMBool(10,true);
  428. }
  429. /****************************停止运动的槽函数*********************************
  430. Function :点击停止运动按钮,会触发该槽函数
  431. Output :
  432. *********************************************************************/
  433. void MotorControll::on_DotStopRunBtn_clicked()
  434. {
  435. WriteMBool(15,true);
  436. }
  437. /****************************继续运动的槽函数*********************************
  438. Function :点击继续运动按钮,会触发该槽函数
  439. Output :
  440. *********************************************************************/
  441. void MotorControll::on_DotKeepRunBtn_clicked()
  442. {
  443. WriteMBool(15,false);
  444. }
  445. /****************************************************基础运动模块*****************************************************/
  446. /****************************更新位置的槽函数*********************************
  447. Function :点击更新位置按钮,会触发该槽函数
  448. Output :
  449. *********************************************************************/
  450. void MotorControll::on_RunPlaceUpdataBtn_clicked()
  451. {
  452. int value=ui->RunPlaceLedit->text().toInt();
  453. WriteDInt(100,value);
  454. }
  455. /****************************更新速度的槽函数*********************************
  456. Function :点击更新速度按钮,会触发该槽函数
  457. Output :
  458. *********************************************************************/
  459. void MotorControll::on_RunSpeedUpdataBtn_clicked()
  460. {
  461. int value=ui->RunSpeedLedit->text().toInt();
  462. WriteDInt(150,value);
  463. }
  464. /****************************更新时间的槽函数*********************************
  465. Function :点击更新时间按钮,会触发该槽函数
  466. Output :
  467. *********************************************************************/
  468. void MotorControll::on_RunTimeUpdataBtn_clicked()
  469. {
  470. int value=ui->RunTimeLedit->text().toInt();
  471. WriteDInt(200,value);
  472. }
  473. /****************************修改位置的槽函数*********************************
  474. Function :点击修改位置按钮,会触发该槽函数
  475. Output :
  476. *********************************************************************/
  477. void MotorControll::on_RunStartPlaceModifyBtn_clicked()
  478. {
  479. int value=ui->RunStartPlaceLedit->text().toInt();
  480. WriteDInt(450,value);
  481. WriteMBool(40,true);
  482. WriteMBool(40,false);
  483. }
  484. /****************************绝对运动的槽函数*********************************
  485. Function :点击绝对运动按钮,会触发该槽函数
  486. Output :
  487. *********************************************************************/
  488. void MotorControll::on_RunStartAbsolutBtn_clicked()
  489. {
  490. WriteMBool(30,true);
  491. WriteMBool(30,false);
  492. }
  493. /****************************相对运动的槽函数*********************************
  494. Function :点击相对运动按钮,会触发该槽函数
  495. Output :
  496. *********************************************************************/
  497. void MotorControll::on_RunStartRelativeBtn_clicked()
  498. {
  499. WriteMBool(25,true);
  500. WriteMBool(25,false);
  501. }
  502. /****************************停止运动的槽函数*********************************
  503. Function :点击停止运动按钮,会触发该槽函数
  504. Output :
  505. *********************************************************************/
  506. void MotorControll::on_RunStopBtn_clicked()
  507. {
  508. WriteMBool(20,false);
  509. WriteMBool(15,true);
  510. }
  511. /****************************继续运动的槽函数*********************************
  512. Function :点击继续运动按钮,会触发该槽函数
  513. Output :
  514. *********************************************************************/
  515. void MotorControll::on_RunKeepBtn_clicked()
  516. {
  517. WriteMBool(15,false);
  518. WriteMBool(20,true);
  519. }
  520. /****************************************************多段运动模块*****************************************************/
  521. /****************************添加运动的槽函数*********************************
  522. Function :点击添加运动按钮,会触发该槽函数
  523. Output :
  524. *********************************************************************/
  525. void MotorControll::on_RunMoreAddRunBtn_clicked()
  526. {
  527. Movement.setWindowFlags(Qt::Dialog|Qt::WindowCloseButtonHint|Qt::WindowMaximizeButtonHint);
  528. Movement.setWindowModality(Qt::ApplicationModal);
  529. Movement.show();
  530. }
  531. /****************************更新数据的槽函数*********************************
  532. Function :点击更新数据按钮,会触发该槽函数
  533. Output :
  534. *********************************************************************/
  535. void MotorControll::on_RunMoreDataUpdataBtn_clicked()
  536. {
  537. int AddValue=ui->RunMoreAddSpeedTimeLedit->text().toInt();
  538. int SubValue=ui->RunMoreSubSpeedTimeLedit->text().toInt();
  539. int RunModel=ui->RunMoreModelBox->currentIndex();
  540. WriteDInt(400,RunModel);
  541. WriteDInt(404,AddValue);
  542. WriteDInt(406,SubValue);
  543. }
  544. /****************************启动运动的槽函数*********************************
  545. Function :点击启动运动按钮,会触发该槽函数
  546. Output :
  547. *********************************************************************/
  548. void MotorControll::on_RunMoreStartBtn_clicked()
  549. {
  550. WriteMBool(35,true);
  551. WriteMBool(35,false);
  552. }
  553. /****************************closeEvent函数*********************************
  554. Function :窗口关闭事件函数
  555. Output :
  556. *********************************************************************/
  557. void MotorControll::closeEvent(QCloseEvent *event)
  558. {
  559. QMessageBox::StandardButton Value=QMessageBox::question(this,QStringLiteral("退出提示"),QStringLiteral("确认退出程序?"));
  560. if(Value==QMessageBox::Yes)
  561. {
  562. emit CloseWin();
  563. event->accept();
  564. }else
  565. {
  566. event->ignore();
  567. }
  568. }