|
|
@@ -674,6 +674,8 @@ class MainWindow(QMainWindow):
|
|
|
cam = next((c for c in self.active_bucket.cameras if c.position == (CameraPosition.LEFT if side == "left" else CameraPosition.RIGHT)), None)
|
|
|
if not cam:
|
|
|
return
|
|
|
+ if not self._is_camera_online(cam):
|
|
|
+ return
|
|
|
label = self.left_label if side == "left" else self.right_label
|
|
|
delay = self._rtsp_retry_delay_left if side == "left" else self._rtsp_retry_delay_right
|
|
|
label.setText(f"正在重连({delay}s)...")
|
|
|
@@ -695,6 +697,10 @@ class MainWindow(QMainWindow):
|
|
|
if not cam:
|
|
|
return
|
|
|
label = self.left_label if side == "left" else self.right_label
|
|
|
+ if not self._is_camera_online(cam):
|
|
|
+ self.show_timeout_on_label(label)
|
|
|
+ self._cancel_rtsp_retry(side)
|
|
|
+ return
|
|
|
self.show_loading_on_label(label)
|
|
|
w, h = label.width(), label.height()
|
|
|
timeout = self.config.video.rtsp_timeout
|
|
|
@@ -733,7 +739,12 @@ class MainWindow(QMainWindow):
|
|
|
if player:
|
|
|
player.set_ai_objects(objects)
|
|
|
|
|
|
- # ---------- 点击工位 ----------
|
|
|
+ def _is_camera_online(self, cam) -> bool:
|
|
|
+ m = re.search(r'rtsp://(?:[^@]+@)?([^:/]+)', cam.rtsp_url)
|
|
|
+ if not m:
|
|
|
+ return False
|
|
|
+ lat = self._camera_signal.get(m.group(1))
|
|
|
+ return lat is not None and lat >= 0
|
|
|
def on_bucket_clicked(self, bucket: BucketModel):
|
|
|
if self.switch_mode != SwitchMode.HAND:
|
|
|
self.switch_mode = SwitchMode.HAND
|
|
|
@@ -866,7 +877,7 @@ class MainWindow(QMainWindow):
|
|
|
left_cam = next((c for c in bucket.cameras if c.position == CameraPosition.LEFT), None)
|
|
|
right_cam = next((c for c in bucket.cameras if c.position == CameraPosition.RIGHT), None)
|
|
|
|
|
|
- if left_cam:
|
|
|
+ if left_cam and self._is_camera_online(left_cam):
|
|
|
w = self.left_label.width()
|
|
|
h = self.left_label.height()
|
|
|
timeout = self.config.video.rtsp_timeout
|
|
|
@@ -876,8 +887,10 @@ class MainWindow(QMainWindow):
|
|
|
player.timeout.connect(lambda p=player: self.on_player_timeout(self.left_label, p, "left"))
|
|
|
self.left_player = player
|
|
|
player.start()
|
|
|
+ elif left_cam:
|
|
|
+ self.show_timeout_on_label(self.left_label)
|
|
|
|
|
|
- if right_cam:
|
|
|
+ if right_cam and self._is_camera_online(right_cam):
|
|
|
w = self.right_label.width()
|
|
|
h = self.right_label.height()
|
|
|
timeout = self.config.video.rtsp_timeout
|
|
|
@@ -887,6 +900,8 @@ class MainWindow(QMainWindow):
|
|
|
player.timeout.connect(lambda p=player: self.on_player_timeout(self.right_label, p, "right"))
|
|
|
self.right_player = player
|
|
|
player.start()
|
|
|
+ elif right_cam:
|
|
|
+ self.show_timeout_on_label(self.right_label)
|
|
|
else:
|
|
|
self._unsubscribe_all_topics()
|
|
|
self.left_label.clear()
|