This commit is contained in:
DESKTOP-7I8SUIC\zhang 2025-07-17 20:10:38 +08:00
parent a1d2b53084
commit 16450402a1
7 changed files with 46 additions and 73 deletions

View File

@ -216,6 +216,7 @@ void ConfigMgr::Save(QString & file_path) {
latching.append(thrust_ptr->danger_latching_); latching.append(thrust_ptr->danger_latching_);
latching.append(thrust_ptr->timed_ok_); latching.append(thrust_ptr->timed_ok_);
variables["zero_position"] = thrust_ptr->zero_position.value; variables["zero_position"] = thrust_ptr->zero_position.value;
variables["negation"] = thrust_ptr->zero_position.negation;
variables["latching"] = latching; variables["latching"] = latching;
}else if(ptr->base_config_[cid].channel_type == kVibPressurePulsation){ }else if(ptr->base_config_[cid].channel_type == kVibPressurePulsation){
std::shared_ptr<PressurePulsationVariable> pressure_ptr = std::dynamic_pointer_cast<PressurePulsationVariable>(base_channel_ptr); std::shared_ptr<PressurePulsationVariable> pressure_ptr = std::dynamic_pointer_cast<PressurePulsationVariable>(base_channel_ptr);
@ -371,7 +372,7 @@ void ConfigMgr::Save(QString & file_path) {
}else{ }else{
for(int ch = 0;ch < RELAY_COUNT;++ch){ for(int ch = 0;ch < RELAY_COUNT;++ch){
QJsonObject channel_item; QJsonObject channel_item;
if(card_type_[i] == kCardRelaySingleNOK){ if(card_type_[i] == kCardRelaySingle){
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot); std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
if (base_ptr == nullptr) { if (base_ptr == nullptr) {
continue; continue;
@ -380,26 +381,9 @@ void ConfigMgr::Save(QString & file_path) {
if(ptr->single_relay[ch].logic_expression != ""){ if(ptr->single_relay[ch].logic_expression != ""){
qDebug() << "ch" << ch << ptr->single_relay[ch].logic_expression; qDebug() << "ch" << ch << ptr->single_relay[ch].logic_expression;
channel_item.insert("logic_expression", ptr->single_relay[ch].logic_expression); channel_item.insert("logic_expression", ptr->single_relay[ch].logic_expression);
channel_item.insert("active", ptr->single_relay[ch].active);
} }
}else if(card_type_[i] == kCardRelaySingle){
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
if (base_ptr == nullptr) {
continue;
}
std::shared_ptr<TmrrelayassociationData> ptr = std::dynamic_pointer_cast<TmrrelayassociationData>(base_ptr);
if(ptr->tmr_relay[ch].logic_expression != "")
channel_item.insert("logic_expression", ptr->tmr_relay[ch].logic_expression);
}else if(card_type_[i] == kCardRelayTMRPrimary){
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
if (base_ptr == nullptr) {
continue;
}
std::shared_ptr<TmrrelayassociationData> ptr = std::dynamic_pointer_cast<TmrrelayassociationData>(base_ptr);
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);
}
} }
if(!channel_item.isEmpty() ){ if(!channel_item.isEmpty() ){
slot_item[QString::number(ch + 1)] = channel_item; slot_item[QString::number(ch + 1)] = channel_item;
@ -596,6 +580,7 @@ void ConfigMgr::Load(QString filename) {
variable->danger_latching_ = latching["danger"].toBool(); variable->danger_latching_ = latching["danger"].toBool();
variable->timed_ok_ = latching["timed_ok"].toBool(); variable->timed_ok_ = latching["timed_ok"].toBool();
variable->zero_position.value = tmp_variable["zero_position"].toDouble(); variable->zero_position.value = tmp_variable["zero_position"].toDouble();
variable->zero_position.negation = tmp_variable["negation"].toBool();
vib_data->variables_.push_back(variable); vib_data->variables_.push_back(variable);
break; break;
} }
@ -726,7 +711,7 @@ void ConfigMgr::Load(QString filename) {
keyphase_data->variables_[j].automatic_threshold = channel["automatic_threshold"].toBool(); keyphase_data->variables_[j].automatic_threshold = channel["automatic_threshold"].toBool();
} }
cards_.push_back(keyphase_data); cards_.push_back(keyphase_data);
}else if (card_type_[i] == kCardRelaySingleNOK ){ }else if (card_type_[i] == kCardRelaySingle ){
std::shared_ptr<SingleRelayData> singlerelay_data = std::make_shared<SingleRelayData>(); std::shared_ptr<SingleRelayData> singlerelay_data = std::make_shared<SingleRelayData>();
singlerelay_data->slot_ = slot; singlerelay_data->slot_ = slot;
singlerelay_data->card_type_ = static_cast<CardType>(card_type_[i]); singlerelay_data->card_type_ = static_cast<CardType>(card_type_[i]);
@ -734,35 +719,10 @@ void ConfigMgr::Load(QString filename) {
for (int j = 0; j < RELAY_COUNT; ++j) { for (int j = 0; j < RELAY_COUNT; ++j) {
channel = temp_obj[QString::number(j + 1)].toObject(); channel = temp_obj[QString::number(j + 1)].toObject();
singlerelay_data->single_relay[j].logic_expression = channel["logic_expression"].toString(); singlerelay_data->single_relay[j].logic_expression = channel["logic_expression"].toString();
} singlerelay_data->single_relay[j].active = channel["active"].toBool();
cards_.push_back(singlerelay_data);
}else if(card_type_[i] == kCardRelaySingle){
std::shared_ptr<TmrrelayassociationData> relay_data = std::make_shared<TmrrelayassociationData>();
relay_data->slot_ = slot;
relay_data->card_type_ = static_cast<CardType>(card_type_[i]);
relay_data->version_ = temp_obj["version"].toInt();
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();
}
cards_.push_back(relay_data);
}else if(card_type_[i] == kCardRelayTMRPrimary){
std::shared_ptr<TmrrelayassociationData> relay_data = std::make_shared<TmrrelayassociationData>();
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();
} }
cards_.push_back(relay_data); cards_.push_back(singlerelay_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);
} }
} }
} }

