터치 패널 실시간 점멸과 PC 대기 상태 개선
This commit is contained in:
1 parent
6aa8e7277f
commit
2184183ed8
2 files changed
+35
-9
No files matched your search
+34
-8
@@ -230,26 +230,52 @@ class PcWakeButton(StatusTile):
|
||||
super().__init__("PC")
|
||||
self.online = False
|
||||
self.last_wake_at = 0.0
|
||||
self.wait_until = 0.0
|
||||
self.error_until = 0.0
|
||||
self.blink_timer = QTimer(self)
|
||||
self.blink_timer.timeout.connect(self.tick_waiting)
|
||||
self.blink_timer.start(250)
|
||||
|
||||
def set_online(self, online):
|
||||
self.online = online
|
||||
self.read_dot.set_steady(online)
|
||||
self.error_dot.set_steady(False)
|
||||
now = time.monotonic()
|
||||
self.error_dot.set_steady(now < self.error_until)
|
||||
if online:
|
||||
self.wait_until = 0.0
|
||||
self.detail.setText("켜짐")
|
||||
elif time.monotonic() - self.last_wake_at < 30:
|
||||
remaining = int(30 - (time.monotonic() - self.last_wake_at))
|
||||
elif now < self.wait_until:
|
||||
remaining = int(self.wait_until - now)
|
||||
self.detail.setText(f"대기 {remaining}s")
|
||||
else:
|
||||
self.detail.setText("꺼짐")
|
||||
|
||||
def tick_waiting(self):
|
||||
now = time.monotonic()
|
||||
if not self.online and now < self.wait_until:
|
||||
self.write_dot.blink()
|
||||
if not self.online and self.wait_until > 0 and now >= self.wait_until:
|
||||
self.wait_until = 0.0
|
||||
self.error_until = now + 60
|
||||
self.error_dot.set_steady(True)
|
||||
self.detail.setText("실패")
|
||||
if self.error_until > 0 and now >= self.error_until:
|
||||
self.error_until = 0.0
|
||||
self.error_dot.set_steady(False)
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
if event.button() == Qt.LeftButton:
|
||||
self.write_dot.blink()
|
||||
if not self.online and time.monotonic() - self.last_wake_at >= 30:
|
||||
self.last_wake_at = time.monotonic()
|
||||
now = time.monotonic()
|
||||
if not self.online and now >= self.wait_until:
|
||||
self.last_wake_at = now
|
||||
self.wait_until = now + 60
|
||||
self.error_until = 0.0
|
||||
self.error_dot.set_steady(False)
|
||||
self.detail.setText("깨우는 중")
|
||||
if not send_magic_packet(PC_MAC):
|
||||
self.wait_until = 0.0
|
||||
self.error_until = now + 5
|
||||
self.error_dot.set_steady(True)
|
||||
super().mousePressEvent(event)
|
||||
|
||||
@@ -385,7 +411,7 @@ class TouchPanel(QMainWindow):
|
||||
|
||||
self.sample_timer = QTimer(self)
|
||||
self.sample_timer.timeout.connect(self.sample)
|
||||
self.sample_timer.start(120)
|
||||
self.sample_timer.start(50)
|
||||
|
||||
self.graph_timer = QTimer(self)
|
||||
self.graph_timer.timeout.connect(self.update_graphs)
|
||||
@@ -405,7 +431,7 @@ class TouchPanel(QMainWindow):
|
||||
|
||||
self.pulse_timer = QTimer(self)
|
||||
self.pulse_timer.timeout.connect(self.tick_pulses)
|
||||
self.pulse_timer.start(70)
|
||||
self.pulse_timer.start(25)
|
||||
self.sample()
|
||||
self.ping_pc()
|
||||
self.update_disk_temp()
|
||||
@@ -557,7 +583,7 @@ class TouchPanel(QMainWindow):
|
||||
def update_disk_temp(self):
|
||||
if self.disk_temp_proc.state() != QProcess.NotRunning:
|
||||
return
|
||||
self.disk_temp_proc.start("/usr/sbin/smartctl", ["-A", "-d", "sntasmedia", "/dev/sda"])
|
||||
self.disk_temp_proc.start("/usr/bin/sudo", ["-n", "/usr/sbin/smartctl", "-A", "-d", "sntasmedia", "/dev/sda"])
|
||||
|
||||
def disk_temp_finished(self, exit_code, exit_status):
|
||||
del exit_code, exit_status
|
||||
|
||||
Reference in new issue
Block a user