Instrument Neutral Distributed Interface INDI  2.0.2
flip_flat.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  FlipFlat();
42  virtual ~FlipFlat() = 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  static void parkTimeoutHelper(void *context);
54  static void unparkTimeoutHelper(void *context);
55 
56  typedef enum
57  {
62 
63  protected:
64  const char *getDefaultName() override;
65 
66  virtual bool saveConfigItems(FILE *fp) override;
67  void TimerHit() override;
68 
69  // From Dust Cap
70  virtual IPState ParkCap() override;
71  virtual IPState UnParkCap() override;
72 
73  // From Light Box
74  virtual bool SetLightBoxBrightness(uint16_t value) override;
75  virtual bool EnableLightBox(bool enable) override;
76 
77  private:
78  bool sendCommand(const char *command, char *response);
79  bool getStartupData();
80  bool ping();
81  bool getStatus();
82  bool getFirmwareVersion();
83  bool getBrightness();
84 
85  void parkTimeout();
86  int parkTimeoutID { -1 };
87  void unparkTimeout();
88  int unparkTimeoutID { -1 };
89 
90  bool Handshake();
91 
92  // Status
93  ITextVectorProperty StatusTP;
94  IText StatusT[3] {};
95 
96  // Firmware version
97  ITextVectorProperty FirmwareTP;
98  IText FirmwareT[1] {};
99 
100  int PortFD{ -1 };
101  uint16_t productID{ 0 };
102  DeviceType m_Type { FLIP_FLAT };;
103 
104  uint8_t simulationWorkCounter{ 0 };
105  uint8_t prevCoverStatus{ 0xFF };
106  uint8_t prevLightStatus{ 0xFF };
107  uint8_t prevMotorStatus{ 0xFF };
108  uint8_t prevBrightness{ 0xFF };
109 
110  Connection::Serial *serialConnection{ nullptr };
111 };
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
virtual bool EnableLightBox(bool enable) override
EnableLightBox Turn on/off on a light box. Must be impelemented in the child class.
Definition: flip_flat.cpp:323
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: flip_flat.cpp:173
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
Definition: flip_flat.cpp:213
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: flip_flat.cpp:86
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: flip_flat.cpp:192
static void parkTimeoutHelper(void *context)
Definition: flip_flat.cpp:646
virtual IPState UnParkCap() override
unPark dust cap (open cover). Must be implemented by child.
Definition: flip_flat.cpp:294
const char * getDefaultName() override
Definition: flip_flat.cpp:126
@ ALNITAK_DUST_COVER
Definition: flip_flat.h:60
@ FLIP_MAN
Definition: flip_flat.h:59
@ FLIP_FLAT
Definition: flip_flat.h:58
virtual bool SetLightBoxBrightness(uint16_t value) override
setBrightness Set light level. Must be impelemented in the child class, if supported.
Definition: flip_flat.cpp:567
virtual IPState ParkCap() override
Park dust cap (close cover). Must be implemented by child.
Definition: flip_flat.cpp:266
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: flip_flat.cpp:94
virtual ~FlipFlat()=default
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: flip_flat.cpp:515
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Definition: flip_flat.cpp:181
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: flip_flat.cpp:206
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: flip_flat.cpp:50
static void unparkTimeoutHelper(void *context)
Definition: flip_flat.cpp:651
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
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 text descriptor.
Text vector property descriptor.
Definition: indiapi.h:246