A comprehensive C++ Qt-based simulator for the Celestron Origin telescope system that implements both WebSocket and HTTP protocols for complete telescope control and image serving functionality.
- Complete Protocol Implementation: Supports both WebSocket control commands and HTTP image serving
- Real-time Status Updates: Broadcasts telescope status, focuser, camera, and environmental data
- Command Processing: Handles telescope control commands including alignment, GOTO, tracking, and imaging
- Image Simulation: Serves simulated telescope images via HTTP
- Network Discovery: Broadcasts UDP discovery messages for automatic telescope detection
- WebSocket Ping/Pong: Proper WebSocket heartbeat implementation with timeout handling
The simulator is organized into several key components:
TelescopeState: Maintains all telescope state data (mount, camera, focuser, environment, etc.)CelestronOriginSimulator: Main simulator class handling network protocols and coordinationWebSocketConnection: Manages individual WebSocket connections with proper frame handlingCommandHandler: Processes telescope control commands and updates stateStatusSender: Manages status broadcasts to connected clients
- Dual Protocol Support: WebSocket for control, HTTP for image serving
- Proper WebSocket Implementation: Complete frame parsing, ping/pong, close handling
- Command Processing: Supports mount control, focuser operations, camera settings, and more
- Status Broadcasting: Regular status updates to all connected clients
- Image Generation: Creates realistic dummy telescope images with star fields
RunInitialize- Initialize telescope with location/timeStartAlignment/AddAlignmentPoint/FinishAlignment- Alignment sequenceGotoRaDec- Slew to coordinatesStartTracking/StopTracking- Tracking controlAbortAxisMovement- Emergency stop
GetCaptureParameters/SetCaptureParameters- Camera settingsRunImaging/CancelImaging- Imaging operationsGetFilter- Filter wheel status
MoveToPosition- Move focuser to positionGetStatus- Get focuser statusSetBacklash- Set backlash compensation
GetStatus- Get component status (Mount, Camera, Focuser, etc.)GetVersion- Get firmware versionGetModel- Get device model and capabilities
- Endpoint:
ws://localhost/SmartScope-1.0/mountControlEndpoint - Purpose: Real-time telescope control and status
- Features: Command/response, status notifications, ping/pong heartbeat
- Live Images:
http://localhost/SmartScope-1.0/dev2/Images/Temp/ - Astrophotography:
http://localhost/SmartScope-1.0/dev2/Images/Astrophotography/ - Purpose: Serve telescope images and captures
- Purpose: Network discovery
- Message: "Origin IP Address: [IP] Identity: Origin140020 Version: 1.1.4248"
- Qt 5.12 or later
- C++11 compatible compiler
- macOS (for Xcode project generation)
qmake OriginSimulator.pro
makeqmake -spec macx-xcode OriginSimulator.pro
open OriginSimulator.xcodeproj-
Start the Simulator:
./OriginSimulator
-
Connect via WebSocket:
const ws = new WebSocket('ws://localhost/SmartScope-1.0/mountControlEndpoint');
-
Send Commands:
{ "Command": "GetStatus", "Destination": "Mount", "SequenceID": 1, "Source": "TestClient", "Type": "Command" } -
View Images: Open
http://localhost/SmartScope-1.0/dev2/Images/Temp/0.jpgin browser
├── TelescopeState.h # Telescope state data structure
├── CelestronOriginSimulator.h # Main simulator class
├── CelestronOriginSimulator.cpp
├── WebSocketConnection.h # WebSocket protocol handler
├── WebSocketConnection.cpp
├── CommandHandler.h # Command processing
├── CommandHandler.cpp
├── StatusSender.h # Status broadcast manager
├── StatusSender.cpp
├── main.cpp # Application entry point
├── OriginSimulator.pro # Qt project file
└── README.md # This file
- Full RFC 6455 compliance for frame parsing
- Proper masking/unmasking for client frames
- Ping/pong heartbeat with 10-second timeout
- Graceful connection closure with status codes
- Asynchronous command handling
- Proper error responses with codes/messages
- State validation for operations (e.g., alignment required for GOTO)
- Realistic timing simulation for slews and imaging
- Regular status updates every second
- Component-specific update intervals
- Efficient JSON message construction
- Selective client notification support
The simulator has been tested with:
- WebSocket clients (browser, Node.js)
- HTTP image requests
- Multiple simultaneous connections
- Command sequences and error conditions
- Network discovery via UDP
- Support for additional telescope commands
- More realistic imaging simulation
- Configuration file support
- Logging and debugging features
- Additional image formats and metadata