Instrument Neutral Distributed Interface INDI  2.0.2
synscandriverlegacy.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2010 Gerry Rozema. All rights reserved.
3  Copyright(c) 2018 Jasem Mutlaq. All rights reserved.
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 *******************************************************************************/
19 
20 #pragma once
21 
22 #include "inditelescope.h"
23 
25 {
26  public:
28 
29  virtual bool updateProperties() override;
30  virtual const char *getDefaultName() override;
31  virtual bool initProperties() override;
32 
33  virtual bool Connect() override;
34 
35  virtual bool ReadScopeStatus() override;
36 
37  virtual bool Goto(double, double) override;
38  virtual bool Park() override;
39  virtual bool UnPark() override;
40  virtual bool Abort() override;
41  virtual bool SetSlewRate(int index) override;
42  virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
43  virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
44 
45  virtual bool updateLocation(double latitude, double longitude, double elevation) override;
46  virtual bool updateTime(ln_date *utc, double utc_offset) override;
47  virtual bool SetCurrentPark() override;
48  virtual bool SetDefaultPark() override;
49 
50  // methods added for alignment subsystem
51  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
52  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
53  virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[],
54  char *formats[], char *names[], int n) override;
55  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
56  virtual bool Sync(double ra, double dec) override;
57 
58  protected:
59  virtual bool AnalyzeMount();
60  virtual void initParking();
61  bool StartTrackMode();
62  bool ReadTime();
63  bool ReadLocation();
64 
65  int HexStrToInteger(const std::string &str);
66 
67  double SlewTargetAlt { -1 };
68  double SlewTargetAz { -1 };
69  double CurrentRA { 0 };
70  double CurrentDEC { 0 };
71  double TargetRA {0};
72  double TargetDEC {0};
73  bool CanSetLocation { false };
74  bool ReadLatLong { false };
75  int MountCode { 0 };
76  int SlewRate { 5 };
77  bool NewFirmware { false };
78  double FirmwareVersion { 0 };
79 
80  std::string HandsetFwVersion;
81  std::string AlignmentStatus;
82  std::string GotoStatus;
83  std::string PointingStatus;
84  std::string TrackingStatus;
85  std::string TrackingMode;
86 
87  private:
88  int PassthruCommand(int cmd, int target, int msgsize, int data, int numReturn);
89  void UpdateMountInformation(bool inform_client);
90  void MountSim();
91 
92  char LastParkRead[20];
93  int NumPark { 0 };
94  int StopCount { 0 };
95  int CustomNSSlewRate { -1 };
96  int CustomWESlewRate { -1 };
97  int RecoverTrials { 0 };
98 
99  IText BasicMountInfoT[6] = {};
100  ITextVectorProperty BasicMountInfoTP;
101  enum MountInfo
102  {
103  MI_FW_VERSION,
104  MI_MOUNT_CODE,
105  MI_ALIGN_STATUS,
106  MI_GOTO_STATUS,
107  MI_POINT_STATUS,
108  MI_TRACK_MODE
109  };
110 
111  // ISwitch UseWiFiS[2];
112  // ISwitchVectorProperty UseWiFiSP;
113  // enum UseWiFiMembers
114  // {
115  // WIFI_ENABLED,
116  // WIFI_DISABLED,
117  // };
118 
119 
120  static constexpr uint16_t SLEW_RATE[] = {1, 2, 8, 16, 64, 128, 256, 512, 1024};
121  static constexpr const char * MountInfoPage = "Mount Information";
122  static const uint8_t MAX_SYN_BUF = 64;
123 };
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool Sync(double ra, double dec) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) override
Process the client newBLOB command.
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual bool updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual const char * getDefaultName() override
int HexStrToInteger(const std::string &str)
virtual bool Goto(double, double) override
Move the scope to the supplied RA and DEC coordinates.
virtual bool Park() override
Park the telescope to its home position.
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool SetSlewRate(int index) override
SetSlewRate Set desired slew rate index.
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual bool ReadScopeStatus() override
Read telescope status.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
double ra
double dec
ISState
Switch state.
Definition: indiapi.h:150
INDI_DIR_WE
Definition: indibasetypes.h:55
INDI_DIR_NS
Definition: indibasetypes.h:48
__u8 cmd[4]
Definition: pwc-ioctl.h:2
One text descriptor.
Text vector property descriptor.
Definition: indiapi.h:246