Kstars

indiconcretedevice.h
1/*
2 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5
6 Concrete device is a device that implement specific INDI Device Interface (e.g. Telescope).
7*/
8
9#pragma once
10
11#include "indistd.h"
12#include "indipropertyswitch.h"
13
14#include <QTimer>
15
16namespace ISD
17{
18
19/**
20 * @brief The ConcreteDevice class
21 *
22 * A convenience class to wrap common requests to parent generic device.
23 */
25{
27 Q_PROPERTY(QString name READ getDeviceName)
28 Q_PROPERTY(bool connected READ isConnected)
29
30 public:
32 virtual ~ConcreteDevice() override = default;
33
34 const QString &getDeviceName() const
35 {
36 return m_Name;
37 }
38
39 bool isReady() const
40 {
41 return m_Parent->isReady();
42 }
43 bool isConnected() const
44 {
45 return m_Parent->isConnected();
46 }
47
48 void Connect()
49 {
50 m_Parent->Connect();
51 }
52
53 void Disconnect()
54 {
55 m_Parent->Disconnect();
56 }
57
58 uint32_t getDriverInterface()
59 {
60 return m_Parent->getDriverInterface();
61 }
62
63 GenericDevice *genericDevice() const
64 {
65 return m_Parent;
66 }
67
68 INDI::PropertyView<INumber> *getNumber(const QString &name) const;
69 /** @return Return vector text property given its name */
70 INDI::PropertyView<IText> *getText(const QString &name) const;
71 /** @return Return vector switch property given its name */
72 INDI::PropertyView<ISwitch> *getSwitch(const QString &name) const;
73 /** @return Return vector light property given its name */
74 INDI::PropertyView<ILight> *getLight(const QString &name) const;
75 /** @return Return vector BLOB property given its name */
76 INDI::PropertyView<IBLOB> *getBLOB(const QString &name) const;
77
78 /** @brief Send new property command to server */
79 void sendNewProperty(INDI::Property prop);
80
81 INDI::Property getProperty(const QString &name) const;
82 Properties getProperties() const;
83 const QSharedPointer<DriverInfo> &getDriverInfo() const;
84 bool setConfig(INDIConfig tConfig);
85 bool getMinMaxStep(const QString &propName, const QString &elementName, double *min, double *max,
86 double *step) const;
87 IPState getState(const QString &propName) const;
88 IPerm getPermission(const QString &propName) const;
89 QString getMessage(int id) const;
90
91 const QString &getDUBSObjectPath() const
92 {
93 return m_DBusObjectPath;
94 }
95
96 // No implmenetation by default
97 virtual void registerProperty(INDI::Property) override {}
98 virtual void removeProperty(INDI::Property) override {}
99 virtual void updateProperty(INDI::Property prop) override;
100
101 virtual void processSwitch(INDI::Property) override {}
102 virtual void processText(INDI::Property) override {}
103 virtual void processNumber(INDI::Property) override {}
104 virtual void processLight(INDI::Property) override {}
105 virtual bool processBLOB(INDI::Property) override
106 {
107 return false;
108 }
109 virtual void processMessage(int) override {}
110
111 /**
112 * @brief Register all properties.
113 */
114 void registeProperties();
115
116 /**
117 * @brief processProperties Process all properties
118 */
119 void processProperties();
120
121 signals:
122 // Connection
123 void Connected();
124 void Disconnected();
125
126 // Registeration
127 void propertyDefined(INDI::Property prop);
128 void propertyUpdated(INDI::Property prop);
129 void propertyDeleted(INDI::Property prop);
130
131 void ready();
132
133 protected:
134 GenericDevice *m_Parent;
135 QString m_Name;
136 QScopedPointer<QTimer> m_ReadyTimer;
137 QString m_DBusObjectPath;
138 static uint8_t getID()
139 {
140 return m_ID++;
141 }
142 static uint8_t m_ID;
143};
144
145}
The ConcreteDevice class.
void registeProperties()
Register all properties.
void sendNewProperty(INDI::Property prop)
Send new property command to server.
void processProperties()
processProperties Process all properties
INDI::PropertyView< IBLOB > * getBLOB(const QString &name) const
INDI::PropertyView< ILight > * getLight(const QString &name) const
INDI::PropertyView< IText > * getText(const QString &name) const
INDI::PropertyView< ISwitch > * getSwitch(const QString &name) const
GDInterface is the Generic Device Interface for INDI devices.
Definition indistd.h:84
GenericDevice is the Generic Device for INDI devices.
Definition indistd.h:117
ISD is a collection of INDI Standard Devices.
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.