qt_client/mainwindow.cpp

1649 lines
48 KiB
C++

#include "mainwindow.h"
#include "./ui_mainwindow.h"
/**
* 前散 0.1 2.0
* 测散 0.1 2.0
* fl1 0.02 1.5
* fl2 0.05 1.5
* fl3 0.3 1.5
*
*
*/
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
ui->le_server_ip->setText("10.9.8.2");
// ui->le_server_ip->setText("192.168.123.140");
ui->le_port->setText("1122");
// ui->rb_con_sta->setEnabled(false);
ui->rb_con_sta->setCheckable(false);
ui->rb_con_sta->setChecked(false);
connect(ui->bt_start, QPushButton::clicked, this, &MainWindow::start_connet);
connect(ui->bt_stop, QPushButton::clicked, this, &MainWindow::stop_connet);
connect(ui->bt_cmd, QPushButton::clicked, this, &MainWindow::send_cmd);
connect(ui->bt_help, QPushButton::clicked, this, &MainWindow::cmd_help);
connect(ui->bt_read, QPushButton::clicked, this, &MainWindow::cmd_read);
connect(ui->bt_set_fpga, QPushButton::clicked, this, &MainWindow::cmd_fpga);
connect(ui->bt_start_fpga, QPushButton::clicked, this,
&MainWindow::start_fpga);
connect(ui->bt_stop_fpga, QPushButton::clicked, this, &MainWindow::stop_fpga);
connect(ui->bt_sv17_open, QPushButton::clicked, this, &MainWindow::sv17_open);
connect(ui->bt_sv17_close, QPushButton::clicked, this,
&MainWindow::sv17_close);
connect(ui->bt_sv18_open, QPushButton::clicked, this, &MainWindow::sv18_open);
connect(ui->bt_sv18_close, QPushButton::clicked, this,
&MainWindow::sv18_close);
connect(ui->bt_sv20_open, QPushButton::clicked, this, &MainWindow::sv20_open);
connect(ui->bt_sv20_close, QPushButton::clicked, this,
&MainWindow::sv20_close);
connect(ui->bt_sv21_open, QPushButton::clicked, this, &MainWindow::sv21_open);
connect(ui->bt_sv21_close, QPushButton::clicked, this,
&MainWindow::sv21_close);
connect(ui->bt_p15_open, QPushButton::clicked, this, &MainWindow::p15_open);
connect(ui->bt_p15_close, QPushButton::clicked, this, &MainWindow::p15_close);
connect(ui->bt_p16_open, QPushButton::clicked, this, &MainWindow::p16_open);
connect(ui->bt_p16_close, QPushButton::clicked, this, &MainWindow::p16_close);
connect(ui->bt_p18_open, QPushButton::clicked, this, &MainWindow::p18_open);
connect(ui->bt_p18_close, QPushButton::clicked, this, &MainWindow::p18_close);
connect(ui->bt_p19_open, QPushButton::clicked, this, &MainWindow::p19_open);
connect(ui->bt_p19_close, QPushButton::clicked, this, &MainWindow::p19_close);
connect(ui->bt_p17_back, QPushButton::clicked, this,
&MainWindow::p17_backward);
connect(ui->bt_p17_forworad, QPushButton::clicked, this,
&MainWindow::p17_forward);
connect(ui->bt_p17_close, QPushButton::clicked, this, &MainWindow::p17_close);
connect(ui->bt_p17_rotate_ext, QPushButton::clicked, this,
&MainWindow::p17_forward_ext);
connect(ui->bt_p17_back_ext, QPushButton::clicked, this,
&MainWindow::p17_backward_ext);
connect(ui->bt_pump_clean, QPushButton::clicked, this,
&MainWindow::pump_clean);
connect(ui->bt_fast_stop, QPushButton::clicked, this, &MainWindow::fast_stop);
connect(ui->bt_blue_laser_close, QPushButton::clicked, this,
&MainWindow::blue_laser_close);
connect(ui->bt_blue_laser_open, QPushButton::clicked, this,
&MainWindow::blue_laser_open);
connect(ui->bt_red_laser_close, QPushButton::clicked, this,
&MainWindow::red_laser_close);
connect(ui->bt_red_laser_open, QPushButton::clicked, this,
&MainWindow::red_laser_open);
connect(ui->bt_z_go_zero, QPushButton::clicked, this, &MainWindow::z_go_zero);
connect(ui->bt_z_go_cyto, QPushButton::clicked, this, &MainWindow::z_go_cyto);
connect(ui->bt_z_ret_mov, QPushButton::clicked, this,
&MainWindow::z_go_ret_mov);
connect(ui->bt_z_abs_mov, QPushButton::clicked, this,
&MainWindow::z_go_abs_mov);
connect(ui->bt_fulling, QPushButton::clicked, this, &MainWindow::fulling);
connect(ui->bt_water_wash, QPushButton::clicked, this,
&MainWindow::water_wash);
connect(ui->bt_aco_wash, QPushButton::clicked, this, &MainWindow::aco_wash);
connect(ui->bt_washliq_wash, QPushButton::clicked, this,
&MainWindow::washliq_wash);
connect(ui->bt_clean, QPushButton::clicked, this, &MainWindow::info_clean);
connect(ui->bt_fpga_page_pre, QPushButton::clicked, this,
&MainWindow::fpga_page_prv);
connect(ui->bt_fpga_page_next, QPushButton::clicked, this,
&MainWindow::fpga_page_nxt);
connect(ui->bt_reverse_clean, QPushButton::clicked, this,
&MainWindow::revers_clean);
connect(ui->bt_p15_speed_set, QPushButton::clicked, this,
&MainWindow::p15_set_speed);
connect(ui->bt_laser_blue_set, QPushButton::clicked, this,
&MainWindow::laser_blue_set_power_ref);
connect(ui->bt_laser_red_set, QPushButton::clicked, this,
&MainWindow::laser_red_set_power_ref);
connect(ui->bt_rev1_open, QPushButton::clicked, this, &MainWindow::rev1_open);
connect(ui->bt_rev1_close, QPushButton::clicked, this,
&MainWindow::rev1_close);
connect(ui->bt_rev1_set, QPushButton::clicked, this,
&MainWindow::rev1_set_speed);
connect(ui->bt_open_test_data, QPushButton::clicked, this,
&MainWindow::open_test_data);
connect(ui->bt_close_test_data, QPushButton::clicked, this,
&MainWindow::close_test_data);
connect(ui->bt_sv_rev1_open, QPushButton::clicked, this,
&MainWindow::sv_rev1_open);
connect(ui->bt_sv_rev1_close, QPushButton::clicked, this,
&MainWindow::sv_rev1_close);
connect(ui->bt_sv_rev2_open, QPushButton::clicked, this,
&MainWindow::sv_rev2_open);
connect(ui->bt_sv_rev2_close, QPushButton::clicked, this,
&MainWindow::sv_rev2_close);
connect(ui->bt_sv_rev3_open, QPushButton::clicked, this,
&MainWindow::sv_rev3_open);
connect(ui->bt_sv_rev3_close, QPushButton::clicked, this,
&MainWindow::sv_rev3_close);
connect(ui->bt_read_onebyone, QPushButton::clicked, this,
&MainWindow::read_onebyone);
connect(ui->bt_close_onebyone, QPushButton::clicked, this,
&MainWindow::read_onebyone_stop);
connect(ui->bt_random_open, QPushButton::clicked, this,
&MainWindow::random_open);
connect(ui->bt_fsc_open, QPushButton::clicked, this, &MainWindow::fsc_open);
connect(ui->bt_fast_draw, QPushButton::clicked, this, &MainWindow::fast_draw);
connect(ui->bt_fast_push, QPushButton::clicked, this, &MainWindow::fast_push);
connect(ui->bt_slow_push, QPushButton::clicked, this, &MainWindow::slow_push);
connect(ui->bt_pump_reset, QPushButton::clicked, this,
&MainWindow::pump_reset);
connect(ui->bt_sw_test_prv, QPushButton::clicked, this,
&MainWindow::sw_test_prv);
connect(ui->bt_sw_test_next, QPushButton::clicked, this,
&MainWindow::sw_test_next);
connect(ui->bt_clean_outer_pipe, QPushButton::clicked, this,
&MainWindow::clean_outer_pipe);
timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &MainWindow::stop_the_pump);
connect(ui->bt_fast_draw_water, QPushButton::clicked, this,
&MainWindow::fast_draw_water);
connect(ui->bt_p17_forward_1000, QPushButton::clicked, this,
&MainWindow::p17_forward_1000);
connect(ui->bt_pipe_clean, QPushButton::clicked, this,
&MainWindow::clean_pipe);
connect(ui->bt_set_time_delay, QPushButton::clicked, this,
&MainWindow::set_time_delay);
connect(ui->bt_fpga_menu, QPushButton::clicked, this,
&MainWindow::choose_fpga_page);
connect(ui->bt_pump_menu, QPushButton::clicked, this,
&MainWindow::choose_pump_page);
connect(ui->bt_write_fpga_cfg, QPushButton::clicked, this,
&MainWindow::write_fpga_cfg);
connect(ui->bt_read_fpga_cfg, QPushButton::clicked, this,
&MainWindow::read_fpga_cfg);
connect(ui->bt_wave_open, QPushButton::clicked, this, &MainWindow::wave_open);
connect(ui->bt_wave_close, QPushButton::clicked, this,
&MainWindow::wave_close);
connect(ui->bt_sipm_gain_menu, QPushButton::clicked, this,
&MainWindow::sipm_gain_menu);
connect(ui->bt_sipm_fl1_get_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_get_fl1);
connect(ui->bt_sipm_fl2_get_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_get_fl2);
connect(ui->bt_sipm_fl3_get_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_get_fl3);
connect(ui->bt_sipm_fl4_get_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_get_fl4);
connect(ui->bt_sipm_fl5_get_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_get_fl5);
connect(ui->bt_sipm_fl6_get_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_get_fl6);
connect(ui->bt_sipm_ssc_get_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_get_ssc);
connect(ui->bt_sipm_fl1_set_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_set_fl1);
connect(ui->bt_sipm_fl2_set_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_set_fl2);
connect(ui->bt_sipm_fl3_set_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_set_fl3);
connect(ui->bt_sipm_fl4_set_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_set_fl4);
connect(ui->bt_sipm_fl5_set_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_set_fl5);
connect(ui->bt_sipm_fl6_set_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_set_fl6);
connect(ui->bt_sipm_ssc_set_value, QPushButton::clicked, this,
&MainWindow::sipm_gain_set_ssc);
connect(ui->bt_sipm_get_one_click, QPushButton::clicked, this,
&MainWindow::sipm_gain_get_one_click);
connect(ui->bt_sipm_gain_write_onc_click, QPushButton::clicked, this,
&MainWindow::spim_gain_set_one_click);
// defconfig
ui->le_pz_ch1->setText("2.0");
ui->le_pz_ch2->setText("2.0");
ui->le_pz_ch3->setText("2.0");
ui->le_pz_ch4->setText("2.0");
ui->le_pz_ch5->setText("2.0");
ui->le_pz_ch6->setText("2.0");
ui->le_pz_ch7->setText("2.0");
ui->le_pz_ch8->setText("2.0");
ui->le_zy_ch1->setText("0.1");
ui->le_zy_ch2->setText("0.1");
ui->le_zy_ch3->setText("0.1");
ui->le_zy_ch4->setText("0.1");
ui->le_zy_ch5->setText("0.1");
ui->le_zy_ch6->setText("0.1");
ui->le_zy_ch7->setText("0.1");
ui->le_zy_ch8->setText("0.1");
ui->tb_msgbox->setTextBackgroundColor(Qt::gray);
ui->le_p17_speed->setText("1000");
// user config
ui->le_pz_ch1->setText("2.0");
ui->le_zy_ch1->setText("0.1");
ui->le_pz_ch2->setText("2.0");
ui->le_zy_ch2->setText("0.1");
ui->le_pz_ch3->setText("1.5");
ui->le_zy_ch3->setText("0.02");
ui->le_pz_ch4->setText("1.5");
ui->le_zy_ch4->setText("0.05");
//
ui->le_gain_17->setText("1.2");
ui->le_gain_18->setText("1.2");
ui->le_gain_19->setText("1.2");
ui->le_gain_20->setText("1.2");
ui->le_gain_21->setText("1.2");
ui->le_gain_22->setText("1.2");
ui->le_gain_23->setText("1.2");
ui->le_delay_onebyone->setText("3000");
ui->le_p15_speed->setText("9490");
ui->le_p17_speed->setText("9000");
tcp_socket = nullptr;
}
MainWindow::~MainWindow() {
stop_connet();
delete ui;
}
/**
*
* 貌似加了ReuseAddressHint也没用
*/
void MainWindow::start_connet() {
if (tcp_socket == nullptr) {
// tcp_socket->setSocketOption(QAbstractSocket::KeepAliveOption,
// QVariant::fromValue(true));
int retry = 0;
std::cout << "start connect" << std::endl;
while (retry < 10) {
tcp_socket = new QTcpSocket(this);
connect(tcp_socket, &QTcpSocket::connected, this, &MainWindow::connected);
connect(tcp_socket, &QTcpSocket::readyRead, this,
&MainWindow::receive_cmd);
short port = ui->le_port->text().toInt();
port = port + retry;
bool ret = tcp_socket->bind(port, QAbstractSocket::ReuseAddressHint |
QAbstractSocket::ShareAddress);
std::cout << "bind port " << port << " ret " << ret << std::endl;
tcp_socket->connectToHost(ui->le_server_ip->text(),
ui->le_port->text().toInt());
QAbstractSocket::SocketError error = tcp_socket->error();
if (tcp_socket->error() == -1) {
break;
;
}
QString errorString = tcp_socket->errorString();
std::cout << "error " << error << " errorString "
<< errorString.toStdString() << std::endl;
tcp_socket->close();
delete tcp_socket;
tcp_socket = nullptr;
retry++;
}
if (retry == 10) {
tcp_socket->close();
delete tcp_socket;
tcp_socket = nullptr;
ui->rb_con_sta->setChecked(false);
}
}
}
void MainWindow::connected() {
ui->rb_con_sta->setCheckable(true);
ui->rb_con_sta->setChecked(true);
}
void MainWindow::stop_connet() {
if (tcp_socket != nullptr) {
tcp_socket->disconnectFromHost();
tcp_socket->close();
delete tcp_socket;
tcp_socket = nullptr;
}
ui->rb_con_sta->setChecked(false);
ui->rb_con_sta->setCheckable(false);
}
void MainWindow::send_cmd() {
if (tcp_socket != nullptr) {
ui->tb_msgbox->append("[S]" + ui->le_cmd->text());
QByteArray data = ui->le_cmd->text().toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
QStringList extractWords(const QString &input) {
// 使用QString的split函数按空格划分字符串
QStringList words = input.split(' ', QString::SkipEmptyParts);
return words;
}
void MainWindow::show_sipm_gain(int ch, int gain) {
switch (ch) {
case 0:
ui->le_sipm_ssc_value->setText(QString::number(gain));
break;
case 1:
ui->le_sipm_fl1_value->setText(QString::number(gain));
break;
case 2:
ui->le_sipm_fl2_value->setText(QString::number(gain));
break;
case 3:
ui->le_sipm_fl3_value->setText(QString::number(gain));
break;
case 4:
ui->le_sipm_fl4_value->setText(QString::number(gain));
break;
case 5:
ui->le_sipm_fl5_value->setText(QString::number(gain));
break;
case 6:
ui->le_sipm_fl6_value->setText(QString::number(gain));
break;
default:
break;
}
}
void MainWindow::receive_cmd() {
QByteArray data = tcp_socket->readAll();
QString str = data.data();
ui->tb_msgbox->append("[R]" + str);
QStringList words = extractWords(str);
for (const QString &word : words) {
printf("%s\n", word.toStdString().c_str());
}
do {
if (words[0] == "@") {
if (words[1] == "sipm_gain") {
int ch, gain;
if (words[2] != "ch") {
break;
}
ch = words[3].toInt();
if (words[4] != "gain") {
break;
}
gain = words[5].toInt();
show_sipm_gain(ch, gain);
} else {
break;
}
}
} while (0);
// if (str[0] = '\033', str[1] == '[') {
// // #define F_BLACK "30;"
// // #define F_RED "31;"
// // #define F_GREEN "32;"
// // #define F_YELLOW "33;"
// // #define F_BLUE "34;"
// // #define F_MAGENTA "35;"
// // #define F_CYAN "36;"
// // #define F_WHITE "37;"
// if (str[2] == '3' && str[4] == ';') {
// if (str[3] == '1') {
// ui->tb_msgbox->setTextColor(Qt::red);
// } else if (str[3] == '2') {
// ui->tb_msgbox->setTextColor(Qt::green);
// } else if (str[3] == '3') {
// ui->tb_msgbox->setTextColor(Qt::blue);
// } else if (str[3] == '4') {
// ui->tb_msgbox->setTextColor(Qt::yellow);
// } else if (str[3] == '5') {
// ui->tb_msgbox->setTextColor(Qt::magenta);
// } else if (str[3] == '6') {
// ui->tb_msgbox->setTextColor(Qt::cyan);
// } else if (str[3] == '7') {
// ui->tb_msgbox->setTextColor(Qt::white);
// }
// }
// if (str.length() > 8) {
// str = str.mid(8);
// } else {
// return;
// }
// }
// str = "[R]" + str;
// ui->tb_msgbox->append(str);
// ui->tb_msgbox->setTextColor(Qt::black);
}
void MainWindow::cmd_help() {
if (tcp_socket != nullptr) {
QString cmd = "help";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::cmd_read() {
if (tcp_socket != nullptr) {
QString cmd = "msh_liq_workflow 4";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::revers_clean() {
if (tcp_socket != nullptr) {
QString cmd = "msh_liq_workflow 6";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::wave_open() {
if (tcp_socket != nullptr) {
QString cmd = "set_delay_time_calc 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::wave_close() {
if (tcp_socket != nullptr) {
QString cmd = "set_delay_time_calc 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::cmd_fpga() {
if (tcp_socket != nullptr) {
QString cmd = "test_set_gain_bias 0";
cmd += " ";
cmd += ui->le_zy_ch1->text();
cmd += " \r\n";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
_sleep(100);
cmd = "test_set_gain_bias 1";
cmd += " ";
cmd += ui->le_pz_ch1->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
_sleep(100);
cmd = "test_set_gain_bias 2";
cmd += " ";
cmd += ui->le_zy_ch2->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
_sleep(100);
cmd = "test_set_gain_bias 3";
cmd += " ";
cmd += ui->le_pz_ch2->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
_sleep(100);
cmd = "test_set_gain_bias 4";
cmd += " ";
cmd += ui->le_zy_ch3->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
_sleep(100);
cmd = "test_set_gain_bias 5";
cmd += " ";
cmd += ui->le_pz_ch3->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
{
// fl2
_sleep(100);
cmd = "test_set_gain_bias 6";
cmd += " ";
cmd += ui->le_zy_ch4->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
_sleep(100);
cmd = "test_set_gain_bias 7";
cmd += " ";
cmd += ui->le_pz_ch4->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
{
// fl3
_sleep(100);
cmd = "test_set_gain_bias 8";
cmd += " ";
cmd += ui->le_zy_ch5->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
_sleep(100);
cmd = "test_set_gain_bias 9";
cmd += " ";
cmd += ui->le_pz_ch5->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
{
// fl4
_sleep(100);
cmd = "test_set_gain_bias 10";
cmd += " ";
cmd += ui->le_zy_ch6->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
_sleep(100);
cmd = "test_set_gain_bias 11";
cmd += " ";
cmd += ui->le_pz_ch6->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
{
// fl4
_sleep(100);
cmd = "test_set_gain_bias 10";
cmd += " ";
cmd += ui->le_zy_ch6->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
_sleep(100);
cmd = "test_set_gain_bias 11";
cmd += " ";
cmd += ui->le_pz_ch6->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
{
// fl5
_sleep(100);
cmd = "test_set_gain_bias 12";
cmd += " ";
cmd += ui->le_zy_ch7->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
_sleep(100);
cmd = "test_set_gain_bias 13";
cmd += " ";
cmd += ui->le_pz_ch7->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
{
// fl4
_sleep(100);
cmd = "test_set_gain_bias 14";
cmd += " ";
cmd += ui->le_zy_ch8->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
_sleep(100);
cmd = "test_set_gain_bias 15";
cmd += " ";
cmd += ui->le_pz_ch8->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
{
_sleep(100);
cmd = "test_set_gain_bias 16";
cmd += " ";
cmd += ui->le_gain_17->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
{
_sleep(100);
cmd = "test_set_gain_bias 17";
cmd += " ";
cmd += ui->le_gain_18->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
{
_sleep(100);
cmd = "test_set_gain_bias 18";
cmd += " ";
cmd += ui->le_gain_19->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
{
_sleep(100);
cmd = "test_set_gain_bias 19";
cmd += " ";
cmd += ui->le_gain_20->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
{
_sleep(100);
cmd = "test_set_gain_bias 20";
cmd += " ";
cmd += ui->le_gain_21->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
{
_sleep(100);
cmd = "test_set_gain_bias 21";
cmd += " ";
cmd += ui->le_gain_22->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
{
_sleep(100);
cmd = "test_set_gain_bias 22";
cmd += " ";
cmd += ui->le_gain_23->text();
cmd += " \r\n";
data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
}
void MainWindow::start_fpga() {
if (tcp_socket != nullptr) {
QString cmd = "test_signal_acq_ena 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::stop_fpga() {
if (tcp_socket != nullptr) {
QString cmd = "test_signal_acq_ena 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv17_open() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv17 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv17_close() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv17 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv18_open() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv18 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv18_close() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv18 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv20_open() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv20 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv20_close() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv20 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv21_open() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv21 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv21_close() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv21 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::p19_open() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p19 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::p19_close() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p19 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::p15_open() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p15 rotate_start 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::p15_close() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p15 rotate_stop";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::rev1_open() {
if (tcp_socket != nullptr) {
QString cmd = "msh_motor_rev1 rotate_start 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::rev1_close() {
if (tcp_socket != nullptr) {
QString cmd = "msh_motor_rev1 rotate_stop";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::p16_open() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p16 70";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::p15_set_speed() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p15 speed_change ";
cmd += ui->le_p15_speed->text();
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::rev1_set_speed() {
if (tcp_socket != nullptr) {
QString cmd = "msh_motor_rev1 speed_change ";
cmd += ui->le_rev1_speed->text();
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::p16_close() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p16 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::p18_open() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p18 70";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::p18_close() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p18 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::p17_backward() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p17 rotate_start 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::p17_forward_ext() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p17 rotate_start_ext ";
cmd += ui->le_p17_speed->text();
cmd += " 3000";
cmd += " 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
// std::cout<<"cmd: "<<cmd.toStdString()<<std::endl;
}
}
void MainWindow::p17_backward_ext() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p17 rotate_start_ext ";
cmd += ui->le_p17_speed->text();
cmd += " 3000";
cmd += " 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::p17_forward() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p17 rotate_start 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::p17_close() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p17 rotate_stop";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::pump_clean() {
if (tcp_socket != nullptr) {
QString cmd = "msh_liq_workflow 7";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::fast_stop() {
if (tcp_socket != nullptr) {
QString cmd = "stop";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::blue_laser_open() {
if (tcp_socket != nullptr) {
QString cmd = "cmd_laser_ctrl 0 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::blue_laser_close() {
if (tcp_socket != nullptr) {
QString cmd = "cmd_laser_ctrl 0 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::laser_blue_set_power_ref() {
if (tcp_socket != nullptr) {
QString cmd = "cmd_laser_set_pwref 0 ";
cmd += ui->le_laser_blue_value->text();
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::red_laser_open() {
if (tcp_socket != nullptr) {
QString cmd = "cmd_laser_ctrl 2 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::red_laser_close() {
if (tcp_socket != nullptr) {
QString cmd = "cmd_laser_ctrl 2 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::laser_red_set_power_ref() {
if (tcp_socket != nullptr) {
QString cmd = "cmd_laser_set_pwref 2 ";
cmd += ui->le_laser_red_value->text();
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::z_go_zero() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sample_z go zero";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::z_go_cyto() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sample_z go cyto";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::z_go_ret_mov() {
if (tcp_socket != nullptr) {
QString cmd = "msh_motor_move 2 ";
cmd += ui->le_z_ret_move->text();
cmd += " 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::z_go_abs_mov() {
if (tcp_socket != nullptr) {
QString cmd = "msh_motor_move 2 ";
cmd += ui->le_z_ret_move->text();
cmd += " 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::fulling() {
if (tcp_socket != nullptr) {
QString cmd = "msh_liq_workflow 5";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::water_wash() {
if (tcp_socket != nullptr) {
QString cmd = "msh_liq_workflow 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::aco_wash() {
if (tcp_socket != nullptr) {
QString cmd = "msh_liq_workflow 3";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::washliq_wash() {
if (tcp_socket != nullptr) {
QString cmd = "msh_liq_workflow 2";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::info_clean() { ui->tb_msgbox->setText(""); }
void MainWindow::fpga_page_prv() {
if (ui->fpga_set_page->currentIndex() > 0) {
ui->fpga_set_page->setCurrentIndex(ui->fpga_set_page->currentIndex() - 1);
}
}
void MainWindow::fpga_page_nxt() {
if (ui->fpga_set_page->currentIndex() < ui->fpga_set_page->count()-1) {
ui->fpga_set_page->setCurrentIndex(ui->fpga_set_page->currentIndex() + 1);
}
}
void MainWindow::open_test_data() {
if (tcp_socket != nullptr) {
QString cmd = "test_signal_wave_ena 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::close_test_data() {
if (tcp_socket != nullptr) {
QString cmd = "test_signal_wave_ena 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv_rev1_open() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv_rev1 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv_rev1_close() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv_rev1 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv_rev2_open() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv_rev2 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv_rev2_close() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv_rev2 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv_rev3_open() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv_rev3 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sv_rev3_close() {
if (tcp_socket != nullptr) {
QString cmd = "msh_sv_rev3 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::read_onebyone() {
if (tcp_socket != nullptr) {
p17_forward_ext();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
{ _sleep(ui->le_delay_onebyone->text().toInt()); }
p15_open();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
p15_set_speed();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv17_open();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv_rev3_open();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
}
}
void MainWindow::read_onebyone_stop() {
if (tcp_socket != nullptr) {
p17_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
p15_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv17_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv_rev3_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
}
}
void MainWindow::fsc_open() {
if (tcp_socket != nullptr) {
QString cmd = "test_signal_fsc_ena 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::random_open() {
if (tcp_socket != nullptr) {
QString cmd = "test_signal_random_ena 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sw_test_prv() {
if (ui->sw_test->currentIndex() > 0) {
ui->sw_test->setCurrentIndex(ui->sw_test->currentIndex() - 1);
}
}
void MainWindow::sw_test_next() {
if (ui->sw_test->currentIndex() < 2) {
ui->sw_test->setCurrentIndex(ui->sw_test->currentIndex() + 1);
}
}
void MainWindow::fast_draw() {
if (tcp_socket != nullptr) {
sv_rev1_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv_rev2_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv_rev3_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
QString cmd = "msh_p17 move_ext ";
cmd += PUMP_SPEED;
cmd += " ";
cmd += PUMP_ACCE;
cmd += " ";
cmd += "32000 ";
cmd += "1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::fast_draw_water() {
if (tcp_socket != nullptr) {
sv_rev1_open();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv_rev2_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv_rev3_open();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
QString cmd = "msh_p17 move_ext ";
cmd += PUMP_SPEED;
cmd += " ";
cmd += PUMP_ACCE;
cmd += " ";
cmd += "32000 ";
cmd += "1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::fast_push() {
if (tcp_socket != nullptr) {
sv_rev1_open();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv_rev2_open();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv_rev3_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
QString cmd = "msh_p17 move_ext ";
cmd += PUMP_SPEED;
cmd += " ";
cmd += PUMP_ACCE;
cmd += " ";
cmd += "0 ";
cmd += "1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::slow_push() {
if (tcp_socket != nullptr) {
sv_rev1_open();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv_rev2_open();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv_rev3_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
QString cmd = "msh_p17 rotate_start ";
cmd += "1 ";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
timer->setSingleShot(true); // 设置定时器为单次触发
timer->start(240000);
}
}
void MainWindow::stop_the_pump() { p17_close(); }
void MainWindow::pump_reset() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p17 rotate_start_ext ";
cmd += 1000;
cmd += " 3000";
cmd += " 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten(3000);
// for (int i = 0; i < 2; i++) {
_sleep(1000);
// }
}
if (tcp_socket != nullptr) {
QString cmd = "msh_p17 rotate_stop";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten(3000);
}
if (tcp_socket != nullptr) {
QString cmd = "msh_p17 init ";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::clean_outer_pipe() {
printf("clean_outer_pipe\n");
if (tcp_socket != nullptr) {
printf("clean_outer_pipe\n");
QString cmd = "msh_p19 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
p16_open();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
for (int i = 0; i < 5; i++) {
z_go_cyto();
tcp_socket->waitForBytesWritten(3000);
_sleep(2000);
z_go_zero();
tcp_socket->waitForBytesWritten(3000);
_sleep(2000);
}
p16_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
p19_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
}
}
void MainWindow::p17_forward_1000() {
if (tcp_socket != nullptr) {
QString cmd = "msh_p17 move_ext ";
cmd += "10000";
cmd += " ";
cmd += "10000";
cmd += " ";
cmd += "1000 ";
cmd += "0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::clean_pipe() {
if (tcp_socket != nullptr) {
p19_open();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
}
for (int i = 0; i < 5; i++) {
if (tcp_socket != nullptr) {
fast_draw_water();
tcp_socket->waitForBytesWritten(3000);
_sleep(5000);
sv_rev1_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv_rev1_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
sv_rev3_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
QString cmd = "msh_p17 move_ext ";
cmd += PUMP_SPEED;
cmd += " ";
cmd += PUMP_ACCE;
cmd += " ";
cmd += "0 ";
cmd += "1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten(3000);
_sleep(5000);
}
}
if (tcp_socket != nullptr) {
p19_close();
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
}
}
void MainWindow::set_time_delay() {
if (tcp_socket != nullptr) {
QString cmd = "cyto_set_laser_time_diff ";
cmd += ui->le_time_delay->text();
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten(3000);
_sleep(100);
}
}
void MainWindow::choose_fpga_page() { ui->sw_config->setCurrentIndex(0); }
void MainWindow::choose_pump_page() { ui->sw_config->setCurrentIndex(1); }
void MainWindow::sipm_gain_menu() { ui->sw_config->setCurrentIndex(2); }
void MainWindow::write_fpga_cfg() {
QSettings settings("config.ini", QSettings::IniFormat);
settings.setValue("pz_ch1", ui->le_pz_ch1->text());
settings.setValue("pz_ch2", ui->le_pz_ch2->text());
settings.setValue("pz_ch3", ui->le_pz_ch3->text());
settings.setValue("pz_ch4", ui->le_pz_ch4->text());
settings.setValue("pz_ch5", ui->le_pz_ch5->text());
settings.setValue("pz_ch6", ui->le_pz_ch6->text());
settings.setValue("pz_ch7", ui->le_pz_ch7->text());
settings.setValue("pz_ch8", ui->le_pz_ch8->text());
settings.setValue("zy_ch1", ui->le_zy_ch1->text());
settings.setValue("zy_ch2", ui->le_zy_ch2->text());
settings.setValue("zy_ch3", ui->le_zy_ch3->text());
settings.setValue("zy_ch4", ui->le_zy_ch4->text());
settings.setValue("zy_ch5", ui->le_zy_ch5->text());
settings.setValue("zy_ch6", ui->le_zy_ch6->text());
settings.setValue("zy_ch7", ui->le_zy_ch7->text());
settings.setValue("zy_ch8", ui->le_zy_ch8->text());
settings.setValue("red_laser_delay", ui->le_time_delay->text());
settings.setValue("p15_speed", ui->le_p17_speed->text());
settings.setValue("p17_speed", ui->le_p17_speed->text());
settings.sync();
}
void MainWindow::read_fpga_cfg() {
QSettings settings("config.ini", QSettings::IniFormat);
ui->le_pz_ch1->setText(settings.value("pz_ch1").toString());
ui->le_pz_ch2->setText(settings.value("pz_ch2").toString());
ui->le_pz_ch3->setText(settings.value("pz_ch3").toString());
ui->le_pz_ch4->setText(settings.value("pz_ch4").toString());
ui->le_pz_ch5->setText(settings.value("pz_ch5").toString());
ui->le_pz_ch6->setText(settings.value("pz_ch6").toString());
ui->le_pz_ch7->setText(settings.value("pz_ch7").toString());
ui->le_pz_ch8->setText(settings.value("pz_ch8").toString());
ui->le_zy_ch1->setText(settings.value("zy_ch1").toString());
ui->le_zy_ch2->setText(settings.value("zy_ch2").toString());
ui->le_zy_ch3->setText(settings.value("zy_ch3").toString());
ui->le_zy_ch4->setText(settings.value("zy_ch4").toString());
ui->le_zy_ch5->setText(settings.value("zy_ch5").toString());
ui->le_zy_ch6->setText(settings.value("zy_ch6").toString());
ui->le_zy_ch7->setText(settings.value("zy_ch7").toString());
ui->le_zy_ch8->setText(settings.value("zy_ch8").toString());
ui->le_time_delay->setText(settings.value("red_laser_delay").toString());
ui->le_p17_speed->setText(settings.value("p17_speed").toString());
ui->le_p15_speed->setText(settings.value("p15_speed").toString());
}
void MainWindow::sipm_gain_set_ssc() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_set_gain 0 ";
cmd += ui->le_sipm_ssc_value->text();
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_set_fl1() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_set_gain 1 ";
cmd += ui->le_sipm_fl1_value->text();
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_set_fl2() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_set_gain 2 ";
cmd += ui->le_sipm_fl2_value->text();
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_set_fl3() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_set_gain 3 ";
cmd += ui->le_sipm_fl3_value->text();
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_set_fl4() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_set_gain 4 ";
cmd += ui->le_sipm_fl4_value->text();
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_set_fl5() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_set_gain 5 ";
cmd += ui->le_sipm_fl5_value->text();
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_set_fl6() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_set_gain 6 ";
cmd += ui->le_sipm_fl6_value->text();
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_get_ssc() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_get_gain 0";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_get_fl1() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_get_gain 1";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_get_fl2() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_get_gain 2";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_get_fl3() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_get_gain 3";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_get_fl4() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_get_gain 4";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_get_fl5() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_get_gain 5";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_get_fl6() {
if (tcp_socket != nullptr) {
QString cmd = "sipm_get_gain 6";
QByteArray data = cmd.toUtf8();
tcp_socket->write(data);
tcp_socket->waitForBytesWritten();
}
}
void MainWindow::sipm_gain_get_one_click() {
if (tcp_socket != nullptr) {
sipm_gain_get_ssc();
_sleep(100);
sipm_gain_get_fl1();
_sleep(100);
sipm_gain_get_fl2();
_sleep(100);
sipm_gain_get_fl3();
_sleep(100);
sipm_gain_get_fl4();
_sleep(100);
sipm_gain_get_fl5();
_sleep(100);
sipm_gain_get_fl6();
_sleep(100);
}
}
void MainWindow::spim_gain_set_one_click() {
if (tcp_socket != nullptr) {
sipm_gain_set_ssc();
_sleep(100);
sipm_gain_set_fl1();
_sleep(100);
sipm_gain_set_fl2();
_sleep(100);
sipm_gain_set_fl3();
_sleep(100);
sipm_gain_set_fl4();
_sleep(100);
sipm_gain_set_fl5();
_sleep(100);
sipm_gain_set_fl6();
_sleep(100);
}
}