USB设备端口识别监测嵌入式python3自动化测试脚本

news2026/3/17 13:54:33
软件版本python3编译器IDLE编译器库PyAutoGUl库cmd终端安装PyAutoGUl库命令pip install pyautogui一、应用场景简介嵌入式设备测试开发中开关机测试监控特定USB设备的连接状态变化记录USB端口连接断开次数其它。——多设备测试生产线测试自动化测试二、功能简介监测电脑设备管理器的端口的连接开机和断开关机记录连接和断开的次数。三、脚本GUI界面功能介绍使用配置好VOD,PID后下方第3点描述VID,PID查看方式点击开始监测停止监测。1.注使用前查看设备端口是否被正常识别端口是否可用。Ctrlx选择设备管理器查看CMO端口。2.日志保存路径D\0\test_log不清空之前的日志会保留之前的日志。监控设备配置功能板块可自行配置VID,PID下方第3点描述VID,PID查看方式输入后点击应用配置。设备状态功能板块显示端口名连接时长。本次监控统计功能板块记录连接次数断开次数监控状态设备连接断开状态检查频率为1s事件日志功能板块显示最新的设备连接断开信息。最底部为监控使用的按钮开始监控停止监控重置统计数量等。3.查看VIDPID快捷键ctalx设备管理器端口右键属性事件。代码如下。关注点赞欢迎留言评论区。备注日志一直在一个文档不删除历史日志一直累计有需可改import tkinter as tkfrom tkinter import ttkimport threadingimport timeimport sysimport osfrom datetime import datetimeimport jsontry:import serial.tools.list_portsimport serialSERIAL_AVAILABLE Trueexcept ImportError:SERIAL_AVAILABLE Falseprint(请先安装pyserial模块: pip install pyserial)# 目标设备的VID和PIDTARGET_VID 05C6TARGET_PID 902E# 日志保存路径LOG_DIR rD:\0\test_logLOG_FILE os.path.join(LOG_DIR, usb_monitor_log.txt)STATS_FILE os.path.join(LOG_DIR, usb_statistics.json)DAILY_LOG_DIR os.path.join(LOG_DIR, daily_logs)class USBMonitorApp:def __init__(self, root):self.root rootself.root.title(USB设备监控器 - 带日志保存)self.root.geometry(650x500)# 状态变量self.device_connected Falseself.monitoring_active Falseself.monitor_thread None# 本次监控统计从开始监控时清零self.session_connection_count 0 # 本次监控连接次数self.session_disconnection_count 0 # 本次监控断开次数self.session_start_time None # 本次监控开始时间self.session_running_time 0 # 本次监控运行时间秒# 设备连接时间记录self.device_connect_time Noneself.device_disconnect_time None# 日志列表self.log_entries []# 创建日志目录self.setup_log_directory()self.setup_ui()# 检查依赖if not SERIAL_AVAILABLE:self.show_error(请先安装pyserial模块:\n打开CMD并运行: pip install pyserial)return# 记录程序启动self.log_program_start()# 默认自动开始监控self.start_monitoring()def setup_log_directory(self):创建日志目录try:os.makedirs(LOG_DIR, exist_okTrue)os.makedirs(DAILY_LOG_DIR, exist_okTrue)print(f日志目录已创建: {LOG_DIR})except Exception as e:print(f创建日志目录失败: {e})def setup_ui(self):# 创建主框架main_frame ttk.Frame(self.root, padding10)main_frame.grid(row0, column0, sticky(tk.W, tk.E, tk.N, tk.S))# 标题和路径显示title_frame ttk.Frame(main_frame)title_frame.grid(row0, column0, columnspan3, pady(0, 10), sticky(tk.W, tk.E))title_label ttk.Label(title_frame, textUSB设备监控系统, font(Arial, 16, bold))title_label.grid(row0, column0, stickytk.W)# 显示日志路径log_path_label ttk.Label(title_frame, textf日志路径: {LOG_DIR}, font(Arial, 8), foregroundgray)log_path_label.grid(row1, column0, stickytk.W, pady(2, 0))# 设备信息info_frame ttk.LabelFrame(main_frame, text监控设备信息, padding10)info_frame.grid(row1, column0, columnspan3, sticky(tk.W, tk.E), pady(0, 10))ttk.Label(info_frame, textVID:).grid(row0, column0, stickytk.W)ttk.Label(info_frame, textTARGET_VID, font(Arial, 10, bold), foregroundblue).grid(row0, column1, stickytk.W, padx(5, 20))ttk.Label(info_frame, textPID:).grid(row0, column2, stickytk.W)ttk.Label(info_frame, textTARGET_PID, font(Arial, 10, bold), foregroundblue).grid(row0, column3, stickytk.W, padx(5, 0))# 状态显示status_frame ttk.LabelFrame(main_frame, text设备状态, padding10)status_frame.grid(row2, column0, columnspan3, sticky(tk.W, tk.E), pady(0, 10))self.status_label ttk.Label(status_frame, text正在检测..., font(Arial, 12))self.status_label.grid(row0, column0, stickytk.W, padx(10, 20))self.status_indicator tk.Canvas(status_frame, width20, height20, bggray)self.status_indicator.grid(row0, column1, stickytk.W)# 当前连接时长显示self.connection_duration_label ttk.Label(status_frame, text连接时长: --:--:--, font(Arial, 9))self.connection_duration_label.grid(row0, column2, stickytk.W, padx(30, 0))# 连接统计本次监控count_frame ttk.LabelFrame(main_frame, text本次监控统计, padding10)count_frame.grid(row3, column0, columnspan3, sticky(tk.W, tk.E), pady(0, 10))# 连接次数ttk.Label(count_frame, text连接次数:).grid(row0, column0, stickytk.W)self.connection_label ttk.Label(count_frame, text0, font(Arial, 12, bold), foregroundgreen)self.connection_label.grid(row0, column1, stickytk.W, padx(5, 30))# 断开次数ttk.Label(count_frame, text断开次数:).grid(row0, column2, stickytk.W)self.disconnection_label ttk.Label(count_frame, text0, font(Arial, 12, bold), foregroundred)self.disconnection_label.grid(row0, column3, stickytk.W, padx(5, 0))# 运行时间ttk.Label(count_frame, text运行时间:).grid(row0, column4, stickytk.W, padx(20, 5))self.runtime_label ttk.Label(count_frame, text00:00:00, font(Arial, 10, bold))self.runtime_label.grid(row0, column5, stickytk.W)# 监控状态ttk.Label(count_frame, text监控状态:).grid(row1, column0, stickytk.W, pady(5, 0))self.monitoring_status_label ttk.Label(count_frame, text未开始, font(Arial, 10, bold))self.monitoring_status_label.grid(row1, column1, stickytk.W, padx(5, 30), pady(5, 0))# 当前状态ttk.Label(count_frame, text设备状态:).grid(row1, column2, stickytk.W, pady(5, 0))self.device_status_label ttk.Label(count_frame, text未知, font(Arial, 10, bold))self.device_status_label.grid(row1, column3, stickytk.W, padx(5, 0), pady(5, 0))# 检查频率ttk.Label(count_frame, text检查频率:).grid(row1, column4, stickytk.W, padx(20, 5), pady(5, 0))self.check_freq_label ttk.Label(count_frame, text1秒, font(Arial, 10, bold))self.check_freq_label.grid(row1, column5, stickytk.W, pady(5, 0))# 日志区域log_frame ttk.LabelFrame(main_frame, text事件日志, padding10)log_frame.grid(row4, column0, columnspan3, sticky(tk.W, tk.E, tk.N, tk.S), pady(0, 10))# 创建日志框架self.log_frame_inner ttk.Frame(log_frame)self.log_frame_inner.pack(filltk.BOTH, expandTrue)# 创建滚动条scrollbar ttk.Scrollbar(self.log_frame_inner)scrollbar.pack(sidetk.RIGHT, filltk.Y)# 创建日志文本框self.log_text tk.Text(self.log_frame_inner,height10,width70,yscrollcommandscrollbar.set,bg#f5f5f5,relieftk.FLAT,font(Consolas, 9))self.log_text.pack(sidetk.LEFT, filltk.BOTH, expandTrue)scrollbar.config(commandself.log_text.yview)# 控制按钮button_frame ttk.Frame(main_frame)button_frame.grid(row5, column0, columnspan3, pady(10, 0))self.start_button ttk.Button(button_frame, text▶ 开始监控, commandself.start_monitoring)self.start_button.grid(row0, column0, padx(0, 10))self.stop_button ttk.Button(button_frame, text■ 停止监控, commandself.stop_monitoring, statedisabled)self.stop_button.grid(row0, column1, padx(0, 10))self.reset_button ttk.Button(button_frame, text 重置统计, commandself.reset_statistics)self.reset_button.grid(row0, column2, padx(0, 10))self.clear_button ttk.Button(button_frame, text️ 清空日志, commandself.clear_log)self.clear_button.grid(row0, column3, padx(0, 10))self.copy_button ttk.Button(button_frame, text 复制日志, commandself.copy_log)self.copy_button.grid(row0, column4, padx(0, 10))self.save_button ttk.Button(button_frame, text 保存日志, commandself.save_log)self.save_button.grid(row0, column5, padx(0, 10))self.view_button ttk.Button(button_frame, text 打开日志, commandself.open_log_folder)self.view_button.grid(row0, column6, padx(0, 10))self.quit_button ttk.Button(button_frame, text✕ 退出, commandself.quit_app)self.quit_button.grid(row0, column7)# 配置网格权重self.root.columnconfigure(0, weight1)self.root.rowconfigure(0, weight1)main_frame.columnconfigure(0, weight1)main_frame.rowconfigure(4, weight1)# 初始化运行时间更新self.update_runtime()self.update_connection_duration()def update_runtime(self):更新运行时间if self.monitoring_active and self.session_start_time:elapsed int(time.time() - self.session_start_time)self.session_running_time elapsedhours elapsed // 3600minutes (elapsed % 3600) // 60seconds elapsed % 60self.runtime_label.config(textf{hours:02d}:{minutes:02d}:{seconds:02d})# 每秒更新一次self.root.after(1000, self.update_runtime)def update_connection_duration(self):更新连接时长if self.device_connected and self.device_connect_time:elapsed int(time.time() - self.device_connect_time)hours elapsed // 3600minutes (elapsed % 3600) // 60seconds elapsed % 60self.connection_duration_label.config(textf连接时长: {hours:02d}:{minutes:02d}:{seconds:02d})else:self.connection_duration_label.config(text连接时长: --:--:--)# 每秒更新一次self.root.after(1000, self.update_connection_duration)def check_device(self):检查目标设备是否连接try:ports serial.tools.list_ports.comports()for port in ports:if hasattr(port, vid) and port.vid:vid_hex f{port.vid:04X}.upper()pid_hex f{port.pid:04X}.upper() if port.pid else 0000if vid_hex TARGET_VID and pid_hex TARGET_PID:return True, port.device, port.descriptionreturn False, None, Noneexcept Exception as e:self.log_event(f检查设备时出错: {str(e)}, error)return False, None, Nonedef update_status(self, connected, port_infoNone, descriptionNone):更新UI状态current_status connected if connected else disconnectedif connected and not self.device_connected:# 设备刚刚连接self.session_connection_count 1self.device_connected Trueself.device_connect_time time.time()# 更新UIself.status_label.config(textf已连接 - {port_info})self.status_indicator.config(bggreen)self.connection_label.config(textstr(self.session_connection_count))self.device_status_label.config(text已连接, foregroundgreen)# 保存到文件timestamp datetime.now().strftime(%Y-%m-%d %H:%M:%S)log_entry f[{timestamp}] 设备连接 - 端口: {port_info}, 描述: {description}self.log_event(f[{timestamp}] ✓ 设备已连接 - 端口: {port_info}, 描述: {description}, connect)self.save_to_log_file(log_entry, CONNECT)# 播放连接提示音self.root.bell()elif not connected and self.device_connected:# 设备刚刚断开self.session_disconnection_count 1self.device_connected False# 计算连接时长duration if self.device_connect_time:connect_duration int(time.time() - self.device_connect_time)hours connect_duration // 3600minutes (connect_duration % 3600) // 60seconds connect_duration % 60duration f (连接时长: {hours:02d}:{minutes:02d}:{seconds:02d})self.device_connect_time None# 更新UIself.status_label.config(text未连接)self.status_indicator.config(bgred)self.disconnection_label.config(textstr(self.session_disconnection_count))self.device_status_label.config(text未连接, foregroundred)# 保存到文件timestamp datetime.now().strftime(%Y-%m-%d %H:%M:%S)log_entry f[{timestamp}] 设备断开{duration}self.log_event(f[{timestamp}] ✗ 设备已断开{duration}, disconnect)self.save_to_log_file(log_entry, DISCONNECT)# 播放断开提示音self.root.bell()elif connected and self.device_connected:# 设备保持连接状态self.status_label.config(textf已连接 - {port_info})self.status_indicator.config(bggreen)self.device_status_label.config(text已连接, foregroundgreen)else:# 设备保持断开状态self.status_label.config(text未连接)self.status_indicator.config(bgred)self.device_status_label.config(text未连接, foregroundred)# 保存统计数据self.save_statistics()def reset_statistics(self):重置统计信息if self.monitoring_active:response tk.messagebox.askyesno(确认, 监控正在进行中重置统计将清空当前数据。\n是否继续)if not response:return# 重置统计self.session_connection_count 0self.session_disconnection_count 0self.session_running_time 0# 更新UIself.connection_label.config(text0)self.disconnection_label.config(text0)self.runtime_label.config(text00:00:00)self.status_label.config(text未连接)self.status_indicator.config(bggray)self.device_status_label.config(text未知)self.connection_duration_label.config(text连接时长: --:--:--)# 清空日志self.clear_log()timestamp datetime.now().strftime(%Y-%m-%d %H:%M:%S)self.log_event(f[{timestamp}] 统计信息已重置, info)# 如果是监控中重新开始计时if self.monitoring_active:self.session_start_time time.time()self.log_event(f[{timestamp}] ⏱️ 监控计时已重置, info)def save_to_log_file(self, message, event_type):保存日志到文件try:# 保存到主日志文件with open(LOG_FILE, a, encodingutf-8) as f:f.write(f{message}\n)# 保存到每日日志文件today datetime.now().strftime(%Y%m%d)daily_log_file os.path.join(DAILY_LOG_DIR, fusb_log_{today}.txt)with open(daily_log_file, a, encodingutf-8) as f:f.write(f{message}\n)except Exception as e:self.log_event(f保存日志到文件失败: {str(e)}, error)def save_to_detailed_log(self, data):保存详细日志JSON格式try:detailed_log {timestamp: datetime.now().strftime(%Y-%m-%d %H:%M:%S),event: data.get(event),port: data.get(port),description: data.get(description),duration: data.get(duration),session_connections: self.session_connection_count,session_disconnections: self.session_disconnection_count,session_runtime: self.session_running_time}today datetime.now().strftime(%Y%m%d)detailed_log_file os.path.join(DAILY_LOG_DIR, fdetailed_log_{today}.json)# 读取现有数据或创建新列表if os.path.exists(detailed_log_file):with open(detailed_log_file, r, encodingutf-8) as f:logs json.load(f)else:logs []# 添加新日志logs.append(detailed_log)# 保存回文件with open(detailed_log_file, w, encodingutf-8) as f:json.dump(logs, f, ensure_asciiFalse, indent2)except Exception as e:self.log_event(f保存详细日志失败: {str(e)}, error)def log_event(self, message, event_typeinfo):添加日志条目到UItimestamp datetime.now().strftime(%H:%M:%S)# 为不同事件类型设置不同颜色if event_type connect:tag_color greenelif event_type disconnect:tag_color redelif event_type error:tag_color orangeelse:tag_color black# 插入带时间戳的日志self.log_text.insert(tk.END, message \n)# 为最近的消息设置颜色标签start_index self.log_text.search(message.split(\n)[0], end-1c linestart, stopindex1.0)if start_index:end_index f{start_index}{len(message)}cself.log_text.tag_add(event_type, start_index, end_index)self.log_text.tag_config(event_type, foregroundtag_color)self.log_text.see(tk.END) # 自动滚动到底部# 保存到日志列表self.log_entries.append(message)def load_statistics(self):加载历史统计数据现在只用于读取不影响本次监控统计try:if os.path.exists(STATS_FILE):with open(STATS_FILE, r, encodingutf-8) as f:stats json.load(f)# 只读取不用于显示total_connections stats.get(total_connections, 0)total_disconnections stats.get(total_disconnections, 0)# 记录到日志但不显示在UItimestamp datetime.now().strftime(%H:%M:%S)self.log_event(f[{timestamp}] 历史统计: 总连接 {total_connections} 次, 总断开 {total_disconnections} 次, info)except Exception as e:self.log_event(f读取历史统计失败: {str(e)}, error)def save_statistics(self):保存统计数据try:# 读取现有统计数据if os.path.exists(STATS_FILE):with open(STATS_FILE, r, encodingutf-8) as f:stats json.load(f)else:stats {}# 更新统计数据total_connections stats.get(total_connections, 0) self.session_connection_counttotal_disconnections stats.get(total_disconnections, 0) self.session_disconnection_countstats.update({total_connections: total_connections,total_disconnections: total_disconnections,last_updated: datetime.now().strftime(%Y-%m-%d %H:%M:%S),last_session_connections: self.session_connection_count,last_session_disconnections: self.session_disconnection_count,last_session_runtime: self.session_running_time})with open(STATS_FILE, w, encodingutf-8) as f:json.dump(stats, f, ensure_asciiFalse, indent2)except Exception as e:self.log_event(f保存统计数据失败: {str(e)}, error)def log_program_start(self):记录程序启动try:start_time datetime.now().strftime(%Y-%m-%d %H:%M:%S)log_entry f[{start_time}] 程序启动 # 保存到日志文件with open(LOG_FILE, a, encodingutf-8) as f:f.write(f\n{log_entry}\n)# 在UI中显示self.log_event(f[{datetime.now().strftime(%H:%M:%S)}] ✅ 程序启动 - 日志保存到: {LOG_DIR}, info)# 加载历史统计仅显示self.load_statistics()except Exception as e:self.log_event(f记录程序启动失败: {str(e)}, error)def clear_log(self):清空日志self.log_text.delete(1.0, tk.END)self.log_entries.clear()self.log_event(f[{datetime.now().strftime(%H:%M:%S)}] 日志已清空, info)def copy_log(self):复制日志到剪贴板try:log_content self.log_text.get(1.0, tk.END).strip()if log_content:self.root.clipboard_clear()self.root.clipboard_append(log_content)self.log_event(f[{datetime.now().strftime(%H:%M:%S)}] 日志已复制到剪贴板, info)except Exception as e:self.log_event(f复制日志时出错: {str(e)}, error)def save_log(self):手动保存日志try:timestamp datetime.now().strftime(%Y%m%d_%H%M%S)manual_log_file os.path.join(LOG_DIR, fmanual_save_{timestamp}.txt)with open(manual_log_file, w, encodingutf-8) as f:f.write(self.log_text.get(1.0, tk.END))self.log_event(f[{datetime.now().strftime(%H:%M:%S)}] 日志已手动保存到: {manual_log_file}, info)except Exception as e:self.log_event(f保存日志失败: {str(e)}, error)def open_log_folder(self):打开日志文件夹try:os.startfile(LOG_DIR)self.log_event(f[{datetime.now().strftime(%H:%M:%S)}] 已打开日志文件夹, info)except Exception as e:self.log_event(f打开日志文件夹失败: {str(e)}, error)def monitor_loop(self):监控循环check_interval 1 # 检查间隔(秒)while self.monitoring_active:try:connected, port, description self.check_device()# 在UI线程中更新状态self.root.after(0, lambda cconnected, pport, ddescription: self.update_status(c, p, d))# 等待下次检查for _ in range(check_interval * 10):if not self.monitoring_active:breaktime.sleep(0.1)except Exception as e:self.root.after(0, lambda: self.log_event(f监控循环错误: {str(e)}, error))time.sleep(check_interval)def start_monitoring(self):开始监控if self.monitoring_active:returnself.monitoring_active Trueself.session_start_time time.time()self.start_button.config(statedisabled)self.stop_button.config(statenormal)self.monitoring_status_label.config(text运行中, foregroundgreen)# 记录监控开始时间self.current_session_start datetime.now()self.save_to_log_file(f[{self.current_session_start.strftime(%Y-%m-%d %H:%M:%S)}] 监控开始, INFO)# 初始检查connected, port, description self.check_device()self.update_status(connected, port, description)# 启动监控线程self.monitor_thread threading.Thread(targetself.monitor_loop, daemonTrue)self.monitor_thread.start()timestamp datetime.now().strftime(%Y-%m-%d %H:%M:%S)self.log_event(f[{timestamp}] ✅ 开始监控设备 VID:{TARGET_VID}, PID:{TARGET_PID}, info)self.log_event(f[{timestamp}] 统计从此刻开始: 连接次数{self.session_connection_count}, 断开次数{self.session_disconnection_count}, 运行时间00:00:00, info)def stop_monitoring(self):停止监控if not self.monitoring_active:returnself.monitoring_active Falseself.start_button.config(statenormal)self.stop_button.config(statedisabled)self.monitoring_status_label.config(text已停止, foregroundred)# 记录监控结束时间if self.session_start_time:duration int(time.time() - self.session_start_time)hours duration // 3600minutes (duration % 3600) // 60seconds duration % 60duration_str f{hours:02d}:{minutes:02d}:{seconds:02d}self.save_to_log_file(f[{datetime.now().strftime(%Y-%m-%d %H:%M:%S)}] 监控结束 (本次运行时长: {duration_str}, 连接: {self.session_connection_count}, 断开: {self.session_disconnection_count}), INFO)if self.monitor_thread:self.monitor_thread.join(timeout2)timestamp datetime.now().strftime(%Y-%m-%d %H:%M:%S)self.log_event(f[{timestamp}] ⏹️ 停止监控, info)self.log_event(f[{timestamp}] 本次监控统计: 连接次数{self.session_connection_count}, 断开次数{self.session_disconnection_count}, 运行时间{self.runtime_label.cget(text)}, info)# 保存统计数据self.save_statistics()def show_error(self, message):显示错误信息在日志区域error_msg f[{datetime.now().strftime(%H:%M:%S)}] ❌ 错误: {message}self.log_event(error_msg, error)def quit_app(self):退出应用程序# 记录程序关闭try:end_time datetime.now().strftime(%Y-%m-%d %H:%M:%S)log_entry f[{end_time}] 程序关闭 \nwith open(LOG_FILE, a, encodingutf-8) as f:f.write(f{log_entry}\n)except:pass# 保存统计数据self.save_statistics()# 停止监控self.stop_monitoring()# 关闭窗口self.root.quit()self.root.destroy()def on_closing(self):窗口关闭事件处理self.quit_app()def main():if not SERIAL_AVAILABLE:print(请先安装pyserial模块: pip install pyserial)input(按Enter键退出...)returnroot tk.Tk()# 设置窗口样式root.style ttk.Style()root.style.theme_use(clam)app USBMonitorApp(root)# 设置窗口关闭事件root.protocol(WM_DELETE_WINDOW, app.on_closing)# 设置窗口图标可选try:root.iconbitmap(defaulticon.ico)except:passroot.mainloop()if __name__ __main__:main()

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2419611.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

