Kstars

indidbus.h
1 /*
2  SPDX-FileCopyrightText: 2014 Jasem Mutlaq <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QObject>
10 
11 /**
12  * @class INDIDBus
13  *
14  * Collection of INDI DBus functions.
15  *
16  * @author Jasem Mutlaq
17  */
18 class INDIDBus : public QObject
19 {
20  Q_OBJECT
21  Q_CLASSINFO("D-Bus Interface", "org.kde.kstars.INDI")
22 
23  public:
24  explicit INDIDBus(QObject *parent = nullptr);
25 
26  /** @defgroup INDIDBusInterface INDI DBus Interface
27  * INDIDBus interface provides complete scripting capability over INDI servers and devices within KStars.
28  *
29  * A Python DBus <a href="http://indilib.org/support/tutorials/148-dbus-scripting-with-kstars-python.html">tutorial</a> demonstrates
30  * the capabilities of the INDI DBus interface.
31  */
32 
33  /*@{*/
34 
35  /** DBUS interface function. Start a local INDI server given a list of drivers on the given port.
36  * @param port Port used to establish server. If empty, default port 7624 is used.
37  * @param drivers List of drivers executables to run.
38  */
39  Q_SCRIPTABLE bool start(int port, const QStringList &drivers);
40 
41  /** DBUS interface function. Stops server running on the given port
42  @param port Port of existing server to stop
43  */
44  Q_SCRIPTABLE bool stop(const QString &port);
45 
46  /** DBUS interface function. Connect to an INDI server
47  * @param host hostname of server to connect to.
48  * @param port Port of server.
49  */
50  Q_SCRIPTABLE bool connect(const QString &host, int port);
51 
52  /** DBUS interface function. Disconnect from an INDI server
53  * @param host hostname of server to disconnect.
54  * @param port Port of server.
55  */
56  Q_SCRIPTABLE bool disconnect(const QString &host, int port);
57 
58  /** DBUS interface function. Returns a list of INDI devices
59  * @returns List of device names
60  */
61  Q_SCRIPTABLE QStringList getDevicesPaths(uint32_t interface);
62 
63  /** DBUS interface function. Returns a list of INDI devices
64  * @returns List of device names
65  */
66  Q_SCRIPTABLE QStringList getDevices();
67 
68  /** DBUS interface function. Returns a list of INDI properties
69  * @param device device name
70  * @returns List of properties in the format DEVICE.PROPERTY.ELEMENT.
71  */
72  Q_SCRIPTABLE QStringList getProperties(const QString &device);
73 
74  /** DBUS interface function. Returns INDI property state
75  * @param device device name
76  * @param property property name
77  * @returns Idle, Ok, Busy, or Alert. If no property is found, it returns "Invalid"
78  */
79  Q_SCRIPTABLE QString getPropertyState(const QString &device, const QString &property);
80 
81  /** DBUS interface function. Sends property to INDI server
82  * @param device device name
83  * @param property property name
84  * @returns true if property is found and sent to server, false otherwise.
85  */
86  Q_SCRIPTABLE bool sendProperty(const QString &device, const QString &property);
87 
88  /** DBUS interface function. Set INDI Switch status
89  * @param device device name
90  * @param property property name
91  * @param switchName switch name
92  * @param status Either On or Off.
93  * /note This function ONLY sets the switch status but does not send it to server. Use sendProperty to send a switch to server.
94  */
95  Q_SCRIPTABLE bool setSwitch(const QString &device, const QString &property, const QString &switchName,
96  const QString &status);
97 
98  /** DBUS interface function. Returns INDI switch status
99  * @param device device name
100  * @param property property name
101  * @param switchName switch name
102  * @returns On or Off if switch is found. If no switch is found, it returns "Invalid".
103  */
104  Q_SCRIPTABLE QString getSwitch(const QString &device, const QString &property, const QString &switchName);
105 
106  /** DBUS interface function. Set INDI Text
107  * @param device device name
108  * @param property property name
109  * @param textName text element name
110  * @param text text value
111  * /note This function ONLY sets the text value but does not send it to server. Use sendProperty to send a text to server.
112  */
113  Q_SCRIPTABLE bool setText(const QString &device, const QString &property, const QString &textName,
114  const QString &text);
115 
116  /** DBUS interface function. Returns INDI text value
117  * @param device device name
118  * @param property property name
119  * @param textName text element name
120  * @returns text value. If no text is found, it returns "Invalid".
121  */
122  Q_SCRIPTABLE QString getText(const QString &device, const QString &property, const QString &textName);
123 
124  /** DBUS interface function. Set INDI Number
125  * @param device device name
126  * @param property property name
127  * @param numberName number element name
128  * @param value number value
129  * @returns true if successful, false otherwise.
130  * /note This function ONLY sets the number value but does not send it to server. Use sendProperty to send a number to server.
131  */
132  Q_SCRIPTABLE bool setNumber(const QString &device, const QString &property, const QString &numberName,
133  double value);
134 
135  /** DBUS interface function. Returns INDI number value
136  * @param device device name
137  * @param property name
138  * @param numberName number element name
139  * @returns number value. If no text is found, it returns NAN.
140  */
141  Q_SCRIPTABLE double getNumber(const QString &device, const QString &property, const QString &numberName);
142 
143  /** DBUS interface function. Returns INDI Light state
144  * @param device device name
145  * @param property name
146  * @param lightName light element name
147  * @returns Idle, Ok, Busy, or Alert. If no property is found, it returns "Invalid"
148  */
149  Q_SCRIPTABLE QString getLight(const QString &device, const QString &property, const QString &lightName);
150 
151  /** DBUS interface function. Returns INDI blob data. It can be extremely inefficient transporting large amount of data via DBUS.
152  * @param device device name
153  * @param property property name
154  * @param blobName blob element name
155  * @param blobFormat blob element format. It is usually the extension of the blob file.
156  * @param size blob element size in bytes. If -1, then there is an error.
157  * @returns array of bytes containing blob.
158  * @see getBLOBFile
159  */
160  Q_SCRIPTABLE QByteArray getBLOBData(const QString &device, const QString &property, const QString &blobName,
161  QString &blobFormat, int &size);
162 
163  /** DBUS interface function. Returns INDI blob filename stored on the local file system.
164  * @param device device name
165  * @param property property name
166  * @param blobName blob element name
167  * @param blobFormat blob element format. It is usually the extension of a file.
168  * @param size blob element size in bytes. If -1, then there is an error.
169  * @returns full file name
170  */
171  Q_SCRIPTABLE QString getBLOBFile(const QString &device, const QString &property, const QString &blobName,
172  QString &blobFormat, int &size);
173 
174  /** @}*/
175 };
Q_OBJECTQ_OBJECT
Q_SCRIPTABLE QStringList getDevicesPaths(uint32_t interface)
DBUS interface function.
Definition: indidbus.cpp:129
Q_SCRIPTABLE QString getText(const QString &device, const QString &property, const QString &textName)
DBUS interface function.
Definition: indidbus.cpp:396
Q_CLASSINFO(Name, Value)
Q_SCRIPTABLE QString getBLOBFile(const QString &device, const QString &property, const QString &blobName, QString &blobFormat, int &size)
DBUS interface function.
Definition: indidbus.cpp:525
Q_SCRIPTABLE bool setText(const QString &device, const QString &property, const QString &textName, const QString &text)
DBUS interface function.
Definition: indidbus.cpp:366
Q_SCRIPTABLE QStringList getProperties(const QString &device)
DBUS interface function.
Definition: indidbus.cpp:141
Q_SCRIPTABLE QStringList getDevices()
DBUS interface function.
Definition: indidbus.cpp:117
Q_SCRIPTABLE bool connect(const QString &host, int port)
DBUS interface function.
Definition: indidbus.cpp:77
Q_SCRIPTABLE bool setNumber(const QString &device, const QString &property, const QString &numberName, double value)
DBUS interface function.
Definition: indidbus.cpp:427
Q_SCRIPTABLE bool sendProperty(const QString &device, const QString &property)
DBUS interface function.
Definition: indidbus.cpp:217
Q_SCRIPTABLE bool start(int port, const QStringList &drivers)
DBUS interface function.
Definition: indidbus.cpp:28
Q_SCRIPTABLE bool disconnect(const QString &host, int port)
DBUS interface function.
Definition: indidbus.cpp:98
Q_SCRIPTABLE bool setSwitch(const QString &device, const QString &property, const QString &switchName, const QString &status)
DBUS interface function.
Definition: indidbus.cpp:294
Q_SCRIPTABLE QString getSwitch(const QString &device, const QString &property, const QString &switchName)
DBUS interface function.
Definition: indidbus.cpp:335
ScriptableExtension * host() const
Q_SCRIPTABLE QByteArray getBLOBData(const QString &device, const QString &property, const QString &blobName, QString &blobFormat, int &size)
DBUS interface function.
Definition: indidbus.cpp:488
Q_SCRIPTABLE QString getPropertyState(const QString &device, const QString &property)
DBUS interface function.
Definition: indidbus.cpp:193
Q_SCRIPTABLE bool stop(const QString &port)
DBUS interface function.
Definition: indidbus.cpp:53
Q_SCRIPTABLE double getNumber(const QString &device, const QString &property, const QString &numberName)
DBUS interface function.
Definition: indidbus.cpp:457
Q_SCRIPTABLE QString getLight(const QString &device, const QString &property, const QString &lightName)
DBUS interface function.
Definition: indidbus.cpp:262
QObject * parent() const const
QVariant property(const char *name) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Sep 27 2023 04:02:10 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.