From d0d1fc8098660c76475fb6425f630fb84e05c168 Mon Sep 17 00:00:00 2001 From: pandx Date: Thu, 13 Nov 2025 11:02:38 +0800 Subject: [PATCH] fix LSB_32BIT bug and set keep alive option --- SamplingDialog.py | 3 ++- mainwindow.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/SamplingDialog.py b/SamplingDialog.py index 55cbf75..d1fed93 100644 --- a/SamplingDialog.py +++ b/SamplingDialog.py @@ -742,7 +742,8 @@ class CalibrationDialog(QDialog): def process_wave_packet(self, wave_data): data = wave_data # 接收所有数据 data = np.frombuffer(data, dtype=np.int32) # 根据实际数据格式转换 - LSB_32BIT = (2.8 / (2 ** 31)) * ((750 + 287) / 287) * 1000 / 10.2 + LSB_32BIT = (2.8 / (2 ** 31)) * ((750 + 249) / 249) * 1000 / 10.2 + # LSB_32BIT = (2.8 / (2 ** 31)) * ((750 + 287) / 287) * 1000 / 10.2 self.scaled_data = data * LSB_32BIT result = self.get_extremes(self.scaled_data) diff --git a/mainwindow.py b/mainwindow.py index f628813..d01b090 100644 --- a/mainwindow.py +++ b/mainwindow.py @@ -8,6 +8,7 @@ from typing import Tuple, Optional import matplotlib import matplotlib.pyplot as plt from PyQt5.QtCore import QTimer +from PyQt5.QtNetwork import QAbstractSocket from PyQt5.QtWidgets import QFrame, QStatusBar, QSizePolicy, QFileDialog, QApplication, QMainWindow, QWidget, QAction from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas, NavigationToolbar2QT from scipy.fft import fft, fftfreq @@ -403,6 +404,8 @@ class SocketClientApp(QMainWindow): port = int(self.port_input.text()) self.socket.abort() self.socket.connectToHost(ip, port) + # 设置 TCP Keep-Alive + self.socket.setSocketOption(QAbstractSocket.KeepAliveOption, True) def on_socket_connected(self): self.status_bar.showMessage("状态: 连接成功")