添加读写配置
This commit is contained in:
parent
ce9f75be9f
commit
58d4a43788
@ -155,20 +155,18 @@ void Acceleration::Init()
|
|||||||
void Acceleration::on_pushButton_confirm_clicked()
|
void Acceleration::on_pushButton_confirm_clicked()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if(filter[i].checked){
|
if(filter[i].type == "band_pass"){
|
||||||
if(filter[i].type == "band_pass"){
|
filter[i].checked = ui->checkBox_band_pass->isChecked();
|
||||||
filter[i].checked = ui->checkBox_band_pass->isChecked();
|
filter[i].low = ui->spinBox_band_pass_low->value();
|
||||||
filter[i].low = ui->spinBox_band_pass_low->value();
|
filter[i].high = ui->spinBox_band_pass_high->value();
|
||||||
filter[i].high = ui->spinBox_band_pass_high->value();
|
}else if(filter[i].type == "low_pass"){
|
||||||
}else if(filter[i].type == "low_pass"){
|
filter[i].checked = ui->checkBox_low_pass->isChecked();
|
||||||
filter[i].checked = ui->checkBox_low_pass->isChecked();
|
filter[i].low = ui->spinBox_low_pass_low->value();
|
||||||
filter[i].low = ui->spinBox_low_pass_low->value();
|
filter[i].high = ui->spinBox_low_pass_high->value();
|
||||||
filter[i].high = ui->spinBox_low_pass_high->value();
|
}else if(filter[i].type == "high_pass"){
|
||||||
}else if(filter[i].type == "high_pass"){
|
filter[i].checked = ui->checkBox_high_pass->isChecked();
|
||||||
filter[i].checked = ui->checkBox_high_pass->isChecked();
|
filter[i].low = ui->spinBox_high_pass_low->value();
|
||||||
filter[i].low = ui->spinBox_high_pass_low->value();
|
filter[i].high = ui->spinBox_high_pass_high->value();
|
||||||
filter[i].high = ui->spinBox_high_pass_high->value();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
@ -223,11 +221,18 @@ void Acceleration::on_pushButton_confirm_clicked()
|
|||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 4; i++){
|
||||||
QJsonObject temp_obj;
|
QJsonObject temp_obj;
|
||||||
temp_obj.insert("type",variables[i].type);
|
temp_obj.insert("type",variables[i].type);
|
||||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
if(variables[i].type == "direct"){
|
||||||
temp_obj.insert("bias_voltage",variables[i].bias_voltage);
|
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||||
temp_obj.insert("phase_lag",variables[i].phase_lag);
|
}else if(variables[i].type == "bias_volt"){
|
||||||
temp_obj.insert("checked",variables[i].checked);
|
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||||
|
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||||
|
}else if(variables[i].type == "1x_ampl" || variables[i].type == "2x_ampl"){
|
||||||
|
temp_obj.insert("checked",variables[i].checked);
|
||||||
|
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||||
|
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||||
|
temp_obj.insert("phase_lag",variables[i].phase_lag);
|
||||||
|
}
|
||||||
variables_array.append(temp_obj);
|
variables_array.append(temp_obj);
|
||||||
}
|
}
|
||||||
variables_obj.insert("variables",variables_array);
|
variables_obj.insert("variables",variables_array);
|
||||||
|
@ -13,7 +13,7 @@ extern QString g_strServerIp; // 服务端IP
|
|||||||
#define CHANNLE_COUNT 4
|
#define CHANNLE_COUNT 4
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int slot;
|
int slot;
|
||||||
int slot_type;
|
QString slot_type;
|
||||||
QString chan_display;
|
QString chan_display;
|
||||||
QString rack_type;
|
QString rack_type;
|
||||||
QPushButton* slot_btn;
|
QPushButton* slot_btn;
|
||||||
@ -29,14 +29,7 @@ enum CMTCommand {
|
|||||||
kRelayStatus = 6,
|
kRelayStatus = 6,
|
||||||
kUpgradeProgress = 7
|
kUpgradeProgress = 7
|
||||||
};
|
};
|
||||||
enum SlotType{
|
|
||||||
POWER = 10,
|
|
||||||
CONFIG = 20,
|
|
||||||
KEYPHASOR = 25,
|
|
||||||
RELAY = 30,
|
|
||||||
VIBRATE = 40,
|
|
||||||
RPM = 50
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
int id;
|
int id;
|
||||||
|
177
keyphase.cpp
177
keyphase.cpp
@ -1,21 +1,196 @@
|
|||||||
#include "keyphase.h"
|
#include "keyphase.h"
|
||||||
#include "ui_keyphase.h"
|
#include "ui_keyphase.h"
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
KeyPhase::KeyPhase(QWidget *parent)
|
KeyPhase::KeyPhase(int slot_no_,QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, ui(new Ui::KeyPhase)
|
, ui(new Ui::KeyPhase)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->widget_body->setProperty("flag", "body");
|
ui->widget_body->setProperty("flag", "body");
|
||||||
|
slot_no = slot_no_;
|
||||||
|
QString slot = QString("%1").arg(slot_no);
|
||||||
|
ui->label_slot->setText(slot);
|
||||||
|
QString filePath_keyphase = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\keyphase.json").arg(slot_no);
|
||||||
|
readJsonFile(filePath_keyphase);
|
||||||
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyPhase::~KeyPhase()
|
KeyPhase::~KeyPhase()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
void KeyPhase::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;
|
||||||
|
}
|
||||||
|
QJsonObject json_obj = jsonDoc.object();
|
||||||
|
QJsonArray chan_array = json_obj["chan"].toArray();
|
||||||
|
for(int i = 0; i < chan_array.size(); i++){
|
||||||
|
QJsonObject temp_obj = chan_array[i].toObject();
|
||||||
|
keyphase_variables[i].id = temp_obj["id"].toInt();
|
||||||
|
keyphase_variables[i].active = temp_obj["active"].toBool();
|
||||||
|
QJsonArray voltage_range_array = temp_obj["normal_voltage_range"].toArray();
|
||||||
|
keyphase_variables[i].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||||
|
keyphase_variables[i].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||||
|
keyphase_variables[i].threshold = temp_obj["threshold"].toDouble();
|
||||||
|
keyphase_variables[i].hysteresis = temp_obj["hysteresis"].toDouble();
|
||||||
|
keyphase_variables[i].events_per_revolution = temp_obj["events_per_revolution"].toInt();
|
||||||
|
keyphase_variables[i].record_output = temp_obj["record_output"].toString();
|
||||||
|
keyphase_variables[i].two_ma_clamp = temp_obj["two_ma_clamp"].toBool();
|
||||||
|
keyphase_variables[i].alert_latching = temp_obj["alert_latching"].toBool();
|
||||||
|
keyphase_variables[i].overspeed_latching = temp_obj["overspeed_latching"].toBool();
|
||||||
|
keyphase_variables[i].normal_latching = temp_obj["normal_latching"].toBool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void KeyPhase::Init()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||||
|
if(keyphase_variables[i].id == 1){
|
||||||
|
ui->checkBox_enable_1->setChecked(keyphase_variables[i].active);
|
||||||
|
ui->doubleSpinBox_high_1->setValue(keyphase_variables[i].normal_voltage_high);
|
||||||
|
ui->doubleSpinBox_low_1->setValue(keyphase_variables[i].normal_voltage_low);
|
||||||
|
if(keyphase_variables[i].automatic_threshold)
|
||||||
|
ui->radioButton_automatic_threshold_1->setChecked(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_manual_threshold_1->setChecked(true);
|
||||||
|
ui->doubleSpinBox_threshold_1->setValue(keyphase_variables[i].threshold);
|
||||||
|
ui->doubleSpinBox_hysteresis_1->setValue(keyphase_variables[i].hysteresis);
|
||||||
|
ui->spinBox_events_per_revolution_1->setValue(keyphase_variables[i].events_per_revolution);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(keyphase_variables[i].id == 2)
|
||||||
|
{
|
||||||
|
ui->checkBox_enable_2->setChecked(keyphase_variables[i].active);
|
||||||
|
ui->doubleSpinBox_high_2->setValue(keyphase_variables[i].normal_voltage_high);
|
||||||
|
ui->doubleSpinBox_low_2->setValue(keyphase_variables[i].normal_voltage_low);
|
||||||
|
if(keyphase_variables[i].automatic_threshold)
|
||||||
|
ui->radioButton_automatic_threshold_2->setChecked(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_manual_threshold_2->setChecked(true);
|
||||||
|
ui->doubleSpinBox_threshold_2->setValue(keyphase_variables[i].threshold);
|
||||||
|
ui->doubleSpinBox_hysteresis_2->setValue(keyphase_variables[i].hysteresis);
|
||||||
|
ui->spinBox_events_per_revolution_2->setValue(keyphase_variables[i].events_per_revolution);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(keyphase_variables[i].id == 3){
|
||||||
|
ui->checkBox_enable_3->setChecked(keyphase_variables[i].active);
|
||||||
|
ui->doubleSpinBox_high_3->setValue(keyphase_variables[i].normal_voltage_high);
|
||||||
|
ui->doubleSpinBox_low_3->setValue(keyphase_variables[i].normal_voltage_low);
|
||||||
|
if(keyphase_variables[i].automatic_threshold)
|
||||||
|
ui->radioButton_automatic_threshold_3->setChecked(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_manual_threshold_3->setChecked(true);
|
||||||
|
ui->doubleSpinBox_threshold_3->setValue(keyphase_variables[i].threshold);
|
||||||
|
ui->doubleSpinBox_hysteresis_3->setValue(keyphase_variables[i].hysteresis);
|
||||||
|
ui->spinBox_events_per_revolution_3->setValue(keyphase_variables[i].events_per_revolution);
|
||||||
|
}
|
||||||
|
if(keyphase_variables[i].id == 4){
|
||||||
|
ui->checkBox_enable_4->setChecked(keyphase_variables[i].active);
|
||||||
|
ui->doubleSpinBox_high_4->setValue(keyphase_variables[i].normal_voltage_high);
|
||||||
|
ui->doubleSpinBox_low_4->setValue(keyphase_variables[i].normal_voltage_low);
|
||||||
|
if(keyphase_variables[i].automatic_threshold)
|
||||||
|
ui->radioButton_automatic_threshold_4->setChecked(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_manual_threshold_4->setChecked(true);
|
||||||
|
ui->doubleSpinBox_threshold_4->setValue(keyphase_variables[i].threshold);
|
||||||
|
ui->doubleSpinBox_hysteresis_4->setValue(keyphase_variables[i].hysteresis);
|
||||||
|
ui->spinBox_events_per_revolution_4->setValue(keyphase_variables[i].events_per_revolution);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
void KeyPhase::on_pushButton_confirm_clicked()
|
void KeyPhase::on_pushButton_confirm_clicked()
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||||
|
if(keyphase_variables[i].id == 1){
|
||||||
|
keyphase_variables[i].active = ui->checkBox_enable_1->isChecked();
|
||||||
|
keyphase_variables[i].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||||
|
keyphase_variables[i].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||||
|
keyphase_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_1->isChecked();
|
||||||
|
keyphase_variables[i].threshold = ui->doubleSpinBox_threshold_1->value();
|
||||||
|
keyphase_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_1->value();
|
||||||
|
keyphase_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value();
|
||||||
|
}
|
||||||
|
if(keyphase_variables[i].id == 2){
|
||||||
|
keyphase_variables[i].active = ui->checkBox_enable_2->isChecked();
|
||||||
|
keyphase_variables[i].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||||
|
keyphase_variables[i].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||||
|
keyphase_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_2->isChecked();
|
||||||
|
keyphase_variables[i].threshold = ui->doubleSpinBox_threshold_2->value();
|
||||||
|
keyphase_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_2->value();
|
||||||
|
keyphase_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value();
|
||||||
|
}
|
||||||
|
if(keyphase_variables[i].id == 3){
|
||||||
|
keyphase_variables[i].active = ui->checkBox_enable_3->isChecked();
|
||||||
|
keyphase_variables[i].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||||
|
keyphase_variables[i].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||||
|
keyphase_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_3->isChecked();
|
||||||
|
keyphase_variables[i].threshold = ui->doubleSpinBox_threshold_3->value();
|
||||||
|
keyphase_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_3->value();
|
||||||
|
keyphase_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value();
|
||||||
|
}
|
||||||
|
if(keyphase_variables[i].id == 4){
|
||||||
|
keyphase_variables[i].active = ui->checkBox_enable_4->isChecked();
|
||||||
|
keyphase_variables[i].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||||
|
keyphase_variables[i].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||||
|
keyphase_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_4->isChecked();
|
||||||
|
keyphase_variables[i].threshold = ui->doubleSpinBox_threshold_4->value();
|
||||||
|
keyphase_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_4->value();
|
||||||
|
keyphase_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QString slot = QString("%1").arg(slot_no);
|
||||||
|
QString filePath_keyphase = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\keyphase.json").arg(slot_no);
|
||||||
|
QFile file(filePath_keyphase);
|
||||||
|
if(!file.open(QIODevice::WriteOnly))
|
||||||
|
{
|
||||||
|
qDebug() << "Could not open file for writing";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QJsonObject json_obj;
|
||||||
|
QJsonArray chan_array;
|
||||||
|
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||||
|
QJsonObject temp_obj;
|
||||||
|
temp_obj.insert("id", keyphase_variables[i].id);
|
||||||
|
temp_obj.insert("active", keyphase_variables[i].active);
|
||||||
|
QJsonArray voltage_range_array;
|
||||||
|
voltage_range_array.append(keyphase_variables[i].normal_voltage_low);
|
||||||
|
voltage_range_array.append(keyphase_variables[i].normal_voltage_high);
|
||||||
|
temp_obj.insert("normal_voltage_range", voltage_range_array);
|
||||||
|
temp_obj.insert("threshold", keyphase_variables[i].threshold);
|
||||||
|
temp_obj.insert("hysteresis", keyphase_variables[i].hysteresis);
|
||||||
|
temp_obj.insert("events_per_revolution", keyphase_variables[i].events_per_revolution);
|
||||||
|
chan_array.append(temp_obj);
|
||||||
|
}
|
||||||
|
json_obj.insert("chan", chan_array);
|
||||||
|
json_obj.insert("version",1);
|
||||||
|
json_obj.insert("slot",slot_no);
|
||||||
|
json_obj.insert("card_type",2);
|
||||||
|
QJsonDocument json_doc;
|
||||||
|
json_doc.setObject(json_obj);
|
||||||
|
QByteArray byte_array = json_doc.toJson();
|
||||||
|
file.write(byte_array);
|
||||||
|
file.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define KEYPHASE_H
|
#define KEYPHASE_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include "data_config.h"
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class KeyPhase;
|
class KeyPhase;
|
||||||
}
|
}
|
||||||
@ -12,14 +12,18 @@ class KeyPhase : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit KeyPhase(QWidget *parent = nullptr);
|
explicit KeyPhase(int slot_no_,QWidget *parent = nullptr);
|
||||||
~KeyPhase();
|
~KeyPhase();
|
||||||
|
int slot_no;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_pushButton_confirm_clicked();
|
void on_pushButton_confirm_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::KeyPhase *ui;
|
Ui::KeyPhase *ui;
|
||||||
|
Tachometer_Variables keyphase_variables[4];
|
||||||
|
void readJsonFile(const QString &filePath);
|
||||||
|
void Init();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEYPHASE_H
|
#endif // KEYPHASE_H
|
||||||
|
1118
keyphase.ui
1118
keyphase.ui
File diff suppressed because it is too large
Load Diff
@ -97,7 +97,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini",QSettings::IniFormat);
|
QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini",QSettings::IniFormat);
|
||||||
|
|
||||||
g_strServerIp = settingsread.value("Server/IP").toString();
|
g_strServerIp = settingsread.value("Server/IP").toString();
|
||||||
connectServer();
|
//connectServer();
|
||||||
// 设置自定义日志处理函数
|
// 设置自定义日志处理函数
|
||||||
#ifndef QT_DEBUG
|
#ifndef QT_DEBUG
|
||||||
qInstallMessageHandler(messageHandler);
|
qInstallMessageHandler(messageHandler);
|
||||||
@ -172,7 +172,7 @@ void MainWindow::readJsonFile(const QString &filePath)
|
|||||||
if (value.isObject()) { // 处理数组中的对象,例如每个对象代表一个记录或用户等。
|
if (value.isObject()) { // 处理数组中的对象,例如每个对象代表一个记录或用户等。
|
||||||
QJsonObject obj = value.toObject();
|
QJsonObject obj = value.toObject();
|
||||||
slot_config.slot = obj["slot"].toInt();
|
slot_config.slot = obj["slot"].toInt();
|
||||||
slot_config.slot_type = obj["slot_type"].toInt();
|
slot_config.slot_type = obj["slot_type"].toString();
|
||||||
slot_config.chan_display = obj["chan_display"].toString();
|
slot_config.chan_display = obj["chan_display"].toString();
|
||||||
slot_config.rack_type = obj["rack_type"].toString();
|
slot_config.rack_type = obj["rack_type"].toString();
|
||||||
map_slot_config.insert(slot_id,slot_config);
|
map_slot_config.insert(slot_id,slot_config);
|
||||||
@ -306,17 +306,17 @@ void MainWindow::onMenuActionTriggered()
|
|||||||
QPushButton *button = qobject_cast<QPushButton*>(menu->parent());
|
QPushButton *button = qobject_cast<QPushButton*>(menu->parent());
|
||||||
if (button) {
|
if (button) {
|
||||||
qDebug() << "子菜单项被点击,所属按钮:" << button->objectName() << action->text();
|
qDebug() << "子菜单项被点击,所属按钮:" << button->objectName() << action->text();
|
||||||
int slot_type = action->text().mid(1,2).toInt();
|
QString slot_type = action->text().mid(1,6);
|
||||||
QString rack_type = action->text().right(action->text().length()-4);
|
QString rack_type = action->text().right(action->text().length()-8);
|
||||||
int button_id = button->objectName().right(button->objectName().length()-15).toInt();
|
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 ;
|
qDebug() << slot_type << rack_type << button_id << map_slot_config[button_id + 1].slot_type << map_slot_config[button_id + 2].slot_type ;
|
||||||
map_slot_config[button_id].slot_label->setStyleSheet("QLabel { color :#2980b9; font: bold 16px}");
|
map_slot_config[button_id].slot_label->setStyleSheet("QLabel { color :#2980b9; font: bold 16px}");
|
||||||
if(rack_type == "三冗余板卡" && (map_slot_config[button_id].slot_type != 0 || map_slot_config[button_id + 1].slot_type != 0 \
|
if(rack_type == "三冗余板卡" && (map_slot_config[button_id].slot_type != "" || map_slot_config[button_id + 1].slot_type != "" \
|
||||||
|| map_slot_config[button_id + 2].slot_type != 0)){
|
|| map_slot_config[button_id + 2].slot_type != "")){
|
||||||
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠三冗余板卡配置,请在创建新配置之前移除现有的配置!");
|
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠三冗余板卡配置,请在创建新配置之前移除现有的配置!");
|
||||||
return;
|
return;
|
||||||
}else if(rack_type == "三冗余板卡" && map_slot_config[button_id + 1].slot_type == 0 \
|
}else if(rack_type == "三冗余板卡" && map_slot_config[button_id + 1].slot_type == "" \
|
||||||
&& map_slot_config[button_id + 2].slot_type == 0){
|
&& map_slot_config[button_id + 2].slot_type == ""){
|
||||||
map_slot_config[button_id].slot_type = slot_type;
|
map_slot_config[button_id].slot_type = slot_type;
|
||||||
map_slot_config[button_id].rack_type = "TMR1";
|
map_slot_config[button_id].rack_type = "TMR1";
|
||||||
map_slot_config[button_id].slot_btn->setText(action->text());
|
map_slot_config[button_id].slot_btn->setText(action->text());
|
||||||
@ -330,10 +330,10 @@ void MainWindow::onMenuActionTriggered()
|
|||||||
map_slot_config[button_id + 2].slot_btn->setText(action->text());
|
map_slot_config[button_id + 2].slot_btn->setText(action->text());
|
||||||
map_slot_config[button_id + 2].chan_display = action->text();
|
map_slot_config[button_id + 2].chan_display = action->text();
|
||||||
}
|
}
|
||||||
if(rack_type == "两板卡" && (map_slot_config[button_id].slot_type != 0 || map_slot_config[button_id + 1].slot_type != 0 )){
|
if(rack_type == "两板卡" && (map_slot_config[button_id].slot_type != "" || map_slot_config[button_id + 1].slot_type != "" )){
|
||||||
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠两板卡配置,请在创建新配置之前移除现有的配置!");
|
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠两板卡配置,请在创建新配置之前移除现有的配置!");
|
||||||
return;
|
return;
|
||||||
}else if(rack_type == "两板卡" && map_slot_config[button_id + 1].slot_type == 0){
|
}else if(rack_type == "两板卡" && map_slot_config[button_id + 1].slot_type == ""){
|
||||||
map_slot_config[button_id].slot_type = slot_type;
|
map_slot_config[button_id].slot_type = slot_type;
|
||||||
map_slot_config[button_id].rack_type = "Double1";
|
map_slot_config[button_id].rack_type = "Double1";
|
||||||
map_slot_config[button_id].slot_btn->setText(action->text());
|
map_slot_config[button_id].slot_btn->setText(action->text());
|
||||||
@ -343,10 +343,10 @@ void MainWindow::onMenuActionTriggered()
|
|||||||
map_slot_config[button_id + 1].slot_btn->setText(action->text());
|
map_slot_config[button_id + 1].slot_btn->setText(action->text());
|
||||||
map_slot_config[button_id + 1].chan_display = action->text();
|
map_slot_config[button_id + 1].chan_display = action->text();
|
||||||
}
|
}
|
||||||
if(rack_type == "单板卡" && map_slot_config[button_id].slot_type != 0){
|
if(rack_type == "单板卡" && map_slot_config[button_id].slot_type != ""){
|
||||||
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠单板卡配置,请在创建新配置之前移除现有的配置!");
|
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠单板卡配置,请在创建新配置之前移除现有的配置!");
|
||||||
return;
|
return;
|
||||||
}else if(rack_type == "单板卡" && map_slot_config[button_id].slot_type == 0) {
|
}else if(rack_type == "单板卡" && map_slot_config[button_id].slot_type == "") {
|
||||||
map_slot_config[button_id].slot_type = slot_type;
|
map_slot_config[button_id].slot_type = slot_type;
|
||||||
map_slot_config[button_id].rack_type = "Single";
|
map_slot_config[button_id].rack_type = "Single";
|
||||||
map_slot_config[button_id].chan_display = action->text();
|
map_slot_config[button_id].chan_display = action->text();
|
||||||
@ -355,68 +355,68 @@ void MainWindow::onMenuActionTriggered()
|
|||||||
|
|
||||||
if(action->text() == "重置模块"){
|
if(action->text() == "重置模块"){
|
||||||
if(map_slot_config[button_id].rack_type == "TMR1"){
|
if(map_slot_config[button_id].rack_type == "TMR1"){
|
||||||
map_slot_config[button_id].slot_type = 0;
|
map_slot_config[button_id].slot_type = "";
|
||||||
map_slot_config[button_id].rack_type = "0";
|
map_slot_config[button_id].rack_type = "0";
|
||||||
map_slot_config[button_id].slot_btn->setText("");
|
map_slot_config[button_id].slot_btn->setText("");
|
||||||
map_slot_config[button_id].chan_display = "";
|
map_slot_config[button_id].chan_display = "";
|
||||||
map_slot_config[button_id + 1].slot_type = 0;
|
map_slot_config[button_id + 1].slot_type = "";
|
||||||
map_slot_config[button_id + 1].rack_type = "0";
|
map_slot_config[button_id + 1].rack_type = "0";
|
||||||
map_slot_config[button_id + 1].slot_btn->setText("");
|
map_slot_config[button_id + 1].slot_btn->setText("");
|
||||||
map_slot_config[button_id + 1].chan_display = "";
|
map_slot_config[button_id + 1].chan_display = "";
|
||||||
map_slot_config[button_id + 2].slot_type = 0;
|
map_slot_config[button_id + 2].slot_type = "";
|
||||||
map_slot_config[button_id + 2].rack_type = "0";
|
map_slot_config[button_id + 2].rack_type = "0";
|
||||||
map_slot_config[button_id + 2].slot_btn->setText("");
|
map_slot_config[button_id + 2].slot_btn->setText("");
|
||||||
map_slot_config[button_id + 2].chan_display = "";
|
map_slot_config[button_id + 2].chan_display = "";
|
||||||
}else if(map_slot_config[button_id].rack_type == "TMR2"){
|
}else if(map_slot_config[button_id].rack_type == "TMR2"){
|
||||||
map_slot_config[button_id - 1].slot_type = 0;
|
map_slot_config[button_id - 1].slot_type = "";
|
||||||
map_slot_config[button_id - 1].rack_type = "0";
|
map_slot_config[button_id - 1].rack_type = "0";
|
||||||
map_slot_config[button_id - 1].slot_btn->setText("");
|
map_slot_config[button_id - 1].slot_btn->setText("");
|
||||||
map_slot_config[button_id - 1].chan_display = "";
|
map_slot_config[button_id - 1].chan_display = "";
|
||||||
map_slot_config[button_id].slot_type = 0;
|
map_slot_config[button_id].slot_type = "";
|
||||||
map_slot_config[button_id].rack_type = "0";
|
map_slot_config[button_id].rack_type = "0";
|
||||||
map_slot_config[button_id].slot_btn->setText("");
|
map_slot_config[button_id].slot_btn->setText("");
|
||||||
map_slot_config[button_id].chan_display = "";
|
map_slot_config[button_id].chan_display = "";
|
||||||
map_slot_config[button_id + 1].slot_type = 0;
|
map_slot_config[button_id + 1].slot_type = "";
|
||||||
map_slot_config[button_id + 1].rack_type = "0";
|
map_slot_config[button_id + 1].rack_type = "0";
|
||||||
map_slot_config[button_id + 1].slot_btn->setText("");
|
map_slot_config[button_id + 1].slot_btn->setText("");
|
||||||
map_slot_config[button_id + 1].chan_display = "";
|
map_slot_config[button_id + 1].chan_display = "";
|
||||||
}else if(map_slot_config[button_id].rack_type == "TMR3"){
|
}else if(map_slot_config[button_id].rack_type == "TMR3"){
|
||||||
map_slot_config[button_id - 2].slot_type = 0;
|
map_slot_config[button_id - 2].slot_type = "";
|
||||||
map_slot_config[button_id - 2].rack_type = "0";
|
map_slot_config[button_id - 2].rack_type = "0";
|
||||||
map_slot_config[button_id - 2].slot_btn->setText("");
|
map_slot_config[button_id - 2].slot_btn->setText("");
|
||||||
map_slot_config[button_id - 2].chan_display = "";
|
map_slot_config[button_id - 2].chan_display = "";
|
||||||
map_slot_config[button_id - 1].slot_type = 0;
|
map_slot_config[button_id - 1].slot_type = "";
|
||||||
map_slot_config[button_id - 1].rack_type = "0";
|
map_slot_config[button_id - 1].rack_type = "0";
|
||||||
map_slot_config[button_id - 1].slot_btn->setText("");
|
map_slot_config[button_id - 1].slot_btn->setText("");
|
||||||
map_slot_config[button_id - 1].chan_display = "";
|
map_slot_config[button_id - 1].chan_display = "";
|
||||||
map_slot_config[button_id].slot_type = 0;
|
map_slot_config[button_id].slot_type = "";
|
||||||
map_slot_config[button_id].rack_type = "0";
|
map_slot_config[button_id].rack_type = "0";
|
||||||
map_slot_config[button_id].slot_btn->setText("");
|
map_slot_config[button_id].slot_btn->setText("");
|
||||||
map_slot_config[button_id].chan_display = "";
|
map_slot_config[button_id].chan_display = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(map_slot_config[button_id].rack_type == "Double1"){
|
if(map_slot_config[button_id].rack_type == "Double1"){
|
||||||
map_slot_config[button_id].slot_type = 0;
|
map_slot_config[button_id].slot_type = "";
|
||||||
map_slot_config[button_id].rack_type = "0";
|
map_slot_config[button_id].rack_type = "0";
|
||||||
map_slot_config[button_id].slot_btn->setText("");
|
map_slot_config[button_id].slot_btn->setText("");
|
||||||
map_slot_config[button_id].chan_display = "";
|
map_slot_config[button_id].chan_display = "";
|
||||||
map_slot_config[button_id + 1].slot_type = 0;
|
map_slot_config[button_id + 1].slot_type = "";
|
||||||
map_slot_config[button_id + 1].rack_type = "0";
|
map_slot_config[button_id + 1].rack_type = "0";
|
||||||
map_slot_config[button_id + 1].slot_btn->setText("");
|
map_slot_config[button_id + 1].slot_btn->setText("");
|
||||||
map_slot_config[button_id + 1].chan_display = "";
|
map_slot_config[button_id + 1].chan_display = "";
|
||||||
|
|
||||||
}else if(map_slot_config[button_id].rack_type == "Double2"){
|
}else if(map_slot_config[button_id].rack_type == "Double2"){
|
||||||
map_slot_config[button_id - 1].slot_type = 0;
|
map_slot_config[button_id - 1].slot_type = "";
|
||||||
map_slot_config[button_id - 1].rack_type = "0";
|
map_slot_config[button_id - 1].rack_type = "0";
|
||||||
map_slot_config[button_id - 1].slot_btn->setText("");
|
map_slot_config[button_id - 1].slot_btn->setText("");
|
||||||
map_slot_config[button_id - 1].chan_display = "";
|
map_slot_config[button_id - 1].chan_display = "";
|
||||||
map_slot_config[button_id].slot_type = 0;
|
map_slot_config[button_id].slot_type = "";
|
||||||
map_slot_config[button_id].rack_type = "0";
|
map_slot_config[button_id].rack_type = "0";
|
||||||
map_slot_config[button_id].slot_btn->setText("");
|
map_slot_config[button_id].slot_btn->setText("");
|
||||||
map_slot_config[button_id].chan_display = "";
|
map_slot_config[button_id].chan_display = "";
|
||||||
}
|
}
|
||||||
if(map_slot_config[button_id].rack_type == "Single"){
|
if(map_slot_config[button_id].rack_type == "Single"){
|
||||||
map_slot_config[button_id].slot_type = 0;
|
map_slot_config[button_id].slot_type = "";
|
||||||
map_slot_config[button_id].rack_type = "0";
|
map_slot_config[button_id].rack_type = "0";
|
||||||
map_slot_config[button_id].slot_btn->setText("");
|
map_slot_config[button_id].slot_btn->setText("");
|
||||||
map_slot_config[button_id].chan_display = "";
|
map_slot_config[button_id].chan_display = "";
|
||||||
@ -444,19 +444,19 @@ void MainWindow::OnButtonGroup(QAbstractButton * slot_btn)
|
|||||||
int button_id = object_name.right(object_name.length()-15).toInt();
|
int button_id = object_name.right(object_name.length()-15).toInt();
|
||||||
SlotConfig slot_config = map_slot_config[button_id];
|
SlotConfig slot_config = map_slot_config[button_id];
|
||||||
map_slot_config[button_id].slot_label->setStyleSheet("QLabel { color :#2980b9; font: bold 16px}");
|
map_slot_config[button_id].slot_label->setStyleSheet("QLabel { color :#2980b9; font: bold 16px}");
|
||||||
if (slot_config.slot_type == KEYPHASOR){
|
if (slot_config.slot_type == "KPM834"){// 键相模块
|
||||||
KeyPhase *key_phase = new KeyPhase();
|
KeyPhase *key_phase = new KeyPhase(button_id);
|
||||||
key_phase->setWindowModality(Qt::ApplicationModal);
|
key_phase->setWindowModality(Qt::ApplicationModal);
|
||||||
key_phase->show();
|
key_phase->show();
|
||||||
}else if (slot_config.slot_type == RELAY){
|
}else if (slot_config.slot_type == "DOM810"){// 继电器模块
|
||||||
SingleRelay *single_relay = new SingleRelay();
|
SingleRelay *single_relay = new SingleRelay();
|
||||||
single_relay->setWindowModality(Qt::ApplicationModal);
|
single_relay->setWindowModality(Qt::ApplicationModal);
|
||||||
single_relay->show();
|
single_relay->show();
|
||||||
}else if (slot_config.slot_type == VIBRATE){
|
}else if (slot_config.slot_type == "HAM824"){// 振动模块
|
||||||
Seismic_monitor *seismic_monitor = new Seismic_monitor(button_id);
|
Seismic_monitor *seismic_monitor = new Seismic_monitor(button_id);
|
||||||
seismic_monitor->setWindowModality(Qt::ApplicationModal);
|
seismic_monitor->setWindowModality(Qt::ApplicationModal);
|
||||||
seismic_monitor->show();
|
seismic_monitor->show();
|
||||||
}else if (slot_config.slot_type == RPM){
|
}else if (slot_config.slot_type == "OPM844"){// 转速模块
|
||||||
Tachometer *tachometer = new Tachometer(button_id);
|
Tachometer *tachometer = new Tachometer(button_id);
|
||||||
tachometer->setWindowModality(Qt::ApplicationModal);
|
tachometer->setWindowModality(Qt::ApplicationModal);
|
||||||
tachometer->show();
|
tachometer->show();
|
||||||
@ -625,6 +625,7 @@ void MainWindow::sendUpgradePackage(int slot)
|
|||||||
qint64 chunkSize = 0;
|
qint64 chunkSize = 0;
|
||||||
if(MAX_CHUNK_SIZE < totalBytes - bytesSent){
|
if(MAX_CHUNK_SIZE < totalBytes - bytesSent){
|
||||||
chunkSize = MAX_CHUNK_SIZE;
|
chunkSize = MAX_CHUNK_SIZE;
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
chunkSize = totalBytes - bytesSent;
|
chunkSize = totalBytes - bytesSent;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ Radial_vibration::Radial_vibration(int slot_no_,int channel_,bool active,QWidget
|
|||||||
readJsonFile(filePath_filter);
|
readJsonFile(filePath_filter);
|
||||||
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\radial_vibration_variables_%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);
|
||||||
readJsonFile(filePath_variables);
|
readJsonFile(filePath_variables);
|
||||||
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Radial_vibration::~Radial_vibration()
|
Radial_vibration::~Radial_vibration()
|
||||||
@ -105,20 +106,18 @@ void Radial_vibration::readJsonFile(const QString &filePath)
|
|||||||
void Radial_vibration::Init()
|
void Radial_vibration::Init()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if(filter[i].checked){
|
if(filter[i].type == "band_pass"){
|
||||||
if(filter[i].type == "band_pass"){
|
ui->checkBox_band_pass->setChecked(filter[i].checked);
|
||||||
ui->checkBox_band_pass->setChecked(filter[i].checked);
|
ui->spinBox_band_pass_low->setValue(filter[i].low);
|
||||||
ui->spinBox_band_pass_low->setValue(filter[i].low);
|
ui->spinBox_band_pass_high->setValue(filter[i].high);
|
||||||
ui->spinBox_band_pass_high->setValue(filter[i].high);
|
}else if(filter[i].type == "low_pass"){
|
||||||
}else if(filter[i].type == "low_pass"){
|
ui->checkBox_low_pass->setChecked(filter[i].checked);
|
||||||
ui->checkBox_low_pass->setChecked(filter[i].checked);
|
ui->spinBox_low_pass_low->setValue(filter[i].low);
|
||||||
ui->spinBox_low_pass_low->setValue(filter[i].low);
|
ui->spinBox_low_pass_high->setValue(filter[i].high);
|
||||||
ui->spinBox_low_pass_high->setValue(filter[i].high);
|
}else if(filter[i].type == "high_pass"){
|
||||||
}else if(filter[i].type == "high_pass"){
|
ui->checkBox_high_pass->setChecked(filter[i].checked);
|
||||||
ui->checkBox_high_pass->setChecked(filter[i].checked);
|
ui->spinBox_high_pass_low->setValue(filter[i].low);
|
||||||
ui->spinBox_high_pass_low->setValue(filter[i].low);
|
ui->spinBox_high_pass_high->setValue(filter[i].high);
|
||||||
ui->spinBox_high_pass_high->setValue(filter[i].high);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
@ -129,21 +128,21 @@ void Radial_vibration::Init()
|
|||||||
ui->comboBox_gap_range->setCurrentText(variables[i].full_sacle_range);
|
ui->comboBox_gap_range->setCurrentText(variables[i].full_sacle_range);
|
||||||
ui->doubleSpinBox_gap_clamp->setValue(variables[i].clamp_value);
|
ui->doubleSpinBox_gap_clamp->setValue(variables[i].clamp_value);
|
||||||
}else if(variables[i].type == "1x_ampl"){
|
}else if(variables[i].type == "1x_ampl"){
|
||||||
ui->checkBox_1x_ampl->setCheckable(variables[i].checked);
|
ui->checkBox_1x_ampl->setChecked(variables[i].checked);
|
||||||
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);
|
||||||
ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].phase_lag);
|
ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].phase_lag);
|
||||||
}else if(variables[i].type == "2x_ampl"){
|
}else if(variables[i].type == "2x_ampl"){
|
||||||
ui->checkBox_2x_ampl->setCheckable(variables[i].checked);
|
ui->checkBox_2x_ampl->setChecked(variables[i].checked);
|
||||||
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);
|
||||||
ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].phase_lag);
|
ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].phase_lag);
|
||||||
}else if(variables[i].type == "not_1x_ampl"){
|
}else if(variables[i].type == "not_1x_ampl"){
|
||||||
ui->checkBox_not_1x_ampl->setCheckable(variables[i].checked);
|
ui->checkBox_not_1x_ampl->setChecked(variables[i].checked);
|
||||||
ui->comboBox_not_1x_ampl->setCurrentText(variables[i].full_sacle_range);
|
ui->comboBox_not_1x_ampl->setCurrentText(variables[i].full_sacle_range);
|
||||||
ui->doubleSpinBox_not_1x_ampl_clamp->setValue(variables[i].clamp_value);
|
ui->doubleSpinBox_not_1x_ampl_clamp->setValue(variables[i].clamp_value);
|
||||||
}else if(variables[i].type == "smax_ampl"){
|
}else if(variables[i].type == "smax_ampl"){
|
||||||
ui->checkBox_smax_ampl->setCheckable(variables[i].checked);
|
ui->checkBox_smax_ampl->setChecked(variables[i].checked);
|
||||||
ui->comboBox_smax_range->setCurrentText(variables[i].full_sacle_range);
|
ui->comboBox_smax_range->setCurrentText(variables[i].full_sacle_range);
|
||||||
ui->doubleSpinBox_smax_clamp->setValue(variables[i].clamp_value);
|
ui->doubleSpinBox_smax_clamp->setValue(variables[i].clamp_value);
|
||||||
}
|
}
|
||||||
@ -234,11 +233,22 @@ void Radial_vibration::on_pushButton_confirm_clicked()
|
|||||||
for(int i = 0; i < 6; i++){
|
for(int i = 0; i < 6; i++){
|
||||||
QJsonObject temp_obj;
|
QJsonObject temp_obj;
|
||||||
temp_obj.insert("type",variables[i].type);
|
temp_obj.insert("type",variables[i].type);
|
||||||
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
if(variables[i].type == "direct"){
|
||||||
temp_obj.insert("bias_voltage",variables[i].bias_voltage);
|
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||||
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||||
temp_obj.insert("phase_lag",variables[i].phase_lag);
|
}else if(variables[i].type == "gap"){
|
||||||
temp_obj.insert("checked",variables[i].checked);
|
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||||
|
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||||
|
}else if(variables[i].type == "1x_ampl" || variables[i].type == "2x_ampl"){
|
||||||
|
temp_obj.insert("checked",variables[i].checked);
|
||||||
|
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||||
|
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||||
|
temp_obj.insert("phase_lag",variables[i].phase_lag);
|
||||||
|
}else if(variables[i].type == "not_1x_ampl" || variables[i].type == "smax_ampl"){
|
||||||
|
temp_obj.insert("checked",variables[i].checked);
|
||||||
|
temp_obj.insert("full_sacle_range",variables[i].full_sacle_range);
|
||||||
|
temp_obj.insert("clamp_value",variables[i].clamp_value);
|
||||||
|
}
|
||||||
variables_array.append(temp_obj);
|
variables_array.append(temp_obj);
|
||||||
}
|
}
|
||||||
variables_obj.insert("variables",variables_array);
|
variables_obj.insert("variables",variables_array);
|
||||||
|
@ -75,12 +75,13 @@ void Seismic_monitor::Init()
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||||
if(seismic_monitor[i].id == 1){
|
if(seismic_monitor[i].id == 1){
|
||||||
|
qDebug() << seismic_monitor[i].channel_type ;
|
||||||
if(seismic_monitor[i].channel_type == "acceleration"){
|
if(seismic_monitor[i].channel_type == "acceleration"){
|
||||||
ui->comboBox_chan_type_1->setCurrentText("加速度");
|
ui->comboBox_chan_type_1->setCurrentText("加速度");
|
||||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||||
ui->comboBox_chan_type_1->setCurrentText("速度");
|
ui->comboBox_chan_type_1->setCurrentText("速度");
|
||||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||||
ui->comboBox_chan_type_1->setCurrentText("径向位移");
|
ui->comboBox_chan_type_1->setCurrentText("位移");
|
||||||
}
|
}
|
||||||
//ui->comboBox_transducer_name_1->setText(seismic_monitor[i].transducer_name);
|
//ui->comboBox_transducer_name_1->setText(seismic_monitor[i].transducer_name);
|
||||||
ui->lineEdit_scale_factor_1->setText(seismic_monitor[i].scale_factor);
|
ui->lineEdit_scale_factor_1->setText(seismic_monitor[i].scale_factor);
|
||||||
@ -97,7 +98,7 @@ void Seismic_monitor::Init()
|
|||||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||||
ui->comboBox_chan_type_2->setCurrentText("速度");
|
ui->comboBox_chan_type_2->setCurrentText("速度");
|
||||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||||
ui->comboBox_chan_type_2->setCurrentText("径向位移");
|
ui->comboBox_chan_type_2->setCurrentText("位移");
|
||||||
}
|
}
|
||||||
//ui->comboBox_transducer_name_2->setText(seismic_monitor[i].transducer_name);
|
//ui->comboBox_transducer_name_2->setText(seismic_monitor[i].transducer_name);
|
||||||
ui->lineEdit_scale_factor_2->setText(seismic_monitor[i].scale_factor);
|
ui->lineEdit_scale_factor_2->setText(seismic_monitor[i].scale_factor);
|
||||||
@ -114,7 +115,7 @@ void Seismic_monitor::Init()
|
|||||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||||
ui->comboBox_chan_type_3->setCurrentText("速度");
|
ui->comboBox_chan_type_3->setCurrentText("速度");
|
||||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||||
ui->comboBox_chan_type_3->setCurrentText("径向位移");
|
ui->comboBox_chan_type_3->setCurrentText("位移");
|
||||||
}
|
}
|
||||||
//ui->lineEdit_transducer_name_3->setText(seismic_monitor[i].transducer_name);
|
//ui->lineEdit_transducer_name_3->setText(seismic_monitor[i].transducer_name);
|
||||||
ui->lineEdit_scale_factor_3->setText(seismic_monitor[i].scale_factor);
|
ui->lineEdit_scale_factor_3->setText(seismic_monitor[i].scale_factor);
|
||||||
@ -131,7 +132,7 @@ void Seismic_monitor::Init()
|
|||||||
}else if(seismic_monitor[i].channel_type == "velocity"){
|
}else if(seismic_monitor[i].channel_type == "velocity"){
|
||||||
ui->comboBox_chan_type_4->setCurrentText("速度");
|
ui->comboBox_chan_type_4->setCurrentText("速度");
|
||||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
||||||
ui->comboBox_chan_type_4->setCurrentText("径向位移");
|
ui->comboBox_chan_type_4->setCurrentText("位移");
|
||||||
}
|
}
|
||||||
//ui->lineEdit_transducer_name_4->setText(seismic_monitor[i].transducer_name);
|
//ui->lineEdit_transducer_name_4->setText(seismic_monitor[i].transducer_name);
|
||||||
ui->lineEdit_scale_factor_4->setText(seismic_monitor[i].scale_factor);
|
ui->lineEdit_scale_factor_4->setText(seismic_monitor[i].scale_factor);
|
||||||
@ -221,17 +222,17 @@ void Seismic_monitor::on_pushButton_config_1_clicked()
|
|||||||
{
|
{
|
||||||
for (int i = 0 ;i < CHANNLE_COUNT ; i++) {
|
for (int i = 0 ;i < CHANNLE_COUNT ; i++) {
|
||||||
if(seismic_monitor[i].id == 1){
|
if(seismic_monitor[i].id == 1){
|
||||||
if(seismic_monitor[i].channel_type == "acceleration"){
|
if(ui->comboBox_chan_type_1->currentText() == "加速度"){
|
||||||
channel = 1;
|
channel = 1;
|
||||||
Acceleration *acceleration = new Acceleration(slot_no,channel,seismic_monitor[i].active);
|
Acceleration *acceleration = new Acceleration(slot_no,channel,seismic_monitor[i].active);
|
||||||
acceleration->setWindowModality(Qt::ApplicationModal);
|
acceleration->setWindowModality(Qt::ApplicationModal);
|
||||||
acceleration->show();
|
acceleration->show();
|
||||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
}else if(ui->comboBox_chan_type_1->currentText() == "位移"){
|
||||||
channel = 1;
|
channel = 1;
|
||||||
Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,seismic_monitor[i].active);
|
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(ui->comboBox_chan_type_1->currentText() == "速度"){
|
||||||
channel = 1;
|
channel = 1;
|
||||||
Velocity *velocity = new Velocity(slot_no,channel,seismic_monitor[i].active);
|
Velocity *velocity = new Velocity(slot_no,channel,seismic_monitor[i].active);
|
||||||
velocity->setWindowModality(Qt::ApplicationModal);
|
velocity->setWindowModality(Qt::ApplicationModal);
|
||||||
@ -246,17 +247,17 @@ void Seismic_monitor::on_pushButton_config_3_clicked()
|
|||||||
{
|
{
|
||||||
for (int i = 0 ;i < CHANNLE_COUNT ; i++) {
|
for (int i = 0 ;i < CHANNLE_COUNT ; i++) {
|
||||||
if(seismic_monitor[i].id == 3){
|
if(seismic_monitor[i].id == 3){
|
||||||
if(seismic_monitor[i].channel_type == "acceleration"){
|
if(seismic_monitor[i].channel_type == "加速度"){
|
||||||
channel = 3;
|
channel = 3;
|
||||||
Acceleration *acceleration = new Acceleration(slot_no,channel,seismic_monitor[i].active);
|
Acceleration *acceleration = new Acceleration(slot_no,channel,seismic_monitor[i].active);
|
||||||
acceleration->setWindowModality(Qt::ApplicationModal);
|
acceleration->setWindowModality(Qt::ApplicationModal);
|
||||||
acceleration->show();
|
acceleration->show();
|
||||||
}else if(seismic_monitor[i].channel_type == "proximeter"){
|
}else if(seismic_monitor[i].channel_type == "位移"){
|
||||||
channel = 3;
|
channel = 3;
|
||||||
Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,seismic_monitor[i].active);
|
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 == "速度"){
|
||||||
channel = 3;
|
channel = 3;
|
||||||
Velocity *velocity = new Velocity(slot_no,channel,seismic_monitor[i].active);
|
Velocity *velocity = new Velocity(slot_no,channel,seismic_monitor[i].active);
|
||||||
velocity->setWindowModality(Qt::ApplicationModal);
|
velocity->setWindowModality(Qt::ApplicationModal);
|
||||||
|
229
tachometer.cpp
229
tachometer.cpp
@ -15,7 +15,7 @@ Tachometer::Tachometer(int slot_no_,QWidget *parent)
|
|||||||
ui->widget_body->setProperty("flag", "body");
|
ui->widget_body->setProperty("flag", "body");
|
||||||
slot_no = slot_no_;
|
slot_no = slot_no_;
|
||||||
QString slot = QString("%1").arg(slot_no);
|
QString slot = QString("%1").arg(slot_no);
|
||||||
|
ui->label_slot->setText(slot);
|
||||||
QString filePath_tachometer = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\tachometer.json").arg(slot_no);
|
QString filePath_tachometer = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\tachometer.json").arg(slot_no);
|
||||||
readJsonFile(filePath_tachometer);
|
readJsonFile(filePath_tachometer);
|
||||||
Init();
|
Init();
|
||||||
@ -29,20 +29,23 @@ Tachometer::~Tachometer()
|
|||||||
void Tachometer::readJsonFile(const QString &filePath)
|
void Tachometer::readJsonFile(const QString &filePath)
|
||||||
{
|
{
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
if(!file.open(QIODevice::ReadOnly))
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
{
|
qDebug() << "Cannot open file for reading:" << filePath;
|
||||||
qDebug() << "Could not open file for reading";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QByteArray saveData = file.readAll();
|
QString content = file.readAll();
|
||||||
QJsonParseError json_error;
|
file.close();
|
||||||
QJsonDocument parse_doucment = QJsonDocument::fromJson(saveData, &json_error);
|
QByteArray jsonData = content.toUtf8();
|
||||||
if(json_error.error != QJsonParseError::NoError)
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||||
{
|
if (jsonDoc.isNull()) {
|
||||||
qDebug() << "json error!";
|
qDebug() << "Cannot parse JSON document";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json_obj = parse_doucment.object();
|
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||||
|
qDebug() << "JSON document is not an object or an array";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QJsonObject json_obj = jsonDoc.object();
|
||||||
QJsonArray chan_array = json_obj["chan"].toArray();
|
QJsonArray chan_array = json_obj["chan"].toArray();
|
||||||
for(int i = 0; i < chan_array.size(); i++){
|
for(int i = 0; i < chan_array.size(); i++){
|
||||||
QJsonObject temp_obj = chan_array[i].toObject();
|
QJsonObject temp_obj = chan_array[i].toObject();
|
||||||
@ -66,5 +69,207 @@ void Tachometer::readJsonFile(const QString &filePath)
|
|||||||
}
|
}
|
||||||
void Tachometer::Init()
|
void Tachometer::Init()
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||||
|
if(tachometer_variables[i].id == 1){
|
||||||
|
ui->checkBox_chan_1->setChecked(tachometer_variables[i].active);
|
||||||
|
ui->doubleSpinBox_high_1->setValue(tachometer_variables[i].normal_voltage_high);
|
||||||
|
ui->doubleSpinBox_low_1->setValue(tachometer_variables[i].normal_voltage_low);
|
||||||
|
if(tachometer_variables[i].automatic_threshold)
|
||||||
|
ui->radioButton_automatic_threshold_1->setChecked(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_manual_threshold_1->setChecked(true);
|
||||||
|
ui->doubleSpinBox_threshold_1->setValue(tachometer_variables[i].threshold);
|
||||||
|
ui->doubleSpinBox_hysteresis_1->setValue(tachometer_variables[i].hysteresis);
|
||||||
|
ui->spinBox_events_per_revolution_1->setValue(tachometer_variables[i].events_per_revolution);
|
||||||
|
ui->comboBox_record_output_1->setCurrentText(tachometer_variables[i].record_output);
|
||||||
|
ui->checkBox_two_ma_clamp_1->setChecked(tachometer_variables[i].two_ma_clamp);
|
||||||
|
if(tachometer_variables[i].alert_latching)
|
||||||
|
ui->radioButton_alert_latching_1->setCheckable(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_alert_latching_1->setCheckable(false);
|
||||||
|
if(tachometer_variables[i].overspeed_latching)
|
||||||
|
ui->radioButton_overspeed_latching_1->setCheckable(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_overspeed_latching_1->setCheckable(false);
|
||||||
|
}
|
||||||
|
if(tachometer_variables[i].id == 2){
|
||||||
|
ui->checkBox_chan_2->setChecked(tachometer_variables[i].active);
|
||||||
|
ui->doubleSpinBox_high_2->setValue(tachometer_variables[i].normal_voltage_high);
|
||||||
|
ui->doubleSpinBox_low_2->setValue(tachometer_variables[i].normal_voltage_low);
|
||||||
|
if(tachometer_variables[i].automatic_threshold)
|
||||||
|
ui->radioButton_automatic_threshold_2->setChecked(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_manual_threshold_2->setChecked(true);
|
||||||
|
ui->doubleSpinBox_threshold_2->setValue(tachometer_variables[i].threshold);
|
||||||
|
ui->doubleSpinBox_hysteresis_2->setValue(tachometer_variables[i].hysteresis);
|
||||||
|
ui->spinBox_events_per_revolution_2->setValue(tachometer_variables[i].events_per_revolution);
|
||||||
|
ui->comboBox_record_output_2->setCurrentText(tachometer_variables[i].record_output);
|
||||||
|
ui->checkBox_two_ma_clamp_2->setChecked(tachometer_variables[i].two_ma_clamp);
|
||||||
|
if(tachometer_variables[i].alert_latching)
|
||||||
|
ui->radioButton_alert_latching_2->setCheckable(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_alert_latching_2->setCheckable(false);
|
||||||
|
if(tachometer_variables[i].overspeed_latching)
|
||||||
|
ui->radioButton_overspeed_latching_2->setCheckable(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_overspeed_latching_2->setCheckable(false);
|
||||||
|
if(tachometer_variables[i].normal_latching)
|
||||||
|
ui->radioButton_normal_latching_2->setCheckable(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_not_normal_latching_2->setCheckable(false);
|
||||||
|
}
|
||||||
|
if(tachometer_variables[i].id == 3){
|
||||||
|
ui->checkBox_chan_3->setChecked(tachometer_variables[i].active);
|
||||||
|
ui->doubleSpinBox_high_3->setValue(tachometer_variables[i].normal_voltage_high);
|
||||||
|
ui->doubleSpinBox_low_3->setValue(tachometer_variables[i].normal_voltage_low);
|
||||||
|
if(tachometer_variables[i].automatic_threshold)
|
||||||
|
ui->radioButton_automatic_threshold_3->setChecked(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_manual_threshold_3->setChecked(true);
|
||||||
|
ui->doubleSpinBox_threshold_3->setValue(tachometer_variables[i].threshold);
|
||||||
|
ui->doubleSpinBox_hysteresis_3->setValue(tachometer_variables[i].hysteresis);
|
||||||
|
ui->spinBox_events_per_revolution_3->setValue(tachometer_variables[i].events_per_revolution);
|
||||||
|
ui->comboBox_record_output_3->setCurrentText(tachometer_variables[i].record_output);
|
||||||
|
ui->checkBox_two_ma_clamp_3->setChecked(tachometer_variables[i].two_ma_clamp);
|
||||||
|
if(tachometer_variables[i].alert_latching)
|
||||||
|
ui->radioButton_alert_latching_3->setCheckable(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_alert_latching_3->setCheckable(false);
|
||||||
|
if(tachometer_variables[i].overspeed_latching)
|
||||||
|
ui->radioButton_overspeed_latching_3->setCheckable(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_overspeed_latching_3->setCheckable(false);
|
||||||
|
if(tachometer_variables[i].normal_latching)
|
||||||
|
ui->radioButton_normal_latching_3->setCheckable(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_not_normal_latching_3->setCheckable(false);
|
||||||
|
}
|
||||||
|
if(tachometer_variables[i].id == 4){
|
||||||
|
ui->checkBox_chan_4->setChecked(tachometer_variables[i].active);
|
||||||
|
ui->doubleSpinBox_high_4->setValue(tachometer_variables[i].normal_voltage_high);
|
||||||
|
ui->doubleSpinBox_low_4->setValue(tachometer_variables[i].normal_voltage_low);
|
||||||
|
if(tachometer_variables[i].automatic_threshold)
|
||||||
|
ui->radioButton_automatic_threshold_4->setChecked(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_manual_threshold_4->setChecked(true);
|
||||||
|
ui->doubleSpinBox_threshold_4->setValue(tachometer_variables[i].threshold);
|
||||||
|
ui->doubleSpinBox_hysteresis_4->setValue(tachometer_variables[i].hysteresis);
|
||||||
|
ui->spinBox_events_per_revolution_4->setValue(tachometer_variables[i].events_per_revolution);
|
||||||
|
ui->comboBox_record_output_4->setCurrentText(tachometer_variables[i].record_output);
|
||||||
|
ui->checkBox_two_ma_clamp_4->setChecked(tachometer_variables[i].two_ma_clamp);
|
||||||
|
if(tachometer_variables[i].alert_latching)
|
||||||
|
ui->radioButton_alert_latching_4->setCheckable(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_alert_latching_4->setCheckable(false);
|
||||||
|
if(tachometer_variables[i].overspeed_latching)
|
||||||
|
ui->radioButton_overspeed_latching_4->setCheckable(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_overspeed_latching_4->setCheckable(false);
|
||||||
|
if(tachometer_variables[i].normal_latching)
|
||||||
|
ui->radioButton_normal_latching_4->setCheckable(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_not_normal_latching_4->setCheckable(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Tachometer::on_pushButton_confirm_clicked()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||||
|
if(tachometer_variables[i].id == 1){
|
||||||
|
tachometer_variables[i].active = ui->checkBox_chan_1->isChecked();
|
||||||
|
tachometer_variables[i].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||||
|
tachometer_variables[i].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||||
|
tachometer_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_1->isChecked();
|
||||||
|
tachometer_variables[i].threshold = ui->doubleSpinBox_threshold_1->value();
|
||||||
|
tachometer_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_1->value();
|
||||||
|
tachometer_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value();
|
||||||
|
tachometer_variables[i].record_output = ui->comboBox_record_output_1->currentText();
|
||||||
|
tachometer_variables[i].two_ma_clamp = ui->checkBox_two_ma_clamp_1->isChecked();
|
||||||
|
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_1->isChecked();
|
||||||
|
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_1->isChecked();
|
||||||
|
}
|
||||||
|
if(tachometer_variables[i].id == 2){
|
||||||
|
tachometer_variables[i].active = ui->checkBox_chan_2->isChecked();
|
||||||
|
tachometer_variables[i].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||||
|
tachometer_variables[i].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||||
|
tachometer_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_2->isChecked();
|
||||||
|
tachometer_variables[i].threshold = ui->doubleSpinBox_threshold_2->value();
|
||||||
|
tachometer_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_2->value();
|
||||||
|
tachometer_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value();
|
||||||
|
tachometer_variables[i].record_output = ui->comboBox_record_output_2->currentText();
|
||||||
|
tachometer_variables[i].two_ma_clamp = ui->checkBox_two_ma_clamp_2->isChecked();
|
||||||
|
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_2->isChecked();
|
||||||
|
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_2->isChecked();
|
||||||
|
tachometer_variables[i].normal_latching = ui->radioButton_normal_latching_2->isChecked();
|
||||||
|
}
|
||||||
|
if(tachometer_variables[i].id == 3){
|
||||||
|
tachometer_variables[i].active = ui->checkBox_chan_3->isChecked();
|
||||||
|
tachometer_variables[i].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||||
|
tachometer_variables[i].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||||
|
tachometer_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_3->isChecked();
|
||||||
|
tachometer_variables[i].threshold = ui->doubleSpinBox_threshold_3->value();
|
||||||
|
tachometer_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_3->value();
|
||||||
|
tachometer_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value();
|
||||||
|
tachometer_variables[i].record_output = ui->comboBox_record_output_3->currentText();
|
||||||
|
tachometer_variables[i].two_ma_clamp = ui->checkBox_two_ma_clamp_3->isChecked();
|
||||||
|
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_3->isChecked();
|
||||||
|
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_3->isChecked();
|
||||||
|
tachometer_variables[i].normal_latching = ui->radioButton_normal_latching_3->isChecked();
|
||||||
|
}
|
||||||
|
if(tachometer_variables[i].id == 4){
|
||||||
|
tachometer_variables[i].active = ui->checkBox_chan_4->isChecked();
|
||||||
|
tachometer_variables[i].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||||
|
tachometer_variables[i].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||||
|
tachometer_variables[i].automatic_threshold = ui->radioButton_automatic_threshold_4->isChecked();
|
||||||
|
tachometer_variables[i].threshold = ui->doubleSpinBox_threshold_4->value();
|
||||||
|
tachometer_variables[i].hysteresis = ui->doubleSpinBox_hysteresis_4->value();
|
||||||
|
tachometer_variables[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value();
|
||||||
|
tachometer_variables[i].record_output = ui->comboBox_record_output_4->currentText();
|
||||||
|
tachometer_variables[i].two_ma_clamp = ui->checkBox_two_ma_clamp_4->isChecked();
|
||||||
|
tachometer_variables[i].alert_latching = ui->radioButton_alert_latching_4->isChecked();
|
||||||
|
tachometer_variables[i].overspeed_latching = ui->radioButton_overspeed_latching_4->isChecked();
|
||||||
|
tachometer_variables[i].normal_latching = ui->radioButton_normal_latching_4->isChecked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QString slot = QString("%1").arg(slot_no);
|
||||||
|
QString filePath_tachometer = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\tachometer.json").arg(slot_no);
|
||||||
|
QFile file(filePath_tachometer);
|
||||||
|
if(!file.open(QIODevice::WriteOnly))
|
||||||
|
{
|
||||||
|
qDebug() << "Could not open file for writing";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QJsonObject json_obj;
|
||||||
|
QJsonArray chan_array;
|
||||||
|
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
||||||
|
QJsonObject temp_obj;
|
||||||
|
temp_obj.insert("id", tachometer_variables[i].id);
|
||||||
|
temp_obj.insert("active", tachometer_variables[i].active);
|
||||||
|
QJsonArray voltage_range_array;
|
||||||
|
voltage_range_array.append(tachometer_variables[i].normal_voltage_low);
|
||||||
|
voltage_range_array.append(tachometer_variables[i].normal_voltage_high);
|
||||||
|
temp_obj.insert("normal_voltage_range", voltage_range_array);
|
||||||
|
temp_obj.insert("threshold", tachometer_variables[i].threshold);
|
||||||
|
temp_obj.insert("hysteresis", tachometer_variables[i].hysteresis);
|
||||||
|
temp_obj.insert("events_per_revolution", tachometer_variables[i].events_per_revolution);
|
||||||
|
temp_obj.insert("record_output", tachometer_variables[i].record_output);
|
||||||
|
temp_obj.insert("two_ma_clamp", tachometer_variables[i].two_ma_clamp);
|
||||||
|
temp_obj.insert("alert_latching", tachometer_variables[i].alert_latching);
|
||||||
|
temp_obj.insert("overspeed_latching", tachometer_variables[i].overspeed_latching);
|
||||||
|
temp_obj.insert("normal_latching", tachometer_variables[i].normal_latching);
|
||||||
|
temp_obj.insert("alert_response_time", tachometer_variables[i].alert_response_time);
|
||||||
|
temp_obj.insert("danger_response_time", tachometer_variables[i].danger_response_time);
|
||||||
|
chan_array.append(temp_obj);
|
||||||
|
}
|
||||||
|
json_obj.insert("chan", chan_array);
|
||||||
|
json_obj.insert("version",1);
|
||||||
|
json_obj.insert("slot",slot_no);
|
||||||
|
json_obj.insert("card_type",2);
|
||||||
|
QJsonDocument json_doc;
|
||||||
|
json_doc.setObject(json_obj);
|
||||||
|
QByteArray byte_array = json_doc.toJson();
|
||||||
|
file.write(byte_array);
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,9 @@ public:
|
|||||||
explicit Tachometer(int slot_no_,QWidget *parent = nullptr);
|
explicit Tachometer(int slot_no_,QWidget *parent = nullptr);
|
||||||
~Tachometer();
|
~Tachometer();
|
||||||
int slot_no;
|
int slot_no;
|
||||||
|
private slots:
|
||||||
|
void on_pushButton_confirm_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Tachometer *ui;
|
Ui::Tachometer *ui;
|
||||||
|
|
||||||
|
1730
tachometer.ui
1730
tachometer.ui
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,7 @@ Velocity::Velocity(int slot_no_,int channel_,bool active,QWidget *parent)
|
|||||||
ui->label_active->setText("(停用)");
|
ui->label_active->setText("(停用)");
|
||||||
QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%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\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel);
|
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\velocity_variables_%2.json").arg(slot_no).arg(channel);
|
||||||
readJsonFile(filePath_variables);
|
readJsonFile(filePath_variables);
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ void Velocity::readJsonFile(const QString &filePath)
|
|||||||
filter[i].high = temp_obj["high"].toInt();
|
filter[i].high = temp_obj["high"].toInt();
|
||||||
filter[i].checked = temp_obj["checked"].toBool();
|
filter[i].checked = temp_obj["checked"].toBool();
|
||||||
}
|
}
|
||||||
}else if(filePath.contains("acceleration_variables_")){
|
}else if(filePath.contains("velocity_variables_")){
|
||||||
|
|
||||||
QJsonArray variables_array = json_obj["variables"].toArray();
|
QJsonArray variables_array = json_obj["variables"].toArray();
|
||||||
for(int i = 0; i < variables_array.size(); i++){
|
for(int i = 0; i < variables_array.size(); i++){
|
||||||
@ -224,7 +224,7 @@ void Velocity::on_pushButton_confirm_clicked()
|
|||||||
}
|
}
|
||||||
filter_file.write(filter_data);
|
filter_file.write(filter_data);
|
||||||
filter_file.close();
|
filter_file.close();
|
||||||
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel);
|
QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\velocity_variables_%2.json").arg(slot_no).arg(channel);
|
||||||
QJsonObject variables_obj;
|
QJsonObject variables_obj;
|
||||||
QJsonArray variables_array;
|
QJsonArray variables_array;
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 4; i++){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user