Instrument Neutral Distributed Interface INDI 2.2.5
planewave_mount.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2023 Jasem Mutlaq. All rights reserved.
3
4 Planewave Mount
5 API Communication via PWI4 HTTP Interface
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 "inditelescope.h"
25#include "indipropertytext.h"
26#include "indipropertynumber.h"
27#include "indipropertyswitch.h"
28#include "inicpp.h"
29
30#include <httplib.h>
31#include <memory>
32
34{
35 public:
36 PlaneWave();
37 // Destructor must be declared here (not = default) because the unique_ptr
38 // to the incomplete httplib::Client type must be destroyed in the .cpp.
39 virtual ~PlaneWave();
40
41 virtual const char *getDefaultName() override;
42 virtual bool Handshake() override;
43 virtual bool ReadScopeStatus() override;
44 virtual bool initProperties() override;
45 virtual bool updateProperties() override;
46
47 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
48 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
49 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
50
51 protected:
52 // Motion
53 virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
54 virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
55 virtual bool Abort() override;
56
57 // Time & Location
58 virtual bool updateLocation(double latitude, double longitude, double elevation) override;
59 virtual bool updateTime(ln_date *utc, double utc_offset) override;
60
61 // GOTO & SYNC
62 virtual bool Goto(double ra, double dec) override;
63 virtual bool Sync(double ra, double dec) override;
64
65 // Tracking
66 virtual bool SetTrackMode(uint8_t mode) override;
67 virtual bool SetTrackRate(double raRate, double deRate) override;
68 virtual bool SetTrackEnabled(bool enabled) override;
69
70 // Parking
71 virtual bool SetCurrentPark() override;
72 virtual bool SetDefaultPark() override;
73 virtual bool Park() override;
74 virtual bool UnPark() override;
75
76 // Config items
77 virtual bool saveConfigItems(FILE *fp) override;
78
79 private:
83 bool getStatus();
84 bool enableAxis(int axis, bool enable);
85 double getSlewRateArcsecPerSec() const;
86
90
94 bool dispatch(const std::string &request);
95
99
101 INDI::PropertyText FirmwareTP {1};
102
104 INDI::PropertyText MountGeometryTP {1};
105
107 INDI::PropertyNumber AltAzNP {2};
108 enum { AZ_VALUE, ALT_VALUE };
109
111 INDI::PropertyNumber Axis0TelemetryNP {4};
112 INDI::PropertyNumber Axis1TelemetryNP {4};
113 enum
114 {
115 TELEMETRY_RMS_ERROR,
116 TELEMETRY_DIST_TO_TARGET,
117 TELEMETRY_SERVO_ERROR,
118 TELEMETRY_MOTOR_CURRENT
119 };
120
122 INDI::PropertyNumber DistanceToSunNP {1};
123
127
129 INDI::PropertySwitch Axis0MotorSP {2};
131 INDI::PropertySwitch Axis1MotorSP {2};
132
134 INDI::PropertySwitch FindHomeSP {1};
135
139
141 INDI::PropertyText ModelFilenameTP {1};
142
144 INDI::PropertyNumber ModelInfoNP {3};
145 enum { MODEL_POINTS_TOTAL, MODEL_POINTS_ENABLED, MODEL_RMS_ERROR };
146
148 INDI::PropertySwitch ModelOperationSP {2};
149 enum { MODEL_SAVE_AS_DEFAULT, MODEL_CLEAR_POINTS };
150
152 INDI::PropertyText ModelLoadFilenameTP {1};
153
155 INDI::PropertyText ModelSaveFilenameTP {1};
156
160
162 INDI::PropertyNumber SlewTimeConstantNP {1};
163
167
170
172 std::unique_ptr<httplib::Client> m_HttpClient;
173
177
180 static constexpr double SLEW_RATES[4] {7.5, 30.0, 120.0, 750.0};
182 static constexpr const char *MODEL_TAB {"Pointing Model"};
183};
virtual bool UnPark() override
UnPark — re-enable both motors before clearing the parked state.
virtual bool Abort() override
Abort.
virtual bool updateLocation(double latitude, double longitude, double elevation) override
virtual ~PlaneWave()
virtual bool Sync(double ra, double dec) override
Sync — adds a pointing-model calibration point at the current position.
virtual bool Goto(double ra, double dec) override
Goto — J2000 RA/Dec (INDI convention)
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate — called when the user changes TrackRateNP.
virtual bool Park() override
Park.
virtual bool updateProperties() override
updateProperties
virtual bool SetDefaultPark() override
SetDefaultPark.
virtual bool Handshake() override
Handshake — build the persistent client and verify the mount is live.
virtual bool initProperties() override
initProperties
virtual const char * getDefaultName() override
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
MoveNS — jog in Dec using a continuous offset rate.
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
ISNewText.
virtual bool updateTime(ln_date *utc, double utc_offset) override
updateTime — PWI4 uses the host PC clock; nothing to push.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
ISNewNumber.
PlaneWave()
Constructor / Destructor.
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
MoveWE — jog in RA using a continuous offset rate.
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems
virtual bool ReadScopeStatus() override
ReadScopeStatus — called every polling interval.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
ISNewSwitch.
virtual bool SetCurrentPark() override
SetCurrentPark — tell PWI4 to store the current position as the park point.
double ra
double dec
ISState
Switch state.
Definition indiapi.h:148
INDI_DIR_WE
INDI_DIR_NS