phidget.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <cob_phidgets/phidget.h>
18 #include <iostream>
19 #include <algorithm>
20 #include <string>
21 #include <cstring>
22 
23 Phidget::Phidget(CPhidgetHandle* handle, SensingMode mode)
24  : _phiHandle(handle), _serialNumber(-1), _last_error(-1), _sensMode(mode)
25 {
26 }
27 
29 {
30  CPhidget_close(*_phiHandle);
31  CPhidget_delete(*_phiHandle);
32 }
33 
34 auto Phidget::open(int serial_number) -> int
35 {
36  return CPhidget_open(*_phiHandle, serial_number);
37 }
38 
39 auto Phidget::close(int serial_number) -> int
40 {
41  return CPhidget_close(*_phiHandle);
42 }
43 
44 auto Phidget::waitForAttachment(int timeout) -> int
45 {
46  return CPhidget_waitForAttachment(*_phiHandle, timeout);
47 }
48 
49 auto Phidget::getDeviceType() -> std::string
50 {
51  char a[256];
52  const char * deviceptr = a;
53  CPhidget_getDeviceType(*_phiHandle, &deviceptr);
54  return std::string(deviceptr);
55 }
56 
57 auto Phidget::getDeviceName() -> std::string
58 {
59  char a[256];
60  const char * deviceptr = a;
61  CPhidget_getDeviceName(*_phiHandle, &deviceptr);
62  return std::string(deviceptr);
63 }
64 
65 auto Phidget::getDeviceLabel() -> std::string
66 {
67  char a[256];
68  const char * deviceptr = a;
69  CPhidget_getDeviceType(*_phiHandle, &deviceptr);
70  return std::string(deviceptr);
71 }
72 
73 auto Phidget::getLibraryVersion() -> std::string
74 {
75  char a[256];
76  const char * deviceptr = a;
77  CPhidget_getLibraryVersion(&deviceptr);
78  return std::string(deviceptr);
79 }
80 
82 {
83  int sernum;
84  CPhidget_getSerialNumber(*_phiHandle, &sernum);
85  _serialNumber = sernum;
86  return sernum;
87 }
88 
90 {
91  int version;
92  CPhidget_getDeviceVersion(*_phiHandle, &version);
93  return version;
94 }
95 
96 auto Phidget::getErrorDescription(int errorCode) -> std::string
97 {
98  char a[256];
99  const char * errorPtr = a;
100  CPhidget_getErrorDescription(errorCode, &errorPtr);
101  return std::string(errorPtr);
102 }
103 
105 {
106  printf("attachHandler()");
107  return 0;
108 }
109 
111 {
112  printf("detachHandler()");
113  return 0;
114 }
115 
116 auto Phidget::update() -> void
117 {
118  printf("Phidget::update()");
119 }
auto open(int serial_number) -> int
Definition: phidget.cpp:34
~Phidget()
Definition: phidget.cpp:28
auto waitForAttachment(int timeout) -> int
Definition: phidget.cpp:44
virtual auto detachHandler() -> int
Definition: phidget.cpp:110
auto close(int serial_number) -> int
Definition: phidget.cpp:39
SensingMode
Definition: phidget.h:27
auto getDeviceType() -> std::string
Definition: phidget.cpp:49
Phidget(CPhidgetHandle *handle, SensingMode mode)
Definition: phidget.cpp:23
auto getDeviceName() -> std::string
Definition: phidget.cpp:57
virtual auto update() -> void
Definition: phidget.cpp:116
CPhidgetHandle * _phiHandle
Definition: phidget.h:46
auto getLibraryVersion() -> std::string
Definition: phidget.cpp:73
static auto getErrorDescription(int errorCode) -> std::string
Definition: phidget.cpp:96
auto getDeviceSerialNumber() -> int
Definition: phidget.cpp:81
auto getDeviceVersion() -> int
Definition: phidget.cpp:89
auto getDeviceLabel() -> std::string
Definition: phidget.cpp:65
int _serialNumber
Definition: phidget.h:47
virtual auto attachHandler() -> int
Definition: phidget.cpp:104


cob_phidgets
Author(s): Florian Weisshardt
autogenerated on Wed Apr 7 2021 02:11:43