[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/*/build/*
|
||||||
python/*/dist/*
|
python/*/dist/*
|
||||||
python/*/*.spec
|
python/*/*.spec
|
||||||
|
python/hfc/测试报告_*.jpg
|
||||||
|
|||||||
@ -41,6 +41,8 @@ class ModbusGasAnalyzer:
|
|||||||
self.start_time = None
|
self.start_time = None
|
||||||
self.test_duration = 0
|
self.test_duration = 0
|
||||||
self.last_concentrations = [] # 用于检测浓度变化
|
self.last_concentrations = [] # 用于检测浓度变化
|
||||||
|
self.average_concentration = 0
|
||||||
|
self.show_concentration = 0
|
||||||
|
|
||||||
# 用户信息 - 初始化空值
|
# 用户信息 - 初始化空值
|
||||||
self.user_info = {
|
self.user_info = {
|
||||||
@ -147,17 +149,35 @@ class ModbusGasAnalyzer:
|
|||||||
channel_frame = tk.Frame(main_frame, bg=self.custom_blue)
|
channel_frame = tk.Frame(main_frame, bg=self.custom_blue)
|
||||||
channel_frame.pack(fill='x', pady=20)
|
channel_frame.pack(fill='x', pady=20)
|
||||||
|
|
||||||
tk.Label(channel_frame, text="通道一:七氟丙烷", font=('Arial', 20, 'bold'),
|
tk.Label(channel_frame, text="通道一:\n七氟丙烷", font=('Arial', 20, 'bold'),
|
||||||
bg=self.custom_blue).pack()
|
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 = tk.Frame(main_frame, bg=self.custom_blue)
|
||||||
concentration_frame.pack(fill='both', expand=True)
|
concentration_frame.pack(fill='both', expand=True)
|
||||||
|
|
||||||
self.concentration_label = tk.Label(concentration_frame, text="0.00%",
|
self.concentration_label = tk.Label(concentration_frame, text="0.000%",
|
||||||
font=('Arial', 48, 'bold'), bg=self.custom_blue,
|
font=('Arial', 36, 'bold'), bg=self.custom_blue,
|
||||||
fg='red')
|
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),
|
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'),
|
tk.Label(result_right_frame, text="最终浓度", font=('Arial', 16, 'bold'),
|
||||||
bg='white').pack(pady=10)
|
bg='white').pack(pady=10)
|
||||||
|
|
||||||
final_concentration = max(0.0, min(self.concentration, 99.6))
|
final_concentration = max(0.0, min(self.show_concentration, 99.990))
|
||||||
concentration_label = tk.Label(result_right_frame, text=f"{final_concentration:.2f}%",
|
concentration_label = tk.Label(result_right_frame, text=f"{final_concentration:.3f}%",
|
||||||
font=('Arial', 36, 'bold'), bg='white', fg='blue')
|
font=('Arial', 36, 'bold'), bg='white', fg='blue')
|
||||||
concentration_label.pack(pady=20)
|
concentration_label.pack(pady=20)
|
||||||
|
|
||||||
@ -306,7 +326,7 @@ class ModbusGasAnalyzer:
|
|||||||
|
|
||||||
# 绘制浓度结果
|
# 绘制浓度结果
|
||||||
result_y = 140
|
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)
|
draw.text((img_width-350, result_y), "测试结果", fill='black', font=header_font)
|
||||||
result_y += 50
|
result_y += 50
|
||||||
@ -319,7 +339,7 @@ class ModbusGasAnalyzer:
|
|||||||
except:
|
except:
|
||||||
conc_font = ImageFont.load_default()
|
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
|
result_y += 80
|
||||||
draw.text((img_width-350, result_y), f"测试时长: {self.test_duration}秒", fill='black', font=content_font)
|
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:
|
if self.concentration < 0:
|
||||||
self.concentration = 0.0
|
self.concentration = 0.0
|
||||||
elif self.concentration > 99.6:
|
elif self.concentration > 99.990:
|
||||||
self.concentration = 99.6
|
self.concentration = 99.990
|
||||||
|
|
||||||
# 记录浓度用于变化检测
|
# 记录浓度用于变化检测
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
self.last_concentrations.append((current_time, self.concentration))
|
self.last_concentrations.append((current_time, self.concentration))
|
||||||
|
|
||||||
# 只保留最近10秒的数据
|
# 只保留最近30秒的数据
|
||||||
self.last_concentrations = [(t, c) for t, c in self.last_concentrations
|
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)
|
self.test_duration = int(time.time() - self.start_time)
|
||||||
|
|
||||||
# 检查停止条件 (20秒或浓度稳定)
|
# 检查停止条件 (120秒或浓度稳定)
|
||||||
if self.check_stop_conditions():
|
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)
|
self.root.after(0, self.create_page3)
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -505,8 +531,14 @@ class ModbusGasAnalyzer:
|
|||||||
while self.is_testing:
|
while self.is_testing:
|
||||||
try:
|
try:
|
||||||
# 更新浓度显示
|
# 更新浓度显示
|
||||||
concentration_display = max(0.0, min(self.concentration, 99.6))
|
if self.concentration > 92:
|
||||||
concentration_text = f"{concentration_display:.2f}%"
|
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
|
# 在主线程中更新UI
|
||||||
self.root.after(0, self.update_concentration_display, concentration_text)
|
self.root.after(0, self.update_concentration_display, concentration_text)
|
||||||
@ -527,17 +559,20 @@ class ModbusGasAnalyzer:
|
|||||||
"""检查停止条件"""
|
"""检查停止条件"""
|
||||||
# 条件1: 测试时间达到120秒
|
# 条件1: 测试时间达到120秒
|
||||||
if self.test_duration >= 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 - 检测时间到")
|
print(f"DEBUG - 检测时间到")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# 条件2: 10秒内浓度变化小于2%
|
# 条件2: 30秒内浓度变化小于2%
|
||||||
if len(self.last_concentrations) >= 10:
|
if len(self.last_concentrations) >= 30:
|
||||||
recent_concentrations = [c for t, c in self.last_concentrations]
|
recent_concentrations = [c for t, c in self.last_concentrations]
|
||||||
max_conc = max(recent_concentrations)
|
max_conc = max(recent_concentrations)
|
||||||
min_conc = min(recent_concentrations)
|
min_conc = min(recent_concentrations)
|
||||||
concentration_change = max_conc - min_conc
|
concentration_change = max_conc - min_conc
|
||||||
|
|
||||||
if concentration_change < 2.0:
|
if concentration_change < 2.0:
|
||||||
|
self.average_concentration = sum(recent_concentrations) / len(recent_concentrations)
|
||||||
print(f"DEBUG - 浓度变化小于2%")
|
print(f"DEBUG - 浓度变化小于2%")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user