| 
									
										
										
										
											2025-08-04 12:25:12 +08:00
										 |  |  | #include "dc_output_channel.h"
 | 
					
						
							|  |  |  | #include "ui_dc_output_channel.h"
 | 
					
						
							|  |  |  | #include <QMessageBox>
 | 
					
						
							| 
									
										
										
										
											2025-08-04 20:13:21 +08:00
										 |  |  | #include "data_config.h"
 | 
					
						
							| 
									
										
										
										
											2025-08-05 20:49:25 +08:00
										 |  |  | #include <QDebug>
 | 
					
						
							| 
									
										
										
										
											2025-08-04 12:25:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-04 20:13:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-06 22:11:14 +08:00
										 |  |  | DC_Output_Channel::DC_Output_Channel(int slot_no_,QString unit_str_,int current_index_,QWidget *parent) : | 
					
						
							| 
									
										
										
										
											2025-08-04 12:25:12 +08:00
										 |  |  |     QWidget(parent), | 
					
						
							|  |  |  |     ui(new Ui::DC_Output_Channel) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     ui->setupUi(this); | 
					
						
							| 
									
										
										
										
											2025-08-04 20:13:21 +08:00
										 |  |  |     unit_str = unit_str_; | 
					
						
							| 
									
										
										
										
											2025-08-05 20:49:25 +08:00
										 |  |  |     current_index = current_index_; | 
					
						
							| 
									
										
										
										
											2025-08-06 22:11:14 +08:00
										 |  |  |     slot_no = slot_no_; | 
					
						
							| 
									
										
										
										
											2025-08-04 20:13:21 +08:00
										 |  |  |     ui->label_min_unit->setText(unit_str); | 
					
						
							|  |  |  |     ui->label_max_unit->setText(unit_str); | 
					
						
							|  |  |  |     radiobtn[0] = ui->radioButton; | 
					
						
							|  |  |  |     radiobtn[1] = ui->radioButton_2; | 
					
						
							|  |  |  |     radiobtn[2] = ui->radioButton_3; | 
					
						
							|  |  |  |     radiobtn[3] = ui->radioButton_4; | 
					
						
							| 
									
										
										
										
											2025-08-05 20:49:25 +08:00
										 |  |  |     radiobtn[4] = ui->radioButton_5; | 
					
						
							|  |  |  |     int not_used = 0; | 
					
						
							|  |  |  |     for (int i = 0; i < 22; i++) { | 
					
						
							|  |  |  |         for (int j = 0; j < 4; j++){ | 
					
						
							| 
									
										
										
										
											2025-08-06 22:11:14 +08:00
										 |  |  |             if(ch_used[slot_no][i].used[j] && current_index == i){ | 
					
						
							| 
									
										
										
										
											2025-08-05 20:49:25 +08:00
										 |  |  |                 radiobtn[j]->setEnabled(true); | 
					
						
							|  |  |  |                 radiobtn[j]->setChecked(true); | 
					
						
							|  |  |  |                 first_used = j; | 
					
						
							| 
									
										
										
										
											2025-08-06 22:11:14 +08:00
										 |  |  |             }else if(ch_used[slot_no][i].used[j] && current_index != i){ | 
					
						
							| 
									
										
										
										
											2025-08-05 20:49:25 +08:00
										 |  |  |                 radiobtn[j]->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2025-08-06 22:11:14 +08:00
										 |  |  |             }else if(!ch_used[slot_no][i].used[j] && current_index == i){ | 
					
						
							| 
									
										
										
										
											2025-08-05 20:49:25 +08:00
										 |  |  |                 not_used ++; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if(not_used == 4){ | 
					
						
							|  |  |  |         ui->radioButton_5->setChecked(true); | 
					
						
							| 
									
										
										
										
											2025-08-04 20:13:21 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-08-04 12:25:12 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | DC_Output_Channel::~DC_Output_Channel() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DC_Output_Channel::on_pushButton_confirm_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int channel = 0; | 
					
						
							| 
									
										
										
										
											2025-08-05 20:49:25 +08:00
										 |  |  |     if(!ui->radioButton_5->isChecked() && ((ui->lineEdit_minmum->text().toFloat() >= ui->lineEdit_maxmum->text().toFloat()) || | 
					
						
							|  |  |  |             (ui->lineEdit_minmum->text().toFloat() == 0 &&  ui->lineEdit_maxmum->text().toFloat() == 0))){ | 
					
						
							| 
									
										
										
										
											2025-08-04 12:25:12 +08:00
										 |  |  |         QMessageBox::information(this, QStringLiteral("提示"), "请填写正确的最小值和最大值"); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if(ui->radioButton->isChecked()){ | 
					
						
							|  |  |  |         channel = 1; | 
					
						
							|  |  |  |     }else if(ui->radioButton_2->isChecked()){ | 
					
						
							|  |  |  |         channel = 2; | 
					
						
							|  |  |  |     }else if(ui->radioButton_3->isChecked()){ | 
					
						
							|  |  |  |         channel = 3; | 
					
						
							|  |  |  |     }else if(ui->radioButton_4->isChecked()){ | 
					
						
							|  |  |  |         channel = 4; | 
					
						
							| 
									
										
										
										
											2025-08-05 20:49:25 +08:00
										 |  |  |     }else if(ui->radioButton_5->isChecked()){ | 
					
						
							| 
									
										
										
										
											2025-08-06 22:11:14 +08:00
										 |  |  |         ch_used[slot_no][current_index].used[first_used] = false; | 
					
						
							| 
									
										
										
										
											2025-08-05 20:49:25 +08:00
										 |  |  |         channel = 5; | 
					
						
							| 
									
										
										
										
											2025-08-04 12:25:12 +08:00
										 |  |  |     }else { | 
					
						
							|  |  |  |         QMessageBox::information(this, QStringLiteral("提示"), "请选择正确的通道"); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-08-05 20:49:25 +08:00
										 |  |  |     emit output_channel_data_sg(channel,ui->lineEdit_minmum->text().toFloat(),ui->lineEdit_maxmum->text().toFloat(),first_used); | 
					
						
							| 
									
										
										
										
											2025-08-04 12:25:12 +08:00
										 |  |  |     this->close(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void DC_Output_Channel::on_pushButton_cancel_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     this->close(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 |