widget.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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_tSwitch->DoGetExecPlanFromEQM();
  35. m_style = 1;
  36. // m_tSwitch->setWebAPIInfo("http://192.1.3.133:31000/v6/", "2e36b53ccd2a433b9a803b98d683ed91", "TMS");
  37. /* 添加设备信息,测试用 */
  38. // addTestDevice();
  39. SPDLOG_INFO("Widget init success");
  40. }
  41. Widget::~Widget()
  42. {
  43. // if(m_tSwitch != nullptr)
  44. // {
  45. // delete m_tSwitch;
  46. // m_tSwitch = nullptr;
  47. // }
  48. // if(m_layout != nullptr)
  49. // {
  50. // delete m_layout;
  51. // m_layout = nullptr;
  52. // }
  53. delete ui;
  54. }
  55. /* 导入数据按钮 */
  56. void Widget::on_pBtn_getData_clicked()
  57. {
  58. if(m_tSwitch == nullptr)
  59. {
  60. SPDLOG_DEBUG("TransmitterSwitch is nullptr");
  61. return;
  62. }
  63. m_tSwitch->DoGetExecPlanFromEQM();
  64. }
  65. /* 导出数据按钮 */
  66. void Widget::on_pBtn_saveData_clicked()
  67. {
  68. if(m_tSwitch == nullptr)
  69. {
  70. SPDLOG_DEBUG("TransmitterSwitch is nullptr");
  71. return;
  72. }
  73. m_tSwitch->DoSaveExecPlanToEQM();
  74. }
  75. /* 切换亮色/暗色的按钮 */
  76. void Widget::on_pBtn_light_dark_clicked()
  77. {
  78. if(m_tSwitch == nullptr)
  79. {
  80. SPDLOG_DEBUG("TransmitterSwitch is nullptr");
  81. return;
  82. }
  83. if(m_style == 0)
  84. {
  85. m_style = 1;
  86. /* 当前是亮色,设置为暗色 */
  87. m_tSwitch->DoShowWindow(m_style, true);
  88. }else
  89. {
  90. m_style = 0;
  91. m_tSwitch->DoShowWindow(m_style, true);
  92. }
  93. }
  94. /* 添加测试用的设备信息 */
  95. // void Widget::addTestDevice()
  96. // {
  97. // auto devType = DevTypeContainer.getDevType(955);
  98. // if(devType.PTTypeCode == -1)
  99. // {
  100. // return;
  101. // }
  102. // DeviceInfo devInfo;
  103. // devInfo.devName = "衢州台主发射机";
  104. // devInfo.PTTypeCode = 955;
  105. // devInfo.DTID = 1;
  106. // devInfo.DID = 1;
  107. // devInfo.ChannelID = 1;
  108. // devInfo.DevType = devType;
  109. // DeviceContainer.addDevice(devInfo);
  110. // devInfo.devName = "衢州台备发射机";
  111. // devInfo.PTTypeCode = 955;
  112. // devInfo.DTID = 1;
  113. // devInfo.DID = 2;
  114. // devInfo.ChannelID = 2;
  115. // devInfo.DevType = devType;
  116. // DeviceContainer.addDevice(devInfo);
  117. // }