优化逻辑
This commit is contained in:
parent
3ec608686f
commit
16bad754f0
@ -38,6 +38,7 @@ void ConfigMgr::Save(QString & file_path) {
|
||||
card_type_[i] != kCardKeyphaseSingle &&
|
||||
card_type_[i] != kCardRelaySingle &&
|
||||
card_type_[i] != kCardRelayTMRPrimary &&
|
||||
card_type_[i] != kCardRelayTMRBackup &&
|
||||
card_type_[i] != kCardRelaySingleNOK) {
|
||||
continue;
|
||||
}
|
||||
@ -300,12 +301,12 @@ void ConfigMgr::Save(QString & file_path) {
|
||||
continue;
|
||||
}
|
||||
std::shared_ptr<TmrrelayassociationData> ptr = std::dynamic_pointer_cast<TmrrelayassociationData>(base_ptr);
|
||||
if(ptr->tmr_relay[ch].logic_expression != "" && !ptr->tmr_relay[ch].sgcc_enable){
|
||||
slot_item["sgcc_enable"] = ptr->sgcc_enable;
|
||||
if(ptr->tmr_relay[ch].logic_expression != ""){
|
||||
channel_item.insert("logic_expression", ptr->tmr_relay[ch].logic_expression);
|
||||
channel_item.insert("sgcc_enable", ptr->tmr_relay[ch].sgcc_enable);
|
||||
}else if(ptr->tmr_relay[ch].logic_expression == "" && ptr->tmr_relay[ch].sgcc_enable){
|
||||
channel_item.insert("sgcc_enable", ptr->tmr_relay[ch].sgcc_enable);
|
||||
}
|
||||
}else if(card_type_[i] == kCardRelayTMRBackup){
|
||||
continue;
|
||||
}
|
||||
if(!channel_item.isEmpty())
|
||||
slot_item[QString::number(ch + 1)] = channel_item;
|
||||
@ -586,12 +587,18 @@ void ConfigMgr::Load(QString filename) {
|
||||
relay_data->slot_ = slot;
|
||||
relay_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||
relay_data->version_ = temp_obj["version"].toInt();
|
||||
relay_data->sgcc_enable = temp_obj["sgcc_enable"].toBool();
|
||||
for (int j = 0; j < RELAY_COUNT; ++j) {
|
||||
channel = temp_obj[QString::number(j + 1)].toObject();
|
||||
relay_data->tmr_relay[j].logic_expression = channel["logic_expression"].toString();
|
||||
relay_data->tmr_relay[j].sgcc_enable = channel["sgcc_enable"].toBool();
|
||||
|
||||
}
|
||||
cards_.push_back(relay_data);
|
||||
}else if(card_type_[i] == kCardRelayTMRBackup){
|
||||
std::shared_ptr<TmrrelayassociationData> relay_data = std::make_shared<TmrrelayassociationData>();
|
||||
relay_data->slot_ = slot;
|
||||
relay_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||
cards_.push_back(relay_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -608,3 +615,6 @@ std::shared_ptr<CardBase> ConfigMgr::GetSlotPtr(int slot) {
|
||||
void ConfigMgr::AddCard(std::shared_ptr<CardBase> ptr) {
|
||||
cards_.push_back(ptr);
|
||||
}
|
||||
void ConfigMgr::RemoveCard(std::shared_ptr<CardBase> ptr) {
|
||||
cards_.erase(remove(cards_.begin(), cards_.end(), ptr));
|
||||
}
|
||||
|
@ -49,8 +49,9 @@ class ConfigMgr {
|
||||
~ConfigMgr();
|
||||
void Save(QString & file_path);
|
||||
void Load(QString filename);
|
||||
std::shared_ptr<CardBase> GetSlotPtr(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);
|
||||
private:
|
||||
QString filename_;
|
||||
|
||||
|
@ -276,10 +276,8 @@ typedef struct SingleRelayNOK_{
|
||||
|
||||
typedef struct TMRRelay_{
|
||||
QString logic_expression;
|
||||
bool sgcc_enable;
|
||||
TMRRelay_(){
|
||||
logic_expression = "";
|
||||
sgcc_enable = false;
|
||||
}
|
||||
} TMRRelay;
|
||||
|
||||
|
@ -313,11 +313,11 @@ void MainWindow::onMenuActionTriggered() {
|
||||
} else if (slot_type == "OPM844") {
|
||||
chan_display = "转速";
|
||||
}
|
||||
if (rack_type == "三冗余板卡" && (map_slot_config[button_id].slot_type != "" || map_slot_config[button_id + 1].slot_type != "" \
|
||||
if (card_type == kCardRelayTMRPrimary && (map_slot_config[button_id].slot_type != "" || map_slot_config[button_id + 1].slot_type != "" \
|
||||
|| map_slot_config[button_id + 2].slot_type != "")) {
|
||||
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠三冗余板卡配置,请在创建新配置之前移除现有的配置!");
|
||||
return;
|
||||
} else if (rack_type == "三冗余板卡" && map_slot_config[button_id + 1].slot_type == "" \
|
||||
} else if (card_type == kCardRelayTMRPrimary && map_slot_config[button_id + 1].slot_type == "" \
|
||||
&& map_slot_config[button_id + 2].slot_type == "") {
|
||||
map_slot_config[button_id].slot_type = slot_type;
|
||||
map_slot_config[button_id].rack_type = "TMR1";
|
||||
@ -331,6 +331,11 @@ void MainWindow::onMenuActionTriggered() {
|
||||
map_slot_config[button_id + 2].rack_type = "TMR3";
|
||||
map_slot_config[button_id + 2].slot_btn->setText(chan_display);
|
||||
map_slot_config[button_id + 2].chan_display = chan_display;
|
||||
|
||||
ConfigMgr::Instance()->card_type_[button_id - 1] = kCardRelayTMRPrimary;
|
||||
ConfigMgr::Instance()->card_type_[button_id] = kCardRelayTMRBackup;
|
||||
ConfigMgr::Instance()->card_type_[button_id + 1] = kCardRelayTMRBackup;
|
||||
|
||||
}
|
||||
if (rack_type == "两板卡" && (map_slot_config[button_id].slot_type != "" || map_slot_config[button_id + 1].slot_type != "")) {
|
||||
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠两板卡配置,请在创建新配置之前移除现有的配置!");
|
||||
@ -348,16 +353,14 @@ void MainWindow::onMenuActionTriggered() {
|
||||
if (rack_type == "单板卡" && map_slot_config[button_id].slot_type != "") {
|
||||
QMessageBox::information(this, QStringLiteral("提示"), "不要重叠单板卡配置,请在创建新配置之前移除现有的配置!");
|
||||
return;
|
||||
} else if (rack_type == "单板卡" && map_slot_config[button_id].slot_type == "") {
|
||||
map_slot_config[button_id].slot_type = slot_type;
|
||||
map_slot_config[button_id].rack_type = "Single";
|
||||
map_slot_config[button_id].chan_display = chan_display;
|
||||
button->setText(chan_display);
|
||||
}else if (rack_type == "单板卡-非OK" && map_slot_config[button_id].slot_type == "") {
|
||||
} else if ((card_type == kCardVibSingle || card_type == kCardSpeedSingle ||
|
||||
card_type == kCardKeyphaseSingle || card_type == kCardRelaySingle ||
|
||||
kCardRelaySingleNOK) && map_slot_config[button_id].slot_type == "") {
|
||||
map_slot_config[button_id].slot_type = slot_type;
|
||||
map_slot_config[button_id].rack_type = "Single";
|
||||
map_slot_config[button_id].chan_display = chan_display;
|
||||
button->setText(chan_display);
|
||||
ConfigMgr::Instance()->card_type_[button_id - 1] = card_type;
|
||||
}
|
||||
if (action->text() == "重置模块") {
|
||||
if (ConfigMgr::Instance()->card_type_[button_id - 1] == kCardRelayTMRPrimary) {
|
||||
@ -373,6 +376,23 @@ void MainWindow::onMenuActionTriggered() {
|
||||
map_slot_config[button_id + 2].rack_type = "0";
|
||||
map_slot_config[button_id + 2].slot_btn->setText("");
|
||||
map_slot_config[button_id + 2].chan_display = "";
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||
if(base_ptr != nullptr){
|
||||
ConfigMgr::Instance()->RemoveCard(base_ptr);
|
||||
ConfigMgr::Instance()->card_type_[button_id - 1] = kCardNone;
|
||||
}
|
||||
std::shared_ptr<CardBase> base_ptr_backup = ConfigMgr::Instance()->GetSlotPtr(button_id + 1);
|
||||
if(base_ptr_backup != nullptr){
|
||||
ConfigMgr::Instance()->RemoveCard(base_ptr_backup);
|
||||
ConfigMgr::Instance()->card_type_[button_id] = kCardNone;
|
||||
}
|
||||
std::shared_ptr<CardBase> base_ptr_backup2 = ConfigMgr::Instance()->GetSlotPtr(button_id + 2);
|
||||
if(base_ptr_backup2 != nullptr){
|
||||
ConfigMgr::Instance()->RemoveCard(base_ptr_backup2);
|
||||
ConfigMgr::Instance()->card_type_[button_id + 1] = kCardNone;
|
||||
|
||||
}
|
||||
|
||||
} else if (ConfigMgr::Instance()->card_type_[button_id - 1] == kCardRelayTMRBackup) {
|
||||
map_slot_config[button_id - 1].slot_type = "";
|
||||
map_slot_config[button_id - 1].rack_type = "0";
|
||||
@ -391,11 +411,17 @@ void MainWindow::onMenuActionTriggered() {
|
||||
ConfigMgr::Instance()->card_type_[button_id - 1] == kCardKeyphaseSingle) {
|
||||
ConfigMgr::Instance()->card_type_[button_id - 1] = kCardNone;
|
||||
map_slot_config[button_id].slot_btn->setText("");
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||
if(base_ptr != nullptr)
|
||||
ConfigMgr::Instance()->RemoveCard(base_ptr);
|
||||
}else if (ConfigMgr::Instance()->card_type_[button_id - 1] == kCardRelaySingle ||
|
||||
ConfigMgr::Instance()->card_type_[button_id - 1] == kCardRelaySingleNOK ||
|
||||
ConfigMgr::Instance()->card_type_[button_id - 1] == kCardRelayTMRPrimary) {
|
||||
ConfigMgr::Instance()->card_type_[button_id - 1] = kCardNone;
|
||||
map_slot_config[button_id].slot_btn->setText("");
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||
if(base_ptr != nullptr)
|
||||
ConfigMgr::Instance()->RemoveCard(base_ptr);
|
||||
}
|
||||
} else if (action->text() == "升级固件") {
|
||||
sendUpgradePackage(button_id);
|
||||
@ -664,6 +690,7 @@ void MainWindow::on_pushButton_open_clicked() {
|
||||
}
|
||||
case kCardRelaySingle:
|
||||
case kCardRelaySingleNOK:
|
||||
case kCardRelayTMRBackup:
|
||||
case kCardRelayTMRPrimary:{
|
||||
buttonList[i + 1]->setText("继电器");
|
||||
break;
|
||||
|
@ -1145,10 +1145,11 @@
|
||||
</property>
|
||||
<addaction name="action_realy"/>
|
||||
<addaction name="action_time"/>
|
||||
<addaction name="action_eth"/>
|
||||
</widget>
|
||||
<addaction name="menu_start"/>
|
||||
<addaction name="menu_2"/>
|
||||
<addaction name="menu_tool"/>
|
||||
<addaction name="menu_2"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="action_new">
|
||||
@ -1168,7 +1169,7 @@
|
||||
</action>
|
||||
<action name="action_time">
|
||||
<property name="text">
|
||||
<string>校时功能</string>
|
||||
<string>校时</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_import">
|
||||
@ -1186,6 +1187,11 @@
|
||||
<string>断开</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_eth">
|
||||
<property name="text">
|
||||
<string>网络配置</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -64,6 +64,7 @@ void Seismic_monitor::Init() {
|
||||
if (i + 1 == 1) {
|
||||
qDebug() << vib_data->base_config_[i].channel_type ;
|
||||
ui->comboBox_chan_type_1->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||
ui->checkBox_standby_1->setChecked(vib_data->base_config_[i].standby);
|
||||
ui->comboBox_transducer_name_1->setCurrentIndex(vib_data->base_config_[i].transducer_id);
|
||||
ui->doubleSpinBox_scale_factor_1->setValue(vib_data->base_config_[i].scale_factor);
|
||||
ui->checkBox_enable_1->setChecked(vib_data->base_config_[i].active);
|
||||
@ -81,6 +82,7 @@ void Seismic_monitor::Init() {
|
||||
ui->comboBox_sample_rate_2->setCurrentIndex(vib_data->base_config_[i].sampling_rate);
|
||||
ui->checkBox_power_2->setChecked(vib_data->base_config_[i].power);
|
||||
} else if (i + 1 == 3) {
|
||||
ui->checkBox_standby_2->setChecked(vib_data->base_config_[i].standby);
|
||||
ui->comboBox_chan_type_3->setCurrentIndex(vib_data->base_config_[i].channel_type);
|
||||
ui->comboBox_transducer_name_3->setCurrentIndex(vib_data->base_config_[i].transducer_id);
|
||||
ui->doubleSpinBox_scale_factor_3->setValue(vib_data->base_config_[i].scale_factor);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "singlerelay.h"
|
||||
#include "ui_singlerelay.h"
|
||||
|
||||
#include "vibrationdata.h"
|
||||
|
||||
SingleRelay::SingleRelay(int slot,int cardtype,QWidget *parent)
|
||||
: QDialog(parent)
|
||||
@ -101,6 +101,10 @@ void SingleRelay::OnButtonGroup(QAbstractButton *slot_btn) {
|
||||
qDebug() << object_name ;
|
||||
int button_id = object_name.right(object_name.length() - 15).toInt();
|
||||
for(int var = 0; var < CHANNEL_COUNT ; ++var){
|
||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||
if((vib_data->base_config_[var].standby && vib_data->base_config_[var + 1].standby && !(var % 2)))
|
||||
continue;
|
||||
QString item_str = QString("S%1C%2P##NO (Slot %3 Channel %4 Not OK)").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')).arg(button_id).arg(var+1);
|
||||
QListWidgetItem *item = new QListWidgetItem(item_str);
|
||||
QString item_data = QString("S%1C%2P##NO").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||
|
@ -102,11 +102,22 @@ void TMRRelayAssociation::Init(){
|
||||
relay_data->card_type_ = car_type;
|
||||
relay_data->slot_ = slot_no;
|
||||
ConfigMgr::Instance()->AddCard(relay_data);
|
||||
|
||||
std::shared_ptr<TmrrelayassociationData> relay_data_backup = std::make_shared<TmrrelayassociationData>();
|
||||
relay_data_backup->card_type_ = kCardRelayTMRBackup;
|
||||
relay_data_backup->slot_ = slot_no + 1;
|
||||
ConfigMgr::Instance()->AddCard(relay_data_backup);
|
||||
|
||||
std::shared_ptr<TmrrelayassociationData> relay_data_backup2 = std::make_shared<TmrrelayassociationData>();
|
||||
relay_data_backup2->card_type_ = kCardRelayTMRBackup;
|
||||
relay_data_backup2->slot_ = slot_no + 2;
|
||||
ConfigMgr::Instance()->AddCard(relay_data_backup2);
|
||||
|
||||
return;
|
||||
}
|
||||
relay_data = std::dynamic_pointer_cast<TmrrelayassociationData>(base_ptr);
|
||||
qDebug() << "logic" <<relay_data->tmr_relay[current_index].logic_expression;
|
||||
ui->checkBox_sgcc->setChecked(relay_data->tmr_relay[current_index].sgcc_enable);
|
||||
ui->checkBox_sgcc->setChecked(relay_data->sgcc_enable);
|
||||
setExpressionToTreeView(treeView_relay, relay_data->tmr_relay[current_index].logic_expression);
|
||||
|
||||
}
|
||||
@ -405,7 +416,7 @@ void TMRRelayAssociation::on_pushButton_confirm_clicked()
|
||||
return;
|
||||
}
|
||||
relay_data->tmr_relay[current_index].logic_expression = finalExpr;
|
||||
relay_data->tmr_relay[current_index].sgcc_enable = ui->checkBox_sgcc->checkState();
|
||||
relay_data->sgcc_enable = ui->checkBox_sgcc->checkState();
|
||||
qDebug() << "逻辑表达式:" << finalExpr;
|
||||
this->close();
|
||||
}
|
||||
@ -430,14 +441,12 @@ void TMRRelayAssociation::onComboBoxIndexChanged(int index){
|
||||
return;
|
||||
}
|
||||
relay_data->tmr_relay[current_index].logic_expression = finalExpr;
|
||||
relay_data->tmr_relay[current_index].sgcc_enable = ui->checkBox_sgcc->checkState();
|
||||
current_index = index;
|
||||
|
||||
if(relay_data->tmr_relay[index].logic_expression != "")
|
||||
setExpressionToTreeView(treeView_relay, relay_data->tmr_relay[index].logic_expression);
|
||||
else
|
||||
model_Relay->clear();
|
||||
ui->checkBox_sgcc->setChecked(relay_data->tmr_relay[index].sgcc_enable);
|
||||
}
|
||||
|
||||
void TMRRelayAssociation::on_pushButton_and_clicked()
|
||||
@ -477,9 +486,15 @@ void TMRRelayAssociation::on_checkBox_sgcc_stateChanged(int arg1)
|
||||
if(ui->checkBox_sgcc->checkState()){
|
||||
treeView_relay->setEnabled(false);
|
||||
list_widget_available->setEnabled(false);
|
||||
ui->comboBox_relay_ch->setEnabled(false);
|
||||
ui->pushButton_logic->setEnabled(false);
|
||||
ui->textEdit_logic->setEnabled(false);
|
||||
}else{
|
||||
treeView_relay->setEnabled(true);
|
||||
list_widget_available->setEnabled(true);
|
||||
ui->comboBox_relay_ch->setEnabled(true);
|
||||
ui->pushButton_logic->setEnabled(true);
|
||||
ui->textEdit_logic->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user