#include "widget.h" #include "ui_widget.h" // #include "LHQLogAPI.h" // #include "lhstylemanager.h" #include "spdlog/spdlog.h" // #include "TransmitterswitchInfo.h" // #include "lhtranmitterswitch.h" Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); m_tSwitch = new LHTransmitterSwitchAPI(); if(m_tSwitch->loadLibrary()) { SPDLOG_INFO("load library success"); }else { SPDLOG_ERROR("load library failed"); } /* 设置一个布局 */ // m_layout = new QVBoxLayout(ui->widget_content); // m_layout->addWidget(m_tSwitch); // ui->widget_content->setLayout(m_layout); /* 设置边距为0 */ // m_layout->setMargin(20); // m_layout->setSpacing(0); /* 初始化WebAPI */ InitData initData; initData.url = "http://192.1.3.133:31000/v6/"; initData.serverID = "2e36b53ccd2a433b9a803b98d683ed91"; initData.serverKey = "TMS"; m_tSwitch->DoInit(&initData); m_tSwitch->DoCreateWindow(1, ui->widget_content); // m_tSwitch->DoGetExecPlanFromEQM(); m_style = 1; // m_tSwitch->setWebAPIInfo("http://192.1.3.133:31000/v6/", "2e36b53ccd2a433b9a803b98d683ed91", "TMS"); /* 添加设备信息,测试用 */ // addTestDevice(); SPDLOG_INFO("Widget init success"); } Widget::~Widget() { // if(m_tSwitch != nullptr) // { // delete m_tSwitch; // m_tSwitch = nullptr; // } // if(m_layout != nullptr) // { // delete m_layout; // m_layout = nullptr; // } delete ui; } /* 导入数据按钮 */ void Widget::on_pBtn_getData_clicked() { if(m_tSwitch == nullptr) { SPDLOG_DEBUG("TransmitterSwitch is nullptr"); return; } m_tSwitch->DoGetExecPlanFromEQM(); } /* 导出数据按钮 */ void Widget::on_pBtn_saveData_clicked() { if(m_tSwitch == nullptr) { SPDLOG_DEBUG("TransmitterSwitch is nullptr"); return; } m_tSwitch->DoSaveExecPlanToEQM(); } /* 切换亮色/暗色的按钮 */ void Widget::on_pBtn_light_dark_clicked() { if(m_tSwitch == nullptr) { SPDLOG_DEBUG("TransmitterSwitch is nullptr"); return; } if(m_style == 0) { m_style = 1; /* 当前是亮色,设置为暗色 */ m_tSwitch->DoShowWindow(m_style, true); }else { m_style = 0; m_tSwitch->DoShowWindow(m_style, true); } } /* 添加测试用的设备信息 */ // void Widget::addTestDevice() // { // auto devType = DevTypeContainer.getDevType(955); // if(devType.PTTypeCode == -1) // { // return; // } // DeviceInfo devInfo; // devInfo.devName = "衢州台主发射机"; // devInfo.PTTypeCode = 955; // devInfo.DTID = 1; // devInfo.DID = 1; // devInfo.ChannelID = 1; // devInfo.DevType = devType; // DeviceContainer.addDevice(devInfo); // devInfo.devName = "衢州台备发射机"; // devInfo.PTTypeCode = 955; // devInfo.DTID = 1; // devInfo.DID = 2; // devInfo.ChannelID = 2; // devInfo.DevType = devType; // DeviceContainer.addDevice(devInfo); // }