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 Types */
153 ISwitch MountTypeS[3];
154 ISwitchVectorProperty MountTypeSP;
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)
Definition pmc8.h:52
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition pmc8.cpp:348
static void guideTimeoutHelperE(void *p)
Definition pmc8.cpp:1358
virtual void simulationTriggered(bool enable) override
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
Definition pmc8.cpp:899
bool ramp_movement(PMC8_DIRECTION calldir)
Definition pmc8.cpp:912
virtual bool Handshake() override
perform handshake with device to check communication
Definition pmc8.cpp:831
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
Definition pmc8.cpp:1494
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:1374
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
Definition pmc8.cpp:1012
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:986
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:689
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:397
~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:855
static void AbortGotoTimeoutHelper(void *p)
Definition pmc8.cpp:716
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:1601
static void rampTimeoutHelperS(void *p)
Definition pmc8.cpp:992
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
Definition pmc8.cpp:1153
virtual bool ReadScopeStatus() override
Read telescope status.
Definition pmc8.cpp:452
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:1083
static void rampTimeoutHelperE(void *p)
Definition pmc8.cpp:1004
virtual bool Park() override
Park the telescope to its home position.
Definition pmc8.cpp:786
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
Definition pmc8.cpp:1486
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:894
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate Set custom tracking rates.
Definition pmc8.cpp:1577
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
Definition pmc8.cpp:1277
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
Definition pmc8.cpp:866
void mountSim()
Definition pmc8.cpp:1387
static void guideTimeoutHelperS(void *p)
Definition pmc8.cpp:1350
static void guideTimeoutHelperW(void *p)
Definition pmc8.cpp:1354
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:415
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
Definition pmc8.cpp:1235
static void guideTimeoutHelperN(void *p)
Definition pmc8.cpp:1346
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
Definition pmc8.cpp:722
void guideTimeout(PMC8_DIRECTION calldir)
Definition pmc8.cpp:1318
virtual bool Goto(double, double) override
Move the scope to the supplied RA and DEC coordinates.
Definition pmc8.cpp:635
virtual bool UnPark() override
Unpark the telescope if already parked.
Definition pmc8.cpp:817
static void rampTimeoutHelperW(void *p)
Definition pmc8.cpp:998
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
Definition pmc8.cpp:1194
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:1547
int getSlewRate()
Definition pmc8.cpp:904
double ra
double dec
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
INDI_DIR_WE
INDI_DIR_NS
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
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365
Text vector property descriptor.
Definition indiapi.h:244