Instrument Neutral Distributed Interface INDI  1.9.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-2021
8 
9  Based on IEQPro driver.
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 2.1 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25 
26 #pragma once
27 
28 #include "pmc8driver.h"
29 #include "indiguiderinterface.h"
30 #include "inditelescope.h"
31 
34 
35 typedef struct PMC8MoveInfo
36 {
38  uint8_t moveDir = 0;
39  int targetRate = 0;
40  int rampIteration = 0;
41  int rampLastStep = 0;
43  int timer;
44 } PMC8MoveInfo;
45 
46 
48 {
49  public:
50 
51  PMC8();
52  ~PMC8() override;
53 
54  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
55  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
56 
57  virtual void ISGetProperties(const char *dev) override;
58 
59  protected:
60 
61  virtual const char *getDefaultName() override;
62 
63  virtual bool Handshake() override;
64 
65  virtual bool initProperties() override;
66 
67  virtual bool updateProperties() override;
68 
69  virtual bool ReadScopeStatus() override;
70 
71  virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
72  virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
73 
74  virtual bool saveConfigItems(FILE *fp) override;
75 
76  virtual bool Park() override;
77  virtual bool UnPark() override;
78 
79  virtual bool Sync(double ra, double dec) override;
80  virtual bool Goto(double, double) override;
81  virtual bool Abort() override;
82 
83  virtual bool updateTime(ln_date *utc, double utc_offset) override;
84  virtual bool updateLocation(double latitude, double longitude, double elevation) override;
85 
86  virtual void debugTriggered(bool enable) override;
87  virtual void simulationTriggered(bool enable) override;
88 
89  // Parking
90  virtual bool SetCurrentPark() override;
91  virtual bool SetDefaultPark() override;
92 
93  // Track Mode
94  virtual bool SetTrackMode(uint8_t mode) override;
95 
96  // Track Rate
97  virtual bool SetTrackRate(double raRate, double deRate) override;
98 
99  // Track On/Off
100  virtual bool SetTrackEnabled(bool enabled) override;
101 
102  // Slew Rate
103  virtual bool SetSlewRate(int index) override;
104 
105  // Sim
106  void mountSim();
107 
108  // Guide
109  virtual IPState GuideNorth(uint32_t ms) override;
110  virtual IPState GuideSouth(uint32_t ms) override;
111  virtual IPState GuideEast(uint32_t ms) override;
112  virtual IPState GuideWest(uint32_t ms) override;
113 
114  // Pulse Guide
115  static void guideTimeoutHelperN(void *p);
116  static void guideTimeoutHelperS(void *p);
117  static void guideTimeoutHelperE(void *p);
118  static void guideTimeoutHelperW(void *p);
119  void guideTimeout(PMC8_DIRECTION calldir);
120 
121  //GUIDE variables.
124 
125  // Move
126  static void rampTimeoutHelperN(void *p);
127  static void rampTimeoutHelperS(void *p);
128  static void rampTimeoutHelperE(void *p);
129  static void rampTimeoutHelperW(void *p);
130  bool ramp_movement(PMC8_DIRECTION calldir);
131 
132  int getSlewRate();
133 
134  private:
138  void getStartupData();
139 
140  uint8_t convertToPMC8TrackMode(uint8_t mode);
141  uint8_t convertFromPMC8TrackMode(uint8_t mode);
142 
143  /* Firmware */
144  IText FirmwareT[1] {};
145  ITextVectorProperty FirmwareTP;
146 
147  /* Mount Types */
148  ISwitch MountTypeS[3];
149  ISwitchVectorProperty MountTypeSP;
150 
151  /* SRF Guide Rates */
152  INumber GuideRateN[2];
153  INumberVectorProperty GuideRateNP;
154  INumber LegacyGuideRateN[1];
155  INumberVectorProperty LegacyGuideRateNP;
156 
157  /* Move Ramp Settings */
158  INumber RampN[3];
159  INumberVectorProperty RampNP;
160 
161  // Serial Cable Type
162  ISwitch SerialCableTypeS[3];
163  ISwitchVectorProperty SerialCableTypeSP;
164 
165  // Post-Goto Behavior
166  ISwitch PostGotoS[3];
167  ISwitchVectorProperty PostGotoSP;
168 
169  unsigned int DBG_SCOPE;
170  double currentRA, currentDEC;
171  double targetRA, targetDEC;
172  double currentTrackRate = 0;
173 
174  int trackingPollCounter = 0;
175 
176  bool isPulsingNS = false;
177  bool isPulsingWE = false;
178 
179  PMC8MoveInfo moveInfoRA, moveInfoDEC;
180 
181  //PMC8Info scopeInfo;
182  FirmwareInfo firmwareInfo;
183 };
184 
185 
PMC8::SetTrackRate
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate Set custom tracking rates.
Definition: pmc8.cpp:1537
PMC8_MOVE_INACTIVE
@ PMC8_MOVE_INACTIVE
Definition: pmc8.h:32
PMC8::ramp_movement
bool ramp_movement(PMC8_DIRECTION calldir)
Definition: pmc8.cpp:863
IPState
IPState
Property state.
Definition: indiapi.h:158
PMC8::Handshake
virtual bool Handshake() override
perform handshake with device to check communication
Definition: pmc8.cpp:784
PMC8::ReadScopeStatus
virtual bool ReadScopeStatus() override
Read telescope status.
Definition: pmc8.cpp:435
ISwitch
One switch descriptor.
PMC8::guideTimeoutHelperW
static void guideTimeoutHelperW(void *p)
Definition: pmc8.cpp:1300
PMC8::SetDefaultPark
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
Definition: pmc8.cpp:1457
PMC8_DIRECTION
PMC8_DIRECTION
Definition: pmc8driver.h:59
PMC8::GuideNSTID
int GuideNSTID
Definition: pmc8.h:122
INDI_DIR_NS
INDI_DIR_NS
Definition: indibasetypes.h:44
INumber
One number descriptor.
PMC8::getDefaultName
virtual const char * getDefaultName() override
Definition: pmc8.cpp:74
INDI_DIR_WE
INDI_DIR_WE
Definition: indibasetypes.h:50
PMC8::guideTimeoutHelperS
static void guideTimeoutHelperS(void *p)
Definition: pmc8.cpp:1296
PMC8::guideTimeoutHelperN
static void guideTimeoutHelperN(void *p)
Definition: pmc8.cpp:1292
PMC8::updateProperties
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
Definition: pmc8.cpp:166
PMC8_MOVE_RAMPING
@ PMC8_MOVE_RAMPING
Definition: pmc8.h:32
PMC8::UnPark
virtual bool UnPark() override
Unpark the telescope if already parked.
Definition: pmc8.cpp:770
PMC8MoveInfo::targetRate
int targetRate
Definition: pmc8.h:39
PMC8_MOVE_STATE
PMC8_MOVE_STATE
Definition: pmc8.h:32
PMC8::SetTrackEnabled
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
Definition: pmc8.cpp:1564
PMC8::MoveWE
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
Definition: pmc8.cpp:1029
PMC8MoveInfo::rampIteration
int rampIteration
Definition: pmc8.h:40
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
PMC8::rampTimeoutHelperE
static void rampTimeoutHelperE(void *p)
Definition: pmc8.cpp:950
PMC8::guideTimeoutHelperE
static void guideTimeoutHelperE(void *p)
Definition: pmc8.cpp:1304
PMC8::guideTimeout
void guideTimeout(PMC8_DIRECTION calldir)
Definition: pmc8.cpp:1264
PMC8::rampTimeoutHelperN
static void rampTimeoutHelperN(void *p)
Definition: pmc8.cpp:932
pmc8driver.h
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
ra
double ra
Definition: ieqprolegacydriver.cpp:43
IText
One text descriptor.
PMC8::simulationTriggered
virtual void simulationTriggered(bool enable) override
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
Definition: pmc8.cpp:850
INDI::Telescope::TelescopeMotionCommand
TelescopeMotionCommand
Definition: inditelescope.h:81
INDI::GuiderInterface
Definition: indiguiderinterface.h:50
PMC8::GuideWest
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
Definition: pmc8.cpp:1223
inditelescope.h
dec
double dec
Definition: ieqprolegacydriver.cpp:44
PMC8::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: pmc8.cpp:340
PMC8::~PMC8
~PMC8() override
Definition: pmc8.cpp:70
PMC8::SetTrackMode
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
Definition: pmc8.cpp:1503
INDI::Telescope
Definition: inditelescope.h:70
PMC8::Abort
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
Definition: pmc8.cpp:686
PMC8::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: pmc8.cpp:398
PMC8_RAMP_DIRECTION
PMC8_RAMP_DIRECTION
Definition: pmc8.h:33
PMC8::rampTimeoutHelperW
static void rampTimeoutHelperW(void *p)
Definition: pmc8.cpp:944
PMC8::updateLocation
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
Definition: pmc8.cpp:819
PMC8MoveInfo
struct PMC8MoveInfo PMC8MoveInfo
PMC8::updateTime
virtual bool updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
Definition: pmc8.cpp:808
PMC8::GuideSouth
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
Definition: pmc8.cpp:1140
name
const char * name
Definition: indiserver.c:116
PMC8_RAMP_UP
@ PMC8_RAMP_UP
Definition: pmc8.h:33
indiguiderinterface.h
PMC8MoveInfo::state
PMC8_MOVE_STATE state
Definition: pmc8.h:37
PMC8::debugTriggered
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:845
PMC8::Sync
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:659
PMC8::PMC8
PMC8()
Definition: pmc8.cpp:55
PMC8::SetCurrentPark
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
Definition: pmc8.cpp:1451
PMC8_RAMP_DOWN
@ PMC8_RAMP_DOWN
Definition: pmc8.h:33
PMC8MoveInfo
Definition: pmc8.h:35
PMC8::Goto
virtual bool Goto(double, double) override
Move the scope to the supplied RA and DEC coordinates.
Definition: pmc8.cpp:614
PMC8::ISGetProperties
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:390
FirmwareInfo
Definition: celestrondriver.h:156
PMC8MoveInfo::timer
int timer
Definition: pmc8.h:43
PMC8::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
Definition: pmc8.cpp:1320
PMC8::Park
virtual bool Park() override
Park the telescope to its home position.
Definition: pmc8.cpp:739
ISState
ISState
Switch state.
Definition: indiapi.h:148
PMC8::GuideWETID
int GuideWETID
Definition: pmc8.h:123
PMC8::GuideNorth
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
Definition: pmc8.cpp:1099
PMC8::MoveNS
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
Definition: pmc8.cpp:958
PMC8::getSlewRate
int getSlewRate()
Definition: pmc8.cpp:855
PMC8MoveInfo::moveDir
uint8_t moveDir
Definition: pmc8.h:38
PMC8
Definition: pmc8.h:47
PMC8_MOVE_ACTIVE
@ PMC8_MOVE_ACTIVE
Definition: pmc8.h:32
PMC8MoveInfo::rampDir
PMC8_RAMP_DIRECTION rampDir
Definition: pmc8.h:42
PMC8MoveInfo::rampLastStep
int rampLastStep
Definition: pmc8.h:41
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365
PMC8::SetSlewRate
virtual bool SetSlewRate(int index) override
SetSlewRate Set desired slew rate index.
Definition: pmc8.cpp:1309
PMC8::initProperties
virtual bool initProperties() override
Called to initialize basic properties required all the time.
Definition: pmc8.cpp:79
PMC8::mountSim
void mountSim()
Definition: pmc8.cpp:1333
PMC8::GuideEast
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
Definition: pmc8.cpp:1181
PMC8::rampTimeoutHelperS
static void rampTimeoutHelperS(void *p)
Definition: pmc8.cpp:938