add codes.
This commit is contained in:
parent
576fe1ffd1
commit
eaed2efaa5
117
acceleration.cpp
117
acceleration.cpp
@ -6,6 +6,10 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
#include "data_config.h"
|
||||||
|
#include "vibrationdata.h"
|
||||||
|
#include "config_mgr.h"
|
||||||
|
|
||||||
Acceleration::Acceleration(int slot_no_, int channel_, bool active, QWidget *parent) :
|
Acceleration::Acceleration(int slot_no_, int channel_, bool active, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::Acceleration) {
|
ui(new Ui::Acceleration) {
|
||||||
@ -21,10 +25,10 @@ Acceleration::Acceleration(int slot_no_, int channel_, bool active, QWidget *par
|
|||||||
} else {
|
} else {
|
||||||
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\\acceleration_variables_%2.json").arg(slot_no).arg(channel);
|
||||||
readJsonFile(filePath_variables);
|
// readJsonFile(filePath_variables);
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,75 +166,8 @@ void Acceleration::on_checkBox_2x_ampl_toggled(bool checked) {
|
|||||||
ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(false);
|
ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Acceleration::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();
|
|
||||||
if (filePath.contains("filter_")) {
|
|
||||||
QJsonArray filter_array = json_obj["filter"].toArray();
|
|
||||||
for (int i = 0; i < filter_array.size(); i++) {
|
|
||||||
QJsonObject temp_obj = filter_array[i].toObject();
|
|
||||||
filter[i].type = temp_obj["type"].toString();
|
|
||||||
filter[i].low = temp_obj["low"].toInt();
|
|
||||||
filter[i].high = temp_obj["high"].toInt();
|
|
||||||
filter[i].checked = temp_obj["checked"].toBool();
|
|
||||||
}
|
|
||||||
} else if (filePath.contains("acceleration_variables_")) {
|
|
||||||
QJsonArray variables_array = json_obj["variables"].toArray();
|
|
||||||
for (int i = 0; i < variables_array.size(); i++) {
|
|
||||||
QJsonObject temp_obj = variables_array[i].toObject();
|
|
||||||
variables[i].type = temp_obj["type"].toString();
|
|
||||||
if (variables[i].type == "direct") {
|
|
||||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt();
|
|
||||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
|
||||||
} else if (variables[i].type == "bias_volt") {
|
|
||||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
|
||||||
variables[i].bias_voltage = temp_obj["bias_voltage"].toInt();
|
|
||||||
} else if (variables[i].type == "1x_ampl") {
|
|
||||||
variables[i].checked = temp_obj["checked"].toBool();
|
|
||||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt();
|
|
||||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
|
||||||
variables[i].phase_lag = temp_obj["phase_lag"].toDouble();
|
|
||||||
} else if (variables[i].type == "2x_ampl") {
|
|
||||||
variables[i].checked = temp_obj["checked"].toBool();
|
|
||||||
variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt();
|
|
||||||
variables[i].clamp_value = temp_obj["clamp_value"].toDouble();
|
|
||||||
variables[i].phase_lag = temp_obj["phase_lag"].toDouble();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QJsonObject delay_obj = json_obj["delay"].toObject();
|
|
||||||
delay.alert = delay_obj["alert"].toInt();
|
|
||||||
delay.danger = delay_obj["danger"].toDouble();
|
|
||||||
delay.active_100ms = delay_obj["100ms"].toBool();
|
|
||||||
alert_variables.rms_active = json_obj["rms_active"].toBool();
|
|
||||||
alert_variables.integrate_active = json_obj["integrate_active"].toBool();
|
|
||||||
alert_variables.alert_latching = json_obj["alert_latching"].toBool();
|
|
||||||
alert_variables.danger_latching = json_obj["danger_latching"].toBool();
|
|
||||||
alert_variables.timed_ok = json_obj["timed_ok"].toBool();
|
|
||||||
alert_variables.recorder_output = json_obj["recorder_output"].toInt();
|
|
||||||
alert_variables.two_ma_clamp = json_obj["two_ma_clamp"].toBool();
|
|
||||||
alert_variables.trip_multiply = json_obj["trip_multiply"].toDouble();
|
|
||||||
alert_variables.comparision = json_obj["comparision"].toString();
|
|
||||||
alert_variables.comparision_percentage = json_obj["comparision_percentage"].toInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void Acceleration::Init() {
|
void Acceleration::Init() {
|
||||||
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (filter[i].checked) {
|
if (filter[i].checked) {
|
||||||
if (filter[i].type == "band_pass") {
|
if (filter[i].type == "band_pass") {
|
||||||
@ -378,24 +315,24 @@ void Acceleration::on_pushButton_confirm_clicked() {
|
|||||||
variables_obj.insert("slot", slot_no);
|
variables_obj.insert("slot", slot_no);
|
||||||
variables_obj.insert("id", channel);
|
variables_obj.insert("id", channel);
|
||||||
variables_obj.insert("version", 1);
|
variables_obj.insert("version", 1);
|
||||||
QJsonDocument jsonDoc_filter(filter_obj);
|
// QJsonDocument jsonDoc_filter(filter_obj);
|
||||||
QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
// QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel);
|
||||||
QFile file(filePath);
|
// QFile file(filePath);
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
// if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
qDebug() << "Cannot open file for writing:" << filePath;
|
// qDebug() << "Cannot open file for writing:" << filePath;
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
file.write(jsonDoc_filter.toJson());
|
// file.write(jsonDoc_filter.toJson());
|
||||||
file.close();
|
// file.close();
|
||||||
QJsonDocument jsonDoc_variables(variables_obj);
|
// QJsonDocument jsonDoc_variables(variables_obj);
|
||||||
filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel);
|
// filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel);
|
||||||
file.setFileName(filePath);
|
// file.setFileName(filePath);
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
// if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
qDebug() << "Cannot open file for writing:" << filePath;
|
// qDebug() << "Cannot open file for writing:" << filePath;
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
file.write(jsonDoc_variables.toJson());
|
// file.write(jsonDoc_variables.toJson());
|
||||||
file.close();
|
// file.close();
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,12 +31,12 @@ class Acceleration : public QWidget {
|
|||||||
private:
|
private:
|
||||||
Ui::Acceleration *ui;
|
Ui::Acceleration *ui;
|
||||||
|
|
||||||
Filter filter[3];
|
// Filter filter[3];
|
||||||
Dealy delay;
|
// Dealy delay;
|
||||||
Variables variables[4];
|
// Variables variables[4];
|
||||||
Alert_Variables alert_variables;
|
// Alert_Variables alert_variables;
|
||||||
|
|
||||||
void readJsonFile(const QString &filePath);
|
// void readJsonFile(const QString &filePath);
|
||||||
void Init();
|
void Init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
38
cardbase.h
38
cardbase.h
@ -2,30 +2,30 @@
|
|||||||
#define CARDBASE_H
|
#define CARDBASE_H
|
||||||
|
|
||||||
#include "data_config.h"
|
#include "data_config.h"
|
||||||
#ifdef NAME
|
//#ifdef NAME
|
||||||
#undef NAME
|
// #undef NAME
|
||||||
#endif
|
//#endif
|
||||||
#define NAME(x) (x, #x)
|
//#define NAME(x) (x, #x)
|
||||||
|
|
||||||
class CardBase {
|
class CardBase {
|
||||||
public:
|
public:
|
||||||
CardBase() {}
|
CardBase() {}
|
||||||
~CardBase() {}
|
~CardBase() {}
|
||||||
void FromJson(const Json::Value &cfg) {
|
// void FromJson(const Json::Value &cfg) {
|
||||||
version_ = cfg["version"].asInt();
|
// version_ = cfg["version"].asInt();
|
||||||
slot_ = cfg["slot"].asInt();
|
// slot_ = cfg["slot"].asInt();
|
||||||
card_type_ = static_cast<CardType>(cfg["type"].asInt());
|
// card_type_ = static_cast<CardType>(cfg["type"].asInt());
|
||||||
}
|
// }
|
||||||
|
|
||||||
Json::Value ToJson() {
|
// Json::Value ToJson() {
|
||||||
Json::Value ch;
|
// Json::Value ch;
|
||||||
ch[NAME(version)] = version_;
|
// ch[NAME(version)] = version_;
|
||||||
ch[NAME(slot)] = slot_;
|
// ch[NAME(slot)] = slot_;
|
||||||
ch[NAME(type)] = card_type_;
|
// ch[NAME(type)] = card_type_;
|
||||||
return ch;
|
// return ch;
|
||||||
}
|
// }
|
||||||
|
|
||||||
protected:
|
// protected:
|
||||||
int version_;
|
int version_;
|
||||||
int slot_; // 从1~15
|
int slot_; // 从1~15
|
||||||
CardType card_type_;
|
CardType card_type_;
|
||||||
@ -35,14 +35,14 @@ class VariableBase {
|
|||||||
public:
|
public:
|
||||||
VariableBase() {}
|
VariableBase() {}
|
||||||
~VariableBase() {}
|
~VariableBase() {}
|
||||||
// TODO: fromjson, tojson
|
|
||||||
int id_;
|
int id_;
|
||||||
VibChannelType type_;
|
VibChannelType type_;
|
||||||
Delay delay_;
|
|
||||||
DirectImpl direct_;
|
DirectImpl direct_;
|
||||||
XImpl x1_;
|
XImpl x1_;
|
||||||
XImpl x2_;
|
XImpl x2_;
|
||||||
RecorderOut recorder_out_;
|
RecorderOut recorder_out_;
|
||||||
|
Delay delay_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 位移
|
// 位移
|
||||||
|
281
config_mgr.cpp
281
config_mgr.cpp
@ -13,11 +13,190 @@ ConfigMgr::~ConfigMgr() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConfigMgr::Save() {
|
void ConfigMgr::Save() {
|
||||||
|
QJsonObject doc_obj;
|
||||||
|
doc_obj["version"] = 1;
|
||||||
|
int slot = 0;
|
||||||
|
QJsonArray card_type;
|
||||||
|
for (int i = 0; i < SLOT_NUM; ++i) {
|
||||||
|
if (card_type_[i] == kCardNone) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QJsonObject card_item;
|
||||||
|
slot = i + 1;
|
||||||
|
card_item["type"] = card_type_[i];
|
||||||
|
card_item["slot"] = slot;
|
||||||
|
card_type.append(card_item);
|
||||||
|
if (card_type_[i] != kCardVibSingle &&
|
||||||
|
card_type_[i] != kCardVibTMRPrimary &&
|
||||||
|
card_type_[i] != kCardSpeedSingle &&
|
||||||
|
card_type_[i] != kCardSpeedTMRPrimary &&
|
||||||
|
card_type_[i] != kCardKeyphase &&
|
||||||
|
card_type_[i] != kCardRelaySingle &&
|
||||||
|
card_type_[i] != kCardRelayTMRPrimary) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// process slot
|
||||||
|
QJsonObject slot_item;
|
||||||
|
if (card_type_[i] != kCardRelaySingle &&
|
||||||
|
card_type_[i] != kCardRelayTMRPrimary) {
|
||||||
|
for (int cid = 0; cid < CHANNEL_COUNT; ++cid) {
|
||||||
|
QJsonObject channel_item;
|
||||||
|
if (card_type_[i] == kCardVibSingle ||
|
||||||
|
card_type_[i] == kCardVibTMRPrimary) {
|
||||||
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
||||||
|
if (base_ptr == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||||
|
channel_item["standby"] = ptr->base_config_[cid].standby;
|
||||||
|
channel_item["active"] = ptr->base_config_[cid].active;
|
||||||
|
channel_item["rack_type"] = 0; // TODO:
|
||||||
|
channel_item["channel_type"] = ptr->base_config_[cid].channel_type;
|
||||||
|
channel_item["transducer_id"] = ptr->base_config_[cid].transducer_id;
|
||||||
|
channel_item["scale_factor"] = ptr->base_config_[cid].scale_factor;
|
||||||
|
channel_item["sampling_rate"] = ptr->base_config_[cid].sampling_rate;
|
||||||
|
QJsonArray voltage_range;
|
||||||
|
voltage_range.append(ptr->base_config_[cid].normal_voltage_low);
|
||||||
|
voltage_range.append(ptr->base_config_[cid].normal_voltage_high);
|
||||||
|
channel_item["normal_voltage_range"] = voltage_range;
|
||||||
|
// filter
|
||||||
|
QJsonArray filter;
|
||||||
|
QJsonObject low_pass;
|
||||||
|
low_pass["low"] = ptr->filter_[cid].filter[0].low;
|
||||||
|
low_pass["high"] = ptr->filter_[cid].filter[0].high;
|
||||||
|
low_pass["checked"] = ptr->filter_[cid].filter[0].checked;
|
||||||
|
filter.append(low_pass);
|
||||||
|
QJsonObject high_pass;
|
||||||
|
high_pass["low"] = ptr->filter_[cid].filter[1].low;
|
||||||
|
high_pass["high"] = ptr->filter_[cid].filter[1].high;
|
||||||
|
high_pass["checked"] = ptr->filter_[cid].filter[1].checked;
|
||||||
|
filter.append(high_pass);
|
||||||
|
QJsonObject band_pass;
|
||||||
|
band_pass["low"] = ptr->filter_[cid].filter[2].low;
|
||||||
|
band_pass["high"] = ptr->filter_[cid].filter[2].high;
|
||||||
|
band_pass["checked"] = ptr->filter_[cid].filter[2].checked;
|
||||||
|
filter.append(band_pass);
|
||||||
|
channel_item["filter"] = filter;
|
||||||
|
// variables
|
||||||
|
QJsonObject variables;
|
||||||
|
std::shared_ptr<VariableBase> base_channel_ptr = ptr->GetChannelPtr(cid + 1);
|
||||||
|
if (base_channel_ptr->type_ == kVibRadial) {
|
||||||
|
std::shared_ptr<RadialVariable> radial_ptr = std::dynamic_pointer_cast<RadialVariable>(base_channel_ptr);
|
||||||
|
QJsonObject direct;
|
||||||
|
QJsonObject x1;
|
||||||
|
QJsonObject x2;
|
||||||
|
QJsonObject recorder_out;
|
||||||
|
QJsonObject delay;
|
||||||
|
QJsonObject not1x;
|
||||||
|
QJsonObject smax;
|
||||||
|
QJsonArray latching;
|
||||||
|
direct["full_scale_range"] = radial_ptr->direct_.full_scale_range;
|
||||||
|
direct["clamp_value"] = radial_ptr->direct_.clamp_value;
|
||||||
|
direct["custom"] = radial_ptr->direct_.custom;
|
||||||
|
variables["direct"] = direct;
|
||||||
|
x1["checked"] = radial_ptr->x1_.checked;
|
||||||
|
x1["full_scale_range"] = radial_ptr->x1_.full_scale_range;
|
||||||
|
x1["clamp_value"] = radial_ptr->x1_.clamp_value;
|
||||||
|
x1["custom"] = radial_ptr->x1_.custom;
|
||||||
|
x1["phase_lag"] = radial_ptr->x1_.phase_lag;
|
||||||
|
variables["x1"] = x1;
|
||||||
|
x2["checked"] = radial_ptr->x2_.checked;
|
||||||
|
x2["full_scale_range"] = radial_ptr->x2_.full_scale_range;
|
||||||
|
x2["clamp_value"] = radial_ptr->x2_.clamp_value;
|
||||||
|
x2["custom"] = radial_ptr->x2_.custom;
|
||||||
|
x2["phase_lag"] = radial_ptr->x2_.phase_lag;
|
||||||
|
variables["x2"] = x2;
|
||||||
|
recorder_out["recorder_output"] = radial_ptr->recorder_out_.recorder_output;
|
||||||
|
recorder_out["two_ma_clamp"] = radial_ptr->recorder_out_.two_ma_clamp;
|
||||||
|
recorder_out["trip_multiply"] = radial_ptr->recorder_out_.trip_multiply;
|
||||||
|
recorder_out["comparision"] = radial_ptr->recorder_out_.comparision;
|
||||||
|
recorder_out["percentage"] = radial_ptr->recorder_out_.percentage;
|
||||||
|
variables["recorder_out"] = recorder_out;
|
||||||
|
delay["alert"] = radial_ptr->delay_.alert;
|
||||||
|
delay["danger"] = radial_ptr->delay_.danger;
|
||||||
|
delay["active_100ms"] = radial_ptr->delay_.active_100ms;
|
||||||
|
variables["delay"] = delay;
|
||||||
|
not1x["checked"] = radial_ptr->not1x_.checked;
|
||||||
|
not1x["full_scale_range"] = radial_ptr->not1x_.full_scale_range;
|
||||||
|
not1x["clamp_value"] = radial_ptr->not1x_.clamp_value;
|
||||||
|
not1x["custom"] = radial_ptr->not1x_.custom;
|
||||||
|
variables["not1x"] = not1x;
|
||||||
|
smax["checked"] = radial_ptr->smax_.checked;
|
||||||
|
smax["full_scale_range"] = radial_ptr->smax_.full_scale_range;
|
||||||
|
smax["clamp_value"] = radial_ptr->smax_.clamp_value;
|
||||||
|
smax["custom"] = radial_ptr->smax_.custom;
|
||||||
|
variables["smax"] = smax;
|
||||||
|
latching.append(radial_ptr->alert_latching_);
|
||||||
|
latching.append(radial_ptr->danger_latching_);
|
||||||
|
variables["latching"] = latching;
|
||||||
|
} else {
|
||||||
|
std::shared_ptr<AccVelVariable> av_ptr = std::dynamic_pointer_cast<AccVelVariable>(base_channel_ptr);
|
||||||
|
QJsonObject direct;
|
||||||
|
QJsonObject x1;
|
||||||
|
QJsonObject x2;
|
||||||
|
QJsonObject recorder_out;
|
||||||
|
QJsonObject delay;
|
||||||
|
QJsonArray latching;
|
||||||
|
direct["full_scale_range"] = av_ptr->direct_.full_scale_range;
|
||||||
|
direct["clamp_value"] = av_ptr->direct_.clamp_value;
|
||||||
|
direct["custom"] = av_ptr->direct_.custom;
|
||||||
|
variables["direct"] = direct;
|
||||||
|
x1["checked"] = av_ptr->x1_.checked;
|
||||||
|
x1["full_scale_range"] = av_ptr->x1_.full_scale_range;
|
||||||
|
x1["clamp_value"] = av_ptr->x1_.clamp_value;
|
||||||
|
x1["custom"] = av_ptr->x1_.custom;
|
||||||
|
x1["phase_lag"] = av_ptr->x1_.phase_lag;
|
||||||
|
variables["x1"] = x1;
|
||||||
|
x2["checked"] = av_ptr->x2_.checked;
|
||||||
|
x2["full_scale_range"] = av_ptr->x2_.full_scale_range;
|
||||||
|
x2["clamp_value"] = av_ptr->x2_.clamp_value;
|
||||||
|
x2["custom"] = av_ptr->x2_.custom;
|
||||||
|
x2["phase_lag"] = av_ptr->x2_.phase_lag;
|
||||||
|
variables["x2"] = x2;
|
||||||
|
QJsonObject rms_integrate;
|
||||||
|
rms_integrate["rms_active"] = av_ptr->rms_active_;
|
||||||
|
rms_integrate["integrate_active"] = av_ptr->integrate_active_;
|
||||||
|
variables["rms_integrate"] = rms_integrate;
|
||||||
|
recorder_out["recorder_output"] = av_ptr->recorder_out_.recorder_output;
|
||||||
|
recorder_out["two_ma_clamp"] = av_ptr->recorder_out_.two_ma_clamp;
|
||||||
|
recorder_out["trip_multiply"] = av_ptr->recorder_out_.trip_multiply;
|
||||||
|
recorder_out["comparision"] = av_ptr->recorder_out_.comparision;
|
||||||
|
recorder_out["percentage"] = av_ptr->recorder_out_.percentage;
|
||||||
|
variables["recorder_out"] = recorder_out;
|
||||||
|
delay["alert"] = av_ptr->delay_.alert;
|
||||||
|
delay["danger"] = av_ptr->delay_.danger;
|
||||||
|
delay["active_100ms"] = av_ptr->delay_.active_100ms;
|
||||||
|
variables["delay"] = delay;
|
||||||
|
latching.append(av_ptr->alert_latching_);
|
||||||
|
latching.append(av_ptr->danger_latching_);
|
||||||
|
latching.append(av_ptr->timed_ok_);
|
||||||
|
variables["latching"] = latching;
|
||||||
|
}
|
||||||
|
channel_item["variable"] = variables;
|
||||||
|
} else {
|
||||||
|
// TODO: save speed, keyphase
|
||||||
|
}
|
||||||
|
slot_item[QString::number(cid + 1)] = channel_item;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// TODO: save relay data
|
||||||
|
}
|
||||||
|
doc_obj[QString::number(slot)] = slot_item;
|
||||||
|
}
|
||||||
|
doc_obj["card_type"] = card_type;
|
||||||
|
// TODO: show success message box
|
||||||
|
QJsonDocument jsonDoc;
|
||||||
|
jsonDoc.setObject(doc_obj);
|
||||||
|
QFile file(filename_);
|
||||||
|
file.open(QIODevice::WriteOnly);
|
||||||
|
file.write(jsonDoc.toJson());
|
||||||
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigMgr::Load(QString filename) {
|
void ConfigMgr::Load(QString filename) {
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
// TODO: show message box
|
||||||
qDebug() << "Cannot open file for reading:" << filename;
|
qDebug() << "Cannot open file for reading:" << filename;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -26,13 +205,16 @@ void ConfigMgr::Load(QString filename) {
|
|||||||
QByteArray jsonData = content.toUtf8();
|
QByteArray jsonData = content.toUtf8();
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||||
if (jsonDoc.isNull()) {
|
if (jsonDoc.isNull()) {
|
||||||
|
// TODO: show message box
|
||||||
qDebug() << "Cannot parse JSON document";
|
qDebug() << "Cannot parse JSON document";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||||
|
// TODO: show message box
|
||||||
qDebug() << "JSON document is not an object or an array";
|
qDebug() << "JSON document is not an object or an array";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
filename_ = filename;
|
||||||
QJsonObject json_obj = jsonDoc.object();
|
QJsonObject json_obj = jsonDoc.object();
|
||||||
// parse card_type
|
// parse card_type
|
||||||
QJsonArray card_type = json_obj["card_type"].toArray();
|
QJsonArray card_type = json_obj["card_type"].toArray();
|
||||||
@ -64,8 +246,7 @@ void ConfigMgr::Load(QString filename) {
|
|||||||
vib_data->base_config_[j].rack_type = channel["rack_type"].toInt();
|
vib_data->base_config_[j].rack_type = channel["rack_type"].toInt();
|
||||||
// vib_data->base_config_[j].tmr_group = channel["tmr_group"].toString();
|
// vib_data->base_config_[j].tmr_group = channel["tmr_group"].toString();
|
||||||
vib_data->base_config_[j].channel_type = channel["channel_type"].toInt();
|
vib_data->base_config_[j].channel_type = channel["channel_type"].toInt();
|
||||||
memset(vib_data->base_config_[j].transducer_name, 0, 32);
|
vib_data->base_config_[j].transducer_id = channel["transducer_id"].toInt();
|
||||||
memcpy(vib_data->base_config_[j].transducer_name, channel["transducer_name"].toString().toStdString().c_str(), channel["transducer_name"].toString().length());
|
|
||||||
vib_data->base_config_[j].scale_factor = channel["scale_factor"].toDouble();
|
vib_data->base_config_[j].scale_factor = channel["scale_factor"].toDouble();
|
||||||
vib_data->base_config_[j].sampling_rate = channel["sampling_rate"].toInt();
|
vib_data->base_config_[j].sampling_rate = channel["sampling_rate"].toInt();
|
||||||
QJsonArray voltage_range_array = channel["normal_voltage_range"].toArray();
|
QJsonArray voltage_range_array = channel["normal_voltage_range"].toArray();
|
||||||
@ -83,15 +264,88 @@ void ConfigMgr::Load(QString filename) {
|
|||||||
QJsonObject tmp_variable = channel["variable"].toObject();
|
QJsonObject tmp_variable = channel["variable"].toObject();
|
||||||
switch (vib_data->base_config_[j].channel_type) {
|
switch (vib_data->base_config_[j].channel_type) {
|
||||||
case kVibRadial: {
|
case kVibRadial: {
|
||||||
std::shared_ptr<RadialVariable> radial_variable = std::make_shared<RadialVariable>();
|
std::shared_ptr<RadialVariable> variable = std::make_shared<RadialVariable>();
|
||||||
radial_variable->id_ = j + 1;
|
variable->id_ = j + 1;
|
||||||
vib_data->variables_.push_back(radial_variable);
|
QJsonObject direct = tmp_variable["direct"].toObject();
|
||||||
|
variable->direct_.full_scale_range = direct["full_scale_range"].toInt();
|
||||||
|
variable->direct_.clamp_value = direct["clamp_value"].toDouble();
|
||||||
|
variable->direct_.custom = direct["custom"].toDouble();
|
||||||
|
QJsonObject x1 = tmp_variable["x1"].toObject();
|
||||||
|
variable->x1_.checked = x1["checked"].toBool();
|
||||||
|
variable->x1_.full_scale_range = x1["full_scale_range"].toInt();
|
||||||
|
variable->x1_.clamp_value = x1["clamp_value"].toDouble();
|
||||||
|
variable->x1_.custom = x1["custom"].toDouble();
|
||||||
|
variable->x1_.phase_lag = x1["phase_lag"].toInt();
|
||||||
|
QJsonObject x2 = tmp_variable["x2"].toObject();
|
||||||
|
variable->x2_.checked = x2["checked"].toBool();
|
||||||
|
variable->x2_.full_scale_range = x2["full_scale_range"].toInt();
|
||||||
|
variable->x2_.clamp_value = x2["clamp_value"].toDouble();
|
||||||
|
variable->x2_.custom = x2["custom"].toDouble();
|
||||||
|
variable->x2_.phase_lag = x2["phase_lag"].toInt();
|
||||||
|
QJsonObject recorder_out = tmp_variable["recorder_out"].toObject();
|
||||||
|
variable->recorder_out_.recorder_output = recorder_out["recorder_output"].toInt();
|
||||||
|
variable->recorder_out_.two_ma_clamp = recorder_out["two_ma_clamp"].toBool();
|
||||||
|
variable->recorder_out_.trip_multiply = recorder_out["trip_multiply"].toDouble();
|
||||||
|
variable->recorder_out_.comparision = recorder_out["comparision"].toInt();
|
||||||
|
variable->recorder_out_.percentage = recorder_out["percentage"].toInt();
|
||||||
|
QJsonObject delay = tmp_variable["delay"].toObject();
|
||||||
|
variable->delay_.alert = delay["alert"].toInt();
|
||||||
|
variable->delay_.danger = delay["danger"].toDouble();
|
||||||
|
variable->delay_.active_100ms = delay["active_100ms"].toBool();
|
||||||
|
QJsonObject not1x = tmp_variable["not1x"].toObject();
|
||||||
|
variable->not1x_.checked = not1x["checked"].toBool();
|
||||||
|
variable->not1x_.full_scale_range = not1x["full_scale_range"].toInt();
|
||||||
|
variable->not1x_.clamp_value = not1x["clamp_value"].toDouble();
|
||||||
|
variable->not1x_.custom = not1x["custom"].toDouble();
|
||||||
|
QJsonObject smax = tmp_variable["smax"].toObject();
|
||||||
|
variable->smax_.checked = smax["checked"].toBool();
|
||||||
|
variable->smax_.full_scale_range = smax["full_scale_range"].toInt();
|
||||||
|
variable->smax_.clamp_value = smax["clamp_value"].toDouble();
|
||||||
|
variable->smax_.custom = smax["custom"].toDouble();
|
||||||
|
QJsonObject latching = tmp_variable["latching"].toObject();
|
||||||
|
variable->alert_latching_ = latching["alert"].toBool();
|
||||||
|
variable->danger_latching_ = latching["danger"].toBool();
|
||||||
|
vib_data->variables_.push_back(variable);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kVibVelocity:
|
case kVibVelocity:
|
||||||
case kVibAcc: {
|
case kVibAcc: {
|
||||||
std::shared_ptr<AccVelVariable> acc_vel_variable = std::make_shared<AccVelVariable>();
|
std::shared_ptr<AccVelVariable> variable = std::make_shared<AccVelVariable>();
|
||||||
vib_data->variables_.push_back(acc_vel_variable);
|
variable->id_ = j + 1;
|
||||||
|
QJsonObject direct = tmp_variable["direct"].toObject();
|
||||||
|
variable->direct_.full_scale_range = direct["full_scale_range"].toInt();
|
||||||
|
variable->direct_.clamp_value = direct["clamp_value"].toDouble();
|
||||||
|
variable->direct_.custom = direct["custom"].toDouble();
|
||||||
|
QJsonObject x1 = tmp_variable["x1"].toObject();
|
||||||
|
variable->x1_.checked = x1["checked"].toBool();
|
||||||
|
variable->x1_.full_scale_range = x1["full_scale_range"].toInt();
|
||||||
|
variable->x1_.clamp_value = x1["clamp_value"].toDouble();
|
||||||
|
variable->x1_.custom = x1["custom"].toDouble();
|
||||||
|
variable->x1_.phase_lag = x1["phase_lag"].toInt();
|
||||||
|
QJsonObject x2 = tmp_variable["x2"].toObject();
|
||||||
|
variable->x2_.checked = x2["checked"].toBool();
|
||||||
|
variable->x2_.full_scale_range = x2["full_scale_range"].toInt();
|
||||||
|
variable->x2_.clamp_value = x2["clamp_value"].toDouble();
|
||||||
|
variable->x2_.custom = x2["custom"].toDouble();
|
||||||
|
variable->x2_.phase_lag = x2["phase_lag"].toInt();
|
||||||
|
QJsonObject rms_integrate = tmp_variable["rms_integrate"].toObject();
|
||||||
|
variable->rms_active_ = rms_integrate["rms_active"].toBool();
|
||||||
|
variable->integrate_active_ = rms_integrate["integrate_active"].toBool();
|
||||||
|
QJsonObject recorder_out = tmp_variable["recorder_out"].toObject();
|
||||||
|
variable->recorder_out_.recorder_output = recorder_out["recorder_output"].toInt();
|
||||||
|
variable->recorder_out_.two_ma_clamp = recorder_out["two_ma_clamp"].toBool();
|
||||||
|
variable->recorder_out_.trip_multiply = recorder_out["trip_multiply"].toDouble();
|
||||||
|
variable->recorder_out_.comparision = recorder_out["comparision"].toInt();
|
||||||
|
variable->recorder_out_.percentage = recorder_out["percentage"].toInt();
|
||||||
|
QJsonObject delay = tmp_variable["delay"].toObject();
|
||||||
|
variable->delay_.alert = delay["alert"].toInt();
|
||||||
|
variable->delay_.danger = delay["danger"].toDouble();
|
||||||
|
variable->delay_.active_100ms = delay["active_100ms"].toBool();
|
||||||
|
QJsonObject latching = tmp_variable["latching"].toObject();
|
||||||
|
variable->alert_latching_ = latching["alert"].toBool();
|
||||||
|
variable->danger_latching_ = latching["danger"].toBool();
|
||||||
|
variable->timed_ok_ = latching["timed_ok"].toBool();
|
||||||
|
vib_data->variables_.push_back(variable);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,3 +354,16 @@ void ConfigMgr::Load(QString filename) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<CardBase> ConfigMgr::GetSlotPtr(int slot) {
|
||||||
|
for (auto &item : cards_) {
|
||||||
|
if (item->slot_ == slot) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigMgr::AddCard(std::shared_ptr<CardBase> ptr) {
|
||||||
|
cards_.push_back(ptr);
|
||||||
|
}
|
||||||
|
@ -22,7 +22,10 @@ class ConfigMgr {
|
|||||||
~ConfigMgr();
|
~ConfigMgr();
|
||||||
void Save();
|
void Save();
|
||||||
void Load(QString filename);
|
void Load(QString filename);
|
||||||
|
std::shared_ptr<CardBase> GetSlotPtr(int slot);
|
||||||
|
void AddCard(std::shared_ptr<CardBase> ptr);
|
||||||
private:
|
private:
|
||||||
|
QString filename_;
|
||||||
int card_type_[15];
|
int card_type_[15];
|
||||||
std::vector<std::shared_ptr<CardBase>> cards_;
|
std::vector<std::shared_ptr<CardBase>> cards_;
|
||||||
};
|
};
|
||||||
|
@ -77,9 +77,9 @@ typedef struct {
|
|||||||
bool standby;
|
bool standby;
|
||||||
bool active;
|
bool active;
|
||||||
int rack_type; // VibRackType
|
int rack_type; // VibRackType
|
||||||
char tmr_group[32];
|
// char tmr_group[32];
|
||||||
int channel_type; // VibChannelType
|
int channel_type; // VibChannelType
|
||||||
char transducer_name[32];
|
int transducer_id;
|
||||||
float scale_factor;
|
float scale_factor;
|
||||||
int sampling_rate; // VibSamplingRate
|
int sampling_rate; // VibSamplingRate
|
||||||
float normal_voltage_low;
|
float normal_voltage_low;
|
||||||
@ -113,14 +113,14 @@ typedef struct {
|
|||||||
} Variables;
|
} Variables;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int full_sacle_range;
|
int full_scale_range;
|
||||||
float clamp_value;
|
float clamp_value;
|
||||||
float custom;
|
float custom;
|
||||||
} DirectImpl;
|
} DirectImpl;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool checked;
|
bool checked;
|
||||||
int full_sacle_range;
|
int full_scale_range;
|
||||||
float clamp_value;
|
float clamp_value;
|
||||||
float custom;
|
float custom;
|
||||||
int phase_lag;
|
int phase_lag;
|
||||||
@ -128,7 +128,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool checked;
|
bool checked;
|
||||||
int full_sacle_range;
|
int full_scale_range;
|
||||||
float clamp_value;
|
float clamp_value;
|
||||||
float custom;
|
float custom;
|
||||||
} RadialImpl;
|
} RadialImpl;
|
||||||
@ -156,8 +156,8 @@ typedef struct {
|
|||||||
int recorder_output;
|
int recorder_output;
|
||||||
bool two_ma_clamp;
|
bool two_ma_clamp;
|
||||||
float trip_multiply;
|
float trip_multiply;
|
||||||
QString comparision;
|
int comparision;
|
||||||
int comparision_percentage;
|
int percentage;
|
||||||
} RecorderOut;
|
} RecorderOut;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -28,11 +28,11 @@ class Radial_vibration : public QWidget {
|
|||||||
private:
|
private:
|
||||||
Ui::Radial_vibration *ui;
|
Ui::Radial_vibration *ui;
|
||||||
|
|
||||||
Filter filter[3];
|
// Filter filter[3];
|
||||||
Dealy delay;
|
// Dealy delay;
|
||||||
Variables variables[6];
|
// Variables variables[6];
|
||||||
Alert_Variables alert_variables;
|
// Alert_Variables alert_variables;
|
||||||
void readJsonFile(const QString &filePath);
|
// void readJsonFile(const QString &filePath);
|
||||||
void Init();
|
void Init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
#include "acceleration.h"
|
#include "acceleration.h"
|
||||||
#include "velocity.h"
|
#include "velocity.h"
|
||||||
#include "radial_vibration.h"
|
#include "radial_vibration.h"
|
||||||
|
#include "data_config.h"
|
||||||
|
#include "config_mgr.h"
|
||||||
|
#include "vibrationdata.h"
|
||||||
|
|
||||||
Seismic_monitor::Seismic_monitor(int slot, QWidget *parent) :
|
Seismic_monitor::Seismic_monitor(int slot, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
@ -30,239 +33,191 @@ Seismic_monitor::Seismic_monitor(int slot, QWidget *parent) :
|
|||||||
slot_no = slot;
|
slot_no = slot;
|
||||||
QString slot_no_ = QString("%1").arg(slot_no);
|
QString slot_no_ = QString("%1").arg(slot_no);
|
||||||
ui->label_slot_no->setText(slot_no_);
|
ui->label_slot_no->setText(slot_no_);
|
||||||
QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\seismic_monitor_slot.json").arg(slot_no);
|
// QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\seismic_monitor_slot.json").arg(slot_no);
|
||||||
readJsonFile(filePath);
|
// readJsonFile(filePath);
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Seismic_monitor::~Seismic_monitor() {
|
Seismic_monitor::~Seismic_monitor() {
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
void Seismic_monitor::readJsonFile(const QString &filePath) {
|
|
||||||
// 创建文件对象
|
//void Seismic_monitor::readJsonFile(const QString &filePath) {
|
||||||
QFile file(filePath);
|
// // 创建文件对象
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
// QFile file(filePath);
|
||||||
qDebug() << "Cannot open file for reading:" << filePath;
|
// if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
return;
|
// qDebug() << "Cannot open file for reading:" << filePath;
|
||||||
}
|
// return;
|
||||||
QString content = file.readAll();
|
// }
|
||||||
file.close();
|
// QString content = file.readAll();
|
||||||
QByteArray jsonData = content.toUtf8();
|
// file.close();
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
// QByteArray jsonData = content.toUtf8();
|
||||||
if (jsonDoc.isNull()) {
|
// QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
||||||
qDebug() << "Cannot parse JSON document";
|
// if (jsonDoc.isNull()) {
|
||||||
return;
|
// qDebug() << "Cannot parse JSON document";
|
||||||
}
|
// return;
|
||||||
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
// }
|
||||||
qDebug() << "JSON document is not an object or an array";
|
// if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
||||||
return;
|
// qDebug() << "JSON document is not an object or an array";
|
||||||
}
|
// return;
|
||||||
QJsonObject json_obj = jsonDoc.object();
|
// }
|
||||||
card_type = json_obj["card_type"].toInt();
|
// QJsonObject json_obj = jsonDoc.object();
|
||||||
QJsonArray chan_array = json_obj["chan"].toArray();
|
// card_type = json_obj["card_type"].toInt();
|
||||||
for (int i = 0; i < chan_array.size(); i++) {
|
// QJsonArray chan_array = json_obj["chan"].toArray();
|
||||||
QJsonObject temp_obj = chan_array[i].toObject();
|
// for (int i = 0; i < chan_array.size(); i++) {
|
||||||
seismic_monitor[i].id = temp_obj["id"].toInt();
|
// QJsonObject temp_obj = chan_array[i].toObject();
|
||||||
// seismic_monitor[i].channel_name = temp_obj["channle_name"].toString();
|
// seismic_monitor[i].id = temp_obj["id"].toInt();
|
||||||
seismic_monitor[i].standby = temp_obj["standby"].toBool();
|
//// seismic_monitor[i].channel_name = temp_obj["channle_name"].toString();
|
||||||
seismic_monitor[i].active = temp_obj["active"].toBool();
|
// seismic_monitor[i].standby = temp_obj["standby"].toBool();
|
||||||
seismic_monitor[i].rack_type = temp_obj["rack_type"].toInt();
|
// seismic_monitor[i].active = temp_obj["active"].toBool();
|
||||||
seismic_monitor[i].tmr_group = temp_obj["tmr_group"].toString();
|
// seismic_monitor[i].rack_type = temp_obj["rack_type"].toInt();
|
||||||
seismic_monitor[i].channel_type = temp_obj["channel_type"].toInt();
|
// seismic_monitor[i].tmr_group = temp_obj["tmr_group"].toString();
|
||||||
seismic_monitor[i].transducer_name = temp_obj["transducer_name"].toString();
|
// seismic_monitor[i].channel_type = temp_obj["channel_type"].toInt();
|
||||||
seismic_monitor[i].scale_factor = temp_obj["scale_factor"].toDouble();
|
// seismic_monitor[i].transducer_name = temp_obj["transducer_name"].toString();
|
||||||
seismic_monitor[i].sampling_rate = temp_obj["sampling_rate"].toInt();
|
// seismic_monitor[i].scale_factor = temp_obj["scale_factor"].toDouble();
|
||||||
QJsonArray voltage_range_array = temp_obj["normal_voltage_range"].toArray();
|
// seismic_monitor[i].sampling_rate = temp_obj["sampling_rate"].toInt();
|
||||||
seismic_monitor[i].normal_voltage_low = voltage_range_array[0].toDouble();
|
// QJsonArray voltage_range_array = temp_obj["normal_voltage_range"].toArray();
|
||||||
seismic_monitor[i].normal_voltage_high = voltage_range_array[1].toDouble();
|
// seismic_monitor[i].normal_voltage_low = voltage_range_array[0].toDouble();
|
||||||
}
|
// seismic_monitor[i].normal_voltage_high = voltage_range_array[1].toDouble();
|
||||||
QFile file_transducer(QCoreApplication::applicationDirPath() + QString("\\config\\transducer.json"));
|
// }
|
||||||
if (!file_transducer.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
// QFile file_transducer(QCoreApplication::applicationDirPath() + QString("\\config\\transducer.json"));
|
||||||
qDebug() << "Cannot open file for reading:" << filePath;
|
// if (!file_transducer.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
return;
|
// qDebug() << "Cannot open file for reading:" << filePath;
|
||||||
}
|
// return;
|
||||||
QString content_transducer = file_transducer.readAll();
|
// }
|
||||||
file_transducer.close();
|
// QString content_transducer = file_transducer.readAll();
|
||||||
QByteArray jsonData2 = content_transducer.toUtf8();
|
// file_transducer.close();
|
||||||
QJsonDocument jsonDoc2 = QJsonDocument::fromJson(jsonData2);
|
// QByteArray jsonData2 = content_transducer.toUtf8();
|
||||||
if (jsonDoc2.isNull()) {
|
// QJsonDocument jsonDoc2 = QJsonDocument::fromJson(jsonData2);
|
||||||
qDebug() << "Cannot parse JSON document";
|
// if (jsonDoc2.isNull()) {
|
||||||
return;
|
// qDebug() << "Cannot parse JSON document";
|
||||||
}
|
// return;
|
||||||
if (!jsonDoc2.isObject() && !jsonDoc2.isArray()) {
|
// }
|
||||||
qDebug() << "JSON document is not an object or an array";
|
// if (!jsonDoc2.isObject() && !jsonDoc2.isArray()) {
|
||||||
return;
|
// qDebug() << "JSON document is not an object or an array";
|
||||||
}
|
// return;
|
||||||
QJsonArray json_array = jsonDoc2.array();
|
// }
|
||||||
for (int var = 0; var < json_array.size(); ++var) {
|
// QJsonArray json_array = jsonDoc2.array();
|
||||||
Transducer transducer;
|
// for (int var = 0; var < json_array.size(); ++var) {
|
||||||
QJsonObject temp_obj = json_array[var].toObject();
|
// Transducer transducer;
|
||||||
transducer.transducer_name = temp_obj["transducer_name"].toString();
|
// QJsonObject temp_obj = json_array[var].toObject();
|
||||||
transducer.scale_factor = temp_obj["scale_factor"].toDouble();
|
// transducer.transducer_name = temp_obj["transducer_name"].toString();
|
||||||
vec_transducer.push_back(transducer);
|
// transducer.scale_factor = temp_obj["scale_factor"].toDouble();
|
||||||
}
|
// vec_transducer.push_back(transducer);
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
void Seismic_monitor::Init() {
|
void Seismic_monitor::Init() {
|
||||||
for (int var = 0; var < vec_transducer.size(); ++var) {
|
// for (int var = 0; var < vec_transducer.size(); ++var) {
|
||||||
ui->comboBox_transducer_name_1->addItem(vec_transducer[var].transducer_name);
|
// ui->comboBox_transducer_name_1->addItem(vec_transducer[var].transducer_name);
|
||||||
ui->comboBox_transducer_name_2->addItem(vec_transducer[var].transducer_name);
|
// ui->comboBox_transducer_name_2->addItem(vec_transducer[var].transducer_name);
|
||||||
ui->comboBox_transducer_name_3->addItem(vec_transducer[var].transducer_name);
|
// ui->comboBox_transducer_name_3->addItem(vec_transducer[var].transducer_name);
|
||||||
ui->comboBox_transducer_name_4->addItem(vec_transducer[var].transducer_name);
|
// ui->comboBox_transducer_name_4->addItem(vec_transducer[var].transducer_name);
|
||||||
|
// }
|
||||||
|
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<VibrationData> vib_data = std::make_shared<VibrationData>();
|
||||||
|
ConfigMgr::Instance()->AddCard(vib_data);
|
||||||
|
UpdateData(vib_data);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||||
if (seismic_monitor[i].id == 1) {
|
for (int i = 0; i < CHANNEL_COUNT; i++) {
|
||||||
qDebug() << seismic_monitor[i].channel_type ;
|
if (i + 1 == 1) {
|
||||||
// if (seismic_monitor[i].channel_type == "acceleration") {
|
qDebug() << vib_data->base_config_[i].channel_type ;
|
||||||
// ui->comboBox_chan_type_1->setCurrentText("加速度");
|
ui->comboBox_chan_type_1->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||||
// } else if (seismic_monitor[i].channel_type == "velocity") {
|
ui->comboBox_transducer_name_1->setCurrentIndex(vib_data->base_config_[i].transducer_id);
|
||||||
// ui->comboBox_chan_type_1->setCurrentText("速度");
|
ui->doubleSpinBox_scale_factor_1->setValue(vib_data->base_config_[i].scale_factor);
|
||||||
// } else if (seismic_monitor[i].channel_type == "proximeter") {
|
ui->checkBox_enable_1->setCheckable(vib_data->base_config_[i].active);
|
||||||
// ui->comboBox_chan_type_1->setCurrentText("位移");
|
ui->doubleSpinBox_low_1->setValue(vib_data->base_config_[i].normal_voltage_low);
|
||||||
// }
|
ui->doubleSpinBox_high_1->setValue(vib_data->base_config_[i].normal_voltage_high);
|
||||||
ui->comboBox_chan_type_1->setCurrentIndex(seismic_monitor[i].channel_type);
|
ui->comboBox_sample_rate_1->setCurrentIndex(vib_data->base_config_[i].sampling_rate);
|
||||||
//ui->comboBox_transducer_name_1->setText(seismic_monitor[i].transducer_name);
|
} else if (i + 1 == 2) {
|
||||||
ui->doubleSpinBox_scale_factor_1->setValue(seismic_monitor[i].scale_factor);
|
ui->comboBox_chan_type_2->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||||
ui->checkBox_enable_1->setCheckable(seismic_monitor[i].active);
|
ui->comboBox_transducer_name_2->setCurrentIndex(vib_data->base_config_[i].transducer_id);
|
||||||
ui->doubleSpinBox_low_1->setValue(seismic_monitor[i].normal_voltage_low);
|
ui->doubleSpinBox_scale_factor_2->setValue(vib_data->base_config_[i].scale_factor);
|
||||||
ui->doubleSpinBox_high_1->setValue(seismic_monitor[i].normal_voltage_high);
|
ui->checkBox_enable_2->setCheckable(vib_data->base_config_[i].active);
|
||||||
// if (seismic_monitor[i].sample_rate == "32000") {
|
ui->doubleSpinBox_low_2->setValue(vib_data->base_config_[i].normal_voltage_low);
|
||||||
// ui->comboBox_sample_rate_1->setCurrentText("32 k");
|
ui->doubleSpinBox_high_2->setValue(vib_data->base_config_[i].normal_voltage_high);
|
||||||
// }
|
ui->comboBox_sample_rate_2->setCurrentIndex(vib_data->base_config_[i].sampling_rate);
|
||||||
ui->comboBox_sample_rate_1->setCurrentIndex(seismic_monitor[i].sampling_rate);
|
} else if (i + 1 == 3) {
|
||||||
}
|
ui->comboBox_chan_type_3->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||||
if (seismic_monitor[i].id == 2) {
|
ui->comboBox_transducer_name_3->setCurrentIndex(vib_data->base_config_[i].transducer_id);
|
||||||
// if (seismic_monitor[i].channel_type == "acceleration") {
|
ui->doubleSpinBox_scale_factor_3->setValue(vib_data->base_config_[i].scale_factor);
|
||||||
// ui->comboBox_chan_type_2->setCurrentText("加速度");
|
ui->checkBox_enable_3->setCheckable(vib_data->base_config_[i].active);
|
||||||
// } else if (seismic_monitor[i].channel_type == "velocity") {
|
ui->doubleSpinBox_low_3->setValue(vib_data->base_config_[i].normal_voltage_low);
|
||||||
// ui->comboBox_chan_type_2->setCurrentText("速度");
|
ui->doubleSpinBox_high_3->setValue(vib_data->base_config_[i].normal_voltage_high);
|
||||||
// } else if (seismic_monitor[i].channel_type == "proximeter") {
|
ui->comboBox_sample_rate_3->setCurrentIndex(vib_data->base_config_[i].sampling_rate);
|
||||||
// ui->comboBox_chan_type_2->setCurrentText("位移");
|
} else if (i + 1 == 4) {
|
||||||
// }
|
ui->comboBox_chan_type_4->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||||
ui->comboBox_chan_type_2->setCurrentIndex(seismic_monitor[i].channel_type);
|
ui->comboBox_transducer_name_4->setCurrentIndex(vib_data->base_config_[i].transducer_id);
|
||||||
//ui->comboBox_transducer_name_2->setText(seismic_monitor[i].transducer_name);
|
ui->doubleSpinBox_scale_factor_4->setValue(vib_data->base_config_[i].scale_factor);
|
||||||
ui->doubleSpinBox_scale_factor_2->setValue(seismic_monitor[i].scale_factor);
|
ui->checkBox_enable_4->setCheckable(vib_data->base_config_[i].active);
|
||||||
ui->checkBox_enable_2->setCheckable(seismic_monitor[i].active);
|
ui->doubleSpinBox_low_4->setValue(vib_data->base_config_[i].normal_voltage_low);
|
||||||
ui->doubleSpinBox_low_2->setValue(seismic_monitor[i].normal_voltage_low);
|
ui->doubleSpinBox_high_4->setValue(vib_data->base_config_[i].normal_voltage_high);
|
||||||
ui->doubleSpinBox_high_2->setValue(seismic_monitor[i].normal_voltage_high);
|
ui->comboBox_sample_rate_4->setCurrentIndex(vib_data->base_config_[i].sampling_rate);
|
||||||
// if (seismic_monitor[i].sample_rate == "32000") {
|
|
||||||
// ui->comboBox_sample_rate_2->setCurrentText("32 k");
|
|
||||||
// }
|
|
||||||
ui->comboBox_sample_rate_2->setCurrentIndex(seismic_monitor[i].sampling_rate);
|
|
||||||
}
|
|
||||||
if (seismic_monitor[i].id == 3) {
|
|
||||||
// if (seismic_monitor[i].channel_type == "acceleration") {
|
|
||||||
// ui->comboBox_chan_type_3->setCurrentText("加速度");
|
|
||||||
// } 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->setCurrentIndex(seismic_monitor[i].channel_type);
|
|
||||||
//ui->lineEdit_transducer_name_3->setText(seismic_monitor[i].transducer_name);
|
|
||||||
ui->doubleSpinBox_scale_factor_3->setValue(seismic_monitor[i].scale_factor);
|
|
||||||
ui->checkBox_enable_3->setCheckable(seismic_monitor[i].active);
|
|
||||||
ui->doubleSpinBox_low_3->setValue(seismic_monitor[i].normal_voltage_low);
|
|
||||||
ui->doubleSpinBox_high_3->setValue(seismic_monitor[i].normal_voltage_high);
|
|
||||||
// if (seismic_monitor[i].sample_rate == "32000") {
|
|
||||||
// ui->comboBox_sample_rate_3->setCurrentText("32 k");
|
|
||||||
// }
|
|
||||||
ui->comboBox_sample_rate_3->setCurrentIndex(seismic_monitor[i].sampling_rate);
|
|
||||||
}
|
|
||||||
if (seismic_monitor[i].id == 4) {
|
|
||||||
// if (seismic_monitor[i].channel_type == "acceleration") {
|
|
||||||
// ui->comboBox_chan_type_4->setCurrentText("加速度");
|
|
||||||
// } 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->setCurrentIndex(seismic_monitor[i].channel_type);
|
|
||||||
//ui->lineEdit_transducer_name_4->setText(seismic_monitor[i].transducer_name);
|
|
||||||
ui->doubleSpinBox_scale_factor_4->setValue(seismic_monitor[i].scale_factor);
|
|
||||||
ui->checkBox_enable_4->setCheckable(seismic_monitor[i].active);
|
|
||||||
ui->doubleSpinBox_low_4->setValue(seismic_monitor[i].normal_voltage_low);
|
|
||||||
ui->doubleSpinBox_high_4->setValue(seismic_monitor[i].normal_voltage_high);
|
|
||||||
// if (seismic_monitor[i].sample_rate == "32000") {
|
|
||||||
// ui->comboBox_sample_rate_4->setCurrentText("32 k");
|
|
||||||
// }
|
|
||||||
ui->comboBox_sample_rate_4->setCurrentIndex(seismic_monitor[i].sampling_rate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Seismic_monitor::on_pushButton_confirm_clicked() {
|
|
||||||
for (int var = 0; var < CHANNLE_COUNT; ++var) {
|
void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
|
||||||
if (seismic_monitor[var].id == 1) {
|
for (int var = 0; var < CHANNEL_COUNT; ++var) {
|
||||||
seismic_monitor[var].transducer_name = ui->comboBox_transducer_name_1->currentText();
|
if (var + 1 == 1) {
|
||||||
seismic_monitor[var].scale_factor = ui->doubleSpinBox_scale_factor_1->value();
|
vib_data->base_config_[var].standby = ui->checkBox_standby_1->isChecked();
|
||||||
seismic_monitor[var].active = ui->checkBox_enable_1->isChecked();
|
vib_data->base_config_[var].active = ui->checkBox_enable_1->isChecked();
|
||||||
// if (ui->comboBox_sample_rate_1->currentText() == "32 k") {
|
vib_data->base_config_[var].rack_type = 0;
|
||||||
// seismic_monitor[var].sample_rate = "32000";
|
vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_1->currentIndex();
|
||||||
// }
|
vib_data->base_config_[var].transducer_id = ui->comboBox_transducer_name_1->currentIndex();
|
||||||
seismic_monitor[var].sampling_rate = ui->comboBox_sample_rate_1->currentIndex();
|
vib_data->base_config_[var].scale_factor = ui->doubleSpinBox_scale_factor_1->value();
|
||||||
seismic_monitor[var].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
vib_data->base_config_[var].sampling_rate = ui->comboBox_sample_rate_1->currentIndex();
|
||||||
seismic_monitor[var].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_1->value();
|
||||||
} else if (seismic_monitor[var].id == 2) {
|
vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_1->value();
|
||||||
seismic_monitor[var].transducer_name = ui->comboBox_transducer_name_2->currentText();
|
} else if (var + 1 == 2) {
|
||||||
seismic_monitor[var].scale_factor = ui->doubleSpinBox_scale_factor_2->value();
|
vib_data->base_config_[var].standby = ui->checkBox_standby_1->isChecked();
|
||||||
seismic_monitor[var].active = ui->checkBox_enable_2->isChecked();
|
vib_data->base_config_[var].active = ui->checkBox_enable_2->isChecked();
|
||||||
// if (ui->comboBox_sample_rate_2->currentText() == "32 k") {
|
vib_data->base_config_[var].rack_type = 0;
|
||||||
// seismic_monitor[var].sample_rate = "32000";
|
vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_2->currentIndex();
|
||||||
// }
|
vib_data->base_config_[var].transducer_id = ui->comboBox_transducer_name_2->currentIndex();
|
||||||
seismic_monitor[var].sampling_rate = ui->comboBox_sample_rate_2->currentIndex();
|
vib_data->base_config_[var].scale_factor = ui->doubleSpinBox_scale_factor_2->value();
|
||||||
seismic_monitor[var].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
vib_data->base_config_[var].sampling_rate = ui->comboBox_sample_rate_2->currentIndex();
|
||||||
seismic_monitor[var].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_2->value();
|
||||||
} else if (seismic_monitor[var].id == 3) {
|
vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_2->value();
|
||||||
seismic_monitor[var].transducer_name = ui->comboBox_transducer_name_3->currentText();
|
} else if (var + 1 == 3) {
|
||||||
seismic_monitor[var].scale_factor = ui->doubleSpinBox_scale_factor_3->value();
|
vib_data->base_config_[var].standby = ui->checkBox_standby_2->isChecked();
|
||||||
seismic_monitor[var].active = ui->checkBox_enable_3->isChecked();
|
vib_data->base_config_[var].active = ui->checkBox_enable_3->isChecked();
|
||||||
// if (ui->comboBox_sample_rate_3->currentText() == "32 k") {
|
vib_data->base_config_[var].rack_type = 0;
|
||||||
// seismic_monitor[var].sample_rate = "32000";
|
vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_3->currentIndex();
|
||||||
// }
|
vib_data->base_config_[var].transducer_id = ui->comboBox_transducer_name_3->currentIndex();
|
||||||
seismic_monitor[var].sampling_rate = ui->comboBox_sample_rate_3->currentIndex();
|
vib_data->base_config_[var].scale_factor = ui->doubleSpinBox_scale_factor_3->value();
|
||||||
seismic_monitor[var].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
vib_data->base_config_[var].sampling_rate = ui->comboBox_sample_rate_3->currentIndex();
|
||||||
seismic_monitor[var].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_3->value();
|
||||||
} else if (seismic_monitor[var].id == 4) {
|
vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_3->value();
|
||||||
seismic_monitor[var].transducer_name = ui->comboBox_transducer_name_4->currentText();
|
} else if (var + 1 == 4) {
|
||||||
seismic_monitor[var].scale_factor = ui->doubleSpinBox_scale_factor_4->value();
|
vib_data->base_config_[var].standby = ui->checkBox_standby_2->isChecked();
|
||||||
seismic_monitor[var].active = ui->checkBox_enable_4->isChecked();
|
vib_data->base_config_[var].active = ui->checkBox_enable_4->isChecked();
|
||||||
// if (ui->comboBox_sample_rate_4->currentText() == "32 k") {
|
vib_data->base_config_[var].rack_type = 0;
|
||||||
// seismic_monitor[var].sample_rate = "32000";
|
vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_4->currentIndex();
|
||||||
// }
|
vib_data->base_config_[var].transducer_id = ui->comboBox_transducer_name_4->currentIndex();
|
||||||
seismic_monitor[var].sampling_rate = ui->comboBox_sample_rate_4->currentIndex();
|
vib_data->base_config_[var].scale_factor = ui->doubleSpinBox_scale_factor_4->value();
|
||||||
seismic_monitor[var].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
vib_data->base_config_[var].sampling_rate = ui->comboBox_sample_rate_4->currentIndex();
|
||||||
seismic_monitor[var].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_4->value();
|
||||||
|
vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_4->value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QJsonObject monitor_obj, item_obj;
|
}
|
||||||
QJsonArray chan_array;
|
|
||||||
for (int i = 0; i < CHANNLE_COUNT; i++) {
|
void Seismic_monitor::on_pushButton_confirm_clicked() {
|
||||||
item_obj["id"] = seismic_monitor[i].id;
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||||
item_obj["channel_name"] = seismic_monitor[i].channel_name;
|
if (base_ptr == nullptr) {
|
||||||
item_obj["standby"] = seismic_monitor[i].standby;
|
qCritical() << " should not be here";
|
||||||
item_obj["active"] = seismic_monitor[i].active;
|
// std::shared_ptr<VibrationData> vib_data = std::make_shared<VibrationData>();
|
||||||
item_obj["rack_type"] = seismic_monitor[i].rack_type;
|
// ConfigMgr::Instance()->AddCard(vib_data);
|
||||||
item_obj["tmr_group"] = seismic_monitor[i].tmr_group;
|
// UpdateData(vib_data);
|
||||||
item_obj["channel_type"] = seismic_monitor[i].channel_type;
|
return;
|
||||||
item_obj["transducer_name"] = seismic_monitor[i].transducer_name;
|
|
||||||
item_obj["scale_factor"] = seismic_monitor[i].scale_factor;
|
|
||||||
item_obj["sampling_rate"] = seismic_monitor[i].sampling_rate;
|
|
||||||
QJsonArray normal_voltage_array;
|
|
||||||
normal_voltage_array.append(seismic_monitor[i].normal_voltage_low);
|
|
||||||
normal_voltage_array.append(seismic_monitor[i].normal_voltage_high);
|
|
||||||
item_obj["normal_voltage_range"] = normal_voltage_array;
|
|
||||||
chan_array.append(item_obj);
|
|
||||||
}
|
}
|
||||||
monitor_obj["chan"] = chan_array;
|
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||||
monitor_obj["slot"] = slot_no;
|
UpdateData(vib_data);
|
||||||
monitor_obj["version"] = 1;
|
|
||||||
monitor_obj["card_type"] = kCardVibSingle;
|
|
||||||
QJsonDocument jsonDoc;
|
|
||||||
jsonDoc.setObject(monitor_obj);
|
|
||||||
QString file_name = QString("\\config\\%1\\seismic_monitor_slot.json").arg(slot_no);
|
|
||||||
QFile file(QCoreApplication::applicationDirPath() + file_name);
|
|
||||||
file.open(QIODevice::WriteOnly);
|
|
||||||
file.write(jsonDoc.toJson());
|
|
||||||
file.close();
|
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,4 +383,3 @@ void Seismic_monitor::on_comboBox_transducer_name_4_currentTextChanged(const QSt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,21 +3,21 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "data_config.h"
|
#include "data_config.h"
|
||||||
|
#include "vibrationdata.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class Seismic_monitor;
|
class Seismic_monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Seismic_monitor : public QWidget
|
class Seismic_monitor : public QWidget {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Seismic_monitor(int slot,QWidget *parent = nullptr);
|
explicit Seismic_monitor(int slot, QWidget *parent = nullptr);
|
||||||
~Seismic_monitor();
|
~Seismic_monitor();
|
||||||
int slot_no;
|
int slot_no;
|
||||||
int channel;
|
int channel;
|
||||||
private slots:
|
private slots:
|
||||||
void on_pushButton_confirm_clicked();
|
void on_pushButton_confirm_clicked();
|
||||||
|
|
||||||
void on_pushButton_set_default_clicked();
|
void on_pushButton_set_default_clicked();
|
||||||
@ -48,12 +48,12 @@ private slots:
|
|||||||
|
|
||||||
void on_comboBox_transducer_name_4_currentTextChanged(const QString &arg1);
|
void on_comboBox_transducer_name_4_currentTextChanged(const QString &arg1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Seismic_monitor *ui;
|
Ui::Seismic_monitor *ui;
|
||||||
|
void UpdateData(std::shared_ptr<VibrationData> vib_data);
|
||||||
int card_type;
|
int card_type;
|
||||||
void readJsonFile(const QString &filePath);
|
// void readJsonFile(const QString &filePath);
|
||||||
SeismicMonitor seismic_monitor[CHANNLE_COUNT];
|
// SeismicMonitor seismic_monitor[CHANNLE_COUNT];
|
||||||
QVector<Transducer> vec_transducer;
|
QVector<Transducer> vec_transducer;
|
||||||
void Init();
|
void Init();
|
||||||
};
|
};
|
||||||
|
@ -463,7 +463,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
@ -630,7 +630,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_unit_1">
|
<widget class="QLabel" name="label_unit_1">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>mv/ m/s^2</string>
|
<string>v/mm</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -852,7 +852,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
@ -1016,7 +1016,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_unit_2">
|
<widget class="QLabel" name="label_unit_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>mv/ m/s^2</string>
|
<string>v/mm</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -1283,7 +1283,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_3">
|
<widget class="QWidget" name="tab_3">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -1414,7 +1414,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
@ -1578,7 +1578,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_unit_3">
|
<widget class="QLabel" name="label_unit_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>mv/ m/s^2</string>
|
<string>v/mm</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -1788,7 +1788,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
@ -1952,7 +1952,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_unit_4">
|
<widget class="QLabel" name="label_unit_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>mv/ m/s^2</string>
|
<string>v/mm</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
10
velocity.h
10
velocity.h
@ -28,12 +28,12 @@ class Velocity : public QWidget {
|
|||||||
private:
|
private:
|
||||||
Ui::Velocity *ui;
|
Ui::Velocity *ui;
|
||||||
|
|
||||||
Filter filter[3];
|
// Filter filter[3];
|
||||||
Dealy delay;
|
// Dealy delay;
|
||||||
Variables variables[4];
|
// Variables variables[4];
|
||||||
Alert_Variables alert_variables;
|
// Alert_Variables alert_variables;
|
||||||
|
|
||||||
void readJsonFile(const QString &filePath);
|
// void readJsonFile(const QString &filePath);
|
||||||
void Init();
|
void Init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
#include "vibrationdata.h"
|
#include "vibrationdata.h"
|
||||||
|
|
||||||
VibrationData::VibrationData()
|
VibrationData::VibrationData() {
|
||||||
{
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<VariableBase> VibrationData::GetChannelPtr(int cid) {
|
||||||
|
for (auto &item : variables_) {
|
||||||
|
if (item->id_ == cid) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -8,19 +8,20 @@
|
|||||||
class VibrationData : public CardBase {
|
class VibrationData : public CardBase {
|
||||||
public:
|
public:
|
||||||
VibrationData();
|
VibrationData();
|
||||||
void FromJson(const Json::Value &cfg) {
|
// void FromJson(const Json::Value &cfg) {
|
||||||
version_ = cfg["version"].asInt();
|
// version_ = cfg["version"].asInt();
|
||||||
slot_ = cfg["slot"].asInt();
|
// slot_ = cfg["slot"].asInt();
|
||||||
card_type_ = static_cast<CardType>(cfg["type"].asInt());
|
// card_type_ = static_cast<CardType>(cfg["type"].asInt());
|
||||||
}
|
// }
|
||||||
|
|
||||||
Json::Value ToJson() {
|
// Json::Value ToJson() {
|
||||||
Json::Value ch;
|
// Json::Value ch;
|
||||||
ch[NAME(version)] = version_;
|
// ch[NAME(version)] = version_;
|
||||||
ch[NAME(slot)] = slot_;
|
// ch[NAME(slot)] = slot_;
|
||||||
ch[NAME(type)] = card_type_;
|
// ch[NAME(type)] = card_type_;
|
||||||
return ch;
|
// return ch;
|
||||||
}
|
// }
|
||||||
|
std::shared_ptr<VariableBase> GetChannelPtr(int cid);
|
||||||
// private:
|
// private:
|
||||||
SeismicMonitor base_config_[CHANNEL_COUNT];
|
SeismicMonitor base_config_[CHANNEL_COUNT];
|
||||||
AllFilter filter_[CHANNEL_COUNT];
|
AllFilter filter_[CHANNEL_COUNT];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user