2025-03-29 18:05:12 +08:00
|
|
|
#include "config_mgr.h"
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonArray>
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
|
|
|
#include "data_config.h"
|
|
|
|
#include "vibrationdata.h"
|
2025-04-02 14:07:37 +08:00
|
|
|
#include "tachometer_data.h"
|
2025-04-02 14:32:25 +08:00
|
|
|
#include "keyphase_data.h"
|
2025-04-10 16:45:20 +08:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
2025-03-29 18:05:12 +08:00
|
|
|
|
|
|
|
ConfigMgr *ConfigMgr::instance = nullptr;
|
|
|
|
|
|
|
|
ConfigMgr::~ConfigMgr() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigMgr::Save() {
|
2025-04-01 15:03:59 +08:00
|
|
|
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 &&
|
2025-04-10 16:45:20 +08:00
|
|
|
card_type_[i] != kCardKeyphaseSingle &&
|
2025-04-01 15:03:59 +08:00
|
|
|
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;
|
2025-04-10 16:45:20 +08:00
|
|
|
channel_item["power"] = ptr->base_config_[cid].power;
|
2025-04-01 15:03:59 +08:00
|
|
|
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;
|
2025-04-16 13:55:32 +08:00
|
|
|
QJsonObject setpoint_data;
|
|
|
|
setpoint_data["direct_upper"] = ptr->vib_alert_danger[cid].direct_upper;
|
|
|
|
setpoint_data["direct_enable"] = ptr->vib_alert_danger[cid].direct_enable;
|
|
|
|
setpoint_data["1x_ampl_upper"] = ptr->vib_alert_danger[cid].x1_ampl_upper;
|
|
|
|
setpoint_data["1x_ampl_lower"] = ptr->vib_alert_danger[cid].x1_ampl_lower;
|
|
|
|
setpoint_data["1x_ampl_enable"] = ptr->vib_alert_danger[cid].x1_ampl_enable;
|
|
|
|
setpoint_data["2x_ampl_upper"] = ptr->vib_alert_danger[cid].x2_ampl_upper;
|
|
|
|
setpoint_data["2x_ampl_lower"] = ptr->vib_alert_danger[cid].x2_ampl_lower;
|
|
|
|
setpoint_data["2x_ampl_enable"] = ptr->vib_alert_danger[cid].x2_ampl_enable;
|
|
|
|
setpoint_data["danger_param"] = ptr->vib_alert_danger[cid].danger_param;
|
|
|
|
setpoint_data["danger_upper"] = ptr->vib_alert_danger[cid].danger_upper;
|
|
|
|
setpoint_data["danger_enable"] = ptr->vib_alert_danger[cid].danger_enable;
|
|
|
|
channel_item["setpoint"] = setpoint_data;
|
2025-04-01 15:03:59 +08:00
|
|
|
// variables
|
|
|
|
QJsonObject variables;
|
|
|
|
std::shared_ptr<VariableBase> base_channel_ptr = ptr->GetChannelPtr(cid + 1);
|
2025-04-10 16:45:20 +08:00
|
|
|
if (base_channel_ptr == nullptr) {
|
|
|
|
continue;
|
|
|
|
}
|
2025-04-01 15:03:59 +08:00
|
|
|
if (base_channel_ptr->type_ == kVibRadial) {
|
|
|
|
std::shared_ptr<RadialVariable> radial_ptr = std::dynamic_pointer_cast<RadialVariable>(base_channel_ptr);
|
2025-04-14 20:30:41 +08:00
|
|
|
if(radial_ptr == nullptr){
|
|
|
|
continue;
|
|
|
|
}
|
2025-04-02 09:59:55 +08:00
|
|
|
// filter
|
|
|
|
QJsonArray filter;
|
|
|
|
QJsonObject low_pass;
|
|
|
|
low_pass["low"] = radial_ptr->filter_[0].low;
|
|
|
|
low_pass["high"] = radial_ptr->filter_[0].high;
|
|
|
|
low_pass["checked"] = radial_ptr->filter_[0].checked;
|
|
|
|
filter.append(low_pass);
|
|
|
|
QJsonObject high_pass;
|
|
|
|
high_pass["low"] = radial_ptr->filter_[1].low;
|
|
|
|
high_pass["high"] = radial_ptr->filter_[1].high;
|
|
|
|
high_pass["checked"] = radial_ptr->filter_[1].checked;
|
|
|
|
filter.append(high_pass);
|
|
|
|
QJsonObject band_pass;
|
|
|
|
band_pass["low"] = radial_ptr->filter_[2].low;
|
|
|
|
band_pass["high"] = radial_ptr->filter_[2].high;
|
|
|
|
band_pass["checked"] = radial_ptr->filter_[2].checked;
|
|
|
|
filter.append(band_pass);
|
2025-04-14 20:30:41 +08:00
|
|
|
variables["filter"] = filter;
|
2025-04-01 15:03:59 +08:00
|
|
|
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);
|
2025-04-14 20:30:41 +08:00
|
|
|
if(av_ptr == nullptr){
|
|
|
|
continue;
|
|
|
|
}
|
2025-04-02 09:59:55 +08:00
|
|
|
// filter
|
|
|
|
QJsonArray filter;
|
|
|
|
QJsonObject low_pass;
|
|
|
|
low_pass["low"] = av_ptr->filter_[0].low;
|
|
|
|
low_pass["high"] = av_ptr->filter_[0].high;
|
|
|
|
low_pass["checked"] = av_ptr->filter_[0].checked;
|
|
|
|
filter.append(low_pass);
|
|
|
|
QJsonObject high_pass;
|
|
|
|
high_pass["low"] = av_ptr->filter_[1].low;
|
|
|
|
high_pass["high"] = av_ptr->filter_[1].high;
|
|
|
|
high_pass["checked"] = av_ptr->filter_[1].checked;
|
|
|
|
filter.append(high_pass);
|
|
|
|
QJsonObject band_pass;
|
|
|
|
band_pass["low"] = av_ptr->filter_[2].low;
|
|
|
|
band_pass["high"] = av_ptr->filter_[2].high;
|
|
|
|
band_pass["checked"] = av_ptr->filter_[2].checked;
|
|
|
|
filter.append(band_pass);
|
2025-04-14 20:30:41 +08:00
|
|
|
variables["filter"] = filter;
|
2025-04-01 15:03:59 +08:00
|
|
|
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;
|
2025-04-02 14:07:37 +08:00
|
|
|
} else if (card_type_[i] == kCardSpeedSingle || card_type_[i] == kCardSpeedTMRPrimary) {
|
|
|
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
|
|
|
if (base_ptr == nullptr) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
std::shared_ptr<TachometerData> ptr = std::dynamic_pointer_cast<TachometerData>(base_ptr);
|
|
|
|
QJsonArray voltage_range_array;
|
|
|
|
voltage_range_array.append(ptr->variables_[cid].normal_voltage_low);
|
|
|
|
voltage_range_array.append(ptr->variables_[cid].normal_voltage_high);
|
|
|
|
channel_item.insert("active", ptr->variables_[cid].active);
|
|
|
|
channel_item.insert("normal_voltage_range", voltage_range_array);
|
|
|
|
channel_item.insert("threshold", ptr->variables_[cid].threshold);
|
|
|
|
channel_item.insert("hysteresis", ptr->variables_[cid].hysteresis);
|
|
|
|
channel_item.insert("events_per_revolution", ptr->variables_[cid].events_per_revolution);
|
|
|
|
channel_item.insert("record_output", ptr->variables_[cid].record_output);
|
|
|
|
channel_item.insert("two_ma_clamp", ptr->variables_[cid].two_ma_clamp);
|
|
|
|
channel_item.insert("alert_latching", ptr->variables_[cid].alert_latching);
|
|
|
|
channel_item.insert("overspeed_latching", ptr->variables_[cid].overspeed_latching);
|
|
|
|
channel_item.insert("normal_latching", ptr->variables_[cid].normal_latching);
|
|
|
|
channel_item.insert("speed_peak", ptr->variables_[cid].speed_peek);
|
|
|
|
channel_item.insert("default_speed", ptr->variables_[cid].default_speed);
|
2025-04-16 13:55:32 +08:00
|
|
|
|
2025-04-10 16:45:20 +08:00
|
|
|
} else if (card_type_[i] == kCardKeyphaseSingle) {
|
2025-04-02 14:32:25 +08:00
|
|
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
|
|
|
if (base_ptr == nullptr) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
std::shared_ptr<KeyphaseData> ptr = std::dynamic_pointer_cast<KeyphaseData>(base_ptr);
|
|
|
|
QJsonArray voltage_range_array;
|
|
|
|
voltage_range_array.append(ptr->variables_[cid].normal_voltage_low);
|
|
|
|
voltage_range_array.append(ptr->variables_[cid].normal_voltage_high);
|
|
|
|
channel_item.insert("active", ptr->variables_[cid].active);
|
|
|
|
channel_item.insert("normal_voltage_range", voltage_range_array);
|
|
|
|
channel_item.insert("threshold", ptr->variables_[cid].threshold);
|
|
|
|
channel_item.insert("hysteresis", ptr->variables_[cid].hysteresis);
|
|
|
|
channel_item.insert("events_per_revolution", ptr->variables_[cid].events_per_revolution);
|
2025-04-01 15:03:59 +08:00
|
|
|
}
|
|
|
|
slot_item[QString::number(cid + 1)] = channel_item;
|
|
|
|
}
|
2025-04-10 16:45:20 +08:00
|
|
|
}else{
|
2025-04-01 15:03:59 +08:00
|
|
|
// 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);
|
2025-04-10 16:45:20 +08:00
|
|
|
filename_ = QCoreApplication::applicationDirPath() + "\\config\\tsi_config_file.json";
|
2025-04-01 15:03:59 +08:00
|
|
|
QFile file(filename_);
|
|
|
|
file.open(QIODevice::WriteOnly);
|
|
|
|
file.write(jsonDoc.toJson());
|
|
|
|
file.close();
|
2025-03-29 18:05:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigMgr::Load(QString filename) {
|
|
|
|
QFile file(filename);
|
|
|
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
2025-04-01 15:03:59 +08:00
|
|
|
// TODO: show message box
|
2025-03-29 18:05:12 +08:00
|
|
|
qDebug() << "Cannot open file for reading:" << filename;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QString content = file.readAll();
|
|
|
|
file.close();
|
|
|
|
QByteArray jsonData = content.toUtf8();
|
|
|
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
|
|
|
|
if (jsonDoc.isNull()) {
|
2025-04-01 15:03:59 +08:00
|
|
|
// TODO: show message box
|
2025-03-29 18:05:12 +08:00
|
|
|
qDebug() << "Cannot parse JSON document";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
|
2025-04-01 15:03:59 +08:00
|
|
|
// TODO: show message box
|
2025-03-29 18:05:12 +08:00
|
|
|
qDebug() << "JSON document is not an object or an array";
|
|
|
|
return;
|
|
|
|
}
|
2025-04-01 15:03:59 +08:00
|
|
|
filename_ = filename;
|
2025-03-29 18:05:12 +08:00
|
|
|
QJsonObject json_obj = jsonDoc.object();
|
|
|
|
// parse card_type
|
|
|
|
QJsonArray card_type = json_obj["card_type"].toArray();
|
|
|
|
int slot = 0;
|
|
|
|
QJsonObject temp_obj;
|
|
|
|
for (int i = 0; i < card_type.size(); ++i) {
|
|
|
|
temp_obj = card_type[i].toObject();
|
|
|
|
slot = temp_obj["slot"].toInt();
|
|
|
|
card_type_[slot - 1] = static_cast<CardType>(temp_obj["type"].toInt());
|
|
|
|
}
|
|
|
|
// parse each slot
|
|
|
|
QJsonObject channel;
|
|
|
|
for (int i = 0; i < SLOT_NUM; ++i) {
|
|
|
|
if (card_type_[i] == kCardNone) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
slot = i + 1;
|
|
|
|
if (json_obj[QString::number(slot)].isNull()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
temp_obj = json_obj[QString::number(slot)].toObject();
|
|
|
|
if (card_type_[i] == kCardVibSingle) {
|
|
|
|
std::shared_ptr<VibrationData> vib_data = std::make_shared<VibrationData>();
|
2025-04-02 14:07:37 +08:00
|
|
|
vib_data->version_ = temp_obj["version"].toInt();
|
|
|
|
vib_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
|
|
|
vib_data->slot_ = slot;
|
2025-03-29 18:05:12 +08:00
|
|
|
for (int j = 0; j < CHANNEL_COUNT; ++j) {
|
|
|
|
channel = temp_obj[QString::number(j + 1)].toObject();
|
2025-04-10 16:45:20 +08:00
|
|
|
if(channel.isEmpty())
|
|
|
|
continue;
|
2025-03-29 18:05:12 +08:00
|
|
|
// base info
|
|
|
|
vib_data->base_config_[j].standby = channel["standby"].toBool();
|
|
|
|
vib_data->base_config_[j].active = channel["active"].toBool();
|
|
|
|
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].channel_type = channel["channel_type"].toInt();
|
2025-04-01 15:03:59 +08:00
|
|
|
vib_data->base_config_[j].transducer_id = channel["transducer_id"].toInt();
|
2025-03-29 18:05:12 +08:00
|
|
|
vib_data->base_config_[j].scale_factor = channel["scale_factor"].toDouble();
|
|
|
|
vib_data->base_config_[j].sampling_rate = channel["sampling_rate"].toInt();
|
|
|
|
QJsonArray voltage_range_array = channel["normal_voltage_range"].toArray();
|
|
|
|
vib_data->base_config_[j].normal_voltage_low = voltage_range_array[0].toDouble();
|
|
|
|
vib_data->base_config_[j].normal_voltage_high = voltage_range_array[1].toDouble();
|
2025-04-10 16:45:20 +08:00
|
|
|
vib_data->base_config_[j].power = channel["power"].toBool();
|
2025-04-16 13:55:32 +08:00
|
|
|
//setpoint
|
|
|
|
QJsonObject setpoint_data = channel["setpoint"].toObject();
|
|
|
|
vib_data->vib_alert_danger[j].direct_upper = setpoint_data["direct_upper"].toDouble();
|
|
|
|
vib_data->vib_alert_danger[j].direct_enable = setpoint_data["direct_enable"].toBool();
|
|
|
|
vib_data->vib_alert_danger[j].x1_ampl_upper = setpoint_data["1x_ampl_upper"].toDouble();
|
|
|
|
vib_data->vib_alert_danger[j].x1_ampl_lower = setpoint_data["1x_ampl_lower"].toDouble();
|
|
|
|
vib_data->vib_alert_danger[j].x1_ampl_enable = setpoint_data["1x_ampl_enable"].toBool();
|
|
|
|
vib_data->vib_alert_danger[j].x2_ampl_upper = setpoint_data["2x_ampl_upper"].toDouble();
|
|
|
|
vib_data->vib_alert_danger[j].x2_ampl_lower = setpoint_data["2x_ampl_lower"].toDouble();
|
|
|
|
vib_data->vib_alert_danger[j].x2_ampl_enable = setpoint_data["2x_ampl_enable"].toBool();
|
|
|
|
vib_data->vib_alert_danger[j].danger_param = setpoint_data["danger_param"].toInt();
|
|
|
|
vib_data->vib_alert_danger[j].danger_upper = setpoint_data["danger_upper"].toDouble();
|
|
|
|
vib_data->vib_alert_danger[j].danger_enable = setpoint_data["danger_enable"].toBool();
|
2025-03-29 18:05:12 +08:00
|
|
|
// variables
|
|
|
|
QJsonObject tmp_variable = channel["variable"].toObject();
|
|
|
|
switch (vib_data->base_config_[j].channel_type) {
|
|
|
|
case kVibRadial: {
|
2025-04-01 15:03:59 +08:00
|
|
|
std::shared_ptr<RadialVariable> variable = std::make_shared<RadialVariable>();
|
2025-04-02 09:59:55 +08:00
|
|
|
// filter
|
2025-04-14 20:30:41 +08:00
|
|
|
QJsonArray filter_array = tmp_variable["filter"].toArray();
|
2025-04-02 09:59:55 +08:00
|
|
|
for (int k = 0; k < filter_array.size(); k++) {
|
2025-04-11 20:27:45 +08:00
|
|
|
QJsonObject filter_ele = filter_array[k].toObject();
|
2025-04-02 09:59:55 +08:00
|
|
|
variable->filter_[k].low = filter_ele["low"].toInt();
|
|
|
|
variable->filter_[k].high = filter_ele["high"].toInt();
|
|
|
|
variable->filter_[k].checked = filter_ele["checked"].toBool();
|
|
|
|
}
|
2025-04-01 15:03:59 +08:00
|
|
|
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 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);
|
2025-03-29 18:05:12 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case kVibVelocity:
|
|
|
|
case kVibAcc: {
|
2025-04-01 15:03:59 +08:00
|
|
|
std::shared_ptr<AccVelVariable> variable = std::make_shared<AccVelVariable>();
|
2025-04-02 09:59:55 +08:00
|
|
|
// filter
|
|
|
|
QJsonArray filter_array = channel["filter"].toArray();
|
|
|
|
for (int k = 0; k < filter_array.size(); k++) {
|
|
|
|
QJsonObject filter_ele = filter_array[i].toObject();
|
|
|
|
variable->filter_[k].low = filter_ele["low"].toInt();
|
|
|
|
variable->filter_[k].high = filter_ele["high"].toInt();
|
|
|
|
variable->filter_[k].checked = filter_ele["checked"].toBool();
|
|
|
|
}
|
2025-04-01 15:03:59 +08:00
|
|
|
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);
|
2025-03-29 18:05:12 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cards_.push_back(vib_data);
|
2025-04-02 14:07:37 +08:00
|
|
|
} else if (card_type_[i] == kCardSpeedSingle ||
|
|
|
|
card_type_[i] == kCardSpeedTMRPrimary) {
|
|
|
|
std::shared_ptr<TachometerData> speed_data = std::make_shared<TachometerData>();
|
|
|
|
speed_data->slot_ = slot;
|
|
|
|
speed_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
|
|
|
speed_data->version_ = temp_obj["version"].toInt();
|
|
|
|
for (int j = 0; j < CHANNEL_COUNT; ++j) {
|
|
|
|
channel = temp_obj[QString::number(j + 1)].toObject();
|
|
|
|
speed_data->variables_[j].active = channel["active"].toBool();
|
|
|
|
QJsonArray voltage_range_array = channel["normal_voltage_range"].toArray();
|
|
|
|
speed_data->variables_[j].normal_voltage_high = voltage_range_array[1].toDouble();
|
|
|
|
speed_data->variables_[j].normal_voltage_low = voltage_range_array[0].toDouble();
|
|
|
|
speed_data->variables_[j].threshold = channel["threshold"].toDouble();
|
|
|
|
speed_data->variables_[j].hysteresis = channel["hysteresis"].toDouble();
|
|
|
|
speed_data->variables_[j].events_per_revolution = channel["events_per_revolution"].toInt();
|
|
|
|
speed_data->variables_[j].record_output = channel["record_output"].toInt();
|
|
|
|
speed_data->variables_[j].two_ma_clamp = channel["two_ma_clamp"].toBool();
|
|
|
|
speed_data->variables_[j].alert_latching = channel["alert_latching"].toBool();
|
|
|
|
speed_data->variables_[j].overspeed_latching = channel["overspeed_latching"].toBool();
|
|
|
|
speed_data->variables_[j].normal_latching = channel["normal_latching"].toBool();
|
|
|
|
speed_data->variables_[j].speed_peek = channel["speed_peak"].toInt();
|
|
|
|
speed_data->variables_[j].default_speed = channel["default_speed"].toInt();
|
|
|
|
}
|
|
|
|
cards_.push_back(speed_data);
|
2025-04-10 16:45:20 +08:00
|
|
|
} else if (card_type_[i] == kCardKeyphaseSingle) {
|
2025-04-02 14:32:25 +08:00
|
|
|
std::shared_ptr<KeyphaseData> keyphase_data = std::make_shared<KeyphaseData>();
|
|
|
|
keyphase_data->slot_ = slot;
|
|
|
|
keyphase_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
|
|
|
keyphase_data->version_ = temp_obj["version"].toInt();
|
|
|
|
for (int j = 0; j < CHANNEL_COUNT; ++j) {
|
|
|
|
channel = temp_obj[QString::number(j + 1)].toObject();
|
|
|
|
keyphase_data->variables_[j].active = channel["active"].toBool();
|
|
|
|
QJsonArray voltage_range_array = channel["normal_voltage_range"].toArray();
|
|
|
|
keyphase_data->variables_[j].normal_voltage_high = voltage_range_array[1].toDouble();
|
|
|
|
keyphase_data->variables_[j].normal_voltage_low = voltage_range_array[0].toDouble();
|
|
|
|
keyphase_data->variables_[j].threshold = channel["threshold"].toDouble();
|
|
|
|
keyphase_data->variables_[j].hysteresis = channel["hysteresis"].toDouble();
|
|
|
|
keyphase_data->variables_[j].events_per_revolution = channel["events_per_revolution"].toInt();
|
|
|
|
}
|
|
|
|
cards_.push_back(keyphase_data);
|
2025-03-29 18:05:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2025-04-01 15:03:59 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|