Instrument Neutral Distributed Interface INDI 2.2.5
indigpsinterface.h
Go to the documentation of this file.
1/*
2 GPS Interface
3 Copyright (C) 2023 Jasem Mutlaq ([email protected])
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19*/
20
21#pragma once
22
23#include "indibase.h"
24#include "indipropertynumber.h"
25#include "indipropertyswitch.h"
26#include "indipropertytext.h"
27#include "inditimer.h"
28
29#include <stdint.h>
30#include <string>
31#include <vector>
32
33// Alias
35
36namespace INDI
37{
38
46{
47 public:
54
55 protected:
56 explicit GPSInterface(DefaultDevice * defaultDevice);
57 virtual ~GPSInterface() = default;
58
64 void initProperties(const char * groupName);
65
70 bool updateProperties();
71
73 bool processNumber(const char * dev, const char * name, double values[], char * names[], int n);
74
76 bool processSwitch(const char * dev, const char * name, ISState * states, char * names[], int n);
77
83 virtual bool saveConfigItems(FILE * fp);
84
88 void checkGPSState();
89
96 bool setSystemTime(time_t &raw_time);
97
98#ifdef __linux__
103 bool runCommand(const std::vector<std::string> &args, std::string *output = nullptr);
104
114 bool timedateCall(const std::vector<std::string> &busctlArgs, const std::vector<std::string> &gdbusArgs,
115 std::string *output = nullptr);
116
118 bool isNTPActive();
119
121 bool setNTPEnabled(bool enabled);
122
124 void disableNTPForGPSTime();
125
127 void restoreNTPOnDisconnect();
128#endif
129
134 virtual IPState updateGPS();
135
136
137 // A number vector that stores latitude, longitude and altitude.
139
140 // UTC and UTC Offset
142
143 // Refresh data
145
146 // Refresh Period
148
149 // System Time
151 enum
152 {
156 };
157
159
160 // # of seconds since 1970 UTC
161 std::time_t m_GPSTime;
162
163 // Track whether system time was updated
165
166 // Track whether this GPS interface disabled NTP (so we can restore on disconnect)
167 bool m_NTPDisabledByGPS { false };
168
170};
171}
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Provides interface to implement GPS functionality.
INDI::PropertyNumber LocationNP
void checkGPSState()
checkGPSState Check and update GPS state
DefaultDevice * m_DefaultDevice
bool setSystemTime(time_t &raw_time)
SetSystemTime Update system-wide time.
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
virtual IPState updateGPS()
updateGPS Retrieve Location & Time from GPS. Update LocationNP & TimeTP properties (value and state) ...
INDI::PropertyNumber PeriodNP
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process focus switch properties.
INDI::PropertySwitch SystemTimeUpdateSP
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process focus number properties.
virtual bool saveConfigItems(FILE *fp)
saveConfigItems save focuser properties defined in the interface in config file
INDI::PropertyText TimeTP
virtual ~GPSInterface()=default
INDI::PropertySwitch RefreshSP
void initProperties(const char *groupName)
Initialize focuser properties. It is recommended to call this function within initProperties() of you...
The Timer class provides repetitive and single-shot timers.
Definition inditimer.h:41
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
Namespace to encapsulate INDI client, drivers, and mediator classes.