Instrument Neutral Distributed Interface INDI  1.6.0
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  AUX_INTERFACE = (1 << 15),
79  };
80 
82  INumberVectorProperty *getNumber(const char *name);
84  ITextVectorProperty *getText(const char *name);
86  ISwitchVectorProperty *getSwitch(const char *name);
88  ILightVectorProperty *getLight(const char *name);
90  IBLOBVectorProperty *getBLOB(const char *name);
92  IPState getPropertyState(const char *name);
94  IPerm getPropertyPermission(const char *name);
95 
97 
103  int removeProperty(const char *name, char *errmsg);
104 
116 
124 
127  std::vector<INDI::Property *> *getProperties() { return &pAll; }
128 
140  bool buildSkeleton(const char *filename);
141 
143  bool isConnected();
144 
148  void setDeviceName(const char *dev);
149 
151  const char *getDeviceName();
152 
156  void addMessage(const std::string& msg);
157 
158  void checkMessage(XMLEle *root);
159  void doMessage(XMLEle *msg);
160 
162  std::string messageQueue(int index) const;
163 
165  std::string lastMessage();
166 
168  void setMediator(INDI::BaseMediator *med) { mediator = med; }
169 
171  INDI::BaseMediator *getMediator() { return mediator; }
172 
176  const char *getDriverName();
177 
181  const char *getDriverExec();
182 
186  const char *getDriverVersion();
187 
201  virtual uint16_t getDriverInterface();
202 
203  protected:
208  int buildProp(XMLEle *root, char *errmsg);
209 
211  int setValue(XMLEle *root, char *errmsg);
213  int setBLOB(IBLOBVectorProperty *pp, XMLEle *root, char *errmsg);
214 
215  private:
216  char *deviceID;
217 
218  std::vector<INDI::Property *> pAll;
219 
220  LilXML *lp;
221 
222  std::vector<std::string> messageLog;
223 
224  INDI::BaseMediator *mediator;
225 
226  friend class INDI::BaseClient;
227  friend class INDI::BaseClientQt;
228  friend class INDI::DefaultDevice;
229 };
230 
231 }
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:397
INDI_PROPERTY_TYPE
Definition: indibasetypes.h:22
Definition: lilxml.c:90
std::string messageQueue(int index) const
IPState
Property state.
Definition: indiapi.h:143
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:113
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:168
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:347
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:539
INDI::BaseMediator * getMediator()
Definition: basedevice.h:171
ITextVectorProperty * getText(const char *name)
Definition: basedevice.cpp:81
BLOB (Binary Large Object) vector property descriptor.
Definition: indiapi.h:451
virtual ~BaseDevice()
Definition: basedevice.cpp:60
Number vector property descriptor.
Definition: indiapi.h:299
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:939
std::vector< INDI::Property * > * getProperties()
Return a list of all properties in the device.
Definition: basedevice.h:127
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
IPerm
Permission hint, with respect to client.
Definition: indiapi.h:164
IBLOBVectorProperty * getBLOB(const char *name)
Definition: basedevice.cpp:108
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:226
Class to provide basic client functionality.
Definition: baseclient.h:54
__le16 type
Definition: pwc-ioctl.h:53
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:77