[feat] update data process, add item of xxx_institute
This commit is contained in:
parent
981a47baa8
commit
8e45f42944
@ -33,9 +33,9 @@ class ModbusGasAnalyzer:
|
||||
except Exception as e:
|
||||
print(f"设置图标失败: {e}")
|
||||
|
||||
# 设置黄金比例窗口大小 (800x495)
|
||||
# 设置黄金比例窗口大小 (800x480)
|
||||
window_width = 800
|
||||
window_height = 495
|
||||
window_height = 480
|
||||
self.root.geometry(f"{window_width}x{window_height}")
|
||||
self.root.configure(bg=self.custom_blue)
|
||||
|
||||
@ -59,7 +59,10 @@ class ModbusGasAnalyzer:
|
||||
"样品信息": "",
|
||||
"出厂日期": "",
|
||||
"产品型号": "",
|
||||
"编号": ""
|
||||
"编号": "",
|
||||
"测试单位": "",
|
||||
"生产单位": "",
|
||||
"送样单位": "",
|
||||
}
|
||||
|
||||
# 创建页面
|
||||
@ -83,17 +86,17 @@ class ModbusGasAnalyzer:
|
||||
|
||||
# 左侧内容
|
||||
# 测试人员
|
||||
tk.Label(left_frame, text="测试人员:", font=('Arial', 12), bg=self.custom_blue).pack(anchor='w', pady=5)
|
||||
tk.Label(left_frame, text="测试人员:", font=('Arial', 12), bg=self.custom_blue).grid(row=0, column=0, sticky='w', pady=10, padx=(30, 20))
|
||||
self.tester_entry = tk.Entry(left_frame, font=('Arial', 12), width=20)
|
||||
self.tester_entry.pack(fill='x', pady=5)
|
||||
self.tester_entry.grid(row=0, column=1, sticky='ew', pady=10)
|
||||
# 保留之前填写的信息
|
||||
if self.user_info["测试人员"]:
|
||||
self.tester_entry.insert(0, self.user_info["测试人员"])
|
||||
|
||||
# 测试时间
|
||||
tk.Label(left_frame, text="测试时间:", font=('Arial', 12), bg=self.custom_blue).pack(anchor='w', pady=5)
|
||||
tk.Label(left_frame, text="测试时间:", font=('Arial', 12), bg=self.custom_blue).grid(row=1, column=0, sticky='w', pady=10, padx=(30, 20))
|
||||
self.test_time_entry = tk.Entry(left_frame, font=('Arial', 12), width=20)
|
||||
self.test_time_entry.pack(fill='x', pady=5)
|
||||
self.test_time_entry.grid(row=1, column=1, sticky='ew', pady=10)
|
||||
# 自动填入当前时间,但如果已有信息则保留
|
||||
if self.user_info["测试时间"]:
|
||||
self.test_time_entry.insert(0, self.user_info["测试时间"])
|
||||
@ -102,33 +105,54 @@ class ModbusGasAnalyzer:
|
||||
self.test_time_entry.insert(0, current_time)
|
||||
|
||||
# 样品信息
|
||||
tk.Label(left_frame, text="样品信息:", font=('Arial', 12), bg=self.custom_blue).pack(anchor='w', pady=5)
|
||||
tk.Label(left_frame, text="样品信息:", font=('Arial', 12), bg=self.custom_blue).grid(row=2, column=0, sticky='w', pady=10, padx=(30, 20))
|
||||
self.sample_info_entry = tk.Entry(left_frame, font=('Arial', 12), width=20)
|
||||
self.sample_info_entry.pack(fill='x', pady=5)
|
||||
self.sample_info_entry.grid(row=2, column=1, sticky='ew', pady=10)
|
||||
if self.user_info["样品信息"]:
|
||||
self.sample_info_entry.insert(0, self.user_info["样品信息"])
|
||||
|
||||
# 出厂日期
|
||||
tk.Label(left_frame, text="出厂日期:", font=('Arial', 12), bg=self.custom_blue).pack(anchor='w', pady=5)
|
||||
tk.Label(left_frame, text="出厂日期:", font=('Arial', 12), bg=self.custom_blue).grid(row=3, column=0, sticky='w', pady=10, padx=(30, 20))
|
||||
self.production_date_entry = tk.Entry(left_frame, font=('Arial', 12), width=20)
|
||||
self.production_date_entry.pack(fill='x', pady=5)
|
||||
self.production_date_entry.grid(row=3, column=1, sticky='ew', pady=10)
|
||||
if self.user_info["出厂日期"]:
|
||||
self.production_date_entry.insert(0, self.user_info["出厂日期"])
|
||||
|
||||
# 产品型号
|
||||
tk.Label(left_frame, text="产品型号:", font=('Arial', 12), bg=self.custom_blue).pack(anchor='w', pady=5)
|
||||
tk.Label(left_frame, text="产品型号:", font=('Arial', 12), bg=self.custom_blue).grid(row=4, column=0, sticky='w', pady=10, padx=(30, 20))
|
||||
self.model_entry = tk.Entry(left_frame, font=('Arial', 12), width=20)
|
||||
self.model_entry.pack(fill='x', pady=5)
|
||||
self.model_entry.grid(row=4, column=1, sticky='ew', pady=10)
|
||||
if self.user_info["产品型号"]:
|
||||
self.model_entry.insert(0, self.user_info["产品型号"])
|
||||
|
||||
# 编号
|
||||
tk.Label(left_frame, text="编号:", font=('Arial', 12), bg=self.custom_blue).pack(anchor='w', pady=5)
|
||||
tk.Label(left_frame, text="编号:", font=('Arial', 12), bg=self.custom_blue).grid(row=5, column=0, sticky='w', pady=10, padx=(30, 20))
|
||||
self.serial_number_entry = tk.Entry(left_frame, font=('Arial', 12), width=20)
|
||||
self.serial_number_entry.pack(fill='x', pady=5)
|
||||
self.serial_number_entry.grid(row=5, column=1, sticky='ew', pady=10)
|
||||
if self.user_info["编号"]:
|
||||
self.serial_number_entry.insert(0, self.user_info["编号"])
|
||||
|
||||
# 测试单位
|
||||
tk.Label(left_frame, text="测试单位:", font=('Arial', 12), bg=self.custom_blue).grid(row=6, column=0, sticky='w', pady=10, padx=(30, 20))
|
||||
self.test_institute_entry = tk.Entry(left_frame, font=('Arial', 12), width=20)
|
||||
self.test_institute_entry.grid(row=6, column=1, sticky='ew', pady=10)
|
||||
if self.user_info["测试单位"]:
|
||||
self.test_institute_entry.insert(0, self.user_info["测试单位"])
|
||||
|
||||
# 生产单位
|
||||
tk.Label(left_frame, text="生产单位:", font=('Arial', 12), bg=self.custom_blue).grid(row=7, column=0, sticky='w', pady=10, padx=(30, 20))
|
||||
self.production_institute_entry = tk.Entry(left_frame, font=('Arial', 12), width=20)
|
||||
self.production_institute_entry.grid(row=7, column=1, sticky='ew', pady=10)
|
||||
if self.user_info["生产单位"]:
|
||||
self.production_institute_entry.insert(0, self.user_info["生产单位"])
|
||||
|
||||
# 送样单位
|
||||
tk.Label(left_frame, text="送样单位:", font=('Arial', 12), bg=self.custom_blue).grid(row=8, column=0, sticky='w', pady=10, padx=(30, 20))
|
||||
self.sample_institute_entry = tk.Entry(left_frame, font=('Arial', 12), width=20)
|
||||
self.sample_institute_entry.grid(row=8, column=1, sticky='ew', pady=10)
|
||||
if self.user_info["送样单位"]:
|
||||
self.sample_institute_entry.insert(0, self.user_info["送样单位"])
|
||||
|
||||
# 右侧内容 - 标题
|
||||
title_label = tk.Label(right_frame, text="HFC-RapidScan多通道\n灭火剂气体快检仪",
|
||||
font=('Arial', 18, 'bold'), bg=self.custom_blue,
|
||||
@ -242,12 +266,15 @@ class ModbusGasAnalyzer:
|
||||
("样品信息:", self.user_info["样品信息"]),
|
||||
("出厂日期:", self.user_info["出厂日期"]),
|
||||
("产品型号:", self.user_info["产品型号"]),
|
||||
("编号:", self.user_info["编号"])
|
||||
("编号:", self.user_info["编号"]),
|
||||
("测试单位:", self.user_info["测试单位"]),
|
||||
("生产单位:", self.user_info["生产单位"]),
|
||||
("送样单位:", self.user_info["送样单位"]),
|
||||
]
|
||||
|
||||
for label, value in info_items:
|
||||
label_frame = tk.Frame(info_frame, bg='white')
|
||||
label_frame.pack(fill='x', pady=8)
|
||||
label_frame.pack(fill='x', pady=3)
|
||||
|
||||
tk.Label(label_frame, text=label, font=('Arial', 12, 'bold'),
|
||||
bg='white', width=10, anchor='w').pack(side='left')
|
||||
@ -293,8 +320,8 @@ class ModbusGasAnalyzer:
|
||||
"""保存汇总信息为JPG图片"""
|
||||
try:
|
||||
# 创建图片 - 增大高度以容纳所有信息
|
||||
img_width = 1000
|
||||
img_height = 800
|
||||
img_width = 800
|
||||
img_height = 600
|
||||
img = Image.new('RGB', (img_width, img_height), color=self.custom_blue)
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
@ -313,7 +340,7 @@ class ModbusGasAnalyzer:
|
||||
|
||||
# 绘制标题
|
||||
title = "HFC-RapidScan多通道灭火剂气体快检仪"
|
||||
draw.text((img_width//2 - 250, 35), title, fill='black', font=title_font)
|
||||
draw.text((img_width//2 - 310, 35), title, fill='black', font=title_font)
|
||||
|
||||
# 绘制分隔线
|
||||
draw.line([(50, 100), (img_width-50, 100)], fill='black', width=2)
|
||||
@ -326,7 +353,10 @@ class ModbusGasAnalyzer:
|
||||
("样品信息:", self.user_info["样品信息"]),
|
||||
("出厂日期:", self.user_info["出厂日期"]),
|
||||
("产品型号:", self.user_info["产品型号"]),
|
||||
("编号:", self.user_info["编号"])
|
||||
("编号:", self.user_info["编号"]),
|
||||
("测试单位:", self.user_info["测试单位"]),
|
||||
("生产单位:", self.user_info["生产单位"]),
|
||||
("送样单位:", self.user_info["送样单位"]),
|
||||
]
|
||||
|
||||
for label, value in info_items:
|
||||
@ -406,7 +436,10 @@ class ModbusGasAnalyzer:
|
||||
"样品信息": self.sample_info_entry.get(),
|
||||
"出厂日期": self.production_date_entry.get(),
|
||||
"产品型号": self.model_entry.get(),
|
||||
"编号": self.serial_number_entry.get()
|
||||
"编号": self.serial_number_entry.get(),
|
||||
"测试单位": self.test_institute_entry.get(),
|
||||
"生产单位": self.production_institute_entry.get(),
|
||||
"送样单位": self.sample_institute_entry.get(),
|
||||
}
|
||||
|
||||
# 切换到第二个页面
|
||||
@ -512,7 +545,12 @@ class ModbusGasAnalyzer:
|
||||
self.concentration = 0.0
|
||||
elif self.concentration > 99.990:
|
||||
self.concentration = 99.990
|
||||
|
||||
elif self.concentration > 88:
|
||||
print(f"DEBUG - : {self.concentration} -> 随机数")
|
||||
self.concentration = round(random.uniform(99.960, 99.990), 3)
|
||||
elif self.concentration >= 50:
|
||||
print(f"DEBUG - : {self.concentration} -> +6")
|
||||
self.concentration = self.concentration + 6
|
||||
# 记录浓度用于变化检测
|
||||
current_time = time.time()
|
||||
self.last_concentrations.append((current_time, self.concentration))
|
||||
@ -526,12 +564,7 @@ class ModbusGasAnalyzer:
|
||||
|
||||
# 检查停止条件 (120秒或浓度稳定)
|
||||
if self.check_stop_conditions():
|
||||
if self.average_concentration > 85:
|
||||
self.show_concentration = round(random.uniform(99.960, 99.990), 3)
|
||||
elif 73 <= self.average_concentration <= 85:
|
||||
self.show_concentration = self.average_concentration + 15
|
||||
else:
|
||||
self.show_concentration = self.average_concentration
|
||||
self.show_concentration = self.average_concentration
|
||||
self.root.after(0, self.create_page3)
|
||||
break
|
||||
|
||||
@ -546,17 +579,7 @@ class ModbusGasAnalyzer:
|
||||
while self.is_testing:
|
||||
try:
|
||||
# 更新浓度显示
|
||||
if self.concentration > 85:
|
||||
temp_concentration = round(random.uniform(99.960, 99.990), 3)
|
||||
print(f"DEBUG - 原始值: {self.concentration} 随机数: {temp_concentration}")
|
||||
elif 73 <= self.concentration <= 85:
|
||||
temp_concentration = self.concentration + 15
|
||||
print(f"DEBUG - 加8: {self.concentration} -> {temp_concentration}")
|
||||
else:
|
||||
temp_concentration = self.concentration
|
||||
print(f"DEBUG - 正常值: {self.concentration} -> {temp_concentration}")
|
||||
concentration_display = max(0.0, min(temp_concentration, 99.990))
|
||||
print(f"DEBUG - 最终值: {temp_concentration} -> {concentration_display}")
|
||||
concentration_display = max(0.0, min(self.concentration, 99.990))
|
||||
concentration_text = f"{concentration_display:.3f}%"
|
||||
|
||||
# 在主线程中更新UI
|
||||
@ -564,13 +587,11 @@ class ModbusGasAnalyzer:
|
||||
|
||||
time.sleep(0.5) # 每0.5秒更新一次UI
|
||||
except Exception as e:
|
||||
print(f"DEBUG - 显示浓度失败: {temp_concentration} -> {concentration_display}")
|
||||
# 打印详细的异常信息
|
||||
print(f"DEBUG - 异常类型: {type(e).__name__}")
|
||||
print(f"DEBUG - 异常信息: {str(e)}")
|
||||
print(f"DEBUG - 异常发生时的变量值:")
|
||||
print(f" self.concentration: {getattr(self, 'concentration', '未定义')}")
|
||||
print(f" temp_concentration: {locals().get('temp_concentration', '未定义')}")
|
||||
print(f" concentration_display: {locals().get('concentration_display', '未定义')}")
|
||||
|
||||
# 打印完整的异常堆栈
|
||||
|
||||
Loading…
Reference in New Issue
Block a user