Instrument Neutral Distributed Interface INDI 2.2.5
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"
30
31#include <stdint.h>
32
33namespace Connection
34{
35class 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
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 implemented in the child class.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
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.
static void parkTimeoutHelper(void *context)
virtual IPState UnParkCap() override
unPark dust cap (open cover). Must be implemented by child.
const char * getDefaultName() override
@ ALNITAK_DUST_COVER
Definition flip_flat.h:60
@ FLIP_FLAT
Definition flip_flat.h:58
virtual bool SetLightBoxBrightness(uint16_t value) override
setBrightness Set light level. Must be implemented in the child class, if supported.
virtual IPState ParkCap() override
Park dust cap (close cover). Must be implemented by child.
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.
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
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 initProperties() override
Initialize properties initial state and value. The child class must implement this function.
Definition flip_flat.cpp:50
static void unparkTimeoutHelper(void *context)
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
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:244