View File

@ -197,6 +197,7 @@ typedef struct {
typedef struct { typedef struct {
float value; float value;
bool negation;
} ZeroPosition; } ZeroPosition;
typedef struct { typedef struct {
@ -319,8 +320,10 @@ typedef struct SpeedAlert_{
typedef struct SingleRelayNOK_{ typedef struct SingleRelayNOK_{
QString logic_expression; QString logic_expression;
bool active;
SingleRelayNOK_(){ SingleRelayNOK_(){
logic_expression = ""; logic_expression = "";
active = false;
} }
} SingleRelayNOK; } SingleRelayNOK;

View File

@ -192,10 +192,10 @@ void MainWindow::createMenu(const QString &rootTitle, QPushButton *parent) {
// 创建第二层子菜单:/DOM810 继电器模块 // 创建第二层子菜单:/DOM810 继电器模块
QAction *relays_1 = relays->addAction("/DOM810 单板卡"); QAction *relays_1 = relays->addAction("/DOM810 单板卡");
relays_1->setData(kCardRelaySingle); relays_1->setData(kCardRelaySingle);
QAction *relays_2 = relays->addAction("/DOM810 单板卡-非OK"); // QAction *relays_2 = relays->addAction("/DOM810 单板卡-非OK");
relays_2->setData(kCardRelaySingleNOK); // relays_2->setData(kCardRelaySingleNOK);
QAction *relays_3 = relays->addAction("/DOM810 三冗余板卡"); // QAction *relays_3 = relays->addAction("/DOM810 三冗余板卡");
relays_3->setData(kCardRelayTMRPrimary); // relays_3->setData(kCardRelayTMRPrimary);
// 将子菜单加入上一级菜单 // 将子菜单加入上一级菜单
monitors->addMenu(proximitor_menu); // 将第二层加入第一层 monitors->addMenu(proximitor_menu); // 将第二层加入第一层
monitors->addMenu(rpm_menu); // 第二层另一个子菜单 monitors->addMenu(rpm_menu); // 第二层另一个子菜单
@ -222,8 +222,8 @@ void MainWindow::createMenu(const QString &rootTitle, QPushButton *parent) {
//QObject::connect(proximitor_2, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); //QObject::connect(proximitor_2, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
QObject::connect(rpm_1, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); QObject::connect(rpm_1, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
QObject::connect(relays_1, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); QObject::connect(relays_1, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
QObject::connect(relays_2, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); //QObject::connect(relays_2, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
QObject::connect(relays_3, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); //QObject::connect(relays_3, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
QObject::connect(keyphasor_1, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); QObject::connect(keyphasor_1, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
//QObject::connect(keyphasor_2, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); //QObject::connect(keyphasor_2, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
QObject::connect(reset, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); QObject::connect(reset, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
@ -421,13 +421,7 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) {
key_phase->show(); key_phase->show();
} else if (slot_config.slot_type == "DOM810") { // 继电器模块 } else if (slot_config.slot_type == "DOM810") { // 继电器模块
switch (card_type) { switch (card_type) {
case kCardRelaySingle: case kCardRelaySingle:{
case kCardRelayTMRPrimary:{
TMRRelayAssociation *single_tmr_relay = new TMRRelayAssociation(button_id,card_type);
single_tmr_relay->setWindowModality(Qt::ApplicationModal);
single_tmr_relay->show();
}break;
case kCardRelaySingleNOK:{
SingleRelay *single_relay = new SingleRelay(button_id,card_type); SingleRelay *single_relay = new SingleRelay(button_id,card_type);
single_relay->setWindowModality(Qt::ApplicationModal); single_relay->setWindowModality(Qt::ApplicationModal);
single_relay->show(); single_relay->show();
@ -464,19 +458,12 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) {
tachometer->show(); tachometer->show();
break; break;
} }
case kCardRelaySingleNOK:{ case kCardRelaySingle:{
SingleRelay *single_relay = new SingleRelay(button_id,card_type); SingleRelay *single_relay = new SingleRelay(button_id,card_type);
single_relay->setWindowModality(Qt::ApplicationModal); single_relay->setWindowModality(Qt::ApplicationModal);
single_relay->show(); single_relay->show();
break; break;
} }
case kCardRelaySingle:
case kCardRelayTMRPrimary:{
TMRRelayAssociation *single_tmr_relay = new TMRRelayAssociation(button_id,card_type);
single_tmr_relay->setWindowModality(Qt::ApplicationModal);
single_tmr_relay->show();
break;
}
} }
} }
if (slot_btn != NULL && ui->pushButton_alarm->isChecked()) { if (slot_btn != NULL && ui->pushButton_alarm->isChecked()) {

View File

@ -103,6 +103,8 @@ void SingleRelay::Init(){
relay_data = std::dynamic_pointer_cast<SingleRelayData>(base_ptr); relay_data = std::dynamic_pointer_cast<SingleRelayData>(base_ptr);
qDebug() << "logic" <<relay_data->single_relay[current_index].logic_expression; qDebug() << "logic" <<relay_data->single_relay[current_index].logic_expression;
qDebug() << "active" <<relay_data->single_relay[current_index].active << "index" << current_index;
for(int i = 0 ; i < SLOT_NUM ; i++){ for(int i = 0 ; i < SLOT_NUM ; i++){
std::shared_ptr<CardBase> cardbase_ptr = ConfigMgr::Instance()->GetSlotPtr(i + 1); std::shared_ptr<CardBase> cardbase_ptr = ConfigMgr::Instance()->GetSlotPtr(i + 1);
if(cardbase_ptr != nullptr && if(cardbase_ptr != nullptr &&
@ -134,6 +136,7 @@ void SingleRelay::Init(){
if(!relay_data->single_relay[current_index].logic_expression.isEmpty()){ if(!relay_data->single_relay[current_index].logic_expression.isEmpty()){
setExpressionToTreeView(treeView_relay, relay_data->single_relay[current_index].logic_expression); setExpressionToTreeView(treeView_relay, relay_data->single_relay[current_index].logic_expression);
} }
ui->checkBox_active->setChecked(relay_data->single_relay[current_index].active);
} }
void SingleRelay::on_pushButton_cancel_clicked() { void SingleRelay::on_pushButton_cancel_clicked() {
this->close(); this->close();
@ -243,6 +246,7 @@ void SingleRelay::on_pushButton_confirm_clicked()
return; return;
} }
relay_data->single_relay[current_index].logic_expression = finalExpr; relay_data->single_relay[current_index].logic_expression = finalExpr;
relay_data->single_relay[current_index].active = ui->checkBox_active->isChecked();
qDebug() << "逻辑表达式:" << finalExpr; qDebug() << "逻辑表达式:" << finalExpr;
this->close(); this->close();
} }
@ -267,8 +271,10 @@ void SingleRelay::onComboBoxIndexChanged(int index){
} }
qDebug() << "finalExpr" << finalExpr; qDebug() << "finalExpr" << finalExpr;
relay_data->single_relay[current_index].logic_expression = finalExpr; relay_data->single_relay[current_index].logic_expression = finalExpr;
relay_data->single_relay[current_index].active = ui->checkBox_active->isChecked();
current_index = index; current_index = index;
qDebug() << "active" << relay_data->single_relay[index].active;
ui->checkBox_active->setChecked(relay_data->single_relay[index].active);
if(relay_data->single_relay[index].logic_expression != "") if(relay_data->single_relay[index].logic_expression != "")
setExpressionToTreeView(treeView_relay, relay_data->single_relay[index].logic_expression); setExpressionToTreeView(treeView_relay, relay_data->single_relay[index].logic_expression);
else else

View File

@ -183,7 +183,7 @@
</property> </property>
</item> </item>
</widget> </widget>
<widget class="QCheckBox" name="checkBox"> <widget class="QCheckBox" name="checkBox_active">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>26</x> <x>26</x>

View File

@ -73,6 +73,7 @@ void Trust::Init() {
ui->comboBox_recorder_output->setCurrentIndex(variable_ptr->recorder_out_.recorder_output); ui->comboBox_recorder_output->setCurrentIndex(variable_ptr->recorder_out_.recorder_output);
ui->checkBox_two_ma_clamp->setChecked(variable_ptr->recorder_out_.two_ma_clamp); ui->checkBox_two_ma_clamp->setChecked(variable_ptr->recorder_out_.two_ma_clamp);
ui->doubleSpinBox_zero_position->setValue(variable_ptr->zero_position.value); ui->doubleSpinBox_zero_position->setValue(variable_ptr->zero_position.value);
ui->checkBox_negation->setChecked(variable_ptr->zero_position.negation);
} }
void Trust::on_pushButton_confirm_clicked() void Trust::on_pushButton_confirm_clicked()
{ {
@ -114,6 +115,7 @@ void Trust::on_pushButton_confirm_clicked()
variable->alert_latching_ = ui->checkBox_alert_latching->isChecked(); variable->alert_latching_ = ui->checkBox_alert_latching->isChecked();
variable->danger_latching_ = ui->checkBox_danger_latching->isChecked(); variable->danger_latching_ = ui->checkBox_danger_latching->isChecked();
variable->zero_position.value = ui->doubleSpinBox_zero_position->value(); variable->zero_position.value = ui->doubleSpinBox_zero_position->value();
variable->zero_position.negation = ui->checkBox_negation->isChecked();
ptr->variables_.push_back(variable); ptr->variables_.push_back(variable);
this->close(); this->close();
return; return;
@ -140,6 +142,8 @@ void Trust::on_pushButton_confirm_clicked()
variable->delay_.active_100ms = ui->checkBox_100ms->isChecked(); variable->delay_.active_100ms = ui->checkBox_100ms->isChecked();
variable->alert_latching_ = ui->checkBox_alert_latching->isChecked(); variable->alert_latching_ = ui->checkBox_alert_latching->isChecked();
variable->danger_latching_ = ui->checkBox_danger_latching->isChecked(); variable->danger_latching_ = ui->checkBox_danger_latching->isChecked();
variable->zero_position.value = ui->doubleSpinBox_zero_position->value();
variable->zero_position.negation = ui->checkBox_negation->isChecked();
this->close(); this->close();
} }

View File

@ -562,7 +562,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>50</y> <y>30</y>
<width>61</width> <width>61</width>
<height>21</height> <height>21</height>
</rect> </rect>
@ -581,13 +581,26 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>80</x> <x>80</x>
<y>50</y> <y>30</y>
<width>91</width> <width>91</width>
<height>16</height> <height>16</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>-6.33 - 13.99 V</string> <string>0 - 13.99 V</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_negation">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>71</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>取反</string>
</property> </property>
</widget> </widget>
</widget> </widget>