phidget.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #include <cob_phidgets/phidget.h>
00018 #include <iostream>
00019 #include <algorithm>
00020 #include <string>
00021 #include <cstring>
00022 
00023 Phidget::Phidget(CPhidgetHandle* handle, SensingMode mode)
00024         : _phiHandle(handle), _serialNumber(-1), _last_error(-1), _sensMode(mode)
00025 {
00026 }
00027 
00028 Phidget::~Phidget()
00029 {
00030         CPhidget_close(*_phiHandle);
00031         CPhidget_delete(*_phiHandle);
00032 }
00033 
00034 auto Phidget::open(int serial_number) -> int
00035 {
00036         return CPhidget_open(*_phiHandle, serial_number);
00037 }
00038 
00039 auto Phidget::close(int serial_number) -> int
00040 {
00041         return CPhidget_close(*_phiHandle);
00042 }
00043 
00044 auto Phidget::waitForAttachment(int timeout) -> int
00045 {
00046         return CPhidget_waitForAttachment(*_phiHandle, timeout);
00047 }
00048 
00049 auto Phidget::getDeviceType() -> std::string
00050 {
00051         char a[256];
00052         const char * deviceptr = a;
00053         CPhidget_getDeviceType(*_phiHandle, &deviceptr);
00054         return std::string(deviceptr);
00055 }
00056 
00057 auto Phidget::getDeviceName() -> std::string
00058 {
00059         char a[256];
00060         const char * deviceptr = a;
00061         CPhidget_getDeviceName(*_phiHandle, &deviceptr);
00062         return std::string(deviceptr);
00063 }
00064 
00065 auto Phidget::getDeviceLabel() -> std::string
00066 {
00067         char a[256];
00068         const char * deviceptr = a;
00069         CPhidget_getDeviceType(*_phiHandle, &deviceptr);
00070         return std::string(deviceptr);
00071 }
00072 
00073 auto Phidget::getLibraryVersion() -> std::string
00074 {
00075         char a[256];
00076         const char * deviceptr = a;
00077         CPhidget_getLibraryVersion(&deviceptr);
00078         return std::string(deviceptr);
00079 }
00080 
00081 auto Phidget::getDeviceSerialNumber() -> int
00082 {
00083         int sernum;
00084         CPhidget_getSerialNumber(*_phiHandle, &sernum);
00085         _serialNumber = sernum;
00086         return sernum;
00087 }
00088 
00089 auto Phidget::getDeviceVersion() -> int
00090 {
00091         int version;
00092         CPhidget_getDeviceVersion(*_phiHandle, &version);
00093         return version;
00094 }
00095 
00096 auto Phidget::getErrorDescription(int errorCode) -> std::string
00097 {
00098         char a[256];
00099         const char * errorPtr = a;
00100         CPhidget_getErrorDescription(errorCode, &errorPtr);
00101         return std::string(errorPtr);
00102 }
00103 
00104 auto Phidget::attachHandler() -> int
00105 {
00106         printf("attachHandler()");
00107         return 0;
00108 }
00109 
00110 auto Phidget::detachHandler() -> int
00111 {
00112         printf("detachHandler()");
00113         return 0;
00114 }
00115 
00116 auto Phidget::update() -> void
00117 {
00118         printf("Phidget::update()");
00119 }


cob_phidgets
Author(s): Florian Weisshardt
autogenerated on Sat Jun 8 2019 21:02:14