Instrument Neutral Distributed Interface INDI 2.2.5
safetymonitor_client.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2025 Jasem Mutlaq. All rights reserved.
3
4 INDI Safety Monitor Client
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 "baseclient.h"
28#include "basedevice.h"
29#include "indipropertylight.h"
30
31#include <string>
32#include <functional>
33
38{
39 public:
40 SafetyMonitorClient(const std::string &deviceName, std::function<void()> statusCallback);
42
49 bool connectToServer(const std::string &host, int port);
50
56
61 const std::string& getMonitoredDeviceName() const { return m_DeviceName; }
62
67 bool isDeviceOnline() const { return m_DeviceOnline; }
68
73 bool hasSafetyStatus() const { return m_HasSafetyStatus; }
74
79 const char* getDeviceName() const { return "Safety Monitor"; }
80
81 protected:
82 void newDevice(INDI::BaseDevice dp) override;
83 void removeDevice(INDI::BaseDevice dp) override;
84 void newProperty(INDI::Property property) override;
85 void updateProperty(INDI::Property property) override;
86 void serverConnected() override;
87 void serverDisconnected(int exitCode) override;
88
89 private:
90 std::string m_DeviceName;
91 bool m_DeviceOnline;
92 bool m_HasSafetyStatus;
93 INDI::PropertyLight m_SafetyStatusLP;
94 std::function<void()> m_StatusCallback;
95};
Class to provide basic client functionality.
Definition baseclient.h:52
Class to provide basic INDI device functionality.
Definition basedevice.h:52
Provides generic container for INDI properties.
SafetyMonitorClient connects to a remote INDI device and monitors its SAFETY_STATUS property.
void newProperty(INDI::Property property) override
Emmited when a new property is created for an INDI driver.
bool connectToServer(const std::string &host, int port)
Connect to an INDI server.
bool isDeviceOnline() const
Check if the monitored device is online.
void newDevice(INDI::BaseDevice dp) override
Emmited when a new device is created from INDI server.
IPState getSafetyStatus() const
Get the current safety status.
const char * getDeviceName() const
Get the device name for logging purposes (INDI logging requirement)
void updateProperty(INDI::Property property) override
Emmited when a new property value arrives from INDI server.
const std::string & getMonitoredDeviceName() const
Get the monitored device name.
void serverConnected() override
Emmited when the server is connected.
void removeDevice(INDI::BaseDevice dp) override
Emmited when a device is deleted from INDI server.
bool hasSafetyStatus() const
Check if the SAFETY_STATUS property has been received.
void serverDisconnected(int exitCode) override
Emmited when the server gets disconnected.
IPState
Property state.
Definition indiapi.h:158