添加主界面逻辑

This commit is contained in:
zhangsheng 2025-02-11 19:54:22 +08:00
parent 923b95bca6
commit cf3b2c94d0
7 changed files with 2539 additions and 2865 deletions

View File

@ -16,16 +16,19 @@ SOURCES += \
radial_vibration.cpp \ radial_vibration.cpp \
seismic_monitor.cpp \ seismic_monitor.cpp \
setpoint.cpp \ setpoint.cpp \
singlerelay.cpp \
tachometer.cpp \ tachometer.cpp \
velocity.cpp velocity.cpp
HEADERS += \ HEADERS += \
acceleration.h \ acceleration.h \
data_config.h \
keyphase.h \ keyphase.h \
mainwindow.h \ mainwindow.h \
radial_vibration.h \ radial_vibration.h \
seismic_monitor.h \ seismic_monitor.h \
setpoint.h \ setpoint.h \
singlerelay.h \
tachometer.h \ tachometer.h \
velocity.h velocity.h

View File

@ -13,96 +13,225 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<widget class="QTabWidget" name="tabWidget"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="geometry"> <item>
<rect> <widget class="QWidget" name="widget_3" native="true">
<x>40</x> <property name="minimumSize">
<y>100</y> <size>
<width>621</width> <width>0</width>
<height>391</height> <height>50</height>
</rect> </size>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>通道:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>(启用)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string> 槽位号:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>400</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
<string>滤波配置</string> <string>滤波配置</string>
</attribute> </attribute>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>591</width>
<height>141</height>
</rect>
</property>
<property name="title"> <property name="title">
<string>滤波</string> <string>滤波</string>
</property> </property>
<widget class="QLabel" name="label_29"> <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="geometry">
<rect>
<x>310</x>
<y>70</y>
<width>72</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>30 - 30000Hz</string>
</property>
</widget>
<widget class="QComboBox" name="comboBox_7">
<property name="geometry">
<rect>
<x>225</x>
<y>70</y>
<width>69</width>
<height>20</height>
</rect>
</property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="checkBox_10">
<property name="text"> <property name="text">
<string>30000</string> <string/>
</property> </property>
</item>
</widget> </widget>
<widget class="QLabel" name="label_30"> </item>
<property name="geometry"> <item>
<rect> <widget class="QLabel" name="label_12">
<x>195</x> <property name="text">
<y>70</y> <string>高通:</string>
<width>21</width>
<height>16</height>
</rect>
</property> </property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_2">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="minimum">
<number>3</number>
</property>
<property name="maximum">
<number>3000</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_33">
<property name="text"> <property name="text">
<string>-</string> <string>-</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_11"> </item>
<property name="geometry"> <item>
<rect> <widget class="QSpinBox" name="spinBox_3">
<x>56</x> <property name="minimumSize">
<y>71</y> <size>
<width>36</width> <width>60</width>
<height>16</height> <height>0</height>
</rect> </size>
</property> </property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="minimum">
<number>3</number>
</property>
<property name="maximum">
<number>3000</number>
</property>
<property name="value">
<number>3000</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_32">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>3 - 3000Hz</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="checkBox_11">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_11">
<property name="text"> <property name="text">
<string>低通:</string> <string>低通:</string>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_2"> <widget class="QComboBox" name="comboBox_2">
<property name="geometry"> <property name="minimumSize">
<rect> <size>
<x>105</x> <width>60</width>
<y>71</y> <height>0</height>
<width>61</width> </size>
<height>20</height>
</rect>
</property> </property>
<item> <item>
<property name="text"> <property name="text">
@ -110,101 +239,74 @@
</property> </property>
</item> </item>
</widget> </widget>
<widget class="QLabel" name="label_12"> </item>
<property name="geometry"> <item>
<rect> <widget class="QLabel" name="label_30">
<x>56</x>
<y>31</y>
<width>36</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>高通:</string>
</property>
</widget>
<widget class="QLabel" name="label_32">
<property name="geometry">
<rect>
<x>310</x>
<y>30</y>
<width>60</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>3 - 3000Hz</string>
</property>
</widget>
<widget class="QLabel" name="label_33">
<property name="geometry">
<rect>
<x>195</x>
<y>30</y>
<width>21</width>
<height>16</height>
</rect>
</property>
<property name="text"> <property name="text">
<string>-</string> <string>-</string>
</property> </property>
</widget> </widget>
<widget class="QSpinBox" name="spinBox_2"> </item>
<property name="geometry"> <item>
<rect> <widget class="QComboBox" name="comboBox_7">
<x>105</x> <property name="minimumSize">
<y>30</y> <size>
<width>61</width> <width>60</width>
<height>22</height> <height>0</height>
</rect> </size>
</property> </property>
<property name="minimum"> <item>
<number>3</number> <property name="text">
<string>30000</string>
</property> </property>
<property name="maximum"> </item>
<number>3000</number> </widget>
</item>
<item>
<widget class="QLabel" name="label_29">
<property name="text">
<string>30 - 30000Hz</string>
</property> </property>
</widget> </widget>
<widget class="QSpinBox" name="spinBox_3"> </item>
<property name="geometry"> <item>
<rect> <spacer name="horizontalSpacer_3">
<x>225</x> <property name="orientation">
<y>30</y> <enum>Qt::Horizontal</enum>
<width>61</width>
<height>22</height>
</rect>
</property> </property>
<property name="minimum"> <property name="sizeHint" stdset="0">
<number>3</number> <size>
<width>40</width>
<height>20</height>
</size>
</property> </property>
<property name="maximum"> </spacer>
<number>3000</number> </item>
</property> </layout>
<property name="value"> </item>
<number>3000</number> <item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QCheckBox" name="checkBox_12">
<property name="text">
<string/>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QLabel" name="label_13"> <widget class="QLabel" name="label_13">
<property name="geometry">
<rect>
<x>56</x>
<y>101</y>
<width>36</width>
<height>16</height>
</rect>
</property>
<property name="text"> <property name="text">
<string>带通:</string> <string>带通:</string>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_5"> <widget class="QSpinBox" name="spinBox_5">
<property name="geometry"> <property name="minimumSize">
<rect> <size>
<x>105</x> <width>60</width>
<y>100</y> <height>0</height>
<width>61</width> </size>
<height>22</height>
</rect>
</property> </property>
<property name="minimum"> <property name="minimum">
<number>3</number> <number>3</number>
@ -213,27 +315,21 @@
<number>3000</number> <number>3000</number>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QLabel" name="label_34"> <widget class="QLabel" name="label_34">
<property name="geometry">
<rect>
<x>195</x>
<y>100</y>
<width>21</width>
<height>16</height>
</rect>
</property>
<property name="text"> <property name="text">
<string>-</string> <string>-</string>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_6"> <widget class="QSpinBox" name="spinBox_6">
<property name="geometry"> <property name="minimumSize">
<rect> <size>
<x>225</x> <width>60</width>
<y>100</y> <height>0</height>
<width>61</width> </size>
<height>22</height>
</rect>
</property> </property>
<property name="minimum"> <property name="minimum">
<number>3</number> <number>3</number>
@ -245,59 +341,46 @@
<number>3000</number> <number>3000</number>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QLabel" name="label_35"> <widget class="QLabel" name="label_35">
<property name="geometry">
<rect>
<x>310</x>
<y>100</y>
<width>60</width>
<height>16</height>
</rect>
</property>
<property name="text"> <property name="text">
<string>3 - 3000Hz</string> <string>3 - 3000Hz</string>
</property> </property>
</widget> </widget>
<widget class="QCheckBox" name="checkBox_10"> </item>
<property name="geometry"> <item>
<rect> <spacer name="horizontalSpacer_4">
<x>20</x> <property name="orientation">
<y>30</y> <enum>Qt::Horizontal</enum>
<width>21</width>
<height>16</height>
</rect>
</property> </property>
<property name="text"> <property name="sizeHint" stdset="0">
<string/> <size>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>248</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget> </widget>
<widget class="QCheckBox" name="checkBox_11"> </item>
<property name="geometry"> </layout>
<rect>
<x>20</x>
<y>70</y>
<width>21</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_12">
<property name="geometry">
<rect>
<x>20</x>
<y>100</y>
<width>21</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</widget> </widget>
<widget class="QWidget" name="tab_2"> <widget class="QWidget" name="tab_2">
<attribute name="title"> <attribute name="title">
@ -900,120 +983,106 @@
</widget> </widget>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="layoutWidget_3"> </item>
<property name="geometry"> </layout>
<rect> </widget>
<x>20</x> </item>
<y>510</y> <item>
<width>651</width> <widget class="QWidget" name="widget_2" native="true">
<height>29</height> <property name="minimumSize">
</rect> <size>
<width>0</width>
<height>50</height>
</size>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="QToolButton" name="toolButton_9"> <widget class="QPushButton" name="pushButton_9">
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="text"> <property name="text">
<string>确定</string> <string>确定</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButton_10"> <widget class="QPushButton" name="pushButton_10">
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="text"> <property name="text">
<string>设置为默认值</string> <string>设置为默认值</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButton_11"> <widget class="QPushButton" name="pushButton_11">
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="text"> <property name="text">
<string>测点名称</string> <string>测点名称</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButton_12"> <widget class="QPushButton" name="pushButton_12">
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="text"> <property name="text">
<string>取消</string> <string>取消</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButton_13"> <widget class="QPushButton" name="pushButton_13">
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="text"> <property name="text">
<string>打印</string> <string>打印</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QToolButton" name="toolButton_14"> <widget class="QPushButton" name="pushButton_14">
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="text"> <property name="text">
<string>帮助</string> <string>帮助</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget>
<widget class="QWidget" name="layoutWidget_4">
<property name="geometry">
<rect>
<x>30</x>
<y>10</y>
<width>231</width>
<height>22</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>通道:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>(启用)</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="layoutWidget_5">
<property name="geometry">
<rect>
<x>350</x>
<y>10</y>
<width>189</width>
<height>22</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string> 槽位号:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_2">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,14 @@
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include <QDebug> #include <QDebug>
#include <QList> #include <QList>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include "keyphase.h"
#include "singlerelay.h"
#include "tachometer.h"
#include "seismic_monitor.h"
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
@ -26,24 +34,64 @@ MainWindow::MainWindow(QWidget *parent)
btnGroup_slot->addButton(ui->pushButton_slot16); btnGroup_slot->addButton(ui->pushButton_slot16);
btnGroup_slot->addButton(ui->pushButton_slot17); btnGroup_slot->addButton(ui->pushButton_slot17);
ui->pushButton_slot->setChecked(true);
readJsonFile(QCoreApplication::applicationDirPath() + "\\config\\main.json");
createMenu(); createMenu();
connect(btnGroup_slot, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(OnButtonGroup(QAbstractButton *)));
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
delete ui; delete ui;
} }
void MainWindow::readJsonFile(const QString &filePath)
{
// 创建文件对象
QFile file(filePath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "Cannot open file for reading:" << filePath;
return;
}
QString content = file.readAll();
file.close();
QByteArray jsonData = content.toUtf8();
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
if (jsonDoc.isNull()) {
qDebug() << "Cannot parse JSON document";
return;
}
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
qDebug() << "JSON document is not an object or an array";
return;
}
int slot_id = 3;
QJsonArray jsonArray = jsonDoc.array();
for (const QJsonValue &value : jsonArray) {
SlotConfig slot_config;
if (value.isObject()) { // 处理数组中的对象,例如每个对象代表一个记录或用户等。
QJsonObject obj = value.toObject();
slot_config.slot = obj["slot"].toInt();
slot_config.slot_type = obj["slot_type"].toInt();
slot_config.chan_type = obj["chan_type"].toString();
slot_config.rack_type = obj["rack_type"].toString();
map_slot_config.insert(slot_id,slot_config);
slot_id ++;
}
}
}
void MainWindow::createMenu() void MainWindow::createMenu()
{ {
QList<QAbstractButton*> buttonList = btnGroup_slot->buttons(); QList<QAbstractButton*> buttonList = btnGroup_slot->buttons();
for (int i = 0; i < buttonList.count(); i++){ for (int i = 0; i < buttonList.count(); i++){
slot_type.insert(buttonList[i]->objectName(),""); //buttonList[i]->setText(map_slot_config[i + 3].chan_type);
}
for (int i = 0; i < buttonList.count(); i++){
if(slot_type[buttonList[i]->objectName()] == "")
createMenu(QString("%1").arg(i + 1), (QPushButton*)buttonList[i]); createMenu(QString("%1").arg(i + 1), (QPushButton*)buttonList[i]);
else // else
createMenuSet(QString("%1").arg(i + 1), (QPushButton*)buttonList[i]); // createMenuSet(QString("%1").arg(i + 1), (QPushButton*)buttonList[i]);
} }
} }
void MainWindow::createMenu(const QString& rootTitle, QPushButton* parent ) void MainWindow::createMenu(const QString& rootTitle, QPushButton* parent )
@ -99,7 +147,9 @@ void MainWindow::createMenu(const QString& rootTitle, QPushButton* parent )
QObject::connect(keyphasor_1, &QAction::triggered,this, &MainWindow::onMenuActionTriggered); QObject::connect(keyphasor_1, &QAction::triggered,this, &MainWindow::onMenuActionTriggered);
QObject::connect(keyphasor_2, &QAction::triggered,this, &MainWindow::onMenuActionTriggered); QObject::connect(keyphasor_2, &QAction::triggered,this, &MainWindow::onMenuActionTriggered);
QObject::connect(reset, &QAction::triggered,this, &MainWindow::onMenuActionTriggered); QObject::connect(reset, &QAction::triggered,this, &MainWindow::onMenuActionTriggered);
} }
void MainWindow::createMenuSet(const QString& rootTitle, QPushButton* parent ) void MainWindow::createMenuSet(const QString& rootTitle, QPushButton* parent )
{ {
// 创建主菜单 // 创建主菜单
@ -146,9 +196,30 @@ void MainWindow::onMenuActionTriggered()
while (menu) { while (menu) {
QPushButton *button = qobject_cast<QPushButton*>(menu->parent()); QPushButton *button = qobject_cast<QPushButton*>(menu->parent());
if (button) { if (button) {
qDebug() << "子菜单项被点击,所属按钮:" << button->objectName(); qDebug() << "子菜单项被点击,所属按钮:" << button->objectName() << action->text();
int slot_type = action->text().mid(1,2).toInt();
QString rack_type = action->text().right(action->text().length()-4);
int button_id = button->objectName().right(button->objectName().length()-15).toInt();
qDebug() << slot_type << rack_type << button_id << map_slot_config[button_id + 1].slot_type << map_slot_config[button_id + 2].slot_type << endl;
if(rack_type == "三冗余板卡" && (map_slot_config[button_id + 1].slot_type != 0 \
|| map_slot_config[button_id + 2].slot_type != 0)){
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠三冗余板卡配置,请在创建新配置之前移除现有的配置!");
return;
}else if(rack_type == "三冗余板卡" && map_slot_config[button_id + 1].slot_type == 0 \
&& map_slot_config[button_id + 2].slot_type == 0){
map_slot_config[button_id].slot_type = slot_type;
map_slot_config[button_id].rack_type = "TMR";
}
if(rack_type == "两板卡" && map_slot_config[button_id + 1].slot_type != 0 ){
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠两板卡配置,请在创建新配置之前移除现有的配置!");
return;
}else if(rack_type == "两板卡" && map_slot_config[button_id + 1].slot_type == 0){
map_slot_config[button_id].slot_type = slot_type;
map_slot_config[button_id].rack_type = "Double";
}
map_slot_config[button_id].slot_type = slot_type;
map_slot_config[button_id].rack_type = "Single";
button->setText(action->text()); button->setText(action->text());
slot_type[button->objectName()] = action->text();
QMenu* menu = button->menu(); QMenu* menu = button->menu();
if (!menu) { if (!menu) {
qWarning() << "菜单为空,无法清除属性!"; qWarning() << "菜单为空,无法清除属性!";
@ -164,40 +235,94 @@ void MainWindow::onMenuActionTriggered()
} }
} }
void MainWindow::OnButtonGroup(QAbstractButton * slot_btn, bool checked) void MainWindow::OnButtonGroup(QAbstractButton * slot_btn)
{ {
if(slot_btn != NULL) if(slot_btn != NULL && ui->pushButton_chan->isChecked())
{ {
qDebug() << slot_btn->objectName(); QString object_name = slot_btn->objectName();
qDebug() << checked; qDebug() << object_name << endl;
QString str; int button_id = object_name.right(object_name.length()-15).toInt();
QList<QAbstractButton*> buttonList = btnGroup_slot->buttons(); SlotConfig slot_config = map_slot_config[button_id];
for (int i = 0; i < buttonList.count(); i++){ if (slot_config.slot_type == KEYPHASOR){
KeyPhase *key_phase = new KeyPhase();
key_phase->setWindowModality(Qt::ApplicationModal);
key_phase->show();
}else if (slot_config.slot_type == RELAY){
SingleRelay *single_relay = new SingleRelay();
single_relay->setWindowModality(Qt::ApplicationModal);
single_relay->show();
}else if (slot_config.slot_type == VIBRATE){
Seismic_monitor *seismic_monitor = new Seismic_monitor();
seismic_monitor->setWindowModality(Qt::ApplicationModal);
seismic_monitor->show();
}else if (slot_config.slot_type == RPM){
Tachometer *tachometer = new Tachometer();
tachometer->setWindowModality(Qt::ApplicationModal);
tachometer->show();
} }
} }
} }
void MainWindow::on_pushButton_slot_clicked() void MainWindow::on_pushButton_slot_clicked()
{ {
if(ui->pushButton_chan->isChecked())
ui->pushButton_chan->setChecked(false);
if(ui->pushButton_alarm->isChecked())
ui->pushButton_alarm->setChecked(false);
if(ui->pushButton_point_name->isChecked())
ui->pushButton_point_name->setChecked(false);
} }
void MainWindow::on_pushButton_chan_clicked() void MainWindow::on_pushButton_chan_clicked()
{ {
if(ui->pushButton_slot->isChecked())
ui->pushButton_slot->setChecked(false);
if(ui->pushButton_alarm->isChecked())
ui->pushButton_alarm->setChecked(false);
if(ui->pushButton_point_name->isChecked())
ui->pushButton_point_name->setChecked(false);
} }
void MainWindow::on_pushButton_alarm_clicked() void MainWindow::on_pushButton_alarm_clicked()
{ {
if(ui->pushButton_slot->isChecked())
ui->pushButton_slot->setChecked(false);
if(ui->pushButton_chan->isChecked())
ui->pushButton_chan->setChecked(false);
if(ui->pushButton_point_name->isChecked())
ui->pushButton_point_name->setChecked(false);
} }
void MainWindow::on_pushButton_point_name_clicked() void MainWindow::on_pushButton_point_name_clicked()
{ {
if(ui->pushButton_slot->isChecked())
ui->pushButton_slot->setChecked(false);
if(ui->pushButton_chan->isChecked())
ui->pushButton_chan->setChecked(false);
if(ui->pushButton_alarm->isChecked())
ui->pushButton_alarm->setChecked(false);
}
void MainWindow::on_pushButton_save_clicked()
{
QJsonObject itemObj;
QJsonArray slotArray;
for(int i = 0; i < map_slot_config.size();i++){
itemObj["slot"] = map_slot_config[i+3].slot;
itemObj["slot_type"] = map_slot_config[i+3].slot_type;
itemObj["chan_type"] = map_slot_config[i+3].chan_type;
itemObj["rack_type"] = map_slot_config[i+3].rack_type;
slotArray.append(itemObj);
}
QJsonDocument jsonDoc;
jsonDoc.setArray(slotArray);
QFile file(QCoreApplication::applicationDirPath() + "\\config\\main.json");
file.open(QIODevice::WriteOnly);
file.write(jsonDoc.toJson());
file.close();
} }

View File

@ -5,6 +5,7 @@
#include <QMap> #include <QMap>
#include <QButtonGroup> #include <QButtonGroup>
#include <QPushButton> #include <QPushButton>
#include "data_config.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; } namespace Ui { class MainWindow; }
@ -29,7 +30,7 @@ private:
//声明菜单 //声明菜单
QMenu * button_menu; QMenu * button_menu;
QMap<QString,QString> slot_type; QMap<int,SlotConfig> map_slot_config;
QButtonGroup * btnGroup_slot = nullptr; QButtonGroup * btnGroup_slot = nullptr;
@ -38,14 +39,17 @@ private:
void createMenuSet(const QString& rootTitle, QPushButton* button = nullptr); void createMenuSet(const QString& rootTitle, QPushButton* button = nullptr);
void clearMenuProperties(QMenu* menu); void clearMenuProperties(QMenu* menu);
void readJsonFile(const QString &filePath);
private slots: private slots:
void OnButtonGroup(QAbstractButton *, bool); void OnButtonGroup(QAbstractButton *);
void onMenuActionTriggered(); void onMenuActionTriggered();
void on_pushButton_slot_clicked(); void on_pushButton_slot_clicked();
void on_pushButton_chan_clicked(); void on_pushButton_chan_clicked();
void on_pushButton_alarm_clicked(); void on_pushButton_alarm_clicked();
void on_pushButton_point_name_clicked(); void on_pushButton_point_name_clicked();
void on_pushButton_save_clicked();
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -32,7 +32,7 @@
<height>100</height> <height>100</height>
</size> </size>
</property> </property>
<widget class="QPushButton" name="pushButton_20"> <widget class="QPushButton" name="pushButton_save">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>20</x>
@ -54,7 +54,7 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string/> <string>保存</string>
</property> </property>
</widget> </widget>
<widget class="QPushButton" name="pushButton_21"> <widget class="QPushButton" name="pushButton_21">
@ -269,6 +269,9 @@
<property name="text"> <property name="text">
<string>板卡配置</string> <string>板卡配置</string>
</property> </property>
<property name="checkable">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -282,6 +285,9 @@
<property name="text"> <property name="text">
<string>通道配置</string> <string>通道配置</string>
</property> </property>
<property name="checkable">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -295,6 +301,9 @@
<property name="text"> <property name="text">
<string>触发配置</string> <string>触发配置</string>
</property> </property>
<property name="checkable">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -308,6 +317,9 @@
<property name="text"> <property name="text">
<string>测点名称</string> <string>测点名称</string>
</property> </property>
<property name="checkable">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>

File diff suppressed because it is too large Load Diff