Kstars

indidriver.h
1/*
2 SPDX-FileCopyrightText: 2001 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "ui_devmanager.h"
10
11#include <QFrame>
12#include <QHash>
13#include <QIcon>
14#include <QList>
15
16#include <lilxml.h>
17
18#ifndef _WIN32
19#include <unistd.h>
20#endif
21
22class QTreeWidgetItem;
23
24class DeviceManager;
25class INDI_D;
26class KStars;
27
28struct INDIHostsInfo
29{
30 QString name;
31 QString hostname;
32 QString portnumber;
33 bool isConnected { false };
34 DeviceManager *deviceManager { nullptr };
35};
36
37class IDevice : public QObject
38{
40
41 public:
42 enum DeviceStatus
43 {
44 DEV_START,
45 DEV_TERMINATE
46 };
47 enum XMLSource
48 {
49 PRIMARY_XML,
50 THIRD_PARTY_XML,
51 EM_XML
52 };
53
54 IDevice(const QString &inName, const QString &inLabel, const QString &inDriver, const QString &inVersion);
55 ~IDevice();
56
57 void clear();
58 QString getServerBuffer();
59
60 QString tree_label;
61 QString unique_label;
62 QString name;
63 QString driver;
64 QString version;
65 QString id;
66 QString port;
67 DeviceStatus state;
68 XMLSource xmlSource;
69
70 DeviceManager *deviceManager;
71 int type { 0 };
72
73 /* Telescope specific attributes */
74 double focal_length { 0 };
75 double aperture { 0 };
76};
77
78class DeviceManagerUI : public QFrame, public Ui::devManager
79{
81
82 public:
83 explicit DeviceManagerUI(QWidget *parent = nullptr);
84
85 QIcon runningPix;
86 QIcon stopPix;
87 QIcon connected;
88 QIcon disconnected;
89 QIcon localMode;
90 QIcon serverMode;
91
92 public slots:
93 void makePortEditable(QTreeWidgetItem *selectedItem, int column);
94};
95
96class INDIDriver : public QDialog
97{
99
100 public:
101 enum
102 {
103 LOCAL_NAME_COLUMN = 0,
104 LOCAL_STATUS_COLUMN,
105 LOCAL_MODE_COLUMN,
106 LOCAL_VERSION_COLUMN,
107 LOCAL_PORT_COLUMN
108 };
109 enum
110 {
111 HOST_STATUS_COLUMN = 0,
112 HOST_NAME_COLUMN,
113 HOST_PORT_COLUMN
114 };
115
116 explicit INDIDriver(KStars *ks);
117 ~INDIDriver();
118
119 bool readXMLDrivers();
120 void processXMLDriver(QString &driverName);
121 bool buildDeviceGroup(XMLEle *root, char errmsg[]);
122 bool buildDriverElement(XMLEle *root, QTreeWidgetItem *DGroup, int groupType, char errmsg[]);
123
124 int getINDIPort(int customPort);
125 bool isDeviceRunning(const QString &deviceLabel);
126
127 void saveHosts();
128
129 void processLocalTree(IDevice::DeviceStatus dev_request);
130 void processRemoteTree(IDevice::DeviceStatus dev_request);
131 IDevice *findDeviceByLabel(const QString &label);
132
133 public slots:
134 void enableDevice(INDI_D *device);
135 void disableDevice(INDI_D *device);
136
137 void resizeDeviceColumn();
138 void updateLocalTab();
139 void updateClientTab();
140
141 void updateMenuActions();
142
143 void addINDIHost();
144 void modifyINDIHost();
145 void removeINDIHost();
146 void activateRunService();
147 void activateStopService();
148 void activateHostConnection();
149 void activateHostDisconnection();
150 void newTelescopeDiscovered();
151 void newCCDDiscovered();
152 void updateCustomDrivers();
153
154 public:
155 KStars *ksw { nullptr };
156 DeviceManagerUI *ui { nullptr };
157 QList<IDevice *> devices;
158 QTreeWidgetItem *lastGroup { nullptr };
159 QTreeWidgetItem *lastDevice { nullptr };
160 QHash<QString, QString> driversList;
161 int currentPort { 0 };
162 IDevice::XMLSource xmlSource;
163
164 signals:
165 void newDevice();
166 void newTelescope();
167 void newCCD();
168};
INDI_D represents an INDI GUI Device.
Definition indidevice.h:35
This is the main window for KStars.
Definition kstars.h:89
Q_OBJECTQ_OBJECT
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.