优化继电器相关界面

This commit is contained in:
DESKTOP-7I8SUIC\zhang 2025-11-26 10:13:23 +08:00
parent a264bffb15
commit 110685ef56
8 changed files with 382 additions and 321 deletions

View File

@ -591,12 +591,37 @@ void ConfigMgr::Save(QString & file_path) {
if(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("vote",ptr->single_relay[ch].vote);
channel_item.insert("active", ptr->single_relay[ch].active);
channel_item.insert("group",ptr->single_relay[ch].group);
}
}
}else if(card_type_[i] == kCardRelaySingleNOK){
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
if (base_ptr == nullptr) {
continue;
}
std::shared_ptr<SingleRelayData> ptr = std::dynamic_pointer_cast<SingleRelayData>(base_ptr);
if(ptr->single_relay[ch].vote){
channel_item.insert("count_vote",ptr->single_relay[ch].count_vote);
QJsonArray array_logic;
for(int var = 0 ; var < 10;++var){
if(ptr->single_relay[ch].logic[var] != ""){
array_logic.append(ptr->single_relay[ch].logic[var]);
}
}
channel_item.insert("logic_vote", array_logic);
}else{
if(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("vote",ptr->single_relay[ch].vote);
channel_item.insert("active", ptr->single_relay[ch].active);
channel_item.insert("group",ptr->single_relay[ch].group);
}
}
}else if(card_type_[i] == kCardRelayTMRPrimary){
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
if (base_ptr == nullptr) {
@ -1126,6 +1151,27 @@ void ConfigMgr::Load(QString filename) {
singlerelay_data->single_relay[j].group = channel["group"].toInt();
}
cards_.push_back(singlerelay_data);
}else if(card_type_[i] == kCardRelaySingleNOK){
std::shared_ptr<SingleRelayData> singlerelay_data = std::make_shared<SingleRelayData>();
singlerelay_data->slot_ = slot;
singlerelay_data->card_type_ = static_cast<CardType>(card_type_[i]);
singlerelay_data->version_ = temp_obj["version"].toInt();
for (int j = 0; j < RELAY_COUNT; ++j) {
channel = temp_obj[QString::number(j + 1)].toObject();
if(channel["vote"].toBool()){
singlerelay_data->single_relay[j].count_vote = channel["count_vote"].toInt();
singlerelay_data->single_relay[j].vote = channel["vote"].toBool();
QJsonArray array_logic = channel["logic_vote"].toArray();
for(int var = 0;var < array_logic.size();++var){
singlerelay_data->single_relay[j].logic[var] = array_logic[var].toString();
}
}else{
singlerelay_data->single_relay[j].logic_expression = channel["logic_expression"].toString();
}
singlerelay_data->single_relay[j].active = channel["active"].toBool();
singlerelay_data->single_relay[j].group = channel["group"].toInt();
}
cards_.push_back(singlerelay_data);
}else if(card_type_[i] == kCardRelayTMRPrimary){
std::shared_ptr<TmrrelayassociationData> relay_data = std::make_shared<TmrrelayassociationData>();
relay_data->slot_ = slot;

View File

@ -106,102 +106,6 @@
</attribute>
</widget>
</widget>
<widget class="QLineEdit" name="lineEdit_minmum">
<property name="geometry">
<rect>
<x>50</x>
<y>260</y>
<width>113</width>
<height>25</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_maxmum">
<property name="geometry">
<rect>
<x>50</x>
<y>300</y>
<width>113</width>
<height>25</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
<widget class="QLabel" name="label_min_unit">
<property name="geometry">
<rect>
<x>190</x>
<y>270</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>- -</string>
</property>
</widget>
<widget class="QLabel" name="label_max_unit">
<property name="geometry">
<rect>
<x>190</x>
<y>310</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>- -</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>280</x>
<y>270</y>
<width>54</width>
<height>25</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>最小值</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>280</x>
<y>310</y>
<width>54</width>
<height>25</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>最大值</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_confirm">
<property name="geometry">
<rect>
@ -228,6 +132,90 @@
<string>取消</string>
</property>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>50</x>
<y>260</y>
<width>250</width>
<height>27</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEdit_minmum">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_min_unit">
<property name="text">
<string>- -</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>最小值</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>50</x>
<y>300</y>
<width>250</width>
<height>27</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="lineEdit_maxmum">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_max_unit">
<property name="text">
<string>- -</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>最大值</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>

View File

@ -114,6 +114,9 @@ MainWindow::MainWindow(QWidget *parent)
#ifndef QT_DEBUG
//qInstallMessageHandler(messageHandler);
#endif
QDate buildDate = QLocale( QLocale::English ).toDate( QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
QString Version = "V1.0_" + buildDate.toString("yyyyMMdd");
ui->label_version->setText(Version);
}
MainWindow::~MainWindow() {
@ -497,6 +500,11 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) {
single_tmr_relay->setWindowModality(Qt::ApplicationModal);
single_tmr_relay->show();
}break;
case kCardRelaySingleNOK:{
SingleRelay_NOK *single_relay_nok = new SingleRelay_NOK(button_id,card_type);
single_relay_nok->setWindowModality(Qt::ApplicationModal);
single_relay_nok->show();
}break;
}
}
if (slot_btn != NULL && ui->pushButton_alarm->isChecked()) {

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1129</width>
<height>529</height>
<height>537</height>
</rect>
</property>
<property name="windowTitle">
@ -15,21 +15,6 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widget_body" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
@ -1050,6 +1035,22 @@
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_bot" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_version">
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -137,10 +137,10 @@ void SingleRelay::Init(){
if(var == 3){
qDebug() << "alert" << variable_base->danger_high.enable<<variable_base->danger_high.enable;
}
channelNameMap[item_data] = item_str;
item_str = QString("%1 (槽位 %2 通道 %3 非OK)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2));
item_data = QString("%1P##NO").arg(ptr->base_config_[var].chan_id);
channelNameMap[item_data] = item_str;
// channelNameMap[item_data] = item_str;
// item_str = QString("%1 (槽位 %2 通道 %3 非OK)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2));
// item_data = QString("%1P##NO").arg(ptr->base_config_[var].chan_id);
// channelNameMap[item_data] = item_str;
}
}else if(cardbase_ptr != nullptr &&
cardbase_ptr->card_type_ == kCardSpeedSingle){
@ -210,11 +210,11 @@ void SingleRelay::OnButtonGroup(QAbstractButton *slot_btn) {
item->setData(Qt::UserRole, item_data);
list_widget_available->addItem(item);
}
QString item_str = QString("%1 (槽位 %2 通道 %3 非OK)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
QListWidgetItem *item = new QListWidgetItem(item_str);
QString item_data_nok = QString("S%1C%2P##NO").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
item->setData(Qt::UserRole, item_data_nok);
list_widget_available->addItem(item);
// QString item_str = QString("%1 (槽位 %2 通道 %3 非OK)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
// QListWidgetItem *item = new QListWidgetItem(item_str);
// QString item_data_nok = QString("S%1C%2P##NO").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
// item->setData(Qt::UserRole, item_data_nok);
// list_widget_available->addItem(item);
}
}
}

