-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindi_benropolaris.h
133 lines (115 loc) · 5.72 KB
/
indi_benropolaris.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#pragma once
#include "inditelescope.h"
#include "indiguiderinterface.h"
#include "indipropertyswitch.h"
#include "alignment/AlignmentSubsystemForDrivers.h"
// typedef enum { PARK_COUNTERCLOCKWISE = 0, PARK_CLOCKWISE } ParkDirection_t;
// typedef enum { PARK_NORTH = 0, PARK_EAST, PARK_SOUTH, PARK_WEST } ParkPosition_t;
class BenroPolaris : public INDI::Telescope, public INDI::AlignmentSubsystem::AlignmentSubsystemForDrivers {
public:
BenroPolaris();
virtual bool initProperties() override;
virtual void ISGetProperties(const char *dev) override;
virtual bool updateProperties() override;
virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[],
char *formats[], char *names[], int n) override;
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
protected:
/////////////////////////////////////////////////////////////////////////////////////
/// Communication
/////////////////////////////////////////////////////////////////////////////////////
virtual bool Handshake() override;
virtual bool Connect() override;
virtual bool Disconnect() override;
virtual bool ReadScopeStatus() override;
/////////////////////////////////////////////////////////////////////////////////////
/// Motion
/////////////////////////////////////////////////////////////////////////////////////
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override;
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override;
virtual bool Goto(double ra, double dec) override;
virtual bool Sync(double ra, double dec) override;
virtual bool Abort() override;
virtual bool SetTrackEnabled(bool enabled) override;
virtual bool SetTrackMode(uint8_t mode) override;
virtual bool SetTrackRate(double raRate, double deRate) override;
/////////////////////////////////////////////////////////////////////////////////////
/// Misc.
/////////////////////////////////////////////////////////////////////////////////////
virtual const char *getDefaultName() override;
virtual void TimerHit() override;
virtual bool updateLocation(double latitude, double longitude, double elevation) override;
// virtual bool saveConfigItems(FILE *fp) override;
// double GetSlewRate();
// double GetParkDeltaAz(ParkDirection_t target_direction, ParkPosition_t target_position);
/////////////////////////////////////////////////////////////////////////////////////
/// Guiding
/////////////////////////////////////////////////////////////////////////////////////
// virtual IPState GuideNorth(uint32_t ms) override;
// virtual IPState GuideSouth(uint32_t ms) override;
// virtual IPState GuideEast(uint32_t ms) override;
// virtual IPState GuideWest(uint32_t ms) override;
/////////////////////////////////////////////////////////////////////////////////////
/// Parking
/////////////////////////////////////////////////////////////////////////////////////
virtual bool Park() override;
virtual bool UnPark() override;
virtual bool SetCurrentPark() override;
virtual bool SetDefaultPark() override;
private:
/////////////////////////////////////////////////////////////////////////////////////
/// Comunication
/////////////////////////////////////////////////////////////////////////////////////
void WriteRequest(std::string request, bool readResponse = true, int retries = 3);
void ReadResponses(int portRef);
int readResponseCallback;
// void Keepalive();
// int keepaliveTimer;
std::map<int, std::pair<std::map<std::string, std::string>, int64_t>> responses;
void StoreResponseAndUpdateState(std::pair<int, std::map<std::string, std::string>> decodedResponse);
/////////////////////////////////////////////////////////////////////////////////////
/// Message Encoding/Decoding
/////////////////////////////////////////////////////////////////////////////////////
std::pair<int, std::map<std::string, std::string>> DecodeResponse(std::string message);
std::string EncodeRequest(int command, int type, std::map<std::string, std::string> data);
std::string EncodeRequest(int command, int type, std::string data);
std::string EncodeRequest(int command, int type);
/////////////////////////////////////////////////////////////////////////////////////
/// Properties
/////////////////////////////////////////////////////////////////////////////////////
INDI::PropertyNumber AltAzNP {2};
enum
{
ALT,
AZM,
};
INDI::PropertyText DeviceInfoTP {5};
enum
{
HARDWARE_VERSION,
SOFTWARE_VERSION,
ASTRO_MODULE_VERSION,
SV,
OV,
};
INDI::PropertyNumber StorageNP {3};
enum
{
TOTAL,
FREE,
USED,
};
INDI::PropertyNumber BatteryNP {1};
enum
{
CAPACITY,
};
INDI::PropertyText CommandTP {2};
enum
{
REQUEST,
RESPONSE,
};
};