Instrument Neutral Distributed Interface INDI 2.2.5
rigel_dome.h
Go to the documentation of this file.
1/*******************************************************************************
2 Rigel Systems Dome INDI Driver
3
4 Copyright(c) 2019 Jasem Mutlaq. All rights reserved.
5
6 Based on Protocol extracted from https://github.com/rpineau/RigelDome
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License version 2 as published by the Free Software Foundation.
11 .
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16 .
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*******************************************************************************/
22#pragma once
23
24#include "indidome.h"
25
26class RigelDome : public INDI::Dome
27{
28 public:
33
34 RigelDome();
35 virtual ~RigelDome() override = default;
36
37 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
38 virtual bool ISNewNumber(const char * dev, const char * name, double values[], char * names[], int n) override;
39 virtual const char *getDefaultName() override;
40
41 protected:
42 virtual bool initProperties() override;
43 virtual bool updateProperties() override;
44
45 virtual bool Handshake() override;
46 virtual void TimerHit() override;
47
48 virtual IPState MoveRel(double azDiff) override;
49 virtual IPState MoveAbs(double az) override;
50 virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override;
51 virtual IPState ControlShutter(ShutterOperation operation) override;
52 virtual bool Abort() override;
53 virtual bool Sync(double az) override;
54
55 // Parking
56 virtual IPState Park() override;
57 virtual IPState UnPark() override;
58 virtual bool SetCurrentPark() override;
59 virtual bool SetDefaultPark() override;
60
61 private:
62 ShutterOperation m_TargetShutter { SHUTTER_OPEN };
63
64 RigelShutterState m_rawShutterState {S_UnKnown};
65 RigelMotorState m_rawMotorState {M_Idle};
66 double targetAz { 0 };
67
68 // Pulsar Dome Drive workaround for stuck motor detection
69 double previousAngle { -1 };
70 int stuckAngleCounter { 0 };
71 static constexpr const int STUCK_THRESHOLD = 3; // 3 consecutive cycles
72 static constexpr const double ANGLE_TOLERANCE = 1.0; // 1 degree
73
77 bool setShutterConnected(bool enabled);
78 bool isShutterConnected();
79 bool readShutterStatus();
80 ShutterState parseShutterState(int state);
81
85 bool readFirmware();
86 bool readModel();
87 bool readPosition();
88 bool readHomePosition();
89 bool getStartupValues();
90 bool readState();
91 bool readBatteryLevels();
92 bool readStepsPerRevolution();
93
97 bool setParkAz(double az);
98 bool home();
99 bool calibrate();
100 bool setHome(double az);
101
105 bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
106 void hexDump(char * buf, const char * data, int size);
107 std::vector<std::string> split(const std::string &input, const std::string &regex);
108
112 INDI::PropertySwitch OperationSP {2};
113 enum
114 {
115 OPERATION_FIND_HOME,
116 OPERATION_CALIBRATE,
117 };
118
119 // Info
120 INDI::PropertyText InfoTP {4};
121 enum
122 {
123 INFO_FIRMWARE,
124 INFO_MODEL,
125 INFO_TICKS,
126 INFO_BATTERY,
127 };
128
129 // Home angle
130 INDI::PropertyNumber HomePositionNP {1};
131
135 static constexpr const char * INFO_TAB = "Info";
136 // 0xD is the stop char
137 static const char DRIVER_STOP_CHAR { 0x0D };
138 // Wait up to a maximum of 3 seconds for serial input
139 static constexpr const uint8_t DRIVER_TIMEOUT {3};
140 // Maximum buffer for sending/receiving.
141 static constexpr const uint8_t DRIVER_LEN {64};
142};
Class to provide general functionality of a Dome device.
Definition indidome.h:75
ShutterOperation
Shutter operation command.
Definition indidome.h:114
DomeMotionCommand
Definition indidome.h:97
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
@ M_MovingToVelocity
Definition rigel_dome.h:30
@ M_MovingAtSideral
Definition rigel_dome.h:30
@ M_Calibrating
Definition rigel_dome.h:31
@ M_MovingToTarget
Definition rigel_dome.h:30
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
virtual IPState ControlShutter(ShutterOperation operation) override
Open or Close shutter.
virtual IPState UnPark() override
UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutte...
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool Sync(double az) override
Sync sets the dome current azimuth as the supplied azimuth position.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override
Move the Dome in a particular direction.
virtual IPState MoveAbs(double az) override
Move the Dome to an absolute azimuth.
virtual bool Abort() override
Abort all dome motion.
virtual IPState Park() override
Goto Park Position. The park position is an absolute azimuth value.
virtual ~RigelDome() override=default
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual const char * getDefaultName() override
virtual IPState MoveRel(double azDiff) override
Move the Dome to an relative position.
virtual bool Handshake() override
perform handshake with device to check communication
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
uint8_t cmd[4]
Definition pwc-ioctl.h:2