Files
alro65 7390d5cd51 sprint-6: Runtime desktop client (PySide6 + WebSocket + REST)
Cliente desktop completo conectado al Runtime server por HTTP+WebSocket.

vmssailor/runtime/client/api_client.py
- RuntimeApiClient: wrapper async httpx contra /health, /project, /tags,
  /tags/{id}, /tags/{id}/history, /alarms, /logbook, /alarms/{id}/ack
- RuntimeWebSocketClient: conexion ws://host:port/ws/realtime con
  reconexion automatica + heartbeats + on_event/on_state_change callbacks

vmssailor/runtime/client/app.py
- RuntimeClientApp QApplication con tema Deep Ocean (compartido con Studio)
- run_client() entry point

vmssailor/runtime/client/main_window.py
- Topbar: logo + vessel name + status pill (connecting/connected/disconnected)
  + alarm chip + user chip
- Sidebar lista: Overview, Mimicos, Alarmas, Trends, Trim, Log Book, Conexion
- QStackedWidget central conmuta vista segun sidebar
- Reloj live + statusbar con estado WS + version
- Sprint 6 trae 3 vistas funcionales (Overview, Alarmas, Conexion); resto stubs

vmssailor/runtime/client/views/connection_view.py
- _AsyncWorker QObject corre asyncio event loop en QThread separado
- Conecta API + WS, emite signals connectionStateChanged / eventReceived / projectLoaded
- Tabla con ultimos 500 eventos crudos del WebSocket
- Conecta/desconecta sin congelar la UI

vmssailor/runtime/client/views/overview_view.py
- Grid de tiles dinamicas que se crean al recibir tag_update events
- Cada tile muestra: descripcion, tag_id, valor formateado, quality, timestamp
- Layout 4 columnas con QScrollArea

vmssailor/runtime/client/views/alarms_view.py
- Tabla de alarmas activas con priority coloreada (emergency/high/low/info)
- Boton ACK por fila emite signal acknowledged(alarm_id)
- handle_event mantiene set vivo segun state=active/cleared

runtime_client_main.py
- Entry point: uv run python runtime_client_main.py

Tests (tests/runtime/test_client.py, 5 nuevos, total 157/157):
- main window builds with 7 stack pages
- overview handles tag_update
- alarms view shows + clears on state change
- connection view initial state

Para correr el sistema completo en vivo:
    # Terminal 1 — servidor:
    uv run python runtime_server_main.py --verbose
    # Terminal 2 — cliente:
    uv run python runtime_client_main.py

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 20:37:06 -04:00

48 lines
1.4 KiB
Python

"""Bootstrap del cliente desktop Runtime (PySide6)."""
from __future__ import annotations
import sys
from pathlib import Path
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QApplication
from vmssailor.shared.logging_setup import setup_logging
from vmssailor.studio.theme import apply_theme
from vmssailor.version import __version__
BRAND_ROOT = Path(__file__).resolve().parents[3] / "docs" / "brand"
class RuntimeClientApp(QApplication):
"""QApplication del cliente Runtime."""
def __init__(self, argv: list[str] | None = None) -> None:
super().__init__(argv or sys.argv)
self.setOrganizationName("Aerom")
self.setApplicationName("VMS-Sailor Runtime Client")
self.setApplicationDisplayName("VMS-Sailor Runtime")
self.setApplicationVersion(__version__)
icon_svg = BRAND_ROOT / "favicon.svg"
if icon_svg.exists():
self.setWindowIcon(QIcon(str(icon_svg)))
apply_theme(self)
def run_client(argv: list[str] | None = None) -> int:
"""Lanza el cliente Runtime y bloquea hasta que cierre."""
setup_logging()
app = RuntimeClientApp(argv)
from vmssailor.runtime.client.main_window import RuntimeClientWindow
window = RuntimeClientWindow()
window.resize(1440, 900)
window.show()
return app.exec()
if __name__ == "__main__":
sys.exit(run_client())