Instrument Neutral Distributed Interface INDI 2.2.5
rainbow.h
Go to the documentation of this file.
1/*
2 Rainbow Mount Driver
3 Copyright (C) 2020 Jasem Mutlaq ([email protected])
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19*/
20
21#pragma once
22
23#include "inditelescope.h"
24#include "indiguiderinterface.h"
25
26#define ALIGNMENT_TAB "Alignment"
27#define GENERAL_INFO_TAB "General Info"
28
29
31{
32 public:
33 Rainbow();
34
35 const char *getDefaultName() override;
36 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
37 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
38
39 typedef enum { Equatorial, Horizontal } GotoType;
40 typedef enum { North, South, West, East } Direction;
41
42 protected:
43 virtual bool initProperties() override;
44 virtual bool updateProperties() override;
45 virtual bool Handshake() override;
46
50 // Is slew over?
51 virtual bool isSlewComplete();
52 // Goto
53 virtual bool Goto(double ra, double dec) override;
54 // Read mount state
55 virtual bool ReadScopeStatus() override;
56 // Abort
57 virtual bool Abort() override;
58 // N/S manual motion
59 virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
60 // W/E manual motion
61 virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
62 // Slew Rate
63 virtual bool SetSlewRate(int index) override;
64 // Syncing
65 virtual bool Sync(double ra, double dec) override;
66 // Home
67 virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override;
68
69 // RA/DE
70 bool getRA();
71 bool getDE();
72 bool setRA(double ra);
73 bool setDE(double de);
74 // Slew to RA/DE
75 bool slewToEquatorialCoords(double ra, double de);
76
77
81 // Toggle Tracking
82 virtual bool SetTrackEnabled(bool enabled) override;
83 virtual bool SetTrackMode(uint8_t mode) override;
84 bool getTrackingState();
85
89 void getStartupStatus();
90 bool getFirmwareVersion();
92
96 virtual bool updateLocation(double latitude, double longitude, double elevation) override;
97 //virtual bool updateTime(ln_date *utc, double utc_offset) override;
98
102 virtual IPState GuideNorth(uint32_t ms) override;
103 virtual IPState GuideSouth(uint32_t ms) override;
104 virtual IPState GuideEast(uint32_t ms) override;
105 virtual IPState GuideWest(uint32_t ms) override;
106
107 static void guideTimeoutHelperN(void *p);
108 static void guideTimeoutHelperS(void *p);
109 static void guideTimeoutHelperW(void *p);
110 static void guideTimeoutHelperE(void *p);
111
112 IPState guide(Direction direction, uint32_t ms);
113 void guideTimeout(Direction direction);
114 void addGuideTimer(Direction direction, uint32_t ms);
115 bool setGuideRate(double rate);
116 bool getGuideRate();
117
121 // Parking
122 virtual bool Park() override;
123 virtual bool UnPark() override;
124 virtual bool SetCurrentPark() override;
125 virtual bool SetDefaultPark() override;
126 // Homing
127 bool findHome();
129
133 bool sendScopeTime();
134 bool sendScopeLocation();
135 bool getUTFOffset(double *offset);
136 bool getLocalDate(char *dateString);
137 bool getLocalTime(char *timeString);
138
142 bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
143 void hexDump(char * buf, const char * data, int size);
144 std::vector<std::string> split(const std::string &input, const std::string &regex);
145
146 private:
147
148 // Horizontal Coordinates functions.
149 bool getAZ();
150 bool getAL();
151 bool setAZ(double azimuth);
152 bool setAL(double altitude);
153 bool slewToHorizontalCoords(double azimuth, double altitude);
154
155 // Set and get slew speeds
156 bool setSlewSpeedVal(int speedtype, double rate);
157 bool getSlewSpeedVal(int speedtype);
158
162 ISwitchVectorProperty SaveAlignBeforeSyncSP;
163 ISwitch SaveAlignBeforeSyncS[2];
164 enum { STAR_ALIGNMENT_DISABLED, STAR_ALIGNMENT_ENABLED};
165
166 IText RSTVersionsT[2];
167 ITextVectorProperty RSTVersionsTP;
168 enum { FIRMWARE, SERIALNUMBER };
169
170 ISwitchVectorProperty PullVoltTempSP;
171 ISwitch PullVoltTempS[2];
172 enum { PULL_VOLTTEMP_DISABLED, PULL_VOLTTEMP_ENABLED};
173
174 INumber RSTVoltTempN[4];
175 INumberVectorProperty RSTVoltTempNP;
176 enum { VOLTAGE, BOARD_TEMPERATURE, RA_M_TEMPERATURE, DE_M_TEMPERATURE };
177
178 INumber RSTMotorPowN[2];
179 INumberVectorProperty RSTMotorPowNP;
180 enum { RA_M_POWER, DE_M_POWER };
181
182 INumberVectorProperty HorizontalCoordsNP;
183 INumber HorizontalCoordsN[2];
184
185 INumber GuideRateN[1];
186 INumberVectorProperty GuideRateNP;
187
188 INumberVectorProperty SlewSpeedsNP;
189 INumber SlewSpeedsN[3];
190 enum { SLEW_SPEED_MAX, SLEW_SPEED_FIND, SLEW_SPEED_CENTERING };
191
192 const std::string getSlewErrorString(uint8_t code);
193 uint8_t m_SlewErrorCode {0};
194
195 GotoType m_GotoType { Equatorial };
196 double m_CurrentAZ {0}, m_CurrentAL {0};
197 double m_CurrentRA {0}, m_CurrentDE {0};
198 std::string m_Version;
199 int m_GuideNSTID {0};
200 int m_GuideWETID {0};
201
205 static constexpr const char * INFO_TAB = "Info";
206 // '#' is the stop char
207 static const char DRIVER_STOP_CHAR { 0x23 };
208 // Wait up to a maximum of 3 seconds for serial input
209 static constexpr const uint8_t DRIVER_TIMEOUT {3};
210 // Maximum buffer for sending/receiving.
211 static constexpr const uint8_t DRIVER_LEN {64};
212};
int SetSlewRate(void)
virtual bool Sync(double ra, double dec) override
Sync.
Definition rainbow.cpp:1111
virtual IPState GuideNorth(uint32_t ms) override
Guiding.
Definition rainbow.cpp:1201
virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override
Execute a homing action.
Definition rainbow.cpp:1778
void guideTimeout(Direction direction)
Guide Timeout.
Definition rainbow.cpp:1360
static void guideTimeoutHelperN(void *p)
Guide Timeout North.
Definition rainbow.cpp:1328
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
Definition rainbow.cpp:143
bool getTrackingState()
Definition rainbow.cpp:461
virtual bool Goto(double ra, double dec) override
Slew RA/DE.
Definition rainbow.cpp:787
bool checkHoming()
bool findHome()
Definition rainbow.cpp:478
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition rainbow.cpp:186
virtual IPState GuideEast(uint32_t ms) override
Guide East.
Definition rainbow.cpp:1217
virtual bool SetTrackMode(uint8_t mode) override
Set Track Mode.
Definition rainbow.cpp:1139
virtual IPState GuideWest(uint32_t ms) override
Guide West.
Definition rainbow.cpp:1225
virtual bool initProperties() override
Called to initialize basic properties required all the time.
Definition rainbow.cpp:63
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Abort.
Definition rainbow.cpp:1013
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition rainbow.cpp:281
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Location & Time.
Definition rainbow.cpp:371
virtual bool SetTrackEnabled(bool enabled) override
Tracking Functions.
Definition rainbow.cpp:451
void getStartupStatus()
Query Functions.
Definition rainbow.cpp:332
void hexDump(char *buf, const char *data, int size)
Definition rainbow.cpp:1752
bool getFirmwareVersion()
Definition rainbow.cpp:419
const char * getDefaultName() override
Definition rainbow.cpp:55
virtual bool Park() override
Parking & Homing.
Definition rainbow.cpp:572
virtual bool Handshake() override
perform handshake with device to check communication
Definition rainbow.cpp:411
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
Definition rainbow.cpp:562
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
Definition rainbow.cpp:552
bool sendScopeLocation()
Get Location from mount.
Definition rainbow.cpp:1585
bool sendScopeTime()
Location & Time.
Definition rainbow.cpp:1510
Rainbow()
Definition rainbow.cpp:34
static void guideTimeoutHelperS(void *p)
Guide Timeout South.
Definition rainbow.cpp:1336
bool getLocalDate(char *dateString)
Get Date from mount.
Definition rainbow.cpp:1445
bool sendCommand(const char *cmd, char *res=nullptr, int cmd_len=-1, int res_len=-1)
Communication Functions.
Definition rainbow.cpp:1685
IPState guide(Direction direction, uint32_t ms)
Guide universal function.
Definition rainbow.cpp:1233
TelescopePierSide getSideOfPier()
Send Command.
Definition rainbow.cpp:1655
static void guideTimeoutHelperW(void *p)
Guide Timeout West.
Definition rainbow.cpp:1344
std::vector< std::string > split(const std::string &input, const std::string &regex)
Definition rainbow.cpp:1764
static void guideTimeoutHelperE(void *p)
Guide Timeout East.
Definition rainbow.cpp:1352
virtual bool UnPark() override
Unparking.
Definition rainbow.cpp:593
bool setRA(double ra)
Set Target RA.
Definition rainbow.cpp:873
bool getLocalTime(char *timeString)
Get Time from mount.
Definition rainbow.cpp:1417
void addGuideTimer(Direction direction, uint32_t ms)
Add guide timer.
Definition rainbow.cpp:1395
bool getUTFOffset(double *offset)
GET UTC offset from mount.
Definition rainbow.cpp:1482
bool setDE(double de)
Set Target Altitude.
Definition rainbow.cpp:893
bool getDE()
Get DE.
Definition rainbow.cpp:859
virtual IPState GuideSouth(uint32_t ms) override
Guide South.
Definition rainbow.cpp:1209
virtual bool Abort() override
Abort.
Definition rainbow.cpp:1075
Direction
Definition rainbow.h:40
@ West
Definition rainbow.h:40
@ South
Definition rainbow.h:40
@ East
Definition rainbow.h:40
@ North
Definition rainbow.h:40
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
W/E Motion.
Definition rainbow.cpp:1044
bool slewToEquatorialCoords(double ra, double de)
Slew to Equatorial Coordinates.
Definition rainbow.cpp:913
virtual bool isSlewComplete()
Motion Functions.
Definition rainbow.cpp:612
bool setGuideRate(double rate)
Definition rainbow.cpp:490
bool getGuideRate()
Definition rainbow.cpp:500
virtual bool ReadScopeStatus() override
Read telescope status.
Definition rainbow.cpp:653
bool getRA()
Get RA.
Definition rainbow.cpp:846
@ Equatorial
Definition rainbow.h:39
@ Horizontal
Definition rainbow.h:39
double ra
double dec
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
INDI_DIR_WE
INDI_DIR_NS
uint8_t cmd[4]
Definition pwc-ioctl.h:2
One number descriptor.
One switch descriptor.
One text descriptor.
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365
Text vector property descriptor.
Definition indiapi.h:244