fix ch1 &2 config bugs

This commit is contained in:
zhangsheng 2026-01-08 19:11:20 +08:00
parent faffd3695f
commit 1de7d438ad
6 changed files with 85 additions and 3 deletions

View File

@ -54,7 +54,7 @@ int MyTcpClient::sendData(char*data,qint64 len) {
return bytesWritten; return bytesWritten;
} }
void MyTcpClient::waitForRead() { void MyTcpClient::waitForRead() {
socket->waitForReadyRead(); socket->waitForReadyRead(3000);
} }
void MyTcpClient::disconnectFromServer() { void MyTcpClient::disconnectFromServer() {
shouldReconnect = false; // 停止自动重连 shouldReconnect = false; // 停止自动重连

View File

@ -294,6 +294,9 @@ typedef struct SeismicMonitor_{
normal_voltage_low = -20; normal_voltage_low = -20;
signal_sensitivity = 8; signal_sensitivity = 8;
channel_type = -1; channel_type = -1;
function = 0;
first_channel_angle = 0;
second_channel_angle = 0;
} }
} SeismicMonitor; } SeismicMonitor;

View File

@ -514,7 +514,7 @@
<rect> <rect>
<x>460</x> <x>460</x>
<y>280</y> <y>280</y>
<width>31</width> <width>41</width>
<height>16</height> <height>16</height>
</rect> </rect>
</property> </property>

View File

