Instrument Neutral Distributed Interface INDI 2.2.5
planewave_rotator.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2026 Jasem Mutlaq. All rights reserved.
3
4 PlaneWave Rotator Driver
5 API Communication via PWI4 HTTP Interface (port 8220)
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License version 2 as published by the Free Software Foundation.
10 .
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15 .
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*******************************************************************************/
21
22#pragma once
23
24#include "indirotator.h"
25#include "indipropertytext.h"
26#include "indipropertynumber.h"
27#include "indipropertyswitch.h"
28#include "indipropertylight.h"
29#include "inicpp.h"
30
31#include <httplib.h>
32#include <memory>
33
47{
48 public:
50 // Destructor must be defined in .cpp so unique_ptr<httplib::Client>
51 // is destroyed after the complete type is known.
53
54 virtual const char *getDefaultName() override;
55 virtual bool initProperties() override;
56 virtual bool updateProperties() override;
57 virtual bool Handshake() override;
58
59 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
60 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
61
62 protected:
63 // ── RotatorInterface pure-virtual overrides ──────────────────────────
64 virtual IPState MoveRotator(double angle) override;
65 virtual bool AbortRotator() override;
66 virtual bool ReverseRotator(bool enabled) override;
67
68 // ── INDI device overrides ─────────────────────────────────────────────
69 virtual void TimerHit() override;
70 virtual bool saveConfigItems(FILE *fp) override;
71
72 private:
76
81 bool dispatch(const std::string &request);
82
84 bool getStatus();
85
89
91 INDI::PropertyText VersionTP {1};
92
94 INDI::PropertySwitch MotorStateSP {2};
95 enum { MOTOR_ENABLE, MOTOR_DISABLE };
96
98 INDI::PropertyNumber MechPositionNP {1};
99
101 INDI::PropertyLight RotatorStatusLP {2};
102 enum { STATUS_CONNECTED, STATUS_ENABLED };
103
107
110
112 std::unique_ptr<httplib::Client> m_HttpClient;
113
115 double m_LastMechPosition {-1.0};
116
118 double m_LastFieldAngle {-1.0};
119
123 static constexpr int DEFAULT_PORT {8220};
124 static constexpr double POSITION_THRESHOLD {0.01};
125};
The PlaneWaveRotator class provides an INDI driver for the PlaneWave Series 5 rotator,...
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
ISNewNumber.
virtual bool AbortRotator() override
AbortRotator — RotatorInterface virtual.
virtual bool updateProperties() override
updateProperties
PlaneWaveRotator()
Constructor / Destructor.
virtual bool Handshake() override
Handshake — build the persistent HTTP client and verify connectivity.
virtual bool ReverseRotator(bool enabled) override
virtual void TimerHit() override
TimerHit — polling loop.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems
virtual ~PlaneWaveRotator()
virtual const char * getDefaultName() override
getDefaultName
virtual IPState MoveRotator(double angle) override
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
ISNewSwitch.
virtual bool initProperties() override
initProperties
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158