From 49083ca06d01c1c040b6f763dd074c836fc757a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D1=8F=D1=87=D0=B5=D1=81=D0=BB=D0=B0=D0=B2=20=D0=A8?= =?UTF-8?q?=D1=82=D0=B5=D0=B9=D0=B1=D0=B5=D0=B7=D0=B0=D0=BD=D0=B4=D1=82?= Date: Wed, 11 Dec 2024 16:55:48 +0300 Subject: [PATCH] Hot Fix 2. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit >Некорректная индикация напряжения ТЭ была устранена. >Исправлена ошибка с некорректным определением модели регистров. >Исправлено некорректное визуальное отображение статуса работы МЗКТЕ Примечание: Необходимо отвязать индикацию ТЭ от панели управления, передав уставки и коилы на внутренние таблицы --- M3KTE_TERM/m3kte.cpp | 139 +++++++++++++++++------------- M3KTE_TERM/m3kte.ui | 12 +++ M3KTE_TERM/settingsdialog.cpp | 2 +- M3KTE_TERM/settingsdialog.h | 2 +- M3KTE_TERM/settingsdialog.ui | 5 +- M3KTE_TERM/writeregistermodel.cpp | 12 ++- M3KTE_TERM/writeregistermodel.h | 2 + 7 files changed, 112 insertions(+), 62 deletions(-) diff --git a/M3KTE_TERM/m3kte.cpp b/M3KTE_TERM/m3kte.cpp index 7a86540..bd49339 100644 --- a/M3KTE_TERM/m3kte.cpp +++ b/M3KTE_TERM/m3kte.cpp @@ -480,7 +480,14 @@ M3KTE::M3KTE(QWidget *parent) ui->BST_Off->setChecked(true); - changeTable(ui->boardSelectBox->currentIndex(), ui->writeTable->currentIndex()); + ui->boardSelectBox->setCurrentIndex(0); + ui->writeTable->setCurrentIndex(0); + changeTable(0, 0); + + for (int i = 0; i < 4; i++) { + statusM3KTE.Warnings[i] = false; + statusM3KTE.Accidents[i] = false; + } for(int i = 0; i<320; i++) { @@ -488,7 +495,7 @@ M3KTE::M3KTE(QWidget *parent) QString style_fc_off = "QProgressBar {border: 2px solid black; font: bold 10px} QProgressBar::chunk {background: hsva(" + QString::number(30) + ", 30, 30, 30%);} "; m[i]->setStyleSheet(style_fc_off); } - //debug(); + debug(); //Вызов окна настройки подключения @@ -511,36 +518,36 @@ void M3KTE::debug() m[i]->setMaximumSize(25, 25); m[i]->resize(25, 25); m[i]->setAlignment(Qt::AlignCenter); - m[i]->setFormat(QString("%1").arg((i%85))); - int j = rand()%4; - if(j!=3) j=rand()%4; - m[i]->setValue(j); - QString style_fc = "QProgressBar {border: 2px solid black; font: bold 10px} QProgressBar::chunk {background: hsva(" + QString::number(j*50-50) + ", 255, 255, 100%);} "; - QString style_fc_off = "QProgressBar {border: 2px solid black; font: bold 10px} QProgressBar::chunk {background: hsva(" + QString::number(30) + ", 30, 30, 30%);} "; - m[i]->setStyleSheet(style_fc); + m[i]->setFormat(QString("%1").arg((i%85+1))); +// int j = rand()%4; +// if(j!=3) j=rand()%4; +// m[i]->setValue(j); +// QString style_fc = "QProgressBar {border: 2px solid black; font: bold 10px} QProgressBar::chunk {background: hsva(" + QString::number(j*50-50) + ", 255, 255, 100%);} "; +// QString style_fc_off = "QProgressBar {border: 2px solid black; font: bold 10px} QProgressBar::chunk {background: hsva(" + QString::number(30) + ", 30, 30, 30%);} "; +// m[i]->setStyleSheet(style_fc); - switch (j) { - case 1: - { - m[i]->setStatusTip(QString("П%1 ТЭ%2: Аварийный уровень напряжения.").arg(QString::number(i/85+1), QString::number(i%85))); - break; - } - case 2: - { - m[i]->setStatusTip(QString("П%1 ТЭ%2: Предупредительный уровень напряжения.").arg(QString::number(i/85+1), QString::number(i%85))); - break; - } - case 3: - { - m[i]->setStatusTip(QString("П%1 ТЭ%2: Уровень напряжения в норме.").arg(QString::number(i/85+1), QString::number(i%85))); - break; - } - case 0: - m[i]->setStatusTip(QString("П%1 ТЭ%2: Топливный Элемент не учитывается.").arg(QString::number(i/85+1), QString::number(i%85))); - m[i]->setStyleSheet(style_fc_off); - m[i]->setValue(3); - break; - } +// switch (j) { +// case 1: +// { +// m[i]->setStatusTip(QString("П%1 ТЭ%2: Аварийный уровень напряжения.").arg(QString::number(i/85+1), QString::number(i%85))); +// break; +// } +// case 2: +// { +// m[i]->setStatusTip(QString("П%1 ТЭ%2: Предупредительный уровень напряжения.").arg(QString::number(i/85+1), QString::number(i%85))); +// break; +// } +// case 3: +// { +// m[i]->setStatusTip(QString("П%1 ТЭ%2: Уровень напряжения в норме.").arg(QString::number(i/85+1), QString::number(i%85))); +// break; +// } +// case 0: +// m[i]->setStatusTip(QString("П%1 ТЭ%2: Топливный Элемент не учитывается.").arg(QString::number(i/85+1), QString::number(i%85))); +// m[i]->setStyleSheet(style_fc_off); +// m[i]->setValue(3); +// break; +// } } } @@ -562,7 +569,7 @@ void M3KTE::initActions() connect(ui->boardSelectBox, QOverload::of(&QComboBox::currentIndexChanged), this, &M3KTE::onSelectedBoardChanged); connect(ui->writeTable, QOverload::of(&QComboBox::currentIndexChanged), - this, &M3KTE::onSelectedBoardChanged); + this, &M3KTE::onWriteTableChanged); connect(ui->ConnectionMenuSettings, &QAction::triggered, m_settingsDialog, &QDialog::show); connect(ui->M3kteMenuSettings, &QAction::triggered, m_deviceSettingsDialog, &QDialog::show); @@ -595,14 +602,6 @@ void M3KTE::onConnectClicked() ui->ConnectionMenuConnect->setEnabled(false); ui->ConnectionMenuDisconnect->setEnabled(true); - ui->BST_Off->setChecked(false); - ui->BST_On->setChecked(true); - - ui->BSM_Warning->setEnabled(true); - ui->BSM_Accident->setEnabled(true); - ui->BSM_WorkInProgress->setEnabled(true); - ui->BSM_WorkInProgress->setChecked(true); - if(pingNetworkDevices()) { unsigned tmp_adr[4]; @@ -611,6 +610,18 @@ void M3KTE::onConnectClicked() } m_deviceSettingsDialog->updateSettingsAfterConnection(m_settingsDialog->settings().baud, m_settingsDialog->settings().parity, tmp_adr); + + ui->boardSelectBox->setCurrentIndex(0); + ui->writeTable->setCurrentIndex(0); + changeTable(0, 0); + + ui->BST_Off->setChecked(false); + ui->BST_On->setChecked(true); + + ui->BSM_Warning->setEnabled(true); + ui->BSM_Accident->setEnabled(true); + ui->BSM_WorkInProgress->setEnabled(true); + ui->BSM_WorkInProgress->setChecked(true); } //Опрос устройств } @@ -624,6 +635,7 @@ void M3KTE::onConnectClicked() ui->BSM_Warning->setChecked(false); ui->BSM_Accident->setChecked(false); ui->BSM_WorkInProgress->setChecked(false); + ui->BSM_Warning->setEnabled(false); ui->BSM_Accident->setEnabled(false); ui->BSM_WorkInProgress->setEnabled(false); @@ -951,7 +963,7 @@ bool M3KTE::pingNetworkDevices() bar->setValue(i); - for(i=0; i<4;) + for(i=0; i<1;) { bar->setValue(i); timerForPingSignal = false; @@ -981,6 +993,7 @@ bool M3KTE::pingNetworkDevices() //ERROR //OUT OF RANGE QMessageBox::warning(this, "Ошибка при сканировании сети.", QString("Выход за пределы допустимых адресов. Найдено %1 плат.").arg(i)); + bar->setValue(4); bar->deleteLater(); onConnectClicked(); return false; @@ -994,7 +1007,7 @@ bool M3KTE::pingNetworkDevices() _unit_settings[1] = new QModbusDataUnit(QModbusDataUnit::HoldingRegisters, 0, 85); _unit_settings[2] = new QModbusDataUnit(QModbusDataUnit::HoldingRegisters, 85, 85); - for(i=0; i<4; i++) + for(i=0; i<1; i++) { for (int j = 0; j<3; j++) { @@ -1022,6 +1035,7 @@ bool M3KTE::pingNetworkDevices() else { QMessageBox::warning(this, "Ошибка при получении текущих настроек.", QString("Таймаут при опросе устройства %1 по адресу %2").arg(i).arg(Boards[i].adr)); + bar->setValue(12); onConnectClicked(); return false; } @@ -1042,9 +1056,9 @@ void M3KTE::timeForPingIsGone() void M3KTE::beginScanBoards() { firstBoardScan(); - secondBoardScan(); - thirdBoardScan(); - fourthBoardScan(); + //secondBoardScan(); + //thirdBoardScan(); + //fourthBoardScan(); return; } @@ -1177,25 +1191,30 @@ void M3KTE::displayResultOfScan(QModbusReply *reply, int boardID) for(int i = unit.startAddress(), total = int(unit.valueCount()); i < total; ++i) { - if(Boards[boardID].ModbusModelCoil->data(Boards[boardID].ModbusModelCoil->index(i, 2)).Int) + //QErrorMessage::showMessage() + //if(Boards[boardID].ModbusModelCoil->data(Boards[boardID].ModbusModelCoil->index(i, 2), Qt::CheckStateRole).Bool != 0) + if(Boards[boardID].ModbusModelCoil->get_coil(Boards[boardID].ModbusModelCoil->index(i, 2))==true) { int j = 0; - if(Boards[boardID].ModbusModelHoldingReg->data(Boards[boardID].ModbusModelHoldingReg->index(85+i, 3)).Int > unit.value(i)) + if(Boards[boardID].ModbusModelHoldingReg->get_holreg(Boards[boardID].ModbusModelHoldingReg->index(85+i, 3)) > unit.value(i)) { j = 1; m[i+boardID*85]->setStatusTip(QString("П%1 ТЭ%2: Аварийный уровень напряжения.").arg(QString::number(boardID+1), QString::number(i%85))); + m[i+boardID*85]->setWhatsThis(QString("П%1 ТЭ%2: Аварийный уровень напряжения.").arg(QString::number(boardID+1), QString::number(i%85))); A_Flag = true; } - else if(Boards[boardID].ModbusModelHoldingReg->data(Boards[boardID].ModbusModelHoldingReg->index(i, 3)).Int > unit.value(i)) + else if(Boards[boardID].ModbusModelHoldingReg->get_holreg(Boards[boardID].ModbusModelHoldingReg->index(i, 3)) > unit.value(i)) { j = 2; m[i+boardID*85]->setStatusTip(QString("П%1 ТЭ%2: Предупредительный уровень напряжения.").arg(QString::number(boardID+1), QString::number(i%85))); + m[i+boardID*85]->setWhatsThis(QString("П%1 ТЭ%2: Предупредительный уровень напряжения.").arg(QString::number(boardID+1), QString::number(i%85))); W_Flag = true; } else { j = 3; m[i+boardID*85]->setStatusTip(QString("П%1 ТЭ%2: Уровень напряжения в норме.").arg(QString::number(boardID+1), QString::number(i%85))); + m[i+boardID*85]->setWhatsThis(QString("П%1 ТЭ%2: Уровень напряжения в норме.").arg(QString::number(boardID+1), QString::number(i%85))); } m[i+boardID*85]->setValue(j); QString style_fc = "QProgressBar {border: 2px solid black; font: bold 10px} QProgressBar::chunk {background: hsva(" + QString::number(j*50-50) + ", 255, 255, 100%);} "; @@ -1204,33 +1223,37 @@ void M3KTE::displayResultOfScan(QModbusReply *reply, int boardID) else { m[i+boardID*85]->setStatusTip(QString("П%1 ТЭ%2: Топливный Элемент не учитывается.").arg(QString::number(boardID+1), QString::number(i%85))); + m[i+boardID*85]->setWhatsThis(QString("П%1 ТЭ%2: Топливный Элемент не учитывается.").arg(QString::number(boardID+1), QString::number(i%85))); QString style_fc_off = "QProgressBar {border: 2px solid black; font: bold 10px} QProgressBar::chunk {background: hsva(" + QString::number(30) + ", 30, 30, 30%);} "; m[i+boardID*85]->setStyleSheet(style_fc_off); } } if(A_Flag) statusM3KTE.Accidents[boardID] = true; + else + statusM3KTE.Accidents[boardID] = false; if(W_Flag) statusM3KTE.Warnings[boardID] = true; + else + statusM3KTE.Warnings[boardID] = false; - - ui->BSM_Warning->setEnabled(false); - ui->BSM_Accident->setEnabled(false); - ui->BSM_WorkInProgress->setEnabled(true); + ui->BSM_Warning->setChecked(false); + ui->BSM_Accident->setChecked(false); + ui->BSM_WorkInProgress->setChecked(true); for(int i = 0; i < 4; i++) { if(statusM3KTE.Accidents[i]) { - ui->BSM_WorkInProgress->setEnabled(false); - ui->BSM_Warning->setEnabled(false); - ui->BSM_Accident->setEnabled(true); + ui->BSM_WorkInProgress->setChecked(false); + ui->BSM_Warning->setChecked(false); + ui->BSM_Accident->setChecked(true); break; } if(statusM3KTE.Warnings[i]) { - ui->BSM_WorkInProgress->setEnabled(false); - ui->BSM_Accident->setEnabled(false); - ui->BSM_Warning->setEnabled(true); + ui->BSM_WorkInProgress->setChecked(false); + ui->BSM_Accident->setChecked(false); + ui->BSM_Warning->setChecked(true); } } } else if (reply->error() == QModbusDevice::ProtocolError) { diff --git a/M3KTE_TERM/m3kte.ui b/M3KTE_TERM/m3kte.ui index f7fed7e..2a435a7 100644 --- a/M3KTE_TERM/m3kte.ui +++ b/M3KTE_TERM/m3kte.ui @@ -14204,6 +14204,9 @@ Отключено + + true + @@ -14211,6 +14214,9 @@ Подключено + + true + @@ -14239,6 +14245,9 @@ Работа + + true + @@ -14246,6 +14255,9 @@ Предупреждение + + true + diff --git a/M3KTE_TERM/settingsdialog.cpp b/M3KTE_TERM/settingsdialog.cpp index 48e4a1f..7911af6 100644 --- a/M3KTE_TERM/settingsdialog.cpp +++ b/M3KTE_TERM/settingsdialog.cpp @@ -7,7 +7,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) : { ui->setupUi(this); - ui->parityCombo->setCurrentIndex(1); + ui->parityCombo->setCurrentIndex(0); #if QT_CONFIG(modbus_serialport) ui->baudCombo->setCurrentText(QString::number(m_settings.baud)); ui->dataBitsCombo->setCurrentText(QString::number(m_settings.dataBits)); diff --git a/M3KTE_TERM/settingsdialog.h b/M3KTE_TERM/settingsdialog.h index 6b576ca..5ab4834 100644 --- a/M3KTE_TERM/settingsdialog.h +++ b/M3KTE_TERM/settingsdialog.h @@ -20,7 +20,7 @@ public: struct Settings { QString portName; int parity = QSerialPort::NoParity; - int baud = 31250; + int baud = 115200; int dataBits = QSerialPort::Data8; int stopBits = QSerialPort::OneStop; int responseTime = 1000; diff --git a/M3KTE_TERM/settingsdialog.ui b/M3KTE_TERM/settingsdialog.ui index e4d2e1a..736499a 100644 --- a/M3KTE_TERM/settingsdialog.ui +++ b/M3KTE_TERM/settingsdialog.ui @@ -112,7 +112,7 @@ - 5 + 8 @@ -170,6 +170,9 @@ + + 3 + 5 diff --git a/M3KTE_TERM/writeregistermodel.cpp b/M3KTE_TERM/writeregistermodel.cpp index eabcde7..207710a 100644 --- a/M3KTE_TERM/writeregistermodel.cpp +++ b/M3KTE_TERM/writeregistermodel.cpp @@ -33,7 +33,7 @@ QVariant WriteRegisterModel::data(const QModelIndex &index, int role) const return QString::number(index.row()); if (index.column() == NameColumn && role == Qt::DisplayRole) - return QString("ТЭ%1").arg(index.row()%(RowCount/(1+isHR))); + return QString("ТЭ%1").arg(index.row()%(RowCount/(1+isHR))+1); if (index.column() == CoilsColumn && role == Qt::CheckStateRole) // coils return m_coils.at(index.row()) ? Qt::Checked : Qt::Unchecked; @@ -123,3 +123,13 @@ void WriteRegisterModel::setNumberOfValues(const QString &number) m_number = number.toInt(); //emit updateViewport(); } + +bool WriteRegisterModel::get_coil(const QModelIndex &index) +{ + return m_coils.at(index.row()); +} + +uint WriteRegisterModel::get_holreg(const QModelIndex &index) +{ + return m_holdingRegisters.at(index.row()); +} diff --git a/M3KTE_TERM/writeregistermodel.h b/M3KTE_TERM/writeregistermodel.h index 9637aa2..e666155 100644 --- a/M3KTE_TERM/writeregistermodel.h +++ b/M3KTE_TERM/writeregistermodel.h @@ -12,6 +12,8 @@ private: int RowCount; public: WriteRegisterModel(QObject *parent = nullptr, int _tmpRC = 85, bool _isHR = false); + bool get_coil(const QModelIndex &index); + uint get_holreg(const QModelIndex &index); int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override;