widget.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #include "widget.h"
  2. #include "ui_widget.h"
  3. // #include "LHQLogAPI.h"
  4. // #include "lhstylemanager.h"
  5. #include "spdlog/spdlog.h"
  6. // #include "TransmitterswitchInfo.h"
  7. // #include "lhtranmitterswitch.h"
  8. Widget::Widget(QWidget *parent) :
  9. QWidget(parent),
  10. ui(new Ui::Widget)
  11. {
  12. ui->setupUi(this);
  13. m_tSwitch = new LHTransmitterSwitchAPI();
  14. if(m_tSwitch->loadLibrary())
  15. {
  16. SPDLOG_INFO("load library success");
  17. }else {
  18. SPDLOG_ERROR("load library failed");
  19. }
  20. /* 设置一个布局 */
  21. // m_layout = new QVBoxLayout(ui->widget_content);
  22. // m_layout->addWidget(m_tSwitch);
  23. // ui->widget_content->setLayout(m_layout);
  24. /* 设置边距为0 */
  25. // m_layout->setMargin(20);
  26. // m_layout->setSpacing(0);
  27. /* 初始化WebAPI */
  28. InitData initData;
  29. initData.url = "http://192.1.3.133:31000/v6/";
  30. initData.serverID = "2e36b53ccd2a433b9a803b98d683ed91";
  31. initData.serverKey = "TMS";
  32. m_tSwitch->DoInit(&initData);
  33. m_tSwitch->DoCreateWindow(1, ui->widget_content);
  34. m_style = 1;
  35. // m_tSwitch->setWebAPIInfo("http://192.1.3.133:31000/v6/", "2e36b53ccd2a433b9a803b98d683ed91", "TMS");
  36. /* 添加设备信息,测试用 */
  37. // addTestDevice();
  38. SPDLOG_INFO("Widget init success");
  39. }
  40. Widget::~Widget()
  41. {
  42. // if(m_tSwitch != nullptr)
  43. // {
  44. // delete m_tSwitch;
  45. // m_tSwitch = nullptr;
  46. // }
  47. // if(m_layout != nullptr)
  48. // {
  49. // delete m_layout;
  50. // m_layout = nullptr;
  51. // }
  52. delete ui;
  53. }
  54. /* 导入数据按钮 */
  55. void Widget::on_pBtn_getData_clicked()
  56. {
  57. if(m_tSwitch == nullptr)
  58. {
  59. SPDLOG_DEBUG("TransmitterSwitch is nullptr");
  60. return;
  61. }
  62. m_tSwitch->DoGetExecPlanFromEQM();
  63. }
  64. /* 导出数据按钮 */
  65. void Widget::on_pBtn_saveData_clicked()
  66. {
  67. if(m_tSwitch == nullptr)
  68. {
  69. SPDLOG_DEBUG("TransmitterSwitch is nullptr");
  70. return;
  71. }
  72. m_tSwitch->DoSaveExecPlanToEQM();
  73. }
  74. /* 切换亮色/暗色的按钮 */
  75. void Widget::on_pBtn_light_dark_clicked()
  76. {
  77. if(m_tSwitch == nullptr)
  78. {
  79. SPDLOG_DEBUG("TransmitterSwitch is nullptr");
  80. return;
  81. }
  82. if(m_style == 0)
  83. {
  84. m_style = 1;
  85. /* 当前是亮色,设置为暗色 */
  86. m_tSwitch->DoShowWindow(m_style, true);
  87. }else
  88. {
  89. m_style = 0;
  90. m_tSwitch->DoShowWindow(m_style, true);
  91. }
  92. }
  93. /* 添加测试用的设备信息 */
  94. // void Widget::addTestDevice()
  95. // {
  96. // auto devType = DevTypeContainer.getDevType(955);
  97. // if(devType.PTTypeCode == -1)
  98. // {
  99. // return;
  100. // }
  101. // DeviceInfo devInfo;
  102. // devInfo.devName = "衢州台主发射机";
  103. // devInfo.PTTypeCode = 955;
  104. // devInfo.DTID = 1;
  105. // devInfo.DID = 1;
  106. // devInfo.ChannelID = 1;
  107. // devInfo.DevType = devType;
  108. // DeviceContainer.addDevice(devInfo);
  109. // devInfo.devName = "衢州台备发射机";
  110. // devInfo.PTTypeCode = 955;
  111. // devInfo.DTID = 1;
  112. // devInfo.DID = 2;
  113. // devInfo.ChannelID = 2;
  114. // devInfo.DevType = devType;
  115. // DeviceContainer.addDevice(devInfo);
  116. // }