Kstars

indilistener.h
1/*
2 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5
6 Handle INDI Standard properties.
7*/
8
9#pragma once
10
11#include "indi/indistd.h"
12
13#include <indiproperty.h>
14
15#include <QObject>
16
17class ClientManager;
18class FITSViewer;
19class DeviceInfo;
20
21/**
22 * @class INDIListener
23 * INDIListener is responsible for creating ISD::GDInterface generic devices as new devices arrive from
24 * ClientManager. It can support multiple ClientManagers and will first create a generic INDI device.
25 * Upon arrival of INDI properties, INDIListener can create specialized devices (e.g. Telescope) if it
26 * detects key Standard INDI property that signifies a particular device family. The generic device
27 * functionality is extended via the Decorator design pattern.
28 *
29 * INDIListener also delegates INDI properties as they are received from ClientManager to the appropriate
30 * device to be processed.
31 *
32 * @author Jasem Mutlaq
33 */
34class INDIListener : public QObject
35{
37
38 public:
39 static INDIListener *Instance();
40 // Convenience function
41 static const QList<QSharedPointer<ISD::GenericDevice>> &devices()
42 {
43 return INDIListener::Instance()->getDevices();
44 }
45 static const QList<QSharedPointer<ISD::GenericDevice>> devicesByInterface(uint32_t interface)
46 {
48 auto all = devices();
49 std::copy_if(all.begin(), all.end(), std::back_inserter(filteredDevices), [interface](auto & oneDevice)
50 {
51 return oneDevice->getDriverInterface() & interface;
52 });
53 return filteredDevices;
54 }
55 static bool findDevice(const QString &name, QSharedPointer<ISD::GenericDevice> &device);
56
57 void addClient(ClientManager *cm);
58 void removeClient(ClientManager *cm);
59
60 bool getDevice(const QString &name, QSharedPointer<ISD::GenericDevice> &device) const;
61 const QList<QSharedPointer<ISD::GenericDevice>> &getDevices() const
62 {
63 return m_Devices;
64 }
65
66 int size() const
67 {
68 return m_Devices.size();
69 }
70
71 public slots:
72 void processDevice(DeviceInfo *dv);
73 void removeDevice(const QString &deviceName);
74
75 void registerProperty(INDI::Property prop);
76 void updateProperty(INDI::Property prop);
77 void removeProperty(INDI::Property prop);
78
79 void processMessage(INDI::BaseDevice dp, int messageID);
80 void processUniversalMessage(const QString &message);
81
82 private:
83 explicit INDIListener(QObject *parent);
84
85 static INDIListener *_INDIListener;
86
89
90
91 signals:
92 void newDevice(const QSharedPointer<ISD::GenericDevice> &device);
93 void deviceRemoved(const QSharedPointer<ISD::GenericDevice> &device);
94};
ClientManager manages connection to INDI server, creation of devices, and receiving/sending propertie...
DeviceInfo is simple class to hold DriverInfo and INDI::BaseDevice associated with a particular devic...
Definition deviceinfo.h:21
Primary window to view monochrome and color FITS images.
Definition fitsviewer.h:54
INDIListener is responsible for creating ISD::GDInterface generic devices as new devices arrive from ...
qsizetype size() const const
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.