优化了测试界面
This commit is contained in:
+126
-1
@@ -1,6 +1,7 @@
|
||||
import socket
|
||||
import struct
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox
|
||||
import threading
|
||||
import random
|
||||
from udpmsg import *
|
||||
@@ -54,7 +55,8 @@ class ccuSys(Frame):
|
||||
self._create_status_column("FCU Status", [
|
||||
"fcuState", "fcuFaultLeve", "powerLimit",
|
||||
"totalPowerGeneration", "fcuVoltage", "fcuCurrent",
|
||||
"fcuOutPower", "fcuOutIns"
|
||||
"fcuOutPower", "fcuOutIns", "fcuGZ_1L", "fcuGZ_1H",
|
||||
"fcuGZ_2L", "fcuGZ_2H", "fcuGZ_3L", "fcuGZ_3H"
|
||||
])
|
||||
|
||||
self._create_status_column("Battery Status", [
|
||||
@@ -141,6 +143,56 @@ class ccuSys(Frame):
|
||||
)
|
||||
self.fcu_fault_menu.pack(side=tk.LEFT, padx=5)
|
||||
|
||||
# FCU GZ control
|
||||
tk.Label(self.fcu_frame, text="GZ 1L:").pack(side=tk.LEFT)
|
||||
self.fcu_gz1l_var = tk.IntVar(value=0)
|
||||
self.fcu_gz1l_entry = tk.Entry(
|
||||
self.fcu_frame, textvariable=self.fcu_gz1l_var, width=5
|
||||
)
|
||||
self.fcu_gz1l_entry.pack(side=tk.LEFT, padx=5)
|
||||
self.fcu_gz1l_entry.bind("<Return>", lambda e: self.set_fcu_gz1l())
|
||||
|
||||
tk.Label(self.fcu_frame, text="GZ 1H:").pack(side=tk.LEFT)
|
||||
self.fcu_gz1h_var = tk.IntVar(value=0)
|
||||
self.fcu_gz1h_entry = tk.Entry(
|
||||
self.fcu_frame, textvariable=self.fcu_gz1h_var, width=5
|
||||
)
|
||||
self.fcu_gz1h_entry.pack(side=tk.LEFT, padx=5)
|
||||
self.fcu_gz1h_entry.bind("<Return>", lambda e: self.set_fcu_gz1h())
|
||||
|
||||
# Add more GZ controls
|
||||
tk.Label(self.fcu_frame, text="GZ 2L:").pack(side=tk.LEFT)
|
||||
self.fcu_gz2l_var = tk.IntVar(value=0)
|
||||
self.fcu_gz2l_entry = tk.Entry(
|
||||
self.fcu_frame, textvariable=self.fcu_gz2l_var, width=5
|
||||
)
|
||||
self.fcu_gz2l_entry.pack(side=tk.LEFT, padx=5)
|
||||
self.fcu_gz2l_entry.bind("<Return>", lambda e: self.set_fcu_gz2l())
|
||||
|
||||
tk.Label(self.fcu_frame, text="GZ 2H:").pack(side=tk.LEFT)
|
||||
self.fcu_gz2h_var = tk.IntVar(value=0)
|
||||
self.fcu_gz2h_entry = tk.Entry(
|
||||
self.fcu_frame, textvariable=self.fcu_gz2h_var, width=5
|
||||
)
|
||||
self.fcu_gz2h_entry.pack(side=tk.LEFT, padx=5)
|
||||
self.fcu_gz2h_entry.bind("<Return>", lambda e: self.set_fcu_gz2h())
|
||||
|
||||
tk.Label(self.fcu_frame, text="GZ 3L:").pack(side=tk.LEFT)
|
||||
self.fcu_gz3l_var = tk.IntVar(value=0)
|
||||
self.fcu_gz3l_entry = tk.Entry(
|
||||
self.fcu_frame, textvariable=self.fcu_gz3l_var, width=5
|
||||
)
|
||||
self.fcu_gz3l_entry.pack(side=tk.LEFT, padx=5)
|
||||
self.fcu_gz3l_entry.bind("<Return>", lambda e: self.set_fcu_gz3l())
|
||||
|
||||
tk.Label(self.fcu_frame, text="GZ 3H:").pack(side=tk.LEFT)
|
||||
self.fcu_gz3h_var = tk.IntVar(value=0)
|
||||
self.fcu_gz3h_entry = tk.Entry(
|
||||
self.fcu_frame, textvariable=self.fcu_gz3h_var, width=5
|
||||
)
|
||||
self.fcu_gz3h_entry.pack(side=tk.LEFT, padx=5)
|
||||
self.fcu_gz3h_entry.bind("<Return>", lambda e: self.set_fcu_gz3h())
|
||||
|
||||
def _create_status_column(self, title, fields):
|
||||
"""Create a status column with specified fields"""
|
||||
col_frame = tk.LabelFrame(
|
||||
@@ -205,6 +257,13 @@ class ccuSys(Frame):
|
||||
self.ccuState.insEmergencyStatusWord = random.randint(0, 255)
|
||||
self.ccuState.powerEmergencyStatusWord = random.randint(0, 255)
|
||||
|
||||
self.ccuState.fcuGZ_1L=self.fcu_gz1l_var.get()
|
||||
self.ccuState.fcuGZ_1H=self.fcu_gz1h_var.get()
|
||||
self.ccuState.fcuGZ_2L=self.fcu_gz2l_var.get()
|
||||
self.ccuState.fcuGZ_2H=self.fcu_gz2h_var.get()
|
||||
self.ccuState.fcuGZ_3L=self.fcu_gz3l_var.get()
|
||||
self.ccuState.fcuGZ_3H=self.fcu_gz3h_var.get()
|
||||
|
||||
def update_display(self):
|
||||
"""Update all displayed values"""
|
||||
# Generate simulated data if no real data available
|
||||
@@ -277,6 +336,72 @@ class ccuSys(Frame):
|
||||
self.ccuState.fcuFaultLeve = level
|
||||
self.update_display()
|
||||
|
||||
def set_fcu_gz1l(self, value=None):
|
||||
"""Set FCU GZ 1L and update display"""
|
||||
if value is None:
|
||||
try:
|
||||
value = self.fcu_gz1l_var.get()
|
||||
except tk.TclError:
|
||||
tk.messagebox.showwarning("Input Error", "Invalid GZ 1L value")
|
||||
return
|
||||
self.ccuState.fcuGZ_1L = value
|
||||
self.update_display()
|
||||
|
||||
def set_fcu_gz1h(self, value=None):
|
||||
"""Set FCU GZ 1H and update display"""
|
||||
if value is None:
|
||||
try:
|
||||
value = self.fcu_gz1h_var.get()
|
||||
except tk.TclError:
|
||||
tk.messagebox.showwarning("Input Error", "Invalid GZ 1H value")
|
||||
return
|
||||
self.ccuState.fcuGZ_1H = value
|
||||
self.update_display()
|
||||
|
||||
def set_fcu_gz2l(self, value=None):
|
||||
"""Set FCU GZ 2L and update display"""
|
||||
if value is None:
|
||||
try:
|
||||
value = self.fcu_gz2l_var.get()
|
||||
except tk.TclError:
|
||||
tk.messagebox.showwarning("Input Error", "Invalid GZ 2L value")
|
||||
return
|
||||
self.ccuState.fcuGZ_2L = value
|
||||
self.update_display()
|
||||
|
||||
def set_fcu_gz2h(self, value=None):
|
||||
"""Set FCU GZ 2H and update display"""
|
||||
if value is None:
|
||||
try:
|
||||
value = self.fcu_gz2h_var.get()
|
||||
except tk.TclError:
|
||||
tk.messagebox.showwarning("Input Error", "Invalid GZ 2H value")
|
||||
return
|
||||
self.ccuState.fcuGZ_2H = value
|
||||
self.update_display()
|
||||
|
||||
def set_fcu_gz3l(self, value=None):
|
||||
"""Set FCU GZ 3L and update display"""
|
||||
if value is None:
|
||||
try:
|
||||
value = self.fcu_gz3l_var.get()
|
||||
except tk.TclError:
|
||||
tk.messagebox.showwarning("Input Error", "Invalid GZ 3L value")
|
||||
return
|
||||
self.ccuState.fcuGZ_3L = value
|
||||
self.update_display()
|
||||
|
||||
def set_fcu_gz3h(self, value=None):
|
||||
"""Set FCU GZ 3H and update display"""
|
||||
if value is None:
|
||||
try:
|
||||
value = self.fcu_gz3h_var.get()
|
||||
except tk.TclError:
|
||||
tk.messagebox.showwarning("Input Error", "Invalid GZ 3H value")
|
||||
return
|
||||
self.ccuState.fcuGZ_3H = value
|
||||
self.update_display()
|
||||
|
||||
def start_update_timer(self):
|
||||
"""Start the periodic display update timer"""
|
||||
if not hasattr(self, 'data_update_thread'):
|
||||
|
||||
Reference in New Issue
Block a user