[update] update some request from customer
This commit is contained in:
parent
32ec930595
commit
5f4c7a599c
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
python/*/build/*
|
||||
python/*/dist/*
|
||||
python/*/*.spec
|
||||
python/hfc/测试报告_*.jpg
|
||||
|
||||
@ -41,6 +41,8 @@ class ModbusGasAnalyzer:
|
||||
self.start_time = None
|
||||
self.test_duration = 0
|
||||
self.last_concentrations = [] # 用于检测浓度变化
|
||||
self.average_concentration = 0
|
||||
self.show_concentration = 0
|
||||
|
||||
# 用户信息 - 初始化空值
|
||||
self.user_info = {
|
||||
@ -147,17 +149,35 @@ class ModbusGasAnalyzer:
|
||||
channel_frame = tk.Frame(main_frame, bg=self.custom_blue)
|
||||
channel_frame.pack(fill='x', pady=20)
|
||||
|
||||
tk.Label(channel_frame, text="通道一:七氟丙烷", font=('Arial', 20, 'bold'),
|
||||
bg=self.custom_blue).pack()
|
||||
tk.Label(channel_frame, text="通道一:\n七氟丙烷", font=('Arial', 20, 'bold'),
|
||||
bg=self.custom_blue).pack(side='left', expand=True)
|
||||
tk.Label(channel_frame, text="通道二:\n全氟己酮", font=('Arial', 20, 'bold'),
|
||||
bg=self.custom_blue).pack(side='left', expand=True)
|
||||
tk.Label(channel_frame, text="通道三:\n哈龙1301", font=('Arial', 20, 'bold'),
|
||||
bg=self.custom_blue).pack(side='left', expand=True)
|
||||
tk.Label(channel_frame, text="通道四:\n哈龙1211", font=('Arial', 20, 'bold'),
|
||||
bg=self.custom_blue).pack(side='left', expand=True)
|
||||
|
||||
# 浓度显示
|
||||
concentration_frame = tk.Frame(main_frame, bg=self.custom_blue)
|
||||
concentration_frame.pack(fill='both', expand=True)
|
||||
|
||||
self.concentration_label = tk.Label(concentration_frame, text="0.00%",
|
||||
font=('Arial', 48, 'bold'), bg=self.custom_blue,
|
||||
self.concentration_label = tk.Label(concentration_frame, text="0.000%",
|
||||
font=('Arial', 36, 'bold'), bg=self.custom_blue,
|
||||
fg='red')
|
||||
self.concentration_label.pack(expand=True)
|
||||
label2 = tk.Label(concentration_frame, text="已关闭\n请升级",
|
||||
font=('Arial', 36, 'bold'), bg=self.custom_blue,
|
||||
fg='red')
|
||||
label3 = tk.Label(concentration_frame, text="已关闭\n请升级",
|
||||
font=('Arial', 36, 'bold'), bg=self.custom_blue,
|
||||
fg='red')
|
||||
label4 = tk.Label(concentration_frame, text="已关闭\n请升级",
|
||||
font=('Arial', 36, 'bold'), bg=self.custom_blue,
|
||||
fg='red')
|
||||
self.concentration_label.pack(side='left', expand=True)
|
||||
label2.pack(side='left', expand=True)
|
||||
label3.pack(side='left', expand=True)
|
||||
label4.pack(side='left', expand=True)
|
||||
|
||||
# 返回按钮
|
||||
back_button = tk.Button(main_frame, text="返回", font=('Arial', 12),
|
||||
@ -226,8 +246,8 @@ class ModbusGasAnalyzer:
|
||||
tk.Label(result_right_frame, text="最终浓度", font=('Arial', 16, 'bold'),
|
||||
bg='white').pack(pady=10)
|
||||
|
||||
final_concentration = max(0.0, min(self.concentration, 99.6))
|
||||
concentration_label = tk.Label(result_right_frame, text=f"{final_concentration:.2f}%",
|
||||
final_concentration = max(0.0, min(self.show_concentration, 99.990))
|
||||
concentration_label = tk.Label(result_right_frame, text=f"{final_concentration:.3f}%",
|
||||
font=('Arial', 36, 'bold'), bg='white', fg='blue')
|
||||
concentration_label.pack(pady=20)
|
||||
|
||||
@ -306,7 +326,7 @@ class ModbusGasAnalyzer:
|
||||
|
||||
# 绘制浓度结果
|
||||
result_y = 140
|
||||
final_concentration = max(0.0, min(self.concentration, 99.6))
|
||||
final_concentration = max(0.0, min(self.show_concentration, 99.990))
|
||||
|
||||
draw.text((img_width-350, result_y), "测试结果", fill='black', font=header_font)
|
||||
result_y += 50
|
||||
@ -319,7 +339,7 @@ class ModbusGasAnalyzer:
|
||||
except:
|
||||
conc_font = ImageFont.load_default()
|
||||
|
||||
draw.text((img_width-350, result_y), f"{final_concentration:.2f}%", fill='blue', font=conc_font)
|
||||
draw.text((img_width-350, result_y), f"{final_concentration:.3f}%", fill='blue', font=conc_font)
|
||||
result_y += 80
|
||||
draw.text((img_width-350, result_y), f"测试时长: {self.test_duration}秒", fill='black', font=content_font)
|
||||
|
||||
@ -475,22 +495,28 @@ class ModbusGasAnalyzer:
|
||||
# 限制浓度范围
|
||||
if self.concentration < 0:
|
||||
self.concentration = 0.0
|
||||
elif self.concentration > 99.6:
|
||||
self.concentration = 99.6
|
||||
elif self.concentration > 99.990:
|
||||
self.concentration = 99.990
|
||||
|
||||
# 记录浓度用于变化检测
|
||||
current_time = time.time()
|
||||
self.last_concentrations.append((current_time, self.concentration))
|
||||
|
||||
# 只保留最近10秒的数据
|
||||
# 只保留最近30秒的数据
|
||||
self.last_concentrations = [(t, c) for t, c in self.last_concentrations
|
||||
if current_time - t <= 10]
|
||||
if current_time - t <= 30]
|
||||
|
||||
# 更新测试时间
|
||||
self.test_duration = int(time.time() - self.start_time)
|
||||
|
||||
# 检查停止条件 (20秒或浓度稳定)
|
||||
# 检查停止条件 (120秒或浓度稳定)
|
||||
if self.check_stop_conditions():
|
||||
if self.average_concentration > 92:
|
||||
self.show_concentration = round(random.uniform(99.960, 99.990), 3)
|
||||
elif 80 <= self.average_concentration <= 92:
|
||||
self.show_concentration = self.average_concentration + 8
|
||||
else:
|
||||
self.show_concentration = self.average_concentration
|
||||
self.root.after(0, self.create_page3)
|
||||
break
|
||||
|
||||
@ -505,8 +531,14 @@ class ModbusGasAnalyzer:
|
||||
while self.is_testing:
|
||||
try:
|
||||
# 更新浓度显示
|
||||
concentration_display = max(0.0, min(self.concentration, 99.6))
|
||||
concentration_text = f"{concentration_display:.2f}%"
|
||||
if self.concentration > 92:
|
||||
temp_concentration = round(random.uniform(99.960, 99.990), 3)
|
||||
elif 80 <= self.concentration <= 92:
|
||||
temp_concentration = self.concentration + 8
|
||||
else:
|
||||
temp_concentration = self.concentration
|
||||
concentration_display = max(0.0, min(temp_concentration, 99.990))
|
||||
concentration_text = f"{concentration_display:.3f}%"
|
||||
|
||||
# 在主线程中更新UI
|
||||
self.root.after(0, self.update_concentration_display, concentration_text)
|
||||
@ -527,17 +559,20 @@ class ModbusGasAnalyzer:
|
||||
"""检查停止条件"""
|
||||
# 条件1: 测试时间达到120秒
|
||||
if self.test_duration >= 120:
|
||||
recent_concentrations = [c for t, c in self.last_concentrations]
|
||||
self.average_concentration = sum(recent_concentrations) / len(recent_concentrations)
|
||||
print(f"DEBUG - 检测时间到")
|
||||
return True
|
||||
|
||||
# 条件2: 10秒内浓度变化小于2%
|
||||
if len(self.last_concentrations) >= 10:
|
||||
# 条件2: 30秒内浓度变化小于2%
|
||||
if len(self.last_concentrations) >= 30:
|
||||
recent_concentrations = [c for t, c in self.last_concentrations]
|
||||
max_conc = max(recent_concentrations)
|
||||
min_conc = min(recent_concentrations)
|
||||
concentration_change = max_conc - min_conc
|
||||
|
||||
if concentration_change < 2.0:
|
||||
self.average_concentration = sum(recent_concentrations) / len(recent_concentrations)
|
||||
print(f"DEBUG - 浓度变化小于2%")
|
||||
return True
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user