Update of /cvsroot/libphidget/libphidget/src/examples
In directory sc8-pr-cvs1:/tmp/cvs-serv29738/src/examples
Modified Files:
Makefile.am
Added Files:
query_example.cc
Log Message:
Fixed a lot that was wrong with the query system. Seems to work pretty good now. Wrote an example of how to use the query system.
--- NEW FILE: query_example.cc ---
#include <CPhidgetManager.h>
#include <CInterfaceKit.h>
#include <CDigitalIn.h>
#include <CDigitalOut.h>
#include <CAnalogIn.h>
#include <CTextLCD.h>
#include <unistd.h>
static const char *revision="$Revision: 1.1 $";
main()
{
try
{
char adjusted_version[64];
memcpy(adjusted_version,revision+11,strlen(revision)-11-2);
adjusted_version[strlen(revision)-11-2]=0;
// What we are
printf("query_example: shows how to query for different classes of phidgets and there devices\n");
// Get the version number
printf("Version %s\n",adjusted_version);
{
vector<CUID> list=CPhidgetManager::getInstance()->query(LP_ALL);
// Create as many phidgets as we can, so that they can let us know about there sub devices
for (int t=0;t<list.size();t++)
CUniqueDevice *p=CPhidgetManager::getInstance()->find(list[t],true);
}
printf("Device Totals:\n");
printf(" Devices:%d\n",CPhidgetManager::getInstance()->query(LP_ALL).size());
printf(" Phidgets:%d\n",CPhidgetManager::getInstance()->query(LP_PHIDGET).size());
printf(" Servo Controllers:%d\n",CPhidgetManager::getInstance()->query(LP_SERVO_CONTROLLER).size());
printf(" Interface Kits:%d\n",CPhidgetManager::getInstance()->query(LP_INTERFACE_KIT).size());
printf(" 880 Interface Kits:%d\n",CPhidgetManager::getInstance()->query(LP_INTERFACE_KIT_880).size());
printf(" 488 Interface Kits:%d\n",CPhidgetManager::getInstance()->query(LP_INTERFACE_KIT_488).size());
printf(" Text LCDs:%d\n",CPhidgetManager::getInstance()->query(LP_TEXT_LCD).size());
printf(" Sub devices:%d\n",CPhidgetManager::getInstance()->query(LP_SUB_DEVICE).size());
printf(" Servos:%d\n",CPhidgetManager::getInstance()->query(LP_SERVO).size());
printf(" Digital Inputs:%d\n",CPhidgetManager::getInstance()->query(LP_DIGITAL_IN).size());
printf(" Digital Outputs:%d\n",CPhidgetManager::getInstance()->query(LP_DIGITAL_OUT).size());
printf(" Analog Inputs:%d\n",CPhidgetManager::getInstance()->query(LP_ANALOG_IN).size());
printf(" Analog Outputs:%d\n",CPhidgetManager::getInstance()->query(LP_ANALOG_OUT).size());
printf(" Inputs:%d\n",CPhidgetManager::getInstance()->query(LP_IN).size());
printf(" Outputs:%d\n",CPhidgetManager::getInstance()->query(LP_OUT).size());
printf(" Other:%d\n",CPhidgetManager::getInstance()->query(LP_OTHER).size());
}
catch(const exception &e)
{
printf("exception:%s\n",e.what());
}
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/libphidget/libphidget/src/examples/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Makefile.am 17 Dec 2002 03:10:10 -0000 1.4
--- Makefile.am 18 Dec 2002 02:51:16 -0000 1.5
***************
*** 1,3 ****
! bin_PROGRAMS = phidget_c phidget_cpp servo_example ik_example ik2lcd
phidget_c_SOURCES = phidget_c.c
--- 1,3 ----
! bin_PROGRAMS = phidget_c phidget_cpp servo_example ik_example ik2lcd query_example
phidget_c_SOURCES = phidget_c.c
***************
*** 21,24 ****
--- 21,28 ----
ik2lcd_LDADD = ../libphidget/libphidget.la ../phidget++/libphidget++.la
ik2lcd_DEPENDENCIES = ../libphidget/libphidget.la ../phidget++/libphidget++.la
+
+ query_example_SOURCES = query_example.cc
+ query_example_LDADD = ../libphidget/libphidget.la ../phidget++/libphidget++.la
+ query_example_DEPENDENCIES = ../libphidget/libphidget.la ../phidget++/libphidget++.la
CFLAGS = -I../libphidget -L../libphidget
|