Instrument Neutral Distributed Interface INDI 2.2.5
pmc8.h
Go to the documentation of this file.
1/*
2 INDI Explore Scientific PMC8 driver
3
4 Copyright (C) 2017 Michael Fulbright
5 Additional contributors:
6 Thomas Olson, Copyright (C) 2019
7 Karl Rees, Copyright (C) 2019-2023
8 Martin Ruiz, Copyright (C) 2023
9
10 Based on IEQPro driver.
11
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Lesser General Public
14 License as published by the Free Software Foundation; either
15 version 2.1 of the License, or (at your option) any later version.
16
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public
23 License along with this library; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25*/
26
27#pragma once
28
29#include "pmc8driver.h"
30#include "indiguiderinterface.h"
31#include "inditelescope.h"
32
35
36// JM 2024.12.03: Since INDI tracking rate is defined as arcsecs per second (SOLAR second), we need to convert from solar to sidereal
37#define SOLAR_SECOND 1.00278551532
38
49
50
52{
53 public:
54
55 PMC8();
56 ~PMC8() override;
57
58 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
59 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
60
61 virtual void ISGetProperties(const char *dev) override;
62
63 protected:
64
65 virtual const char *getDefaultName() override;
66
67 virtual bool Handshake() override;
68
69 virtual bool initProperties() override;
70
71 virtual bool updateProperties() override;
72
73 virtual bool ReadScopeStatus() override;
74
75 virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
76 virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
77
78 virtual bool saveConfigItems(FILE *fp) override;
79
80 virtual bool Park() override;
81 virtual bool UnPark() override;
82
83 virtual bool Sync(double ra, double dec) override;
84 virtual bool Goto(double, double) override;
85 virtual bool Abort() override;
86 static void AbortGotoTimeoutHelper(void *p);
87
88 virtual bool updateTime(ln_date *utc, double utc_offset) override;
89 virtual bool updateLocation(double latitude, double longitude, double elevation) override;
90
91 virtual void debugTriggered(bool enable) override;
92 virtual void simulationTriggered(bool enable) override;
93
94 // Parking
95 virtual bool SetCurrentPark() override;
96 virtual bool SetDefaultPark() override;
97
98 // Track Mode
99 virtual bool SetTrackMode(uint8_t mode) override;
100
101 // Track Rate
102 virtual bool SetTrackRate(double raRate, double deRate) override;
103
104 // Track On/Off
105 virtual bool SetTrackEnabled(bool enabled) override;
106
107 // Slew Rate
108 virtual bool SetSlewRate(int index) override;
109
110 // Sim
111 void mountSim();
112
113 // Guide
114 virtual IPState GuideNorth(uint32_t ms) override;
115 virtual IPState GuideSouth(uint32_t ms) override;
116 virtual IPState GuideEast(uint32_t ms) override;
117 virtual IPState GuideWest(uint32_t ms) override;
118
119 // Pulse Guide
120 static void guideTimeoutHelperN(void *p);
121 static void guideTimeoutHelperS(void *p);
122 static void guideTimeoutHelperE(void *p);
123 static void guideTimeoutHelperW(void *p);
124 void guideTimeout(PMC8_DIRECTION calldir);
125
126 //GUIDE variables.
129
130 // Move
131 static void rampTimeoutHelperN(void *p);
132 static void rampTimeoutHelperS(void *p);
133 static void rampTimeoutHelperE(void *p);
134 static void rampTimeoutHelperW(void *p);
135 bool ramp_movement(PMC8_DIRECTION calldir);
136
137 int getSlewRate();
138
139 private:
143 void getStartupData();
144
145 uint8_t convertToPMC8TrackMode(uint8_t mode);
146 uint8_t convertFromPMC8TrackMode(uint8_t mode);
147
148 /* Firmware */
149 IText FirmwareT[1] {};
150 ITextVectorProperty FirmwareTP;
151
152 /* Mount Model (G11, EXOS2, iEXOS100). Kept as MOUNT_TYPE for config compatibility. */
153 ISwitch MountModelS[3];
154 ISwitchVectorProperty MountModelSP;
155
156 /* SRF Guide Rates */
157 INumber GuideRateN[2];
158 INumberVectorProperty GuideRateNP;
159 INumber LegacyGuideRateN[1];
160 INumberVectorProperty LegacyGuideRateNP;
161
162 /* Move Ramp Settings */
163 INumber RampN[3];
165
166 // Serial Cable Type
167 ISwitch SerialCableTypeS[3];
168 ISwitchVectorProperty SerialCableTypeSP;
169
170 // Post-Goto Behavior
171 ISwitch PostGotoS[3];
172 ISwitchVectorProperty PostGotoSP;
173
174 unsigned int DBG_SCOPE;
175 double currentRA, currentDEC;
176 double targetRA, targetDEC;
177
178 int trackingPollCounter = 0;
179
180 bool isPulsingNS = false;
181 bool isPulsingWE = false;
182
183 PMC8MoveInfo moveInfoRA, moveInfoDEC;
184
185 //PMC8Info scopeInfo;
186 FirmwareInfo firmwareInfo;
187};
188
189
int SetSlewRate(void)
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition pmc8.cpp:349
static void guideTimeoutHelperE(void *p)
Definition pmc8.cpp:1359
virtual void simulationTriggered(bool enable) override
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
Definition pmc8.cpp:900
bool ramp_movement(PMC8_DIRECTION calldir)
Definition pmc8.cpp:913
virtual bool Handshake() override
perform handshake with device to check communication
Definition pmc8.cpp:832
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
Definition pmc8.cpp:1495
PMC8()
Definition pmc8.cpp:59
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
Definition pmc8.cpp:1375
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
Definition pmc8.cpp:1013
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
Definition pmc8.cpp:171
static void rampTimeoutHelperN(void *p)
Definition pmc8.cpp:987
virtual bool Sync(double ra, double dec) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
Definition pmc8.cpp:690
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
Definition pmc8.cpp:398
~PMC8() override
Definition pmc8.cpp:77
virtual bool updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
Definition pmc8.cpp:856
static void AbortGotoTimeoutHelper(void *p)
Definition pmc8.cpp:717
virtual const char * getDefaultName() override
Definition pmc8.cpp:81
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
Definition pmc8.cpp:1602
static void rampTimeoutHelperS(void *p)
Definition pmc8.cpp:993
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
Definition pmc8.cpp:1154
virtual bool ReadScopeStatus() override
Read telescope status.
Definition pmc8.cpp:453
int GuideNSTID
Definition pmc8.h:127
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
Definition pmc8.cpp:1084
static void rampTimeoutHelperE(void *p)
Definition pmc8.cpp:1005
virtual bool Park() override
Park the telescope to its home position.
Definition pmc8.cpp:787
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
Definition pmc8.cpp:1487
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
Definition pmc8.cpp:895
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate Set custom tracking rates.
Definition pmc8.cpp:1578
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
Definition pmc8.cpp:1278
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
Definition pmc8.cpp:867
void mountSim()
Definition pmc8.cpp:1388
static void guideTimeoutHelperS(void *p)
Definition pmc8.cpp:1351
static void guideTimeoutHelperW(void *p)
Definition pmc8.cpp:1355
virtual bool initProperties() override
Called to initialize basic properties required all the time.
Definition pmc8.cpp:86
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition pmc8.cpp:416
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
Definition pmc8.cpp:1236
static void guideTimeoutHelperN(void *p)
Definition pmc8.cpp:1347
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
Definition pmc8.cpp:723
void guideTimeout(PMC8_DIRECTION calldir)
Definition pmc8.cpp:1319
virtual bool Goto(double, double) override
Move the scope to the supplied RA and DEC coordinates.
Definition pmc8.cpp:636
virtual bool UnPark() override
Unpark the telescope if already parked.
Definition pmc8.cpp:818
static void rampTimeoutHelperW(void *p)
Definition pmc8.cpp:999
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
Definition pmc8.cpp:1195
int GuideWETID
Definition pmc8.h:128
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
Definition pmc8.cpp:1548
int getSlewRate()
Definition pmc8.cpp:905
#define currentDEC
Definition ieq45.cpp:48
#define currentRA
Definition ieq45.cpp:47
double ra
double dec
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
struct _ISwitchVectorProperty ISwitchVectorProperty
struct _ITextVectorProperty ITextVectorProperty
struct _INumberVectorProperty INumberVectorProperty
INDI_DIR_WE
INDI_DIR_NS
*brief user defined string literal for JSON values *sa std::size_t n
unsigned int DBG_SCOPE
PMC8_MOVE_STATE
Definition pmc8.h:33
@ PMC8_MOVE_INACTIVE
Definition pmc8.h:33
@ PMC8_MOVE_RAMPING
Definition pmc8.h:33
@ PMC8_MOVE_ACTIVE
Definition pmc8.h:33
PMC8_RAMP_DIRECTION
Definition pmc8.h:34
@ PMC8_RAMP_UP
Definition pmc8.h:34
@ PMC8_RAMP_DOWN
Definition pmc8.h:34
PMC8_DIRECTION
Definition pmc8driver.h:64
One number descriptor.
One switch descriptor.
One text descriptor.
PMC8_RAMP_DIRECTION rampDir
Definition pmc8.h:46
int targetRate
Definition pmc8.h:43
int rampLastStep
Definition pmc8.h:45
int timer
Definition pmc8.h:47
PMC8_MOVE_STATE state
Definition pmc8.h:41
uint8_t moveDir
Definition pmc8.h:42
int rampIteration
Definition pmc8.h:44