Instrument Neutral Distributed Interface INDI  2.0.2
ioptronv3.h
Go to the documentation of this file.
1 /*
2  INDI IOptron v3 Driver for firmware version 20171001 or later.
3 
4  Copyright (C) 2018 Jasem Mutlaq
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  Updated for PEC V3
21 */
22 
23 #pragma once
24 
25 #include <memory>
26 
27 #include "ioptronv3driver.h"
28 #include "indiguiderinterface.h"
29 #include "inditelescope.h"
30 
32 {
33  public:
34 
35  IOptronV3();
36 
37  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
38  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
39 
40  protected:
41  virtual const char *getDefaultName() override;
42 
43  virtual bool Handshake() override;
44 
45  virtual bool initProperties() override;
46  virtual bool updateProperties() override;
47 
48  virtual bool ReadScopeStatus() override;
49 
50  virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
51  virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
52 
53  virtual bool saveConfigItems(FILE *fp) override;
54 
55  virtual bool Park() override;
56  virtual bool UnPark() override;
57 
58  virtual bool Sync(double ra, double de) override;
59  virtual bool Goto(double ra, double de) override;
60  virtual bool Abort() override;
61 
62  virtual bool updateTime(ln_date *utc, double utc_offset) override;
63  virtual bool updateLocation(double latitude, double longitude, double elevation) override;
64 
65  virtual void debugTriggered(bool enable) override;
66  virtual void simulationTriggered(bool enable) override;
67 
68  // Parking
69  virtual bool SetCurrentPark() override;
70  virtual bool SetDefaultPark() override;
71 
72  // Track Mode
73  virtual bool SetTrackMode(uint8_t mode) override;
74 
75  // Track Rate
76  virtual bool SetTrackRate(double raRate, double deRate) override;
77 
78  // Track On/Off
79  virtual bool SetTrackEnabled(bool enabled) override;
80 
81  // Slew Rate
82  virtual bool SetSlewRate(int index) override;
83 
84  // Sim
85  void mountSim();
86 
87  // Guide
88  virtual IPState GuideNorth(uint32_t ms) override;
89  virtual IPState GuideSouth(uint32_t ms) override;
90  virtual IPState GuideEast(uint32_t ms) override;
91  virtual IPState GuideWest(uint32_t ms) override;
92 
93  private:
97  void getStartupData();
98 
104  bool GetPECDataStatus(bool enabled);
105 
106  /* Mod v3.0 Adding PEC Recording Switches */
107  ISwitch PECTrainingS[2];
108  ISwitchVectorProperty PECTrainingSP;
109 
110  ITextVectorProperty PECInfoTP;
111  IText PECInfoT[2] {};
112 
113  int PECTime {false};
114  bool isTraining {false};
115  // End Mod */
116 
117  /* Firmware */
118  IText FirmwareT[5] {};
119  ITextVectorProperty FirmwareTP;
120 
121  /* GPS Status */
122  ISwitch GPSStatusS[3];
123  ISwitchVectorProperty GPSStatusSP;
124 
125  /* Time Source */
126  ISwitch TimeSourceS[3];
127  ISwitchVectorProperty TimeSourceSP;
128 
129  /* Hemisphere */
130  ISwitch HemisphereS[2];
131  ISwitchVectorProperty HemisphereSP;
132 
133  /* Home Control */
134  ISwitch HomeS[3];
135  ISwitchVectorProperty HomeSP;
136 
137  /* Guide Rate */
138  INumber GuideRateN[2];
139  INumberVectorProperty GuideRateNP;
140 
141  /* Slew Mode */
142  ISwitch SlewModeS[2];
143  ISwitchVectorProperty SlewModeSP;
144 
145  /* Counterweight Status */
146  ISwitch CWStateS[2];
147  ISwitchVectorProperty CWStateSP;
148 
149  /* Daylight Saving */
150  ISwitch DaylightS[2];
151  ISwitchVectorProperty DaylightSP;
152 
153  // Meridian Behavior
154  ISwitch MeridianActionS[2];
155  ISwitchVectorProperty MeridianActionSP;
156 
157  // Meridian Limit
158  INumber MeridianLimitN[1];
159  INumberVectorProperty MeridianLimitNP;
160 
161  uint32_t DBG_SCOPE;
162 
163  double currentRA, currentDEC;
164  double targetRA, targetDEC;
165 
166  IOPv3::IOPInfo scopeInfo;
167  IOPv3::FirmwareInfo firmwareInfo;
168 
169  uint8_t m_ParkingCounter {0};
170  static constexpr const uint8_t MAX_PARK_COUNTER {2};
171  static constexpr const char *MB_TAB {"Meridian Behavior"};
172 
173  std::unique_ptr<IOPv3::Driver> driver;
174 };
virtual bool Goto(double ra, double de) override
Move the scope to the supplied RA and DEC coordinates.
Definition: ioptronv3.cpp:843
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
Definition: ioptronv3.cpp:1077
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
Definition: ioptronv3.cpp:1101
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
Definition: ioptronv3.cpp:1003
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate Set custom tracking rates.
Definition: ioptronv3.cpp:1242
virtual const char * getDefaultName() override
Definition: ioptronv3.cpp:72
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
Definition: ioptronv3.cpp:1232
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: ioptronv3.cpp:433
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
Definition: ioptronv3.cpp:1037
virtual bool Park() override
Park the telescope to its home position.
Definition: ioptronv3.cpp:904
virtual bool UnPark() override
Unpark the telescope if already parked.
Definition: ioptronv3.cpp:926
virtual void simulationTriggered(bool enable) override
Inform driver that the simulation option was triggered. This function is called after setSimulation i...
Definition: ioptronv3.cpp:998
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
Definition: ioptronv3.cpp:1203
void mountSim()
Definition: ioptronv3.cpp:1114
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
Definition: ioptronv3.cpp:1071
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
Definition: ioptronv3.cpp:965
virtual bool Sync(double ra, double de) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
Definition: ioptronv3.cpp:876
virtual bool Handshake() override
perform handshake with device to check communication
Definition: ioptronv3.cpp:946
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
Definition: ioptronv3.cpp:1262
virtual bool ReadScopeStatus() override
Read telescope status.
Definition: ioptronv3.cpp:684
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: ioptronv3.cpp:480
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
Definition: ioptronv3.cpp:1221
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
Definition: ioptronv3.cpp:220
virtual void debugTriggered(bool enable) override
Inform driver that the debug option was triggered. This function is called after setDebug is triggere...
Definition: ioptronv3.cpp:993
virtual bool updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
Definition: ioptronv3.cpp:956
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
Definition: ioptronv3.cpp:1083
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
Definition: ioptronv3.cpp:899
virtual bool initProperties() override
Called to initialize basic properties required all the time.
Definition: ioptronv3.cpp:77
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
Definition: ioptronv3.cpp:1089
virtual bool SetSlewRate(int index) override
SetSlewRate Set desired slew rate index.
Definition: ioptronv3.cpp:1095
double ra
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
INDI_DIR_WE
Definition: indibasetypes.h:55
INDI_DIR_NS
Definition: indibasetypes.h:48
One number descriptor.
One switch descriptor.
One text descriptor.
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367
Text vector property descriptor.
Definition: indiapi.h:246