Instrument Neutral Distributed Interface INDI  1.7.6
basedevice.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2011 Jasem Mutlaq. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 *******************************************************************************/
18 
19 #pragma once
20 
21 #include "indibase.h"
22 #include "indiproperty.h"
23 
24 #include <string>
25 #include <vector>
26 
27 #include <stdint.h>
28 
29 #define MAXRBUF 2048
30 
41 namespace INDI
42 {
43 
45 {
46  public:
47  BaseDevice();
48  virtual ~BaseDevice();
49 
52  {
57  };
58 
63  {
65  TELESCOPE_INTERFACE = (1 << 0),
66  CCD_INTERFACE = (1 << 1),
67  GUIDER_INTERFACE = (1 << 2),
68  FOCUSER_INTERFACE = (1 << 3),
69  FILTER_INTERFACE = (1 << 4),
70  DOME_INTERFACE = (1 << 5),
71  GPS_INTERFACE = (1 << 6),
72  WEATHER_INTERFACE = (1 << 7),
73  AO_INTERFACE = (1 << 8),
74  DUSTCAP_INTERFACE = (1 << 9),
75  LIGHTBOX_INTERFACE = (1 << 10),
76  DETECTOR_INTERFACE = (1 << 11),
77  ROTATOR_INTERFACE = (1 << 12),
78  SPECTROGRAPH_INTERFACE = (1 << 13),
79  AUX_INTERFACE = (1 << 15),
80  };
81 
83  INumberVectorProperty *getNumber(const char *name);
85  ITextVectorProperty *getText(const char *name);
87  ISwitchVectorProperty *getSwitch(const char *name);
89  ILightVectorProperty *getLight(const char *name);
91  IBLOBVectorProperty *getBLOB(const char *name);
93  IPState getPropertyState(const char *name);
95  IPerm getPropertyPermission(const char *name);
96 
98 
104  int removeProperty(const char *name, char *errmsg);
105 
117 
125 
128  std::vector<INDI::Property *> *getProperties() { return &pAll; }
129 
141  bool buildSkeleton(const char *filename);
142 
144  bool isConnected();
145 
149  void setDeviceName(const char *dev);
150 
152  const char *getDeviceName();
153 
157  void addMessage(const std::string& msg);
158 
159  void checkMessage(XMLEle *root);
160  void doMessage(XMLEle *msg);
161 
163  std::string messageQueue(int index) const;
164 
166  std::string lastMessage();
167 
169  void setMediator(INDI::BaseMediator *med) { mediator = med; }
170 
172  INDI::BaseMediator *getMediator() { return mediator; }
173 
177  const char *getDriverName();
178 
182  const char *getDriverExec();
183 
187  const char *getDriverVersion();
188 
202  virtual uint16_t getDriverInterface();
203 
204  protected:
209  int buildProp(XMLEle *root, char *errmsg);
210 
212  int setValue(XMLEle *root, char *errmsg);
214  int setBLOB(IBLOBVectorProperty *pp, XMLEle *root, char *errmsg);
215 
216  private:
217  char *deviceID;
218 
219  std::vector<INDI::Property *> pAll;
220 
221  LilXML *lp;
222 
223  std::vector<std::string> messageLog;
224 
225  INDI::BaseMediator *mediator;
226 
227  friend class INDI::BaseClient;
228  friend class INDI::BaseClientQt;
229  friend class INDI::DefaultDevice;
230 };
231 
232 }
virtual uint16_t getDriverInterface()
getDriverInterface returns ORed values of DRIVER_INTERFACE. It presents the device classes supported ...
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Light vector property descriptor.
Definition: indiapi.h:413
INDI_PROPERTY_TYPE
Definition: indibasetypes.h:22
IPState
Property state.
Definition: indiapi.h:156
Provides generic container for INDI properties.
Definition: indiproperty.h:33
const char * getDriverExec()
void setDeviceName(const char *dev)
Set the device name.
void * getRawProperty(const char *name, INDI_PROPERTY_TYPE type=INDI_UNKNOWN)
Return a property and its type given its name.
Definition: basedevice.cpp:238
const char * name
Definition: indiserver.c:115
Class to provide basic client functionality based on Qt5 toolkit and is therefore suitable for cross-...
Definition: baseclientqt.h:50
void setMediator(INDI::BaseMediator *med)
Set the driver&#39;s mediator to receive notification of news devices and updated property values...
Definition: basedevice.h:169
Class to provide basic INDI device functionality.
Definition: basedevice.h:44
ISwitchVectorProperty * getSwitch(const char *name)
Definition: basedevice.cpp:90
INumberVectorProperty * getNumber(const char *name)
Definition: basedevice.cpp:72
int removeProperty(const char *name, char *errmsg)
Remove a property.
Definition: basedevice.cpp:385
Switch vector property descriptor.
Definition: indiapi.h:363
IPState getPropertyState(const char *name)
Definition: basedevice.cpp:117
const char * getDriverVersion()
Namespace to encapsulate INDI client, drivers, and mediator classes. Developers can subclass the base...
int buildProp(XMLEle *root, char *errmsg)
Build a property given the supplied XML element (defXXX)
Definition: basedevice.cpp:540
INDI::BaseMediator * getMediator()
Definition: basedevice.h:172
ITextVectorProperty * getText(const char *name)
Definition: basedevice.cpp:81
BLOB (Binary Large Object) vector property descriptor.
Definition: indiapi.h:467
virtual ~BaseDevice()
Definition: basedevice.cpp:60
Number vector property descriptor.
Definition: indiapi.h:315
std::string lastMessage()
const char * getDeviceName()
void addMessage(const std::string &msg)
Add message to the driver&#39;s message queue.
bool buildSkeleton(const char *filename)
Build driver properties from a skeleton file.
Definition: basedevice.cpp:466
int setValue(XMLEle *root, char *errmsg)
handle SetXXX commands from client
Definition: basedevice.cpp:941
std::vector< INDI::Property * > * getProperties()
Return a list of all properties in the device.
Definition: basedevice.h:128
INDI::Property * getProperty(const char *name, INDI_PROPERTY_TYPE type=INDI_UNKNOWN)
Return a property and its type given its name.
Definition: basedevice.cpp:311
void doMessage(XMLEle *msg)
const char * getDriverName()
DRIVER_INTERFACE
The DRIVER_INTERFACE enum defines the class of devices the driver implements. A driver may implement ...
Definition: basedevice.h:62
Definition: lilxml.c:90
IPerm
Permission hint, with respect to client.
Definition: indiapi.h:179
IBLOBVectorProperty * getBLOB(const char *name)
Definition: basedevice.cpp:108
std::string messageQueue(int index) const
int setBLOB(IBLOBVectorProperty *pp, XMLEle *root, char *errmsg)
Parse and store BLOB in the respective vector.
ILightVectorProperty * getLight(const char *name)
Definition: basedevice.cpp:99
IPerm getPropertyPermission(const char *name)
Definition: basedevice.cpp:181
Text vector property descriptor.
Definition: indiapi.h:242
Class to provide basic client functionality.
Definition: baseclient.h:54
__le16 type
Definition: pwc-ioctl.h:292
void checkMessage(XMLEle *root)
void registerProperty(void *p, INDI_PROPERTY_TYPE type)
Meditates event notification as generated by driver and passed to clients.
Definition: indibase.h:78