[Libphidget-cvs-commits] CVS: libphidget/src/phidget++ CServoController.cc,1.8,1.9 CServoController.
Status: Alpha
Brought to you by:
jstrohm
From: Jack S. <js...@us...> - 2002-12-21 03:58:14
|
Update of /cvsroot/libphidget/libphidget/src/phidget++ In directory sc8-pr-cvs1:/tmp/cvs-serv23200 Modified Files: CServoController.cc CServoController.h Log Message: Documentation Index: CServoController.cc =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CServoController.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CServoController.cc 17 Dec 2002 21:20:24 -0000 1.8 --- CServoController.cc 21 Dec 2002 03:58:11 -0000 1.9 *************** *** 21,24 **** --- 21,25 ---- { METHOD_GUARD; + // Make sure it was constructed properly if (classType() != LP_SERVO_CONTROLLER) *************** *** 135,210 **** } - /* - void CServoController::setServoCount(int num) - { - if (_servos.size()!=0) - throw runtime_error("Can only call this function one."); - - for (int t=0;t<num;t++) - _servos.push_back(new CServo(this,t)); - } - - CServoController::CServoController(CServoController *orig) : - CPhidget(orig) - { - for (int t=0;t<orig->_servos.size();t++) - _servos.push_back(new CServo(this,t,orig->_servos[t])); - } - - - CServoController::CServoController(phidget *device) : - CPhidget(device) - { - if (classType()!=SERVO_CONTROLLER) - throw runtime_error("Can't initialize a CServoController with a phidget that is not a servo controller"); - - switch(productID()) - { - case 0x0038: - { - setServoCount(4); - break; - } - case 0x0039: - { - setServoCount(1); - break; - } - case 0x003B: - { - setServoCount(8); - break; - } - default: - { - char temp[128]; - sprintf(temp,"Unknown type of servo controller Vendor ID:0x0%x Product ID:0x0%x\n",vendorID(),productID()); - throw runtime_error(temp); - } - } - } - - CServoController::~CServoController() - { - // If we replace a servo then we need to reset it's servo info - if (getReplacement()!=NULL) - { - CServoController *rep=dynamic_cast<CServoController *>(getReplacement()); - - for (int t=0;t<_servos.size();t++) - { - CServo &a=*(rep->_servos[t]); - CServo &b=*(_servos[t]); - - a=b; - } - } - - - for (int t=0;t<_servos.size();t++) - delete _servos[t]; - } - */ - void CServoController::update() { --- 136,139 ---- *************** *** 231,248 **** } ! /* ! const vector <CServo *> &CServoController::servos() const { ! return(_servos); ! } ! CUniqueDevice *CServoController::find(const CUID &uid) ! { ! for (int t=0;t<_servos.size();t++) ! { ! if (_servos[t]->UID()==uid) ! return(_servos[t]); ! } ! return(NULL); } - */ --- 160,169 ---- } ! void CServoController::query(const EDeviceClass tp, set < CUID >&devices) { ! CPhidget::query(tp, devices); ! if (tp == LP_SERVO || tp == LP_ALL || tp == LP_SUB_DEVICE ) ! for (int t = 0; t < _servoCount; t++) ! devices.insert(CUID (UID().serial(), t)); } Index: CServoController.h =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CServoController.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CServoController.h 18 Dec 2002 02:51:17 -0000 1.8 --- CServoController.h 21 Dec 2002 03:58:11 -0000 1.9 *************** *** 27,31 **** int _servoCount; ! pair < bool, CServo *>*_servos; void setServoCount(int num); --- 27,31 ---- int _servoCount; ! pair <bool, CServo *> *_servos; void setServoCount(int num); *************** *** 34,45 **** public: - CServoController (const CUID &uid); /** ! * Constructor to be used when a user derives from this phidget, the user must ! * get a CServoController from the PhidgetManager he wishes to replace and then ! * pass it to this constructor, in the constructor of his derived type. ! */ ! //CServoController(CServoController *orig); /** --- 34,45 ---- public: /** ! * Construct a servo controller and get the device from the phidget manager ! * using the supplied CUID ! */ ! CServoController ( ! const CUID &uid //!< CUID of the servo controller you want to construct ! ); /** *************** *** 57,66 **** * Search for any devices or sub-devices that match this uid */ ! CUniqueDevice *find(const CUID &uid, bool create); /** * returns a previously created servo */ ! CServo *servo(int id, bool create = true); /** --- 57,72 ---- * Search for any devices or sub-devices that match this uid */ ! CUniqueDevice *find( ! const CUID &uid, //!< UID of the object you want to find ! bool create //!< if this is true then it will try to create if it can find something that can create it. ! ); /** * returns a previously created servo */ ! CServo *servo( ! int id, //!< The ID of the servo we want ! bool create = true //!< By default it will create a servo you request if it can't find an already created one. ! ); /** *************** *** 73,86 **** /** ! * Query for devices or sub-devices that match a certain class */ ! virtual void query(const EDeviceClass tp, set < CUID >&devices) ! { ! CPhidget::query(tp, devices); ! ! if (tp == LP_SERVO || tp == LP_ALL || tp == LP_SUB_DEVICE ) ! for (int t = 0; t < _servoCount; t++) ! devices.insert(CUID (UID().serial(), t)); ! } }; --- 79,88 ---- /** ! * Query for a device that matches the libphidget device class passed in. */ ! virtual void query( ! const EDeviceClass tp, //!< The device class we are looking for ! set < CUID >&devices //!< This will be filled with UID's of phidgets (or sub-objects) that match the device class ! ); }; |