Kstars

indidriver.h
1 /*
2  SPDX-FileCopyrightText: 2001 Jasem Mutlaq <[email protected]>
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 
22 class QTreeWidgetItem;
23 
24 class DeviceManager;
25 class INDI_D;
26 class KStars;
27 
28 struct INDIHostsInfo
29 {
30  QString name;
32  QString portnumber;
33  bool isConnected { false };
34  DeviceManager *deviceManager { nullptr };
35 };
36 
37 class IDevice : public QObject
38 {
39  Q_OBJECT
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;
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 
78 class DeviceManagerUI : public QFrame, public Ui::devManager
79 {
80  Q_OBJECT
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 
96 class INDIDriver : public QDialog
97 {
98  Q_OBJECT
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 };
Q_OBJECTQ_OBJECT
Type type(const QSqlDatabase &db)
NETWORKMANAGERQT_EXPORT QString hostname()
This is the main window for KStars. In addition to the GUI elements, the class contains the program c...
Definition: kstars.h:92
QAction * clear(const QObject *recvr, const char *slot, QObject *parent)
KDB_EXPORT KDbVersionInfo version()
const char * name(StandardAction id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:54 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.