View File

@ -1003,7 +1003,7 @@
<rect>
<x>640</x>
<y>30</y>
<width>71</width>
<width>91</width>
<height>16</height>
</rect>
</property>
@ -1014,15 +1014,74 @@
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>630</x>
<y>70</y>
<width>100</width>
<height>32</height>
<x>632</x>
<y>110</y>
<width>141</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_97">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string> 选择:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_vote_count">
<property name="minimumSize">
<size>
<width>50</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>632</x>
<y>72</y>
<width>141</width>
<height>32</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_96">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string> 逻辑:</string>
</property>
@ -1041,7 +1100,7 @@
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<width>50</width>
<height>30</height>
</size>
</property>
@ -1099,41 +1158,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>631</x>
<y>131</y>
<width>100</width>
<height>27</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_97">
<property name="text">
<string> 选择:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_vote_count">
<property name="minimumSize">
<size>
<width>50</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>25</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>

View File

@ -210,36 +210,6 @@ void SingleRelay_NOK::OnButtonGroup(QAbstractButton *slot_btn) {
if(variable_base == nullptr)
continue;
if(base_ptr->card_type_ == kCardVibSingle){
QString item_data;
if(variable_base->alert_high.enable){
QString item_str = QString("%1 (槽位 %3 通道 %4 警报高)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
QListWidgetItem *item = new QListWidgetItem(item_str);
item_data = QString("S%1C%2A2").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
item->setData(Qt::UserRole, item_data);
list_widget_available->addItem(item);
}
if(variable_base->danger_high.enable){
QString item_str = QString("%1 (槽位 %3 通道 %4 危险高)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
QListWidgetItem *item = new QListWidgetItem(item_str);
item_data = QString("S%1C%2A1").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
item->setData(Qt::UserRole, item_data);
list_widget_available->addItem(item);
}
if(variable_base->danger_low.enable){
QString item_str = QString("%1 (槽位 %3 通道 %4 危险低)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
QListWidgetItem *item = new QListWidgetItem(item_str);
item_data = QString("S%1C%2A4").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
item->setData(Qt::UserRole, item_data);
list_widget_available->addItem(item);
}
if(variable_base->alert_low.enable){
QString item_str = QString("%1 (槽位 %3 通道 %4 警报低)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
QListWidgetItem *item = new QListWidgetItem(item_str);
item_data = QString("S%1C%2A3").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
item->setData(Qt::UserRole, item_data);
list_widget_available->addItem(item);
}
QString item_str = QString("%1 (槽位 %2 通道 %3 非OK)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
QListWidgetItem *item = new QListWidgetItem(item_str);
QString item_data_nok = QString("S%1C%2P##NO").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));

View File

@ -6,101 +6,13 @@
<rect>
<x>0</x>
<y>0</y>
<width>903</width>
<width>975</width>
<height>606</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<string>非OK继电器</string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>630</x>
<y>70</y>
<width>111</width>
<height>32</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_96">
<property name="text">
<string> 逻辑:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_vote_group">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>3</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>5</string>
</property>
</item>
<item>
<property name="text">
<string>6</string>
</property>
</item>
<item>
<property name="text">
<string>7</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
<item>
<property name="text">
<string>9</string>
</property>
</item>
<item>
<property name="text">
<string>10</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
@ -826,41 +738,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget_3">
<property name="geometry">
<rect>
<x>631</x>
<y>131</y>
<width>111</width>
<height>27</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_97">
<property name="text">
<string> 选择:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_vote_count">
<property name="minimumSize">
<size>
<width>50</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>25</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
@ -1134,6 +1011,153 @@
<string>可用的告警:</string>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>630</x>
<y>108</y>
<width>141</width>
<height>32</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_97">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string> 选择:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_vote_count">
<property name="minimumSize">
<size>
<width>50</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget_3">
<property name="geometry">
<rect>
<x>630</x>
<y>70</y>
<width>141</width>
<height>32</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_96">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string> 逻辑:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_vote_group">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>30</height>
</size>
</property>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>3</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>5</string>
</property>
</item>
<item>
<property name="text">
<string>6</string>
</property>
</item>
<item>
<property name="text">
<string>7</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
<item>
<property name="text">
<string>9</string>
</property>
</item>
<item>
<property name="text">
<string>10</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>