add laod template vib config,fix some bugs

This commit is contained in:
zhangsheng 2026-01-10 17:32:11 +08:00
parent 8417745a17
commit 24f3956206
12 changed files with 818 additions and 71 deletions

293
config/template_vib.json Normal file
View File

@ -0,0 +1,293 @@
{
"1": {
"1": {
"active": true,
"chan_id": "S01C01",
"channel_type": 0,
"keyphase": false,
"keyphase_ch": 1,
"keyphase_slot": 1,
"normal_voltage_range": [
-18,
-2
],
"point_name": "出线端X向轴振1",
"power": false,
"sensitivity_unit": 3,
"signal_sensitivity": 8,
"standby": true,
"variable": {
"filter": [
{
"checked": false,
"high": 0,
"low": 0
},
{
"checked": false,
"high": 500,
"low": 5
},
{
"checked": false,
"high": 3000,
"low": 3
}
],
"gap": {
"alarm": {
"alert_high_delay": 0,
"alert_high_enable": false,
"alert_high_hysteresis": 0,
"alert_high_latch": false,
"alert_high_level": 0,
"danger_high_delay": 0,
"danger_high_enable": false,
"danger_high_hysteresis": 0,
"danger_high_latch": false,
"danger_high_level": 0
},
"general": {
"engieneering_unit": 4,
"output_used": false,
"rectifier_function": -1
}
},
"measurement": {
"alarm": {
"alert_high_delay": 1,
"alert_high_enable": true,
"alert_high_hysteresis": 0,
"alert_high_latch": false,
"alert_high_level": 125,
"danger_high_delay": 1,
"danger_high_enable": true,
"danger_high_hysteresis": 0,
"danger_high_latch": false,
"danger_high_level": 260
},
"general": {
"engieneering_unit": 4,
"output_used": true,
"rectifier_function": 3
}
}
}
},
"2": {
"active": true,
"chan_id": "S01C02",
"channel_type": 0,
"keyphase": false,
"keyphase_ch": 1,
"keyphase_slot": 1,
"normal_voltage_range": [
-18,
-2
],
"point_name": "出线端X向轴振2",
"power": false,
"sensitivity_unit": 3,
"signal_sensitivity": 8,
"standby": true,
"variable": {
"filter": [
{
"checked": false,
"high": 0,
"low": 0
},
{
"checked": true,
"high": 500,
"low": 5
},
{
"checked": false,
"high": 3000,
"low": 3
}
],
"gap": {
"alarm": {
"alert_high_delay": 0,
"alert_high_enable": false,
"alert_high_hysteresis": 0,
"alert_high_latch": false,
"alert_high_level": 0,
"danger_high_delay": 0,
"danger_high_enable": false,
"danger_high_hysteresis": 0,
"danger_high_latch": false,
"danger_high_level": 0
},
"general": {
"engieneering_unit": 4,
"output_used": false,
"rectifier_function": -1
}
},
"measurement": {
"alarm": {
"alert_high_delay": 1,
"alert_high_enable": true,
"alert_high_hysteresis": 0,
"alert_high_latch": false,
"alert_high_level": 125,
"danger_high_delay": 1,
"danger_high_enable": true,
"danger_high_hysteresis": 0,
"danger_high_latch": false,
"danger_high_level": 260
},
"general": {
"engieneering_unit": 4,
"output_used": true,
"rectifier_function": 3
}
}
}
},
"3": {
"active": true,
"chan_id": "S01C03",
"channel_type": 2,
"keyphase": false,
"keyphase_ch": 1,
"keyphase_slot": 1,
"normal_voltage_range": [
-20,
20
],
"point_name": "非出线端Y向绝对振动1",
"power": false,
"sensitivity_unit": 2,
"signal_sensitivity": 20,
"standby": true,
"variable": {
"filter": [
{
"checked": false,
"high": 0,
"low": 0
},
{
"checked": false,
"high": 3000,
"low": 3
},
{
"checked": false,
"high": 3000,
"low": 3
}
],
"processed_output": {
"alarm": {
"alert_high_delay": 1,
"alert_high_enable": true,
"alert_high_hysteresis": 0,
"alert_high_latch": false,
"alert_high_level": 7.5,
"danger_high_delay": 1,
"danger_high_enable": true,
"danger_high_hysteresis": 0,
"danger_high_latch": false,
"danger_high_level": 11.800000190734864
},
"general": {
"engieneering_unit": 2,
"output_used": true,
"rectifier_function": 6
}
}
}
},
"4": {
"active": false,
"chan_id": "S01C04",
"channel_type": 2,
"keyphase": false,
"keyphase_ch": 1,
"keyphase_slot": 1,
"normal_voltage_range": [
-20,
20
],
"point_name": "非出线端Y向绝对振动2",
"power": false,
"sensitivity_unit": 2,
"signal_sensitivity": 20,
"standby": true,
"variable": {
"filter": [
{
"checked": false,
"high": 0,
"low": 0
},
{
"checked": false,
"high": 3000,
"low": 3
},
{
"checked": false,
"high": 3000,
"low": 3
}
],
"processed_output": {
"alarm": {
"alert_high_delay": 1,
"alert_high_enable": true,
"alert_high_hysteresis": 0,
"alert_high_latch": false,
"alert_high_level": 7.5,
"danger_high_delay": 1,
"danger_high_enable": true,
"danger_high_hysteresis": 0,
"danger_high_latch": false,
"danger_high_level": 11.800000190734864
},
"general": {
"engieneering_unit": 2,
"output_used": true,
"rectifier_function": 6
}
}
}
},
"dc_output": {
"1": {
"maxmum": 500,
"minmum": 0,
"output_channel": 0
},
"2": {
"maxmum": 500,
"minmum": 0,
"output_channel": 0
},
"3": {
"maxmum": 20,
"minmum": 0,
"output_channel": 2
},
"4": {
"maxmum": 20,
"minmum": 0,
"output_channel": 2
}
},
"group": 1,
"relative_number": 1,
"version": 1
},
"card_type": [
{
"slot": 1,
"type": 10
}
]
}

