diff --git a/TSI_Config.pro b/TSI_Config.pro index 455498f..7b967e4 100644 --- a/TSI_Config.pro +++ b/TSI_Config.pro @@ -16,6 +16,7 @@ SOURCES += \ main.cpp \ mainwindow.cpp \ radial_vibration.cpp \ + relaysetting.cpp \ seismic_monitor.cpp \ setpoint.cpp \ singlerelay.cpp \ @@ -30,6 +31,7 @@ HEADERS += \ keyphase.h \ mainwindow.h \ radial_vibration.h \ + relaysetting.h \ seismic_monitor.h \ setpoint.h \ singlerelay.h \ @@ -41,6 +43,7 @@ FORMS += \ keyphase.ui \ mainwindow.ui \ radial_vibration.ui \ + relaysetting.ui \ seismic_monitor.ui \ setpoint.ui \ singlerelay.ui \ diff --git a/data_config.h b/data_config.h index 28ba88a..070e636 100644 --- a/data_config.h +++ b/data_config.h @@ -7,6 +7,8 @@ typedef unsigned char uint8_t; typedef unsigned short uint16_t; +extern QString g_strServerIp; // 服务端IP + #define CHANNLE_COUNT 4 typedef struct { int slot; @@ -20,7 +22,8 @@ enum CMTCommand { kEigenvalueCmd = 1, kExceptionInfo = 2, kUpgradeCard = 3, - kGetVersionInfo = 4 + kGetVersionInfo = 4, + kRelaySetting = 5 }; enum SlotType{ POWER = 10, @@ -107,6 +110,17 @@ typedef struct { uint8_t sw; // 软件版本号 char fpga_data[9]; // fpga版本日期 } VersionRsp; + +typedef struct { + uint8_t card_id; // 0xff是本机,其它子卡是1~15 + uint8_t led_id; // ok 灯 0xff,rx/tx 灯 0xf1,其他 1 ~ 16 + uint8_t led_operate; // 0 OFF,1 ON,2 红色,3 绿色,4 红色1Hz闪烁,5 红色2Hz闪烁,6 绿色闪烁 +} RelaySettingReq; + +typedef struct { + uint8_t code; +} RelaySettingRsp; + #pragma pack() #endif // DATA_CONFIG_H diff --git a/mainwindow.cpp b/mainwindow.cpp index 34bb30d..3a97355 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -16,12 +16,20 @@ #include #include #include +#include "relaysetting.h" + +QString g_strServerIp; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); + QMenuBar* menuBar = this->menuBar(); + this->setMenuBar(menuBar); //添加到对象树 + menuBar->addMenu(ui->menu_tool); + //添加信号槽 + QObject::connect(ui->action_realy, &QAction::triggered, this, &MainWindow::onMenuAction_relay); slot = -1; btnGroup_slot = new QButtonGroup(this); btnGroup_slot->addButton(ui->pushButton_slot3); @@ -48,7 +56,7 @@ MainWindow::MainWindow(QWidget *parent) connect(btnGroup_slot, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(OnButtonGroup(QAbstractButton *))); QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini",QSettings::IniFormat); - m_strServerIp = settingsread.value("Server/IP").toString(); + g_strServerIp = settingsread.value("Server/IP").toString(); } MainWindow::~MainWindow() @@ -418,6 +426,13 @@ void MainWindow::on_pushButton_point_name_clicked() ui->pushButton_alarm->setChecked(false); } +void MainWindow::onMenuAction_relay() +{ + qDebug() << " onMenuAction_relay " << endl; + RelaySetting *relay_setting = new RelaySetting(); + relay_setting->setWindowModality(Qt::ApplicationModal); + relay_setting->show(); +} void MainWindow::on_pushButton_save_clicked() { @@ -475,7 +490,7 @@ void MainWindow::sendUpgradePackage(int slot) QTcpSocket socket; // 连接到服务器 - socket.connectToHost(m_strServerIp, 10000); + socket.connectToHost(g_strServerIp, 10000); if (!socket.waitForConnected()) { qDebug() << "Connection failed!"; return; @@ -567,7 +582,7 @@ void MainWindow::getVersion(int slot) // 连接到服务器 QTcpSocket socket; // 连接到服务器 - socket.connectToHost(m_strServerIp, 10000); + socket.connectToHost(g_strServerIp, 10000); if (!socket.waitForConnected()) { qDebug() << "Connection failed!"; return; diff --git a/mainwindow.h b/mainwindow.h index 740f2fb..a941218 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -11,6 +11,8 @@ QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE + + class MainWindow : public QMainWindow { Q_OBJECT @@ -33,7 +35,7 @@ private: QMap map_slot_config; QButtonGroup * btnGroup_slot = nullptr; - QString m_strServerIp; // 服务端IP + int slot; void createMenu(); @@ -46,7 +48,7 @@ private: void getVersion(int slot); private slots: - + void onMenuAction_relay(); void OnButtonGroup(QAbstractButton *); void onMenuActionTriggered(); diff --git a/mainwindow.ui b/mainwindow.ui index e62b7b6..eebde1a 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -1121,8 +1121,16 @@ 帮助 + + + 工具 + + + + + @@ -1135,6 +1143,16 @@ Open + + + 继电器配置 + + + + + 校时功能 + +