电机控制项目
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

79 lignes
2.3 KiB

  1. /******************************xnetconnect.cpp文件说明**********************************
  2. * Descript :源文件,包含通信配置窗口的函数实现
  3. * Author :caitiancheng
  4. * Date :2021_12_19
  5. *******************************************************************************/
  6. /***********************************头文件****************************************/
  7. #include "xnetconnect.h"
  8. #include "ui_xnetconnect.h"
  9. #include "Base.h"
  10. #include <QCloseEvent>
  11. /***********************************类的声明和继承****************************************/
  12. XnetConnect::XnetConnect(QWidget *parent) :
  13. QWidget(parent),
  14. ui(new Ui::XnetConnect)
  15. {
  16. ui->setupUi(this);
  17. //禁止修改窗体大小
  18. setFixedSize(this->width(), this->height());
  19. ServiceFlag=false;
  20. //设置窗口标题
  21. setWindowTitle("通信连接");
  22. }
  23. /****************************closeEvent函数*********************************
  24. Function :窗口关闭事件函数
  25. Output :
  26. *********************************************************************/
  27. void XnetConnect::closeEvent(QCloseEvent *event)
  28. {
  29. emit CloseWin();
  30. event->accept();
  31. }
  32. /****************************启动服务槽函数函数*********************************
  33. Function :点击启动服务会触发该槽函数
  34. Output :
  35. *********************************************************************/
  36. void XnetConnect::on_CtrlServiceBtn_clicked()
  37. {
  38. Base TempBase;
  39. if(!ServiceFlag)
  40. {
  41. QString NeetSetIp=ui->NeedIPEdit->text();
  42. SetXNetClient(NeetSetIp.toLatin1().data());
  43. if(TempBase.ConStatus())
  44. {
  45. ServiceFlag=true;
  46. ui->CtrlServiceBtn->setText(QStringLiteral("关闭服务"));
  47. QMessageBox::information(this,QStringLiteral("启动提示"),QStringLiteral("通信成功"));
  48. }else
  49. {
  50. QMessageBox::information(this,QStringLiteral("启动提示"),QStringLiteral("通信失败"));
  51. }
  52. }else
  53. {
  54. CloseXNetClient();
  55. ServiceFlag=false;
  56. ui->CtrlServiceBtn->setText(QStringLiteral("开启服务"));
  57. QMessageBox::information(this,QStringLiteral("关闭提示"),QStringLiteral("关闭成功"));
  58. }
  59. }
  60. /******************************************************析构函数*****************************************************/
  61. XnetConnect::~XnetConnect()
  62. {
  63. delete ui;
  64. }