Instrument Neutral Distributed Interface INDI 2.2.5
indipacinterface.h
Go to the documentation of this file.
1/*
2 PAC Interface (Polar Alignment Correction)
3 Copyright (C) 2026 Joaquin Rodriguez ([email protected])
4 Copyright (C) 2026 Jasem Mutlaq ([email protected])
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20*/
21
22#pragma once
23
24#include "indibase.h"
25#include "indidriver.h"
26#include "indipropertyswitch.h"
27#include "indipropertynumber.h"
28#include <cstdint>
29
65
66namespace INDI
67{
68
70{
71 public:
73 enum
74 {
77 };
78
80 enum
81 {
84 };
85
89 enum
90 {
91 PAC_HAS_SPEED = 1 << 0,
92 PAC_CAN_REVERSE = 1 << 1,
94 PAC_CAN_HOME = 1 << 3,
96 PAC_CAN_SYNC = 1 << 5,
98
100 uint32_t GetCapability() const
101 {
102 return m_Capability;
103 }
104
109 void SetCapability(uint32_t cap)
110 {
111 m_Capability = cap;
112 }
113
115 bool HasSpeed()
116 {
117 return m_Capability & PAC_HAS_SPEED;
118 }
119
122 {
123 return m_Capability & PAC_CAN_REVERSE;
124 }
125
128 {
129 return m_Capability & PAC_HAS_POSITION;
130 }
131
133 bool CanHome()
134 {
135 return m_Capability & PAC_CAN_HOME;
136 }
137
140 {
141 return m_Capability & PAC_HAS_BACKLASH;
142 }
143
145 bool CanSync()
146 {
147 return m_Capability & PAC_CAN_SYNC;
148 }
149
150 protected:
152 virtual ~PACInterface() = default;
153
165 virtual IPState MoveAZ(double degrees);
166
178 virtual IPState MoveALT(double degrees);
179
199 virtual IPState MoveBoth(double azDegrees, double altDegrees);
200
209 virtual bool AbortMotion();
210
220 virtual bool SetPACSpeed(uint16_t speed);
221
230 virtual bool ReverseAZ(bool enabled);
231
240 virtual bool ReverseALT(bool enabled);
241
242 // ──────────────────────────────────────────────────────────────────
243 // PAC_CAN_HOME
244 // ──────────────────────────────────────────────────────────────────
245
253 virtual bool SetHome();
254
262 virtual IPState GoHome();
263
271 virtual bool ResetHome();
272
273 // ──────────────────────────────────────────────────────────────────
274 // PAC_CAN_SYNC
275 // ──────────────────────────────────────────────────────────────────
276
285 virtual bool SyncAZ(double degrees);
286
295 virtual bool SyncALT(double degrees);
296
297 // ──────────────────────────────────────────────────────────────────
298 // PAC_HAS_BACKLASH
299 // ──────────────────────────────────────────────────────────────────
300
309 virtual bool SetBacklashEnabled(bool enabled);
310
319 virtual bool SetBacklashAZ(int32_t steps);
320
329 virtual bool SetBacklashALT(int32_t steps);
330
336 void initProperties(const char *group);
337
343 bool updateProperties();
344
346 bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
347
349 bool processNumber(const char *dev, const char *name, double values[], char *names[], int n);
350
357 bool saveConfigItems(FILE *fp);
358
371
377
383
390
395
400
407
415 enum { SYNC_AZ, SYNC_ALT };
416
421
429
430 private:
431 DefaultDevice *m_DefaultDevice {nullptr};
432 uint32_t m_Capability {0};
433};
434
435}
436
hid_device * device
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
virtual bool SetPACSpeed(uint16_t speed)
SetPACSpeed Set the motor speed used for axis movements.
INDI::PropertyNumber SyncNP
virtual bool ReverseALT(bool enabled)
ReverseALT Reverse the direction of altitude axis movement.
virtual bool ResetHome()
ResetHome Clear the stored home reference without moving.
virtual bool SetBacklashEnabled(bool enabled)
SetBacklashEnabled Enable or disable hardware backlash compensation.
INDI::PropertySwitch BacklashSP
virtual IPState GoHome()
GoHome Slew both axes back to the home (0, 0) position.
PACInterface(DefaultDevice *device)
@ MANUAL_AZ
Azimuth step in degrees: positive = East, negative = West.
@ MANUAL_ALT
Altitude step in degrees: positive = North, negative = South.
bool saveConfigItems(FILE *fp)
saveConfigItems Save PAC interface properties to config file. Call this from your driver's saveConfig...
virtual bool SetHome()
SetHome Mark the current position as the home (zero) reference.
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process PAC number properties.
INDI::PropertyNumber SpeedNP
@ POSITION_ALT
Current altitude position in degrees.
@ POSITION_AZ
Current azimuth position in degrees.
void initProperties(const char *group)
initProperties Initialize PAC properties. Call this from your driver's initProperties().
virtual bool SetBacklashALT(int32_t steps)
SetBacklashALT Set the altitude axis backlash compensation value in steps.
void SetCapability(uint32_t cap)
SetCapability sets the PAC device capabilities. Call this in the driver constructor.
virtual bool SetBacklashAZ(int32_t steps)
SetBacklashAZ Set the azimuth axis backlash compensation value in steps.
virtual bool AbortMotion()
AbortMotion Abort all axis motion immediately.
virtual bool ReverseAZ(bool enabled)
ReverseAZ Reverse the direction of azimuth axis movement.
enum INDI::PACInterface::@325005317353003273026150071354333012037230166273 PACCapability
PAC capability flags passed to SetCapability().
INDI::PropertyNumber PositionNP
INDI::PropertyNumber ManualAdjustmentNP
virtual ~PACInterface()=default
virtual IPState MoveAZ(double degrees)
Move the azimuth axis by the given number of degrees.
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process PAC switch properties.
bool updateProperties()
updateProperties Define or delete properties based on connection state. Call this from your driver's ...
virtual bool SyncALT(double degrees)
SyncALT Sync the altitude position reference to the given value without moving.
INDI::PropertySwitch ALTReverseSP
virtual bool SyncAZ(double degrees)
SyncAZ Sync the azimuth position reference to the given value without moving.
virtual IPState MoveBoth(double azDegrees, double altDegrees)
MoveBoth Move both axes in a single coordinated operation.
virtual IPState MoveALT(double degrees)
MoveALT Move the altitude axis by the given number of degrees.
INDI::PropertySwitch HomeSP
uint32_t GetCapability() const
INDI::PropertySwitch AZReverseSP
INDI::PropertySwitch AbortSP
INDI::PropertyNumber BacklashNP
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
*brief user defined string literal for JSON values *sa std::size_t n
INDI::PACInterface PACI
Namespace to encapsulate INDI client, drivers, and mediator classes.