View File

@ -1130,6 +1130,328 @@ void ConfigMgr::Load(QString filename) {
}
}
void ConfigMgr::LaodTemplate(QString filename,int slot){
QFile file(filename);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
// TODO: show message box
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()) {
// TODO: show message box
qDebug() << "Cannot parse JSON document";
return;
}
if (!jsonDoc.isObject() && !jsonDoc.isArray()) {
// TODO: show message box
qDebug() << "JSON document is not an object or an array";
return;
}
filename_ = filename;
QJsonObject json_obj = jsonDoc.object();
// parse card_type
QJsonArray card_type = json_obj["card_type"].toArray();
QJsonObject temp_obj;
for (int i = 0; i < card_type.size(); ++i) {
temp_obj = card_type[i].toObject();
card_type_[slot - 1] = static_cast<CardType>(temp_obj["type"].toInt());
}
// parse each slot
QJsonObject channel;
temp_obj = json_obj[QString::number(1)].toObject();
std::shared_ptr<VibrationData> vib_data = std::make_shared<VibrationData>();
vib_data->version_ = temp_obj["version"].toInt();
vib_data->card_type_ = kCardVibSingle;
vib_data->slot_ = slot;
vib_data->relative_number = temp_obj["relative_number"].toInt();
vib_data->group = temp_obj["group"].toInt();
// dc_output
QJsonObject dc_output_obj = temp_obj["dc_output"].toObject();
if(!dc_output_obj.isEmpty()){
QJsonObject output_obj;
for (int var = 0; var < CHANNEL_COUNT; ++var) {
output_obj = dc_output_obj[QString::number(var + 1)].toObject();
if(output_obj.isEmpty())
continue;
vib_data->dc_output[var].output_channel = output_obj["output_channel"].toInt();
vib_data->dc_output[var].minmum = output_obj["minmum"].toDouble();
vib_data->dc_output[var].maxmum = output_obj["maxmum"].toDouble();
}
}
for (int j = 0; j < CHANNEL_COUNT; ++j) {
std::shared_ptr<VariableBase> base_channel_ptr = vib_data->GetChannelPtr(j + 1);
channel = temp_obj[QString::number(j + 1)].toObject();
if(channel.isEmpty())
continue;
// base info
vib_data->base_config_[j].channel_type = channel["channel_type"].toInt();
if(vib_data->base_config_[j].channel_type == kVib12 ||
vib_data->base_config_[j].channel_type == kVib34){
vib_data->base_config_[j].function = channel["function"].toInt();
if(vib_data->base_config_[j].function == kRST){
vib_data->base_config_[j].first_channel_angle = channel["first_channel_angle"].toDouble();
vib_data->base_config_[j].second_channel_angle = channel["second_channel_angle"].toDouble();
}else if(vib_data->base_config_[j].function == kDMF){
vib_data->base_config_[j].dmf_function = channel["dmf_function"].toInt();
}
}else{
vib_data->base_config_[j].standby = channel["standby"].toBool();
vib_data->base_config_[j].active = channel["active"].toBool();
vib_data->base_config_[j].transducer_id = channel["transducer_id"].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();
vib_data->base_config_[j].power = channel["power"].toBool();
vib_data->base_config_[j].point_name = channel["point_name"].toString();
vib_data->base_config_[j].chan_id = channel["chan_id"].toString();
vib_data->base_config_[j].sensitivity_unit = channel["sensitivity_unit"].toInt();
vib_data->base_config_[j].signal_sensitivity = channel["signal_sensitivity"].toDouble();
vib_data->base_config_[j].keyphase = channel["keyphase"].toBool();
vib_data->base_config_[j].keyphase_slot = channel["keyphase_slot"].toInt();
vib_data->base_config_[j].keyphase_ch = channel["keyphase_ch"].toInt();
}
//setpoint
QJsonObject setpoint_data = channel["setpoint"].toObject();
if(vib_data->base_config_[j].channel_type == kVibRadial || vib_data->base_config_[j].channel_type == kVibThrust ||
vib_data->base_config_[j].channel_type == kVibAcc ||vib_data->base_config_[j].channel_type == kVibVelocity ){
vib_data->base_config_[j].keyphase = channel["keyphase"].toBool();
vib_data->base_config_[j].keyphase_slot = channel["keyphase_slot"].toInt();
vib_data->base_config_[j].keyphase_ch = channel["keyphase_ch"].toInt();
}
// variables
QJsonObject tmp_variable = channel["variable"].toObject();
switch (vib_data->base_config_[j].channel_type) {
case kVibRadial: {
std::shared_ptr<RadialVariable> variable = std::make_shared<RadialVariable>();
// filter
QJsonArray filter_array = tmp_variable["filter"].toArray();
for (int k = 0; k < filter_array.size(); k++) {
QJsonObject filter_ele = filter_array[k].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();
}
variable->id_ = j + 1;
QJsonObject measurement, gap,m_general,m_alarm,g_general,g_alarm;
measurement = tmp_variable["measurement"].toObject();
gap = tmp_variable["gap"].toObject();
m_general = measurement["general"].toObject();
m_alarm = measurement["alarm"].toObject();
g_general = gap["general"].toObject();
g_alarm = gap["alarm"].toObject();
variable->general.output_used = m_general["output_used"].toBool();
variable->general.engineering_unit = m_general["engieneering_unit"].toInt();
variable->general.rectifier_function = m_general["rectifier_function"].toInt();
variable->danger_high.level = m_alarm["danger_high_level"].toDouble();
variable->danger_high.hysteresis = m_alarm["danger_high_hysteresis"].toDouble();
variable->danger_high.delay = m_alarm["danger_high_delay"].toInt();
variable->danger_high.enable = m_alarm["danger_high_enable"].toBool();
variable->danger_high.latch = m_alarm["danger_high_latch"].toBool();
variable->alert_high.level = m_alarm["alert_high_level"].toDouble();
variable->alert_high.hysteresis = m_alarm["alert_high_hysteresis"].toDouble();
variable->alert_high.delay = m_alarm["alert_high_delay"].toInt();
variable->alert_high.enable = m_alarm["alert_high_enable"].toBool();
variable->alert_high.latch = m_alarm["alert_high_latch"].toBool();
variable->gap_general.output_used = g_general["output_used"].toBool();
variable->gap_general.engineering_unit = g_general["engieneering_unit"].toInt();
variable->gap_general.rectifier_function = g_general["rectifier_function"].toInt();
variable->gap_danger_high.level = g_alarm["danger_high_level"].toDouble();
variable->gap_danger_high.hysteresis = g_alarm["danger_high_hysteresis"].toDouble();
variable->gap_danger_high.delay = g_alarm["danger_high_delay"].toInt();
variable->gap_danger_high.enable = g_alarm["danger_high_enable"].toBool();
variable->gap_danger_high.latch = g_alarm["danger_high_latch"].toBool();
variable->gap_alert_high.level = g_alarm["alert_high_level"].toDouble();
variable->gap_alert_high.hysteresis = g_alarm["alert_high_hysteresis"].toDouble();
variable->gap_alert_high.delay = g_alarm["alert_high_delay"].toInt();
variable->gap_alert_high.enable = g_alarm["alert_high_enable"].toBool();
variable->gap_alert_high.latch = g_alarm["alert_high_latch"].toBool();
vib_data->variables_.push_back(variable);
break;
}
case kVibThrust: {
std::shared_ptr<ThrustVariable> variable = std::make_shared<ThrustVariable>();
// filter
QJsonArray filter_array = tmp_variable["filter"].toArray();
for (int k = 0; k < filter_array.size(); k++) {
QJsonObject filter_ele = filter_array[k].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();
}
variable->id_ = j + 1;
QJsonObject gap,g_general,g_alarm;
gap = tmp_variable["gap"].toObject();
g_general = gap["general"].toObject();
g_alarm = gap["alarm"].toObject();
variable->gap_general.output_used = g_general["output_used"].toBool();
variable->gap_general.engineering_unit = g_general["engieneering_unit"].toInt();
variable->gap_danger_high.level = g_alarm["danger_high_level"].toDouble();
variable->gap_danger_high.hysteresis = g_alarm["danger_high_hysteresis"].toDouble();
variable->gap_danger_high.delay = g_alarm["danger_high_delay"].toInt();
variable->gap_danger_high.enable = g_alarm["danger_high_enable"].toBool();
variable->gap_danger_high.latch = g_alarm["danger_high_latch"].toBool();
variable->gap_alert_high.level = g_alarm["alert_high_level"].toDouble();
variable->gap_alert_high.hysteresis = g_alarm["alert_high_hysteresis"].toDouble();
variable->gap_alert_high.delay = g_alarm["alert_high_delay"].toInt();
variable->gap_alert_high.enable = g_alarm["alert_high_enable"].toBool();
variable->gap_alert_high.latch = g_alarm["alert_high_latch"].toBool();
variable->gap_danger_low.level = g_alarm["danger_low_level"].toDouble();
variable->gap_danger_low.hysteresis = g_alarm["danger_low_hysteresis"].toDouble();
variable->gap_danger_low.delay = g_alarm["danger_low_delay"].toInt();
variable->gap_danger_low.enable = g_alarm["danger_low_enable"].toBool();
variable->gap_danger_low.latch = g_alarm["danger_low_latch"].toBool();
variable->gap_alert_low.level = g_alarm["alert_low_level"].toDouble();
variable->gap_alert_low.hysteresis = g_alarm["alert_low_hysteresis"].toDouble();
variable->gap_alert_low.delay = g_alarm["alert_low_delay"].toInt();
variable->gap_alert_low.enable = g_alarm["alert_low_enable"].toBool();
variable->gap_alert_low.latch = g_alarm["alert_low_latch"].toBool();
variable->zero_position.value = tmp_variable["zero_position"].toDouble();
variable->zero_position.negation = tmp_variable["negation"].toBool();
vib_data->variables_.push_back(variable);
break;
}
case kVibPressurePulsation:{
std::shared_ptr<PressurePulsationVariable> variable = std::make_shared<PressurePulsationVariable>();
// filter
QJsonArray filter_array = tmp_variable["filter"].toArray();
for (int k = 0; k < filter_array.size(); k++) {
QJsonObject filter_ele = filter_array[k].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();
}
variable->id_ = j + 1;
QJsonObject processed_output, general, alarm;
processed_output = tmp_variable["processed_output"].toObject();
general = processed_output["general"].toObject();
alarm = processed_output["alarm"].toObject();
variable->general.output_used = general["output_used"].toBool();
variable->general.engineering_unit = general["engieneering_unit"].toInt();
variable->general.rectifier_function = general["rectifier_function"].toInt();
variable->danger_high.level = alarm["danger_high_level"].toDouble();
variable->danger_high.hysteresis = alarm["danger_high_hysteresis"].toDouble();
variable->danger_high.delay = alarm["danger_high_delay"].toInt();
variable->danger_high.enable = alarm["danger_high_enable"].toBool();
variable->danger_high.latch = alarm["danger_high_latch"].toBool();
variable->alert_high.level = alarm["alert_high_level"].toDouble();
variable->alert_high.hysteresis = alarm["alert_high_hysteresis"].toDouble();
variable->alert_high.delay = alarm["alert_high_delay"].toInt();
variable->alert_high.enable = alarm["alert_high_enable"].toBool();
variable->alert_high.latch = alarm["alert_high_latch"].toBool();
QJsonObject freband_output_obj = tmp_variable["freband_output"].toObject();
QJsonObject number_obj,config_params;
for (int k = 0; k < 10; ++k) {
number_obj = freband_output_obj[QString::number(k + 1)].toObject();
if(number_obj.isEmpty())
continue;
FrequencybandOutput output;
output.enable = number_obj["enable"].toBool();
output.start = number_obj["start"].toInt();
output.end = number_obj["end"].toInt();
variable->freband_output[k] = output;
}
config_params = tmp_variable["config_params"].toObject();
if(!config_params.isEmpty()){
variable->freband_output_item.fre_domain_resolution = config_params["fre_domain_resolution"].toDouble();
variable->freband_output_item.lines_number = config_params["lines_number"].toInt();
}
vib_data->variables_.push_back(variable);
break;
}
case kVibVelocity:{
std::shared_ptr<AccVelVariable> variable = std::make_shared<AccVelVariable>();
// filter
QJsonArray filter_array = tmp_variable["filter"].toArray();
for (int k = 0; k < filter_array.size(); k++) {
QJsonObject filter_ele = filter_array[k].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();
}
variable->id_ = j + 1;
QJsonObject processed_output, general, alarm;
processed_output = tmp_variable["processed_output"].toObject();
general = processed_output["general"].toObject();
alarm = processed_output["alarm"].toObject();
variable->general.output_used = general["output_used"].toBool();
variable->general.engineering_unit = general["engieneering_unit"].toInt();
variable->general.rectifier_function = general["rectifier_function"].toInt();
variable->danger_high.level = alarm["danger_high_level"].toDouble();
variable->danger_high.hysteresis = alarm["danger_high_hysteresis"].toDouble();
variable->danger_high.delay = alarm["danger_high_delay"].toInt();
variable->danger_high.enable = alarm["danger_high_enable"].toBool();
variable->danger_high.latch = alarm["danger_high_latch"].toBool();
variable->alert_high.level = alarm["alert_high_level"].toDouble();
variable->alert_high.hysteresis = alarm["alert_high_hysteresis"].toDouble();
variable->alert_high.delay = alarm["alert_high_delay"].toInt();
variable->alert_high.enable = alarm["alert_high_enable"].toBool();
variable->alert_high.latch = alarm["alert_high_latch"].toBool();
vib_data->variables_.push_back(variable);
break;
}
case kVibAcc: {
std::shared_ptr<AccVelVariable> variable = std::make_shared<AccVelVariable>();
// filter
QJsonArray filter_array = tmp_variable["filter"].toArray();
for (int k = 0; k < filter_array.size(); k++) {
QJsonObject filter_ele = filter_array[k].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();
}
variable->id_ = j + 1;
QJsonObject processed_output, general, alarm;
processed_output = tmp_variable["processed_output"].toObject();
general = processed_output["general"].toObject();
alarm = processed_output["alarm"].toObject();
variable->general.output_used = general["output_used"].toBool();
variable->general.engineering_unit = general["engieneering_unit"].toInt();
variable->general.rectifier_function = general["rectifier_function"].toInt();
variable->danger_high.level = alarm["danger_high_level"].toDouble();
variable->danger_high.hysteresis = alarm["danger_high_hysteresis"].toDouble();
variable->danger_high.delay = alarm["danger_high_delay"].toInt();
variable->danger_high.enable = alarm["danger_high_enable"].toBool();
variable->danger_high.latch = alarm["danger_high_latch"].toBool();
variable->alert_high.level = alarm["alert_high_level"].toDouble();
variable->alert_high.hysteresis = alarm["alert_high_hysteresis"].toDouble();
variable->alert_high.delay = alarm["alert_high_delay"].toInt();
variable->alert_high.enable = alarm["alert_high_enable"].toBool();
variable->alert_high.latch = alarm["alert_high_latch"].toBool();
QJsonObject freband_output_obj = tmp_variable["freband_output"].toObject();
QJsonObject number_obj,config_params;
for (int k = 0; k < 10; ++k) {
number_obj = freband_output_obj[QString::number(k + 1)].toObject();
if(number_obj.isEmpty())
continue;
FrequencybandOutput output;
output.enable = number_obj["enable"].toBool();
output.start = number_obj["start"].toInt();
output.end = number_obj["end"].toInt();
variable->freband_output[k] = output;
}
config_params = tmp_variable["config_params"].toObject();
if(!config_params.isEmpty()){
variable->freband_output_item.fre_domain_resolution = config_params["fre_domain_resolution"].toDouble();
variable->freband_output_item.lines_number = config_params["lines_number"].toInt();
}
vib_data->variables_.push_back(variable);
break;
}
}
}
cards_.push_back(vib_data);
}
std::shared_ptr<CardBase> ConfigMgr::GetSlotPtr(int slot) {
for (auto &item : cards_) {
if (item->slot_ == slot) {

View File

@ -124,6 +124,7 @@ class ConfigMgr {
~ConfigMgr();
int Save(QString & file_path);
void Load(QString filename);
void LaodTemplate(QString filename,int slot);
std::shared_ptr<CardBase> GetSlotPtr(int slot);//1-15
void AddCard(std::shared_ptr<CardBase> ptr);
void RemoveCard(std::shared_ptr<CardBase> ptr);

View File

@ -584,6 +584,14 @@ typedef struct TMRRelay_{
}
} TMRRelay;
enum UpgradeResultCode {
kUpgradeNone = 0,
kUpgradeUploadSuccess = 1,
kUpgradeSuccessToSubcard = 2,
kUpgradeFailToTransfer = 3,
KupgradeCrcError = 4
};
#pragma pack(1)
// kUpgradeCard
typedef struct {

View File

@ -104,6 +104,7 @@ MainWindow::MainWindow(QWidget *parent)
QObject::connect(ui->action_mqtt, &QAction::triggered, this, &MainWindow::onMqttConfig);
QObject::connect(ui->action_deviveID, &QAction::triggered, this, &MainWindow::onConfigDeviceID);
QObject::connect(ui->action_get_deviceID, &QAction::triggered, this, &MainWindow::onGetDeviceID);
QObject::connect(ui->action_close, &QAction::triggered, this, &MainWindow::onCloseConfig);
QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini", QSettings::IniFormat);
@ -115,7 +116,7 @@ MainWindow::MainWindow(QWidget *parent)
//qInstallMessageHandler(messageHandler);
#endif
QDate buildDate = QLocale( QLocale::English ).toDate( QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
QString Version = "V1.0_" + buildDate.toString("yyyyMMdd") + "_1de7";
QString Version = "V1.0_" + buildDate.toString("yyyyMMdd") + "_8417";
ui->label_version->setText(Version);
}
@ -353,6 +354,7 @@ void MainWindow::onMenuActionTriggered() {
map_slot_config[button_id].card_type = card_type;
button->setText(chan_display);
ConfigMgr::Instance()->card_type_[button_id - 1] = card_type;
ConfigMgr::Instance()->LaodTemplate(":/config/template_vib.json",button_id);
}else if ((card_type == kCardVibSingle || card_type == kCardSpeedSingle ||
card_type == kCardKeyphaseSingle || card_type == kCardRelaySingle ||
card_type == kCardRelaySingleNOK) && ConfigMgr::Instance()->card_type_[button_id - 1] != kCardNone) {
@ -908,15 +910,24 @@ void MainWindow::readData(const QByteArray &data) {
if (cmd == kGetVersionInfo) {
VersionRsp version_rsp;
memcpy(&version_rsp, data.data(), sizeof(VersionRsp));
QString strVerion = QString("第 %1 板卡\nFPGA 版本:%2\n软件版本:%3\nFPGA版本日期%4").arg(slot_no).arg(version_rsp.fpga).arg(version_rsp.sw).arg(version_rsp.fpga_date);
QString strVerion = "";
if(slot_no == 0){
strVerion = QString("CPU板卡\nFPGA 版本:%2\n软件版本:%3\nFPGA版本日期%4").arg(slot_no).arg(version_rsp.fpga).arg(version_rsp.sw).arg(version_rsp.fpga_date);
}else{
strVerion = QString("第 %1 板卡\nFPGA 版本:%2\n软件版本:%3\nFPGA版本日期%4").arg(slot_no).arg(version_rsp.fpga).arg(version_rsp.sw).arg(version_rsp.fpga_date);
}
QMessageBox::information(this, QStringLiteral("提示"), strVerion);
} else if (cmd == kUpgradeCard) {
UpgradeRsp resp;
memcpy(&resp, data.data(), sizeof(UpgradeRsp));
if (resp.code == 0) {
if (resp.code == kUpgradeUploadSuccess) {
statusBar()->showMessage("上传成功!", 3000);
}else {
}else if(resp.code == kUpgradeSuccessToSubcard){
statusBar()->showMessage("上传子板卡成功!", 3000);
}else if(resp.code == kUpgradeFailToTransfer){
statusBar()->showMessage("上传失败!", 3000);
}else if(resp.code == KupgradeCrcError){
statusBar()->showMessage("文件CRC校验失败", 3000);
}
} else if (cmd == kUpgradeProgress) {
UpgradeRsp upgrade_resp;
@ -1067,7 +1078,19 @@ void MainWindow::onGetDeviceID(){
m_tcpClient->waitForRead();
qDebug() << "bytesWritten: " << bytesWritten;
}
void MainWindow::onCloseConfig(){
QList<QAbstractButton *> buttonList = btnGroup_slot->buttons();
for (int i = 1; i < buttonList.count(); i++) {
buttonList[i]->setText("");
}
for (int i = 0; i < SLOT_NUM; i++) {
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(i + 1);
if(base_ptr != nullptr){
ConfigMgr::Instance()->RemoveCard(base_ptr);
}
}
tsi_config_file = "";
}
void MainWindow::onConfigDeviceID(){
QString strTips =QString("请输入0到99之间的数值");

View File

@ -82,6 +82,7 @@ private slots:
void onMqttConfig();
void onConfigDeviceID();
void onGetDeviceID();
void onCloseConfig();
void onMenuActionTriggered();

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1129</width>
<height>537</height>
<height>561</height>
</rect>
</property>
<property name="windowTitle">
@ -1071,6 +1071,7 @@
</property>
<addaction name="action_new"/>
<addaction name="action_open"/>
<addaction name="action_close"/>
<addaction name="action_import"/>
<addaction name="action_connect"/>
<addaction name="action_disconnect"/>
@ -1162,6 +1163,11 @@
<string>获取振动板卡辅助程序版本</string>
</property>
</action>
<action name="action_close">
<property name="text">
<string>关闭</string>
</property>
</action>
</widget>
<resources/>
<connections/>

View File

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>qss/soft.css</file>
<file>config/template_vib.json</file>
</qresource>
</RCC>

View File

@ -25,6 +25,7 @@ Radial::Radial(int slot_no_, int channel_, bool active, QWidget *parent)
} else {
ui->label_active->setText("(停用)");
}
ui->comboBox_output_used_2->setCurrentIndex(1);
Init();
}

View File

@ -49,6 +49,8 @@ Seismic_monitor::Seismic_monitor(int slot,CardType cardtype, QWidget *parent) :
ui->label_text_6->setVisible(false);
ui->comboBox_function_1->setCurrentIndex(0);
ui->comboBox_function_2->setCurrentIndex(0);
ui->comboBox_dual_math_function->setCurrentIndex(6);
ui->comboBox_dual_math_function_2->setCurrentIndex(6);
Init();
}
@ -187,9 +189,16 @@ void Seismic_monitor::Init() {
ui->comboBox_group->setCurrentIndex(base_ptr->group - 1);
}
void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data,int save) {
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
for (int var = 0; var < CHANNEL_COUNT; ++var) {
if (var + 1 == 1) {
std::shared_ptr<VariableBase> base_channel_ptr = ptr->GetChannelPtr(var + 1);
if(base_channel_ptr == nullptr && save == 1){
QMessageBox::information(this, QStringLiteral("提示"), "通道1未配置完整");
return;
}
vib_data->base_config_[var].standby = ui->checkBox_standby_1->isChecked();
vib_data->base_config_[var].active = ui->checkBox_enable_1->isChecked();
vib_data->base_config_[var].rack_type = 0;
@ -207,6 +216,11 @@ void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
vib_data->base_config_[var].keyphase_slot = ui->comboBox_keyphase_slot->currentText().toInt();
vib_data->base_config_[var].keyphase_ch = ui->comboBox_keyphase_ch->currentText().toInt();
} else if (var + 1 == 2) {
std::shared_ptr<VariableBase> base_channel_ptr = ptr->GetChannelPtr(var + 1);
if(base_channel_ptr == nullptr && save == 1){
QMessageBox::information(this, QStringLiteral("提示"), "通道2未配置完整");
return;
}
vib_data->base_config_[var].standby = ui->checkBox_standby_1->isChecked();
vib_data->base_config_[var].active = ui->checkBox_enable_2->isChecked();
vib_data->base_config_[var].rack_type = 0;
@ -224,6 +238,11 @@ void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
vib_data->base_config_[var].keyphase_slot = ui->comboBox_keyphase_slot_2->currentText().toInt();
vib_data->base_config_[var].keyphase_ch = ui->comboBox_keyphase_ch_2->currentText().toInt();
} else if (var + 1 == 3) {
std::shared_ptr<VariableBase> base_channel_ptr = ptr->GetChannelPtr(var + 1);
if(base_channel_ptr == nullptr && save == 1){
QMessageBox::information(this, QStringLiteral("提示"), "通道3未配置完整");
return;
}
vib_data->base_config_[var].standby = ui->checkBox_standby_2->isChecked();
vib_data->base_config_[var].active = ui->checkBox_enable_3->isChecked();
vib_data->base_config_[var].rack_type = 0;
@ -242,6 +261,11 @@ void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
vib_data->base_config_[var].keyphase_slot = ui->comboBox_keyphase_slot_3->currentText().toInt();
vib_data->base_config_[var].keyphase_ch = ui->comboBox_keyphase_ch_3->currentText().toInt();
} else if (var + 1 == 4) {
std::shared_ptr<VariableBase> base_channel_ptr = ptr->GetChannelPtr(var + 1);
if(base_channel_ptr == nullptr && save == 1){
QMessageBox::information(this, QStringLiteral("提示"), "通道4未配置完整");
return;
}
vib_data->base_config_[var].standby = ui->checkBox_standby_2->isChecked();
vib_data->base_config_[var].active = ui->checkBox_enable_4->isChecked();
vib_data->base_config_[var].rack_type = 0;
@ -346,111 +370,122 @@ void Seismic_monitor::on_pushButton_confirm_clicked() {
base_ptr->relative_number = ui->comboBox_relative_number->currentIndex();
base_ptr->group = ui->comboBox_group->currentIndex() + 1;
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
UpdateData(vib_data);
UpdateData(vib_data,1);
qDebug() <<"type" << base_ptr->card_type_;
this->close();
}
void Seismic_monitor::on_pushButton_set_default_clicked() {
}
void Seismic_monitor::OpenAcc(){
Acceleration *acceleration = new Acceleration(slot_no, channel, ui->checkBox_enable_1->isChecked());
// connect(acceleration, &QObject::destroyed,
// this, &Seismic_monitor::onConfigWindowClosed);
// acceleration->setAttribute(Qt::WA_DeleteOnClose);
acceleration->setWindowModality(Qt::ApplicationModal);
acceleration->show();
}
void Seismic_monitor::OpenRadial(){
Radial *radial_vibration = new Radial(slot_no, channel, ui->checkBox_enable_1->isChecked());
// connect(radial_vibration, &QObject::destroyed,
// this, &Seismic_monitor::onConfigWindowClosed);
// radial_vibration->setAttribute(Qt::WA_DeleteOnClose);
radial_vibration->setWindowModality(Qt::ApplicationModal);
radial_vibration->show();
}
void Seismic_monitor::OpenVelocity(){
Velocity *velocity = new Velocity(slot_no, channel, ui->checkBox_enable_1->isChecked());
// connect(velocity, &QObject::destroyed,
// this, &Seismic_monitor::onConfigWindowClosed);
// velocity->setAttribute(Qt::WA_DeleteOnClose);
velocity->setWindowModality(Qt::ApplicationModal);
velocity->show();
}
void Seismic_monitor::OpenTrust(){
Trust *trust = new Trust(slot_no, channel, ui->checkBox_enable_1->isChecked());
// connect(trust, &QObject::destroyed,
// this, &Seismic_monitor::onConfigWindowClosed);
// trust->setAttribute(Qt::WA_DeleteOnClose);
trust->setWindowModality(Qt::ApplicationModal);
trust->show();
}
void Seismic_monitor::OpenPressure(){
PressurePulsation *pressure_pulsation = new PressurePulsation(slot_no, channel, ui->checkBox_enable_1->isChecked());
// connect(pressure_pulsation, &QObject::destroyed,
// this, &Seismic_monitor::onConfigWindowClosed);
// pressure_pulsation->setAttribute(Qt::WA_DeleteOnClose);
pressure_pulsation->setWindowModality(Qt::ApplicationModal);
pressure_pulsation->show();
}
void Seismic_monitor::onConfigWindowClosed(QObject *)
{
// qDebug() << "onConfigWindowClosed";
// if(ui->comboBox_function_1->currentIndex() != 0 &&
// ui->comboBox_dual_math_function->currentIndex() != 6){
// on_comboBox_dual_math_function_currentIndexChanged(ui->comboBox_dual_math_function->currentIndex());
// }
// if(ui->comboBox_function_2->currentIndex() != 0 &&
// ui->comboBox_dual_math_function_2->currentIndex() != 6){
// on_comboBox_dual_math_function_2_currentIndexChanged(ui->comboBox_dual_math_function_2->currentIndex());
// }
}
void Seismic_monitor::on_pushButton_config_1_clicked() {
channel = 1;
if (ui->comboBox_chan_type_1->currentIndex() == kVibAcc) {
Acceleration *acceleration = new Acceleration(slot_no, channel, ui->checkBox_enable_1->isChecked());
acceleration->setWindowModality(Qt::ApplicationModal);
acceleration->show();
OpenAcc();
} else if (ui->comboBox_chan_type_1->currentIndex() == kVibRadial) {
Radial *radial_vibration = new Radial(slot_no, channel, ui->checkBox_enable_1->isChecked());
radial_vibration->setWindowModality(Qt::ApplicationModal);
radial_vibration->show();
OpenRadial();
} else if (ui->comboBox_chan_type_1->currentIndex() == kVibVelocity) {
Velocity *velocity = new Velocity(slot_no, channel, ui->checkBox_enable_1->isChecked());
velocity->setWindowModality(Qt::ApplicationModal);
velocity->show();
OpenVelocity();
}else if (ui->comboBox_chan_type_1->currentIndex() == kVibThrust) {
Trust *trust = new Trust(slot_no, channel, ui->checkBox_enable_1->isChecked());
trust->setWindowModality(Qt::ApplicationModal);
trust->show();
OpenTrust();
}else if (ui->comboBox_chan_type_1->currentIndex() == kVibPressurePulsation) {
PressurePulsation *pressure_pulsation = new PressurePulsation(slot_no, channel, ui->checkBox_enable_1->isChecked());
pressure_pulsation->setWindowModality(Qt::ApplicationModal);
pressure_pulsation->show();
OpenPressure();
}
}
void Seismic_monitor::on_pushButton_config_2_clicked() {
channel = 2;
if (ui->comboBox_chan_type_2->currentIndex() == kVibAcc) {
Acceleration *acceleration = new Acceleration(slot_no, channel, ui->checkBox_enable_2->isChecked());
acceleration->setWindowModality(Qt::ApplicationModal);
acceleration->show();
OpenAcc();
} else if (ui->comboBox_chan_type_2->currentIndex() == kVibRadial) {
Radial *radial_vibration = new Radial(slot_no, channel, ui->checkBox_enable_2->isChecked());
radial_vibration->setWindowModality(Qt::ApplicationModal);
radial_vibration->show();
OpenRadial();
} else if (ui->comboBox_chan_type_2->currentIndex() == kVibVelocity) {
Velocity *velocity = new Velocity(slot_no, channel, ui->checkBox_enable_2->isChecked());
velocity->setWindowModality(Qt::ApplicationModal);
velocity->show();
OpenVelocity();
}else if (ui->comboBox_chan_type_2->currentIndex() == kVibThrust) {
Trust *trust = new Trust(slot_no, channel, ui->checkBox_enable_2->isChecked());
trust->setWindowModality(Qt::ApplicationModal);
trust->show();
OpenTrust();
}else if (ui->comboBox_chan_type_2->currentIndex() == kVibPressurePulsation) {
PressurePulsation *pressure_pulsation = new PressurePulsation(slot_no, channel, ui->checkBox_enable_2->isChecked());
pressure_pulsation->setWindowModality(Qt::ApplicationModal);
pressure_pulsation->show();
OpenPressure();
}
}
void Seismic_monitor::on_pushButton_config_3_clicked() {
channel = 3;
if (ui->comboBox_chan_type_3->currentIndex() == kVibAcc) {
Acceleration *acceleration = new Acceleration(slot_no, channel, ui->checkBox_enable_3->isChecked());
acceleration->setWindowModality(Qt::ApplicationModal);
acceleration->show();
OpenAcc();
} else if (ui->comboBox_chan_type_3->currentIndex() == kVibRadial) {
Radial *radial_vibration = new Radial(slot_no, channel, ui->checkBox_enable_3->isChecked());
radial_vibration->setWindowModality(Qt::ApplicationModal);
radial_vibration->show();
OpenRadial();
} else if (ui->comboBox_chan_type_3->currentIndex() == kVibVelocity) {
Velocity *velocity = new Velocity(slot_no, channel, ui->checkBox_enable_3->isChecked());
velocity->setWindowModality(Qt::ApplicationModal);
velocity->show();
OpenVelocity();
}else if (ui->comboBox_chan_type_3->currentIndex() == kVibThrust) {
Trust *trust = new Trust(slot_no, channel, ui->checkBox_enable_3->isChecked());
trust->setWindowModality(Qt::ApplicationModal);
trust->show();
OpenTrust();
}else if (ui->comboBox_chan_type_3->currentIndex() == kVibPressurePulsation) {
PressurePulsation *pressure_pulsation = new PressurePulsation(slot_no, channel, ui->checkBox_enable_3->isChecked());
pressure_pulsation->setWindowModality(Qt::ApplicationModal);
pressure_pulsation->show();
OpenPressure();
}
}
void Seismic_monitor::on_pushButton_config_4_clicked() {
channel = 4;
if (ui->comboBox_chan_type_4->currentIndex() == kVibAcc) {
Acceleration *acceleration = new Acceleration(slot_no, channel, ui->checkBox_enable_4->isChecked());
acceleration->setWindowModality(Qt::ApplicationModal);
acceleration->show();
OpenAcc();
} else if (ui->comboBox_chan_type_4->currentIndex() == kVibRadial) {
Radial *radial_vibration = new Radial(slot_no, channel, ui->checkBox_enable_4->isChecked());
radial_vibration->setWindowModality(Qt::ApplicationModal);
radial_vibration->show();
OpenRadial();
} else if (ui->comboBox_chan_type_4->currentIndex() == kVibVelocity) {
Velocity *velocity = new Velocity(slot_no, channel, ui->checkBox_enable_4->isChecked());
velocity->setWindowModality(Qt::ApplicationModal);
velocity->show();
OpenVelocity();
}else if (ui->comboBox_chan_type_4->currentIndex() == kVibThrust) {
Trust *trust = new Trust(slot_no, channel, ui->checkBox_enable_4->isChecked());
trust->setWindowModality(Qt::ApplicationModal);
trust->show();
OpenTrust();
}else if (ui->comboBox_chan_type_4->currentIndex() == kVibPressurePulsation) {
PressurePulsation *pressure_pulsation = new PressurePulsation(slot_no, channel, ui->checkBox_enable_4->isChecked());
pressure_pulsation->setWindowModality(Qt::ApplicationModal);
pressure_pulsation->show();
OpenPressure();
}
}
@ -672,6 +707,7 @@ void Seismic_monitor::on_comboBox_function_2_currentIndexChanged(int index)
ui->label_text_3->setVisible(false);
ui->label_text_4->setVisible(false);
ui->comboBox_dual_math_function_2->setVisible(true);
ui->comboBox_dual_math_function_2->setCurrentIndex(6);
ui->label_text_6->setVisible(true);
}else{
ui->lineEdit_first_2->setVisible(false);
@ -713,6 +749,7 @@ void Seismic_monitor::on_comboBox_function_1_currentIndexChanged(int index)
ui->label_text_1->setVisible(false);
ui->label_text_2->setVisible(false);
ui->comboBox_dual_math_function->setVisible(true);
ui->comboBox_dual_math_function->setCurrentIndex(6);
ui->label_text_5->setVisible(true);
}else{
ui->lineEdit_first_1->setVisible(false);
@ -803,10 +840,26 @@ int Seismic_monitor::SetUnit(QString unit_str){
void Seismic_monitor::on_comboBox_dual_math_function_currentIndexChanged(int index)
{
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
if(base_ptr == nullptr){
QMessageBox::warning(this, QStringLiteral("警告"), "请先配置通道1 和 通道2");
ui->comboBox_function_1->setCurrentIndex(0);
return;
}
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
if(ptr == nullptr){
QMessageBox::warning(this, QStringLiteral("警告"), "请先配置通道1 和 通道2");
ui->comboBox_function_1->setCurrentIndex(0);
return;
}
std::shared_ptr<VariableBase> variable_base1 = ptr->GetChannelPtr(1);
std::shared_ptr<VariableBase> variable_base2 = ptr->GetChannelPtr(2);
qDebug() << "comboBox_function_1" << ui->comboBox_function_1->currentIndex();
if(variable_base1 == nullptr || variable_base2 == nullptr){
QMessageBox::warning(this, QStringLiteral("警告"), "请先配置通道1 和 通道2");
ui->comboBox_function_1->setCurrentIndex(0);
return;
}
qDebug() << "comboBox_function_1" << ui->comboBox_function_1->currentIndex() << ui->comboBox_dual_math_function->currentIndex() << index;
index = ui->comboBox_dual_math_function->currentIndex();
if(ui->comboBox_function_1->currentIndex() == kDMF && (index == kRMSSum || index == kRMSSubtraction)
&& variable_base1->general.rectifier_function != 6
&& variable_base2->general.rectifier_function != 6){
@ -827,9 +880,24 @@ void Seismic_monitor::on_comboBox_dual_math_function_currentIndexChanged(int ind
void Seismic_monitor::on_comboBox_dual_math_function_2_currentIndexChanged(int index)
{
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
if(base_ptr == nullptr){
QMessageBox::warning(this, QStringLiteral("警告"), "请先配置通道3 和 通道4");
ui->comboBox_function_2->setCurrentIndex(0);
return;
}
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
if(ptr == nullptr){
QMessageBox::warning(this, QStringLiteral("警告"), "请先配置通道3 和 通道4");
ui->comboBox_function_2->setCurrentIndex(0);
return;
}
std::shared_ptr<VariableBase> variable_base1 = ptr->GetChannelPtr(3);
std::shared_ptr<VariableBase> variable_base2 = ptr->GetChannelPtr(4);
if(variable_base1 == nullptr || variable_base2 == nullptr){
QMessageBox::warning(this, QStringLiteral("警告"), "请先配置通道3 和 通道4");
ui->comboBox_function_2->setCurrentIndex(0);
return;
}
qDebug() << "comboBox_function_2" << ui->comboBox_function_2->currentIndex();
if(ui->comboBox_function_2->currentIndex() == kDMF && (index == kRMSSum || index == kRMSSubtraction)
&& variable_base1->general.rectifier_function != 6

View File

@ -65,9 +65,11 @@ class Seismic_monitor : public QWidget {
void on_comboBox_dual_math_function_2_currentIndexChanged(int index);
void onConfigWindowClosed(QObject *);
private:
Ui::Seismic_monitor *ui;
void UpdateData(std::shared_ptr<VibrationData> vib_data);
void UpdateData(std::shared_ptr<VibrationData> vib_data,int save = 0);
// int card_type;
// void readJsonFile(const QString &filePath);
// SeismicMonitor seismic_monitor[CHANNLE_COUNT];
@ -83,6 +85,11 @@ private:
void DisableKeyphase2();
void DisableKeyphase3();
void DisableKeyphase4();
void OpenAcc();
void OpenRadial();
void OpenVelocity();
void OpenTrust();
void OpenPressure();
QString GetUnit(int unit_num);
int SetUnit(QString unit_str);
};

View File

@ -1280,6 +1280,9 @@
<height>16777215</height>
</size>
</property>
<property name="currentText">
<string>RMS Sum</string>
</property>
<item>
<property name="text">
<string>RMS Sum</string>
@ -1310,6 +1313,11 @@
<string>X &amp; Y MAX</string>
</property>
</item>
<item>
<property name="text">
<string>No Processing</string>
</property>
</item>
</widget>
</item>
<item>
@ -2646,6 +2654,9 @@
<height>16777215</height>
</size>
</property>
<property name="currentText">
<string>RMS Sum</string>
</property>
<item>
<property name="text">
<string>RMS Sum</string>
@ -2676,6 +2687,11 @@
<string>X &amp; Y MAX</string>
</property>
</item>
<item>
<property name="text">
<string>No Processing</string>
</property>
</item>
</widget>
</item>
<item>