Page 1 of 1

getPhidgets() returning empty vector

Posted: Sun Oct 16, 2011 6:26 pm
by irazinkov

I modified the PhidgetControlPanel example to include the following lines:

Code: Select all

 manager = new Manager();
            attach_listener = new ManagerAttachListener(this, this.deviceTbl);
            detach_listener = new ManagerDetachListener(this, this.deviceTbl);
            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.

Re: getPhidgets() returning empty vector

Posted: Mon Oct 17, 2011 9:07 am
by mphi
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.

Re: getPhidgets() returning empty vector

Posted: Mon Oct 17, 2011 9:53 am
by Patrick
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.


Re: getPhidgets() returning empty vector

Posted: Mon Oct 17, 2011 12:14 pm
by irazinkov
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,

Re: getPhidgets() returning empty vector

Posted: Sat Jun 13, 2015 2:16 pm
by mraiser
I am having a similar issue. If the Phidget is already attached when I start my app, it is not listed in getPhidgets(). If I physically attach the Phidget after launching my app, it shows up in the list. Is there any way to list Phidgets that were already physically attached to the computer prior to launching the app?

Many thanks,