widget.cpp 3.3 KB

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