| 1 |
/* |
| 2 |
* BresserExosIIGoToDriver.hpp |
| 3 |
* |
| 4 |
* Copyright 2020 Kevin Krüger <[email protected]> |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This program 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 |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
| 19 |
* MA 02110-1301, USA. |
| 20 |
* |
| 21 |
* |
| 22 |
*/ |
| 23 |
|
| 24 |
#pragma once |
| 25 |
|
| 26 |
#include <cstdint> |
| 27 |
#include <cmath> |
| 28 |
#include <memory> |
| 29 |
#include <string> |
| 30 |
|
| 31 |
#include <inditelescope.h> |
| 32 |
#include <indiguiderinterface.h> |
| 33 |
|
| 34 |
#include "IndiSerialWrapper.hpp" |
| 35 |
#include "ExosIIMountControl.hpp" |
| 36 |
#include "SerialCommand.hpp" |
| 37 |
|
| 38 |
#include "config.h" |
| 39 |
|
| 40 |
namespace GoToDriver |
| 41 |
{ |
| 42 |
|
| 43 |
struct GuideState |
| 44 |
{ |
| 45 |
SerialDeviceControl::SerialCommandID direction; |
| 46 |
uint32_t remaining_messages; |
| 47 |
}; |
| 48 |
|
| 49 |
//Main wrapper class for the indi driver interface. |
| 50 |
//"Glues" together the independent functionallity with the driver interface from indi. |
| 51 |
class BresserExosIIDriver : public INDI::Telescope, public INDI::GuiderInterface |
| 52 |
{ |
| 53 |
public: |
| 54 |
//default constructor. |
| 55 |
//sets the scope abilities, and default settings. |
| 56 |
BresserExosIIDriver(); |
| 57 |
|
| 58 |
//destructor, not much going on here. Since most of the memory is statically allocated, there is not much to clean up. |
| 59 |
virtual ~BresserExosIIDriver(); |
| 60 |
|
| 61 |
//initialize the properties of the scope. |
| 62 |
virtual bool initProperties() override; |
| 63 |
|
| 64 |
//update the properties of the scope visible in the EKOS dialogs for instance. |
| 65 |
virtual bool updateProperties() override; |
| 66 |
|
| 67 |
//Connect to the scope, and ready everything for serial data exchange. |
| 68 |
virtual bool Connect() override; |
| 69 |
|
| 70 |
//Start the serial receiver thread, so the mount can report its pointing coordinates. |
| 71 |
virtual bool Handshake() override; |
| 72 |
|
| 73 |
//Disconnect from the mount, and disable serial transmission. |
| 74 |
virtual bool Disconnect() override; |
| 75 |
|
| 76 |
//Return the name of the device, displayed in the e.g. EKOS dialogs |
| 77 |
virtual const char* getDefaultName() override; |
| 78 |
|
| 79 |
//Periodically polled function to update the state of the driver, and synchronize it with the mount. |
| 80 |
virtual bool ReadScopeStatus() override; |
| 81 |
|
| 82 |
//update properties from the application -> number |
| 83 |
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override; |
| 84 |
|
| 85 |
//update properties from the application -> text |
| 86 |
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override; |
| 87 |
|
| 88 |
//Park the telescope. This will slew the telescope to the parking position == home position. |
| 89 |
virtual bool Park() override; |
| 90 |
|
| 91 |
//Set the state of the driver to unpark allowing the scope to be manipulated again. |
| 92 |
virtual bool UnPark() override; |
| 93 |
|
| 94 |
//Sync the astro software and mount coordinates. |
| 95 |
virtual bool Sync(double ra, double dec) override; |
| 96 |
|
| 97 |
//Go to the coordinates in the sky, This automatically tracks the selected coordinates. |
| 98 |
virtual bool Goto(double ra, double dec) override; |
| 99 |
|
| 100 |
//Abort any motion of the telescope. This is state indipendent, and always possible when connected. |
| 101 |
virtual bool Abort() override; |
| 102 |
|
| 103 |
//Set the tracking state of the scope, it either goes to the current coordinates or stops the scope motion. |
| 104 |
virtual bool SetTrackingEnabled(bool enabled); |
| 105 |
|
| 106 |
//update the time of the scope. |
| 107 |
virtual bool updateTime(ln_date *utc, double utc_offset) override; |
| 108 |
|
| 109 |
//update the location of the scope. |
| 110 |
virtual bool updateLocation(double latitude, double longitude, double elevation) override; |
| 111 |
|
| 112 |
//commance motion in north or south direction. |
| 113 |
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override; |
| 114 |
|
| 115 |
//commance motion in east or west direction. |
| 116 |
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override; |
| 117 |
|
| 118 |
// Guide |
| 119 |
virtual IPState GuideNorth(uint32_t ms) override; |
| 120 |
virtual IPState GuideSouth(uint32_t ms) override; |
| 121 |
virtual IPState GuideEast(uint32_t ms) override; |
| 122 |
virtual IPState GuideWest(uint32_t ms) override; |
| 123 |
|
| 124 |
// Pulse Guide timeout callbacks. |
| 125 |
static void guideTimeoutHelperN(void *p); |
| 126 |
static void guideTimeoutHelperS(void *p); |
| 127 |
static void guideTimeoutHelperE(void *p); |
| 128 |
static void guideTimeoutHelperW(void *p); |
| 129 |
|
| 130 |
private: |
| 131 |
IndiSerialWrapper mInterfaceWrapper; |
| 132 |
|
| 133 |
TelescopeMountControl::ExosIIMountControl<IndiSerialWrapper> mMountControl; |
| 134 |
|
| 135 |
unsigned int DBG_SCOPE; |
| 136 |
|
| 137 |
int GuideNSTID; |
| 138 |
int GuideWETID; |
| 139 |
|
| 140 |
static void DriverWatchDog(void *p); |
| 141 |
|
| 142 |
void guideTimeout(SerialDeviceControl::SerialCommandID direction); |
| 143 |
|
| 144 |
void LogError(const char* mesage); |
| 145 |
|
| 146 |
void LogInfo(const char* mesage); |
| 147 |
|
| 148 |
IText SourceCodeRepositoryURLT[1] = {}; |
| 149 |
ITextVectorProperty SourceCodeRepositoryURLTP; |
| 150 |
|
| 151 |
GuideState mGuideStateNS; |
| 152 |
|
| 153 |
GuideState mGuideStateEW; |
| 154 |
}; |
| 155 |
} |
| 156 |
|