From 5af8901fdb8eb69fb62b36c73f38e9df495f9265 Mon Sep 17 00:00:00 2001 From: chenyf <1343619937@qq.com> Date: Thu, 12 Dec 2024 19:48:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(sipm=E5=A2=9E=E7=9B=8A):=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0sipm=E5=A2=9E=E7=9B=8A=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 +- CMakeLists.txt.user | 1108 ++++++++++++++++++++--------------------- mainwindow.cpp | 892 ++++++++++++++++++--------------- mainwindow.h | 19 + mainwindow.ui | 208 +++++++- 5 files changed, 1266 insertions(+), 964 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e911f56..9a68422 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -52,6 +52,7 @@ "typeinfo": "cpp", "variant": "cpp", "qabstractsocket": "cpp", - "qtimer": "cpp" + "qtimer": "cpp", + "qstringlist": "cpp" } } \ No newline at end of file diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user index 7db5002..2c96cc7 100644 --- a/CMakeLists.txt.user +++ b/CMakeLists.txt.user @@ -1,554 +1,554 @@ - - - - - - EnvironmentId - {7ff7bbfe-71cb-4343-a3c3-fccd36939917} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - -fno-delayed-template-parsing - - true - Builtin.Questionable - - true - Builtin.DefaultTidyAndClazy - 4 - - - - true - - - - - ProjectExplorer.Project.Target.0 - - Desktop Qt 5.12.9 MinGW 64-bit - Desktop Qt 5.12.9 MinGW 64-bit - qt.qt5.5129.win64_mingw73_kit - 1 - 0 - 0 - - - CMAKE_BUILD_TYPE:STRING=Debug - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - 2 - E:\FCMA\build-qt_client-Desktop_Qt_5_12_9_MinGW_64_bit-Debug - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=Release - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - 2 - E:\FCMA\build-qt_client-Desktop_Qt_5_12_9_MinGW_64_bit-Release - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=RelWithDebInfo - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - 2 - E:\FCMA\build-qt_client-Desktop_Qt_5_12_9_MinGW_64_bit-RelWithDebInfo - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release with Debug Information - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=MinSizeRel - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - 2 - E:\FCMA\build-qt_client-Desktop_Qt_5_12_9_MinGW_64_bit-MinSizeRel - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Minimum Size Release - CMakeProjectManager.CMakeBuildConfiguration - - 4 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - socket_cmd - CMakeProjectManager.CMakeRunConfiguration.socket_cmd - socket_cmd - - false - - false - true - true - false - false - true - - E:/FCMA/build-qt_client-Desktop_Qt_5_12_9_MinGW_64_bit-Release - - 1 - - - - ProjectExplorer.Project.Target.1 - - Qt 5.12.9 MinGW 64-bit - Qt 5.12.9 MinGW 64-bit - {f01e95f2-0cb5-451e-9e9e-b35e7a501b89} - 1 - 0 - 0 - - - CMAKE_BUILD_TYPE:STRING=Debug - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - 2 - E:\FCMA\qt_client\build - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=Release - CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} - CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} - CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} - QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} - - 2 - E:\FCMA\build-qt_client-Qt_5_12_9_MinGW_64_bit-Release - - - - - all - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - - clean - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - CMakeProjectManager.CMakeBuildConfiguration - - 2 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F - true - 4096 - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - socket_cmd - CMakeProjectManager.CMakeRunConfiguration.socket_cmd - socket_cmd - - false - - false - true - true - false - false - true - - - - 1 - - - - ProjectExplorer.Project.TargetCount - 2 - - - ProjectExplorer.Project.Updater.FileVersion - 22 - - - Version - 22 - - + + + + + + EnvironmentId + {7ff7bbfe-71cb-4343-a3c3-fccd36939917} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + -fno-delayed-template-parsing + + true + Builtin.Questionable + + true + Builtin.DefaultTidyAndClazy + 4 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.12.9 MinGW 64-bit + Desktop Qt 5.12.9 MinGW 64-bit + qt.qt5.5129.win64_mingw73_kit + 1 + 0 + 0 + + + CMAKE_BUILD_TYPE:STRING=Debug + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + 2 + E:\FCMA\build-qt_client-Desktop_Qt_5_12_9_MinGW_64_bit-Debug + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=Release + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + 2 + E:\FCMA\build-qt_client-Desktop_Qt_5_12_9_MinGW_64_bit-Release + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=RelWithDebInfo + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + 2 + E:\FCMA\build-qt_client-Desktop_Qt_5_12_9_MinGW_64_bit-RelWithDebInfo + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release with Debug Information + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=MinSizeRel + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + 2 + E:\FCMA\build-qt_client-Desktop_Qt_5_12_9_MinGW_64_bit-MinSizeRel + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Minimum Size Release + CMakeProjectManager.CMakeBuildConfiguration + + 4 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + socket_cmd + CMakeProjectManager.CMakeRunConfiguration.socket_cmd + socket_cmd + + false + + false + true + true + false + false + true + + E:/FCMA/build-qt_client-Desktop_Qt_5_12_9_MinGW_64_bit-Release + + 1 + + + + ProjectExplorer.Project.Target.1 + + Qt 5.12.9 MinGW 64-bit + Qt 5.12.9 MinGW 64-bit + {f01e95f2-0cb5-451e-9e9e-b35e7a501b89} + 1 + 0 + 0 + + + CMAKE_BUILD_TYPE:STRING=Debug + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + 2 + E:\FCMA\qt_client\build + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=Release + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + 2 + E:\FCMA\build-qt_client-Qt_5_12_9_MinGW_64_bit-Release + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + CMakeProjectManager.CMakeBuildConfiguration + + 2 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + socket_cmd + CMakeProjectManager.CMakeRunConfiguration.socket_cmd + socket_cmd + + false + + false + true + true + false + false + true + + + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 6741c78..4d230ba 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -12,8 +12,7 @@ * */ MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent), ui(new Ui::MainWindow) -{ + : 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"); @@ -158,6 +157,40 @@ MainWindow::MainWindow(QWidget *parent) 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"); @@ -192,8 +225,7 @@ MainWindow::MainWindow(QWidget *parent) tcp_socket = nullptr; } -MainWindow::~MainWindow() -{ +MainWindow::~MainWindow() { stop_connet(); delete ui; } @@ -202,16 +234,13 @@ MainWindow::~MainWindow() * * 貌似加了ReuseAddressHint也没用 */ -void MainWindow::start_connet() -{ - if (tcp_socket == nullptr) - { +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) - { + while (retry < 10) { tcp_socket = new QTcpSocket(this); connect(tcp_socket, &QTcpSocket::connected, this, &MainWindow::connected); connect(tcp_socket, &QTcpSocket::readyRead, this, @@ -225,8 +254,7 @@ void MainWindow::start_connet() ui->le_port->text().toInt()); QAbstractSocket::SocketError error = tcp_socket->error(); - if (tcp_socket->error() == -1) - { + if (tcp_socket->error() == -1) { break; ; } @@ -239,8 +267,7 @@ void MainWindow::start_connet() tcp_socket = nullptr; retry++; } - if (retry == 10) - { + if (retry == 10) { tcp_socket->close(); delete tcp_socket; tcp_socket = nullptr; @@ -248,15 +275,12 @@ void MainWindow::start_connet() } } } -void MainWindow::connected() -{ +void MainWindow::connected() { ui->rb_con_sta->setCheckable(true); ui->rb_con_sta->setChecked(true); } -void MainWindow::stop_connet() -{ - if (tcp_socket != nullptr) - { +void MainWindow::stop_connet() { + if (tcp_socket != nullptr) { tcp_socket->disconnectFromHost(); tcp_socket->close(); delete tcp_socket; @@ -266,21 +290,77 @@ void MainWindow::stop_connet() ui->rb_con_sta->setCheckable(false); } -void MainWindow::send_cmd() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::receive_cmd() -{ + +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;" @@ -318,42 +398,34 @@ void MainWindow::receive_cmd() // ui->tb_msgbox->setTextColor(Qt::black); } -void MainWindow::cmd_help() -{ - if (tcp_socket != nullptr) - { +void MainWindow::cmd_help() { + if (tcp_socket != nullptr) { QString cmd = "help"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::cmd_read() -{ - if (tcp_socket != nullptr) - { +void MainWindow::cmd_read() { + if (tcp_socket != nullptr) { QString cmd = "msh_liq_workflow 4"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::revers_clean() -{ - if (tcp_socket != nullptr) - { +void MainWindow::revers_clean() { + if (tcp_socket != nullptr) { QString cmd = "msh_liq_workflow 6"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::wave_open() -{ - if (tcp_socket != nullptr) - { +void MainWindow::wave_open() { + if (tcp_socket != nullptr) { QString cmd = "set_delay_time_calc 1"; QByteArray data = cmd.toUtf8(); tcp_socket->write(data); @@ -361,20 +433,16 @@ void MainWindow::wave_open() } } -void MainWindow::wave_close() -{ - if (tcp_socket != nullptr) - { +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) - { +void MainWindow::cmd_fpga() { + if (tcp_socket != nullptr) { QString cmd = "test_set_gain_bias 0"; cmd += " "; cmd += ui->le_zy_ch1->text(); @@ -551,582 +619,472 @@ void MainWindow::cmd_fpga() } } } -void MainWindow::start_fpga() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::stop_fpga() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv17_open() -{ - if (tcp_socket != nullptr) - { +void MainWindow::sv17_open() { + if (tcp_socket != nullptr) { QString cmd = "msh_sv17 1"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv17_close() -{ - if (tcp_socket != nullptr) - { +void MainWindow::sv17_close() { + if (tcp_socket != nullptr) { QString cmd = "msh_sv17 0"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv18_open() -{ - if (tcp_socket != nullptr) - { +void MainWindow::sv18_open() { + if (tcp_socket != nullptr) { QString cmd = "msh_sv18 1"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv18_close() -{ - if (tcp_socket != nullptr) - { +void MainWindow::sv18_close() { + if (tcp_socket != nullptr) { QString cmd = "msh_sv18 0"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv20_open() -{ - if (tcp_socket != nullptr) - { +void MainWindow::sv20_open() { + if (tcp_socket != nullptr) { QString cmd = "msh_sv20 1"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv20_close() -{ - if (tcp_socket != nullptr) - { +void MainWindow::sv20_close() { + if (tcp_socket != nullptr) { QString cmd = "msh_sv20 0"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv21_open() -{ - if (tcp_socket != nullptr) - { +void MainWindow::sv21_open() { + if (tcp_socket != nullptr) { QString cmd = "msh_sv21 1"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv21_close() -{ - if (tcp_socket != nullptr) - { +void MainWindow::sv21_close() { + if (tcp_socket != nullptr) { QString cmd = "msh_sv21 0"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::p19_open() -{ - if (tcp_socket != nullptr) - { +void MainWindow::p19_open() { + if (tcp_socket != nullptr) { QString cmd = "msh_p19 1"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::p19_close() -{ - if (tcp_socket != nullptr) - { +void MainWindow::p19_close() { + if (tcp_socket != nullptr) { QString cmd = "msh_p19 0"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::p15_open() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::p15_close() -{ - if (tcp_socket != nullptr) - { +void MainWindow::p15_close() { + if (tcp_socket != nullptr) { QString cmd = "msh_p15 rotate_stop"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::rev1_open() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::rev1_close() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::p16_open() -{ - if (tcp_socket != nullptr) - { +void MainWindow::p16_open() { + if (tcp_socket != nullptr) { QString cmd = "msh_p16 70"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::p15_set_speed() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::rev1_set_speed() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::p16_close() -{ - if (tcp_socket != nullptr) - { +void MainWindow::p16_close() { + if (tcp_socket != nullptr) { QString cmd = "msh_p16 0"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::p18_open() -{ - if (tcp_socket != nullptr) - { +void MainWindow::p18_open() { + if (tcp_socket != nullptr) { QString cmd = "msh_p18 70"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::p18_close() -{ - if (tcp_socket != nullptr) - { +void MainWindow::p18_close() { + if (tcp_socket != nullptr) { QString cmd = "msh_p18 0"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::p17_backward() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::p17_forward_ext() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); // std::cout<<"cmd: "<le_p17_speed->text(); cmd += " 3000"; cmd += " 1"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::p17_forward() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::p17_close() -{ - if (tcp_socket != nullptr) - { +void MainWindow::p17_close() { + if (tcp_socket != nullptr) { QString cmd = "msh_p17 rotate_stop"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::pump_clean() -{ - if (tcp_socket != nullptr) - { +void MainWindow::pump_clean() { + if (tcp_socket != nullptr) { QString cmd = "msh_liq_workflow 7"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::fast_stop() -{ - if (tcp_socket != nullptr) - { +void MainWindow::fast_stop() { + if (tcp_socket != nullptr) { QString cmd = "stop"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::blue_laser_open() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::blue_laser_close() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::laser_blue_set_power_ref() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::red_laser_open() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::red_laser_close() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::laser_red_set_power_ref() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::z_go_zero() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::z_go_cyto() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::z_go_ret_mov() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::z_go_abs_mov() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::fulling() -{ - if (tcp_socket != nullptr) - { +void MainWindow::fulling() { + if (tcp_socket != nullptr) { QString cmd = "msh_liq_workflow 5"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::water_wash() -{ - if (tcp_socket != nullptr) - { +void MainWindow::water_wash() { + if (tcp_socket != nullptr) { QString cmd = "msh_liq_workflow 1"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::aco_wash() -{ - if (tcp_socket != nullptr) - { +void MainWindow::aco_wash() { + if (tcp_socket != nullptr) { QString cmd = "msh_liq_workflow 3"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::washliq_wash() -{ - if (tcp_socket != nullptr) - { +void MainWindow::washliq_wash() { + if (tcp_socket != nullptr) { QString cmd = "msh_liq_workflow 2"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + 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) - { +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() < 2) - { +void MainWindow::fpga_page_nxt() { + if (ui->fpga_set_page->currentIndex() < 2) { ui->fpga_set_page->setCurrentIndex(ui->fpga_set_page->currentIndex() + 1); } } -void MainWindow::open_test_data() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::close_test_data() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv_rev1_open() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv_rev1_close() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv_rev2_open() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv_rev2_close() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv_rev3_open() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sv_rev3_close() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::read_onebyone() -{ - if (tcp_socket != nullptr) - { +void MainWindow::read_onebyone() { + if (tcp_socket != nullptr) { p17_forward_ext(); tcp_socket->waitForBytesWritten(3000); _sleep(100); - { - _sleep(ui->le_delay_onebyone->text().toInt()); - } + { _sleep(ui->le_delay_onebyone->text().toInt()); } p15_open(); tcp_socket->waitForBytesWritten(3000); _sleep(100); @@ -1141,10 +1099,8 @@ void MainWindow::read_onebyone() _sleep(100); } } -void MainWindow::read_onebyone_stop() -{ - if (tcp_socket != nullptr) - { +void MainWindow::read_onebyone_stop() { + if (tcp_socket != nullptr) { p17_close(); tcp_socket->waitForBytesWritten(3000); _sleep(100); @@ -1160,48 +1116,38 @@ void MainWindow::read_onebyone_stop() } } -void MainWindow::fsc_open() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::random_open() -{ - if (tcp_socket != nullptr) - { +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->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::sw_test_prv() -{ - if (ui->sw_test->currentIndex() > 0) - { +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) - { +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) - { +void MainWindow::fast_draw() { + if (tcp_socket != nullptr) { sv_rev1_close(); tcp_socket->waitForBytesWritten(3000); _sleep(100); @@ -1219,15 +1165,13 @@ void MainWindow::fast_draw() cmd += "32000 "; cmd += "1"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::fast_draw_water() -{ - if (tcp_socket != nullptr) - { +void MainWindow::fast_draw_water() { + if (tcp_socket != nullptr) { sv_rev1_open(); tcp_socket->waitForBytesWritten(3000); _sleep(100); @@ -1245,15 +1189,13 @@ void MainWindow::fast_draw_water() cmd += "32000 "; cmd += "1"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::fast_push() -{ - if (tcp_socket != nullptr) - { +void MainWindow::fast_push() { + if (tcp_socket != nullptr) { sv_rev1_open(); tcp_socket->waitForBytesWritten(3000); _sleep(100); @@ -1272,15 +1214,13 @@ void MainWindow::fast_push() cmd += "0 "; cmd += "1"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::slow_push() -{ - if (tcp_socket != nullptr) - { +void MainWindow::slow_push() { + if (tcp_socket != nullptr) { sv_rev1_open(); tcp_socket->waitForBytesWritten(3000); _sleep(100); @@ -1293,17 +1233,15 @@ void MainWindow::slow_push() QString cmd = "msh_p17 rotate_start "; cmd += "1 "; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); - timer->setSingleShot(true); // 设置定时器为单次触发 + timer->setSingleShot(true); // 设置定时器为单次触发 timer->start(240000); } } void MainWindow::stop_the_pump() { p17_close(); } -void MainWindow::pump_reset() -{ - if (tcp_socket != nullptr) - { +void MainWindow::pump_reset() { + if (tcp_socket != nullptr) { QString cmd = "msh_p17 rotate_start_ext "; cmd += 1000; cmd += " 3000"; @@ -1315,27 +1253,23 @@ void MainWindow::pump_reset() _sleep(1000); // } } - if (tcp_socket != nullptr) - { + 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) - { + if (tcp_socket != nullptr) { QString cmd = "msh_p17 init "; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::clean_outer_pipe() -{ +void MainWindow::clean_outer_pipe() { printf("clean_outer_pipe\n"); - if (tcp_socket != nullptr) - { + if (tcp_socket != nullptr) { printf("clean_outer_pipe\n"); QString cmd = "msh_p19 1"; QByteArray data = cmd.toUtf8(); @@ -1346,8 +1280,7 @@ void MainWindow::clean_outer_pipe() tcp_socket->waitForBytesWritten(3000); _sleep(100); - for (int i = 0; i < 5; i++) - { + for (int i = 0; i < 5; i++) { z_go_cyto(); tcp_socket->waitForBytesWritten(3000); _sleep(2000); @@ -1364,10 +1297,8 @@ void MainWindow::clean_outer_pipe() } } -void MainWindow::p17_forward_1000() -{ - if (tcp_socket != nullptr) - { +void MainWindow::p17_forward_1000() { + if (tcp_socket != nullptr) { QString cmd = "msh_p17 move_ext "; cmd += "10000"; cmd += " "; @@ -1376,23 +1307,19 @@ void MainWindow::p17_forward_1000() cmd += "1000 "; cmd += "0"; QByteArray data = cmd.toUtf8(); - tcp_socket->write(data); + tcp_socket->write(data); tcp_socket->waitForBytesWritten(); } } -void MainWindow::clean_pipe() -{ - if (tcp_socket != nullptr) - { +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) - { + for (int i = 0; i < 5; i++) { + if (tcp_socket != nullptr) { fast_draw_water(); tcp_socket->waitForBytesWritten(3000); _sleep(5000); @@ -1419,17 +1346,14 @@ void MainWindow::clean_pipe() _sleep(5000); } } - if (tcp_socket != nullptr) - { + if (tcp_socket != nullptr) { p19_close(); tcp_socket->waitForBytesWritten(3000); _sleep(100); } } -void MainWindow::set_time_delay() -{ - if (tcp_socket != nullptr) - { +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(); @@ -1440,9 +1364,8 @@ void MainWindow::set_time_delay() } void MainWindow::choose_fpga_page() { ui->sw_config->setCurrentIndex(0); } void MainWindow::choose_pump_page() { ui->sw_config->setCurrentIndex(1); } - -void MainWindow::write_fpga_cfg() -{ +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()); @@ -1465,8 +1388,7 @@ void MainWindow::write_fpga_cfg() settings.setValue("p17_speed", ui->le_p17_speed->text()); settings.sync(); } -void MainWindow::read_fpga_cfg() -{ +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()); @@ -1487,4 +1409,162 @@ void MainWindow::read_fpga_cfg() 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); + } } \ No newline at end of file diff --git a/mainwindow.h b/mainwindow.h index 42ebcbe..da2f1cd 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -7,6 +7,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; @@ -105,6 +106,24 @@ class MainWindow : public QMainWindow { void read_fpga_cfg(); void wave_open(); void wave_close(); + void sipm_gain_menu(); + void sipm_gain_set_ssc(); + void sipm_gain_set_fl1(); + void sipm_gain_set_fl2(); + void sipm_gain_set_fl3(); + void sipm_gain_set_fl4(); + void sipm_gain_set_fl5(); + void sipm_gain_set_fl6(); + void sipm_gain_get_ssc(); + void sipm_gain_get_fl1(); + void sipm_gain_get_fl2(); + void sipm_gain_get_fl3(); + void sipm_gain_get_fl4(); + void sipm_gain_get_fl5(); + void sipm_gain_get_fl6(); + void show_sipm_gain(int ch, int gain); + void sipm_gain_get_one_click(); + void spim_gain_set_one_click(); private: Ui::MainWindow *ui; QTcpSocket *tcp_socket; diff --git a/mainwindow.ui b/mainwindow.ui index edc131d..4561a85 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 1360 - 1118 + 931 @@ -696,7 +696,7 @@ - 0 + 2 @@ -1202,6 +1202,201 @@ + + + + + + sipm增益调节 + + + + + + 获取 + + + + + + + FL6增益 + + + + + + + 获取 + + + + + + + FL2增益 + + + + + + + FL4增益 + + + + + + + + + + 获取 + + + + + + + 写入 + + + + + + + FL3增益 + + + + + + + + + + + + + 写入 + + + + + + + FL5增益 + + + + + + + 获取 + + + + + + + + + + + + + 获取 + + + + + + + 写入 + + + + + + + + + + 写入 + + + + + + + 写入 + + + + + + + 获取 + + + + + + + SSC增益: + + + + + + + + + + 获取 + + + + + + + 写入 + + + + + + + 写入 + + + + + + + FL1增益 + + + + + + + 一键获取增益 + + + + + + + 一键写入增益 + + + + + + + + @@ -1218,6 +1413,13 @@ + + + + sipm增益menu + + + @@ -1318,7 +1520,7 @@ background-color: rgb(108, 108, 108); 0 0 1360 - 26 + 23