Products for USB Sensing and Control
It is currently Fri May 24, 2013 4:36 pm

All times are UTC - 7 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Oct 16, 2011 6:26 pm 
Offline
Fresh meat

Joined: Sun Oct 16, 2011 6:15 pm
Posts: 2
Hi,

I modified the PhidgetControlPanel example to include the following lines:
Code:
 manager = new Manager();
           
           
            attach_listener = new ManagerAttachListener(this, this.deviceTbl);
            detach_listener = new ManagerDetachListener(this, this.deviceTbl);
       
            manager.addAttachListener(attach_listener);
            manager.addDetachListener(detach_listener);
           
            manager.open();
**addition**
            Vector phidgets = manager.getPhidgets();
            Boolean list_2=phidgets.isEmpty();
                       
            jTextArea1.insert(list_2.toString(), 0x0);
 **end of addition**           


jTextArea1 is just a text box in the panel. I'm using NetBeans.

The *.isEmpty() method always returns true, however, i can see the model and name of the attached stepper motor controller. See attached image for the exact output.


Attachments:
Picture 1.png [23.72 KiB]
Not downloaded yet
Top
 Profile Send private message  
 
PostPosted: Mon Oct 17, 2011 9:07 am 
Offline
Phidgetly

Joined: Tue Nov 16, 2010 4:27 pm
Posts: 45
After calling open, the library needs time to detect for an attached Phidget. The Vector that is returned by getPhidgets() is updated right before the attach event triggers.

To ensure that the library has enough time to detect the Phidgets, you can put getPhidgets() in the attach method.


Top
 Profile Send private message  
 
PostPosted: Mon Oct 17, 2011 9:53 am 
Offline
Lead Developer
User avatar

Joined: Mon Jun 20, 2005 8:46 am
Posts: 2351
Location: Canada
Or, you can just put a small sleep - ~200ms after calling open, and it will have had time to fill the list with any attached Phidgets.

-Patrick


Top
 Profile Send private message  
 
PostPosted: Mon Oct 17, 2011 12:14 pm 
Offline
Fresh meat

Joined: Sun Oct 16, 2011 6:15 pm
Posts: 2
Hi guys,

thank you, i was thinking exactly along those lines. I guess just wasnt sure of it. Anyway, the Thread.sleep(200); works perfect.

thank you,
ivan


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group