Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,32 @@ Then using your favorite web browser, go to
running locally. If the INDI Web Manager is installed on a remote system,
simply replace localhost with the hostname or IP address of the remote system.

# PAA Live Monitor

The PAA (Polar Alignment Assistant) live monitor is an optional feature that
shows **live** polar alignment error from Ekos/KStars. It displays total,
altitude, and azimuth error in degrees-minutes-seconds (DMS) and arcseconds,
with direction arrows; values update as Ekos writes PAA Refresh lines to its
log file.

<img src="img/paa-monitor-mobile.jpeg" alt="PAA Live Monitor on mobile" width="320" />

To enable the PAA monitor, start INDI Web Manager with `--with-paa`. You may
optionally pass one or more log directories with `--kstars-logs DIR [DIR ...]`.
If `--kstars-logs` is omitted, the application searches (in order):
`~/.local/share/kstars/logs` (native KStars install) and
`~/.var/app/org.kde.kstars/data/kstars/logs` (Flatpak). Example:
`indi-web --with-paa` or `indi-web --with-paa --kstars-logs /path/to/kstars/logs`.

**Ekos configuration (required):** In Ekos, enable **Log to file** so that PAA
Refresh lines are written to the KStars log. Run the **Polar Alignment
Assistant** in Ekos so the log contains PAA data. Without Log to file enabled,
the monitor will report that no PAA data was found and prompt you to enable it.

Open the PAA page in the app at [http://localhost:8624/paa](http://localhost:8624/paa)
(when using the default port). Status is also available via REST at
`GET /api/paa/status` and live updates via WebSocket at `/ws/paa` for integration.

# Auto Start

If you selected any profile as **Auto Start** then the INDI server shall be
Expand Down
Binary file added img/paa-monitor-mobile.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 27 additions & 3 deletions indiweb/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import os
import socket
from contextlib import asynccontextmanager

import uvicorn
from fastapi.middleware.cors import CORSMiddleware
Expand All @@ -15,6 +16,7 @@
from .device import Device
from .driver import INDI_DATA_DIR, DriverCollection
from .indi_server import INDI_CONFIG_DIR, INDI_FIFO, INDI_PORT, IndiServer
from .paa_monitor import PaaMonitor, _default_kstars_log_dirs, paa_router
from .routes import router, start_profile
from .state import AppState, IndiWebApp

Expand Down Expand Up @@ -55,6 +57,10 @@ def _build_parser():
help='HTTP server [standalone|apache] (default: standalone')
parser.add_argument('--sudo', '-S', action='store_true',
help='Run poweroff/reboot commands with sudo')
parser.add_argument('--kstars-logs', default=None, nargs='+',
help='KStars/Ekos log directory/ies. Default: search native and Flatpak locations')
parser.add_argument('--with-paa', action='store_true',
help='Enable the PAA (Polar Alignment Assistant) live monitor')
return parser


Expand All @@ -73,6 +79,14 @@ def parse_args(argv=None):
return args


@asynccontextmanager
async def _lifespan(app: IndiWebApp):
"""Application lifespan: clean up PAA monitor on shutdown."""
yield
if app.state.paa_monitor is not None:
await app.state.paa_monitor.shutdown()


def create_app(argv=None):
"""
Create and configure the FastAPI application.
Expand All @@ -92,8 +106,11 @@ def create_app(argv=None):
format='%(asctime)s - %(levelname)s: %(message)s',
level=logging_level)
else:
logging.basicConfig(format='%(asctime)s - %(levelname)s: %(message)s',
level=logging_level)
from uvicorn.logging import DefaultFormatter
handler = logging.StreamHandler()
handler.setFormatter(DefaultFormatter("%(levelprefix)s %(message)s"))
logging.root.addHandler(handler)
logging.root.setLevel(logging_level)
logging.debug("command line arguments: " + str(vars(args)))

collection = DriverCollection(args.xmldir)
Expand All @@ -104,7 +121,11 @@ def create_app(argv=None):
collection.parse_custom_drivers(db.get_custom_drivers())

templates = Jinja2Templates(directory=views_path)
app = IndiWebApp(title="INDI Web Manager", version=__version__)
paa_monitor = None
if getattr(args, 'with_paa', False):
kstars_log_dirs = args.kstars_logs or [str(d) for d in _default_kstars_log_dirs()]
paa_monitor = PaaMonitor(kstars_log_dirs)
app = IndiWebApp(title="INDI Web Manager", version=__version__, lifespan=_lifespan)
app.state = AppState(
db=db,
collection=collection,
Expand All @@ -115,6 +136,7 @@ def create_app(argv=None):
hostname=socket.gethostname(),
saved_profile=None,
active_profile="",
paa_monitor=paa_monitor,
)

app.add_middleware(
Expand All @@ -128,6 +150,8 @@ def create_app(argv=None):
app.mount("/favicon.ico", StaticFiles(directory=views_path), name="favicon.ico")

app.include_router(router)
if paa_monitor is not None:
app.include_router(paa_router)
return app


Expand Down
Loading