SpringBoot-17-MyBatis动态SQL标签之常用标签

文章目录 1 代码1.1 实体User.java1.2 接口UserMapper.java1.3 映射UserMapper.xml1.3.1 标签if1.3.2 标签if和where1.3.3 标签choose和when和otherwise1.4 UserController.java2 常用动态SQL标签2.1 标签set2.1.1 UserMapper.java2.1.2 UserMapper.xml2.1.3 UserController.ja…

wordpress后台更新后 前端没变化的解决方法

使用siteground主机的wordpress网站,会出现更新了网站内容和修改了php模板文件、js文件、css文件、图片文件后,网站没有变化的情况。 不熟悉siteground主机的新手,遇到这个问题,就很抓狂,明明是哪都没操作错误&#x…

网络编程(Modbus进阶)

思维导图 Modbus RTU(先学一点理论) 概念 Modbus RTU 是工业自动化领域 最广泛应用的串行通信协议,由 Modicon 公司(现施耐德电气)于 1979 年推出。它以 高效率、强健性、易实现的特点成为工业控制系统的通信标准。 包…

UE5 学习系列(二)用户操作界面及介绍

这篇博客是 UE5 学习系列博客的第二篇,在第一篇的基础上展开这篇内容。博客参考的 B 站视频资料和第一篇的链接如下: 【Note】:如果你已经完成安装等操作,可以只执行第一篇博客中 2. 新建一个空白游戏项目 章节操作,重…

