From c2a32e3ff5051a268bb5889edc4a7a7166b1ac47 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: Thu, 16 Oct 2025 08:37:34 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BE=D1=82=D1=81=D0=BB=D0=B5=D0=B6=D0=B8=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D0=BF=D0=BB=D0=B0=D1=82=D0=B0=D1=85=20=D0=B2?= =?UTF-8?q?=20=D1=80=D0=B5=D0=B6=D0=B8=D0=BC=D0=B5=20=D0=BE=D1=82=D0=BB?= =?UTF-8?q?=D0=B0=D0=B4=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- M3KTE_TERM/debugTerminalDialog.ui | 2 +- M3KTE_TERM/debugterminaldialog.cpp | 242 +++++++++++++++++------------ M3KTE_TERM/debugterminaldialog.h | 32 +++- M3KTE_TERM/m3kte.cpp | 14 ++ M3KTE_TERM/m3kte.h | 5 +- 5 files changed, 185 insertions(+), 110 deletions(-) diff --git a/M3KTE_TERM/debugTerminalDialog.ui b/M3KTE_TERM/debugTerminalDialog.ui index d04af36..62ddb03 100644 --- a/M3KTE_TERM/debugTerminalDialog.ui +++ b/M3KTE_TERM/debugTerminalDialog.ui @@ -7,7 +7,7 @@ 0 0 1188 - 675 + 578 diff --git a/M3KTE_TERM/debugterminaldialog.cpp b/M3KTE_TERM/debugterminaldialog.cpp index ead6d76..15fc3da 100644 --- a/M3KTE_TERM/debugterminaldialog.cpp +++ b/M3KTE_TERM/debugterminaldialog.cpp @@ -13,6 +13,25 @@ DebugTerminalDialog::DebugTerminalDialog(QWidget *parent) : m_modbusDevice(nullptr) { ui->setupUi(this); + boards[0].error24V = ui->discErr24TestChkBox_1; + boards[0].error5V = ui->discErr5TestChkBox_1; + boards[0].error5VSCI = ui->discErr5VsciTestChkBox_1; + boards[0].error5VA = ui->discErr5VATestChkBox_1; + + boards[1].error24V = ui->discErr24TestChkBox_2; + boards[1].error5V = ui->discErr5TestChkBox_2; + boards[1].error5VSCI = ui->discErr5VsciTestChkBox_2; + boards[1].error5VA = ui->discErr5VATestChkBox_2; + + boards[2].error24V = ui->discErr24TestChkBox_3; + boards[2].error5V = ui->discErr5TestChkBox_3; + boards[2].error5VSCI = ui->discErr5VsciTestChkBox_3; + boards[2].error5VA = ui->discErr5VATestChkBox_3; + + boards[3].error24V = ui->discErr24TestChkBox_4; + boards[3].error5V = ui->discErr5TestChkBox_4; + boards[3].error5VSCI = ui->discErr5VsciTestChkBox_4; + boards[3].error5VA = ui->discErr5VATestChkBox_4; initializeConnections(); // Создаем AdcGraphDialog с nullptr @@ -23,6 +42,10 @@ DebugTerminalDialog::~DebugTerminalDialog() { delete ui; } +void DebugTerminalDialog::setMainTerm(M3KTE* term) +{ + mainTerm = term; +} void DebugTerminalDialog::setModbusDevice(QModbusClient *device) { @@ -59,78 +82,75 @@ void DebugTerminalDialog::closeEvent(QCloseEvent *event) void DebugTerminalDialog::initializeConnections() { - // Подключаем кнопки OK и RestoreDefaults - connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &DebugTerminalDialog::on_buttonBox_clicked); +// // Подключаем кнопки OK и RestoreDefaults +// connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &DebugTerminalDialog::on_buttonBox_clicked); - // Подключаем все чекбоксы для платы 1 - connect(ui->continiusCallChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_continiusCallChkBox_1_stateChanged); - connect(ui->calibrateCallChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_calibrateCallChkBox_1_stateChanged); - connect(ui->pollTECallChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_pollTECallChkBox_1_stateChanged); - connect(ui->resetKeyCallChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_resetKeyCallChkBox_1_stateChanged); - connect(ui->resetDefaultCallChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_resetDefaultCallChkBox_1_stateChanged); - connect(ui->getHardfaultCallChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_getHardfaultCallChkBox_1_stateChanged); +// // Подключаем все чекбоксы для платы 1 +// connect(ui->continiusCallChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_continiusCallChkBox_1_stateChanged); +// connect(ui->calibrateCallChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_calibrateCallChkBox_1_stateChanged); +// connect(ui->pollTECallChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_pollTECallChkBox_1_stateChanged); +// connect(ui->resetKeyCallChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_resetKeyCallChkBox_1_stateChanged); +// connect(ui->resetDefaultCallChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_resetDefaultCallChkBox_1_stateChanged); +// connect(ui->getHardfaultCallChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_getHardfaultCallChkBox_1_stateChanged); - connect(ui->enableLedTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::enableLedTestChkBox_1_stateChanged); +// connect(ui->enableLedTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::enableLedTestChkBox_1_stateChanged); - connect(ui->discWorkTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discWorkTestChkBox_1_stateChanged); - connect(ui->discWarnTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discWarnTestChkBox_1_stateChanged); - connect(ui->discErrTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErrTestChkBox_1_stateChanged); +// connect(ui->discWorkTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discWorkTestChkBox_1_stateChanged); +// connect(ui->discWarnTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discWarnTestChkBox_1_stateChanged); +// connect(ui->discErrTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErrTestChkBox_1_stateChanged); - connect(ui->discErr24TestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr24TestChkBox_1_stateChanged); - ui->discErr24TestChkBox_1->setAttribute(Qt::WA_TransparentForMouseEvents, true); - connect(ui->discErr5TestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr5TestChkBox_1_stateChanged); - ui->discErr5TestChkBox_1->setAttribute(Qt::WA_TransparentForMouseEvents, true); - connect(ui->discErr5VsciTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr5VsciTestChkBox_1_stateChanged); - ui->discErr5VsciTestChkBox_1->setAttribute(Qt::WA_TransparentForMouseEvents, true); - connect(ui->discErr5VATestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr5VATestChkBox_1_stateChanged); - ui->discErr5VATestChkBox_1->setAttribute(Qt::WA_TransparentForMouseEvents, true); +// connect(ui->discErr24TestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr24TestChkBox_1_stateChanged); +// ui->discErr24TestChkBox_1->setAttribute(Qt::WA_TransparentForMouseEvents, true); +// connect(ui->discErr5TestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr5TestChkBox_1_stateChanged); +// ui->discErr5TestChkBox_1->setAttribute(Qt::WA_TransparentForMouseEvents, true); +// connect(ui->discErr5VsciTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr5VsciTestChkBox_1_stateChanged); +// ui->discErr5VsciTestChkBox_1->setAttribute(Qt::WA_TransparentForMouseEvents, true); +// connect(ui->discErr5VATestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr5VATestChkBox_1_stateChanged); +// ui->discErr5VATestChkBox_1->setAttribute(Qt::WA_TransparentForMouseEvents, true); - connect(ui->ledWorkTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledWorkTestChkBox_1_stateChanged); - connect(ui->ledWarnTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledWarnTestChkBox_1_stateChanged); - connect(ui->ledErrTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledErrTestChkBox_1_stateChanged); - connect(ui->ledConnectTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledConnectTestChkBox_1_stateChanged); - connect(ui->ledVH1TestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledVH1TestChkBox_1_stateChanged); - connect(ui->ledVH2TestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledVH2TestChkBox_1_stateChanged); - connect(ui->ledVH3TestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledVH3TestChkBox_1_stateChanged); +// connect(ui->ledWorkTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledWorkTestChkBox_1_stateChanged); +// connect(ui->ledWarnTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledWarnTestChkBox_1_stateChanged); +// connect(ui->ledErrTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledErrTestChkBox_1_stateChanged); +// connect(ui->ledConnectTestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledConnectTestChkBox_1_stateChanged); +// connect(ui->ledVH1TestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledVH1TestChkBox_1_stateChanged); +// connect(ui->ledVH2TestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledVH2TestChkBox_1_stateChanged); +// connect(ui->ledVH3TestChkBox_1, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledVH3TestChkBox_1_stateChanged); - // Подключаем все чекбоксы для платы 2 - connect(ui->continiusCallChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_continiusCallChkBox_2_stateChanged); - connect(ui->calibrateCallChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_calibrateCallChkBox_2_stateChanged); - connect(ui->pollTECallChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_pollTECallChkBox_2_stateChanged); - connect(ui->resetKeyCallChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_resetKeyCallChkBox_2_stateChanged); - connect(ui->resetDefaultCallChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_resetDefaultCallChkBox_2_stateChanged); - connect(ui->getHardfaultCallChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_getHardfaultCallChkBox_2_stateChanged); +// // Подключаем все чекбоксы для платы 2 +// connect(ui->continiusCallChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_continiusCallChkBox_2_stateChanged); +// connect(ui->calibrateCallChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_calibrateCallChkBox_2_stateChanged); +// connect(ui->pollTECallChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_pollTECallChkBox_2_stateChanged); +// connect(ui->resetKeyCallChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_resetKeyCallChkBox_2_stateChanged); +// connect(ui->resetDefaultCallChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_resetDefaultCallChkBox_2_stateChanged); +// connect(ui->getHardfaultCallChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_getHardfaultCallChkBox_2_stateChanged); - connect(ui->enableLedTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::enableLedTestChkBox_2_stateChanged); +// connect(ui->enableLedTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::enableLedTestChkBox_2_stateChanged); - connect(ui->discWorkTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discWorkTestChkBox_2_stateChanged); - connect(ui->discWarnTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discWarnTestChkBox_2_stateChanged); - connect(ui->discErrTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErrTestChkBox_2_stateChanged); +// connect(ui->discWorkTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discWorkTestChkBox_2_stateChanged); +// connect(ui->discWarnTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discWarnTestChkBox_2_stateChanged); +// connect(ui->discErrTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErrTestChkBox_2_stateChanged); - connect(ui->discErr24TestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr24TestChkBox_2_stateChanged); - ui->discErr24TestChkBox_2->setAttribute(Qt::WA_TransparentForMouseEvents, true); - connect(ui->discErr5TestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr5TestChkBox_2_stateChanged); - ui->discErr5TestChkBox_2->setAttribute(Qt::WA_TransparentForMouseEvents, true); - connect(ui->discErr5VsciTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr5VsciTestChkBox_2_stateChanged); - ui->discErr5VsciTestChkBox_2->setAttribute(Qt::WA_TransparentForMouseEvents, true); - connect(ui->discErr5VATestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr5VATestChkBox_2_stateChanged); - ui->discErr5VATestChkBox_2->setAttribute(Qt::WA_TransparentForMouseEvents, true); +// connect(ui->discErr24TestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr24TestChkBox_2_stateChanged); +// ui->discErr24TestChkBox_2->setAttribute(Qt::WA_TransparentForMouseEvents, true); +// connect(ui->discErr5TestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr5TestChkBox_2_stateChanged); +// ui->discErr5TestChkBox_2->setAttribute(Qt::WA_TransparentForMouseEvents, true); +// connect(ui->discErr5VsciTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr5VsciTestChkBox_2_stateChanged); +// ui->discErr5VsciTestChkBox_2->setAttribute(Qt::WA_TransparentForMouseEvents, true); +// connect(ui->discErr5VATestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_discErr5VATestChkBox_2_stateChanged); +// ui->discErr5VATestChkBox_2->setAttribute(Qt::WA_TransparentForMouseEvents, true); - connect(ui->ledWorkTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledWorkTestChkBox_2_stateChanged); - connect(ui->ledWarnTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledWarnTestChkBox_2_stateChanged); - connect(ui->ledErrTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledErrTestChkBox_2_stateChanged); - connect(ui->ledConnectTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledConnectTestChkBox_2_stateChanged); - connect(ui->ledVH1TestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledVH1TestChkBox_2_stateChanged); - connect(ui->ledVH2TestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledVH2TestChkBox_2_stateChanged); - connect(ui->ledVH3TestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledVH3TestChkBox_2_stateChanged); +// connect(ui->ledWorkTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledWorkTestChkBox_2_stateChanged); +// connect(ui->ledWarnTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledWarnTestChkBox_2_stateChanged); +// connect(ui->ledErrTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledErrTestChkBox_2_stateChanged); +// connect(ui->ledConnectTestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledConnectTestChkBox_2_stateChanged); +// connect(ui->ledVH1TestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledVH1TestChkBox_2_stateChanged); +// connect(ui->ledVH2TestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledVH2TestChkBox_2_stateChanged); +// connect(ui->ledVH3TestChkBox_2, &QCheckBox::stateChanged, this, &DebugTerminalDialog::on_ledVH3TestChkBox_2_stateChanged); } - - - void DebugTerminalDialog::updateConnectionStatus(int boardID, bool connected) { // Обновляем визуальное отображение статуса соединения @@ -140,7 +160,6 @@ void DebugTerminalDialog::updateConnectionStatus(int boardID, bool connected) // Реализация по необходимости } - void DebugTerminalDialog::on_buttonBox_clicked(QAbstractButton *button) { switch (ui->buttonBox->buttonRole(button)) { @@ -186,7 +205,7 @@ void DebugTerminalDialog::on_getHardfaultCallChkBox_1_stateChanged(int state) } // Реализация слотов для теста дискретных сигналов платы 1 -void DebugTerminalDialog::enableLedTestChkBox_1_stateChanged(int state) +void DebugTerminalDialog::on_enableLedTestChkBox_1_stateChanged(int state) { writeCoil(0, COIL_LED_TEST_ENABLE, state == Qt::Checked ? 1 : 0); ui->leds_1->setEnabled(state); @@ -252,11 +271,6 @@ void DebugTerminalDialog::on_ledVH3TestChkBox_1_stateChanged(int state) writeCoil(0, COIL_LED_VH3_TEST, state == Qt::Checked ? 1 : 0); } - - - - - // Реализация слотов для вызова функций платы 2 void DebugTerminalDialog::on_continiusCallChkBox_2_stateChanged(int state) { @@ -289,7 +303,7 @@ void DebugTerminalDialog::on_getHardfaultCallChkBox_2_stateChanged(int state) } // Реализация слотов для теста дискретных сигналов платы 2 -void DebugTerminalDialog::enableLedTestChkBox_2_stateChanged(int state) +void DebugTerminalDialog::on_enableLedTestChkBox_2_stateChanged(int state) { writeCoil(1, COIL_LED_TEST_ENABLE, state == Qt::Checked ? 1 : 0); ui->leds_2->setEnabled(state); @@ -355,15 +369,6 @@ void DebugTerminalDialog::on_ledVH3TestChkBox_2_stateChanged(int state) writeCoil(1, COIL_LED_VH3_TEST, state == Qt::Checked ? 1 : 0); } - - - - - - - - - // Реализация слотов для вызова функций платы 3 void DebugTerminalDialog::on_continiusCallChkBox_3_stateChanged(int state) { @@ -396,7 +401,7 @@ void DebugTerminalDialog::on_getHardfaultCallChkBox_3_stateChanged(int state) } // Реализация слотов для теста дискретных сигналов платы 3 -void DebugTerminalDialog::enableLedTestChkBox_3_stateChanged(int state) +void DebugTerminalDialog::on_enableLedTestChkBox_3_stateChanged(int state) { writeCoil(2, COIL_LED_TEST_ENABLE, state == Qt::Checked ? 1 : 0); ui->leds_3->setEnabled(state); @@ -462,10 +467,6 @@ void DebugTerminalDialog::on_ledVH3TestChkBox_3_stateChanged(int state) writeCoil(2, COIL_LED_VH3_TEST, state == Qt::Checked ? 1 : 0); } - - - - // Реализация слотов для вызова функций платы 4 void DebugTerminalDialog::on_continiusCallChkBox_4_stateChanged(int state) { @@ -498,7 +499,7 @@ void DebugTerminalDialog::on_getHardfaultCallChkBox_4_stateChanged(int state) } // Реализация слотов для теста дискретных сигналов платы 4 -void DebugTerminalDialog::enableLedTestChkBox_4_stateChanged(int state) +void DebugTerminalDialog::on_enableLedTestChkBox_4_stateChanged(int state) { writeCoil(3, COIL_LED_TEST_ENABLE, state == Qt::Checked ? 1 : 0); ui->leds_4->setEnabled(state); @@ -564,12 +565,8 @@ void DebugTerminalDialog::on_ledVH3TestChkBox_4_stateChanged(int state) writeCoil(3, COIL_LED_VH3_TEST, state == Qt::Checked ? 1 : 0); } - - - void DebugTerminalDialog::openAdc(int boardID, int teNumber) { - // Удаляем старый диалог и создаем новый if (m_adcGraphDialog) { m_adcGraphDialog->deleteLater(); @@ -595,21 +592,18 @@ void DebugTerminalDialog::setGraphUpdateInterval(int milliseconds) } } - void DebugTerminalDialog::writeCoil(int boardID, int coil, int value) { QGroupBox* boardGroup = nullptr; switch(boardID) { case 0: boardGroup = ui->DbgPlate_1; break; // Плата 1 - case 1: boardGroup = ui->DbgPlate_2; break; // Плата 2 + case 1: boardGroup = ui->DbgPlate_2; break; // Плата 2 case 2: boardGroup = ui->DbgPlate_3; break; // Плата 3 case 3: boardGroup = ui->DbgPlate_4; break; // Плата 4 default: return; } - if(!boardGroup->isEnabled()) return; - qDebug() << "Writing board" << boardID << "coil:" << coil << "value:" << value; emit coilValueChanged(boardID, coil, value); } @@ -619,19 +613,17 @@ void DebugTerminalDialog::writeTENumber(int boardId, int teNumber) m_adcGraphDialog->setTENumber(boardId, teNumber); } - void DebugTerminalDialog::setBoardActive(int boardID, bool active) { // Получаем групбокс для указанной платы QGroupBox* boardGroup = nullptr; switch(boardID) { case 0: boardGroup = ui->DbgPlate_1; break; // Плата 1 - case 1: boardGroup = ui->DbgPlate_2; break; // Плата 2 + case 1: boardGroup = ui->DbgPlate_2; break; // Плата 2 case 2: boardGroup = ui->DbgPlate_3; break; // Плата 3 case 3: boardGroup = ui->DbgPlate_4; break; // Плата 4 default: return; } - if (boardGroup) { boardGroup->setEnabled(active); // Можно добавить визуальное отличие неактивных плат @@ -679,12 +671,6 @@ void DebugTerminalDialog::resetAll() ui->ledVH2TestChkBox_1->setChecked(false); ui->ledVH3TestChkBox_1->setChecked(false); - - - - - - // Сброс всех чекбоксов вызова функций ui->continiusCallChkBox_2->setChecked(false); ui->calibrateCallChkBox_2->setChecked(false); @@ -712,7 +698,6 @@ void DebugTerminalDialog::resetAll() ui->ledVH2TestChkBox_2->setChecked(false); ui->ledVH3TestChkBox_2->setChecked(false); - // Сброс всех чекбоксов вызова функций ui->continiusCallChkBox_3->setChecked(false); ui->calibrateCallChkBox_3->setChecked(false); @@ -740,9 +725,6 @@ void DebugTerminalDialog::resetAll() ui->ledVH2TestChkBox_3->setChecked(false); ui->ledVH3TestChkBox_3->setChecked(false); - - - // Сброс всех чекбоксов вызова функций ui->continiusCallChkBox_4->setChecked(false); ui->calibrateCallChkBox_4->setChecked(false); @@ -769,5 +751,61 @@ void DebugTerminalDialog::resetAll() ui->ledVH1TestChkBox_4->setChecked(false); ui->ledVH2TestChkBox_4->setChecked(false); ui->ledVH3TestChkBox_4->setChecked(false); - +} + +void DebugTerminalDialog::boardDebugReading(int boardID) +{ + if(mainTerm == nullptr) + return; + + if(!boards[boardID].isActive) + return; + + if(!this->isVisible()) + return; + + QModbusReply *_24V = mainTerm->readSingleCoil(boardID, 603); + if(_24V != nullptr) + connect(_24V, &QModbusReply::finished, this, [this, boardID, _24V]() { + if(_24V->error() == QModbusDevice::NoError) + boards[boardID].error24V->setChecked(_24V->result().value(0)); + _24V->deleteLater(); + }); + + QModbusReply *_5V = mainTerm->readSingleCoil(boardID, 604); + if(_5V != nullptr) + connect(_5V, &QModbusReply::finished, this, [this, boardID, _5V]() { + if(_5V->error() == QModbusDevice::NoError) + boards[boardID].error5V->setChecked(_5V->result().value(0)); + _5V->deleteLater(); + }); + + QModbusReply *_5VSCI = mainTerm->readSingleCoil(boardID, 605); + if(_5VSCI != nullptr) + connect(_5VSCI, &QModbusReply::finished, this, [this, boardID, _5VSCI]() { + if(_5VSCI->error() == QModbusDevice::NoError) + boards[boardID].error5VSCI->setChecked(_5VSCI->result().value(0)); + _5VSCI->deleteLater(); + }); + + QModbusReply *_5VA = mainTerm->readSingleCoil(boardID, 606); + if(_5VA != nullptr) + connect(_5VA, &QModbusReply::finished, this, [this, boardID, _5VA]() { + if(_5VA->error() == QModbusDevice::NoError) + boards[boardID].error5VA->setChecked(_5VA->result().value(0)); + _5VA->deleteLater(); + }); +} + +void DebugTerminalDialog::setScanBoardActive(bool flag, int boardID) +{ + boards[boardID].isActive = flag; +} + +void DebugTerminalDialog::offAllBoard() +{ + for(int i = 0; i < 4; i++) + { + boards[i].isActive = false; + } } diff --git a/M3KTE_TERM/debugterminaldialog.h b/M3KTE_TERM/debugterminaldialog.h index 4471b57..0c37b41 100644 --- a/M3KTE_TERM/debugterminaldialog.h +++ b/M3KTE_TERM/debugterminaldialog.h @@ -4,6 +4,8 @@ #include #include #include +#include +#include // Forward declarations вместо include class M3KTE; @@ -65,12 +67,20 @@ public: void setGraphUpdateInterval(int milliseconds); void writeTENumber(int boardId, int teNumber); void openAdc(int boardID, int teNumber); + void setMainTerm(M3KTE* term); + +public slots: + void boardDebugReading(int boardID); + void setScanBoardActive(bool flag, int boardID); + void offAllBoard(); protected: void showEvent(QShowEvent *event) override; void closeEvent(QCloseEvent *event) override; private slots: + + void on_buttonBox_clicked(QAbstractButton *button); // Плата 1 @@ -81,7 +91,7 @@ private slots: void on_resetDefaultCallChkBox_1_stateChanged(int state); void on_getHardfaultCallChkBox_1_stateChanged(int state); - void enableLedTestChkBox_1_stateChanged(int state); + void on_enableLedTestChkBox_1_stateChanged(int state); void on_discWorkTestChkBox_1_stateChanged(int state); void on_discWarnTestChkBox_1_stateChanged(int state); @@ -107,7 +117,7 @@ private slots: void on_resetDefaultCallChkBox_2_stateChanged(int state); void on_getHardfaultCallChkBox_2_stateChanged(int state); - void enableLedTestChkBox_2_stateChanged(int state); + void on_enableLedTestChkBox_2_stateChanged(int state); void on_discWorkTestChkBox_2_stateChanged(int state); void on_discWarnTestChkBox_2_stateChanged(int state); @@ -134,7 +144,7 @@ private slots: void on_resetDefaultCallChkBox_3_stateChanged(int state); void on_getHardfaultCallChkBox_3_stateChanged(int state); - void enableLedTestChkBox_3_stateChanged(int state); + void on_enableLedTestChkBox_3_stateChanged(int state); void on_discWorkTestChkBox_3_stateChanged(int state); void on_discWarnTestChkBox_3_stateChanged(int state); @@ -160,7 +170,7 @@ private slots: void on_resetDefaultCallChkBox_4_stateChanged(int state); void on_getHardfaultCallChkBox_4_stateChanged(int state); - void enableLedTestChkBox_4_stateChanged(int state); + void on_enableLedTestChkBox_4_stateChanged(int state); void on_discWorkTestChkBox_4_stateChanged(int state); void on_discWarnTestChkBox_4_stateChanged(int state); @@ -178,14 +188,15 @@ private slots: void on_ledVH2TestChkBox_4_stateChanged(int state); void on_ledVH3TestChkBox_4_stateChanged(int state); - signals: void coilValueChanged(int boardID, int coil, int value); void writeRegister(int boardID, int reg, int value); + void readCoil(int boardID, int coil, QModbusReply *reply); private: Ui::DebugTerminalDialog *ui; QModbusClient *m_modbusDevice; // Храним указатель здесь + M3KTE* mainTerm = nullptr; // Карты для хранения состояний QMap m_functionCalls; // boardId -> coil -> state @@ -195,10 +206,19 @@ private: // Номера ТЭ для каждой платы int m_teNumbers[4] = {0, 0, 0, 0}; + struct boardErrorLinks{ + bool isActive = false; + QCheckBox* error24V = nullptr; + QCheckBox* error5V = nullptr; + QCheckBox* error5VSCI = nullptr; + QCheckBox* error5VA = nullptr; + }; + boardErrorLinks boards[4]; + void initializeConnections(); void writeCoil(int boardID, int coil, int value); - void readCoil(int coil); + //void readCoil(int coil); void resetAll(); }; diff --git a/M3KTE_TERM/m3kte.cpp b/M3KTE_TERM/m3kte.cpp index 7cacb1d..7460c6e 100644 --- a/M3KTE_TERM/m3kte.cpp +++ b/M3KTE_TERM/m3kte.cpp @@ -368,9 +368,11 @@ M3KTE::M3KTE(QWidget *parent) } m_deviceSettingsDialog = new DeviceSettingsDialog(this); m_debugTerminalDialog = new DebugTerminalDialog(this); + m_debugTerminalDialog->setMainTerm(this); m_regMultipleSettings = new MultipleSettings(this); modbusDevice = new QModbusRtuSerialMaster(this); m_debugTerminalDialog->setModbusDevice(modbusDevice); + connect(this, &M3KTE::boardReading, m_debugTerminalDialog, &DebugTerminalDialog::boardDebugReading); m_lineRinger = new LineRinger(); Boards[0].boardScanners = new QTimer(); Boards[1].boardScanners = new QTimer(); @@ -676,6 +678,7 @@ void M3KTE::onConnectClicked() ui->BSM_WorkInProgress->setEnabled(false); ui->M3kteRegSettings->setEnabled(false); m_deviceSettingsDialog->onDisconnect(); + m_debugTerminalDialog->offAllBoard(); } } @@ -1426,6 +1429,7 @@ void M3KTE::beginScanBoards() { for(int i = 0; i < 4; i++) { if(Boards[i].isActive) { + m_debugTerminalDialog->setScanBoardActive(true, i); m_deviceSettingsDialog->initPollForBoard(i, Boards[i].adr); boardScan(i); } @@ -1438,6 +1442,7 @@ void M3KTE::boardScan(unsigned boardID) if (!modbusDevice) { return; } + emit boardReading(boardID); statusBar()->clearMessage(); @@ -1856,7 +1861,16 @@ void M3KTE::writeSingleRegister(int boardID, int regAddress, quint16 value) } } +QModbusReply* M3KTE::readSingleCoil(int boardID, int coilAddress) +{ + if (!modbusDevice || !Boards[boardID].isActive) + return nullptr; + QModbusDataUnit unit(QModbusDataUnit::Coils, coilAddress, 1); + + auto *reply = modbusDevice->sendReadRequest(unit, Boards[boardID].adr); + return reply; +} void M3KTE::selectPositionOnTree(unsigned int index) { diff --git a/M3KTE_TERM/m3kte.h b/M3KTE_TERM/m3kte.h index d3a2a6b..ec5ac59 100644 --- a/M3KTE_TERM/m3kte.h +++ b/M3KTE_TERM/m3kte.h @@ -38,7 +38,7 @@ extern "C" __declspec(dllexport) QWidget* init(QWidget *parent); QT_BEGIN_NAMESPACE -namespace Ui { class M3KTE; class SettingsDialog;} +namespace Ui { class M3KTE; class SettingsDialog; class DebugTerminalDialog;} QT_END_NAMESPACE #define LOCAL_STATE_POLL 0 @@ -46,6 +46,7 @@ QT_END_NAMESPACE #define LOCAL_STATE_ERR 2 class SettingsDialog; +class DebugTerminalDialog; class WriteRegisterModel; class M3KTE : public QMainWindow @@ -71,6 +72,7 @@ private: signals: void successAtCheckBoards(); void errorAtCheckBoards(); + void boardReading(int boardID); private slots: void clearLogger(); void logError(const QString &errorPlace, const QString &errorString, unsigned errorCount, const QString &description); @@ -92,6 +94,7 @@ public: M3KTE(QWidget *parent = nullptr); ~M3KTE(); QModbusClient* getModbusDevice() const { return modbusDevice; } + QModbusReply* readSingleCoil(int boardID, int coilAddress); private: Ui::M3KTE *ui; QTableWidget *loggerTable = nullptr;