添加继电器设置

This commit is contained in:
zhangsheng 2025-03-04 16:00:19 +08:00
parent 964affc137
commit 26d44b1edf
5 changed files with 58 additions and 6 deletions

View File

@ -16,6 +16,7 @@ SOURCES += \
main.cpp \ main.cpp \
mainwindow.cpp \ mainwindow.cpp \
radial_vibration.cpp \ radial_vibration.cpp \
relaysetting.cpp \
seismic_monitor.cpp \ seismic_monitor.cpp \
setpoint.cpp \ setpoint.cpp \
singlerelay.cpp \ singlerelay.cpp \
@ -30,6 +31,7 @@ HEADERS += \
keyphase.h \ keyphase.h \
mainwindow.h \ mainwindow.h \
radial_vibration.h \ radial_vibration.h \
relaysetting.h \
seismic_monitor.h \ seismic_monitor.h \
setpoint.h \ setpoint.h \
singlerelay.h \ singlerelay.h \
@ -41,6 +43,7 @@ FORMS += \
keyphase.ui \ keyphase.ui \
mainwindow.ui \ mainwindow.ui \
radial_vibration.ui \ radial_vibration.ui \
relaysetting.ui \
seismic_monitor.ui \ seismic_monitor.ui \
setpoint.ui \ setpoint.ui \
singlerelay.ui \ singlerelay.ui \

View File

@ -7,6 +7,8 @@
typedef unsigned char uint8_t; typedef unsigned char uint8_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
extern QString g_strServerIp; // 服务端IP
#define CHANNLE_COUNT 4 #define CHANNLE_COUNT 4
typedef struct { typedef struct {
int slot; int slot;
@ -20,7 +22,8 @@ enum CMTCommand {
kEigenvalueCmd = 1, kEigenvalueCmd = 1,
kExceptionInfo = 2, kExceptionInfo = 2,
kUpgradeCard = 3, kUpgradeCard = 3,
kGetVersionInfo = 4 kGetVersionInfo = 4,
kRelaySetting = 5
}; };
enum SlotType{ enum SlotType{
POWER = 10, POWER = 10,
@ -107,6 +110,17 @@ typedef struct {
uint8_t sw; // 软件版本号 uint8_t sw; // 软件版本号
char fpga_data[9]; // fpga版本日期 char fpga_data[9]; // fpga版本日期
} VersionRsp; } VersionRsp;
typedef struct {
uint8_t card_id; // 0xff是本机其它子卡是115
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() #pragma pack()
#endif // DATA_CONFIG_H #endif // DATA_CONFIG_H

View File

@ -16,12 +16,20 @@
#include <stdio.h> #include <stdio.h>
#include <QSysInfo> #include <QSysInfo>
#include <qsettings.h> #include <qsettings.h>
#include "relaysetting.h"
QString g_strServerIp;
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
, ui(new Ui::MainWindow) , ui(new Ui::MainWindow)
{ {
ui->setupUi(this); 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; slot = -1;
btnGroup_slot = new QButtonGroup(this); btnGroup_slot = new QButtonGroup(this);
btnGroup_slot->addButton(ui->pushButton_slot3); btnGroup_slot->addButton(ui->pushButton_slot3);
@ -48,7 +56,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(btnGroup_slot, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(OnButtonGroup(QAbstractButton *))); connect(btnGroup_slot, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(OnButtonGroup(QAbstractButton *)));
QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini",QSettings::IniFormat); 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() MainWindow::~MainWindow()
@ -418,6 +426,13 @@ void MainWindow::on_pushButton_point_name_clicked()
ui->pushButton_alarm->setChecked(false); 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() void MainWindow::on_pushButton_save_clicked()
{ {
@ -475,7 +490,7 @@ void MainWindow::sendUpgradePackage(int slot)
QTcpSocket socket; QTcpSocket socket;
// 连接到服务器 // 连接到服务器
socket.connectToHost(m_strServerIp, 10000); socket.connectToHost(g_strServerIp, 10000);
if (!socket.waitForConnected()) { if (!socket.waitForConnected()) {
qDebug() << "Connection failed!"; qDebug() << "Connection failed!";
return; return;
@ -567,7 +582,7 @@ void MainWindow::getVersion(int slot)
// 连接到服务器 // 连接到服务器
QTcpSocket socket; QTcpSocket socket;
// 连接到服务器 // 连接到服务器
socket.connectToHost(m_strServerIp, 10000); socket.connectToHost(g_strServerIp, 10000);
if (!socket.waitForConnected()) { if (!socket.waitForConnected()) {
qDebug() << "Connection failed!"; qDebug() << "Connection failed!";
return; return;

View File

@ -11,6 +11,8 @@ QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; } namespace Ui { class MainWindow; }
QT_END_NAMESPACE QT_END_NAMESPACE
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -33,7 +35,7 @@ private:
QMap<int,SlotConfig> map_slot_config; QMap<int,SlotConfig> map_slot_config;
QButtonGroup * btnGroup_slot = nullptr; QButtonGroup * btnGroup_slot = nullptr;
QString m_strServerIp; // 服务端IP
int slot; int slot;
void createMenu(); void createMenu();
@ -46,7 +48,7 @@ private:
void getVersion(int slot); void getVersion(int slot);
private slots: private slots:
void onMenuAction_relay();
void OnButtonGroup(QAbstractButton *); void OnButtonGroup(QAbstractButton *);
void onMenuActionTriggered(); void onMenuActionTriggered();

View File

@ -1121,8 +1121,16 @@
<string>帮助</string> <string>帮助</string>
</property> </property>
</widget> </widget>
<widget class="QMenu" name="menu_tool">
<property name="title">
<string>工具</string>
</property>
<addaction name="action_realy"/>
<addaction name="action_time"/>
</widget>
<addaction name="menu"/> <addaction name="menu"/>
<addaction name="menu_2"/> <addaction name="menu_2"/>
<addaction name="menu_tool"/>
</widget> </widget>
<widget class="QStatusBar" name="statusBar"/> <widget class="QStatusBar" name="statusBar"/>
<action name="actionNEW"> <action name="actionNEW">
@ -1135,6 +1143,16 @@
<string>Open</string> <string>Open</string>
</property> </property>
</action> </action>
<action name="action_realy">
<property name="text">
<string>继电器配置</string>
</property>
</action>
<action name="action_time">
<property name="text">
<string>校时功能</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>