How ascominitiative/alpycadevice works
Project type and purpose
• This is an open-source Python SDK (framework) for building ASCOM Alpaca device drivers.
• Its core is a “server” (device/app.py) that hosts one or more device implementations (e.g., the sample Rotator) over the Alpaca HTTP API.
• It also ships a rich set of templates for generating skeleton drivers for all ASCOM device types, plus a suite of ConformU tests in the thunder-tests folder.
File structure
• Top-level:
• device/ – core SDK modules and sample driver
• templates/ – code skeletons for all ASCOM device types
• docs/ – Sphinx documentation source
• thunder-tests/ – HTTP collection tests for ConformU
• Key modules under device/:
• app.py – entry point and HTTP server
• management.py – driver registration and lifecycle
• discovery.py – mDNS/Alpaca service discovery
• rotatordevice.py & rotator.py – the sample device implementation
• config.py & config.toml – runtime settings
• log.py & exceptions.py – logging and error handling
• setup.py – package metadata
• No database or external queue – purely in-memory drivers with HTTP interface.
Extract insights from the README
• Purpose: “lightweight Python framework” for any ASCOM device over Alpaca.
• Features: built-in ConformU passing sample, plus boilerplate templates.
• Usage: run device/app.py→HTTP endpoints→client tools (SkySafari, SGP, ConformU).
• External dependencies: ASCOM Platform 7, ConformU test suite, and any Alpaca-speaking client (e.g., Cartes du Ciel).
Main components
a. Alpaca Server
• DeviceApp (HTTP server - device/app.py)
• Driver Manager (device/management.py)
• Service Discovery (device/discovery.py)
b. Device Implementations
• Rotator (sample: rotator.py + rotatordevice.py)
• Other skeletons (from templates/…)
c. Configuration & Logging
• Config loader (config.py + config.toml)
• Logging subsystem (log.py)
d. External Clients & Tools
• ConformU test runner (thunder-tests)
• Alpaca-speaking applications (SkySafari, SGP, etc.)
e. Documentation system (Sphinx in docs/) – shown as a peripheral component.
Relationships and interactions
• External Client → HTTP(S) → Alpaca Server (app.py)
• Server → Driver Manager → Selected Device Implementation → domain logic
• Server ↔ Config loader (on startup)
• Server → Logging
• Server → Service Discovery (mDNS announcements)
• ConformU tests behave like another external client
• Templates are offline code-generation artifacts (no runtime link, but important for extensibility)
Architectural patterns & design principles
• Modular layering:
• Presentation/API layer (app.py + HTTP routes)
• Management/Dispatcher layer (management.py)
• Device business logic layer (rotator.py, plus template-generated peers)
• Plugin-style extensibility: new devices drop in and register via the same driver manager.
• Configuration-first initialization: one central TOML file.
• No persistent storage: purely in-memory simulation unless extended.