添加速度和位移配置读写
This commit is contained in:
parent
2b81cf0f6b
commit
e65572b684
@ -1,6 +1,8 @@
|
|||||||
#include "MyTcpClient.h"
|
#include "MyTcpClient.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
MyTcpClient* MyTcpClient::m_instance = nullptr;
|
||||||
|
|
||||||
MyTcpClient::MyTcpClient(QObject *parent) : QObject(parent), shouldReconnect(true) {
|
MyTcpClient::MyTcpClient(QObject *parent) : QObject(parent), shouldReconnect(true) {
|
||||||
socket = new QTcpSocket(this);
|
socket = new QTcpSocket(this);
|
||||||
|
|
||||||
@ -21,7 +23,13 @@ MyTcpClient::~MyTcpClient() {
|
|||||||
socket->deleteLater();
|
socket->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MyTcpClient* MyTcpClient::instance()
|
||||||
|
{
|
||||||
|
if (!m_instance) {
|
||||||
|
m_instance = new MyTcpClient();
|
||||||
|
}
|
||||||
|
return m_instance;
|
||||||
|
}
|
||||||
void MyTcpClient::connectToServer(const QString &host, quint16 port) {
|
void MyTcpClient::connectToServer(const QString &host, quint16 port) {
|
||||||
serverHost = host;
|
serverHost = host;
|
||||||
serverPort = port;
|
serverPort = port;
|
||||||
|
@ -9,6 +9,7 @@ class MyTcpClient : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static MyTcpClient* instance();
|
||||||
explicit MyTcpClient(QObject *parent = nullptr);
|
explicit MyTcpClient(QObject *parent = nullptr);
|
||||||
~MyTcpClient();
|
~MyTcpClient();
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ private:
|
|||||||
QString serverHost;
|
QString serverHost;
|
||||||
quint16 serverPort;
|
quint16 serverPort;
|
||||||
bool shouldReconnect; // 标记是否需要重连
|
bool shouldReconnect; // 标记是否需要重连
|
||||||
|
static MyTcpClient* m_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MYTCPCLIENT_H
|
#endif // MYTCPCLIENT_H
|
||||||
|
@ -21,9 +21,9 @@ Acceleration::Acceleration(int slot_no_,int channel_,bool active,QWidget *parent
|
|||||||
ui->label_active->setText("(启用)");
|
ui->label_active->setText("(启用)");
|
||||||
else
|
else
|
||||||
ui->label_active->setText("(停用)");
|
ui->label_active->setText("(停用)");
|
||||||
QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\filter_%1_%2.json").arg(slot_no).arg(channel);
|
QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||||
readJsonFile(filePath_filter);
|
readJsonFile(filePath_filter);
|
||||||
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\acceleration_variables_%1_%2.json").arg(slot_no).arg(channel);
|
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel);
|
||||||
readJsonFile(filePath_variables);
|
readJsonFile(filePath_variables);
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
@ -77,14 +77,12 @@ void Acceleration::readJsonFile(const QString &filePath)
|
|||||||
variables[i].checked = temp_obj["checked"].toBool();
|
variables[i].checked = temp_obj["checked"].toBool();
|
||||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||||
}else if(variables[i].type == "1x_phase_lag"){
|
variables[i].phase_lag = temp_obj["phase_lag"].toDouble();
|
||||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
|
||||||
}else if(variables[i].type == "2x_ampl"){
|
}else if(variables[i].type == "2x_ampl"){
|
||||||
variables[i].checked = temp_obj["checked"].toBool();
|
variables[i].checked = temp_obj["checked"].toBool();
|
||||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString();
|
||||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
||||||
}else if(variables[i].type == "2x_phase_lag"){
|
variables[i].phase_lag = temp_obj["phase_lag"].toDouble();
|
||||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QJsonObject delay_obj = json_obj["delay"].toObject();
|
QJsonObject delay_obj = json_obj["delay"].toObject();
|
||||||
@ -98,7 +96,7 @@ void Acceleration::readJsonFile(const QString &filePath)
|
|||||||
alert_variables.timed_ok = json_obj["timed_ok"].toBool();
|
alert_variables.timed_ok = json_obj["timed_ok"].toBool();
|
||||||
alert_variables.recorder_output = json_obj["recorder_output"].toString();
|
alert_variables.recorder_output = json_obj["recorder_output"].toString();
|
||||||
alert_variables.two_ma_clamp = json_obj["two_ma_clamp"].toBool();
|
alert_variables.two_ma_clamp = json_obj["two_ma_clamp"].toBool();
|
||||||
alert_variables.trip_mutiply = json_obj["trip_mutiply"].toDouble();
|
alert_variables.trip_multiply = json_obj["trip_multiply"].toDouble();
|
||||||
alert_variables.comparision = json_obj["comparision"].toString();
|
alert_variables.comparision = json_obj["comparision"].toString();
|
||||||
alert_variables.comparision_percentage = json_obj["comparision_percentage"].toInt();
|
alert_variables.comparision_percentage = json_obj["comparision_percentage"].toInt();
|
||||||
}
|
}
|
||||||
@ -132,12 +130,10 @@ void Acceleration::Init()
|
|||||||
}else if(variables[i].type == "1x_ampl"){
|
}else if(variables[i].type == "1x_ampl"){
|
||||||
ui->comboBox_1x_value_range->setCurrentText(variables[i].full_sacle_range);
|
ui->comboBox_1x_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||||
ui->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value);
|
ui->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||||
}else if(variables[i].type == "1x_phase_lag"){
|
|
||||||
ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].clamp_value);
|
ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].clamp_value);
|
||||||
}else if(variables[i].type == "2x_ampl"){
|
}else if(variables[i].type == "2x_ampl"){
|
||||||
ui->comboBox_2x_value_range->setCurrentText(variables[i].full_sacle_range);
|
ui->comboBox_2x_value_range->setCurrentText(variables[i].full_sacle_range);
|
||||||
ui->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value);
|
ui->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||||
}else if(variables[i].type == "2x_phase_lag"){
|
|
||||||
ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].clamp_value);
|
ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].clamp_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,7 +147,7 @@ void Acceleration::Init()
|
|||||||
ui->checkBox_timed_ok->setChecked(alert_variables.timed_ok);
|
ui->checkBox_timed_ok->setChecked(alert_variables.timed_ok);
|
||||||
ui->comboBox_recorder_output->setCurrentText(alert_variables.recorder_output);
|
ui->comboBox_recorder_output->setCurrentText(alert_variables.recorder_output);
|
||||||
ui->checkBox_two_ma_clamp->setChecked(alert_variables.two_ma_clamp);
|
ui->checkBox_two_ma_clamp->setChecked(alert_variables.two_ma_clamp);
|
||||||
ui->doubleSpinBox_trip_mutiply->setValue(alert_variables.trip_mutiply);
|
ui->doubleSpinBox_trip_multiply->setValue(alert_variables.trip_multiply);
|
||||||
ui->comboBox_comparision->setCurrentText(alert_variables.comparision);
|
ui->comboBox_comparision->setCurrentText(alert_variables.comparision);
|
||||||
ui->spinBox_comparision_percentage->setValue(alert_variables.comparision_percentage);
|
ui->spinBox_comparision_percentage->setValue(alert_variables.comparision_percentage);
|
||||||
}
|
}
|
||||||
@ -205,7 +201,7 @@ void Acceleration::on_pushButton_confirm_clicked()
|
|||||||
alert_variables.timed_ok = ui->checkBox_timed_ok->isChecked();
|
alert_variables.timed_ok = ui->checkBox_timed_ok->isChecked();
|
||||||
alert_variables.recorder_output = ui->comboBox_recorder_output->currentText();
|
alert_variables.recorder_output = ui->comboBox_recorder_output->currentText();
|
||||||
alert_variables.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
alert_variables.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
||||||
alert_variables.trip_mutiply = ui->doubleSpinBox_trip_mutiply->value();
|
alert_variables.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
||||||
alert_variables.comparision = ui->comboBox_comparision->currentText();
|
alert_variables.comparision = ui->comboBox_comparision->currentText();
|
||||||
alert_variables.comparision_percentage = ui->spinBox_comparision_percentage->value();
|
alert_variables.comparision_percentage = ui->spinBox_comparision_percentage->value();
|
||||||
|
|
||||||
@ -246,13 +242,13 @@ void Acceleration::on_pushButton_confirm_clicked()
|
|||||||
variables_obj.insert("timed_ok",alert_variables.timed_ok);
|
variables_obj.insert("timed_ok",alert_variables.timed_ok);
|
||||||
variables_obj.insert("recorder_output",alert_variables.recorder_output);
|
variables_obj.insert("recorder_output",alert_variables.recorder_output);
|
||||||
variables_obj.insert("two_ma_clamp",alert_variables.two_ma_clamp);
|
variables_obj.insert("two_ma_clamp",alert_variables.two_ma_clamp);
|
||||||
variables_obj.insert("trip_mutiply",alert_variables.trip_mutiply);
|
variables_obj.insert("trip_multiply",alert_variables.trip_multiply);
|
||||||
variables_obj.insert("comparision",alert_variables.comparision);
|
variables_obj.insert("comparision",alert_variables.comparision);
|
||||||
variables_obj.insert("comparision_percentage",alert_variables.comparision_percentage);
|
variables_obj.insert("comparision_percentage",alert_variables.comparision_percentage);
|
||||||
variables_obj.insert("slot",slot_no);
|
variables_obj.insert("slot",slot_no);
|
||||||
variables_obj.insert("id",channel);
|
variables_obj.insert("id",channel);
|
||||||
QJsonDocument jsonDoc_filter(filter_obj);
|
QJsonDocument jsonDoc_filter(filter_obj);
|
||||||
QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\filter_%1_%2.json").arg(slot_no).arg(channel);
|
QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
qDebug() << "Cannot open file for writing:" << filePath;
|
qDebug() << "Cannot open file for writing:" << filePath;
|
||||||
@ -261,7 +257,7 @@ void Acceleration::on_pushButton_confirm_clicked()
|
|||||||
file.write(jsonDoc_filter.toJson());
|
file.write(jsonDoc_filter.toJson());
|
||||||
file.close();
|
file.close();
|
||||||
QJsonDocument jsonDoc_variables(variables_obj);
|
QJsonDocument jsonDoc_variables(variables_obj);
|
||||||
filePath = QCoreApplication::applicationDirPath() + QString("\\config\\acceleration_variables_%1_%2.json").arg(slot_no).arg(channel);
|
filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel);
|
||||||
file.setFileName(filePath);
|
file.setFileName(filePath);
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
qDebug() << "Cannot open file for writing:" << filePath;
|
qDebug() << "Cannot open file for writing:" << filePath;
|
||||||
@ -271,3 +267,9 @@ void Acceleration::on_pushButton_confirm_clicked()
|
|||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Acceleration::on_pushButton_set_default_clicked()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ public:
|
|||||||
private slots:
|
private slots:
|
||||||
void on_pushButton_confirm_clicked();
|
void on_pushButton_confirm_clicked();
|
||||||
|
|
||||||
|
void on_pushButton_set_default_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Acceleration *ui;
|
Ui::Acceleration *ui;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -126,13 +126,6 @@
|
|||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkBox_high_pass">
|
<widget class="QCheckBox" name="checkBox_high_pass">
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_12">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>高通:</string>
|
<string>高通:</string>
|
||||||
</property>
|
</property>
|
||||||
@ -224,13 +217,6 @@
|
|||||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkBox_low_pass">
|
<widget class="QCheckBox" name="checkBox_low_pass">
|
||||||
<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>
|
||||||
@ -301,13 +287,6 @@
|
|||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkBox_band_pass">
|
<widget class="QCheckBox" name="checkBox_band_pass">
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_13">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>带通:</string>
|
<string>带通:</string>
|
||||||
</property>
|
</property>
|
||||||
@ -713,8 +692,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>60</x>
|
<x>60</x>
|
||||||
<y>50</y>
|
<y>50</y>
|
||||||
<width>62</width>
|
<width>61</width>
|
||||||
<height>16</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="decimals">
|
<property name="decimals">
|
||||||
@ -769,7 +748,7 @@
|
|||||||
<x>60</x>
|
<x>60</x>
|
||||||
<y>20</y>
|
<y>20</y>
|
||||||
<width>61</width>
|
<width>61</width>
|
||||||
<height>16</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
@ -830,7 +809,7 @@
|
|||||||
<string>倍增</string>
|
<string>倍增</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_trip_mutiply">
|
<widget class="QDoubleSpinBox" name="doubleSpinBox_trip_multiply">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>460</x>
|
<x>460</x>
|
||||||
@ -1052,7 +1031,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_pushButton_set_default">
|
<widget class="QPushButton" name="pushButton_set_default">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>100</width>
|
||||||
|
@ -82,7 +82,7 @@ typedef struct{
|
|||||||
bool timed_ok;
|
bool timed_ok;
|
||||||
QString recorder_output;
|
QString recorder_output;
|
||||||
bool two_ma_clamp;
|
bool two_ma_clamp;
|
||||||
float trip_mutiply;
|
float trip_multiply;
|
||||||
QString comparision;
|
QString comparision;
|
||||||
int comparision_percentage;
|
int comparision_percentage;
|
||||||
} Alert_Variables;
|
} Alert_Variables;
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
"danger_latching":true,
|
"danger_latching":true,
|
||||||
"recorder_output":"direct",
|
"recorder_output":"direct",
|
||||||
"two_ma_clamp":true,
|
"two_ma_clamp":true,
|
||||||
"trip_mutiply":1.00,
|
"trip_multiply":1.00,
|
||||||
"comparision":"direct",
|
"comparision":"direct",
|
||||||
"comparision_percentage":5
|
"comparision_percentage":5
|
||||||
}
|
}
|
23
keyphase.ui
23
keyphase.ui
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>660</width>
|
<width>660</width>
|
||||||
<height>686</height>
|
<height>661</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -1601,13 +1601,13 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>40</x>
|
<x>41</x>
|
||||||
<y>10</y>
|
<y>10</y>
|
||||||
<width>478</width>
|
<width>431</width>
|
||||||
<height>23</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
@ -1619,16 +1619,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEdit">
|
<widget class="QLabel" name="label_40">
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>5</string>
|
<string>5</string>
|
||||||
</property>
|
</property>
|
||||||
@ -1655,7 +1646,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEdit_2">
|
<widget class="QLabel" name="label_41">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>5-6</string>
|
<string>5-6</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -109,31 +109,24 @@ MainWindow::~MainWindow()
|
|||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
void MainWindow::onDisConnected()
|
||||||
|
{
|
||||||
|
statusBar()->showMessage("连接失败!正在重连……", 3000); // 显示3秒
|
||||||
|
}
|
||||||
|
void MainWindow::onConnected()
|
||||||
|
{
|
||||||
|
statusBar()->showMessage("连接成功!", 3000); // 显示3秒
|
||||||
|
}
|
||||||
void MainWindow::connectServer()
|
void MainWindow::connectServer()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
m_tcpClient = MyTcpClient::instance();
|
||||||
|
// 监听信号
|
||||||
|
connect(m_tcpClient, SIGNAL(dataReceived(const QByteArray&)), this, SLOT(readData(const QByteArray&)));
|
||||||
|
connect(m_tcpClient, SIGNAL(disconnected()), this, SLOT(onDisConnected()));
|
||||||
|
connect(m_tcpClient, SIGNAL(connected()), this, SLOT(onConnected()));
|
||||||
// 连接服务器
|
// 连接服务器
|
||||||
client.connectToServer(g_strServerIp, 10000);
|
m_tcpClient->connectToServer(g_strServerIp, 10000);
|
||||||
//client.sendData("send_buf", 1);
|
|
||||||
// // 监听信号
|
|
||||||
// QObject::connect(&client, &MyTcpClient::connected, []() {
|
|
||||||
// qDebug() << "Client connected!";
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // QObject::connect(&client, &MyTcpClient::dataReceived, [](const QByteArray &data) {
|
|
||||||
// // qDebug() << "Received from server:" << data;
|
|
||||||
// // });
|
|
||||||
connect(&client, SIGNAL(dataReceived(const QByteArray&)), this, SLOT(readData(const QByteArray&)));
|
|
||||||
connect(&client, SIGNAL(disconnected()), this, SLOT(onDisConnected()));
|
|
||||||
// // QObject::connect(&client, &MyTcpClient::errorOccurred, [](const QString &error) {
|
|
||||||
// // qDebug() << "Error:" << error;
|
|
||||||
// // });
|
|
||||||
// socket = new QTcpSocket(this);
|
|
||||||
// connect(socket, &QTcpSocket::connected, this, &MainWindow::onConnected);
|
|
||||||
// connect(socket, &QTcpSocket::readyRead, this, &MainWindow::readData);
|
|
||||||
// socket->connectToHost(g_strServerIp, 10000);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,29 +197,29 @@ void MainWindow::createMenu(const QString& rootTitle, QPushButton* parent )
|
|||||||
// 创建主菜单
|
// 创建主菜单
|
||||||
QMenu *mainMenu = new QMenu(rootTitle, parent);
|
QMenu *mainMenu = new QMenu(rootTitle, parent);
|
||||||
|
|
||||||
// 创建第一层子菜单:/30 振电器模块
|
// 创建第一层子菜单
|
||||||
QMenu *monitors = new QMenu("监视器", mainMenu);
|
QMenu *monitors = new QMenu("监视器", mainMenu);
|
||||||
QMenu *relays = new QMenu("/30 继电器模块", mainMenu);
|
QMenu *relays = new QMenu("/DOM810 继电器模块", mainMenu);
|
||||||
QMenu *keyphasor = new QMenu("/25 键相模块", mainMenu);
|
QMenu *keyphasor = new QMenu("/KPM834 键相模块", mainMenu);
|
||||||
|
|
||||||
// 创建第二层子菜单:/40 振动板卡
|
// 创建第二层子菜单:/HAM824 振动板卡
|
||||||
QMenu *proximitor_menu = new QMenu("/40 振动板卡", monitors);
|
QMenu *proximitor_menu = new QMenu("/HAM824 振动板卡", monitors);
|
||||||
QMenu *rpm_menu = new QMenu("/50 转速板卡", monitors);
|
QMenu *rpm_menu = new QMenu("/OPM844 转速板卡", monitors);
|
||||||
|
|
||||||
// 创建第三层子菜单:/40 单板卡、三冗余板卡
|
// 创建第三层子菜单:/HAM824 单板卡、三冗余板卡
|
||||||
QAction *proximitor_1 = proximitor_menu->addAction("/40 单板卡");
|
QAction *proximitor_1 = proximitor_menu->addAction("/HAM824 单板卡");
|
||||||
QAction *proximitor_2 = proximitor_menu->addAction("/40 三冗余板卡");
|
QAction *proximitor_2 = proximitor_menu->addAction("/HAM824 三冗余板卡");
|
||||||
|
|
||||||
QAction *rpm_1 = rpm_menu->addAction("/50 单板卡");
|
QAction *rpm_1 = rpm_menu->addAction("/OPM844 单板卡");
|
||||||
|
|
||||||
|
|
||||||
// 创建第二层子菜单:/25 键相模块
|
// 创建第二层子菜单:/KPM834 键相模块
|
||||||
QAction *keyphasor_1 = keyphasor->addAction("/25 单板卡");
|
QAction *keyphasor_1 = keyphasor->addAction("/KPM834 单板卡");
|
||||||
QAction *keyphasor_2 = keyphasor->addAction("/25 两板卡");
|
QAction *keyphasor_2 = keyphasor->addAction("/KPM834 两板卡");
|
||||||
|
|
||||||
// 创建第二层子菜单:/30 继电器模块
|
// 创建第二层子菜单:/DOM810 继电器模块
|
||||||
QAction *relays_1 = relays->addAction("/30 单板卡");
|
QAction *relays_1 = relays->addAction("/DOM810 单板卡");
|
||||||
QAction *relays_2 = relays->addAction("/30 三冗余板卡");
|
QAction *relays_2 = relays->addAction("/DOM810 三冗余板卡");
|
||||||
|
|
||||||
// 将子菜单加入上一级菜单
|
// 将子菜单加入上一级菜单
|
||||||
monitors->addMenu(proximitor_menu); // 将第二层加入第一层
|
monitors->addMenu(proximitor_menu); // 将第二层加入第一层
|
||||||
@ -635,7 +628,7 @@ void MainWindow::sendUpgradePackage(int slot)
|
|||||||
}else{
|
}else{
|
||||||
chunkSize = totalBytes - bytesSent;
|
chunkSize = totalBytes - bytesSent;
|
||||||
}
|
}
|
||||||
qint64 bytesWritten = client.sendData(send_buf + bytesSent, chunkSize);
|
qint64 bytesWritten = m_tcpClient->sendData(send_buf + bytesSent, chunkSize);
|
||||||
qDebug() << "bytesWritten" << bytesWritten << "bytesSent" << bytesSent ;
|
qDebug() << "bytesWritten" << bytesWritten << "bytesSent" << bytesSent ;
|
||||||
if (bytesWritten == -1) {
|
if (bytesWritten == -1) {
|
||||||
break;
|
break;
|
||||||
@ -643,7 +636,7 @@ void MainWindow::sendUpgradePackage(int slot)
|
|||||||
bytesSent += bytesWritten;
|
bytesSent += bytesWritten;
|
||||||
}
|
}
|
||||||
qDebug() << "bytesSent" << bytesSent ;
|
qDebug() << "bytesSent" << bytesSent ;
|
||||||
client.waitForRead();
|
m_tcpClient->waitForRead();
|
||||||
progressBar->reset();
|
progressBar->reset();
|
||||||
progressBar->setVisible(true);
|
progressBar->setVisible(true);
|
||||||
QString upgrade_text = QStringLiteral("正在上传板卡 [ %1 ] …… %p%").arg(slot);
|
QString upgrade_text = QStringLiteral("正在上传板卡 [ %1 ] …… %p%").arg(slot);
|
||||||
@ -667,14 +660,10 @@ void MainWindow::getVersion(int slot)
|
|||||||
memcpy(send_buf, (char*)&header, sizeof(PackageHead));
|
memcpy(send_buf, (char*)&header, sizeof(PackageHead));
|
||||||
memcpy(send_buf + sizeof(PackageHead), (char*)&get_version_req, sizeof(GetVersionReq));
|
memcpy(send_buf + sizeof(PackageHead), (char*)&get_version_req, sizeof(GetVersionReq));
|
||||||
int length = sizeof(PackageHead) + sizeof(GetVersionReq);
|
int length = sizeof(PackageHead) + sizeof(GetVersionReq);
|
||||||
qint64 bytesWritten = client.sendData(send_buf, length);
|
qint64 bytesWritten = m_tcpClient->sendData(send_buf, length);
|
||||||
client.waitForRead();
|
m_tcpClient->waitForRead();
|
||||||
qDebug() << "bytesWritten: " << bytesWritten;
|
qDebug() << "bytesWritten: " << bytesWritten;
|
||||||
}
|
}
|
||||||
void MainWindow::onDisConnected()
|
|
||||||
{
|
|
||||||
statusBar()->showMessage("连接失败!", 30000); // 显示3秒
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::readData(const QByteArray& data)
|
void MainWindow::readData(const QByteArray& data)
|
||||||
{
|
{
|
||||||
|
@ -39,10 +39,10 @@ private:
|
|||||||
QList<QLabel*> list_label;
|
QList<QLabel*> list_label;
|
||||||
|
|
||||||
QButtonGroup * btnGroup_slot = nullptr;
|
QButtonGroup * btnGroup_slot = nullptr;
|
||||||
|
MyTcpClient* m_tcpClient;
|
||||||
|
|
||||||
int slot_no = 0;
|
int slot_no = 0;
|
||||||
QTcpSocket *socket;
|
QTcpSocket *socket;
|
||||||
MyTcpClient client;
|
|
||||||
|
|
||||||
QProgressBar *progressBar;
|
QProgressBar *progressBar;
|
||||||
|
|
||||||
@ -59,6 +59,7 @@ private:
|
|||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void onDisConnected();
|
void onDisConnected();
|
||||||
|
void onConnected();
|
||||||
void readData(const QByteArray&);
|
void readData(const QByteArray&);
|
||||||
void onMenuAction_relay();
|
void onMenuAction_relay();
|
||||||
void OnButtonGroup(QAbstractButton *);
|
void OnButtonGroup(QAbstractButton *);
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
#include "Radial_vibration.h"
|
|
||||||
#include "ui_Radial_vibration.h"
|
|
||||||
|
|
||||||
Radial_vibration::Radial_vibration(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::Radial_vibration)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Radial_vibration::~Radial_vibration()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
#ifndef Radial_vibration_H
|
|
||||||
#define Radial_vibration_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Radial_vibration;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Radial_vibration : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Radial_vibration(QWidget *parent = nullptr);
|
|
||||||
~Radial_vibration();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Radial_vibration *ui;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // Radial_vibration_H
|
|
1192
radial_vibration.ui
1192
radial_vibration.ui
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@ Seismic_monitor::Seismic_monitor(int slot,QWidget *parent) :
|
|||||||
QString slot_no_ = QString("%1").arg(slot_no);
|
QString slot_no_ = QString("%1").arg(slot_no);
|
||||||
ui->label_slot_no->setText(slot_no_);
|
ui->label_slot_no->setText(slot_no_);
|
||||||
|
|
||||||
QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\seismic_monitor_slot_%1.json").arg(slot_no);
|
QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\seismic_monitor_slot.json").arg(slot_no);
|
||||||
readJsonFile(filePath);
|
readJsonFile(filePath);
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
@ -228,17 +228,16 @@ void Seismic_monitor::on_pushButton_config_1_clicked()
|
|||||||
acceleration->show();
|
acceleration->show();
|
||||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||||
channel = 1;
|
channel = 1;
|
||||||
Radial_vibration *radial_vibration = new Radial_vibration();
|
Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,seismic_monitor[i].active);
|
||||||
radial_vibration->setWindowModality(Qt::ApplicationModal);
|
radial_vibration->setWindowModality(Qt::ApplicationModal);
|
||||||
radial_vibration->show();
|
radial_vibration->show();
|
||||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||||
channel = 1;
|
channel = 1;
|
||||||
Velocity *velocity = new Velocity();
|
Velocity *velocity = new Velocity(slot_no,channel,seismic_monitor[i].active);
|
||||||
velocity->setWindowModality(Qt::ApplicationModal);
|
velocity->setWindowModality(Qt::ApplicationModal);
|
||||||
velocity->show();
|
velocity->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,12 +253,12 @@ void Seismic_monitor::on_pushButton_config_3_clicked()
|
|||||||
acceleration->show();
|
acceleration->show();
|
||||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||||
channel = 3;
|
channel = 3;
|
||||||
Radial_vibration *radial_vibration = new Radial_vibration();
|
Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,seismic_monitor[i].active);
|
||||||
radial_vibration->setWindowModality(Qt::ApplicationModal);
|
radial_vibration->setWindowModality(Qt::ApplicationModal);
|
||||||
radial_vibration->show();
|
radial_vibration->show();
|
||||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||||
channel = 3;
|
channel = 3;
|
||||||
Velocity *velocity = new Velocity();
|
Velocity *velocity = new Velocity(slot_no,channel,seismic_monitor[i].active);
|
||||||
velocity->setWindowModality(Qt::ApplicationModal);
|
velocity->setWindowModality(Qt::ApplicationModal);
|
||||||
velocity->show();
|
velocity->show();
|
||||||
}
|
}
|
||||||
|
14
velocity.cpp
14
velocity.cpp
@ -1,14 +0,0 @@
|
|||||||
#include "Velocity.h"
|
|
||||||
#include "ui_Velocity.h"
|
|
||||||
|
|
||||||
Velocity::Velocity(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::Velocity)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
Velocity::~Velocity()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
22
velocity.h
22
velocity.h
@ -1,22 +0,0 @@
|
|||||||
#ifndef velocity_H
|
|
||||||
#define velocity_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class Velocity;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Velocity : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit Velocity(QWidget *parent = nullptr);
|
|
||||||
~Velocity();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::Velocity *ui;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // velocity_H
|
|
1097
velocity.ui
1097
velocity.ui
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user