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 <iostream>
37 #include <algorithm>
38 #include <string>
39 #include <cstring>
40 #include <stdio.h>
41 
42 namespace phidgets {
43 
44 class Phidget
45 {
46  public:
47 
48  Phidget();
49  ~Phidget();
50 
53  int open(int serial_number);
54 
56  int close();
57 
61  int waitForAttachment(int timeout);
62 
64  std::string getDeviceType();
65 
67  std::string getDeviceName();
68 
70  std::string getDeviceLabel();
71 
73  std::string getLibraryVersion();
74 
77 
79  int getDeviceVersion();
80 
83  static std::string getErrorDescription(int errorCode);
84 
85  protected:
86 
87  CPhidgetHandle handle_;
88 
89  void init(CPhidgetHandle handle);
90 
91  virtual void registerHandlers();
92  virtual void attachHandler();
93  virtual void detachHandler();
94  virtual void errorHandler(int error);
95 
96  private:
97 
98  static int AttachHandler(CPhidgetHandle handle, void *userptr);
99  static int DetachHandler(CPhidgetHandle handle, void *userptr);
100  static int ErrorHandler (CPhidgetHandle handle, void *userptr, int ErrorCode, const char *unknown);
101 };
102 
103 } // namespace phidgets
104 
105 #endif // PHIDGETS_API_PHIDGET_H
106 
static int DetachHandler(CPhidgetHandle handle, void *userptr)
Definition: phidget.cpp:117
static int AttachHandler(CPhidgetHandle handle, void *userptr)
Definition: phidget.cpp:111
virtual void registerHandlers()
Definition: phidget.cpp:16
int getDeviceSerialNumber()
Get the Phidget&#39;s serial number.
Definition: phidget.cpp:74
virtual void detachHandler()
Definition: phidget.cpp:101
static int ErrorHandler(CPhidgetHandle handle, void *userptr, int ErrorCode, const char *unknown)
Definition: phidget.cpp:123
int open(int serial_number)
Open a connection to a Phidget.
Definition: phidget.cpp:28
int waitForAttachment(int timeout)
Block until the unit is attached or timeout occurs.
Definition: phidget.cpp:38
static std::string getErrorDescription(int errorCode)
Lookup the string for a CPhidget Error Code.
Definition: phidget.cpp:88
int close()
Close the connection to the phidget.
Definition: phidget.cpp:33
CPhidgetHandle handle_
Definition: phidget.h:87
virtual void errorHandler(int error)
Definition: phidget.cpp:106
virtual void attachHandler()
Definition: phidget.cpp:96
std::string getDeviceType()
Get the device type string.
Definition: phidget.cpp:43
std::string getDeviceLabel()
Get the device label string.
Definition: phidget.cpp:59
std::string getLibraryVersion()
Get the library version string.
Definition: phidget.cpp:67
int getDeviceVersion()
Get the Phidget&#39;s version.
Definition: phidget.cpp:81
void init(CPhidgetHandle handle)
Definition: phidget.cpp:23
std::string getDeviceName()
Get the device name string.
Definition: phidget.cpp:51


phidgets_api
Author(s): Tully Foote, Ivan Dryanovski
autogenerated on Tue May 7 2019 03:19:24