调试工具:界面显示量程为1000mv

main
wangbo 3 weeks ago
parent b9e20bfe09
commit 3cd2ac7d84

@ -31,9 +31,9 @@ class WaveformPage(BasePage):
self.time_axis = np.linspace(0, self.sample_duration, self.sample_points)
# 纵轴配置
self.y_min = -30
self.y_max = 60
self.y_precision = 10
self.y_min = -1000
self.y_max = 1000
self.y_precision = 200
# 通道配置
self.channels = list(range(1, 9))
@ -43,6 +43,9 @@ class WaveformPage(BasePage):
self.selected_channel = tk.IntVar(value=1) # 默认选择通道1
self.previous_channel = 1 # 记录上一个通道
# 波形开启开关
self.wave_enabled = False
# 现在调用父类构造函数
super().__init__(parent, tcp_client, "实时波形")
@ -83,9 +86,8 @@ class WaveformPage(BasePage):
button_frame = ttk.Frame(control_frame)
button_frame.pack(fill=tk.X, pady=5)
ttk.Button(button_frame, text="开始接收", command=self.set_data, width=12).pack(side=tk.LEFT, padx=2)
# ttk.Button(button_frame, text="开始接收", command=self.start_udp, width=12).pack(side=tk.LEFT, padx=2)
ttk.Button(button_frame, text="停止接收", command=self.stop_udp, width=12).pack(side=tk.LEFT, padx=2)
ttk.Button(button_frame, text="开始接收", command=self.set_wave_address, width=12).pack(side=tk.LEFT, padx=2)
ttk.Button(button_frame, text="停止接收", command=self.clr_wave_address, width=12).pack(side=tk.LEFT, padx=2)
ttk.Button(button_frame, text="清空数据", command=self.clear_data, width=12).pack(side=tk.LEFT, padx=2)
ttk.Button(button_frame, text="自动缩放", command=self.auto_scale, width=12).pack(side=tk.LEFT, padx=2)
@ -155,7 +157,7 @@ class WaveformPage(BasePage):
# 纵轴刻度
y_major_ticks = np.arange(self.y_min, self.y_max + 1, self.y_precision) # 每10mV主刻度
y_minor_ticks = np.arange(self.y_min, self.y_max + 1, 2) # 每2mV次刻度
y_minor_ticks = np.arange(self.y_min, self.y_max + 1, 50) # 每2mV次刻度
self.ax.set_xticks(x_major_ticks)
self.ax.set_xticks(x_minor_ticks, minor=True)
@ -193,17 +195,36 @@ class WaveformPage(BasePage):
except Exception as e:
self.status_var.set(f"UDP设置失败: {e}")
def set_data(self):
def set_wave_address(self):
"""设置波形接收地址"""
try:
addr = DebugWaveAddress()
addr.wave_ipv4 = bytes(self.get_local_ip(), encoding='utf-8')
addr.wave_port = 10100
print(f"wave_ipv4: {addr.wave_ipv4} wave_port:{addr.wave_port}")
print(f"发送命令: {Cmd.SET_WAVE_ADDRESS}")
if not self.tcp_client.connected:
self.show_error("未连接设备")
return
self.wave_enabled = True
self.tcp_client.send_packet(Cmd.SET_WAVE_ADDRESS, addr.to_bytes())
except ValueError as e:
self.show_error(f"参数格式错误: {e}")
except Exception as e:
self.show_error(f"设置失败: {e}")
def clr_wave_address(self):
"""设置波形接收地址"""
try:
addr = DebugWaveAddress()
addr.wave_ipv4 = bytes(self.get_local_ip(), encoding='utf-8')
addr.wave_port = 10100
addr.wave_ipv4 = bytes(16)
addr.wave_port = 0
print(f"wave_ipv4: {addr.wave_ipv4} wave_port:{addr.wave_port}")
@ -211,7 +232,7 @@ class WaveformPage(BasePage):
if not self.tcp_client.connected:
self.show_error("未连接设备")
return
self.wave_enabled = False
self.tcp_client.send_packet(Cmd.SET_WAVE_ADDRESS, addr.to_bytes())
except ValueError as e:
@ -413,8 +434,12 @@ class WaveformPage(BasePage):
def on_set_response(self, header, body):
"""处理设置响应"""
if self.wave_enabled:
self.show_info("波形地址设置成功")
self.start_udp()
else:
elf.show_info("波形地址设置成功")
self.stop_udp()
def ip_to_int(self, ip):
parts = ip.split('.')

Loading…
Cancel
Save