@ -298,6 +298,7 @@ void MainWindow::onMenuActionTriggered() {
CardType card_type = static_cast<CardType>(action->data().toInt()); CardType card_type = static_cast<CardType>(action->data().toInt());
qDebug() << "rack_type" << action->data() << "card type" << card_type; qDebug() << "rack_type" << action->data() << "card type" << card_type;
int button_id = button->objectName().right(button->objectName().length() - 15).toInt(); int button_id = button->objectName().right(button->objectName().length() - 15).toInt();
current_slot = button_id;
qDebug() << slot_type << rack_type << button_id << map_slot_config[button_id].slot_type << map_slot_config[button_id + 2].slot_type ; qDebug() << slot_type << rack_type << button_id << map_slot_config[button_id].slot_type << map_slot_config[button_id + 2].slot_type ;
map_slot_config[button_id].slot_label->setStyleSheet("QLabel { color :#2980b9; font: bold 16px}"); map_slot_config[button_id].slot_label->setStyleSheet("QLabel { color :#2980b9; font: bold 16px}");
QString chan_display = ""; QString chan_display = "";
@ -677,6 +678,12 @@ void MainWindow::on_pushButton_open_clicked() {
return; return;
} }
QFile file(tsi_config_file); QFile file(tsi_config_file);
// 先读出当前权限
QFileDevice::Permissions p = file.permissions();
// 加上写权限(所有者)
p |= QFileDevice::WriteOwner | QFileDevice::WriteGroup | QFileDevice::WriteOther;
// 去掉只读相当于重新设置权限
file.setPermissions(p);
if (!file.open(QIODevice::ReadOnly)) { if (!file.open(QIODevice::ReadOnly)) {
qWarning() << "Failed to open update file."; qWarning() << "Failed to open update file.";
return; return;

View File

@ -47,6 +47,8 @@ Seismic_monitor::Seismic_monitor(int slot,CardType cardtype, QWidget *parent) :
ui->label_text_4->setVisible(false); ui->label_text_4->setVisible(false);
ui->label_text_5->setVisible(false); ui->label_text_5->setVisible(false);
ui->label_text_6->setVisible(false); ui->label_text_6->setVisible(false);
ui->comboBox_function_1->setCurrentIndex(0);
ui->comboBox_function_2->setCurrentIndex(0);
Init(); Init();
} }
@ -647,7 +649,13 @@ void Seismic_monitor::on_pushButton_copy_channel_clicked()
void Seismic_monitor::on_comboBox_function_2_currentIndexChanged(int index) void Seismic_monitor::on_comboBox_function_2_currentIndexChanged(int index)
{ {
if(index == 1 && (ui->comboBox_chan_type_3->currentIndex() != 0 || ui->comboBox_chan_type_4->currentIndex() != 0)){ if(index == 1 && (ui->comboBox_chan_type_3->currentIndex() != 0 || ui->comboBox_chan_type_4->currentIndex() != 0)){
QMessageBox::warning(this, QStringLiteral("警告"), "通道1 和 通道2 必须为径向位移!"); QMessageBox::warning(this, QStringLiteral("警告"), "通道3 和 通道4 必须为径向位移!");
ui->comboBox_function_2->setCurrentIndex(0);
return;
}
if((index == 2||index == 3||index == 4)
&& (ui->comboBox_chan_type_3->currentIndex() != 3 || ui->comboBox_chan_type_4->currentIndex() != 3)){
QMessageBox::warning(this, QStringLiteral("警告"), "通道3 和 通道4 必须为轴向位移!");
ui->comboBox_function_2->setCurrentIndex(0); ui->comboBox_function_2->setCurrentIndex(0);
return; return;
} }
@ -674,6 +682,9 @@ void Seismic_monitor::on_comboBox_function_2_currentIndexChanged(int index)
ui->label_text_6->setVisible(false); ui->label_text_6->setVisible(false);
} }
current_config_3_4 = index; current_config_3_4 = index;
if(index != 0){
on_comboBox_dual_math_function_2_currentIndexChanged(0);
}
} }
void Seismic_monitor::on_comboBox_function_1_currentIndexChanged(int index) void Seismic_monitor::on_comboBox_function_1_currentIndexChanged(int index)
@ -683,6 +694,12 @@ void Seismic_monitor::on_comboBox_function_1_currentIndexChanged(int index)
ui->comboBox_function_1->setCurrentIndex(0); ui->comboBox_function_1->setCurrentIndex(0);
return; return;
} }
if((index == 2||index == 3||index == 4)
&& (ui->comboBox_chan_type_3->currentIndex() != 3 || ui->comboBox_chan_type_4->currentIndex() != 3)){
QMessageBox::warning(this, QStringLiteral("警告"), "通道1 和 通道2 必须为轴向位移!");
ui->comboBox_function_1->setCurrentIndex(0);
return;
}
if(index == 3){ if(index == 3){
ui->lineEdit_first_1->setVisible(true); ui->lineEdit_first_1->setVisible(true);
ui->lineEdit_second_1->setVisible(true); ui->lineEdit_second_1->setVisible(true);
@ -706,6 +723,9 @@ void Seismic_monitor::on_comboBox_function_1_currentIndexChanged(int index)
ui->label_text_5->setVisible(false); ui->label_text_5->setVisible(false);
} }
current_config_1_2 = index; current_config_1_2 = index;
if(index != 0){
on_comboBox_dual_math_function_currentIndexChanged(0);
}
} }
QString Seismic_monitor::GetUnit(int unit_num){ QString Seismic_monitor::GetUnit(int unit_num){
QString unit_str = ""; QString unit_str = "";
@ -779,3 +799,51 @@ int Seismic_monitor::SetUnit(QString unit_str){
} }
return unit_num; return unit_num;
} }
void Seismic_monitor::on_comboBox_dual_math_function_currentIndexChanged(int index)
{
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
std::shared_ptr<VariableBase> variable_base1 = ptr->GetChannelPtr(1);
std::shared_ptr<VariableBase> variable_base2 = ptr->GetChannelPtr(2);
qDebug() << "comboBox_function_1" << ui->comboBox_function_1->currentIndex();
if(ui->comboBox_function_1->currentIndex() == kDMF && (index == kRMSSum || index == kRMSSubtraction)
&& variable_base1->general.rectifier_function != 6
&& variable_base2->general.rectifier_function != 6){
QMessageBox::warning(this, QStringLiteral("警告"), "通道1 和 通道2 整流器必须为RMS");
ui->comboBox_function_1->setCurrentIndex(0);
return;
}
if((index == kSUM || index == kSUBTRACTION || index == kXYMin || index == kXYMax)
&& variable_base1->general.rectifier_function !=
variable_base2->general.rectifier_function){
QMessageBox::warning(this, QStringLiteral("警告"), "通道1 和 通道2 整流器必须配置相同!");
ui->comboBox_function_1->setCurrentIndex(0);
return;
}
}
void Seismic_monitor::on_comboBox_dual_math_function_2_currentIndexChanged(int index)
{
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
std::shared_ptr<VariableBase> variable_base1 = ptr->GetChannelPtr(3);
std::shared_ptr<VariableBase> variable_base2 = ptr->GetChannelPtr(4);
qDebug() << "comboBox_function_2" << ui->comboBox_function_2->currentIndex();
if(ui->comboBox_function_2->currentIndex() == kDMF && (index == kRMSSum || index == kRMSSubtraction)
&& variable_base1->general.rectifier_function != 6
&& variable_base2->general.rectifier_function != 6){
QMessageBox::warning(this, QStringLiteral("警告"), "通道3 和 通道4 整流器必须为RMS");
ui->comboBox_function_2->setCurrentIndex(0);
return;
}
if((index == kSUM || index == kSUBTRACTION || index == kXYMin || index == kXYMax)
&& variable_base1->general.rectifier_function !=
variable_base2->general.rectifier_function){
QMessageBox::warning(this, QStringLiteral("警告"), "通道3 和 通道4 整流器必须配置相同!");
ui->comboBox_function_2->setCurrentIndex(0);
return;
}
}

View File

@ -61,6 +61,10 @@ class Seismic_monitor : public QWidget {
void on_comboBox_function_1_currentIndexChanged(int index); void on_comboBox_function_1_currentIndexChanged(int index);
void on_comboBox_dual_math_function_currentIndexChanged(int index);
void on_comboBox_dual_math_function_2_currentIndexChanged(int index);
private: private:
Ui::Seismic_monitor *ui; Ui::Seismic_monitor *ui;
void UpdateData(std::shared_ptr<VibrationData> vib_data); void UpdateData(std::shared_ptr<VibrationData> vib_data);