widget.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #include "widget.h"
  2. #include "TransmitterSwitchInfo.h"
  3. #include "ui_widget.h"
  4. #include "LHQLogAPI.h"
  5. #include "lhstylemanager.h"
  6. #include "TransmitterswitchInfo.h"
  7. Widget::Widget(QWidget *parent) :
  8. QWidget(parent),
  9. ui(new Ui::Widget)
  10. {
  11. ui->setupUi(this);
  12. /* 设置暗色 */
  13. // LHStyleMgr->SetSkinStyle("Dark");
  14. m_tSwitch = new TransmitterSwitch();
  15. /* 设置一个布局 */
  16. m_layout = new QVBoxLayout(ui->widget_content);
  17. m_layout->addWidget(m_tSwitch);
  18. ui->widget_content->setLayout(m_layout);
  19. /* 设置边距为0 */
  20. m_layout->setMargin(20);
  21. m_layout->setSpacing(0);
  22. /* 设置参数 */
  23. // m_tSwitch->setQSS(":/QSS/QSS/TransmitterSwitch_dark.qss");
  24. /* 初始化WebAPI */
  25. m_tSwitch->setWebAPIInfo("http://192.1.3.133:31000/v6/", "2e36b53ccd2a433b9a803b98d683ed91", "TMS");
  26. /* 添加设备信息,测试用 */
  27. addTestDevice();
  28. }
  29. Widget::~Widget()
  30. {
  31. if(m_tSwitch != nullptr)
  32. {
  33. delete m_tSwitch;
  34. m_tSwitch = nullptr;
  35. }
  36. if(m_layout != nullptr)
  37. {
  38. delete m_layout;
  39. m_layout = nullptr;
  40. }
  41. delete ui;
  42. }
  43. /* 导入数据按钮 */
  44. void Widget::on_pBtn_getData_clicked()
  45. {
  46. if(m_tSwitch == nullptr)
  47. {
  48. LH_WRITE_ERROR("TransmitterSwitch is nullptr");
  49. return;
  50. }
  51. m_tSwitch->getExecPlanFromEQM();
  52. }
  53. /* 导出数据按钮 */
  54. void Widget::on_pBtn_saveData_clicked()
  55. {
  56. if(m_tSwitch == nullptr)
  57. {
  58. LH_WRITE_ERROR("TransmitterSwitch is nullptr");
  59. return;
  60. }
  61. m_tSwitch->saveExecPlanToEQM();
  62. }
  63. /* 添加测试用的设备信息 */
  64. void Widget::addTestDevice()
  65. {
  66. auto devType = DevTypeContainer.getDevType(955);
  67. if(devType.PTTypeCode == -1)
  68. {
  69. return;
  70. }
  71. DeviceInfo devInfo;
  72. devInfo.devName = "衢州台主发射机";
  73. devInfo.PTTypeCode = 955;
  74. devInfo.DTID = 1;
  75. devInfo.DID = 1;
  76. devInfo.ChannelID = 1;
  77. devInfo.DevType = devType;
  78. DeviceContainer.addDevice(devInfo);
  79. devInfo.devName = "衢州台备发射机";
  80. devInfo.PTTypeCode = 955;
  81. devInfo.DTID = 1;
  82. devInfo.DID = 2;
  83. devInfo.ChannelID = 2;
  84. devInfo.DevType = devType;
  85. DeviceContainer.addDevice(devInfo);
  86. }