phidget.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009, Tully Foote
3  * Copyright (c) 2011, Ivan Dryanovski
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of the Willow Garage, Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef PHIDGETS_API_PHIDGET_H
32 #define PHIDGETS_API_PHIDGET_H
33 
34 #include <libphidget21/phidget21.h>
35 
36 #include <string>
37 
38 namespace phidgets {
39 
40 class Phidget
41 {
42  public:
43  Phidget();
44  virtual ~Phidget();
45 
52  int openAndWaitForAttachment(int serial_number, int timeout);
53 
55  int close();
56 
58  std::string getDeviceType();
59 
61  std::string getDeviceName();
62 
64  std::string getDeviceLabel();
65 
67  std::string getLibraryVersion();
68 
71 
73  int getDeviceVersion();
74 
77  static std::string getErrorDescription(int errorCode);
78 
79  protected:
80  void init(CPhidgetHandle handle);
81 
82  void registerHandlers();
83  virtual void attachHandler();
84  virtual void detachHandler();
85  virtual void errorHandler(int error);
86 
87  private:
88  CPhidgetHandle handle_;
89 
90  static int AttachHandler(CPhidgetHandle handle, void *userptr);
91  static int DetachHandler(CPhidgetHandle handle, void *userptr);
92  static int ErrorHandler(CPhidgetHandle handle, void *userptr, int ErrorCode,
93  const char *unknown);
94 };
95 
96 } // namespace phidgets
97 
98 #endif // PHIDGETS_API_PHIDGET_H
int openAndWaitForAttachment(int serial_number, int timeout)
Open a connection to a Phidget.
Definition: phidget.cpp:29
static int DetachHandler(CPhidgetHandle handle, void *userptr)
Definition: phidget.cpp:121
static int AttachHandler(CPhidgetHandle handle, void *userptr)
Definition: phidget.cpp:115
void registerHandlers()
Definition: phidget.cpp:17
int getDeviceSerialNumber()
Get the Phidget&#39;s serial number.
Definition: phidget.cpp:77
virtual void detachHandler()
Definition: phidget.cpp:104
static int ErrorHandler(CPhidgetHandle handle, void *userptr, int ErrorCode, const char *unknown)
Definition: phidget.cpp:127
static std::string getErrorDescription(int errorCode)
Lookup the string for a CPhidget Error Code.
Definition: phidget.cpp:91
int close()
Close the connection to the phidget.
Definition: phidget.cpp:40
CPhidgetHandle handle_
Definition: phidget.h:88
virtual void errorHandler(int error)
Definition: phidget.cpp:109
virtual ~Phidget()
Definition: phidget.cpp:11
virtual void attachHandler()
Definition: phidget.cpp:99
std::string getDeviceType()
Get the device type string.
Definition: phidget.cpp:45
std::string getDeviceLabel()
Get the device label string.
Definition: phidget.cpp:61
std::string getLibraryVersion()
Get the library version string.
Definition: phidget.cpp:69
int getDeviceVersion()
Get the Phidget&#39;s version.
Definition: phidget.cpp:84
void init(CPhidgetHandle handle)
Definition: phidget.cpp:24
std::string getDeviceName()
Get the device name string.
Definition: phidget.cpp:53


phidgets_api
Author(s): Tully Foote, Ivan Dryanovski
autogenerated on Fri Apr 9 2021 02:56:02