IDEA运行Tomcat出现乱码问题解决汇总

最近正值期末周,有很多同学在写期末Java web作业时,运行tomcat出现乱码问题,经过多次解决与研究,我做了如下整理: 原因: IDEA本身编码与tomcat的编码与Windows编码不同导致,Windows 系统控制台…

利用最小二乘法找圆心和半径

#include <iostream> #include <vector> #include <cmath> #include <Eigen/Dense> // 需安装Eigen库用于矩阵运算 // 定义点结构 struct Point { double x, y; Point(double x_, double y_) : x(x_), y(y_) {} }; // 最小二乘法求圆心和半径 …

使用docker在3台服务器上搭建基于redis 6.x的一主两从三台均是哨兵模式

一、环境及版本说明 如果服务器已经安装了docker,则忽略此步骤,如果没有安装,则可以按照一下方式安装: 1. 在线安装(有互联网环境): 请看我这篇文章 传送阵>> 点我查看 2. 离线安装(内网环境):请看我这篇文章 传送阵>> 点我查看 说明&#xff1a;假设每台服务器已…

XML Group端口详解

在XML数据映射过程中&#xff0c;经常需要对数据进行分组聚合操作。例如&#xff0c;当处理包含多个物料明细的XML文件时&#xff0c;可能需要将相同物料号的明细归为一组&#xff0c;或对相同物料号的数量进行求和计算。传统实现方式通常需要编写脚本代码&#xff0c;增加了开…

