diff --git a/acceleration.cpp b/acceleration.cpp index 289ee91..08ae265 100644 --- a/acceleration.cpp +++ b/acceleration.cpp @@ -155,20 +155,18 @@ void Acceleration::Init() void Acceleration::on_pushButton_confirm_clicked() { for (int i = 0; i < 3; i++) { - if(filter[i].checked){ - if(filter[i].type == "band_pass"){ - filter[i].checked = ui->checkBox_band_pass->isChecked(); - filter[i].low = ui->spinBox_band_pass_low->value(); - filter[i].high = ui->spinBox_band_pass_high->value(); - }else if(filter[i].type == "low_pass"){ - filter[i].checked = ui->checkBox_low_pass->isChecked(); - filter[i].low = ui->spinBox_low_pass_low->value(); - filter[i].high = ui->spinBox_low_pass_high->value(); - }else if(filter[i].type == "high_pass"){ - filter[i].checked = ui->checkBox_high_pass->isChecked(); - filter[i].low = ui->spinBox_high_pass_low->value(); - filter[i].high = ui->spinBox_high_pass_high->value(); - } + if(filter[i].type == "band_pass"){ + filter[i].checked = ui->checkBox_band_pass->isChecked(); + filter[i].low = ui->spinBox_band_pass_low->value(); + filter[i].high = ui->spinBox_band_pass_high->value(); + }else if(filter[i].type == "low_pass"){ + filter[i].checked = ui->checkBox_low_pass->isChecked(); + filter[i].low = ui->spinBox_low_pass_low->value(); + filter[i].high = ui->spinBox_low_pass_high->value(); + }else if(filter[i].type == "high_pass"){ + filter[i].checked = ui->checkBox_high_pass->isChecked(); + filter[i].low = ui->spinBox_high_pass_low->value(); + filter[i].high = ui->spinBox_high_pass_high->value(); } } for (int i = 0; i < 4; i++) { @@ -223,11 +221,18 @@ void Acceleration::on_pushButton_confirm_clicked() for(int i = 0; i < 4; i++){ QJsonObject temp_obj; temp_obj.insert("type",variables[i].type); - temp_obj.insert("full_sacle_range",variables[i].full_sacle_range); - temp_obj.insert("bias_voltage",variables[i].bias_voltage); - temp_obj.insert("clamp_value",variables[i].clamp_value); - temp_obj.insert("phase_lag",variables[i].phase_lag); - temp_obj.insert("checked",variables[i].checked); + if(variables[i].type == "direct"){ + temp_obj.insert("full_sacle_range",variables[i].full_sacle_range); + temp_obj.insert("clamp_value",variables[i].clamp_value); + }else if(variables[i].type == "bias_volt"){ + 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_obj.insert("variables",variables_array); diff --git a/data_config.h b/data_config.h index 1b5da65..e3a4cfb 100644 --- a/data_config.h +++ b/data_config.h @@ -13,7 +13,7 @@ extern QString g_strServerIp; // 服务端IP #define CHANNLE_COUNT 4 typedef struct { int slot; - int slot_type; + QString slot_type; QString chan_display; QString rack_type; QPushButton* slot_btn; @@ -29,14 +29,7 @@ enum CMTCommand { kRelayStatus = 6, kUpgradeProgress = 7 }; -enum SlotType{ - POWER = 10, - CONFIG = 20, - KEYPHASOR = 25, - RELAY = 30, - VIBRATE = 40, - RPM = 50 -}; + typedef struct{ int id; diff --git a/keyphase.cpp b/keyphase.cpp index 7bf1a16..de25ddb 100644 --- a/keyphase.cpp +++ b/keyphase.cpp @@ -1,21 +1,196 @@ #include "keyphase.h" #include "ui_keyphase.h" +#include +#include +#include +#include +#include -KeyPhase::KeyPhase(QWidget *parent) +KeyPhase::KeyPhase(int slot_no_,QWidget *parent) : QDialog(parent) , ui(new Ui::KeyPhase) { ui->setupUi(this); 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() { 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() { + 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(); } diff --git a/keyphase.h b/keyphase.h index 782ac21..069081b 100644 --- a/keyphase.h +++ b/keyphase.h @@ -2,7 +2,7 @@ #define KEYPHASE_H #include - +#include "data_config.h" namespace Ui { class KeyPhase; } @@ -12,14 +12,18 @@ class KeyPhase : public QDialog Q_OBJECT public: - explicit KeyPhase(QWidget *parent = nullptr); + explicit KeyPhase(int slot_no_,QWidget *parent = nullptr); ~KeyPhase(); + int slot_no; private slots: void on_pushButton_confirm_clicked(); private: Ui::KeyPhase *ui; + Tachometer_Variables keyphase_variables[4]; + void readJsonFile(const QString &filePath); + void Init(); }; #endif // KEYPHASE_H diff --git a/keyphase.ui b/keyphase.ui index 3717d29..8bf45df 100644 --- a/keyphase.ui +++ b/keyphase.ui @@ -7,7 +7,7 @@ 0 0 660 - 661 + 580 @@ -34,8 +34,8 @@ - 220 - 610 + 200 + 530 71 32 @@ -47,8 +47,8 @@ - 510 - 610 + 490 + 530 81 32 @@ -60,8 +60,8 @@ - 130 - 610 + 110 + 530 71 32 @@ -86,8 +86,8 @@ - 320 - 610 + 300 + 530 81 32 @@ -115,7 +115,7 @@ 10 60 281 - 541 + 451 @@ -125,7 +125,7 @@ 通道 1 - + 10 @@ -138,118 +138,11 @@ 启用 - - - - 10 - 370 - 251 - 81 - - - - 安装角度 - - - - - 10 - 40 - 58 - 16 - - - - 度数: - - - - - - 60 - 40 - 61 - 22 - - - - 179 - - - - - - 140 - 30 - 71 - 20 - - - - 左边 - - - - - - 140 - 50 - 81 - 20 - - - - 右边 - - - - - - - 10 - 327 - 58 - 16 - - - - 键齿数: - - - - - - 60 - 327 - 51 - 22 - - - - 1 - - - 255 - - - - - - 150 - 330 - 58 - 16 - - - - 1 - 255 - - 130 - 479 + 387 58 16 @@ -262,7 +155,7 @@ 68 - 472 + 380 51 32 @@ -398,11 +291,11 @@ - + 10 - 120 + 130 251 181 @@ -410,7 +303,7 @@ 阈值 - + 10 @@ -422,7 +315,7 @@ 类型 - + 10 @@ -438,10 +331,10 @@ true - + - 80 + 110 20 71 20 @@ -452,7 +345,7 @@ - + 20 @@ -465,7 +358,7 @@ 值: - + false @@ -481,7 +374,7 @@ 1 - + 140 @@ -494,7 +387,7 @@ -20.0 to 0.0 Volts - + 140 @@ -507,7 +400,7 @@ 0.2 to 2.5 Volts - + 10 @@ -520,7 +413,7 @@ 回差: - + false @@ -540,16 +433,11 @@ - - - - 通道 2 - - + 60 - 327 + 340 51 22 @@ -561,11 +449,24 @@ 255 - + + + + 150 + 343 + 58 + 16 + + + + 1 - 255 + + + 10 - 327 + 340 58 16 @@ -574,72 +475,12 @@ 键齿数: - - - - 10 - 370 - 251 - 81 - - - - 安装角度 - - - - - 10 - 40 - 58 - 16 - - - - 度数: - - - - - - 60 - 40 - 61 - 22 - - - - 179 - - - - - - 140 - 30 - 51 - 20 - - - - 左边 - - - - - - 140 - 50 - 61 - 20 - - - - 右边 - - - - + + + + 通道 2 + + 10 @@ -655,8 +496,8 @@ - 140 - 474 + 120 + 384 51 32 @@ -665,24 +506,11 @@ <=== - - - - 150 - 330 - 58 - 16 - - - - 1 - 255 - - - 80 - 480 + 60 + 390 58 16 @@ -691,148 +519,6 @@ 通道 1 - - - - 10 - 120 - 251 - 181 - - - - 阈值 - - - - - 10 - 30 - 201 - 51 - - - - 类型 - - - - - 10 - 20 - 99 - 20 - - - - 自动 - - - true - - - - - - 80 - 20 - 71 - 20 - - - - 手动 - - - - - - - 20 - 90 - 41 - 16 - - - - 值: - - - - - false - - - - 60 - 90 - 62 - 22 - - - - 1 - - - - - - 140 - 90 - 111 - 16 - - - - -20.0 to 0.0 Volts - - - - - - 140 - 130 - 101 - 16 - - - - 0.2 to 2.5 Volts - - - - - - 10 - 130 - 58 - 16 - - - - 回差: - - - - - false - - - - 60 - 130 - 62 - 22 - - - - 1 - - - 2.000000000000000 - - - @@ -845,7 +531,7 @@ 正常电压 - + 74 @@ -867,7 +553,7 @@ - + 74 @@ -960,55 +646,11 @@ - - - - - - 294 - 360 - 51 - 32 - - - - <=== - - - - - - 420 - 610 - 71 - 32 - - - - 打 印... - - - - - - 350 - 60 - 281 - 541 - - - - 0 - - - - 通道 3 - - + 60 - 327 + 340 51 22 @@ -1020,141 +662,11 @@ 255 - + 10 - 327 - 58 - 16 - - - - 键齿数: - - - - - - 10 - 370 - 251 - 81 - - - - 安装角度 - - - - - 10 - 40 - 58 - 16 - - - - 度数: - - - - - - 60 - 40 - 61 - 22 - - - - 179 - - - - - - 140 - 30 - 51 - 20 - - - - 左边 - - - - - - 140 - 50 - 61 - 20 - - - - 右边 - - - - - - - 10 - 10 - 51 - 20 - - - - 启用 - - - - - - 68 - 463 - 51 - 32 - - - - ===> - - - - - - 150 - 330 - 58 - 16 - - - - 1 - 255 - - - - - - 130 - 470 - 58 - 16 - - - - 通道 4 - - - - - - 10 - 120 + 130 251 181 @@ -1162,7 +674,7 @@ 阈值 - + 10 @@ -1174,7 +686,7 @@ 类型 - + 10 @@ -1190,10 +702,10 @@ true - + - 80 + 110 20 71 20 @@ -1204,7 +716,7 @@ - + 20 @@ -1217,7 +729,7 @@ 值: - + false @@ -1233,7 +745,7 @@ 1 - + 140 @@ -1246,7 +758,7 @@ -20.0 to 0.0 Volts - + 140 @@ -1259,7 +771,7 @@ 0.2 to 2.5 Volts - + 10 @@ -1272,7 +784,7 @@ 回差: - + false @@ -1292,6 +804,115 @@ + + + + 10 + 340 + 58 + 16 + + + + 键齿数: + + + + + + 150 + 343 + 58 + 16 + + + + 1 - 255 + + + + + + + + 294 + 360 + 51 + 32 + + + + <=== + + + + + + 400 + 530 + 71 + 32 + + + + 打 印... + + + + + + 350 + 60 + 281 + 451 + + + + 0 + + + + 通道 3 + + + + + 10 + 10 + 51 + 20 + + + + 启用 + + + + + + 68 + 383 + 51 + 32 + + + + ===> + + + + + + 130 + 390 + 58 + 16 + + + + 通道 4 + + @@ -1304,7 +925,7 @@ 正常电压 - + 74 @@ -1326,7 +947,7 @@ - + 74 @@ -1419,16 +1040,11 @@ - - - - 通道 4 - - + 60 - 327 + 340 51 22 @@ -1440,11 +1056,11 @@ 255 - + 10 - 327 + 340 58 16 @@ -1453,102 +1069,11 @@ 键齿数: - - - - 10 - 370 - 251 - 81 - - - - 安装角度 - - - - - 10 - 40 - 58 - 16 - - - - 度数: - - - - - - 60 - 40 - 61 - 22 - - - - 179 - - - - - - 140 - 30 - 71 - 20 - - - - 左边 - - - - - - 140 - 50 - 81 - 20 - - - - 右边 - - - - - - - 10 - 10 - 51 - 20 - - - - 启用 - - - - - - 120 - 470 - 51 - 32 - - - - <=== - - - + 150 - 330 + 343 58 16 @@ -1557,24 +1082,11 @@ 1 - 255 - - - - 60 - 480 - 58 - 16 - - - - 通道 3 - - - + 10 - 120 + 130 251 181 @@ -1582,7 +1094,7 @@ 阈值 - + 10 @@ -1594,7 +1106,7 @@ 类型 - + 10 @@ -1610,10 +1122,10 @@ true - + - 80 + 110 20 71 20 @@ -1624,7 +1136,7 @@ - + 20 @@ -1637,7 +1149,7 @@ 值: - + false @@ -1653,7 +1165,7 @@ 1 - + 140 @@ -1666,7 +1178,7 @@ -20.0 to 0.0 Volts - + 140 @@ -1679,7 +1191,7 @@ 0.2 to 2.5 Volts - + 10 @@ -1692,7 +1204,7 @@ 回差: - + false @@ -1712,6 +1224,50 @@ + + + + 通道 4 + + + + + 10 + 10 + 51 + 20 + + + + 启用 + + + + + + 130 + 380 + 51 + 32 + + + + <=== + + + + + + 70 + 390 + 58 + 16 + + + + 通道 3 + + @@ -1724,7 +1280,7 @@ 正常电压 - + 74 @@ -1746,7 +1302,7 @@ - + 74 @@ -1839,6 +1395,190 @@ + + + + 150 + 343 + 58 + 16 + + + + 1 - 255 + + + + + + 10 + 130 + 251 + 181 + + + + 阈值 + + + + + 10 + 30 + 201 + 51 + + + + 类型 + + + + + 10 + 20 + 99 + 20 + + + + 自动 + + + true + + + + + + 110 + 20 + 71 + 20 + + + + 手动 + + + + + + + 20 + 90 + 41 + 16 + + + + 值: + + + + + false + + + + 60 + 90 + 62 + 22 + + + + 1 + + + + + + 140 + 90 + 111 + 16 + + + + -20.0 to 0.0 Volts + + + + + + 140 + 130 + 101 + 16 + + + + 0.2 to 2.5 Volts + + + + + + 10 + 130 + 58 + 16 + + + + 回差: + + + + + false + + + + 60 + 130 + 62 + 22 + + + + 1 + + + 2.000000000000000 + + + + + + + 10 + 340 + 58 + 16 + + + + 键齿数: + + + + + + 60 + 340 + 51 + 22 + + + + 1 + + + 255 + + @@ -1859,7 +1599,7 @@ - + 5 @@ -1886,7 +1626,7 @@ - + 5-6 diff --git a/mainwindow.cpp b/mainwindow.cpp index b1134c1..803f05e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -97,7 +97,7 @@ MainWindow::MainWindow(QWidget *parent) QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini",QSettings::IniFormat); g_strServerIp = settingsread.value("Server/IP").toString(); - connectServer(); + //connectServer(); // 设置自定义日志处理函数 #ifndef QT_DEBUG qInstallMessageHandler(messageHandler); @@ -172,7 +172,7 @@ void MainWindow::readJsonFile(const QString &filePath) if (value.isObject()) { // 处理数组中的对象,例如每个对象代表一个记录或用户等。 QJsonObject obj = value.toObject(); 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.rack_type = obj["rack_type"].toString(); map_slot_config.insert(slot_id,slot_config); @@ -306,17 +306,17 @@ void MainWindow::onMenuActionTriggered() QPushButton *button = qobject_cast(menu->parent()); if (button) { qDebug() << "子菜单项被点击,所属按钮:" << button->objectName() << action->text(); - int slot_type = action->text().mid(1,2).toInt(); - QString rack_type = action->text().right(action->text().length()-4); + QString slot_type = action->text().mid(1,6); + QString rack_type = action->text().right(action->text().length()-8); 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 ; 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 \ - || map_slot_config[button_id + 2].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 != "")){ QMessageBox::information(this, QStringLiteral("提示"), "不要重叠三冗余板卡配置,请在创建新配置之前移除现有的配置!"); return; - }else if(rack_type == "三冗余板卡" && map_slot_config[button_id + 1].slot_type == 0 \ - && map_slot_config[button_id + 2].slot_type == 0){ + }else if(rack_type == "三冗余板卡" && map_slot_config[button_id + 1].slot_type == "" \ + && map_slot_config[button_id + 2].slot_type == ""){ map_slot_config[button_id].slot_type = slot_type; map_slot_config[button_id].rack_type = "TMR1"; 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].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("提示"), "不要重叠两板卡配置,请在创建新配置之前移除现有的配置!"); 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].rack_type = "Double1"; 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].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("提示"), "不要重叠单板卡配置,请在创建新配置之前移除现有的配置!"); 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].rack_type = "Single"; map_slot_config[button_id].chan_display = action->text(); @@ -355,68 +355,68 @@ void MainWindow::onMenuActionTriggered() if(action->text() == "重置模块"){ 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].slot_btn->setText(""); 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].slot_btn->setText(""); 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].slot_btn->setText(""); map_slot_config[button_id + 2].chan_display = ""; }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].slot_btn->setText(""); 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].slot_btn->setText(""); 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].slot_btn->setText(""); map_slot_config[button_id + 1].chan_display = ""; }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].slot_btn->setText(""); 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].slot_btn->setText(""); 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].slot_btn->setText(""); map_slot_config[button_id].chan_display = ""; } 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].slot_btn->setText(""); 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].slot_btn->setText(""); map_slot_config[button_id + 1].chan_display = ""; }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].slot_btn->setText(""); 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].slot_btn->setText(""); map_slot_config[button_id].chan_display = ""; } 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].slot_btn->setText(""); 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(); SlotConfig slot_config = map_slot_config[button_id]; map_slot_config[button_id].slot_label->setStyleSheet("QLabel { color :#2980b9; font: bold 16px}"); - if (slot_config.slot_type == KEYPHASOR){ - KeyPhase *key_phase = new KeyPhase(); + if (slot_config.slot_type == "KPM834"){// 键相模块 + KeyPhase *key_phase = new KeyPhase(button_id); key_phase->setWindowModality(Qt::ApplicationModal); key_phase->show(); - }else if (slot_config.slot_type == RELAY){ + }else if (slot_config.slot_type == "DOM810"){// 继电器模块 SingleRelay *single_relay = new SingleRelay(); single_relay->setWindowModality(Qt::ApplicationModal); 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->setWindowModality(Qt::ApplicationModal); seismic_monitor->show(); - }else if (slot_config.slot_type == RPM){ + }else if (slot_config.slot_type == "OPM844"){// 转速模块 Tachometer *tachometer = new Tachometer(button_id); tachometer->setWindowModality(Qt::ApplicationModal); tachometer->show(); @@ -625,6 +625,7 @@ void MainWindow::sendUpgradePackage(int slot) qint64 chunkSize = 0; if(MAX_CHUNK_SIZE < totalBytes - bytesSent){ chunkSize = MAX_CHUNK_SIZE; + }else{ chunkSize = totalBytes - bytesSent; } diff --git a/radial_vibration.cpp b/radial_vibration.cpp index daed2db..a094f70 100644 --- a/radial_vibration.cpp +++ b/radial_vibration.cpp @@ -25,6 +25,7 @@ Radial_vibration::Radial_vibration(int slot_no_,int channel_,bool active,QWidget readJsonFile(filePath_filter); QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\radial_vibration_variables_%2.json").arg(slot_no).arg(channel); readJsonFile(filePath_variables); + Init(); } Radial_vibration::~Radial_vibration() @@ -105,20 +106,18 @@ void Radial_vibration::readJsonFile(const QString &filePath) void Radial_vibration::Init() { for (int i = 0; i < 3; i++) { - if(filter[i].checked){ - if(filter[i].type == "band_pass"){ - ui->checkBox_band_pass->setChecked(filter[i].checked); - ui->spinBox_band_pass_low->setValue(filter[i].low); - ui->spinBox_band_pass_high->setValue(filter[i].high); - }else if(filter[i].type == "low_pass"){ - ui->checkBox_low_pass->setChecked(filter[i].checked); - ui->spinBox_low_pass_low->setValue(filter[i].low); - ui->spinBox_low_pass_high->setValue(filter[i].high); - }else if(filter[i].type == "high_pass"){ - ui->checkBox_high_pass->setChecked(filter[i].checked); - ui->spinBox_high_pass_low->setValue(filter[i].low); - ui->spinBox_high_pass_high->setValue(filter[i].high); - } + if(filter[i].type == "band_pass"){ + ui->checkBox_band_pass->setChecked(filter[i].checked); + ui->spinBox_band_pass_low->setValue(filter[i].low); + ui->spinBox_band_pass_high->setValue(filter[i].high); + }else if(filter[i].type == "low_pass"){ + ui->checkBox_low_pass->setChecked(filter[i].checked); + ui->spinBox_low_pass_low->setValue(filter[i].low); + ui->spinBox_low_pass_high->setValue(filter[i].high); + }else if(filter[i].type == "high_pass"){ + ui->checkBox_high_pass->setChecked(filter[i].checked); + ui->spinBox_high_pass_low->setValue(filter[i].low); + ui->spinBox_high_pass_high->setValue(filter[i].high); } } 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->doubleSpinBox_gap_clamp->setValue(variables[i].clamp_value); }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->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value); ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].phase_lag); }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->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value); ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].phase_lag); }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->doubleSpinBox_not_1x_ampl_clamp->setValue(variables[i].clamp_value); }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->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++){ QJsonObject temp_obj; temp_obj.insert("type",variables[i].type); - temp_obj.insert("full_sacle_range",variables[i].full_sacle_range); - temp_obj.insert("bias_voltage",variables[i].bias_voltage); - temp_obj.insert("clamp_value",variables[i].clamp_value); - temp_obj.insert("phase_lag",variables[i].phase_lag); - temp_obj.insert("checked",variables[i].checked); + if(variables[i].type == "direct"){ + temp_obj.insert("full_sacle_range",variables[i].full_sacle_range); + temp_obj.insert("clamp_value",variables[i].clamp_value); + }else if(variables[i].type == "gap"){ + 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_obj.insert("variables",variables_array); diff --git a/seismic_monitor.cpp b/seismic_monitor.cpp index b571bb9..9b5130c 100644 --- a/seismic_monitor.cpp +++ b/seismic_monitor.cpp @@ -75,12 +75,13 @@ void Seismic_monitor::Init() { for (int i = 0; i < CHANNLE_COUNT; i++) { if(seismic_monitor[i].id == 1){ + qDebug() << seismic_monitor[i].channel_type ; if(seismic_monitor[i].channel_type == "acceleration"){ ui->comboBox_chan_type_1->setCurrentText("加速度"); }else if(seismic_monitor[i].channel_type == "velocity"){ ui->comboBox_chan_type_1->setCurrentText("速度"); }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->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"){ ui->comboBox_chan_type_2->setCurrentText("速度"); }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->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"){ ui->comboBox_chan_type_3->setCurrentText("速度"); }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_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"){ ui->comboBox_chan_type_4->setCurrentText("速度"); }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_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++) { if(seismic_monitor[i].id == 1){ - if(seismic_monitor[i].channel_type == "acceleration"){ + if(ui->comboBox_chan_type_1->currentText() == "加速度"){ channel = 1; Acceleration *acceleration = new Acceleration(slot_no,channel,seismic_monitor[i].active); acceleration->setWindowModality(Qt::ApplicationModal); acceleration->show(); - }else if(seismic_monitor[i].channel_type == "proximeter"){ + }else if(ui->comboBox_chan_type_1->currentText() == "位移"){ channel = 1; Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,seismic_monitor[i].active); radial_vibration->setWindowModality(Qt::ApplicationModal); radial_vibration->show(); - }else if(seismic_monitor[i].channel_type == "velocity"){ + }else if(ui->comboBox_chan_type_1->currentText() == "速度"){ channel = 1; Velocity *velocity = new Velocity(slot_no,channel,seismic_monitor[i].active); velocity->setWindowModality(Qt::ApplicationModal); @@ -246,17 +247,17 @@ void Seismic_monitor::on_pushButton_config_3_clicked() { for (int i = 0 ;i < CHANNLE_COUNT ; i++) { if(seismic_monitor[i].id == 3){ - if(seismic_monitor[i].channel_type == "acceleration"){ + if(seismic_monitor[i].channel_type == "加速度"){ channel = 3; Acceleration *acceleration = new Acceleration(slot_no,channel,seismic_monitor[i].active); acceleration->setWindowModality(Qt::ApplicationModal); acceleration->show(); - }else if(seismic_monitor[i].channel_type == "proximeter"){ + }else if(seismic_monitor[i].channel_type == "位移"){ channel = 3; Radial_vibration *radial_vibration = new Radial_vibration(slot_no,channel,seismic_monitor[i].active); radial_vibration->setWindowModality(Qt::ApplicationModal); radial_vibration->show(); - }else if(seismic_monitor[i].channel_type == "velocity"){ + }else if(seismic_monitor[i].channel_type == "速度"){ channel = 3; Velocity *velocity = new Velocity(slot_no,channel,seismic_monitor[i].active); velocity->setWindowModality(Qt::ApplicationModal); diff --git a/tachometer.cpp b/tachometer.cpp index 00db006..999595e 100644 --- a/tachometer.cpp +++ b/tachometer.cpp @@ -15,7 +15,7 @@ Tachometer::Tachometer(int slot_no_,QWidget *parent) ui->widget_body->setProperty("flag", "body"); slot_no = 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); readJsonFile(filePath_tachometer); Init(); @@ -29,20 +29,23 @@ Tachometer::~Tachometer() void Tachometer::readJsonFile(const QString &filePath) { QFile file(filePath); - if(!file.open(QIODevice::ReadOnly)) - { - qDebug() << "Could not open file for reading"; + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << "Cannot open file for reading:" << filePath; 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!"; + QString content = file.readAll(); + file.close(); + QByteArray jsonData = content.toUtf8(); + QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData); + if (jsonDoc.isNull()) { + qDebug() << "Cannot parse JSON document"; 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(); for(int i = 0; i < chan_array.size(); i++){ QJsonObject temp_obj = chan_array[i].toObject(); @@ -66,5 +69,207 @@ void Tachometer::readJsonFile(const QString &filePath) } 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(); +} + diff --git a/tachometer.h b/tachometer.h index ca9acc2..9df2cec 100644 --- a/tachometer.h +++ b/tachometer.h @@ -15,6 +15,9 @@ public: explicit Tachometer(int slot_no_,QWidget *parent = nullptr); ~Tachometer(); int slot_no; +private slots: + void on_pushButton_confirm_clicked(); + private: Ui::Tachometer *ui; diff --git a/tachometer.ui b/tachometer.ui index 71cb0ee..9bed4e8 100644 --- a/tachometer.ui +++ b/tachometer.ui @@ -35,7 +35,7 @@ 打 印... - + 40 @@ -64,7 +64,7 @@ 取 消 - + 40 @@ -90,7 +90,7 @@ 另存为模板 - + 240 @@ -132,7 +132,7 @@ 加载预定义模板 - + 340 @@ -341,7 +341,7 @@ 类型 - + 10 @@ -357,10 +357,10 @@ true - + - 80 + 110 20 71 20 @@ -384,7 +384,7 @@ 值: - + false @@ -439,7 +439,7 @@ 回差: - + false @@ -483,7 +483,7 @@ 告警 - + 30 @@ -496,7 +496,7 @@ 锁存 - + 30 @@ -525,7 +525,7 @@ 超速 - + 30 @@ -538,7 +538,7 @@ 锁存 - + 30 @@ -556,7 +556,7 @@ - + 60 @@ -584,7 +584,7 @@ 记录输出 - + 50 @@ -604,7 +604,7 @@ - + 52 @@ -656,7 +656,7 @@ 危险响应时间: - + 180 @@ -672,7 +672,7 @@ true - + 180 @@ -694,191 +694,6 @@ 通道 2 - - - - 10 - 310 - 58 - 16 - - - - 键齿数: - - - - - - 150 - 313 - 58 - 16 - - - - 1 - 255 - - - - - - 310 - 130 - 371 - 131 - - - - 告警模式 - - - - - 10 - 30 - 151 - 91 - - - - 告警 - - - - - 30 - 30 - 71 - 20 - - - - 锁存 - - - - - - 30 - 60 - 71 - 20 - - - - 非锁存 - - - true - - - - - - - 180 - 33 - 141 - 91 - - - - 超速 - - - - - 30 - 30 - 71 - 20 - - - - 锁存 - - - - - - 30 - 60 - 71 - 20 - - - - 非锁存 - - - true - - - - - - - - 60 - 310 - 51 - 22 - - - - 1 - - - 255 - - - - - - 490 - 20 - 191 - 91 - - - - 记录输出 - - - - - 50 - 30 - 103 - 32 - - - - - 不输出 - - - - - 转速 - - - - - - - 52 - 67 - 101 - 20 - - - - 2 mA 默认值 - - - @@ -891,7 +706,7 @@ 正常模式 - + 30 @@ -904,7 +719,7 @@ 锁存 - + 30 @@ -921,77 +736,6 @@ - - - - 310 - 280 - 371 - 91 - - - - 响应时间(只读) - - - - - 70 - 30 - 101 - 16 - - - - 告警响应时间: - - - - - - 70 - 60 - 81 - 16 - - - - 危险响应时间: - - - - - - 180 - 30 - 61 - 21 - - - - 25ms - - - true - - - - - - 180 - 58 - 61 - 21 - - - - 25ms - - - true - - - @@ -1119,6 +863,262 @@ + + + + 10 + 310 + 58 + 16 + + + + 键齿数: + + + + + + 60 + 310 + 51 + 22 + + + + 1 + + + 255 + + + + + + 150 + 313 + 58 + 16 + + + + 1 - 255 + + + + + + 310 + 130 + 371 + 131 + + + + 告警模式 + + + + + 10 + 30 + 151 + 91 + + + + 告警 + + + + + 30 + 30 + 71 + 20 + + + + 锁存 + + + + + + 30 + 60 + 71 + 20 + + + + 非锁存 + + + true + + + + + + + 180 + 33 + 141 + 91 + + + + 超速 + + + + + 30 + 30 + 71 + 20 + + + + 锁存 + + + + + + 30 + 60 + 71 + 20 + + + + 非锁存 + + + true + + + + + + + + 480 + 20 + 191 + 91 + + + + 记录输出 + + + + + 50 + 30 + 103 + 32 + + + + + 不输出 + + + + + 转速 + + + + + + + 52 + 67 + 101 + 20 + + + + 2 mA 默认值 + + + + + + + 310 + 280 + 371 + 91 + + + + 响应时间(只读) + + + + + 70 + 30 + 101 + 16 + + + + 告警响应时间: + + + + + + 70 + 60 + 81 + 16 + + + + 危险响应时间: + + + + + + 180 + 30 + 61 + 21 + + + + 25ms + + + true + + + + + + 180 + 58 + 61 + 21 + + + + 25ms + + + true + + + @@ -1143,7 +1143,7 @@ 类型 - + 10 @@ -1159,10 +1159,10 @@ true - + - 80 + 110 20 71 20 @@ -1186,7 +1186,7 @@ 值: - + false @@ -1241,7 +1241,7 @@ 回差: - + false @@ -1266,446 +1266,6 @@ 通道 3 - - - - 10 - 310 - 58 - 16 - - - - 键齿数: - - - - - - 150 - 313 - 58 - 16 - - - - 1 - 255 - - - - - - 310 - 130 - 371 - 131 - - - - 告警模式 - - - - - 10 - 30 - 151 - 91 - - - - 告警 - - - - - 30 - 30 - 71 - 20 - - - - 锁存 - - - - - - 30 - 60 - 71 - 20 - - - - 非锁存 - - - true - - - - - - - 180 - 33 - 141 - 91 - - - - 超速 - - - - - 30 - 30 - 71 - 20 - - - - 锁存 - - - - - - 30 - 60 - 71 - 20 - - - - 非锁存 - - - true - - - - - - - - 60 - 310 - 51 - 22 - - - - 1 - - - 255 - - - - - - 490 - 20 - 191 - 91 - - - - 记录输出 - - - - - 50 - 30 - 103 - 32 - - - - - 不输出 - - - - - 转速 - - - - - - - 52 - 67 - 101 - 20 - - - - 2 mA 默认值 - - - - - - - 310 - 20 - 151 - 91 - - - - 正常模式 - - - - - 30 - 30 - 71 - 20 - - - - 锁存 - - - - - - 30 - 60 - 71 - 20 - - - - 非锁存 - - - true - - - - - - - 310 - 280 - 371 - 91 - - - - 响应时间(只读) - - - - - 70 - 30 - 101 - 16 - - - - 告警响应时间: - - - - - - 70 - 60 - 81 - 16 - - - - 危险响应时间: - - - - - - 180 - 30 - 61 - 21 - - - - 25ms - - - true - - - - - - 180 - 58 - 61 - 21 - - - - 25ms - - - true - - - - - - - 10 - 100 - 251 - 181 - - - - 阈值 - - - - - 10 - 30 - 201 - 51 - - - - 类型 - - - - - 10 - 20 - 99 - 20 - - - - 自动 - - - true - - - - - - 80 - 20 - 71 - 20 - - - - 手动 - - - - - - - 20 - 90 - 41 - 16 - - - - 值: - - - - - false - - - - 60 - 90 - 62 - 22 - - - - 1 - - - - - - 140 - 90 - 111 - 16 - - - - -20.0 to 0.0 Volts - - - - - - 140 - 130 - 101 - 16 - - - - 0.2 to 2.5 Volts - - - - - - 10 - 130 - 58 - 16 - - - - 回差: - - - - - false - - - - 60 - 130 - 62 - 22 - - - - 1 - - - 2.000000000000000 - - - @@ -1833,12 +1393,7 @@ - - - - 通道 4 - - + 10 @@ -1851,117 +1406,7 @@ 键齿数: - - - - 150 - 313 - 58 - 16 - - - - 1 - 255 - - - - - - 310 - 130 - 371 - 131 - - - - 告警模式 - - - - - 10 - 30 - 151 - 91 - - - - 告警 - - - - - 30 - 30 - 71 - 20 - - - - 锁存 - - - - - - 30 - 60 - 71 - 20 - - - - 非锁存 - - - true - - - - - - - 180 - 33 - 141 - 91 - - - - 超速 - - - - - 30 - 30 - 71 - 20 - - - - 锁存 - - - - - - 30 - 60 - 71 - 20 - - - - 非锁存 - - - true - - - - - + 60 @@ -1977,10 +1422,120 @@ 255 - + - 490 + 150 + 313 + 58 + 16 + + + + 1 - 255 + + + + + + 310 + 130 + 371 + 131 + + + + 告警模式 + + + + + 10 + 30 + 151 + 91 + + + + 告警 + + + + + 30 + 30 + 71 + 20 + + + + 锁存 + + + + + + 30 + 60 + 71 + 20 + + + + 非锁存 + + + true + + + + + + + 180 + 33 + 141 + 91 + + + + 超速 + + + + + 30 + 30 + 71 + 20 + + + + 锁存 + + + + + + 30 + 60 + 71 + 20 + + + + 非锁存 + + + true + + + + + + + + 480 20 191 91 @@ -1989,7 +1544,7 @@ 记录输出 - + 50 @@ -2009,7 +1564,7 @@ - + 52 @@ -2023,7 +1578,7 @@ - + 310 @@ -2035,7 +1590,7 @@ 正常模式 - + 30 @@ -2048,7 +1603,7 @@ 锁存 - + 30 @@ -2065,11 +1620,11 @@ - + 310 - 280 + 270 371 91 @@ -2077,7 +1632,7 @@ 响应时间(只读) - + 70 @@ -2090,7 +1645,7 @@ 告警响应时间: - + 70 @@ -2103,7 +1658,7 @@ 危险响应时间: - + 180 @@ -2119,7 +1674,7 @@ true - + 180 @@ -2136,11 +1691,11 @@ - + 10 - 100 + 110 251 181 @@ -2148,7 +1703,7 @@ 阈值 - + 10 @@ -2160,7 +1715,7 @@ 类型 - + 10 @@ -2176,10 +1731,10 @@ true - + - 80 + 110 20 71 20 @@ -2190,7 +1745,7 @@ - + 20 @@ -2203,7 +1758,7 @@ 值: - + false @@ -2219,7 +1774,7 @@ 1 - + 140 @@ -2232,7 +1787,7 @@ -20.0 to 0.0 Volts - + 140 @@ -2245,7 +1800,7 @@ 0.2 to 2.5 Volts - + 10 @@ -2258,7 +1813,7 @@ 回差: - + false @@ -2278,6 +1833,11 @@ + + + + 通道 4 + @@ -2405,9 +1965,449 @@ + + + + 150 + 313 + 58 + 16 + + + + 1 - 255 + + + + + + 60 + 310 + 51 + 22 + + + + 1 + + + 255 + + + + + + 10 + 310 + 58 + 16 + + + + 键齿数: + + + + + + 310 + 130 + 371 + 131 + + + + 告警模式 + + + + + 10 + 30 + 151 + 91 + + + + 告警 + + + + + 30 + 30 + 71 + 20 + + + + 锁存 + + + + + + 30 + 60 + 71 + 20 + + + + 非锁存 + + + true + + + + + + + 180 + 33 + 141 + 91 + + + + 超速 + + + + + 30 + 30 + 71 + 20 + + + + 锁存 + + + + + + 30 + 60 + 71 + 20 + + + + 非锁存 + + + true + + + + + + + + 470 + 20 + 191 + 91 + + + + 记录输出 + + + + + 50 + 30 + 103 + 32 + + + + + 不输出 + + + + + 转速 + + + + + + + 52 + 67 + 101 + 20 + + + + 2 mA 默认值 + + + + + + + 310 + 20 + 151 + 91 + + + + 正常模式 + + + + + 30 + 30 + 71 + 20 + + + + 锁存 + + + + + + 30 + 60 + 71 + 20 + + + + 非锁存 + + + true + + + + + + + 310 + 270 + 371 + 91 + + + + 响应时间(只读) + + + + + 70 + 30 + 101 + 16 + + + + 告警响应时间: + + + + + + 70 + 60 + 81 + 16 + + + + 危险响应时间: + + + + + + 180 + 30 + 61 + 21 + + + + 25ms + + + true + + + + + + 180 + 58 + 61 + 21 + + + + 25ms + + + true + + + + + + + 10 + 110 + 251 + 181 + + + + 阈值 + + + + + 10 + 30 + 201 + 51 + + + + 类型 + + + + + 10 + 20 + 99 + 20 + + + + 自动 + + + true + + + + + + 110 + 20 + 71 + 20 + + + + 手动 + + + + + + + 20 + 90 + 41 + 16 + + + + 值: + + + + + false + + + + 60 + 90 + 62 + 22 + + + + 1 + + + + + + 140 + 90 + 111 + 16 + + + + -20.0 to 0.0 Volts + + + + + + 140 + 130 + 101 + 16 + + + + 0.2 to 2.5 Volts + + + + + + 10 + 130 + 58 + 16 + + + + 回差: + + + + + false + + + + 60 + 130 + 62 + 22 + + + + 1 + + + 2.000000000000000 + + + - + 140 @@ -2454,7 +2454,7 @@ - + 7 diff --git a/velocity.cpp b/velocity.cpp index 73e58b1..88f317b 100644 --- a/velocity.cpp +++ b/velocity.cpp @@ -23,7 +23,7 @@ Velocity::Velocity(int slot_no_,int channel_,bool active,QWidget *parent) ui->label_active->setText("(停用)"); QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel); 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); Init(); } @@ -62,7 +62,7 @@ void Velocity::readJsonFile(const QString &filePath) filter[i].high = temp_obj["high"].toInt(); 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(); 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.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; QJsonArray variables_array; for(int i = 0; i < 4; i++){