Instrument Neutral Distributed Interface INDI  2.0.2
snapcap.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2017-2023 Jarno Paananen. All right reserved.
3 
4  Driver for SnapCap dust cap / flat panel
5 
6  based on Flip Flat driver by:
7 
8  Copyright(c) 2015 Jasem Mutlaq. All rights reserved.
9 
10  This program is free software; you can redistribute it and/or modify it
11  under the terms of the GNU General Public License as published by the Free
12  Software Foundation; either version 2 of the License, or (at your option)
13  any later version.
14 
15  This program is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18  more details.
19 
20  You should have received a copy of the GNU Library General Public License
21  along with this library; see the file COPYING.LIB. If not, write to
22  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23  Boston, MA 02110-1301, USA.
24 
25  The full GNU General Public License is included in this distribution in the
26  file called LICENSE.
27 *******************************************************************************/
28 
29 #pragma once
30 
31 #include "defaultdevice.h"
32 #include "indilightboxinterface.h"
33 #include "indidustcapinterface.h"
34 
35 namespace Connection
36 {
37 class Serial;
38 }
39 
41 {
42  public:
43  SnapCap();
44  virtual ~SnapCap() = default;
45 
46  virtual bool initProperties() override;
47  virtual void ISGetProperties(const char *dev) override;
48  virtual bool updateProperties() override;
49 
50  virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
51  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
52  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
53  virtual bool ISSnoopDevice(XMLEle *root) override;
54 
55  protected:
56  const char *getDefaultName() override;
57 
58  virtual bool saveConfigItems(FILE *fp) override;
59  void TimerHit() override;
60 
61  // From Dust Cap
62  virtual IPState ParkCap() override;
63  virtual IPState UnParkCap() override;
64 
65  // From Light Box
66  virtual bool SetLightBoxBrightness(uint16_t value) override;
67  virtual bool EnableLightBox(bool enable) override;
68 
69  private:
70  bool getStartupData();
71  bool ping();
72  bool getStatus();
73  bool getFirmwareVersion();
74  bool getBrightness();
75 
76  bool Handshake();
77 
78  bool sendCommand(const char *command, char *response);
79 
80  IPState Abort();
81 
82  // Status
83  INDI::PropertyText StatusTP{3};
84 
85  // Firmware version
86  INDI::PropertyText FirmwareTP{1};
87 
88  // Abort
89  INDI::PropertySwitch AbortSP{1};
90 
91  // Force open & close
92  INDI::PropertySwitch ForceSP{2};
93 
94  int PortFD{ -1 };
95  bool hasLight{ true };
96  uint8_t simulationWorkCounter{ 0 };
97  uint8_t targetCoverStatus{ 0xFF };
98  uint8_t prevCoverStatus{ 0xFF };
99  uint8_t prevLightStatus{ 0xFF };
100  uint8_t prevMotorStatus{ 0xFF };
101  uint8_t prevBrightness{ 0xFF };
102 
103  Connection::Serial *serialConnection{ nullptr };
104 };
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 IPState UnParkCap() override
unPark dust cap (open cover). Must be implemented by child.
Definition: snapcap.cpp:311
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: snapcap.cpp:50
virtual bool ISSnoopDevice(XMLEle *root) override
Process a snoop event from INDI server. This function is called when a snooped property is updated in...
Definition: snapcap.cpp:216
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...
Definition: snapcap.cpp:95
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: snapcap.cpp:166
virtual bool SetLightBoxBrightness(uint16_t value) override
setBrightness Set light level. Must be impelemented in the child class, if supported.
Definition: snapcap.cpp:610
virtual IPState ParkCap() override
Park dust cap (close cover). Must be implemented by child.
Definition: snapcap.cpp:281
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: snapcap.cpp:569
virtual bool EnableLightBox(bool enable) override
EnableLightBox Turn on/off on a light box. Must be impelemented in the child class.
Definition: snapcap.cpp:364
SnapCap()
Definition: snapcap.cpp:45
virtual ~SnapCap()=default
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: snapcap.cpp:188
const char * getDefaultName() override
Definition: snapcap.cpp:140
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: snapcap.cpp:103
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Definition: snapcap.cpp:177
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
Definition: snapcap.cpp:223
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