add keyphase codes.
This commit is contained in:
parent
d167660911
commit
fcae5b8236
@ -15,6 +15,7 @@ SOURCES += \
|
|||||||
common.cpp \
|
common.cpp \
|
||||||
config_mgr.cpp \
|
config_mgr.cpp \
|
||||||
keyphase.cpp \
|
keyphase.cpp \
|
||||||
|
keyphase_data.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
radial_vibration.cpp \
|
radial_vibration.cpp \
|
||||||
@ -37,6 +38,7 @@ HEADERS += \
|
|||||||
data_config.h \
|
data_config.h \
|
||||||
displacement_ds.h \
|
displacement_ds.h \
|
||||||
keyphase.h \
|
keyphase.h \
|
||||||
|
keyphase_data.h \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
radial_vibration.h \
|
radial_vibration.h \
|
||||||
relaysetting.h \
|
relaysetting.h \
|
||||||
|
@ -178,6 +178,16 @@ typedef struct {
|
|||||||
bool normal_latching;
|
bool normal_latching;
|
||||||
} TachometerVariables;
|
} TachometerVariables;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool active;
|
||||||
|
float normal_voltage_low;
|
||||||
|
float normal_voltage_high;
|
||||||
|
bool automatic_threshold;
|
||||||
|
float threshold;
|
||||||
|
float hysteresis;
|
||||||
|
int events_per_revolution;
|
||||||
|
} KeyphaseVariables;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
QString transducer_name;
|
QString transducer_name;
|
||||||
double scale_factor;
|
double scale_factor;
|
||||||
|
238
keyphase.cpp
238
keyphase.cpp
@ -6,6 +6,10 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
#include "data_config.h"
|
||||||
|
#include "config_mgr.h"
|
||||||
|
#include "keyphase_data.h"
|
||||||
|
|
||||||
KeyPhase::KeyPhase(int slot_no_, QWidget *parent)
|
KeyPhase::KeyPhase(int slot_no_, QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, ui(new Ui::KeyPhase) {
|
, ui(new Ui::KeyPhase) {
|
||||||
@ -15,8 +19,8 @@ KeyPhase::KeyPhase(int slot_no_, QWidget *parent)
|
|||||||
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);
|
ui->label_slot->setText(slot);
|
||||||
QString filePath_keyphase = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\keyphase.json").arg(slot_no);
|
// QString filePath_keyphase = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\keyphase.json").arg(slot_no);
|
||||||
readJsonFile(filePath_keyphase);
|
// readJsonFile(filePath_keyphase);
|
||||||
Init();
|
Init();
|
||||||
connect(ui->radioButton_manual_threshold_1, &QRadioButton::toggled, this, &KeyPhase::on_manual_threshold_1_clicked);
|
connect(ui->radioButton_manual_threshold_1, &QRadioButton::toggled, this, &KeyPhase::on_manual_threshold_1_clicked);
|
||||||
connect(ui->radioButton_manual_threshold_2, &QRadioButton::toggled, this, &KeyPhase::on_manual_threshold_2_clicked);
|
connect(ui->radioButton_manual_threshold_2, &QRadioButton::toggled, this, &KeyPhase::on_manual_threshold_2_clicked);
|
||||||
@ -72,169 +76,117 @@ void KeyPhase::on_manual_threshold_4_clicked(bool checked) {
|
|||||||
ui->doubleSpinBox_hysteresis_4->setEnabled(false);
|
ui->doubleSpinBox_hysteresis_4->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyPhase::readJsonFile(const QString &filePath) {
|
void KeyPhase::UpdateData(std::shared_ptr<KeyphaseData> &keyphase_data) {
|
||||||
QFile file(filePath);
|
keyphase_data->card_type_ = kCardKeyphase;
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
keyphase_data->slot_ = slot_no;
|
||||||
qDebug() << "Cannot open file for reading:" << filePath;
|
keyphase_data->version_ = 1;
|
||||||
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"].toInt();
|
|
||||||
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 < CHANNEL_COUNT; i++) {
|
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||||
if (keyphase_variables[i].id == 1) {
|
if (i + 1 == 1) {
|
||||||
ui->checkBox_enable_1->setChecked(keyphase_variables[i].active);
|
keyphase_data->variables_[i].active = ui->checkBox_enable_1->isChecked();
|
||||||
ui->doubleSpinBox_high_1->setValue(keyphase_variables[i].normal_voltage_high);
|
keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||||
ui->doubleSpinBox_low_1->setValue(keyphase_variables[i].normal_voltage_low);
|
keyphase_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||||
if (keyphase_variables[i].automatic_threshold) {
|
keyphase_data->variables_[i].automatic_threshold = ui->radioButton_automatic_threshold_1->isChecked();
|
||||||
|
keyphase_data->variables_[i].threshold = ui->doubleSpinBox_threshold_1->value();
|
||||||
|
keyphase_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_1->value();
|
||||||
|
keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value();
|
||||||
|
} else if (i + 1 == 2) {
|
||||||
|
keyphase_data->variables_[i].active = ui->checkBox_enable_2->isChecked();
|
||||||
|
keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||||
|
keyphase_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||||
|
keyphase_data->variables_[i].automatic_threshold = ui->radioButton_automatic_threshold_2->isChecked();
|
||||||
|
keyphase_data->variables_[i].threshold = ui->doubleSpinBox_threshold_2->value();
|
||||||
|
keyphase_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_2->value();
|
||||||
|
keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value();
|
||||||
|
} else if (i + 1 == 3) {
|
||||||
|
keyphase_data->variables_[i].active = ui->checkBox_enable_3->isChecked();
|
||||||
|
keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||||
|
keyphase_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||||
|
keyphase_data->variables_[i].automatic_threshold = ui->radioButton_automatic_threshold_3->isChecked();
|
||||||
|
keyphase_data->variables_[i].threshold = ui->doubleSpinBox_threshold_3->value();
|
||||||
|
keyphase_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_3->value();
|
||||||
|
keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value();
|
||||||
|
} else if (i + 1 == 4) {
|
||||||
|
keyphase_data->variables_[i].active = ui->checkBox_enable_4->isChecked();
|
||||||
|
keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||||
|
keyphase_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||||
|
keyphase_data->variables_[i].automatic_threshold = ui->radioButton_automatic_threshold_4->isChecked();
|
||||||
|
keyphase_data->variables_[i].threshold = ui->doubleSpinBox_threshold_4->value();
|
||||||
|
keyphase_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_4->value();
|
||||||
|
keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyPhase::Init() {
|
||||||
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||||
|
if (base_ptr == nullptr) {
|
||||||
|
// do nothing or use template to init it.
|
||||||
|
std::shared_ptr<KeyphaseData> keyphase_data = std::make_shared<KeyphaseData>();
|
||||||
|
ConfigMgr::Instance()->AddCard(keyphase_data);
|
||||||
|
UpdateData(keyphase_data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::shared_ptr<KeyphaseData> keyphase_data = std::dynamic_pointer_cast<KeyphaseData>(base_ptr);
|
||||||
|
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||||
|
if (i + 1 == 1) {
|
||||||
|
ui->checkBox_enable_1->setChecked(keyphase_data->variables_[i].active);
|
||||||
|
ui->doubleSpinBox_high_1->setValue(keyphase_data->variables_[i].normal_voltage_high);
|
||||||
|
ui->doubleSpinBox_low_1->setValue(keyphase_data->variables_[i].normal_voltage_low);
|
||||||
|
if (keyphase_data->variables_[i].automatic_threshold) {
|
||||||
ui->radioButton_automatic_threshold_1->setChecked(true);
|
ui->radioButton_automatic_threshold_1->setChecked(true);
|
||||||
} else {
|
} else {
|
||||||
ui->radioButton_manual_threshold_1->setChecked(true);
|
ui->radioButton_manual_threshold_1->setChecked(true);
|
||||||
}
|
}
|
||||||
ui->doubleSpinBox_threshold_1->setValue(keyphase_variables[i].threshold);
|
ui->doubleSpinBox_threshold_1->setValue(keyphase_data->variables_[i].threshold);
|
||||||
ui->doubleSpinBox_hysteresis_1->setValue(keyphase_variables[i].hysteresis);
|
ui->doubleSpinBox_hysteresis_1->setValue(keyphase_data->variables_[i].hysteresis);
|
||||||
ui->spinBox_events_per_revolution_1->setValue(keyphase_variables[i].events_per_revolution);
|
ui->spinBox_events_per_revolution_1->setValue(keyphase_data->variables_[i].events_per_revolution);
|
||||||
}
|
} else if (i + 1 == 2) {
|
||||||
if (keyphase_variables[i].id == 2) {
|
ui->checkBox_enable_2->setChecked(keyphase_data->variables_[i].active);
|
||||||
ui->checkBox_enable_2->setChecked(keyphase_variables[i].active);
|
ui->doubleSpinBox_high_2->setValue(keyphase_data->variables_[i].normal_voltage_high);
|
||||||
ui->doubleSpinBox_high_2->setValue(keyphase_variables[i].normal_voltage_high);
|
ui->doubleSpinBox_low_2->setValue(keyphase_data->variables_[i].normal_voltage_low);
|
||||||
ui->doubleSpinBox_low_2->setValue(keyphase_variables[i].normal_voltage_low);
|
if (keyphase_data->variables_[i].automatic_threshold) {
|
||||||
if (keyphase_variables[i].automatic_threshold) {
|
|
||||||
ui->radioButton_automatic_threshold_2->setChecked(true);
|
ui->radioButton_automatic_threshold_2->setChecked(true);
|
||||||
} else {
|
} else {
|
||||||
ui->radioButton_manual_threshold_2->setChecked(true);
|
ui->radioButton_manual_threshold_2->setChecked(true);
|
||||||
}
|
}
|
||||||
ui->doubleSpinBox_threshold_2->setValue(keyphase_variables[i].threshold);
|
ui->doubleSpinBox_threshold_2->setValue(keyphase_data->variables_[i].threshold);
|
||||||
ui->doubleSpinBox_hysteresis_2->setValue(keyphase_variables[i].hysteresis);
|
ui->doubleSpinBox_hysteresis_2->setValue(keyphase_data->variables_[i].hysteresis);
|
||||||
ui->spinBox_events_per_revolution_2->setValue(keyphase_variables[i].events_per_revolution);
|
ui->spinBox_events_per_revolution_2->setValue(keyphase_data->variables_[i].events_per_revolution);
|
||||||
}
|
} else if (i + 1 == 3) {
|
||||||
if (keyphase_variables[i].id == 3) {
|
ui->checkBox_enable_3->setChecked(keyphase_data->variables_[i].active);
|
||||||
ui->checkBox_enable_3->setChecked(keyphase_variables[i].active);
|
ui->doubleSpinBox_high_3->setValue(keyphase_data->variables_[i].normal_voltage_high);
|
||||||
ui->doubleSpinBox_high_3->setValue(keyphase_variables[i].normal_voltage_high);
|
ui->doubleSpinBox_low_3->setValue(keyphase_data->variables_[i].normal_voltage_low);
|
||||||
ui->doubleSpinBox_low_3->setValue(keyphase_variables[i].normal_voltage_low);
|
if (keyphase_data->variables_[i].automatic_threshold) {
|
||||||
if (keyphase_variables[i].automatic_threshold) {
|
|
||||||
ui->radioButton_automatic_threshold_3->setChecked(true);
|
ui->radioButton_automatic_threshold_3->setChecked(true);
|
||||||
} else {
|
} else {
|
||||||
ui->radioButton_manual_threshold_3->setChecked(true);
|
ui->radioButton_manual_threshold_3->setChecked(true);
|
||||||
}
|
}
|
||||||
ui->doubleSpinBox_threshold_3->setValue(keyphase_variables[i].threshold);
|
ui->doubleSpinBox_threshold_3->setValue(keyphase_data->variables_[i].threshold);
|
||||||
ui->doubleSpinBox_hysteresis_3->setValue(keyphase_variables[i].hysteresis);
|
ui->doubleSpinBox_hysteresis_3->setValue(keyphase_data->variables_[i].hysteresis);
|
||||||
ui->spinBox_events_per_revolution_3->setValue(keyphase_variables[i].events_per_revolution);
|
ui->spinBox_events_per_revolution_3->setValue(keyphase_data->variables_[i].events_per_revolution);
|
||||||
}
|
} else if (i + 1 == 4) {
|
||||||
if (keyphase_variables[i].id == 4) {
|
ui->checkBox_enable_4->setChecked(keyphase_data->variables_[i].active);
|
||||||
ui->checkBox_enable_4->setChecked(keyphase_variables[i].active);
|
ui->doubleSpinBox_high_4->setValue(keyphase_data->variables_[i].normal_voltage_high);
|
||||||
ui->doubleSpinBox_high_4->setValue(keyphase_variables[i].normal_voltage_high);
|
ui->doubleSpinBox_low_4->setValue(keyphase_data->variables_[i].normal_voltage_low);
|
||||||
ui->doubleSpinBox_low_4->setValue(keyphase_variables[i].normal_voltage_low);
|
if (keyphase_data->variables_[i].automatic_threshold) {
|
||||||
if (keyphase_variables[i].automatic_threshold) {
|
|
||||||
ui->radioButton_automatic_threshold_4->setChecked(true);
|
ui->radioButton_automatic_threshold_4->setChecked(true);
|
||||||
} else {
|
} else {
|
||||||
ui->radioButton_manual_threshold_4->setChecked(true);
|
ui->radioButton_manual_threshold_4->setChecked(true);
|
||||||
}
|
}
|
||||||
ui->doubleSpinBox_threshold_4->setValue(keyphase_variables[i].threshold);
|
ui->doubleSpinBox_threshold_4->setValue(keyphase_data->variables_[i].threshold);
|
||||||
ui->doubleSpinBox_hysteresis_4->setValue(keyphase_variables[i].hysteresis);
|
ui->doubleSpinBox_hysteresis_4->setValue(keyphase_data->variables_[i].hysteresis);
|
||||||
ui->spinBox_events_per_revolution_4->setValue(keyphase_variables[i].events_per_revolution);
|
ui->spinBox_events_per_revolution_4->setValue(keyphase_data->variables_[i].events_per_revolution);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void KeyPhase::on_pushButton_confirm_clicked() {
|
void KeyPhase::on_pushButton_confirm_clicked() {
|
||||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||||
if (keyphase_variables[i].id == 1) {
|
if (base_ptr == nullptr) {
|
||||||
keyphase_variables[i].active = ui->checkBox_enable_1->isChecked();
|
qCritical() << " should not be here";
|
||||||
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;
|
return;
|
||||||
}
|
}
|
||||||
QJsonObject json_obj;
|
std::shared_ptr<KeyphaseData> keyphase_data = std::dynamic_pointer_cast<KeyphaseData>(base_ptr);
|
||||||
QJsonArray chan_array;
|
UpdateData(keyphase_data);
|
||||||
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
this->close();
|
||||||
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);
|
|
||||||
temp_obj.insert("automatic_threshold", keyphase_variables[i].automatic_threshold);
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#ifndef KEYPHASE_H
|
#ifndef KEYPHASE_H
|
||||||
#define KEYPHASE_H
|
#define KEYPHASE_H
|
||||||
|
#include <memory>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "data_config.h"
|
#include "data_config.h"
|
||||||
|
#include "keyphase_data.h"
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class KeyPhase;
|
class KeyPhase;
|
||||||
}
|
}
|
||||||
@ -24,8 +25,9 @@ class KeyPhase : public QDialog {
|
|||||||
void on_manual_threshold_4_clicked(bool checked);
|
void on_manual_threshold_4_clicked(bool checked);
|
||||||
private:
|
private:
|
||||||
Ui::KeyPhase *ui;
|
Ui::KeyPhase *ui;
|
||||||
TachometerVariables keyphase_variables[4];
|
void UpdateData(std::shared_ptr<KeyphaseData> &keyphase_data);
|
||||||
void readJsonFile(const QString &filePath);
|
// TachometerVariables keyphase_variables[4];
|
||||||
|
// void readJsonFile(const QString &filePath);
|
||||||
void Init();
|
void Init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
6
keyphase_data.cpp
Normal file
6
keyphase_data.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "keyphase_data.h"
|
||||||
|
|
||||||
|
KeyphaseData::KeyphaseData()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
11
keyphase_data.h
Normal file
11
keyphase_data.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef KEYPHASEDATA_H
|
||||||
|
#define KEYPHASEDATA_H
|
||||||
|
|
||||||
|
#include "cardbase.h"
|
||||||
|
class KeyphaseData : public CardBase {
|
||||||
|
public:
|
||||||
|
KeyphaseData();
|
||||||
|
KeyphaseVariables variables_[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // KEYPHASEDATA_H
|
Loading…
x
Reference in New Issue
Block a user