LBE-LEX系列工业语音播放器|预警播报器|喇叭蜂鸣器的上位机配置操作说明

LBE-LEX系列工业语音播放器|预警播报器|喇叭蜂鸣器专为工业环境精心打造&#xff0c;完美适配AGV和无人叉车。同时&#xff0c;集成以太网与语音合成技术&#xff0c;为各类高级系统&#xff08;如MES、调度系统、库位管理、立库等&#xff09;提供高效便捷的语音交互体验。 L…

(LeetCode 每日一题) 3442. 奇偶频次间的最大差值 I (哈希、字符串)

题目&#xff1a;3442. 奇偶频次间的最大差值 I 思路 &#xff1a;哈希&#xff0c;时间复杂度0(n)。 用哈希表来记录每个字符串中字符的分布情况&#xff0c;哈希表这里用数组即可实现。 C版本&#xff1a; class Solution { public:int maxDifference(string s) {int a[26]…

【大模型RAG】拍照搜题技术架构速览:三层管道、两级检索、兜底大模型

摘要 拍照搜题系统采用“三层管道&#xff08;多模态 OCR → 语义检索 → 答案渲染&#xff09;、两级检索&#xff08;倒排 BM25 向量 HNSW&#xff09;并以大语言模型兜底”的整体框架&#xff1a; 多模态 OCR 层 将题目图片经过超分、去噪、倾斜校正后&#xff0c;分别用…

