00001 //=========================================================================== 00002 /* 00003 This file is part of the CHAI 3D visualization and haptics libraries. 00004 Copyright (C) 2003-2009 by CHAI 3D. All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License("GPL") version 2 00008 as published by the Free Software Foundation. 00009 00010 For using the CHAI 3D libraries with software that can not be combined 00011 with the GNU GPL, and for taking advantage of the additional benefits 00012 of our support services, please contact CHAI 3D about acquiring a 00013 Professional Edition License. 00014 00015 \author <http://www.chai3d.org> 00016 \author Francois Conti 00017 \version 2.0.0 $Rev: 250 $ 00018 */ 00019 //=========================================================================== 00020 00021 //--------------------------------------------------------------------------- 00022 #ifndef CGenericDeviceH 00023 #define CGenericDeviceH 00024 //--------------------------------------------------------------------------- 00025 #include "extras/CGlobals.h" 00026 #include "devices/CCallback.h" 00027 #include <string> 00028 #include <stdio.h> 00029 //--------------------------------------------------------------------------- 00030 using std::string; 00031 //--------------------------------------------------------------------------- 00032 00033 //=========================================================================== 00041 //=========================================================================== 00042 00043 //--------------------------------------------------------------------------- 00044 // GENERIC DEVICE or BOARD: 00045 //--------------------------------------------------------------------------- 00049 const int CHAI_CMD_GET_DEVICE_STATE = 1010; 00050 00051 //--------------------------------------------------------------------------- 00052 // GENERIC I/O BOARDS: 00053 //--------------------------------------------------------------------------- 00058 00059 const int CHAI_CMD_GET_ENCODER_0 = 1020; 00060 00062 const int CHAI_CMD_GET_ENCODER_1 = 1021; 00063 00065 const int CHAI_CMD_GET_ENCODER_2 = 1022; 00066 00068 const int CHAI_CMD_GET_ENCODER_3 = 1023; 00069 00071 const int CHAI_CMD_GET_ENCODER_4 = 1024; 00072 00074 const int CHAI_CMD_GET_ENCODER_5 = 1025; 00075 00077 const int CHAI_CMD_GET_ENCODER_6 = 1026; 00078 00080 const int CHAI_CMD_GET_ENCODER_7 = 1027; 00081 00082 00087 00088 const int CHAI_CMD_RESET_ENCODER_0 = 1040; 00089 00091 const int CHAI_CMD_RESET_ENCODER_1 = 1041; 00092 00094 const int CHAI_CMD_RESET_ENCODER_2 = 1042; 00095 00097 const int CHAI_CMD_RESET_ENCODER_3 = 1043; 00098 00100 const int CHAI_CMD_RESET_ENCODER_4 = 1044; 00101 00103 const int CHAI_CMD_RESET_ENCODER_5 = 1045; 00104 00106 const int CHAI_CMD_RESET_ENCODER_6 = 1046; 00107 00109 const int CHAI_CMD_RESET_ENCODER_7 = 1047; 00110 00111 00117 00118 const int CHAI_CMD_SET_DAC_0 = 1030; 00119 00121 const int CHAI_CMD_SET_DAC_1 = 1031; 00122 00124 const int CHAI_CMD_SET_DAC_2 = 1032; 00125 00127 const int CHAI_CMD_SET_DAC_3 = 1033; 00128 00130 const int CHAI_CMD_SET_DAC_4 = 1034; 00131 00133 const int CHAI_CMD_SET_DAC_5 = 1035; 00134 00136 const int CHAI_CMD_SET_DAC_6 = 1036; 00137 00139 const int CHAI_CMD_SET_DAC_7 = 1037; 00140 00141 //--------------------------------------------------------------------------- 00142 // GENERIC POINT CONTACT 3/6 DOF HAPTIC DEVICES: 00143 //--------------------------------------------------------------------------- 00144 00149 const int CHAI_CMD_GET_POS_3D = 2000; 00150 00158 const int CHAI_CMD_GET_POS_NORM_3D = 2001; 00159 00164 const int CHAI_CMD_GET_VEL_3D = 2002; 00165 00170 const int CHAI_CMD_SET_FORCE_3D = 2010; 00171 00178 const int CHAI_CMD_SET_FORCE_NORM_3D = 2011; 00179 00184 const int CHAI_CMD_SET_FORCE_TORQUE_3D = 2012; 00185 00190 const int CHAI_CMD_GET_ROT_ANGLES = 2020; 00191 00196 const int CHAI_CMD_GET_ROT_MATRIX = 2021; 00197 00202 const int CHAI_CMD_SET_TORQUE_3D = 2030; 00203 00208 const int CHAI_CMD_GET_SWITCH_0 = 2041; 00209 00214 const int CHAI_CMD_GET_SWITCH_1 = 2042; 00215 00220 const int CHAI_CMD_GET_SWITCH_2 = 2043; 00221 00226 const int CHAI_CMD_GET_SWITCH_MASK = 2044; 00227 00232 const int CHAI_CMD_GET_NORMALIZED_SCALE_FACTOR = 2045; 00233 00234 00235 //=========================================================================== 00240 //=========================================================================== 00241 00243 const int CHAI_MSG_OK = 0; 00244 00246 const int CHAI_MSG_ERROR = -1; 00247 00249 const int CHAI_MSG_NOT_IMPLEMENTED = -2; 00250 00252 const int CHAI_MSG_SYSTEM_NOT_READY = -3; 00253 00254 00255 //=========================================================================== 00269 //=========================================================================== 00270 class cGenericDevice 00271 { 00272 public: 00273 00274 //----------------------------------------------------------------------- 00275 // CONSTRUCTOR & DESTRUCTOR: 00276 //----------------------------------------------------------------------- 00277 00279 cGenericDevice(); 00280 00282 virtual ~cGenericDevice() {}; 00283 00284 00285 //----------------------------------------------------------------------- 00286 // METHODS: 00287 //----------------------------------------------------------------------- 00288 00290 virtual int open() { return -1; } 00291 00293 virtual int close() { return -1; } 00294 00296 virtual int initialize(const bool a_resetEncoders=false) { return -1; } 00297 00299 virtual int command(int a_command, void* a_data) { return (CHAI_MSG_NOT_IMPLEMENTED); } 00300 00302 virtual unsigned int getNumDevices() { return (0); } 00303 00305 bool isSystemAvailable() { return (m_systemAvailable); } 00306 00308 bool isSystemReady() { return (m_systemReady); } 00309 00311 virtual bool setCallback(cCallback* a_callback); 00312 00313 protected: 00315 bool m_systemAvailable; 00316 00318 bool m_systemReady; 00319 00321 cCallback* m_callback; 00322 }; 00323 00324 //--------------------------------------------------------------------------- 00325 #endif 00326 //---------------------------------------------------------------------------