Phidget22 API Discovery and Enumeration

Comments & issues
Post Reply
Steve
Phidgetsian
Posts: 5
Joined: Fri Sep 22, 2006 10:31 am
Location: MSP, MN, USA
Contact:

Phidget22 API Discovery and Enumeration

Post by Steve »

I have been doing a deep dive into the discovery and enumeration mechanisms of the Phidget22 API after quite a while away from the ecosystem (I have Phidgets that are old enough that they don’t even appear on your Discontinued Products page :) ). As others before me have done here in the forums, I am using the Windows Control Panel as a baseline of sorts for guidance using observation and inference. I want to make sure that I have a solid grasp of the multithreaded event model using the code snippet below as a simple example:

Net.ServerAdded += Net_ServerAdded;
Net.ServerRemoved += Net_ServerRemoved;


_Manager.Attach += Manager_Attach;
_Manager.Detach += Manager_Detach;


Net.EnableServerDiscovery(Phidget22.ServerType.DeviceRemote);


_Manager.Open();


Not shown, but locks are employed in the event handlers.

I am specifically interested if Manager (attach) events for a Wireless VINT Hub (HUB5000_0) would ever be received before Net (added) events. I’ve not observed this to be true, but want to be very defensive in my approach.

Also of interest would be if Sensors ever attach before the Hub does for a Wireless VINT Hub (HUB5000_0). Again, I’ve not observed this to be the case, but don’t want to make any assumptions.

Is there any guarantee at all regarding the order the events are received (both intraobject and interobject)? It seems as if perhaps not, but want to verify. I may have missed it, but I didn't see anything in the documentation regarding such.

When trying to construct a hierarchical representation of a Phidget deployment, using the Phidget ‘Channel’ model is interesting in that it is of course a very denormalized / flattened view. Constructing a tree view using the event data is not a huge hurdle but when receiving event data that can be at any ‘level’ of a hierarchy, one must aware of that fact and be ready to build either top down or bottom up as the need arises.

Thanks.

Phidget22 - Version 1.16 - Built Jul 7 2023 09:13:43 / 1.16.20230707 / .NET 7.0
User avatar
Patrick
Lead Developer
Posts: 616
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Phidget22 API Discovery and Enumeration

Post by Patrick »

Hi,

The library doesn't connect to a server until after the serverAdded event - so you won't even see manager channel events from a server until you return from the serverAdded event.

Manager events are always sent in a predictable order, one at a time. For each device, we walk all of it's channels. For VINT hubs, we then walk hub port channels and VINT device channels in order.

The control panel uses getParent() on incoming channels to construct the tree view - the Parent of a channel is it's device. The parent of a device is either a VINT Hub (for VINT devices) or null.

-Patrick
Steve
Phidgetsian
Posts: 5
Joined: Fri Sep 22, 2006 10:31 am
Location: MSP, MN, USA
Contact:

Re: Phidget22 API Discovery and Enumeration

Post by Steve »

Thanks for the insight here. Having a deterministic sequence of events does simplify things. Cheers-
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 37 guests