Kstars

devicemanager.h
1/*
2 SPDX-FileCopyrightText: 2003 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QTcpSocket>
10
11class INDIMenu;
12class INDI_P;
13class INDI_D;
14
15class KProcess;
16class QTcpSocket;
17
18// INDI device manager
19class DeviceManager : public QObject
20{
22 public:
23 enum ManagerMode
24 {
25 M_LOCAL,
26 M_SERVER,
27 M_CLIENT
28 };
29 enum
30 {
31 INDI_DEVICE_NOT_FOUND = -1,
32 INDI_PROPERTY_INVALID = -2,
33 INDI_PROPERTY_DUPLICATED = -3,
34 INDI_DISPATCH_ERROR = -4
35 };
36
37 DeviceManager(INDIMenu *INDIparent, QString inHost, uint inPort, ManagerMode inMode);
38 ~DeviceManager();
39
40 INDIMenu *parent;
41 QList<INDI_D *> indi_dev;
42 QList<IDevice *> managed_devices;
43
44 QTcpSocket serverSocket;
45 LilXML *XMLParser;
46 QString host;
47 uint port;
48 QString serverBuffer;
49 ManagerMode mode;
50 KProcess *serverProcess;
51
52 int dispatchCommand(XMLEle *root, QString &errmsg);
53
54 INDI_D *addDevice(XMLEle *dep, QString &errmsg);
55 INDI_D *findDev(XMLEle *root, int create, QString &errmsg);
56
57 /*****************************************************************
58 * Send to server
59 ******************************************************************/
60 void sendNewText(INDI_P *pp);
61 void sendNewNumber(INDI_P *pp);
62 void sendNewSwitch(INDI_P *pp, INDI_E *lp);
63 void startBlob(const QString &devName, const QString &propName, const QString &timestamp);
64 void sendOneBlob(const QString &blobName, unsigned int blobSize, const QString &blobFormat,
65 unsigned char *blobBuffer);
66 void finishBlob();
67
68 /*****************************************************************
69 * Misc.
70 ******************************************************************/
71 int delPropertyCmd(XMLEle *root, QString &errmsg);
72 int removeDevice(const QString &devName, QString &errmsg);
73 INDI_D *findDev(const QString &devName, QString &errmsg);
74
75 int messageCmd(XMLEle *root, QString &errmsg);
76 void checkMsg(XMLEle *root, INDI_D *dp);
77 void doMsg(XMLEle *msg, INDI_D *dp);
78
79 void appendManagedDevices(QList<IDevice *> &processed_devices);
80 void startServer();
81 void stopServer();
82 void connectToServer();
83 void enableBLOB(bool enable, QString device = QString(), QString property = QString());
84
85 QString getServerBuffer() { return serverBuffer; }
86
87 public slots:
88 void dataReceived();
89 void connectionSuccess();
90 void connectionError();
91 void processStandardError();
92
93 signals:
94 void newDevice(INDI_D *);
95 void deviceManagerError(DeviceManager *);
96 void newServerInput();
97};
INDI_D represents an INDI GUI Device.
Definition indidevice.h:35
INDI_E represents an INDI GUI element (Number, Text, Switch, Light, or BLOB) within an INDI property.
Definition indielement.h:42
INDI_P represents a single INDI property (Switch, Text, Number, Light, or BLOB).
Q_OBJECTQ_OBJECT
QVariant property(const char *name) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:41 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.