调整界面和优化协议字段
This commit is contained in:
parent
7122e96472
commit
ce9f75be9f
@ -218,6 +218,7 @@ void Acceleration::on_pushButton_confirm_clicked()
|
||||
filter_obj.insert("filter",filter_array);
|
||||
filter_obj.insert("slot",slot_no);
|
||||
filter_obj.insert("id",channel);
|
||||
filter_obj.insert("version",1);
|
||||
QJsonArray variables_array;
|
||||
for(int i = 0; i < 4; i++){
|
||||
QJsonObject temp_obj;
|
||||
@ -247,6 +248,7 @@ void Acceleration::on_pushButton_confirm_clicked()
|
||||
variables_obj.insert("comparision_percentage",alert_variables.comparision_percentage);
|
||||
variables_obj.insert("slot",slot_no);
|
||||
variables_obj.insert("id",channel);
|
||||
variables_obj.insert("version",1);
|
||||
QJsonDocument jsonDoc_filter(filter_obj);
|
||||
QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||
QFile file(filePath);
|
||||
|
@ -87,6 +87,24 @@ typedef struct{
|
||||
int comparision_percentage;
|
||||
} Alert_Variables;
|
||||
|
||||
typedef struct{
|
||||
int id;
|
||||
bool active;
|
||||
float normal_voltage_low;
|
||||
float normal_voltage_high;
|
||||
bool automatic_threshold;
|
||||
float threshold;
|
||||
float hysteresis;
|
||||
int events_per_revolution;
|
||||
QString record_output;
|
||||
bool two_ma_clamp;
|
||||
bool alert_latching;
|
||||
bool overspeed_latching;
|
||||
bool normal_latching;
|
||||
int alert_response_time;
|
||||
int danger_response_time;
|
||||
}Tachometer_Variables;
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
|
1256
keyphase.ui
1256
keyphase.ui
File diff suppressed because it is too large
Load Diff
@ -457,7 +457,7 @@ void MainWindow::OnButtonGroup(QAbstractButton * slot_btn)
|
||||
seismic_monitor->setWindowModality(Qt::ApplicationModal);
|
||||
seismic_monitor->show();
|
||||
}else if (slot_config.slot_type == RPM){
|
||||
Tachometer *tachometer = new Tachometer();
|
||||
Tachometer *tachometer = new Tachometer(button_id);
|
||||
tachometer->setWindowModality(Qt::ApplicationModal);
|
||||
tachometer->show();
|
||||
|
||||
|
@ -229,6 +229,7 @@ void Radial_vibration::on_pushButton_confirm_clicked()
|
||||
filter_obj.insert("filter",filter_array);
|
||||
filter_obj.insert("slot",slot_no);
|
||||
filter_obj.insert("id",channel);
|
||||
filter_obj.insert("version",1);
|
||||
QJsonArray variables_array;
|
||||
for(int i = 0; i < 6; i++){
|
||||
QJsonObject temp_obj;
|
||||
@ -255,6 +256,7 @@ void Radial_vibration::on_pushButton_confirm_clicked()
|
||||
variables_obj.insert("comparision_percentage",alert_variables.comparision_percentage);
|
||||
variables_obj.insert("slot",slot_no);
|
||||
variables_obj.insert("id",channel);
|
||||
variables_obj.insert("version",1);
|
||||
QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\radial_vibration_variables_%2.json").arg(slot_no).arg(channel);
|
||||
QFile file_filter(filePath_filter);
|
||||
|
@ -1,15 +1,70 @@
|
||||
#include "tachometer.h"
|
||||
#include "ui_tachometer.h"
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonArray>
|
||||
|
||||
Tachometer::Tachometer(QWidget *parent)
|
||||
Tachometer::Tachometer(int slot_no_,QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::Tachometer)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->widget_body->setProperty("flag", "body");
|
||||
slot_no = slot_no_;
|
||||
QString slot = QString("%1").arg(slot_no);
|
||||
|
||||
QString filePath_tachometer = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\tachometer.json").arg(slot_no);
|
||||
readJsonFile(filePath_tachometer);
|
||||
Init();
|
||||
}
|
||||
|
||||
Tachometer::~Tachometer()
|
||||
{
|
||||
|
||||
delete ui;
|
||||
}
|
||||
void Tachometer::readJsonFile(const QString &filePath)
|
||||
{
|
||||
QFile file(filePath);
|
||||
if(!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
qDebug() << "Could not open file for reading";
|
||||
return;
|
||||
}
|
||||
QByteArray saveData = file.readAll();
|
||||
QJsonParseError json_error;
|
||||
QJsonDocument parse_doucment = QJsonDocument::fromJson(saveData, &json_error);
|
||||
if(json_error.error != QJsonParseError::NoError)
|
||||
{
|
||||
qDebug() << "json error!";
|
||||
return;
|
||||
}
|
||||
QJsonObject json_obj = parse_doucment.object();
|
||||
QJsonArray chan_array = json_obj["chan"].toArray();
|
||||
for(int i = 0; i < chan_array.size(); i++){
|
||||
QJsonObject temp_obj = chan_array[i].toObject();
|
||||
tachometer_variables[i].id = temp_obj["id"].toInt();
|
||||
tachometer_variables[i].active = temp_obj["active"].toBool();
|
||||
QJsonArray voltage_range_array = temp_obj["normal_voltage_range"].toArray();
|
||||
tachometer_variables[i].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||
tachometer_variables[i].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||
tachometer_variables[i].threshold = temp_obj["threshold"].toDouble();
|
||||
tachometer_variables[i].hysteresis = temp_obj["hysteresis"].toDouble();
|
||||
tachometer_variables[i].events_per_revolution = temp_obj["events_per_revolution"].toInt();
|
||||
tachometer_variables[i].record_output = temp_obj["record_output"].toString();
|
||||
tachometer_variables[i].two_ma_clamp = temp_obj["two_ma_clamp"].toBool();
|
||||
tachometer_variables[i].alert_latching = temp_obj["alert_latching"].toBool();
|
||||
tachometer_variables[i].overspeed_latching = temp_obj["overspeed_latching"].toBool();
|
||||
tachometer_variables[i].normal_latching = temp_obj["normal_latching"].toBool();
|
||||
tachometer_variables[i].alert_response_time = temp_obj["alert_response_time"].toInt();
|
||||
tachometer_variables[i].danger_response_time = temp_obj["danger_response_time"].toInt();
|
||||
}
|
||||
|
||||
}
|
||||
void Tachometer::Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
11
tachometer.h
11
tachometer.h
@ -2,7 +2,7 @@
|
||||
#define TACHOMETER_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "data_config.h"
|
||||
namespace Ui {
|
||||
class Tachometer;
|
||||
}
|
||||
@ -12,11 +12,16 @@ class Tachometer : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Tachometer(QWidget *parent = nullptr);
|
||||
explicit Tachometer(int slot_no_,QWidget *parent = nullptr);
|
||||
~Tachometer();
|
||||
|
||||
int slot_no;
|
||||
private:
|
||||
Ui::Tachometer *ui;
|
||||
|
||||
Tachometer_Variables tachometer_variables[4];
|
||||
|
||||
void readJsonFile(const QString &filePath);
|
||||
void Init();
|
||||
};
|
||||
|
||||
#endif // TACHOMETER_H
|
||||
|
1569
tachometer.ui
1569
tachometer.ui
File diff suppressed because it is too large
Load Diff
@ -420,7 +420,7 @@
|
||||
<x>510</x>
|
||||
<y>320</y>
|
||||
<width>271</width>
|
||||
<height>51</height>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
|
@ -211,6 +211,9 @@ void Velocity::on_pushButton_confirm_clicked()
|
||||
filter_array.append(temp_obj);
|
||||
}
|
||||
filter_obj.insert("filter",filter_array);
|
||||
filter_obj.insert("slot",slot_no);
|
||||
filter_obj.insert("id",channel);
|
||||
filter_obj.insert("version",1);
|
||||
QJsonDocument filter_doc;
|
||||
filter_doc.setObject(filter_obj);
|
||||
QByteArray filter_data = filter_doc.toJson();
|
||||
@ -263,6 +266,7 @@ void Velocity::on_pushButton_confirm_clicked()
|
||||
variables_obj.insert("comparision_percentage",alert_variables.comparision_percentage);
|
||||
variables_obj.insert("slot",slot_no);
|
||||
variables_obj.insert("channel",channel);
|
||||
variables_obj.insert("version",1);
|
||||
QJsonDocument variables_doc;
|
||||
variables_doc.setObject(variables_obj);
|
||||
QByteArray variables_data = variables_doc.toJson();
|
||||
|
Loading…
x
Reference in New Issue
Block a user