libphidget-cvs-commits Mailing List for Phidget Library (Page 6)
Status: Alpha
Brought to you by:
jstrohm
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(66) |
Oct
|
Nov
|
Dec
(73) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(9) |
Jul
(5) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
From: Vadim T. <vt...@us...> - 2002-09-10 03:27:48
|
Update of /cvsroot/libphidget/libphidget In directory usw-pr-cvs1:/tmp/cvs-serv1109 Modified Files: Tag: INDENT indent.rules indent.defs Log Message: Modified the rules; works now? Index: indent.rules =================================================================== RCS file: /cvsroot/libphidget/libphidget/indent.rules,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** indent.rules 8 Sep 2002 04:24:31 -0000 1.1 --- indent.rules 10 Sep 2002 03:27:46 -0000 1.1.2.1 *************** *** 1 **** --- 1,5 ---- --gnu-style + --dont-format-comments + --blank-lines-after-block-comments + --honour-newlines + --line-length128 Index: indent.defs =================================================================== RCS file: /cvsroot/libphidget/libphidget/Attic/indent.defs,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** indent.defs 10 Sep 2002 03:01:33 -0000 1.1.2.1 --- indent.defs 10 Sep 2002 03:27:46 -0000 1.1.2.2 *************** *** 17,18 **** --- 17,25 ---- -TCAnalogIn -TCAnalogOut + -TT + -Tclass + -Ttemplate + -Tconst + -T<T> + -T<CUID> + -Tvector |
From: Vadim T. <vt...@us...> - 2002-09-10 03:01:36
|
Update of /cvsroot/libphidget/libphidget In directory usw-pr-cvs1:/tmp/cvs-serv28014 Modified Files: Tag: INDENT Makefile.am Added Files: Tag: INDENT indent.defs Log Message: Attempt to fix the indent stuff by adding the typedef rules --- NEW FILE: indent.defs --- -Tusb_dev_handle -Tusb_device -Tphidget -Tphidget_type -TEDeviceClass -TELPError -TCUniqueDevice -TCUID -TCServo -TCPhidgetManager -TCInterfaceKit -TCDigitalIn -TCDigitalOut -TTSingleton -TCServoController -TCPhidget -TCAnalogIn -TCAnalogOut Index: Makefile.am =================================================================== RCS file: /cvsroot/libphidget/libphidget/Makefile.am,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** Makefile.am 9 Sep 2002 22:57:32 -0000 1.6 --- Makefile.am 10 Sep 2002 03:01:33 -0000 1.6.2.1 *************** *** 16,20 **** @ for FILE in `@FIND@ . -name "*.h" -o -name "*.c" -o -name "*.cc"` ; do \ ! @INDENT@ --ignore-profile --standard-output `@CAT@ ./indent.rules` $$FILE > $$FILE.indent; \ if @TEST@ -n "`@DIFF@ $$FILE $$FILE.indent`" ; then \ @MV@ $$FILE.indent $$FILE; \ --- 16,20 ---- @ for FILE in `@FIND@ . -name "*.h" -o -name "*.c" -o -name "*.cc"` ; do \ ! @INDENT@ --ignore-profile --standard-output `@CAT@ ./indent.rules` `@CAT@ ./indent.defs` $$FILE > $$FILE.indent; \ if @TEST@ -n "`@DIFF@ $$FILE $$FILE.indent`" ; then \ @MV@ $$FILE.indent $$FILE; \ *************** *** 32,36 **** @ for FILE in `@FIND@ . -name "*.h" -o -name "*.c" -o -name "*.cc"` ; do \ ! @INDENT@ --standard-output $$FILE > $$FILE.indent; \ if @TEST@ -n "`@DIFF@ $$FILE $$FILE.indent`" ; then \ @MV@ $$FILE.indent $$FILE; \ --- 32,36 ---- @ for FILE in `@FIND@ . -name "*.h" -o -name "*.c" -o -name "*.cc"` ; do \ ! @INDENT@ --standard-output `@CAT@ ./indent.defs` $$FILE > $$FILE.indent; \ if @TEST@ -n "`@DIFF@ $$FILE $$FILE.indent`" ; then \ @MV@ $$FILE.indent $$FILE; \ |
From: Vadim T. <vt...@us...> - 2002-09-09 22:57:45
|
Update of /cvsroot/libphidget/libphidget In directory usw-pr-cvs1:/tmp/cvs-serv6578 Modified Files: Makefile.am configure.in Log Message: - Package name adjusted: now it is 'libphidget' - RPM build added. In order to build the source and binary RPM, just become root and execute 'make rpm'. Index: Makefile.am =================================================================== RCS file: /cvsroot/libphidget/libphidget/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.am 9 Sep 2002 09:40:42 -0000 1.5 --- Makefile.am 9 Sep 2002 22:57:32 -0000 1.6 *************** *** 39,40 **** --- 39,57 ---- fi; \ done + + rpm: dist + + @ if @TEST@ -z "@RPM@" ; then \ + @ECHO@ "RPM binary not found, can't build RPM package"; \ + exit 1; \ + fi + + # VT: FIXME: It may be a good idea to check other dependencies + # required for a *complete* RPM build, such as Doxygen, and refuse + # to build the RPM, unless something like --enable-lazy-deps is + # provided + + cd src/rpm && ${MAKE} @PACKAGE@.spec + @LN_S@ -f `pwd`/src/rpm/@PACKAGE@.spec /usr/src/redhat/SPECS/@PACKAGE@.spec + @LN_S@ -f `pwd`/@PACKAGE@-@VERSION@.tar.gz /usr/src/redhat/SOURCES/@PACKAGE@-@VERSION@.tar.gz + cd /usr/src/redhat/SPECS && @RPM@ -ba @PACKAGE@.spec Index: configure.in =================================================================== RCS file: /cvsroot/libphidget/libphidget/configure.in,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** configure.in 9 Sep 2002 09:40:43 -0000 1.5 --- configure.in 9 Sep 2002 22:57:32 -0000 1.6 *************** *** 6,10 **** dnl of options, as well as the local set. ! GLOBAL_OPTIONS=/usr/local/share/phidget/configure-options if test -f "${GLOBAL_OPTIONS}" && test -z "${GLOBAL_OPTIONS_PRESENT}" ; then --- 6,10 ---- dnl of options, as well as the local set. ! GLOBAL_OPTIONS=/usr/local/share/libphidget/configure-options if test -f "${GLOBAL_OPTIONS}" && test -z "${GLOBAL_OPTIONS_PRESENT}" ; then *************** *** 36,40 **** AC_SUBST(PATCHLEVEL)dnl ! PACKAGE="phidget" VERSION="${VERSION_MAJOR}.${VERSION_MINOR}p${PATCHLEVEL}" --- 36,40 ---- AC_SUBST(PATCHLEVEL)dnl ! PACKAGE="libphidget" VERSION="${VERSION_MAJOR}.${VERSION_MINOR}p${PATCHLEVEL}" *************** *** 44,48 **** AC_MSG_RESULT(Configuring ${PACKAGE}-${VERSION}) ! AC_PREFIX_DEFAULT(/opt/phidget)dnl AC_PREREQ(2.13)dnl AC_CONFIG_AUX_DIR(src/scripts/install)dnl --- 44,48 ---- AC_MSG_RESULT(Configuring ${PACKAGE}-${VERSION}) ! AC_PREFIX_DEFAULT(/opt/libphidget)dnl AC_PREREQ(2.13)dnl AC_CONFIG_AUX_DIR(src/scripts/install)dnl *************** *** 90,93 **** --- 90,95 ---- src/phidget++/Makefile src/examples/Makefile + src/rpm/Makefile + src/rpm/libphidget.spec )dnl |
From: Vadim T. <vt...@us...> - 2002-09-09 22:57:44
|
Update of /cvsroot/libphidget/libphidget/src/rpm In directory usw-pr-cvs1:/tmp/cvs-serv6578/src/rpm Added Files: .cvsignore Makefile.am libphidget.spec.in Log Message: - Package name adjusted: now it is 'libphidget' - RPM build added. In order to build the source and binary RPM, just become root and execute 'make rpm'. --- NEW FILE: .cvsignore --- Makefile Makefile.in libphidget.spec --- NEW FILE: Makefile.am --- noinst_DATA = libphidget.spec EXTRA_DIST = ${noinst_DATA} clean-generic: @RM@ -f *~ .*~ libphidget.spec --- NEW FILE: libphidget.spec.in --- Summary: Phidget Library Name: libphidget Version: @VERSION@ Release: 1 Source0: @PACKAGE@-@VERSION@.tar.gz License: LGPL Group: Development/Tools BuildRoot: %{_builddir}/%{name}-root %description Phidget Library provides C/C++ library to operate the Phidget family of devices (http://www.phidgets.com/). %prep %setup -q %build ./configure make %install rm -rf $RPM_BUILD_ROOT make DESTDIR=$RPM_BUILD_ROOT install %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) /opt/libphidget/lib/libphidget.so.0.0.0 /opt/libphidget/lib/libphidget.la /opt/libphidget/lib/libphidget.a /opt/libphidget/lib/libphidget++.so.0.0.0 /opt/libphidget/lib/libphidget++.la /opt/libphidget/lib/libphidget++.a /opt/libphidget/lib/libphidget.so.0 /opt/libphidget/lib/libphidget.so /opt/libphidget/lib/libphidget++.so.0 /opt/libphidget/lib/libphidget++.so /opt/libphidget/bin/phidget_c /opt/libphidget/bin/phidget_cpp %doc COPYING AUTHORS README NEWS |
From: Vadim T. <vt...@us...> - 2002-09-09 22:57:44
|
Update of /cvsroot/libphidget/libphidget/src In directory usw-pr-cvs1:/tmp/cvs-serv6578/src Modified Files: Makefile.am Log Message: - Package name adjusted: now it is 'libphidget' - RPM build added. In order to build the source and binary RPM, just become root and execute 'make rpm'. Index: Makefile.am =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile.am 7 Sep 2002 21:56:54 -0000 1.3 --- Makefile.am 9 Sep 2002 22:57:32 -0000 1.4 *************** *** 1 **** ! SUBDIRS = libphidget phidget++ examples --- 1 ---- ! SUBDIRS = libphidget phidget++ examples rpm |
From: Vadim T. <vt...@us...> - 2002-09-09 22:54:55
|
Update of /cvsroot/libphidget/libphidget/src/rpm In directory usw-pr-cvs1:/tmp/cvs-serv5323/src/rpm Log Message: Directory /cvsroot/libphidget/libphidget/src/rpm added to the repository |
From: Vadim T. <vt...@us...> - 2002-09-09 09:40:46
|
Update of /cvsroot/libphidget/libphidget In directory usw-pr-cvs1:/tmp/cvs-serv16807 Modified Files: Makefile.am configure.in Log Message: - Fixed yet another 'make dist' dependency - 'make indent' is smarter now, the files that haven't changed don't change the timestamp now, though there's a problem with a few of them - indent flips the syntax back and forth on every run... Index: Makefile.am =================================================================== RCS file: /cvsroot/libphidget/libphidget/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.am 8 Sep 2002 04:29:44 -0000 1.4 --- Makefile.am 9 Sep 2002 09:40:42 -0000 1.5 *************** *** 2,6 **** SUBDIRS = src ! EXTRA_DIST = bootstrap src/scripts/install/* clean-generic: --- 2,6 ---- SUBDIRS = src ! EXTRA_DIST = bootstrap indent.rules src/scripts/install/* clean-generic: *************** *** 10,20 **** indent: @ for FILE in `@FIND@ . -name "*.h" -o -name "*.c" -o -name "*.cc"` ; do \ ! @INDENT@ --ignore-profile `@CAT@ ./indent.rules` $$FILE ; \ ! done indent-local: @ for FILE in `@FIND@ . -name "*.h" -o -name "*.c" -o -name "*.cc"` ; do \ ! @INDENT@ $$FILE ; \ ! done --- 10,40 ---- indent: + @ if @TEST@ -z "@INDENT@" ; then \ + @ECHO@ "indent was not found, install and rerun ./configure"; \ + @RM@ -f config.cache; \ + fi + @ for FILE in `@FIND@ . -name "*.h" -o -name "*.c" -o -name "*.cc"` ; do \ ! @INDENT@ --ignore-profile --standard-output `@CAT@ ./indent.rules` $$FILE > $$FILE.indent; \ ! if @TEST@ -n "`@DIFF@ $$FILE $$FILE.indent`" ; then \ ! @MV@ $$FILE.indent $$FILE; \ ! else \ ! @RM@ $$FILE.indent; \ ! fi; \ ! done indent-local: + @ if @TEST@ -z "@INDENT@" ; then \ + @ECHO@ "indent was not found, install and rerun ./configure"; \ + @RM@ -f config.cache; \ + fi + @ for FILE in `@FIND@ . -name "*.h" -o -name "*.c" -o -name "*.cc"` ; do \ ! @INDENT@ --standard-output $$FILE > $$FILE.indent; \ ! if @TEST@ -n "`@DIFF@ $$FILE $$FILE.indent`" ; then \ ! @MV@ $$FILE.indent $$FILE; \ ! else \ ! @RM@ $$FILE.indent; \ ! fi; \ ! done Index: configure.in =================================================================== RCS file: /cvsroot/libphidget/libphidget/configure.in,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** configure.in 8 Sep 2002 04:24:31 -0000 1.4 --- configure.in 9 Sep 2002 09:40:43 -0000 1.5 *************** *** 55,58 **** --- 55,60 ---- AC_PROG_FIND AC_PATH_PROG_VERIFY(CAT,cat,$PATH)dnl + AC_PATH_PROG_VERIFY(DIFF,diff,$PATH)dnl + AC_PATH_PROG_VERIFY(MV,mv,$PATH)dnl AC_PATH_PROG_VERIFY(RM,rm,$PATH)dnl dnl AC_PATH_PROG_VERIFY(DIRNAME,dirname,$PATH)dnl |
From: Vadim T. <vt...@us...> - 2002-09-09 08:48:40
|
Update of /cvsroot/libphidget/libphidget/src/libphidget In directory usw-pr-cvs1:/tmp/cvs-serv29626/src/libphidget Modified Files: Makefile.am Log Message: Fixed the bugs that prevented the result of 'make dist' from working properly. Index: Makefile.am =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/libphidget/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.am 7 Sep 2002 20:12:30 -0000 1.2 --- Makefile.am 9 Sep 2002 08:48:33 -0000 1.3 *************** *** 4,7 **** --- 4,9 ---- phidget.c + EXTRA_DIST = Doxyfile + clean-generic: |
From: Vadim T. <vt...@us...> - 2002-09-09 08:48:40
|
Update of /cvsroot/libphidget/libphidget/src/phidget++ In directory usw-pr-cvs1:/tmp/cvs-serv29626/src/phidget++ Modified Files: Makefile.am Log Message: Fixed the bugs that prevented the result of 'make dist' from working properly. Index: Makefile.am =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile.am 7 Sep 2002 21:56:54 -0000 1.3 --- Makefile.am 9 Sep 2002 08:48:33 -0000 1.4 *************** *** 2,5 **** --- 2,6 ---- libphidget___la_SOURCES = CPhidget.h \ + CInterfaceKit.h \ CPhidgetManager.h \ CServo.h \ *************** *** 20,24 **** # CDigitalIn.h # CDigitalOut.h - # CInterfaceKit.h # lsphidget.cc # CAnalogIn.cc --- 21,24 ---- *************** *** 32,35 **** --- 32,37 ---- CXXFLAGS = -I../libphidget -L../libphidget + + EXTRA_DIST = Doxyfile clean-generic: |
Update of /cvsroot/libphidget/libphidget/src/phidget++ In directory usw-pr-cvs1:/tmp/cvs-serv3113/src/phidget++ Modified Files: CAnalogIn.cc CAnalogIn.h CDigitalIn.cc CDigitalIn.h CDigitalOut.cc CDigitalOut.h CInterfaceKit.cc CInterfaceKit.h CPhidget.cc CPhidget.h CPhidgetManager.cc CPhidgetManager.h CServo.cc CServo.h CServoController.cc CServoController.h CUID.cc CUID.h CUniqueDevice.cc CUniqueDevice.h TSingleton.h lsphidget.cc Log Message: Performed 'make indent' on the code - now it conforms to GNU coding style standard. In the future, don't forget to 'make indent' on the top level before doing 'cvs commit'. Otherwise, unwanted, irrelevant, and MASSIVE diffs will result. Index: CAnalogIn.cc =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CAnalogIn.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CAnalogIn.cc 7 Sep 2002 20:12:30 -0000 1.2 --- CAnalogIn.cc 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 11,20 **** #include "CInterfaceKit.h" ! CAnalogIn::CAnalogIn(CInterfaceKit *interfacekit, int id) : ! CUniqueDevice(interfacekit,id), ! _interfaceKit(interfacekit), ! _value(0), ! _lastValue(0) { } - --- 11,17 ---- #include "CInterfaceKit.h" ! CAnalogIn::CAnalogIn (CInterfaceKit * interfacekit, int id): ! CUniqueDevice (interfacekit, id), ! _interfaceKit (interfacekit), _value (0), _lastValue (0) { } Index: CAnalogIn.h =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CAnalogIn.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CAnalogIn.h 7 Sep 2002 20:12:30 -0000 1.2 --- CAnalogIn.h 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 22,60 **** * is when the CPhidgetManager function is called. */ ! class CAnalogIn : CUniqueDevice { ! private: ! friend class CInterfaceKit; ! CInterfaceKit *_interfaceKit; ! // This is the only real data for the servo ! float _value; ! float _lastValue; ! - CAnalogIn(CInterfaceKit *interfacekit,int id); ! public: /** * Empty virtual constructor */ ! virtual ~CAnalogIn() {} ! /** * Return the current value of the analog input, this * value is only updates when CPhidgetManager->checkForEvents() * is called. ! */ ! float value() const ! { ! return(_value); ! } ! /** * No devices are contained in this device ! */ ! CAnalogIn *find(const CUID &uid) {return(NULL);} }; --- 22,61 ---- * is when the CPhidgetManager function is called. */ ! class CAnalogIn:CUniqueDevice { ! private: ! friend class CInterfaceKit; ! CInterfaceKit *_interfaceKit; ! // This is the only real data for the servo ! float _value; ! float _lastValue; ! CAnalogIn (CInterfaceKit * interfacekit, int id); ! ! public: /** * Empty virtual constructor */ ! virtual ~ CAnalogIn () ! { ! } /** * Return the current value of the analog input, this * value is only updates when CPhidgetManager->checkForEvents() * is called. ! */ float value () const ! { ! return (_value); ! } /** * No devices are contained in this device ! */ CAnalogIn *find (const CUID & uid) ! { ! return (NULL); ! } }; Index: CDigitalIn.cc =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CDigitalIn.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CDigitalIn.cc 7 Sep 2002 20:12:30 -0000 1.2 --- CDigitalIn.cc 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 11,19 **** #include "CInterfaceKit.h" ! CDigitalIn::CDigitalIn(CInterfaceKit *interfacekit, int id) : ! CUniqueDevice(interfacekit,id), ! _value(false), ! _lastValue(false) { } - --- 11,16 ---- #include "CInterfaceKit.h" ! CDigitalIn::CDigitalIn (CInterfaceKit * interfacekit, int id): ! CUniqueDevice (interfacekit, id), _value (false), _lastValue (false) { } Index: CDigitalIn.h =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CDigitalIn.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CDigitalIn.h 7 Sep 2002 20:12:30 -0000 1.2 --- CDigitalIn.h 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 22,57 **** * is when the CPhidgetManager function is called. */ ! class CDigitalIn : public CUniqueDevice { ! private: ! friend class CInterfaceKit; ! // This is the only real data for the servo ! bool _value; ! bool _lastValue; ! - CDigitalIn(CInterfaceKit *interfacekit,int id); ! public: /** * Standard virtual destructor */ ! virtual ~CDigitalIn() {} ! /** * Return the current value of the digital input, this * value is only updates when CPhidgetManager->checkForEvents() * is called. ! */ ! bool value() const ! { ! return(_value); ! } ! /** * No devices are contained in this device ! */ ! CDigitalIn *find(const CUID &uid) {return(NULL);} }; --- 22,58 ---- * is when the CPhidgetManager function is called. */ ! class CDigitalIn:public CUniqueDevice { ! private: ! friend class CInterfaceKit; ! // This is the only real data for the servo ! bool _value; ! bool _lastValue; ! CDigitalIn (CInterfaceKit * interfacekit, int id); ! ! public: /** * Standard virtual destructor */ ! virtual ~ CDigitalIn () ! { ! } /** * Return the current value of the digital input, this * value is only updates when CPhidgetManager->checkForEvents() * is called. ! */ bool value () const ! { ! return (_value); ! } /** * No devices are contained in this device ! */ CDigitalIn *find (const CUID & uid) ! { ! return (NULL); ! } }; Index: CDigitalOut.cc =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CDigitalOut.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CDigitalOut.cc 7 Sep 2002 20:12:30 -0000 1.2 --- CDigitalOut.cc 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 11,31 **** #include "CInterfaceKit.h" ! CDigitalOut::CDigitalOut(CInterfaceKit *interfacekit, int id) : ! CUniqueDevice(interfacekit,id), ! _value(false) { } ! void CDigitalOut::value(bool val) { ! _value=val; ! // Tell the interface kit our value has changed, so it ! // sends it to the servo immediately ! CUniqueDevice *temp1=parent(); ! ! CInterfaceKit *temp2=dynamic_cast<CInterfaceKit *>(temp1); ! ! temp2->update(); ! } --- 11,30 ---- #include "CInterfaceKit.h" ! CDigitalOut::CDigitalOut (CInterfaceKit * interfacekit, int id): ! CUniqueDevice (interfacekit, id), _value (false) { } ! void ! CDigitalOut::value (bool val) { ! _value = val; ! // Tell the interface kit our value has changed, so it ! // sends it to the servo immediately ! CUniqueDevice *temp1 = parent (); ! ! CInterfaceKit *temp2 = dynamic_cast < CInterfaceKit * >(temp1); + temp2->update (); + } Index: CDigitalOut.h =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CDigitalOut.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CDigitalOut.h 7 Sep 2002 20:12:30 -0000 1.2 --- CDigitalOut.h 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 22,53 **** * phidget as soon as the function is called. */ ! class CDigitalOut : CUniqueDevice { ! private: ! friend class CInterfaceKit; ! CInterfaceKit *_interfaceKit; ! // This is the only real data for the servo ! bool _value; ! - CDigitalOut(CInterfaceKit *interfacekit,int id); ! public: /** * Standard empty virtual destructor */ ! virtual ~CDigitalOut() {} ! /** * Sends a value to the interface kit ! */ ! void value(bool val); /** * No devices are contained in this device */ ! CDigitalOut *find(const CUID &uid) {return(NULL);} }; --- 22,56 ---- * phidget as soon as the function is called. */ ! class CDigitalOut:CUniqueDevice { ! private: ! friend class CInterfaceKit; ! CInterfaceKit *_interfaceKit; ! // This is the only real data for the servo ! bool _value; ! CDigitalOut (CInterfaceKit * interfacekit, int id); ! ! public: /** * Standard empty virtual destructor */ ! virtual ~ CDigitalOut () ! { ! } /** * Sends a value to the interface kit ! */ void value (bool val); /** * No devices are contained in this device */ ! CDigitalOut *find (const CUID & uid) ! { ! return (NULL); ! } }; Index: CInterfaceKit.cc =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CInterfaceKit.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CInterfaceKit.cc 7 Sep 2002 20:12:30 -0000 1.2 --- CInterfaceKit.cc 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 16,115 **** #include <phidget.h> ! CInterfaceKit::CInterfaceKit(phidget *device) : ! CPhidget(device) { ! if (classType()!=INTERFACE_KIT) ! throw runtime_error("Can't initialize a CInterfaceKit with a phidget that is not an interface kit"); ! switch(productID()) ! { ! default: ! { ! char temp[128]; ! sprintf(temp,"Unknown type of interface kit Vendor ID:0x0%x Product ID:0x0%x\n",vendorID(),productID()); ! throw runtime_error(temp); ! } ! } } ! void CInterfaceKit::setDigitalInCount(int num) { ! if (_digitalIns.size()!=0) throw runtime_error("You can only call this function once"); ! for (int t=0;t<num;t++) _digitalIns.push_back(new CDigitalIn(this,t)); } ! void CInterfaceKit::setDigitalOutCount(int num) { ! if (_digitalOuts.size()!=0) throw runtime_error("You can only call this function once"); ! for (int t=0;t<num;t++) _digitalOuts.push_back(new CDigitalOut(this,t)); } ! void CInterfaceKit::setAnalogInCount(int num) { ! if (_analogIns.size()!=0) throw runtime_error("You can only call this function once"); ! for (int t=0;t<num;t++) _analogIns.push_back(new CAnalogIn(this,t)); } ! CInterfaceKit::CInterfaceKit(CInterfaceKit *orig) : ! CPhidget(orig) { ! for (int t=0;t<orig->_digitalIns.size();t++) _digitalIns.push_back(new CDigitalIn(this,t)); ! for (int t=0;t<orig->_digitalOuts.size();t++) _digitalOuts.push_back(new CDigitalOut(this,t)); ! for (int t=0;t<orig->_analogIns.size();t++) _analogIns.push_back(new CAnalogIn(this,t)); } ! CInterfaceKit::~CInterfaceKit() { ! for (int t=0;t<_digitalIns.size();t++) delete _digitalIns[t]; ! for (int t=0;t<_digitalOuts.size();t++) delete _digitalOuts[t]; ! for (int t=0;t<_analogIns.size();t++) delete _analogIns[t]; } ! void CInterfaceKit::update() { ! // Do nothing, we can't test this yet } ! const vector <CDigitalIn *> &CInterfaceKit::digitalIns() const { ! return(_digitalIns); } ! const vector <CDigitalOut *> &CInterfaceKit::digitalOuts() const { ! return(_digitalOuts); } ! const vector <CAnalogIn *> &CInterfaceKit::analogIns() const { ! return(_analogIns); } ! CUniqueDevice *CInterfaceKit::find(const CUID &uid) { ! CUniqueDevice *temp; ! for (int t=0;t<_digitalIns.size();t++) ! { ! temp=_digitalIns[t]->find(uid); ! if (temp!=NULL) ! return(temp); ! } ! for (int t=0;t<_digitalOuts.size();t++) ! { ! temp=_digitalOuts[t]->find(uid); ! if (temp!=NULL) ! return(temp); ! } ! for (int t=0;t<_analogIns.size();t++) ! { ! temp=_analogIns[t]->find(uid); ! if (temp!=NULL) ! return(temp); ! } ! return(NULL); } - --- 16,144 ---- #include <phidget.h> ! CInterfaceKit::CInterfaceKit (phidget * device): ! CPhidget (device) { ! if (classType () != INTERFACE_KIT) ! throw ! runtime_error ! ("Can't initialize a CInterfaceKit with a phidget that is not an interface kit"); ! switch (productID ()) ! { ! default: ! { ! char temp[128]; ! ! sprintf (temp, ! "Unknown type of interface kit Vendor ID:0x0%x Product ID:0x0%x\n", ! vendorID (), productID ()); ! throw runtime_error (temp); ! } ! } } ! void ! CInterfaceKit::setDigitalInCount (int num) { ! if (_digitalIns.size () != 0) ! throw runtime_error ("You can only call this function once"); ! ! for (int t = 0; t < num; t++) ! _digitalIns.push_back (new CDigitalIn (this, t)); } ! void ! CInterfaceKit::setDigitalOutCount (int num) { ! if (_digitalOuts.size () != 0) ! throw runtime_error ("You can only call this function once"); ! ! for (int t = 0; t < num; t++) ! _digitalOuts.push_back (new CDigitalOut (this, t)); } ! void ! CInterfaceKit::setAnalogInCount (int num) { ! if (_analogIns.size () != 0) ! throw runtime_error ("You can only call this function once"); ! ! for (int t = 0; t < num; t++) ! _analogIns.push_back (new CAnalogIn (this, t)); } ! CInterfaceKit::CInterfaceKit (CInterfaceKit * orig): ! CPhidget (orig) { ! for (int t = 0; t < orig->_digitalIns.size (); t++) ! _digitalIns.push_back (new CDigitalIn (this, t)); ! for (int t = 0; t < orig->_digitalOuts.size (); t++) ! _digitalOuts.push_back (new CDigitalOut (this, t)); ! for (int t = 0; t < orig->_analogIns.size (); t++) ! _analogIns.push_back (new CAnalogIn (this, t)); } ! CInterfaceKit::~CInterfaceKit () { ! for (int t = 0; t < _digitalIns.size (); t++) ! delete _digitalIns[t]; ! ! for (int t = 0; t < _digitalOuts.size (); t++) ! delete _digitalOuts[t]; ! ! for (int t = 0; t < _analogIns.size (); t++) ! delete _analogIns[t]; } ! void ! CInterfaceKit::update () { ! // Do nothing, we can't test this yet } ! const vector < CDigitalIn * >& ! CInterfaceKit::digitalIns () const { ! return (_digitalIns); } ! const vector < CDigitalOut * >& ! CInterfaceKit::digitalOuts () const { ! return (_digitalOuts); } ! const vector < CAnalogIn * >& ! CInterfaceKit::analogIns () const { ! return (_analogIns); } ! CUniqueDevice * ! CInterfaceKit::find (const CUID & uid) { ! CUniqueDevice *temp; ! for (int t = 0; t < _digitalIns.size (); t++) ! { ! temp = _digitalIns[t]->find (uid); ! if (temp != NULL) ! return (temp); ! } ! for (int t = 0; t < _digitalOuts.size (); t++) ! { ! temp = _digitalOuts[t]->find (uid); ! if (temp != NULL) ! return (temp); ! } ! for (int t = 0; t < _analogIns.size (); t++) ! { ! temp = _analogIns[t]->find (uid); ! if (temp != NULL) ! return (temp); ! } ! return (NULL); } Index: CInterfaceKit.h =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CInterfaceKit.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CInterfaceKit.h 7 Sep 2002 20:12:30 -0000 1.2 --- CInterfaceKit.h 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 24,43 **** * inputs. */ ! class CInterfaceKit : public CPhidget { ! private: ! friend class CPhidgetManager; ! vector<CDigitalIn *> _digitalIns; ! vector<CDigitalOut *> _digitalOuts; ! vector<CAnalogIn *> _analogIns; ! void setDigitalInCount(int num); ! void setDigitalOutCount(int num); ! void setAnalogInCount(int num); ! CInterfaceKit(phidget *device); ! public: /** * Constructor to be used when a user derives from this phidget, the user must --- 24,43 ---- * inputs. */ ! class CInterfaceKit:public CPhidget { ! private: ! friend class CPhidgetManager; ! vector < CDigitalIn * >_digitalIns; ! vector < CDigitalOut * >_digitalOuts; ! vector < CAnalogIn * >_analogIns; ! void setDigitalInCount (int num); ! void setDigitalOutCount (int num); ! void setAnalogInCount (int num); ! CInterfaceKit (phidget * device); ! public: /** * Constructor to be used when a user derives from this phidget, the user must *************** *** 45,49 **** * pass it to this constructor, in the constructor of his derived type. */ ! CInterfaceKit(CInterfaceKit *orig); /** --- 45,49 ---- * pass it to this constructor, in the constructor of his derived type. */ ! CInterfaceKit (CInterfaceKit * orig); /** *************** *** 51,83 **** * back into the manager and notify it of the current state of the device */ ! virtual ~CInterfaceKit(); /** * Resends servo information to the controller */ ! void update(); /** * Returns a vector of digital in's that are controlled by this object */ ! const vector <CDigitalIn *> &digitalIns() const; /** * Returns a vector of digital out's that are controlled by this object */ ! const vector <CDigitalOut *> &digitalOuts() const; /** * Returns a vector of analog in's that are controlled by this object */ ! const vector <CAnalogIn *> &analogIns() const; /** * */ ! CUniqueDevice *find(const CUID &uid); }; #endif - - --- 51,81 ---- * back into the manager and notify it of the current state of the device */ ! virtual ~ CInterfaceKit (); /** * Resends servo information to the controller */ ! void update (); /** * Returns a vector of digital in's that are controlled by this object */ ! const vector < CDigitalIn * >&digitalIns () const; /** * Returns a vector of digital out's that are controlled by this object */ ! const vector < CDigitalOut * >&digitalOuts () const; /** * Returns a vector of analog in's that are controlled by this object */ ! const vector < CAnalogIn * >&analogIns () const; /** * */ ! CUniqueDevice *find (const CUID & uid); }; #endif Index: CPhidget.cc =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CPhidget.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CPhidget.cc 7 Sep 2002 20:12:30 -0000 1.2 --- CPhidget.cc 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 14,86 **** #include <usb.h> ! CPhidget::CPhidget(const CUID &uid) : ! CUniqueDevice(uid), ! _device(CPhidgetManager::getInstance()->getDeviceHandle(uid)) { ! // Ask the phidget manager if we really exist as a device, if not throw an exception ! if (_device==NULL) ! throw runtime_error("Phidget doesn't exist."); ! _last_wasAttached=phidgetAttached(_device)==1; } ! CPhidget::~CPhidget() { ! phidgetClose(_device); } ! int CPhidget::classType() { ! //return(_device->type->deviceClass); ! return(phidgetTypeDeviceClass(phidgetType(_device))); } ! const char *CPhidget::name() ! { ! //return(_device->type->name); ! return(phidgetTypeName(phidgetType(_device))); } ! int CPhidget::vendorID() { ! //return(_device->type->vendorID); ! return(phidgetTypeVendorID(phidgetType(_device))); } ! int CPhidget::productID() { ! //return(_device->type->productID); ! return(phidgetTypeProductID(phidgetType(_device))); } ! bool CPhidget::isAttached() { ! //if (_device->attached==1) ! if (phidgetAttached(_device)==1) ! return(true); ! return(false); } ! void CPhidget::processEvents() { ! bool temp=isAttached(); ! if (!_last_wasAttached && temp) ! onAttach(); ! else ! if (_last_wasAttached && !temp) ! onDetach(); ! _last_wasAttached=temp; } ! void CPhidget::onAttach() { } ! void CPhidget::onDetach() { } - --- 14,91 ---- #include <usb.h> ! CPhidget::CPhidget (const CUID & uid): ! CUniqueDevice (uid), ! _device (CPhidgetManager::getInstance ()->getDeviceHandle (uid)) { ! // Ask the phidget manager if we really exist as a device, if not throw an exception ! if (_device == NULL) ! throw runtime_error ("Phidget doesn't exist."); ! _last_wasAttached = phidgetAttached (_device) == 1; } ! CPhidget::~CPhidget () { ! phidgetClose (_device); } ! int ! CPhidget::classType () { ! //return(_device->type->deviceClass); ! return (phidgetTypeDeviceClass (phidgetType (_device))); } ! const char * ! CPhidget::name () ! { ! //return(_device->type->name); ! return (phidgetTypeName (phidgetType (_device))); } ! int ! CPhidget::vendorID () { ! //return(_device->type->vendorID); ! return (phidgetTypeVendorID (phidgetType (_device))); } ! int ! CPhidget::productID () { ! //return(_device->type->productID); ! return (phidgetTypeProductID (phidgetType (_device))); } ! bool CPhidget::isAttached () { ! //if (_device->attached==1) ! if (phidgetAttached (_device) == 1) ! return (true); ! return (false); } ! void ! CPhidget::processEvents () { ! bool temp = isAttached (); ! if (!_last_wasAttached && temp) ! onAttach (); ! else if (_last_wasAttached && !temp) ! onDetach (); ! _last_wasAttached = temp; } ! void ! CPhidget::onAttach () { } ! void ! CPhidget::onDetach () { } Index: CPhidget.h =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CPhidget.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CPhidget.h 7 Sep 2002 20:12:30 -0000 1.2 --- CPhidget.h 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 20,36 **** * All phidgets must be derived from this object */ ! class CPhidget : public CUniqueDevice { ! private: ! bool _last_wasAttached; ! //bool _userConstructed; ! //CPhidget *_replace; ! ! struct phidget *_device; ! // Some friends of phidget ! friend class CServoController; ! friend class CInterfaceKit; /** --- 20,36 ---- * All phidgets must be derived from this object */ ! class CPhidget:public CUniqueDevice { ! private: ! bool _last_wasAttached; ! //bool _userConstructed; ! //CPhidget *_replace; ! struct phidget *_device; ! ! // Some friends of phidget ! friend class CServoController; ! friend class CInterfaceKit; /** *************** *** 38,65 **** * derives from CPhidget (ex. CServoController) */ ! CPhidget(phidget *device /*!< The libphidget phidget device handle */ ); ! protected: ! friend class CPhidgetManager; /** * The device that this CPhidget uses */ ! struct phidget *device() ! { ! return(_device); ! } ! /** * This checks to see if the device status has change. In the case of the base phidget * it checks if it is attached/detached. If a derived phidget overrides this method * it must call the base class method. ! */ ! virtual void processEvents(); /** * Was this phidget constructed by a user */ ! //bool userConstructed() const {return(_userConstructed);} /** --- 38,63 ---- * derives from CPhidget (ex. CServoController) */ ! CPhidget (phidget * device /*!< The libphidget phidget device handle */ ); ! protected: ! friend class CPhidgetManager; /** * The device that this CPhidget uses */ ! struct phidget *device () ! { ! return (_device); ! } /** * This checks to see if the device status has change. In the case of the base phidget * it checks if it is attached/detached. If a derived phidget overrides this method * it must call the base class method. ! */ virtual void processEvents (); /** * Was this phidget constructed by a user */ ! //bool userConstructed() const {return(_userConstructed);} /** *************** *** 67,92 **** * this will return NULL. */ ! //CPhidget *getReplacement() {return(_replace);} ! ! public: ! //CPhidget(CPhidget *orig /*!< The \a CPhidget that we are replacing */); //!< Users can create phidgets, but must pass an already available phidget to them. We must be derived from the same type as the phidget that get's passed in. ! CPhidget(const CUID &uid); ! virtual ~CPhidget(); //!< If it is user constructed, this destructor replaces the original phidget back in the manager ! int classType(); //!< Get the device class as defined in the libphidget documentation. ! const char *name(); //!< Get the device name as defined in the libphidget documentation. ! int vendorID(); //!< Get the vendor ID as defined by the USB standard. ! int productID(); //!< Get the product ID as defined by the USB standard. ! bool isAttached(); //!< Returns if this device is attached or not. ! virtual void onAttach(); //!<This method is called when the device is attached. ! virtual void onDetach(); //!<This method is called when the device is detached. ! virtual void query(const EDeviceClass tp, set<CUID> &devices) ! { ! CUniqueDevice::query(tp,devices); ! if (tp==LP_PHIDGET) ! devices.insert(UID()); ! } }; --- 65,89 ---- * this will return NULL. */ ! //CPhidget *getReplacement() {return(_replace);} ! public: ! //CPhidget(CPhidget *orig /*!< The \a CPhidget that we are replacing */); //!< Users can create phidgets, but must pass an already available phidget to them. We must be derived from the same type as the phidget that get's passed in. ! CPhidget (const CUID & uid); ! virtual ~ CPhidget (); //!< If it is user constructed, this destructor replaces the original phidget back in the manager ! int classType (); //!< Get the device class as defined in the libphidget documentation. ! const char *name (); //!< Get the device name as defined in the libphidget documentation. ! int vendorID (); //!< Get the vendor ID as defined by the USB standard. ! int productID (); //!< Get the product ID as defined by the USB standard. ! bool isAttached (); //!< Returns if this device is attached or not. ! virtual void onAttach (); //!<This method is called when the device is attached. ! virtual void onDetach (); //!<This method is called when the device is detached. ! virtual void query (const EDeviceClass tp, set < CUID > &devices) ! { ! CUniqueDevice::query (tp, devices); + if (tp == LP_PHIDGET) + devices.insert (UID ()); + } }; Index: CPhidgetManager.cc =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CPhidgetManager.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CPhidgetManager.cc 7 Sep 2002 20:12:30 -0000 1.2 --- CPhidgetManager.cc 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 15,37 **** #include <set> ! IMPLEMENT_SINGLETON(CPhidgetManager); ! void CPhidgetManager::registerDevice(CUniqueDevice *dev) { ! _uniqueDevices.push_back(dev); } ! void CPhidgetManager::unregisterDevice(CUniqueDevice *dev) { ! vector<CUniqueDevice *>::iterator i; ! for (i=_uniqueDevices.begin();i!=_uniqueDevices.end();i++) ! if (*i==dev) ! { ! _uniqueDevices.erase(i,i); ! return; ! } ! throw runtime_error("Can't unregister a device that wasn't registered."); } --- 15,39 ---- #include <set> ! IMPLEMENT_SINGLETON (CPhidgetManager); ! void ! CPhidgetManager::registerDevice (CUniqueDevice * dev) { ! _uniqueDevices.push_back (dev); } ! void ! CPhidgetManager::unregisterDevice (CUniqueDevice * dev) { ! vector < CUniqueDevice * >::iterator i; ! for (i = _uniqueDevices.begin (); i != _uniqueDevices.end (); i++) ! if (*i == dev) ! { ! _uniqueDevices.erase (i, i); ! return; ! } ! throw runtime_error ("Can't unregister a device that wasn't registered."); } *************** *** 68,169 **** */ ! CPhidgetManager::CPhidgetManager() { ! phidgetInit(1); ! /* ! // Build classes to handle and open all devices ! int phidget_count; ! struct phidget **phidgets=phidget_get_phidgets(&phidget_count); ! for (int t=0;t<phidget_count;t++) ! { ! // We open this device ! addPossibleNewDevice(phidgets[t]); ! } ! for (int t=0;t<_phidgets.size();t++) _phidgets[t]->processEvents(); ! */ } ! CPhidgetManager::~CPhidgetManager() { ! /* ! for (int t=0;t<_phidgets.size();t++) ! { ! if (_phidgets[t]->userConstructed()) ! throw runtime_error("All user constructed phidgets must be deleted before the phidget manager is destroyed."); ! delete _phidgets[t]; ! } ! */ ! phidgetDeinit(); } ! vector<CUID> CPhidgetManager::query(const EDeviceClass tp) { ! set<CUID> devices; ! ! // Ask libphidget for any known phidgets ! if (tp==LP_ALL || tp==LP_PHIDGET || tp==LP_SERVO_CONTROLLER || tp==LP_INTERFACE_KIT) ! { ! int phidget_count; ! struct phidget **phidgets=phidgetGetPhidgets(&phidget_count); ! ! for (int t=0;t<phidget_count;t++) ! { ! if ( ! (tp==LP_PHIDGET) || ! (tp==LP_ALL) || ! (tp==LP_SERVO_CONTROLLER && phidgetTypeDeviceClass(phidgetType(phidgets[t]))==LP_SERVO_CONTROLLER) || ! (tp==LP_INTERFACE_KIT && phidgetTypeDeviceClass(phidgetType(phidgets[t]))==LP_INTERFACE_KIT) ! ) ! { ! CUID temp_uid(phidgetSerial(phidgets[t])); - devices.insert(temp_uid); - } - } - } ! // Ask each known device if it knows about any devices that match the type we are searching for ! if (tp==LP_ALL || tp==LP_SERVO || tp==LP_DIGITAL_IN || tp==LP_DIGITAL_OUT) { ! for (int t=0;t<_uniqueDevices.size();t++) ! _uniqueDevices[t]->query(tp,devices); ! } ! ! // get a vector of the CUID instead of a set ! vector<CUID> temp; ! for (set<CUID>::iterator i=devices.begin();i!=devices.end();i++) ! temp.push_back(*i); ! return(temp); } ! struct phidget *CPhidgetManager::getDeviceHandle(const CUID &uid) { ! if (uid.id()!=-1) ! throw runtime_error("invalid UID to find phidget. id must be -1"); ! int phidget_count; ! struct phidget **phidgets=phidgetGetPhidgets(&phidget_count); ! for (int t=0;t<phidget_count;t++) { ! // We open this device ! if (phidgetSerial(phidgets[t])==uid.serial()) ! { ! return(phidgetOpen(phidgets[t])); ! } } ! return(NULL); } --- 70,178 ---- */ ! CPhidgetManager::CPhidgetManager () { ! phidgetInit (1); ! /* ! // Build classes to handle and open all devices ! int phidget_count; ! struct phidget **phidgets=phidget_get_phidgets(&phidget_count); ! for (int t=0;t<phidget_count;t++) ! { ! // We open this device ! addPossibleNewDevice(phidgets[t]); ! } ! for (int t=0;t<_phidgets.size();t++) _phidgets[t]->processEvents(); ! */ } ! CPhidgetManager::~CPhidgetManager () { ! /* ! for (int t=0;t<_phidgets.size();t++) ! { ! if (_phidgets[t]->userConstructed()) ! throw runtime_error("All user constructed phidgets must be deleted before the phidget manager is destroyed."); ! delete _phidgets[t]; ! } ! */ ! phidgetDeinit (); } ! vector < CUID > CPhidgetManager::query (const EDeviceClass tp) { ! set < CUID > devices; ! // Ask libphidget for any known phidgets ! if (tp == LP_ALL || tp == LP_PHIDGET || tp == LP_SERVO_CONTROLLER ! || tp == LP_INTERFACE_KIT) ! { ! int ! phidget_count; ! struct phidget ** ! phidgets = phidgetGetPhidgets (&phidget_count); ! for (int t = 0; t < phidget_count; t++) { ! if ( ! (tp == LP_PHIDGET) || ! (tp == LP_ALL) || ! (tp == LP_SERVO_CONTROLLER ! && phidgetTypeDeviceClass (phidgetType (phidgets[t])) == ! LP_SERVO_CONTROLLER) || (tp == LP_INTERFACE_KIT ! && ! phidgetTypeDeviceClass (phidgetType ! (phidgets ! [t])) == ! LP_INTERFACE_KIT)) ! { ! CUID temp_uid (phidgetSerial (phidgets[t])); ! devices.insert (temp_uid); ! } ! } ! } ! // Ask each known device if it knows about any devices that match the type we are searching for ! if (tp == LP_ALL || tp == LP_SERVO || tp == LP_DIGITAL_IN ! || tp == LP_DIGITAL_OUT) ! { ! for (int t = 0; t < _uniqueDevices.size (); t++) ! _uniqueDevices[t]->query (tp, devices); ! } ! // get a vector of the CUID instead of a set ! vector < CUID > temp; ! for (set < CUID >::iterator i = devices.begin (); i != devices.end (); i++) ! temp.push_back (*i); ! return (temp); } ! struct phidget * ! CPhidgetManager::getDeviceHandle (const CUID & uid) { ! if (uid.id () != -1) ! throw runtime_error ("invalid UID to find phidget. id must be -1"); ! int phidget_count; ! struct phidget **phidgets = phidgetGetPhidgets (&phidget_count); ! for (int t = 0; t < phidget_count; t++) ! { ! // We open this device ! if (phidgetSerial (phidgets[t]) == uid.serial ()) { ! return (phidgetOpen (phidgets[t])); } + } ! return (NULL); } *************** *** 180,276 **** //} ! bool CPhidgetManager::checkForEvents() { ! bool found=(phidgetEvents()==1); ! // Get the list of phidgets ! if (found) ! { ! /* ! int phidget_count; ! struct phidget **phidgets=phidget_get_phidgets(&phidget_count); ! for (int t=0;t<phidget_count;t++) ! { ! // We open this device ! addPossibleNewDevice(phidgets[t]); ! } ! for (int t=0;t<_phidgets.size();t++) _phidgets[t]->processEvents(); ! */ ! for (int t=0;t<_uniqueDevices.size();t++) _uniqueDevices[t]->processEvents(); ! } ! return(found); } ! CUniqueDevice *CPhidgetManager::find(const CUID &uid, bool create) { ! CUniqueDevice *temp; ! bool isPhidget=false; ! // Is this a phidget or a phidget device we are trying to find? ! - // Look at all known devices for this - for (int t=0;t<_uniqueDevices.size();t++) - { - temp=_uniqueDevices[t]->find(uid,create); - if (temp!=NULL) - return(temp); - } ! // Wasn't found , so let's return because we were not asked to create this device ! if (!create) ! return(NULL); ! // Not found, is it a phidget? or a phidget device ! if (uid.id()==-1) ! isPhidget=true; ! // Make sure the phidget CUID(uid.serial()) exists ! CUID tempUID(uid.serial()); - bool devfound=false; - if (!isPhidget) - for (int t=0;t<_uniqueDevices.size();t++) - { - if (_uniqueDevices[t]->UID()==uid) - { - devfound=true; - break; - } - } ! // Device wasn't found, this is always true if isPhidget is true ! if (!devfound || isPhidget) ! { ! // Create tempUID, this is the tricky part. ! // How, without know about this phidget do we create it? ! temp=createPhidget(tempUID); - if (isPhidget) - return(temp); - } ! // The base phidget should exists and can now create it for us. ! return(temp->find(uid,create)); } ! CPhidget *CPhidgetManager::createPhidget(const CUID &uid) { ! // This device better not exists, we assume that has already been checked. ! if (uid.id()!=-1) ! throw runtime_error("Id must be -1 for all phidgets"); ! CServoController *sc=new CServoController(uid); ! //_uniqueDevices.push_back(sc); ! return(sc); } --- 189,288 ---- //} ! bool CPhidgetManager::checkForEvents () { ! bool ! found = (phidgetEvents () == 1); ! // Get the list of phidgets ! if (found) ! { ! /* ! int phidget_count; ! struct phidget **phidgets=phidget_get_phidgets(&phidget_count); ! for (int t=0;t<phidget_count;t++) ! { ! // We open this device ! addPossibleNewDevice(phidgets[t]); ! } ! for (int t=0;t<_phidgets.size();t++) _phidgets[t]->processEvents(); ! */ ! for (int t = 0; t < _uniqueDevices.size (); t++) ! _uniqueDevices[t]->processEvents (); ! } ! return (found); } ! CUniqueDevice * ! CPhidgetManager::find (const CUID & uid, bool create) { ! CUniqueDevice *temp; ! bool isPhidget = false; ! // Is this a phidget or a phidget device we are trying to find? ! // Look at all known devices for this ! for (int t = 0; t < _uniqueDevices.size (); t++) ! { ! temp = _uniqueDevices[t]->find (uid, create); ! if (temp != NULL) ! return (temp); ! } ! // Wasn't found , so let's return because we were not asked to create this device ! if (!create) ! return (NULL); ! // Not found, is it a phidget? or a phidget device ! if (uid.id () == -1) ! isPhidget = true; + // Make sure the phidget CUID(uid.serial()) exists + CUID tempUID (uid.serial ()); ! bool devfound = false; ! if (!isPhidget) ! for (int t = 0; t < _uniqueDevices.size (); t++) ! { ! if (_uniqueDevices[t]->UID () == uid) ! { ! devfound = true; ! break; ! } ! } ! // Device wasn't found, this is always true if isPhidget is true ! if (!devfound || isPhidget) ! { ! // Create tempUID, this is the tricky part. ! // How, without know about this phidget do we create it? + temp = createPhidget (tempUID); ! if (isPhidget) ! return (temp); ! } ! // The base phidget should exists and can now create it for us. ! return (temp->find (uid, create)); } ! CPhidget * ! CPhidgetManager::createPhidget (const CUID & uid) { ! // This device better not exists, we assume that has already been checked. ! if (uid.id () != -1) ! throw runtime_error ("Id must be -1 for all phidgets"); ! CServoController *sc = new CServoController (uid); ! //_uniqueDevices.push_back(sc); ! return (sc); } Index: CPhidgetManager.h =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CPhidgetManager.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CPhidgetManager.h 7 Sep 2002 20:12:30 -0000 1.2 --- CPhidgetManager.h 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 49,74 **** * Singleton object that manages all phidgets. */ ! class CPhidgetManager : public TSingleton<CPhidgetManager> { ! private: ! friend class TSingleton<CPhidgetManager>; ! friend class CPhidget; ! friend class CUniqueDevice; ! //vector <CPhidget *> _phidgets; ! vector <CUniqueDevice *> _uniqueDevices; ! CPhidgetManager(); ! //void addPossibleNewDevice(struct phidget *dev); ! //void replacePhidget(CPhidget *a,CPhidget *b); ! struct phidget *getDeviceHandle(const CUID &uid); ! CPhidget *createPhidget(const CUID &uid); ! void registerDevice(CUniqueDevice *dev); ! void unregisterDevice(CUniqueDevice *dev); ! public: /** * Deletes all currently allocated phidgets, only called when the application finishes --- 49,74 ---- * Singleton object that manages all phidgets. */ ! class CPhidgetManager:public TSingleton < CPhidgetManager > { ! private: ! friend class TSingleton < CPhidgetManager >; ! friend class CPhidget; ! friend class CUniqueDevice; ! //vector <CPhidget *> _phidgets; ! vector < CUniqueDevice * >_uniqueDevices; ! CPhidgetManager (); ! //void addPossibleNewDevice(struct phidget *dev); ! //void replacePhidget(CPhidget *a,CPhidget *b); ! struct phidget *getDeviceHandle (const CUID & uid); ! CPhidget *createPhidget (const CUID & uid); ! void registerDevice (CUniqueDevice * dev); ! void unregisterDevice (CUniqueDevice * dev); ! public: /** * Deletes all currently allocated phidgets, only called when the application finishes *************** *** 78,117 **** * be called. */ ! virtual ~CPhidgetManager(); - // Discovery functions - /** * Returns a list of know devices currently available */ ! vector<CUID> query(const EDeviceClass tp=LP_PHIDGET); /** * Get a vector of all phidgets */ ! //const vector<CPhidget *> &phidgets() const; /** * Returns a phidget by it's unique ID or NULL if it is not attached */ ! CPhidget *phidget( ! const CUID &uid //<! Unique ID of phidget ! ); ! CServoController *servoController( ! const CUID &uid ! ); ! //CInterfaceKit *interfaceKit( ! //const CUID &uid ! //); /** * */ ! CUniqueDevice *find( const CUID &uid,bool create=false); ! //CServoController *createServoController(const CUID &uid); --- 78,114 ---- * be called. */ ! virtual ~ CPhidgetManager (); ! ! // Discovery functions /** * Returns a list of know devices currently available */ ! vector < CUID > query (const EDeviceClass tp = LP_PHIDGET); /** * Get a vector of all phidgets */ ! //const vector<CPhidget *> &phidgets() const; /** * Returns a phidget by it's unique ID or NULL if it is not attached */ ! CPhidget *phidget (const CUID & uid //<! Unique ID of phidget ! ); ! CServoController *servoController (const CUID & uid); ! //CInterfaceKit *interfaceKit( ! //const CUID &uid ! //); /** * */ ! CUniqueDevice *find (const CUID & uid, bool create = false); ! //CServoController *createServoController(const CUID &uid); *************** *** 119,135 **** * This goes thru all currently attached phidgets and returns a vector of any servos available */ ! //vector<CServo *> servos() const; /** * Returns a uniquely identified servo or NULL if it is not attached */ ! //CServo * servo( ! //const CUID &id //<! Unique ID of servo ! //); /** * Check for attach/detach events (or any other events. */ ! bool checkForEvents(); --- 116,132 ---- * This goes thru all currently attached phidgets and returns a vector of any servos available */ ! //vector<CServo *> servos() const; /** * Returns a uniquely identified servo or NULL if it is not attached */ ! //CServo * servo( ! //const CUID &id //<! Unique ID of servo ! //); /** * Check for attach/detach events (or any other events. */ ! bool checkForEvents (); Index: CServo.cc =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CServo.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CServo.cc 7 Sep 2002 20:12:30 -0000 1.2 --- CServo.cc 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 27,60 **** */ ! CServo::CServo(CServoController *controller, const int id) : ! CUniqueDevice(controller,id), ! _controller(controller), ! _position(0), ! _systemManaged(true) { } ! CServo::CServo(const CUID &uid) : ! CUniqueDevice(uid), ! _position(0), ! _systemManaged(false) { ! // We have to create it this way, because the phidget manager will ! // be in charge of this servo controller, or return us a servo controller that has already been created. ! _controller=dynamic_cast<CServoController *>(CPhidgetManager::getInstance()->find(CUID(uid.serial()),true)); ! // Let the controller know about this servo ! _controller->registerServo(this,uid.id()); } ! CServo::~CServo() { ! if (!_systemManaged); ! _controller->unregisterServo(UID()); } ! void CServo::position(float p) { ! _position=p; ! _controller->update(); } --- 27,60 ---- */ ! CServo::CServo (CServoController * controller, const int id): ! CUniqueDevice (controller, id), ! _controller (controller), _position (0), _systemManaged (true) { } ! CServo::CServo (const CUID & uid): ! CUniqueDevice (uid), _position (0), _systemManaged (false) { ! // We have to create it this way, because the phidget manager will ! // be in charge of this servo controller, or return us a servo controller that has already been created. ! _controller = ! dynamic_cast < ! CServoController * ! >(CPhidgetManager::getInstance ()->find (CUID (uid.serial ()), true)); ! // Let the controller know about this servo ! _controller->registerServo (this, uid.id ()); } ! CServo::~CServo () { ! if (!_systemManaged); ! _controller->unregisterServo (UID ()); } ! void ! CServo::position (float p) { ! _position = p; ! _controller->update (); } Index: CServo.h =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CServo.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CServo.h 7 Sep 2002 20:12:30 -0000 1.2 --- CServo.h 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 21,87 **** * A single servo */ ! class CServo : public CUniqueDevice { ! private: ! friend class CServoController; ! CServoController *_controller; ! // This is the only real data for the servo ! float _position; ! bool _systemManaged; ! //CServo(CServoController *controller,int id, CServo *orig=NULL); ! - public: - CServo(CServoController *controller,const int id); - CServo(const CUID &uid); ! virtual ~CServo(); /** * Set's the current position of this servo */ ! void position( ! float percent //!< Percentage to turn this servo ! ); /** * Return the last position sent to the servo */ ! float position() const ! { ! return(_position); ! } ! /** * On controllers that support this it will return the real world * position of this servo. If it doesn't, it returns the same * as getPosition() ! */ ! float realPosition() const ! { ! return(position()); ! } ! /** * Makes a copy of the servo, just the real data, not anything about * which controller it is attached to or other information set in the * constructor only ! */ ! const CServo &operator=(const CServo *a) ! { ! _position=a->_position; ! ! return(*this); ! } /** * No devices are contained in this device ! */ ! CServo *find(const CUID &uid) {return(NULL);} }; --- 21,82 ---- * A single servo */ ! class CServo:public CUniqueDevice { ! private: ! friend class CServoController; ! CServoController *_controller; ! // This is the only real data for the servo ! float _position; ! bool _systemManaged; ! //CServo(CServoController *controller,int id, CServo *orig=NULL); + public: + CServo (CServoController * controller, const int id); + CServo (const CUID & uid); ! ! virtual ~ CServo (); /** * Set's the current position of this servo */ ! void position (float percent //!< Percentage to turn this servo ! ); /** * Return the last position sent to the servo */ ! float position () const ! { ! return (_position); ! } /** * On controllers that support this it will return the real world * position of this servo. If it doesn't, it returns the same * as getPosition() ! */ float realPosition () const ! { ! return (position ()); ! } /** * Makes a copy of the servo, just the real data, not anything about * which controller it is attached to or other information set in the * constructor only ! */ const CServo & operator = (const CServo * a) { ! _position = a->_position; + return (*this); + } /** * No devices are contained in this device ! */ CServo *find (const CUID & uid) ! { ! return (NULL); ! } }; Index: CServoController.cc =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CServoController.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CServoController.cc 7 Sep 2002 20:12:30 -0000 1.2 --- CServoController.cc 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 14,120 **** #include <phidget.h> ! CServoController::CServoController(const CUID &uid) : ! CPhidget(uid), ! _servoCount(-1), ! _servos(NULL) { ! // Make sure it was constructed properly ! if (classType()!=LP_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() { ! for (int t=0;t<_servoCount;t++) ! if (_servos[t].first) ! delete _servos[t].second; ! delete[] _servos; } ! CUniqueDevice *CServoController::find(const CUID &uid, bool create) { ! if (uid.serial()==UID().serial() && uid.id()>=0 && uid.id()<_servoCount) ! return(servo(uid.id(),create)); ! return(CPhidget::find(uid)); } ! CServo *CServoController::servo(const int id, bool create) { ! if (id<0 || id>=_servoCount) ! throw runtime_error("Invalid servo id"); ! if (create && _servos[id].second==NULL) ! { ! _servos[id].first=true; ! _servos[id].second=new CServo(this,id); ! } ! return(_servos[id].second); } ! void CServoController::registerServo(CServo *servo,int id) { ! if (id<0 || id>=_servoCount) ! throw runtime_error("Invalid servo id"); ! if (_servos[id].second!=NULL) ! throw runtime_error("This servo id is already being used."); ! _servos[id].first=false; ! _servos[id].second=servo; } ! void CServoController::unregisterServo(const CUID &uid) { ! if ((uid.id()<0 && uid.id()>=_servoCount) || uid.serial()!=UID().serial()) ! throw runtime_error("Invalid servo id"); ! if (_servos[uid.id()].first) ! throw runtime_error("Can't unregister a system managed servo"); ! _servos[uid.id()].first=true; ! _servos[uid.id()].second=NULL; } ! void CServoController::setServoCount(int num) { ! _servoCount=num; ! _servos=new pair<bool, CServo *>[_servoCount]; ! for (int t=0;t<_servoCount;t++) ! { ! _servos[t].first=true; ! _servos[t].second=NULL; ! } } --- 14,129 ---- #include <phidget.h> ! CServoController::CServoController (const CUID & uid): ! CPhidget (uid), _servoCount (-1), _servos (NULL) { ! // Make sure it was constructed properly ! if (classType () != LP_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 () { ! for (int t = 0; t < _servoCount; t++) ! if (_servos[t].first) ! delete _servos[t].second; ! delete[]_servos; } ! CUniqueDevice * ! CServoController::find (const CUID & uid, bool create) { ! if (uid.serial () == UID ().serial () && uid.id () >= 0 ! && uid.id () < _servoCount) return (servo (uid.id (), create)); ! return (CPhidget::find (uid)); } ! CServo * ! CServoController::servo (const int id, bool create) { ! if (id < 0 || id >= _servoCount) ! throw runtime_error ("Invalid servo id"); ! if (create && _servos[id].second == NULL) ! { ! _servos[id].first = true; ! _servos[id].second = new CServo (this, id); ! } ! return (_servos[id].second); } ! void ! CServoController::registerServo (CServo * servo, int id) { ! if (id < 0 || id >= _servoCount) ! throw runtime_error ("Invalid servo id"); ! if (_servos[id].second != NULL) ! throw runtime_error ("This servo id is already being used."); ! _servos[id].first = false; ! _servos[id].second = servo; } ! void ! CServoController::unregisterServo (const CUID & uid) { ! if ((uid.id () < 0 && uid.id () >= _servoCount) ! || uid.serial () != UID ().serial ()) ! throw runtime_error ("Invalid servo id"); ! if (_servos[uid.id ()].first) ! throw runtime_error ("Can't unregister a system managed servo"); ! _servos[uid.id ()].first = true; ! _servos[uid.id ()].second = NULL; } ! void ! CServoController::setServoCount (int num) { ! _servoCount = num; ! _servos = new pair < bool, CServo * >[_servoCount]; ! for (int t = 0; t < _servoCount; t++) ! { ! _servos[t].first = true; ! _servos[t].second = NULL; ! } } *************** *** 191,207 **** */ ! void CServoController::update() { ! if (_servoCount) ! { ! float p1=0,p2=0,p3=0,p4=0; ! if (_servoCount>=1 && _servos[0].second!=NULL) p1=_servos[0].second->position(); ! if (_servoCount>=2 && _servos[1].second!=NULL) p2=_servos[1].second->position(); ! if (_servoCount>=3 && _servos[2].second!=NULL) p3=_servos[2].second->position(); ! if (_servoCount>=4 && _servos[3].second!=NULL) p4=_servos[3].second->position(); ! phidgetQuadServo(device(),p1,p2,p3,p4); ! } } --- 200,221 ---- */ ! void ! CServoController::update () { ! if (_servoCount) ! { ! float p1 = 0, p2 = 0, p3 = 0, p4 = 0; ! if (_servoCount >= 1 && _servos[0].second != NULL) ! p1 = _servos[0].second->position (); ! if (_servoCount >= 2 && _servos[1].second != NULL) ! p2 = _servos[1].second->position (); ! if (_servoCount >= 3 && _servos[2].second != NULL) ! p3 = _servos[2].second->position (); ! if (_servoCount >= 4 && _servos[3].second != NULL) ! p4 = _servos[3].second->position (); ! phidgetQuadServo (device (), p1, p2, p3, p4); ! } } Index: CServoController.h =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CServoController.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CServoController.h 7 Sep 2002 20:12:30 -0000 1.2 --- CServoController.h 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 21,46 **** * Object that represents all servo controllers (both hard and soft). */ ! class CServoController : public CPhidget { ! private: ! friend class CServo; ! //friend class CPhidgetManager; ! //vector<CServo *> _servos; ! int _servoCount; ! void setServoCount(int num); ! pair< bool, CServo *> *_servos; ! void registerServo(CServo *, int id); ! void unregisterServo(const CUID &uid); ! public: ! CServoController(const CUID &uid); ! //CServoController(phidget *device); ! /** * Constructor to be used when a user derives from this phidget, the user must --- 21,46 ---- * Object that represents all servo controllers (both hard and soft). */ ! class CServoController:public CPhidget { ! private: ! friend class CServo; ! //friend class CPhidgetManager; ! //vector<CServo *> _servos; ! int _servoCount; ! void setServoCount (int num); ! pair < bool, CServo * >*_servos; ! void registerServo (CServo *, int id); ! void unregisterServo (const CUID & uid); ! public: ! CServoController (const CUID & uid); ! //CServoController(phidget *device); ! /** * Constructor to be used when a user derives from this phidget, the user must *************** *** 48,52 **** * pass it to this constructor, in the constructor of his derived type. */ ! //CServoController(CServoController *orig); /** --- 48,52 ---- * pass it to this constructor, in the constructor of his derived type. */ ! //CServoController(CServoController *orig); /** *************** *** 54,87 **** * back into the manager and notify it of the current state of the device */ ! virtual ~CServoController(); /** * Resends servo information to the controller */ ! void update(); /** * Returns a vector of servo's that are controlled by this object */ ! //const vector <CServo *> &servos() const; ! CUniqueDevice *find(const CUID &uid, bool create); /** * returns a previously created servo */ ! CServo *servo(int id, bool create=true); ! ! int servoCount() const {return(_servoCount);} ! virtual void query(const EDeviceClass tp, set<CUID> &devices) ! { ! CPhidget::query(tp,devices); ! if (tp==LP_SERVO || tp==LP_ALL) for (int t=0;t<_servoCount;t++) devices.insert(CUID(UID().serial(),t)); ! } }; #endif - - --- 54,89 ---- * back into the manager and notify it of the current state of the device */ ! virtual ~ CServoController (); /** * Resends servo information to the controller */ ! void update (); /** * Returns a vector of servo's that are controlled by this object */ ! //const vector <CServo *> &servos() const; ! CUniqueDevice *find (const CUID & uid, bool create); /** * returns a previously created servo */ ! CServo *servo (int id, bool create = true); ! int servoCount () const ! { ! return (_servoCount); ! } ! virtual void query (const EDeviceClass tp, set < CUID > &devices) ! { ! CPhidget::query (tp, devices); ! if (tp == LP_SERVO || tp == LP_ALL) ! for (int t = 0; t < _servoCount; t++) ! devices.insert (CUID (UID ().serial (), t)); ! } }; #endif Index: CUID.cc =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CUID.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CUID.cc 7 Sep 2002 20:12:30 -0000 1.2 --- CUID.cc 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 12,100 **** ! CUID::CUID( const int serial) : ! _serial(serial), ! _id(-1) { } ! CUID::CUID( const int serial, const int id) : ! _serial(serial), ! _id(id) { } ! CUID::CUID() : ! _serial(-1), ! _id(-1) { } ! CUID::CUID( const CUniqueDevice *device, const int id ) : ! _serial( device->UID().serial() ), ! _id(id) { } ! CUID::CUID(const CUID &id) { ! (*this)=id; } ! const CUID &CUID::operator=(const CUID &id) ! { ! _serial=id._serial; ! _id=id._id; ! ! return(*this); ! } ! bool CUID::operator==(const CUID &id) const ! { ! if (_serial!=id._serial) return(false); ! if (_id!=id._id) return(false); ! return(true); } ! CUID::~CUID() { } ! int CUID::serial() const { ! return(_serial); } ! int CUID::id() const { ! return(_id); } ! bool CUID::operator<(const CUID &id) const ! { ! if (_serial<id._serial) return(true); ! if (_serial>id._serial) return(false); ! return(_id<id._id); ! } ! ! bool CUID::operator>(const CUID &id) const { ! if (_serial<id._serial) return(false); ! if (_serial>id._serial) return(true); ! return(_id>id._id); } ! string CUID::asString() const { ! char temp[16]; ! if (_id==-1) ! sprintf(temp,"%d",_serial); ! else ! sprintf(temp,"%d:%d",_serial,_id); ! return(string(temp)); } - - --- 12,105 ---- ! CUID::CUID (const int serial): ! _serial (serial), _id (-1) { } ! CUID::CUID (const int serial, const int id): ! _serial (serial), _id (id) { } ! CUID::CUID (): ! _serial (-1), _id (-1) { } ! CUID::CUID (const CUniqueDevice * device, const int id): ! _serial (device->UID ().serial ()), _id (id) { } ! CUID::CUID (const CUID & id) { ! (*this) = id; } ! const CUID & ! CUID::operator = (const CUID & id) { ! _serial = id._serial; ! _id = id._id; ! return (*this); } ! bool CUID::operator == (const CUID & id) ! const ! { ! if (_serial != id._serial) ! return (false); ! if (_id != id._id) ! return (false); ! return (true); ! } ! CUID::~ ! CUID () { } ! int ! CUID::serial () const { ! return (_serial); } ! int ! CUID::id () const { ! return (_id); } ! bool CUID::operator < (const CUID & id) ! const ! { ! if (_serial < id._serial) ! return (true); ! if (_serial > id._serial) ! return (false); ! return (_id < id._id); ! } ! bool ! CUID::operator > (const CUID & id) const { ! if (_serial < id._serial) ! return (false); ! if (_serial > id._serial) ! return (true); ! return (_id > id._id); } ! string CUID::asString () const { ! char ! temp[16]; ! if (_id == -1) ! sprintf (temp, "%d", _serial); ! else ! sprintf (temp, "%d:%d"... [truncated message content] |
From: Vadim T. <vt...@us...> - 2002-09-08 18:59:57
|
Update of /cvsroot/libphidget/libphidget/src/libphidget In directory usw-pr-cvs1:/tmp/cvs-serv3113/src/libphidget Modified Files: phidget.c phidget.h Log Message: Performed 'make indent' on the code - now it conforms to GNU coding style standard. In the future, don't forget to 'make indent' on the top level before doing 'cvs commit'. Otherwise, unwanted, irrelevant, and MASSIVE diffs will result. Index: phidget.c =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/libphidget/phidget.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** phidget.c 7 Sep 2002 20:12:30 -0000 1.2 --- phidget.c 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 22,32 **** #define DBG(a) ! int _libPhidgetInitialized=0; /**< Private variable to determine if the libphidget is initialized */ ! int _typeCount=0; /**< count of known phidget types */ ! struct phidget_type *_typeList=NULL; /**< Array that will hold all the type structures */ ! int _phidgetDeviceCount=0; //*< Count of known phidgets */ ! struct phidget *_usbDeviceList[MAX_USB_DEVICES]; //*< Array that will hold all of the phidget structures */ ! int _catchSignals=0; //*< This is set on initialization and determines if signals are caught or not. ! enum ELPError _libPhidgetError=LPE_NONE; //*< Last lib phidget error */ [...1816 lines suppressed...] ! ("During the initialization of a phidget the interface for the USB device could not be claimed"); ! case LPE_SET_ALT_INTERFACE_FAILED: ! return ! ("During the initialization of a phidget the alternate interface for the USB device could not be set"); ! case LPE_NO_SERIAL_RETURNED: ! return ("The serial number could not be requested from the phidget"); ! case LPE_PHIDGET_ALREADY_CLOSED: ! return ("Phidget is already closed"); ! case LPE_PHIDGET_ALREADY_OPENED: ! return ("Phidget is already opened"); ! case LPE_PHIDGET_NOT_OPENED: ! return ("Phidget is not opened"); ! case LPE_CONTROL_MSG_ERROR: ! return ("Error sending a control message to a phidget"); ! case LPE_BULK_READ_ERROR: ! return ("Error reading bulk data from a phidget"); ! default: ! return ("not an error number"); ! } }; Index: phidget.h =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/libphidget/phidget.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** phidget.h 7 Sep 2002 20:12:30 -0000 1.2 --- phidget.h 8 Sep 2002 18:59:54 -0000 1.3 *************** *** 59,82 **** enum EDeviceClass { ! LP_ALL=1, /**< All devices match this */ ! // Actual phidget types ! LP_PHIDGET=100, /**< Generic phidget, not used in this library */ ! LP_SERVO_CONTROLLER=200, /**< Identifies all servo controller phidgets */ ! LP_INTERFACE_KIT=300, /**< Identifies all interface kit phidgets, support being added now */ ! LP_ENCODER=400, /**< Currently unsupported */ ! LP_POWER=500, /**< Currently unsupported */ ! LP_RFID=600, /**< Currently unsupported */ ! LP_LED=700, /**< Currently unsupported */ ! LP_TEXTLCD=800, /**< Currently unsupported */ ! // Phidget devices, a phidget device is something a phidget controls ! LP_SERVO=201, /**< Any servo that a servo controller controls */ ! LP_DIGITAL_IN=301, /**< Any digital input that an interface kit controls */ ! LP_DIGITAL_OUT=302, /**< Any digital output that an interface kit controls */ ! LP_ANALOG_IN=303, /**< Any analog input that an interface kit controls */ ! LP_OTHER=0, /**< Identifies all unknown phidgets, this shouldn't exists */ ! LP_INVALID=-2, /**< Invalid device class */ }; --- 59,82 ---- enum EDeviceClass { ! LP_ALL = 1, /**< All devices match this */ ! // Actual phidget types ! LP_PHIDGET = 100, /**< Generic phidget, not used in this library */ ! LP_SERVO_CONTROLLER = 200, /**< Identifies all servo controller phidgets */ ! LP_INTERFACE_KIT = 300, /**< Identifies all interface kit phidgets, support being added now */ ! LP_ENCODER = 400, /**< Currently unsupported */ ! LP_POWER = 500, /**< Currently unsupported */ ! LP_RFID = 600, /**< Currently unsupported */ ! LP_LED = 700, /**< Currently unsupported */ ! LP_TEXTLCD = 800, /**< Currently unsupported */ ! // Phidget devices, a phidget device is something a phidget controls ! LP_SERVO = 201, /**< Any servo that a servo controller controls */ ! LP_DIGITAL_IN = 301, /**< Any digital input that an interface kit controls */ ! LP_DIGITAL_OUT = 302, /**< Any digital output that an interface kit controls */ ! LP_ANALOG_IN = 303, /**< Any analog input that an interface kit controls */ ! LP_OTHER = 0, /**< Identifies all unknown phidgets, this shouldn't exists */ ! LP_INVALID = -2, /**< Invalid device class */ }; *************** *** 87,111 **** enum ELPError { ! LPE_NONE=0, /**< No error has occured */ ! LPE_PHIDGET_NOT_ATTACHED=1, /**< Phidget is not attached, this is really a warning */ ! LPE_UNKNOWN=-1, /**< An unknown error has occured */ ! LPE_INVALID_PHIDGET_CLASS=LP_INVALID,/**< Invalid device class (same as LP_INVALID), most likely the device class was NULL */ ! LPE_INVALID_PHIDGET=-3, /**< Invalid phidget, most likely the phidget was NULL */ ! LPE_NOT_INITIALIZED=-4, /**< libphidget hasn't been initialized */ ! LPE_WRONG_PHIDGET_CLASS_TYPE=-5, /**< The wrong device class type was passed to a function */ ! LPE_UNKNOWN_PHIDGET_CLASS_TYPE=-6, /**< An unknown device class type was passed to a function */ ! LPE_SET_CONFIGURATION_FAILED=-7, /**< During the initialization of a phidget the configuration for the USB device could not be set */ ! LPE_CLAIM_INTERFACE_FAILED=-8, /**< During the initialization of a phidget the interface for the USB device could not be claimed */ ! LPE_SET_ALT_INTERFACE_FAILED=-9, /**< During the initialization of a phidget the alternate interface for the USB device could not be set */ ! LPE_NO_SERIAL_RETURNED=-10, /**< The serial number could not be requested from the phidget */ ! LPE_PHIDGET_ALREADY_CLOSED=-11, /**< Phidget is already closed */ ! LPE_PHIDGET_ALREADY_OPENED=-12, /**< Phidget is already opened */ ! LPE_PHIDGET_NOT_OPENED=-13, /**< Phidget is not opened */ ! LPE_CONTROL_MSG_ERROR=-14, /**< Error sending a control message to a phidget */ ! LPE_BULK_READ_ERROR=-15 /**< Error reading bulk data from a phidget */ }; #ifdef __cplusplus ! extern "C" { #endif --- 87,112 ---- enum ELPError { ! LPE_NONE = 0, /**< No error has occured */ ! LPE_PHIDGET_NOT_ATTACHED = 1, /**< Phidget is not attached, this is really a warning */ ! LPE_UNKNOWN = -1, /**< An unknown error has occured */ ! LPE_INVALID_PHIDGET_CLASS = LP_INVALID, /**< Invalid device class (same as LP_INVALID), most likely the device class was NULL */ ! LPE_INVALID_PHIDGET = -3, /**< Invalid phidget, most likely the phidget was NULL */ ! LPE_NOT_INITIALIZED = -4, /**< libphidget hasn't been initialized */ ! LPE_WRONG_PHIDGET_CLASS_TYPE = -5, /**< The wrong device class type was passed to a function */ ! LPE_UNKNOWN_PHIDGET_CLASS_TYPE = -6, /**< An unknown device class type was passed to a function */ ! LPE_SET_CONFIGURATION_FAILED = -7, /**< During the initialization of a phidget the configuration for the USB device could not be set */ ! LPE_CLAIM_INTERFACE_FAILED = -8, /**< During the initialization of a phidget the interface for the USB device could not be claimed */ ! LPE_SET_ALT_INTERFACE_FAILED = -9, /**< During the initialization of a phidget the alternate interface for the USB device could not be set */ ! LPE_NO_SERIAL_RETURNED = -10, /**< The serial number could not be requested from the phidget */ ! LPE_PHIDGET_ALREADY_CLOSED = -11, /**< Phidget is already closed */ ! LPE_PHIDGET_ALREADY_OPENED = -12, /**< Phidget is already opened */ ! LPE_PHIDGET_NOT_OPENED = -13, /**< Phidget is not opened */ ! LPE_CONTROL_MSG_ERROR = -14, /**< Error sending a control message to a phidget */ ! LPE_BULK_READ_ERROR = -15 /**< Error reading bulk data from a phidget */ }; #ifdef __cplusplus ! extern "C" ! { #endif *************** *** 118,127 **** * long as \a phidget_deinit is called between each call to \a phidget_init. */ ! enum ELPError phidgetInit(int catchSignals); /** Must be called at the end of your program. Frees some internal data * structures. If this isn't called then there will be memory leaks. */ ! enum ELPError phidgetDeinit(); /** --- 119,128 ---- * long as \a phidget_deinit is called between each call to \a phidget_init. */ ! enum ELPError phidgetInit (int catchSignals); /** Must be called at the end of your program. Frees some internal data * structures. If this isn't called then there will be memory leaks. */ ! enum ELPError phidgetDeinit (); /** *************** *** 129,133 **** * and phidgetLastError() will return the error code. */ ! struct phidget **phidgetGetPhidgets(int *numPhidgets); /** --- 130,134 ---- * and phidgetLastError() will return the error code. */ ! struct phidget **phidgetGetPhidgets (int *numPhidgets); /** *************** *** 135,148 **** * return the error code. */ ! struct phidget *phidgetOpen( ! struct phidget *phidget //<! The phidget that we want to open ! ); /** * Close a phidget */ ! enum ELPError phidgetClose( ! struct phidget *device //<! The phidget to be closed ! ); /** --- 136,147 ---- * return the error code. */ ! struct phidget *phidgetOpen (struct phidget *phidget //<! The phidget that we want to open ! ); /** * Close a phidget */ ! enum ELPError phidgetClose (struct phidget *device //<! The phidget to be closed ! ); /** *************** *** 151,159 **** * writing to. */ ! enum ELPError phidgetWrite( ! struct phidget *device, //<! The phidget to be written to ! char *bytes, //<! Pointer to data that is to be written to the device ! int size //<! Size in bytes of data pointed to by \a bytes ! ); /** --- 150,157 ---- * writing to. */ ! enum ELPError phidgetWrite (struct phidget *device, //<! The phidget to be written to ! char *bytes, //<! Pointer to data that is to be written to the device ! int size //<! Size in bytes of data pointed to by \a bytes ! ); /** *************** *** 161,169 **** * have an interface kit or any phidget that supports reads. */ ! enum ELPError phidgetRead( ! struct phidget *device, //<! The phidget to be read from ! char *bytes, //<! Pointer allocated large enough to hold \a size bytes of data ! int size //<! Size in bytes of data to read from device ! ); /** --- 159,166 ---- * have an interface kit or any phidget that supports reads. */ ! enum ELPError phidgetRead (struct phidget *device, //<! The phidget to be read from ! char *bytes, //<! Pointer allocated large enough to hold \a size bytes of data ! int size //<! Size in bytes of data to read from device ! ); /** *************** *** 174,181 **** * motion on your servo you can simple say percent = desired_angle / range. */ ! enum ELPError phidgetSingleServo( ! struct phidget *device, //<! The phidget to be controlled ! float percent //<! Percentage to move servo 1 ! ); /** --- 171,177 ---- * motion on your servo you can simple say percent = desired_angle / range. */ ! enum ELPError phidgetSingleServo (struct phidget *device, //<! The phidget to be controlled ! float percent //<! Percentage to move servo 1 ! ); /** *************** *** 183,190 **** * device is closed (either on purpose, or when the signal handler catches it) */ ! enum ELPError pidgetSingleServoDefault( ! struct phidget *device, //<! The phidget whose default we want to set ! float percent //!< Percentage to move servo 1 ! ); /** --- 179,185 ---- * device is closed (either on purpose, or when the signal handler catches it) */ ! enum ELPError pidgetSingleServoDefault (struct phidget *device, //<! The phidget whose default we want to set ! float percent //!< Percentage to move servo 1 ! ); /** *************** *** 195,205 **** * motion on your servo you can simple say percent = desired_angle / range. */ ! enum ELPError phidgetQuadServo( ! struct phidget *device, //!< The phidget to be contorlled ! float percent1, //!< Percentage to move servo 1 ! float percent2, //!< Percentage to move servo 2 ! float percent3, //!< Percentage to move servo 3 ! float percent4 //!< Percentage to move servo 4 ! ); /** --- 190,199 ---- * motion on your servo you can simple say percent = desired_angle / range. */ ! enum ELPError phidgetQuadServo (struct phidget *device, //!< The phidget to be contorlled ! float percent1, //!< Percentage to move servo 1 ! float percent2, //!< Percentage to move servo 2 ! float percent3, //!< Percentage to move servo 3 ! float percent4 //!< Percentage to move servo 4 ! ); /** *************** *** 207,217 **** * device is closed (either on purpose, or when the signal handler catches it) */ ! enum ELPError pidgetQuadServoDefault( ! struct phidget *device, //<! The phidget whose default we want to set ! float percent1, //!< Percentage to move servo 1 ! float percent2, //!< Percentage to move servo 2 ! float percent3, //!< Percentage to move servo 3 ! float percent4 //!< Percentage to move servo 4 ! ); /** --- 201,210 ---- * device is closed (either on purpose, or when the signal handler catches it) */ ! enum ELPError pidgetQuadServoDefault (struct phidget *device, //<! The phidget whose default we want to set ! float percent1, //!< Percentage to move servo 1 ! float percent2, //!< Percentage to move servo 2 ! float percent3, //!< Percentage to move servo 3 ! float percent4 //!< Percentage to move servo 4 ! ); /** *************** *** 224,228 **** * then when it is reconnected you will be re-attached to the same USB device. */ ! int phidgetEvents(); --- 217,221 ---- * then when it is reconnected you will be re-attached to the same USB device. */ ! int phidgetEvents (); *************** *** 231,240 **** * a NULL and phidgetLastError() will return the error code. */ ! const struct phidget_type *phidgetType(const struct phidget *device); /** * Return the serial number from a phidget. If an error occurs it returns an \a ELPError equivalent error number. */ ! int phidgetSerial(const struct phidget *device); /** --- 224,233 ---- * a NULL and phidgetLastError() will return the error code. */ ! const struct phidget_type *phidgetType (const struct phidget *device); /** * Return the serial number from a phidget. If an error occurs it returns an \a ELPError equivalent error number. */ ! int phidgetSerial (const struct phidget *device); /** *************** *** 242,276 **** * a NULL and phidgetLastError() will return the error code. */ ! const char *phidgetTypeName(const struct phidget_type *tp); /** * Returns the product ID of a phidget type If an error occurs it returns an \a ELPError equivalent error number. */ ! int phidgetTypeProductID(const struct phidget_type *tp); /** * Returns a vendor ID of a phidget type If an error occurs it returns an \a ELPError equivalent error number. */ ! int phidgetTypeVendorID(const struct phidget_type *tp); /** * Returns the device class of a phidget type If an error occurs it returns an \a ELPError equivalent error number. */ ! enum EDeviceClass phidgetTypeDeviceClass(const struct phidget_type *tp); /** * Returns 1 if a phidget is attached, 0 if it isn't attached. If an error occurs it returns an \a ELPError equivalent error number. */ ! int phidgetAttached(const struct phidget *device); /** * Returns the last error that occured. No defined error can occur during this call. */ ! enum ELPError phidgetLastError(); /** * Returns a human readable string that describes the error number. */ ! const char *phidgetErrorString(const enum ELPError err); --- 235,269 ---- * a NULL and phidgetLastError() will return the error code. */ ! const char *phidgetTypeName (const struct phidget_type *tp); /** * Returns the product ID of a phidget type If an error occurs it returns an \a ELPError equivalent error number. */ ! int phidgetTypeProductID (const struct phidget_type *tp); /** * Returns a vendor ID of a phidget type If an error occurs it returns an \a ELPError equivalent error number. */ ! int phidgetTypeVendorID (const struct phidget_type *tp); /** * Returns the device class of a phidget type If an error occurs it returns an \a ELPError equivalent error number. */ ! enum EDeviceClass phidgetTypeDeviceClass (const struct phidget_type *tp); /** * Returns 1 if a phidget is attached, 0 if it isn't attached. If an error occurs it returns an \a ELPError equivalent error number. */ ! int phidgetAttached (const struct phidget *device); /** * Returns the last error that occured. No defined error can occur during this call. */ ! enum ELPError phidgetLastError (); /** * Returns a human readable string that describes the error number. */ ! const char *phidgetErrorString (const enum ELPError err); *************** *** 279,284 **** } #endif - - #endif - --- 272,274 ---- |
From: Vadim T. <vt...@us...> - 2002-09-08 18:59:57
|
Update of /cvsroot/libphidget/libphidget/src/examples In directory usw-pr-cvs1:/tmp/cvs-serv3113/src/examples Modified Files: phidget_c.c phidget_cpp.cc Log Message: Performed 'make indent' on the code - now it conforms to GNU coding style standard. In the future, don't forget to 'make indent' on the top level before doing 'cvs commit'. Otherwise, unwanted, irrelevant, and MASSIVE diffs will result. Index: phidget_c.c =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/examples/phidget_c.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** phidget_c.c 7 Sep 2002 21:56:54 -0000 1.1 --- phidget_c.c 8 Sep 2002 18:59:54 -0000 1.2 *************** *** 17,89 **** * Simply goes thru all phidgets, looking for servos and then moving them slowly. */ ! int main(int argn, char *argv[]) { ! int t,count; ! struct phidget **phidgets; ! ! printf("----------------------------------------\n"); ! printf("Phidgets Device driver test.\n\n\n"); ! // Initialize libphiget, here is where the devices are actually retrieved by the library ! // We want the library to handle signals (passing it 1) ! phidgetInit(1); ! // Get an array of pointers to phidgets and a count of available phidgets ! phidgets=phidgetGetPhidgets(&count); ! printf("Device count:%d\n",count); ! for (t=0;t<count;t++) ! { ! unsigned char buffer[6]; ! float k; ! struct phidget *dev=phidgetOpen(phidgets[t]); // Open the phidget #t ! // Make sure we opened it successfully ! if (dev==NULL) ! { ! printf("Can't open phidget:%s\n", phidgetErrorString(phidgetLastError())); ! exit(0); ! } ! // Print out some information about this phidget ! printf("Phidget Name:%s Vendor:0x0%x Product:0x0%x Serial#:%06d\n", ! phidgetTypeName(phidgetType(dev)), ! phidgetTypeVendorID(phidgetType(dev)), ! phidgetTypeProductID(phidgetType(dev)), ! phidgetSerial(dev) ! ); ! // Is it a servo controller ! if (phidgetTypeDeviceClass(phidgetType(dev))==LP_SERVO_CONTROLLER) ! { ! for (k=0;k<1;k+=.1) ! { ! int i; ! // Move a single servo (will move servo 0 of a 1 or 4 servo controller) ! phidgetSingleServo(dev,k); ! // Wait a bit ! sleep(1); ! // Process any events that have occured, like attach/detach ! phidgetEvents(); ! } ! } ! // Close the phidget ! phidgetClose(dev); ! printf("Finished\n"); - } ! // done using all phidgets, free's phidget memory ! phidgetDeinit(); ! ! printf("----------------------------------------\n"); ! return(0); } --- 17,88 ---- * Simply goes thru all phidgets, looking for servos and then moving them slowly. */ ! int ! main (int argn, char *argv[]) { ! int t, count; ! struct phidget **phidgets; ! printf ("----------------------------------------\n"); ! printf ("Phidgets Device driver test.\n\n\n"); ! // Initialize libphiget, here is where the devices are actually retrieved by the library ! // We want the library to handle signals (passing it 1) ! phidgetInit (1); ! // Get an array of pointers to phidgets and a count of available phidgets ! phidgets = phidgetGetPhidgets (&count); ! printf ("Device count:%d\n", count); ! for (t = 0; t < count; t++) ! { ! unsigned char buffer[6]; ! float k; ! struct phidget *dev = phidgetOpen (phidgets[t]); // Open the phidget #t ! // Make sure we opened it successfully ! if (dev == NULL) ! { ! printf ("Can't open phidget:%s\n", ! phidgetErrorString (phidgetLastError ())); ! exit (0); ! } ! // Print out some information about this phidget ! printf ! ("Phidget Name:%s Vendor:0x0%x Product:0x0%x Serial#:%06d\n", ! phidgetTypeName (phidgetType (dev)), ! phidgetTypeVendorID (phidgetType (dev)), ! phidgetTypeProductID (phidgetType (dev)), phidgetSerial (dev)); ! // Is it a servo controller ! if (phidgetTypeDeviceClass (phidgetType (dev)) == LP_SERVO_CONTROLLER) ! { ! for (k = 0; k < 1; k += .1) ! { ! int i; ! // Move a single servo (will move servo 0 of a 1 or 4 servo controller) ! phidgetSingleServo (dev, k); ! // Wait a bit ! sleep (1); ! // Process any events that have occured, like attach/detach ! phidgetEvents (); ! } ! } ! // Close the phidget ! phidgetClose (dev); ! printf ("Finished\n"); ! } + // done using all phidgets, free's phidget memory + phidgetDeinit (); ! printf ("----------------------------------------\n"); ! return (0); } Index: phidget_cpp.cc =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/examples/phidget_cpp.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** phidget_cpp.cc 7 Sep 2002 21:56:54 -0000 1.1 --- phidget_cpp.cc 8 Sep 2002 18:59:54 -0000 1.2 *************** *** 195,382 **** */ ! void phidgets_ls() { ! CPhidgetManager *manager=CPhidgetManager::getInstance(); ! vector <CUID> phidgets=manager->query(LP_PHIDGET); ! printf("\n"); ! printf(" UID Name Misc\n"); ! printf("-------- -------------------------------- ----------------\n"); ! for (int t=0;t<phidgets.size();t++) ! { ! const CUID &uid=phidgets[t]; ! CPhidget *phidget=dynamic_cast<CPhidget *>(manager->find(uid,true)); ! if (phidget==NULL) ! throw runtime_error("obtained a phidget CUID that was not a phidget, this can't happen."); ! printf("%8d %32s ", ! phidget->UID().serial(), ! phidget->name() ! ); ! CServoController *sc=dynamic_cast<CServoController *>(phidget); ! if (sc!=NULL) ! { ! printf("Servos: %d\n",sc->servoCount()); ! } ! /* ! else ! if (ik!=NULL) ! { ! printf("DigitalIn: %d\n",ik->digitalIns().size()); ! printf(" DigitalOut: %d\n",ik->digitalOuts().size()); ! printf(" AnalogIns: %d\n",ik->analogIns().size()); ! } ! */ ! else ! printf("Unsupported\n"); ! } ! printf("-------- -------------------------------- ----------------\n"); ! printf("\n\n"); ! printf("Total phidgets:%d\n",phidgets.size()); ! printf("\n"); } ! void readUID(const string &arg) { ! bool colon_found=false; ! string temp; ! char last_char; ! int serial=-1; ! int id=-1; ! for (int t=0;t<arg.length();t++) { ! last_char=arg[t]; ! if (arg[t]==':') ! { ! if (colon_found) throw runtime_error("More than one colon found in UID\n"); ! colon_found=true; ! serial=atoi(temp.c_str()); ! temp=""; ! } ! else ! if (arg[t]>='0' && arg[t]<='9') ! { ! temp+=arg.substr(t,1); ! } ! else ! throw runtime_error("Invalid character in UID:"+arg); } ! if (colon_found && temp.length()>0 && last_char!=':') ! id=atoi(temp.c_str()); ! else ! if (!colon_found) ! serial=atoi(temp.c_str()); ! workingUID=CUID(serial,id); } ! void query() { ! if (workingUID.serial()==-1) ! throw runtime_error("Must use parameter -u with query command\n"); ! CPhidgetManager *manager=CPhidgetManager::getInstance(); ! CUniqueDevice *dev=manager->find(workingUID,true); ! printf("%-10s ",workingUID.asString().c_str()); ! printf(">> "); ! // What type of device is this? ! CPhidget *phidget; ! if ((phidget=dynamic_cast<CPhidget *>(dev))!=NULL) ! { ! printf("Phidget [%s] ",phidget->name()); ! } ! else ! { ! if (dynamic_cast<CServo *>(dev)!=NULL) ! printf("Servo "); ! } ! ! printf("\n"); } ! void moveServo(const string &parm) { ! float p=atof(parm.c_str()); ! CServo servo(workingUID); ! printf("Moving servo to position %f\n",p); ! servo.position(p); ! sleep(1); } ! void help() { ! printf("Arguments:\n\n"); ! printf(" -l (default) list all phidets \n"); ! printf(" -u {UID} set the working UID\n"); ! printf(" -q query the working UID\n"); ! printf(" -h help\n"); ! printf(" -p {percent} adjust the position of a servo referenced by UID\n"); ! printf("\n"); } ! int processArgs(int argn,char *argv[]) { ! if (argn==0) ! return(0); ! // Read an argument ! string arg=argv[0]; ! if (arg=="-u") // The unique device ID to work with ! { ! if (argn<2) throw runtime_error("Expected argument after -u"); ! string parm=argv[1]; ! readUID(parm); ! return(processArgs(argn-2,argv+2)); ! } ! else ! if (arg=="-q") ! { ! query(); ! return(processArgs(argn-1,argv+1)); ! } ! else ! if (arg=="-h") ! { ! help(); ! return(processArgs(argn-1,argv+1)); ! } ! else ! if (arg=="-l") ! { ! phidgets_ls(); ! return(processArgs(argn-1,argv+1)); ! } ! else ! if (arg=="-p") ! { ! if (argn<2) throw runtime_error("Expected argument after -p"); ! string parm=argv[1]; ! moveServo(parm); ! return(processArgs(argn-2,argv+2)); ! } ! throw runtime_error("Invalid argument:"+arg); } --- 195,391 ---- */ ! void ! phidgets_ls () { ! CPhidgetManager *manager = CPhidgetManager::getInstance (); ! vector < CUID > phidgets = manager->query (LP_PHIDGET); ! printf ("\n"); ! printf (" UID Name Misc\n"); ! printf ("-------- -------------------------------- ----------------\n"); ! for (int t = 0; t < phidgets.size (); t++) ! { ! const CUID & uid = phidgets[t]; ! CPhidget *phidget = ! dynamic_cast < CPhidget * >(manager->find (uid, true)); ! if (phidget == NULL) ! throw ! runtime_error ! ("obtained a phidget CUID that was not a phidget, this can't happen."); ! printf ("%8d %32s ", phidget->UID ().serial (), phidget->name ()); ! CServoController *sc = dynamic_cast < CServoController * >(phidget); ! if (sc != NULL) ! { ! printf ("Servos: %d\n", sc->servoCount ()); ! } ! /* ! else ! if (ik!=NULL) ! { ! printf("DigitalIn: %d\n",ik->digitalIns().size()); ! printf(" DigitalOut: %d\n",ik->digitalOuts().size()); ! printf(" AnalogIns: %d\n",ik->analogIns().size()); ! } ! */ ! else ! printf ("Unsupported\n"); ! } ! printf ("-------- -------------------------------- ----------------\n"); ! printf ("\n\n"); ! printf ("Total phidgets:%d\n", phidgets.size ()); ! ! printf ("\n"); } ! void ! readUID (const string & arg) { ! bool colon_found = false; ! string temp; ! char last_char; ! int serial = -1; ! int id = -1; ! for (int t = 0; t < arg.length (); t++) ! { ! last_char = arg[t]; ! ! if (arg[t] == ':') { ! if (colon_found) ! throw runtime_error ("More than one colon found in UID\n"); ! colon_found = true; ! serial = atoi (temp.c_str ()); ! temp = ""; ! } ! else if (arg[t] >= '0' && arg[t] <= '9') ! { ! temp += arg.substr (t, 1); } + else + throw runtime_error ("Invalid character in UID:" + arg); + } ! if (colon_found && temp.length () > 0 && last_char != ':') ! id = atoi (temp.c_str ()); ! else if (!colon_found) ! serial = atoi (temp.c_str ()); ! workingUID = CUID (serial, id); } ! void ! query () { ! if (workingUID.serial () == -1) ! throw runtime_error ("Must use parameter -u with query command\n"); ! CPhidgetManager *manager = CPhidgetManager::getInstance (); ! CUniqueDevice *dev = manager->find (workingUID, true); ! printf ("%-10s ", workingUID.asString ().c_str ()); ! printf (">> "); ! // What type of device is this? ! CPhidget *phidget; ! if ((phidget = dynamic_cast < CPhidget * >(dev)) != NULL) ! { ! printf ("Phidget [%s] ", phidget->name ()); ! } ! else ! { ! if (dynamic_cast < CServo * >(dev) != NULL) ! printf ("Servo "); ! } ! ! ! printf ("\n"); } ! void ! moveServo (const string & parm) { ! float p = atof (parm.c_str ()); ! CServo servo (workingUID); ! printf ("Moving servo to position %f\n", p); ! servo.position (p); ! sleep (1); } ! void ! help () { ! printf ("Arguments:\n\n"); ! printf (" -l (default) list all phidets \n"); ! printf (" -u {UID} set the working UID\n"); ! printf (" -q query the working UID\n"); ! printf (" -h help\n"); ! printf ! (" -p {percent} adjust the position of a servo referenced by UID\n"); ! printf ("\n"); } ! int ! processArgs (int argn, char *argv[]) { ! if (argn == 0) ! return (0); ! // Read an argument ! string arg = argv[0]; ! if (arg == "-u") // The unique device ID to work with ! { ! if (argn < 2) ! throw runtime_error ("Expected argument after -u"); ! string parm = argv[1]; + readUID (parm); + return (processArgs (argn - 2, argv + 2)); + } + else if (arg == "-q") + { + query (); + return (processArgs (argn - 1, argv + 1)); + } + else if (arg == "-h") + { + help (); + return (processArgs (argn - 1, argv + 1)); + } + else if (arg == "-l") + { + phidgets_ls (); + return (processArgs (argn - 1, argv + 1)); + } + else if (arg == "-p") + { + if (argn < 2) + throw runtime_error ("Expected argument after -p"); + string parm = argv[1]; ! moveServo (parm); ! return (processArgs (argn - 2, argv + 2)); ! } ! ! ! throw runtime_error ("Invalid argument:" + arg); } *************** *** 384,412 **** ! int main(int argn,char *argv[]) { ! try ! { ! // What we are ! printf("phidgets: a command line interface utility\n"); ! printf("version $Revision$\n\n"); ! ! // No arguments ! if (argn<=1) ! { ! phidgets_ls(); ! return(0); ! } ! // Recursive argument parser, remove the executable name ! return(processArgs(argn-1,argv+1)); ! } ! catch(const exception &e) ! { ! printf("Exception: %s\n",e.what()); ! return(-1); ! } ! return(0); } --- 393,421 ---- ! int ! main (int argn, char *argv[]) { ! try ! { ! // What we are ! printf ("phidgets: a command line interface utility\n"); ! printf ("version $Revision$\n\n"); ! // No arguments ! if (argn <= 1) ! { ! phidgets_ls (); ! return (0); ! } ! // Recursive argument parser, remove the executable name ! return (processArgs (argn - 1, argv + 1)); ! } ! catch (const exception & e) ! { ! printf ("Exception: %s\n", e.what ()); ! return (-1); ! } ! return (0); } |
From: Vadim T. <vt...@us...> - 2002-09-08 18:25:43
|
Update of /cvsroot/libphidget/libphidget In directory usw-pr-cvs1:/tmp/cvs-serv27435 Removed Files: phidget.c phidget.h main.c Log Message: Removed leftovers - the contents have been moved to ./src/libphidget/phidget.h ./src/libphidget/phidget.c ./src/examples/phidget_c.c --- phidget.c DELETED --- --- phidget.h DELETED --- --- main.c DELETED --- |
From: Vadim T. <vt...@us...> - 2002-09-08 04:29:47
|
Update of /cvsroot/libphidget/libphidget In directory usw-pr-cvs1:/tmp/cvs-serv17787 Modified Files: Makefile.am Log Message: Oops... Forgot to tell it to ignore the $HOME/.indent.pro... Fixed. Index: Makefile.am =================================================================== RCS file: /cvsroot/libphidget/libphidget/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile.am 8 Sep 2002 04:24:31 -0000 1.3 --- Makefile.am 8 Sep 2002 04:29:44 -0000 1.4 *************** *** 11,15 **** @ for FILE in `@FIND@ . -name "*.h" -o -name "*.c" -o -name "*.cc"` ; do \ ! @INDENT@ `@CAT@ ./indent.rules` $$FILE ; \ done --- 11,15 ---- @ for FILE in `@FIND@ . -name "*.h" -o -name "*.c" -o -name "*.cc"` ; do \ ! @INDENT@ --ignore-profile `@CAT@ ./indent.rules` $$FILE ; \ done |
From: Vadim T. <vt...@us...> - 2002-09-08 04:24:34
|
Update of /cvsroot/libphidget/libphidget In directory usw-pr-cvs1:/tmp/cvs-serv17021 Modified Files: Makefile.am configure.in Added Files: indent.rules Log Message: Implemented 'make indent' and 'make indent-local' --- NEW FILE: indent.rules --- --gnu-style Index: Makefile.am =================================================================== RCS file: /cvsroot/libphidget/libphidget/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.am 7 Sep 2002 20:12:29 -0000 1.2 --- Makefile.am 8 Sep 2002 04:24:31 -0000 1.3 *************** *** 4,12 **** EXTRA_DIST = bootstrap src/scripts/install/* - CP = @CP@ - RM = @RM@ - FIND = @FIND@ - clean-generic: ! ${RM} -f `${FIND} -name "*~" -o -name ".*~"` --- 4,20 ---- EXTRA_DIST = bootstrap src/scripts/install/* clean-generic: ! @RM@ -f `@FIND@ -name "*~" -o -name ".*~"` ! ! indent: ! ! @ for FILE in `@FIND@ . -name "*.h" -o -name "*.c" -o -name "*.cc"` ; do \ ! @INDENT@ `@CAT@ ./indent.rules` $$FILE ; \ ! done ! ! indent-local: ! ! @ for FILE in `@FIND@ . -name "*.h" -o -name "*.c" -o -name "*.cc"` ; do \ ! @INDENT@ $$FILE ; \ ! done Index: configure.in =================================================================== RCS file: /cvsroot/libphidget/libphidget/configure.in,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** configure.in 7 Sep 2002 21:56:54 -0000 1.3 --- configure.in 8 Sep 2002 04:24:31 -0000 1.4 *************** *** 54,57 **** --- 54,58 ---- dnl AC_PROG_TR AC_PROG_FIND + AC_PATH_PROG_VERIFY(CAT,cat,$PATH)dnl AC_PATH_PROG_VERIFY(RM,rm,$PATH)dnl dnl AC_PATH_PROG_VERIFY(DIRNAME,dirname,$PATH)dnl |
From: Vadim T. <vt...@us...> - 2002-09-07 21:56:58
|
Update of /cvsroot/libphidget/libphidget/src/examples In directory usw-pr-cvs1:/tmp/cvs-serv4882/src/examples Added Files: .cvsignore Makefile.am phidget_c.c phidget_cpp.cc Log Message: Changed the directory layout and functionality: - ./src/phidget++ now contains the libphidget++ library components - ./src/examples now contains the, ahem, examples --- NEW FILE: .cvsignore --- Makefile Makefile.in .deps .libs phidget_c phidget_cpp --- NEW FILE: Makefile.am --- bin_PROGRAMS = phidget_c phidget_cpp phidget_c_SOURCES = phidget_c.c phidget_c_LDADD = ../libphidget/libphidget.la phidget_c_DEPENDENCIES = ../libphidget/libphidget.la phidget_cpp_SOURCES = phidget_cpp.cc phidget_cpp_LDADD = ../libphidget/libphidget.la ../phidget++/libphidget++.la phidget_cpp_DEPENDENCIES = ../libphidget/libphidget.la ../phidget++/libphidget++.la CFLAGS = -I../libphidget -L../libphidget CXXFLAGS = -I../libphidget -I../phidget++ -L../libphidget -L../phidget++ clean-generic: @RM@ -f *~ .*~ if DOXYGEN_ENABLED all-local: @ @ECHO@ "Doxygen is not being run in this directory yet" #@DOXYGEN@ else all-local: @ @ECHO@ "*** Documentation is not created - install Doxygen" endif --- NEW FILE: phidget_c.c --- /* * libphidget library * $Id: phidget_c.c,v 1.1 2002/09/07 21:56:54 vtt Exp $ * * Copyright (c) 2002 Jack Strohm <js...@ja...> * * This library is covered by the LGPL, read LICENSE for details. */ #include "phidget.h" #include <stdio.h> /** * Simply goes thru all phidgets, looking for servos and then moving them slowly. */ int main(int argn, char *argv[]) { int t,count; struct phidget **phidgets; printf("----------------------------------------\n"); printf("Phidgets Device driver test.\n\n\n"); // Initialize libphiget, here is where the devices are actually retrieved by the library // We want the library to handle signals (passing it 1) phidgetInit(1); // Get an array of pointers to phidgets and a count of available phidgets phidgets=phidgetGetPhidgets(&count); printf("Device count:%d\n",count); for (t=0;t<count;t++) { unsigned char buffer[6]; float k; struct phidget *dev=phidgetOpen(phidgets[t]); // Open the phidget #t // Make sure we opened it successfully if (dev==NULL) { printf("Can't open phidget:%s\n", phidgetErrorString(phidgetLastError())); exit(0); } // Print out some information about this phidget printf("Phidget Name:%s Vendor:0x0%x Product:0x0%x Serial#:%06d\n", phidgetTypeName(phidgetType(dev)), phidgetTypeVendorID(phidgetType(dev)), phidgetTypeProductID(phidgetType(dev)), phidgetSerial(dev) ); // Is it a servo controller if (phidgetTypeDeviceClass(phidgetType(dev))==LP_SERVO_CONTROLLER) { for (k=0;k<1;k+=.1) { int i; // Move a single servo (will move servo 0 of a 1 or 4 servo controller) phidgetSingleServo(dev,k); // Wait a bit sleep(1); // Process any events that have occured, like attach/detach phidgetEvents(); } } // Close the phidget phidgetClose(dev); printf("Finished\n"); } // done using all phidgets, free's phidget memory phidgetDeinit(); printf("----------------------------------------\n"); return(0); } --- NEW FILE: phidget_cpp.cc --- /* * phidget++ library * $Id: phidget_cpp.cc,v 1.1 2002/09/07 21:56:54 vtt Exp $ * * Copyright (c) 2002 Jack Strohm <js...@ja...> * * This library is covered by the LGPL, read LICENSE for details. */ #include "CPhidgetManager.h" #include "CServo.h" #include "CPhidget.h" #include "CServoController.h" #include <unistd.h> // Some globals CUID workingUID; /* class CMyServoController : public CServoController { public: CMyServoController(const CUID &uid) : CServoController(uid) { printf("Initializing My Servo Controller\n"); } ~CMyServoController() { printf("Destroying My Servo Controller\n"); } void onAttach() { printf("My Servo Controller: Attach\n"); } void onDetach() { printf("My Servo Controller: Detach\n"); } }; class CMyServo : public CServo { public: CMyServo(const CUID &uid) : CServo(uid) { printf("Construction of my servo class.\n"); } ~CMyServo() { printf("Destruction of my servo class.\n"); } void position(float f) { CServo::position(f); printf("Rotating servo to %f\n",f); } }; // Discovery of available phidgets, creation of phidget objects, and discovery of all devices afterwards. void example1() { printf("example 1 - Discovery of phidgets\n"); { // See what the system has available CPhidgetManager *manager=CPhidgetManager::getInstance(); CPhidgetManager::getInstance()->checkForEvents(); // This queries for any devices that are phidgets vector< CUID > devices=manager->query(LP_ALL); printf("All:%d\n",devices.size()); CPhidgetManager::getInstance()->checkForEvents(); // Print out how many we found devices=manager->query(LP_PHIDGET); printf("Phidgets:%d\n",devices.size()); CPhidgetManager::getInstance()->checkForEvents(); // Get the phidgets, this forces the manager to create them // since they haven't already been created by the user. for (int t=0;t<devices.size();t++) { CPhidget *phidg=dynamic_cast<CPhidget *>(manager->find(devices[t],true)); } CPhidgetManager::getInstance()->checkForEvents(); // Now let's see how many devices are available devices=manager->query(LP_ALL); printf("All:%d\n",devices.size()); CPhidgetManager::getInstance()->checkForEvents(); } // This makes the next example run like it's the first. CPhidgetManager::release(); printf("Done\n"); } // Just attacheding to a servo, don't have to worry about anything else void example2() { printf("example 2 - Manipulating a servo\n"); { // Create a servo CServo servo(CUID(741,0)); servo.position(.5); sleep(1); CPhidgetManager::getInstance()->checkForEvents(); } // This makes the next example run like it's the first. CPhidgetManager::release(); printf("Done\n"); } void example3() { printf("example 3 - Custom servo device\n"); { // Create a servo CMyServo servo(CUID(741,0)); servo.position(.2); sleep(1); CPhidgetManager::getInstance()->checkForEvents(); servo.position(.5); sleep(1); CPhidgetManager::getInstance()->checkForEvents(); servo.position(.8); sleep(1); CPhidgetManager::getInstance()->checkForEvents(); } // This makes the next example run like it's the first. CPhidgetManager::release(); printf("Done\n"); } void example4() { printf("example 4 - Custom servo device\n"); { CMyServoController controller(CUID(741)); CServo servo(CUID(741,0)); servo.position(.2); sleep(1); CPhidgetManager::getInstance()->checkForEvents(); servo.position(.5); sleep(1); CPhidgetManager::getInstance()->checkForEvents(); servo.position(.8); sleep(1); CPhidgetManager::getInstance()->checkForEvents(); } // This makes the next example run like it's the first. CPhidgetManager::release(); printf("Done\n"); } void example5() { printf("example 5 - Custom servo device\n"); { CMyServoController controller(CUID(741)); CMyServo servo(CUID(741,0)); servo.position(.2); sleep(1); CPhidgetManager::getInstance()->checkForEvents(); servo.position(.5); sleep(1); CPhidgetManager::getInstance()->checkForEvents(); servo.position(.8); sleep(1); CPhidgetManager::getInstance()->checkForEvents(); } // This makes the next example run like it's the first. CPhidgetManager::release(); printf("Done\n"); } */ void phidgets_ls() { CPhidgetManager *manager=CPhidgetManager::getInstance(); vector <CUID> phidgets=manager->query(LP_PHIDGET); printf("\n"); printf(" UID Name Misc\n"); printf("-------- -------------------------------- ----------------\n"); for (int t=0;t<phidgets.size();t++) { const CUID &uid=phidgets[t]; CPhidget *phidget=dynamic_cast<CPhidget *>(manager->find(uid,true)); if (phidget==NULL) throw runtime_error("obtained a phidget CUID that was not a phidget, this can't happen."); printf("%8d %32s ", phidget->UID().serial(), phidget->name() ); CServoController *sc=dynamic_cast<CServoController *>(phidget); if (sc!=NULL) { printf("Servos: %d\n",sc->servoCount()); } /* else if (ik!=NULL) { printf("DigitalIn: %d\n",ik->digitalIns().size()); printf(" DigitalOut: %d\n",ik->digitalOuts().size()); printf(" AnalogIns: %d\n",ik->analogIns().size()); } */ else printf("Unsupported\n"); } printf("-------- -------------------------------- ----------------\n"); printf("\n\n"); printf("Total phidgets:%d\n",phidgets.size()); printf("\n"); } void readUID(const string &arg) { bool colon_found=false; string temp; char last_char; int serial=-1; int id=-1; for (int t=0;t<arg.length();t++) { last_char=arg[t]; if (arg[t]==':') { if (colon_found) throw runtime_error("More than one colon found in UID\n"); colon_found=true; serial=atoi(temp.c_str()); temp=""; } else if (arg[t]>='0' && arg[t]<='9') { temp+=arg.substr(t,1); } else throw runtime_error("Invalid character in UID:"+arg); } if (colon_found && temp.length()>0 && last_char!=':') id=atoi(temp.c_str()); else if (!colon_found) serial=atoi(temp.c_str()); workingUID=CUID(serial,id); } void query() { if (workingUID.serial()==-1) throw runtime_error("Must use parameter -u with query command\n"); CPhidgetManager *manager=CPhidgetManager::getInstance(); CUniqueDevice *dev=manager->find(workingUID,true); printf("%-10s ",workingUID.asString().c_str()); printf(">> "); // What type of device is this? CPhidget *phidget; if ((phidget=dynamic_cast<CPhidget *>(dev))!=NULL) { printf("Phidget [%s] ",phidget->name()); } else { if (dynamic_cast<CServo *>(dev)!=NULL) printf("Servo "); } printf("\n"); } void moveServo(const string &parm) { float p=atof(parm.c_str()); CServo servo(workingUID); printf("Moving servo to position %f\n",p); servo.position(p); sleep(1); } void help() { printf("Arguments:\n\n"); printf(" -l (default) list all phidets \n"); printf(" -u {UID} set the working UID\n"); printf(" -q query the working UID\n"); printf(" -h help\n"); printf(" -p {percent} adjust the position of a servo referenced by UID\n"); printf("\n"); } int processArgs(int argn,char *argv[]) { if (argn==0) return(0); // Read an argument string arg=argv[0]; if (arg=="-u") // The unique device ID to work with { if (argn<2) throw runtime_error("Expected argument after -u"); string parm=argv[1]; readUID(parm); return(processArgs(argn-2,argv+2)); } else if (arg=="-q") { query(); return(processArgs(argn-1,argv+1)); } else if (arg=="-h") { help(); return(processArgs(argn-1,argv+1)); } else if (arg=="-l") { phidgets_ls(); return(processArgs(argn-1,argv+1)); } else if (arg=="-p") { if (argn<2) throw runtime_error("Expected argument after -p"); string parm=argv[1]; moveServo(parm); return(processArgs(argn-2,argv+2)); } throw runtime_error("Invalid argument:"+arg); } int main(int argn,char *argv[]) { try { // What we are printf("phidgets: a command line interface utility\n"); printf("version $Revision: 1.1 $\n\n"); // No arguments if (argn<=1) { phidgets_ls(); return(0); } // Recursive argument parser, remove the executable name return(processArgs(argn-1,argv+1)); } catch(const exception &e) { printf("Exception: %s\n",e.what()); return(-1); } return(0); } |
From: Vadim T. <vt...@us...> - 2002-09-07 21:56:58
|
Update of /cvsroot/libphidget/libphidget/src/phidget++ In directory usw-pr-cvs1:/tmp/cvs-serv4882/src/phidget++ Modified Files: .cvsignore Makefile.am Removed Files: main.cc Log Message: Changed the directory layout and functionality: - ./src/phidget++ now contains the libphidget++ library components - ./src/examples now contains the, ahem, examples Index: .cvsignore =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/.cvsignore,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** .cvsignore 7 Sep 2002 20:12:30 -0000 1.2 --- .cvsignore 7 Sep 2002 21:56:54 -0000 1.3 *************** *** 3,5 **** .deps .libs ! phidget_test --- 3,6 ---- .deps .libs ! *.lo ! *.la Index: Makefile.am =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/phidget++/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.am 7 Sep 2002 20:12:30 -0000 1.2 --- Makefile.am 7 Sep 2002 21:56:54 -0000 1.3 *************** *** 1,5 **** ! bin_PROGRAMS = phidget_test ! phidget_test_SOURCES = CPhidget.h \ CPhidgetManager.h \ CServo.h \ --- 1,5 ---- ! lib_LTLIBRARIES = libphidget++.la ! libphidget___la_SOURCES = CPhidget.h \ CPhidgetManager.h \ CServo.h \ *************** *** 13,18 **** CServoController.cc \ CUID.cc \ ! CUniqueDevice.cc \ ! main.cc # These are not active yet --- 13,17 ---- CServoController.cc \ CUID.cc \ ! CUniqueDevice.cc # These are not active yet *************** *** 29,34 **** ! phidget_test_LDADD = ../libphidget/libphidget.la ! phidget_test_DEPENDENCIES = ../libphidget/libphidget.la CXXFLAGS = -I../libphidget -L../libphidget --- 28,33 ---- ! #phidget_test_LDADD = ../libphidget/libphidget.la ! #phidget_test_DEPENDENCIES = ../libphidget/libphidget.la CXXFLAGS = -I../libphidget -L../libphidget *************** *** 36,40 **** clean-generic: ! @RM@ -f *~ if DOXYGEN_ENABLED --- 35,39 ---- clean-generic: ! @RM@ -f *~ .*~ if DOXYGEN_ENABLED --- main.cc DELETED --- |
From: Vadim T. <vt...@us...> - 2002-09-07 21:56:58
|
Update of /cvsroot/libphidget/libphidget In directory usw-pr-cvs1:/tmp/cvs-serv4882 Modified Files: configure.in Log Message: Changed the directory layout and functionality: - ./src/phidget++ now contains the libphidget++ library components - ./src/examples now contains the, ahem, examples Index: configure.in =================================================================== RCS file: /cvsroot/libphidget/libphidget/configure.in,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** configure.in 7 Sep 2002 20:12:29 -0000 1.2 --- configure.in 7 Sep 2002 21:56:54 -0000 1.3 *************** *** 86,89 **** --- 86,90 ---- src/libphidget/Makefile src/phidget++/Makefile + src/examples/Makefile )dnl |
From: Vadim T. <vt...@us...> - 2002-09-07 21:56:57
|
Update of /cvsroot/libphidget/libphidget/src/libphidget In directory usw-pr-cvs1:/tmp/cvs-serv4882/src/libphidget Removed Files: main.c Log Message: Changed the directory layout and functionality: - ./src/phidget++ now contains the libphidget++ library components - ./src/examples now contains the, ahem, examples --- main.c DELETED --- |
From: Vadim T. <vt...@us...> - 2002-09-07 21:56:57
|
Update of /cvsroot/libphidget/libphidget/src In directory usw-pr-cvs1:/tmp/cvs-serv4882/src Modified Files: Makefile.am Log Message: Changed the directory layout and functionality: - ./src/phidget++ now contains the libphidget++ library components - ./src/examples now contains the, ahem, examples Index: Makefile.am =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.am 7 Sep 2002 20:12:29 -0000 1.2 --- Makefile.am 7 Sep 2002 21:56:54 -0000 1.3 *************** *** 1 **** ! SUBDIRS = libphidget phidget++ --- 1 ---- ! SUBDIRS = libphidget phidget++ examples |
From: Vadim T. <vt...@us...> - 2002-09-07 21:53:26
|
Update of /cvsroot/libphidget/libphidget/src/examples In directory usw-pr-cvs1:/tmp/cvs-serv4283/examples Log Message: Directory /cvsroot/libphidget/libphidget/src/examples added to the repository |
From: Vadim T. <vt...@us...> - 2002-09-07 20:12:35
|
Update of /cvsroot/libphidget/libphidget/src In directory usw-pr-cvs1:/tmp/cvs-serv10661/src Added Files: .cvsignore Makefile.am Log Message: Merged the MULTIPLATFORM branch back to main |
From: Vadim T. <vt...@us...> - 2002-09-07 20:12:34
|
Update of /cvsroot/libphidget/libphidget In directory usw-pr-cvs1:/tmp/cvs-serv10661 Added Files: .cvsignore COPYING ChangeLog INSTALL Makefile.am NEWS README acinclude.m4 bootstrap configure.in Removed Files: Doxyfile LICENSE Makefile Log Message: Merged the MULTIPLATFORM branch back to main --- Doxyfile DELETED --- --- LICENSE DELETED --- --- Makefile DELETED --- |
Update of /cvsroot/libphidget/libphidget/src/phidget++ In directory usw-pr-cvs1:/tmp/cvs-serv10661/src/phidget++ Added Files: .cvsignore CAnalogIn.cc CAnalogIn.h CDigitalIn.cc CDigitalIn.h CDigitalOut.cc CDigitalOut.h CInterfaceKit.cc CInterfaceKit.h CPhidget.cc CPhidget.h CPhidgetManager.cc CPhidgetManager.h CServo.cc CServo.h CServoController.cc CServoController.h CUID.cc CUID.h CUniqueDevice.cc CUniqueDevice.h Doxyfile Makefile.am TSingleton.h lsphidget.cc main.cc Log Message: Merged the MULTIPLATFORM branch back to main |
From: Vadim T. <vt...@us...> - 2002-09-07 20:12:34
|
Update of /cvsroot/libphidget/libphidget/src/scripts/install In directory usw-pr-cvs1:/tmp/cvs-serv10661/src/scripts/install Added Files: config.guess config.sub install-sh ltconfig ltmain.sh missing mkinstalldirs Log Message: Merged the MULTIPLATFORM branch back to main |