Instrument Neutral Distributed Interface INDI  2.0.2
wanderer_cover.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2015 Jasem Mutlaq. All rights reserved.
3 
4  Simple GPS Simulator
5 
6  This program is free software; you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by the Free
8  Software Foundation; either version 2 of the License, or (at your option)
9  any later version.
10 
11  This program is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 
21  The full GNU General Public License is included in this distribution in the
22  file called LICENSE.
23 *******************************************************************************/
24 
25 #pragma once
26 
27 #include "defaultdevice.h"
28 #include "indilightboxinterface.h"
29 #include "indidustcapinterface.h"
30 
31 #include <stdint.h>
32 
33 namespace Connection
34 {
35 class Serial;
36 }
37 
39 {
40  public:
41  WandererCover();
42  virtual ~WandererCover() = default;
43 
44  virtual bool initProperties() override;
45  virtual void ISGetProperties(const char *dev) override;
46  virtual bool updateProperties() override;
47 
48  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
49  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
50  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
51  virtual bool ISSnoopDevice(XMLEle *root) override;
52 
53  protected:
54  const char *getDefaultName() override;
55 
56  virtual bool saveConfigItems(FILE *fp) override;
57 
58  // From Dust Cap
59  virtual IPState ParkCap() override;
60  virtual IPState UnParkCap() override;
61 
62  // From Light Box
63  virtual bool SetLightBoxBrightness(uint16_t value) override;
64  virtual bool EnableLightBox(bool enable) override;
65 
66  private:
67  enum
68  {
69  SET_CURRENT_POSITION_OPEN,
70  SET_CURRENT_POSITION_CLOSE
71  };
72 
73  enum
74  {
75  PLUS_1_DEGREE,
76  PLUS_10_DEGREE,
77  PLUS_50_DEGREE,
78  };
79 
80  enum
81  {
82  MINUS_1_DEGREE,
83  MINUS_10_DEGREE,
84  MINUS_50_DEGREE,
85  };
86 
87  bool sendCommand(std::string command, char *response, bool waitForAnswer);
88  bool getStartupData();
89 
90  bool Handshake();
91 
92  // Dust cap
93  void updateCoverStatus(char* res);
94  void setParkCapStatusAsClosed();
95  void setParkCapStatusAsOpen();
96  IPState moveDustCap(int degrees);
97  bool setCurrentPositionToOpenPosition();
98  bool setCurrentPositionToClosedPosition();
99  bool processConfigurationButtonSwitch(const char *dev, const char *name, ISState *states, char *names[], int n);
100 
101  // Light box
102  bool switchOffLightBox();
103  void setLightBoxStatusAsSwitchedOff();
104  void setLightBoxBrightnesStatusToValue(uint16_t value);
105 
106  // Status
107  ITextVectorProperty StatusTP;
108  IText StatusT[2] {};
109 
110  // Firmware version
111  ITextVectorProperty FirmwareTP;
112  IText FirmwareT[1] {};
113 
114  //Number of steps
115  void setNumberOfStepsStatusValue(int value);
116  int NumberOfStepsBeetweenOpenAndCloseState = 0;
117  int NumberOfDegreesSinceLastOpenPositionSet = 0;
118 
119  // Configuration
120  // Configure open position
121  ISwitchVectorProperty ControlPositionNegativeDegreesConfigurationVP;
122  ISwitch ControlPositionNegativeDegreesConfigurationV[3] {};
123  ISwitchVectorProperty ControlPositionPositiveDegreesConfigurationVP;
124  ISwitch ControlPositionPositiveDegreesConfigurationV[3] {};
125  ISwitchVectorProperty DefinePositionConfigurationVP;
126  ISwitch DefinePositionConfigurationV[2] {};
127 
128  // Check for errors in indi driver
129  bool hasWandererSentAnError(char* response);
130  void displayConfigurationMessage();
131 
132  int PortFD{ -1 };
133 
134  Connection::Serial *serialConnection{ nullptr };
135 };
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
virtual bool SetLightBoxBrightness(uint16_t value) override
setBrightness Set light level. Must be impelemented in the child class, if supported.
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual bool EnableLightBox(bool enable) override
EnableLightBox Turn on/off on a light box. Must be impelemented in the child class.
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual IPState ParkCap() override
Park dust cap (close cover). Must be implemented by child.
virtual IPState UnParkCap() override
unPark dust cap (open cover). Must be implemented by child.
const char * getDefaultName() override
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual ~WandererCover()=default
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition: arduino_st4.h:34
One switch descriptor.
One text descriptor.
Switch vector property descriptor.
Definition: indiapi.h:367
Text vector property descriptor.
Definition: indiapi.h:246