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
59namespace INDI
60{
61
63{
64 public:
66 enum
67 {
70 };
71
73 enum
74 {
77 };
78
82 enum
83 {
84 PAC_HAS_SPEED = 1 << 0,
85 PAC_CAN_REVERSE = 1 << 1,
87 PAC_CAN_HOME = 1 << 3,
89 PAC_CAN_SYNC = 1 << 5,
91
93 uint32_t GetCapability() const
94 {
95 return m_Capability;
96 }
97
102 void SetCapability(uint32_t cap)
103 {
104 m_Capability = cap;
105 }
106
108 bool HasSpeed()
109 {
110 return m_Capability & PAC_HAS_SPEED;
111 }
112
115 {
116 return m_Capability & PAC_CAN_REVERSE;
117 }
118
121 {
122 return m_Capability & PAC_HAS_POSITION;
123 }
124
126 bool CanHome()
127 {
128 return m_Capability & PAC_CAN_HOME;
129 }
130
133 {
134 return m_Capability & PAC_HAS_BACKLASH;
135 }
136
138 bool CanSync()
139 {
140 return m_Capability & PAC_CAN_SYNC;
141 }
142
143 protected:
145 virtual ~PACInterface() = default;
146
158 virtual IPState MoveAZ(double degrees);
159
171 virtual IPState MoveALT(double degrees);
172
192 virtual IPState MoveBoth(double azDegrees, double altDegrees);
193
202 virtual bool AbortMotion();
203
213 virtual bool SetPACSpeed(uint16_t speed);
214
223 virtual bool ReverseAZ(bool enabled);
224
233 virtual bool ReverseALT(bool enabled);
234
235 // ──────────────────────────────────────────────────────────────────
236 // PAC_CAN_HOME
237 // ──────────────────────────────────────────────────────────────────
238
246 virtual bool SetHome();
247
255 virtual IPState GoHome();
256
264 virtual bool ResetHome();
265
266 // ──────────────────────────────────────────────────────────────────
267 // PAC_CAN_SYNC
268 // ──────────────────────────────────────────────────────────────────
269
278 virtual bool SyncAZ(double degrees);
279
288 virtual bool SyncALT(double degrees);
289
290 // ──────────────────────────────────────────────────────────────────
291 // PAC_HAS_BACKLASH
292 // ──────────────────────────────────────────────────────────────────
293
302 virtual bool SetBacklashEnabled(bool enabled);
303
312 virtual bool SetBacklashAZ(int32_t steps);
313
322 virtual bool SetBacklashALT(int32_t steps);
323
329 void initProperties(const char *group);
330
336 bool updateProperties();
337
339 bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
340
342 bool processNumber(const char *dev, const char *name, double values[], char *names[], int n);
343
350 bool saveConfigItems(FILE *fp);
351
364
370
376
383
388
393
400
408 enum { SYNC_AZ, SYNC_ALT };
409
414
422
423 private:
424 DefaultDevice *m_DefaultDevice {nullptr};
425 uint32_t m_Capability {0};
426};
427
428}
429
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.
enum INDI::PACInterface::@458 PACCapability
PAC capability flags passed to SetCapability().
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.
@ 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
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.
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.
@ POSITION_ALT
Current altitude position in degrees.
@ POSITION_AZ
Current azimuth position in degrees.
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
Namespace to encapsulate INDI client, drivers, and mediator classes.