【Axure高保真原型】引导弹窗

今天和大家中分享引导弹窗的原型模板&#xff0c;载入页面后&#xff0c;会显示引导弹窗&#xff0c;适用于引导用户使用页面&#xff0c;点击完成后&#xff0c;会显示下一个引导弹窗&#xff0c;直至最后一个引导弹窗完成后进入首页。具体效果可以点击下方视频观看或打开下方…

接口测试中缓存处理策略

在接口测试中&#xff0c;缓存处理策略是一个关键环节&#xff0c;直接影响测试结果的准确性和可靠性。合理的缓存处理策略能够确保测试环境的一致性&#xff0c;避免因缓存数据导致的测试偏差。以下是接口测试中常见的缓存处理策略及其详细说明&#xff1a; 一、缓存处理的核…

龙虎榜——20250610

上证指数放量收阴线&#xff0c;个股多数下跌&#xff0c;盘中受消息影响大幅波动。 深证指数放量收阴线形成顶分型&#xff0c;指数短线有调整的需求&#xff0c;大概需要一两天。 2025年6月10日龙虎榜行业方向分析 1. 金融科技 代表标的&#xff1a;御银股份、雄帝科技 驱动…

观成科技:隐蔽隧道工具Ligolo-ng加密流量分析

1.工具介绍 Ligolo-ng是一款由go编写的高效隧道工具&#xff0c;该工具基于TUN接口实现其功能&#xff0c;利用反向TCP/TLS连接建立一条隐蔽的通信信道&#xff0c;支持使用Let’s Encrypt自动生成证书。Ligolo-ng的通信隐蔽性体现在其支持多种连接方式&#xff0c;适应复杂网…

