[Libphidget-cvs-commits] CVS: libphidget/src/phidget++ CPhidgetManager.cc,1.15,1.16 CPhidgetManager.
Status: Alpha
Brought to you by:
jstrohm
|
From: Jack S. <js...@us...> - 2002-12-23 04:38:44
|
Update of /cvsroot/libphidget/libphidget/src/phidget++
In directory sc8-pr-cvs1:/tmp/cvs-serv25634/phidget++
Modified Files:
CPhidgetManager.cc CPhidgetManager.h CServoController.cc
Log Message:
Lot's of changes with how servo controller classes work. Now added seperate classes for servo controllers (uni and quad).
Index: CPhidgetManager.cc
===================================================================
RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CPhidgetManager.cc,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** CPhidgetManager.cc 21 Dec 2002 03:31:39 -0000 1.15
--- CPhidgetManager.cc 23 Dec 2002 04:38:40 -0000 1.16
***************
*** 83,86 ****
--- 83,87 ----
devices.insert(temp_uid);
+
// If the device class is a phidget or ALL then we have found it.
if (tp==LP_PHIDGET || tp==LP_ALL)
***************
*** 88,96 ****
// handle some special cases
! if (tp==LP_INTERFACE_KIT && dc==LP_INTERFACE_KIT_880)
! devices.insert(temp_uid);
!
! if (tp==LP_INTERFACE_KIT && dc==LP_INTERFACE_KIT_488)
! devices.insert(temp_uid);
}
--- 89,96 ----
// handle some special cases
! if (tp==LP_INTERFACE_KIT && dc==LP_INTERFACE_KIT_880) devices.insert(temp_uid);
! if (tp==LP_INTERFACE_KIT && dc==LP_INTERFACE_KIT_488) devices.insert(temp_uid);
! if (tp==LP_SERVO_CONTROLLER && dc==LP_UNI_SERVO) devices.insert(temp_uid);
! if (tp==LP_SERVO_CONTROLLER && dc==LP_QUAD_SERVO) devices.insert(temp_uid);
}
***************
*** 222,226 ****
switch (deviceClass)
{
! case LP_SERVO_CONTROLLER:
{
CServoController *sc = new CServoController (uid);
--- 222,228 ----
switch (deviceClass)
{
! case LP_UNI_SERVO:
! case LP_QUAD_SERVO:
! //case LP_8WAY_SERVO:
{
CServoController *sc = new CServoController (uid);
Index: CPhidgetManager.h
===================================================================
RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CPhidgetManager.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** CPhidgetManager.h 21 Dec 2002 03:31:39 -0000 1.8
--- CPhidgetManager.h 23 Dec 2002 04:38:40 -0000 1.9
***************
*** 20,33 ****
* </p>
*
! * Okay , the problem is I want to be able to query for the devices currently attached
* which is fine for just phidgets. But if we haven't created a phidget to manage this
! * device we don't know anything about this device.
*
! * So, for example, we can attach a phidget servo controller with 4 servos to a computer.
* Intial query for phidgets reveals 1, whle a query for servos reveals 0.
* Now if we ask for or create or own servo controller object, then when we query for
! * number of servos we get 4. This is just the way it will be.
*
*
*/
--- 20,52 ----
* </p>
*
! * <p>Okay , the problem is I want to be able to query for the devices currently attached
* which is fine for just phidgets. But if we haven't created a phidget to manage this
! * device we don't know anything about this device.</p>
*
! * <p>So, for example, we can attach a phidget servo controller with 4 servos to a computer.
* Intial query for phidgets reveals 1, whle a query for servos reveals 0.
* Now if we ask for or create or own servo controller object, then when we query for
! * number of servos we get 4. This is just the way it will be.</p>
*
+ * <p>These are the main phidget classes available:</p>
*
+ * <ul>
+ * <li> CServoController </li>
+ * <ul>
+ * <li> CServo </li>
+ * </ul>
+ * <li> CInterfaceKit </li>
+ * <ul>
+ * <li> CDigitalIn </li>
+ * <li> CDigitalOut </li>
+ * <li> CAnalogIn </li>
+ * </ul>
+ * <li> CTextLCD </li>
+ * </ul>
+ *
+ * <p>Hopefully I can document some of the examples soon that will better explain how
+ * this library works. After the documentation the code in the example directory are
+ * a good starting point. I tried to keep them simple. You can also contact me and I'd
+ * be happy to help you out.</p>
*/
Index: CServoController.cc
===================================================================
RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CServoController.cc,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** CServoController.cc 21 Dec 2002 03:58:11 -0000 1.9
--- CServoController.cc 23 Dec 2002 04:38:40 -0000 1.10
***************
*** 23,26 ****
--- 23,47 ----
// Make sure it was constructed properly
+ switch (classType())
+ {
+ case LP_UNI_SERVO:
+ {
+ setServoCount(1);
+ break;
+ }
+ case LP_QUAD_SERVO:
+ {
+ setServoCount(4);
+ break;
+ }
+ //case LP_8WAY_SERVO:
+ //{
+ //setServoCount(8);
+ //break;
+ //}
+ default:
+ throw runtime_error("Can't initialize a CServoController with a phidget that is not a servo controller");
+ }
+ /*
if (classType() != LP_SERVO_CONTROLLER)
throw runtime_error("Can't initialize a CServoController with a phidget that is not a servo controller");
***************
*** 51,54 ****
--- 72,77 ----
}
}
+ */
+
METHOD_UNGUARD;
}
***************
*** 139,143 ****
{
METHOD_GUARD;
! if (_servoCount)
{
float p1 = 0, p2 = 0, p3 = 0, p4 = 0;
--- 162,176 ----
{
METHOD_GUARD;
! if (_servoCount==1)
! {
! float p1 = 0;
!
! if (_servoCount >= 1 && _servos[0].second != NULL)
! p1 = _servos[0].second->position();
!
! error(phidgetSingleServo(device(), p1));
! }
! else
! if (_servoCount==4)
{
float p1 = 0, p2 = 0, p3 = 0, p4 = 0;
|