summaryrefslogtreecommitdiffstats
path: root/kstars/kstars/indidriver.h
blob: 3658683375824a21f13f81480985b68161a8ec4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/***************************************************************************
                          INDI Driver
                             -------------------
    begin                : Wed May 7th 2003
    copyright            : (C) 2001 by Jasem Mutlaq
    email                : mutlaqja@ikarustech.com
 ***************************************************************************/
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef INDIDRIVER_H
#define INDIDRIVER_H

#include <tqstringlist.h>
#include <kdialogbase.h>
#include <unistd.h>
#include <vector>

#include "indi/lilxml.h"
#include "devmanager.h"

class KStars;

class KListView;
class KPopupMenu;
class KProcess;

struct INDIHostsInfo
{
  TQString name;
  TQString hostname;
  TQString portnumber;
  bool isConnected;
  int mgrID;
};

class IDevice : public QObject
{
     Q_OBJECT
     
     public:
        IDevice(TQString inLabel, TQString inDriver, TQString inVersion);
	~IDevice();

      enum ServeMODE { M_LOCAL, M_SERVER };
      TQString label;
      TQString driver;
      TQString version;
      TQStringList serverBuffer;
      int state;
      int mode;
      int indiPort;
      bool managed;
      int mgrID;
      int deviceType;
      KProcess *proc;

      /* Telescope specific attributes */
      double focal_length;
      double aperture;

      void restart();
      
      public slots:
      void processstd(KProcess *proc, char* buffer, int buflen);
      
      signals:
      void newServerInput();
      
};
    
class INDIDriver : public devManager
{

   Q_OBJECT

   public:

   INDIDriver(TQWidget * parent = 0);
   ~INDIDriver();

    KListView* deviceContainer;

    bool readXMLDriver();

    bool buildDriversList( XMLEle *root, char errmsg[]);
    bool buildDeviceGroup  (XMLEle *root, char errmsg[]);
    bool buildDriverElement(XMLEle *root, TQListViewItem *DGroup, int groupType, char errmsg[]);

    TQListViewItem *lastGroup;
    TQListViewItem *lastDevice;

    TQStringList driversList;

    TQPixmap runningPix;
    TQPixmap stopPix;
    TQPixmap connected;
    TQPixmap disconnected;
    TQPixmap establishConnection;
    TQPixmap localMode;
    TQPixmap serverMode;

    KPopupMenu *ClientpopMenu;
    KPopupMenu *LocalpopMenu;

    int lastPort;

    bool runDevice(IDevice *dev);
    void removeDevice(IDevice *dev);
    void removeDevice(TQString deviceLabel);
    void saveDevicesToDisk();
    int getINDIPort();
    int activeDriverCount();
    bool isDeviceRunning(TQString deviceLabel);

    void saveHosts();

    std::vector <IDevice *> devices;

     KStars *ksw;


public slots:
    void updateMenuActions();
    void ClientprocessRightButton( TQListViewItem *, const TQPoint &, int );
    void LocalprocessRightButton( TQListViewItem *, const TQPoint &, int );
    void processDevicetqStatus(int);
    void processHostqStatus(int);
    void addINDIHost();
    void modifyINDIHost();
    void removeINDIHost();
    void shutdownHost(int mgrID);
    void updateLocalButtons();
    void updateClientButtons();
    void activateRunService();
    void activateStopService();
    void activateHostConnection();
    void activateHostDisconnection();
};

#endif