Instrument Neutral Distributed Interface INDI 2.2.5
crux_mount.h
Go to the documentation of this file.
1/*******************************************************************************
2 Driver type: TitanTCS for HOBYM CRUX Mount INDI Driver
3
4 Copyright(c) 2020 Park Suyoung <[email protected]>. All rights reserved.
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation.
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 Library General Public License for more details.
14 .
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*******************************************************************************/
20
21#pragma once
22
23#include "inditelescope.h"
24#include "indiguiderinterface.h"
25
26#define RESPONSE_TIMEOUT 3
27#define USE_PEC 1
28
29typedef struct
30{
31 double ra;
32 double dec;
33 //
35#if USE_PEC
37#endif
42
44{
45 public:
46 TitanTCS();
47
48 private:
49 int m_Connect;
50 // Lightweight-poll slew/park completion detection state
51 double m_LastRA {0};
52 double m_LastDEC {0};
53 bool m_HaveLastPos {false};
54 int m_StableCount {0};
55
56
57 public:
58 virtual const char *getDefaultName() override;
59 virtual bool Connect() override;
60 virtual bool Disconnect() override;
61 virtual bool Handshake() override;
62 virtual bool ReadScopeStatus() override;
63
64 //virtual void ISGetProperties(const char *dev) override;
65 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
66 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
67 virtual bool initProperties() override;
68 virtual bool updateProperties() override;
69
70 virtual bool ISNewText(const char *dev, const char *name, char **texts, char **names, int n) override;
71
72 private:
73 // Mount Info.
74 ITextVectorProperty MountInfoTP;
75 IText MountInfoT[2] {};
76 int GuideNSTID { -1 };
77 int GuideWETID { -1 };
78
79 // How Park() should behave. Mirrors the two options the TitanTCS ASCOM
80 // application offers, using the mount's own firmware park commands.
81 enum
82 {
83 PARK_MODE_AT_CURRENT = 0, // ':hP8#' — lock wherever it points
84 PARK_MODE_AT_SAVED // ':hP1#' — move to saved point, then park
85 };
86 INDI::PropertySwitch ParkModeSP {2};
87
88 stTitanTCS info;
89#if USE_PEC
90 // PECStatus
91 int _PECStatus {0};
92
93 // PEC Training
94 ISwitch PECTrainingS[2];
95 ISwitchVectorProperty PECTrainingSP;
96 // PEC Info.
97 ITextVectorProperty PECInfoTP;
98 IText PECInfoT[2] {};
99#endif
100
101 protected:
102 // Goto, Sync, and Motion
103 virtual bool Goto(double ra, double dec) override;
104 //bool GotoAzAlt(double az, double alt);
105 virtual bool Sync(double ra, double dec) override;
106 virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
107 virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
108 virtual bool Abort() override;
109 virtual bool SetSlewRate(int index) override;
110
111 // Time and Location
112 virtual bool updateLocation(double latitude, double longitude, double elevation) override;
113 virtual bool updateTime(ln_date *utc, double utc_offset) override;
114
115 //GUIDE: guiding functions
116 virtual IPState GuideNorth(uint32_t ms) override;
117 virtual IPState GuideSouth(uint32_t ms) override;
118 virtual IPState GuideEast(uint32_t ms) override;
119 virtual IPState GuideWest(uint32_t ms) override;
120 // Tracking
121 virtual bool SetTrackMode(uint8_t mode) override;
122 virtual bool SetTrackEnabled(bool enabled) override;
123
124 // Parking
125 virtual bool Park() override;
126 virtual bool UnPark() override;
127 virtual bool SetCurrentPark() override;
128 virtual bool SetDefaultPark() override;
129 virtual bool SetParkPosition(double Axis1Value, double Axis2Value) override;
130
131 private:
132 bool SendCommand(const char *cmd_org);
133 bool SendCommand(const char *cmd, int val);
134 bool SendCommand(const char *cmd, double val);
135
136 bool CommandResponse(const char* pCommand, const char* pResponse, char delimeter, double *pDouble, int *pInteger = nullptr);
137 bool CommandResponseHour(const char* pCommand, const char* pResponse, char delimeter, double* Hour);
138 bool CommandResponseStr(const char* pCommand, const char* pResponse, char delimeter, char* pReturn, int len = 0);
139 bool CommandResponseChar(const char* pCommand, const char* pResponse, char* pReturn);
140
141 bool GetMountParams(bool bAll = false);
142 bool GetMountParamsLight();
143
144 bool GetParamStr(const char* pInStr, char* pOutStr, int len, const char* pResponse, char delimeter);
145 bool GetParamNumber(const char* pInStr, char* pOutStr, int len, const char* pResponse, char delimeter, double *pDouble,
146 int *pInteger = NULL);
147 bool GetParamHour(const char* pInStr, char* pOutStr, int len, const char* pResponse, char delimeter, double *pHour);
148
149 bool GetEqPosition(INDI_EQ_AXIS axis, double *value);
150 bool GetEqPosition(double *ra, double *dec);
151
152 void ReadFlush();
153 int ReadResponse(char *buf, int len, char delimeter, int timeout = RESPONSE_TIMEOUT);
154
155 bool SetTarget(double ra, double dec);
156
157 void guideTimeoutNS();
158 void guideTimeoutWE();
159
160 static void guideTimeoutHelperNS(void * p);
161 static void guideTimeoutHelperWE(void * p);
162#if USE_PEC
163 void _setPECState(int pec_status);
164#endif
165};
166
167
int SetSlewRate(void)
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
virtual bool ReadScopeStatus() override
Read telescope status.
virtual bool Disconnect() override
Disconnect from device.
virtual bool Park() override
Park the telescope to its home position.
virtual bool Abort() override
Abort any telescope motion including tracking if possible.
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
virtual bool Handshake() override
perform handshake with device to check communication
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool UnPark() override
Unpark the telescope if already parked.
virtual bool ISNewText(const char *dev, const char *name, char **texts, char **names, int n) override
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
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 SetParkPosition(double Axis1Value, double Axis2Value) override
SetParkPosition Set desired parking position to the supplied value. This ONLY sets the desired park p...
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
virtual bool updateTime(ln_date *utc, double utc_offset) override
Update telescope time, date, and UTC offset.
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual const char * getDefaultName() override
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
virtual bool Goto(double ra, double dec) override
Move the scope to the supplied RA and DEC coordinates.
#define RESPONSE_TIMEOUT
Definition crux_mount.h:26
double ra
double dec
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
INDI_EQ_AXIS
INDI_DIR_WE
INDI_DIR_NS
uint8_t cmd[4]
Definition pwc-ioctl.h:2
One switch descriptor.
One text descriptor.
Switch vector property descriptor.
Definition indiapi.h:365
Text vector property descriptor.
Definition indiapi.h:244
int Landscape
Definition crux_mount.h:38
int TrackingRate
Definition crux_mount.h:39
int TrackingStatus
Definition crux_mount.h:40
double dec
Definition crux_mount.h:32
double ra
Definition crux_mount.h:31
int PECStatus
Definition crux_mount.h:36