Instrument Neutral Distributed Interface INDI  2.0.2
scopedome_arduino.h
Go to the documentation of this file.
1 /*******************************************************************************
2  ScopeDome Dome INDI Driver
3 
4  Copyright(c) 2017-2021 Jarno Paananen. All rights reserved.
5 
6  based on:
7 
8  ScopeDome Windows ASCOM driver version 5.1.30
9 
10  and
11 
12  Copyright(c) 2014 Jasem Mutlaq. All rights reserved.
13 
14  Baader Planetarium Dome INDI Driver
15 
16  This library is free software; you can redistribute it and/or
17  modify it under the terms of the GNU Library General Public
18  License version 2 as published by the Free Software Foundation.
19  .
20  This library is distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23  Library General Public License for more details.
24  .
25  You should have received a copy of the GNU Library General Public License
26  along with this library; see the file COPYING.LIB. If not, write to
27  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
28  Boston, MA 02110-1301, USA.
29 *******************************************************************************/
30 
31 #pragma once
32 
34 
35 #include "scopedome_dome.h"
36 #include <curl/curl.h>
37 #include <string>
38 #include <unordered_map>
39 #include <vector>
40 
44 class ScopeDomeArduino final: public ScopeDomeCard
45 {
46  public:
49 
51  virtual ~ScopeDomeArduino();
52 
55 
56  virtual bool detect() override;
57  virtual void setPortFD(int fd) override
58  {
59  PortFD = fd;
60  };
61 
62  // State polling
63  virtual int updateState() override;
64  virtual uint32_t getStatus() override;
65  virtual int getRotationCounter() override;
66  virtual int getRotationCounterExt() override;
67 
68  // Information
69  virtual void getFirmwareVersions(double &main, double &rotary) override;
70  virtual uint32_t getStepsPerRevolution() override;
71  virtual bool isCalibrationNeeded() override;
72 
73  // Commands
74  virtual void abort() override;
75  virtual void calibrate() override;
76  virtual void findHome() override;
77  virtual void controlShutter(ShutterOperation operation) override;
78 
79  virtual void resetCounter() override;
80 
81  // negative means CCW, positive CW steps
82  virtual void move(int steps) override;
83 
84  // Input/Output management
85  virtual size_t getNumberOfSensors() override;
86  virtual SensorInfo getSensorInfo(size_t index) override;
87  virtual double getSensorValue(size_t index) override;
88 
89  virtual size_t getNumberOfRelays() override;
90  virtual RelayInfo getRelayInfo(size_t index) override;
91  virtual ISState getRelayState(size_t index) override;
92  virtual void setRelayState(size_t index, ISState state) override;
93 
94  virtual size_t getNumberOfInputs() override;
95  virtual InputInfo getInputInfo(size_t index) override;
96  virtual ISState getInputValue(size_t index) override;
97 
98  virtual ISState getInputState(AbstractInput input) override;
99  virtual int setOutputState(AbstractOutput output, ISState state) override;
100 
101  virtual void setHomeSensorPolarity(HomeSensorPolarity polarity) override;
102  private:
103  ScopeDome *parent;
104  CURL *curl{ nullptr };
105 
106  bool performCommand(const std::string &command, std::string &response);
107  std::vector<std::string> splitString(const std::string &src, char splitChar);
108 
109  int32_t rotaryEncoder {0};
110  int32_t shutterEncoder {0};
111  int32_t previousEncoder{0};
112  uint32_t stepsPerRevolution {0};
113 
114  bool inputs[16];
115  double sensors[28];
116  bool relays[6];
117 
118  bool rotaryLink;
119  bool moving;
120  bool homing;
121  bool moveShutterOnHome;
122  bool calibrating;
123  bool ethernet;
124  Connection::Interface* interface;
125  int PortFD;
126  std::string hostName;
127  int port;
128 
129  static constexpr int32_t encoderBaseValue = 32000;
130 };
The Interface class is the base class for all INDI connection plugins.
virtual SensorInfo getSensorInfo(size_t index) override
virtual void controlShutter(ShutterOperation operation) override
virtual size_t getNumberOfRelays() override
virtual void setPortFD(int fd) override
virtual void setHomeSensorPolarity(HomeSensorPolarity polarity) override
virtual ISState getInputValue(size_t index) override
ScopeDomeArduino(ScopeDome *driver, Connection::Interface *interface)
virtual int getRotationCounterExt() override
virtual uint32_t getStatus() override
virtual void resetCounter() override
virtual size_t getNumberOfSensors() override
virtual uint32_t getStepsPerRevolution() override
virtual void getFirmwareVersions(double &main, double &rotary) override
ScopeDomeArduino(const ScopeDomeArduino &)=delete
virtual bool isCalibrationNeeded() override
virtual bool detect() override
virtual void abort() override
virtual double getSensorValue(size_t index) override
virtual size_t getNumberOfInputs() override
virtual RelayInfo getRelayInfo(size_t index) override
virtual ISState getInputState(AbstractInput input) override
virtual int getRotationCounter() override
virtual void calibrate() override
virtual ISState getRelayState(size_t index) override
virtual void findHome() override
virtual void move(int steps) override
virtual void setRelayState(size_t index, ISState state) override
ScopeDomeArduino & operator=(const ScopeDomeArduino &)=delete
virtual int updateState() override
virtual int setOutputState(AbstractOutput output, ISState state) override
virtual InputInfo getInputInfo(size_t index) override
ISState
Switch state.
Definition: indiapi.h:150
int fd
Definition: intelliscope.c:43
int main(int, char *[])