铭豹扩展坞 USB转网口 突然无法识别解决方法

当 USB 转网口扩展坞在一台笔记本上无法识别,但在其他电脑上正常工作时,问题通常出在笔记本自身或其与扩展坞的兼容性上。以下是系统化的定位思路和排查步骤,帮助你快速找到故障原因: 背景: 一个M-pard(铭豹)扩展坞的网卡突然无法识别了,扩展出来的三个USB接口正常。…

未来机器人的大脑:如何用神经网络模拟器实现更智能的决策?

编辑&#xff1a;陈萍萍的公主一点人工一点智能 未来机器人的大脑&#xff1a;如何用神经网络模拟器实现更智能的决策&#xff1f;RWM通过双自回归机制有效解决了复合误差、部分可观测性和随机动力学等关键挑战&#xff0c;在不依赖领域特定归纳偏见的条件下实现了卓越的预测准…

Linux应用开发之网络套接字编程(实例篇)

服务端与客户端单连接 服务端代码 #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <pthread.h> …

华为云AI开发平台ModelArts

华为云ModelArts&#xff1a;重塑AI开发流程的“智能引擎”与“创新加速器”&#xff01; 在人工智能浪潮席卷全球的2025年&#xff0c;企业拥抱AI的意愿空前高涨&#xff0c;但技术门槛高、流程复杂、资源投入巨大的现实&#xff0c;却让许多创新构想止步于实验室。数据科学家…

深度学习在微纳光子学中的应用

深度学习在微纳光子学中的主要应用方向 深度学习与微纳光子学的结合主要集中在以下几个方向&#xff1a; 逆向设计 通过神经网络快速预测微纳结构的光学响应&#xff0c;替代传统耗时的数值模拟方法。例如设计超表面、光子晶体等结构。 特征提取与优化 从复杂的光学数据中自…