Instrument Neutral Distributed Interface INDI 2.2.5
indi_hakos_roof.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2014 Jasem Mutlaq. All rights reserved.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7 .
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12 .
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*******************************************************************************/
18
19#pragma once
20
21#include "indidome.h"
22
23#ifdef _USE_SYSTEM_JSONLIB
24#include <nlohmann/json.hpp>
25#else
26#include <indijson.hpp>
27#endif
28
30
31class HakosRoof : public INDI::Dome
32{
33 public:
34 HakosRoof();
35 virtual ~HakosRoof() = default;
36
37 const char *getDefaultName() override;
38 virtual bool initProperties() override;
39 bool updateProperties() override;
40
41 virtual void ISGetProperties(const char *dev) override;
42 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
43 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
44 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
45 virtual bool saveConfigItems(FILE *fp) override;
46
47 protected:
48 bool Connect() override;
49 void TimerHit() override;
50
51 virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override;
52 virtual IPState Park() override;
53 virtual IPState UnPark() override;
54 virtual bool Abort() override;
55
56 virtual bool getMountSensorSwitch();
57 bool AbortDriver();
58
59 private:
60 float CalcTimeLeft(timeval);
61
62 double MotionRequest { 0 };
63 struct timeval MotionStart { 0, 0 };
64
65 // Source file/url
66 INDI::PropertyText DataSourceTP {1};
67
68 // Roof token
69 INDI::PropertyText RoofTokenTP {1};
70
71 // Roof status (5 text elements)
72 INDI::PropertyText RoofDataTP {5};
73
74 // Encoder Max Ticks
75 INDI::PropertyNumber EncoderTicksNP {1};
76
77 // Simulation Mode
78 INDI::PropertySwitch SimulationSP {1};
79
80 bool sendRoofCommand(const char *action);
81 bool simulateRoofCommand(const char *action);
82
83 //static size_t write_data;
84 std::string readBuffer;
85 int simulatedPosition { 0 };
86 bool isSimulated { false };
87 struct timeval simulationStartTime { 0, 0 };
88 int simulationTargetPosition { 0 };
89 bool isMoving { false };
90};
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 ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual IPState Park() override
Goto Park Position. The park position is an absolute azimuth value.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool Abort() override
Abort all dome motion.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual IPState Move(DomeDirection dir, DomeMotionCommand operation) override
Move the Dome in a particular direction.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the Device Port and Dome Presets in the configuration file
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
const char * getDefaultName() override
virtual ~HakosRoof()=default
virtual IPState UnPark() override
UnPark dome. The action of the Unpark command is dome specific, but it may include opening the shutte...
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool getMountSensorSwitch()
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Class to provide general functionality of a Dome device.
Definition indidome.h:75
DomeMotionCommand
Definition indidome.h:97
a class to store JSON values
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
basic_json<> json
default specialization