터치 패널 그래프 주기 분리

This commit is contained in:
seo committed 2026-08-01 11:42:02 +09:00
1 parent 3f3198b29f
commit 5f1cc4cc7f
2 files changed
+18 -13

No files matched your search

+17 -12
View File
@@ -106,8 +106,10 @@ awk -v cpu="$cpu" -v fan="$fan" -v pwm="$pwm" -v enable="$enable" -v guard="$gua
SAMPLE_INTERVAL_MS = 50
DASHBOARD_INTERVAL_MS = 500
FAN_INTERVAL_MS = 500
GRAPH_SECONDS = 10
GRAPH_POINTS = GRAPH_SECONDS * 1000 // DASHBOARD_INTERVAL_MS
WAN_GRAPH_SECONDS = 10
TEMP_GRAPH_SECONDS = 60
WAN_GRAPH_POINTS = WAN_GRAPH_SECONDS * 1000 // SAMPLE_INTERVAL_MS
TEMP_GRAPH_POINTS = TEMP_GRAPH_SECONDS * 1000 // DASHBOARD_INTERVAL_MS
SYNOLOGY_RESTART_INTERVAL_MS = 1000
TEMP_INTERVAL_MS = 500
DISK_TEMP_INTERVAL_MS = TEMP_INTERVAL_MS
@@ -488,7 +490,7 @@ class MetricCard(QFrame):
class Sparkline(QFrame):
def __init__(self, title, color="#38bdf8", second_color=None, y_unit="", right_unit="", auto_byte_unit=False):
def __init__(self, title, color="#38bdf8", second_color=None, y_unit="", right_unit="", auto_byte_unit=False, max_points=120):
super().__init__()
self.setObjectName("chartCard")
self.color = QColor(color)
@@ -496,6 +498,7 @@ class Sparkline(QFrame):
self.y_unit = y_unit
self.right_unit = right_unit
self.auto_byte_unit = auto_byte_unit
self.max_points = max_points
self.values = []
self.second_values = []
self.title = QLabel(title)
@@ -517,8 +520,8 @@ class Sparkline(QFrame):
layout.addWidget(self.canvas, 1)
def set_values(self, values, caption, second_values=None):
self.values = list(values)[-GRAPH_POINTS:]
self.second_values = list(second_values or [])[-GRAPH_POINTS:]
self.values = list(values)[-self.max_points:]
self.second_values = list(second_values or [])[-self.max_points:]
self.caption.setText(caption)
self.canvas.update()
@@ -611,9 +614,9 @@ class TouchPanel(QMainWindow):
self.latest_rpm = 0
self.latest_pwm = self.current_pwm
self.latest_percent = 0.0
self.temp_history = deque(maxlen=GRAPH_POINTS)
self.rpm_history = deque(maxlen=GRAPH_POINTS)
self.net_history = {"wan": {"rx": deque(maxlen=GRAPH_POINTS), "tx": deque(maxlen=GRAPH_POINTS)}}
self.temp_history = deque(maxlen=TEMP_GRAPH_POINTS)
self.rpm_history = deque(maxlen=TEMP_GRAPH_POINTS)
self.net_history = {"wan": {"rx": deque(maxlen=WAN_GRAPH_POINTS), "tx": deque(maxlen=WAN_GRAPH_POINTS)}}
self.setWindowTitle("Standalone Touch Dashboard")
self.setCursor(Qt.BlankCursor)
@@ -782,8 +785,8 @@ class TouchPanel(QMainWindow):
chart_grid.setHorizontalSpacing(8)
chart_grid.setVerticalSpacing(8)
for index, (key, chart) in enumerate([
("temp", Sparkline("온도 / RPM", "#f97316", "#38bdf8", "C", "rpm")),
("wan", Sparkline("WAN 트래픽", "#f97316", "#22c55e", auto_byte_unit=True)),
("temp", Sparkline("온도 / RPM", "#f97316", "#38bdf8", "C", "rpm", max_points=TEMP_GRAPH_POINTS)),
("wan", Sparkline("WAN 트래픽", "#f97316", "#22c55e", auto_byte_unit=True, max_points=WAN_GRAPH_POINTS)),
]):
self.charts[key] = chart
chart_grid.addWidget(chart, index, 0)
@@ -845,6 +848,7 @@ class TouchPanel(QMainWindow):
self.last_net[key] = current
self.current_rates = rates
self.update_wan_graph()
self.render_status(groups, rates, activity, io_read_activity, io_write_activity, disk_error)
def render_status(self, groups, rates, activity, io_read_activity, io_write_activity, disk_error):
@@ -883,7 +887,7 @@ class TouchPanel(QMainWindow):
self.slider.blockSignals(False)
self.clock.setText(time.strftime("%H:%M:%S"))
self.update_graphs()
self.update_temp_graph()
def ping_pc(self):
if self.pc_ping.state() != QProcess.NotRunning:
@@ -1164,13 +1168,14 @@ class TouchPanel(QMainWindow):
error_activity = previous is not None and (errors > previous[2] or drops > previous[3])
self.rows[key].set_state(self.drop_detail(drops, detail), error_activity, read_activity, write_activity)
def update_graphs(self):
def update_temp_graph(self):
temp = getattr(self, "latest_temp", 0.0)
rpm = getattr(self, "latest_rpm", read_int(self.fan["rpm"]))
self.temp_history.append(temp)
self.rpm_history.append(rpm)
self.charts["temp"].set_values(self.temp_history, format_temp_rpm_caption(temp, rpm), self.rpm_history)
def update_wan_graph(self):
wan = self.current_rates.get("wan", {"rx": 0.0, "tx": 0.0})
self.net_history["wan"]["rx"].append(wan["rx"])
self.net_history["wan"]["tx"].append(wan["tx"])