ik.cpp
Go to the documentation of this file.
1 #include "phidgets_api/ik.h"
2 
3 namespace phidgets {
4 
5 IK::IK() : Phidget(), ik_handle_(nullptr)
6 {
7  // create the handle
8  CPhidgetInterfaceKit_create(&ik_handle_);
9 
10  // pass handle to base class
11  Phidget::init((CPhidgetHandle)ik_handle_);
12 
13  // register base class callbacks
15 
16  // register ik data callback
17  CPhidgetInterfaceKit_set_OnSensorChange_Handler(ik_handle_, SensorHandler,
18  this);
19  CPhidgetInterfaceKit_set_OnInputChange_Handler(ik_handle_, InputHandler,
20  this);
21 }
22 
24 {
25 }
26 
27 int IK::getInputCount() const
28 {
29  int n_in;
30  CPhidgetInterfaceKit_getInputCount(ik_handle_, &n_in);
31  return n_in;
32 }
33 
34 int IK::getOutputCount() const
35 {
36  int n_out;
37  CPhidgetInterfaceKit_getOutputCount(ik_handle_, &n_out);
38  return n_out;
39 }
40 
41 int IK::getSensorCount() const
42 {
43  int n_sensors;
44  CPhidgetInterfaceKit_getSensorCount(ik_handle_, &n_sensors);
45  return n_sensors;
46 }
47 
48 int IK::getSensorRawValue(int index) const
49 {
50  int rawval;
51  CPhidgetInterfaceKit_getSensorRawValue(ik_handle_, index, &rawval);
52  return rawval;
53 }
54 
55 bool IK::setOutputState(int index, bool state) const
56 {
57  return !CPhidgetInterfaceKit_setOutputState(ik_handle_, index, state);
58 }
59 
60 int IK::SensorHandler(CPhidgetInterfaceKitHandle /* ik */, void *userptr,
61  int index, int sensorValue)
62 {
63  ((IK *)userptr)->sensorHandler(index, sensorValue);
64  return 0;
65 }
66 
67 void IK::sensorHandler(int /* index */, int /* sensorValue */)
68 {
69  // This method can be overridden in a concrete subclass (e.g., ROS wrapper)
70 }
71 
72 int IK::InputHandler(CPhidgetInterfaceKitHandle /* ik */, void *userptr,
73  int index, int inputValue)
74 {
75  ((IK *)userptr)->inputHandler(index, inputValue);
76  return 0;
77 }
78 
79 void IK::inputHandler(int /* index */, int /* inputValue */)
80 {
81  // This method can be overridden in a concrete subclass (e.g., ROS wrapper)
82 }
83 
84 } // namespace phidgets
int getSensorCount() const
Definition: ik.cpp:41
void registerHandlers()
Definition: phidget.cpp:17
virtual ~IK()
Definition: ik.cpp:23
bool setOutputState(int index, bool state) const
Definition: ik.cpp:55
static int SensorHandler(CPhidgetInterfaceKitHandle ik, void *userptr, int index, int sensorValue)
Definition: ik.cpp:60
CPhidgetInterfaceKitHandle ik_handle_
Definition: ik.h:26
int getOutputCount() const
Definition: ik.cpp:34
Definition: ik.h:8
IK()
Definition: ik.cpp:5
virtual void inputHandler(int index, int inputValue)
Definition: ik.cpp:79
static int InputHandler(CPhidgetInterfaceKitHandle ik, void *userptr, int index, int inputValue)
Definition: ik.cpp:72
int getInputCount() const
Definition: ik.cpp:27
void init(CPhidgetHandle handle)
Definition: phidget.cpp:24
int getSensorRawValue(int index) const
Definition: ik.cpp:48
virtual void sensorHandler(int index, int sensorValue)
Definition: ik.cpp:67


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