delete m_indicatorLabels
This commit is contained in:
@@ -58,7 +58,6 @@ private:
|
|||||||
QVector<int> m_buttonValues; // Add this new member to store button states
|
QVector<int> m_buttonValues; // Add this new member to store button states
|
||||||
QVector<int> m_buttonBits; // Add this new member for button bits
|
QVector<int> m_buttonBits; // Add this new member for button bits
|
||||||
QVector<QString> m_buttonLabels;
|
QVector<QString> m_buttonLabels;
|
||||||
QVector<QString> m_indicatorLabels;
|
|
||||||
|
|
||||||
QModbusTcpClient* m_modbusClient;
|
QModbusTcpClient* m_modbusClient;
|
||||||
QPushButton* m_connectButton{};
|
QPushButton* m_connectButton{};
|
||||||
|
|||||||
@@ -100,16 +100,6 @@ void MainWindows::loadConfiguration() {
|
|||||||
}
|
}
|
||||||
m_buttonLabels.append(label);
|
m_buttonLabels.append(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load indicator labels
|
|
||||||
for(int i = 1; i <= m_indicatorCount; ++i) {
|
|
||||||
QString labelKey = QString("indicator_label%1").arg(i);
|
|
||||||
QString label = settings.value(labelKey).toString();
|
|
||||||
if(label.isEmpty()) {
|
|
||||||
label = QString("Indicator %1").arg(i);
|
|
||||||
}
|
|
||||||
m_indicatorLabels.append(label);
|
|
||||||
}
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,16 +238,13 @@ void MainWindows::onReadReady() {
|
|||||||
m_buttonValues[i] = value;
|
m_buttonValues[i] = value;
|
||||||
bool bitState = (value >> m_buttonBits[i]) & 1;
|
bool bitState = (value >> m_buttonBits[i]) & 1;
|
||||||
m_buttons[i]->setChecked(bitState); // Устанавливаем состояние кнопки
|
m_buttons[i]->setChecked(bitState); // Устанавливаем состояние кнопки
|
||||||
|
qDebug() << "mButtonRegisters[" << i << "] = " << m_buttonValues[i];
|
||||||
bool hasIndicator = false;
|
bool hasIndicator = false;
|
||||||
// Проверяем, есть ли индикатор для этой кнопки
|
if (m_indicatorRegisters.size() <= i) {
|
||||||
for (int j = 0; j < m_indicatorRegisters.size(); ++j) {
|
|
||||||
if (m_indicatorLabels[j].contains(m_buttonLabels[i], Qt::CaseInsensitive)) {
|
|
||||||
hasIndicator = true;
|
hasIndicator = true;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
m_buttons[i]->setText(hasIndicator ?
|
m_buttons[i]->setText(hasIndicator ?
|
||||||
QString("%1").arg(bitState ? "Выкл" : "Вкл") :
|
QString("%1").arg(bitState ? "Выключить" : "Включить") :
|
||||||
QString("%1").arg(bitState ? "Закрыть" : "Открыть"));
|
QString("%1").arg(bitState ? "Закрыть" : "Открыть"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,8 +285,6 @@ void MainWindows::createUIElements() {
|
|||||||
QString label;
|
QString label;
|
||||||
if (i < m_buttonCount) {
|
if (i < m_buttonCount) {
|
||||||
label = m_buttonLabels[i];
|
label = m_buttonLabels[i];
|
||||||
} else if (i < m_indicatorCount) {
|
|
||||||
label = m_indicatorLabels[i];
|
|
||||||
}
|
}
|
||||||
m_table->setItem(i, 0, new QTableWidgetItem(label));
|
m_table->setItem(i, 0, new QTableWidgetItem(label));
|
||||||
|
|
||||||
@@ -357,7 +342,7 @@ void MainWindows::createUIElements() {
|
|||||||
m_table->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed);
|
m_table->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed);
|
||||||
m_table->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Fixed);
|
m_table->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Fixed);
|
||||||
m_table->setColumnWidth(0, 180); // Label column
|
m_table->setColumnWidth(0, 180); // Label column
|
||||||
m_table->setColumnWidth(1, 100); // Button column
|
m_table->setColumnWidth(1, 170); // Button column
|
||||||
m_table->setColumnWidth(2, 50); // Square column
|
m_table->setColumnWidth(2, 50); // Square column
|
||||||
m_table->setColumnWidth(3, 100); // Status text column
|
m_table->setColumnWidth(3, 100); // Status text column
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,6 @@ button_reg5=5
|
|||||||
button_bit5=3
|
button_bit5=3
|
||||||
button_label5=Насос
|
button_label5=Насос
|
||||||
indicator_reg1=13
|
indicator_reg1=13
|
||||||
indicator_label1=Статус клапана 1
|
|
||||||
indicator_reg2=14
|
indicator_reg2=14
|
||||||
indicator_label2=Статус клапана 2
|
|
||||||
indicator_reg3=15
|
indicator_reg3=15
|
||||||
indicator_label3=Статус клапана 3
|
|
||||||
indicator_reg4=16
|
indicator_reg4=16
|
||||||
indicator_label4=Статус насоса
|
|
||||||
|
|||||||
Reference in New Issue
Block a user