Instrument Neutral Distributed Interface INDI 2.2.5
safetymonitor.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2025 Jasem Mutlaq. All rights reserved.
3
4 INDI Safety Monitor Driver
5 Monitors multiple INDI devices' SAFETY_STATUS properties and reports the worst case
6
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2 of the License, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21
22 The full GNU General Public License is included in this distribution in the
23 file called LICENSE.
24*******************************************************************************/
25
26#pragma once
27
28#include "defaultdevice.h"
30
31#include <memory>
32#include <vector>
33
35{
36 public:
38 virtual ~SafetyMonitor() = default;
39
40 virtual bool initProperties() override;
41 virtual bool updateProperties() override;
42 virtual void ISGetProperties(const char *dev) override;
43 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
44 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
45
46 const char *getDefaultName() override;
47
48 protected:
49 virtual bool Connect() override;
50 virtual bool Disconnect() override;
51 virtual bool saveConfigItems(FILE *fp) override;
52
53 private:
57 void parseConnectionStrings();
58
62 void rebuildSafetyStatusProperty();
63
68 void updateOverallStatus();
69
70 // Connection strings property (comma-separated)
71 INDI::PropertyText ConnectionStringsTP {1};
72
73 // Dynamic safety status property with one element per monitored device
74 INDI::PropertyLight SafetyStatusLP {0};
75
76 // Override switch
77 INDI::PropertySwitch OverrideSP {1};
78
79 // Vector of client instances
80 std::vector<std::unique_ptr<SafetyMonitorClient>> m_Clients;
81};
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
const char * getDefaultName() override
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual ~SafetyMonitor()=default
virtual bool Disconnect() override
Disconnect from device.
virtual bool Connect() override
Connect to the device. INDI::DefaultDevice implementation connects to appropriate connection interfac...
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
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 bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
ISState
Switch state.
Definition indiapi.h:148