widget.cpp 3.0 KB

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