Differentiating multiple appearances of a device

Supporting 2.7 and 3.2+
berkinet
Phidget Mastermind
Posts: 155
Joined: Thu Sep 17, 2009 12:17 pm
Contact:

Differentiating multiple appearances of a device

Postby berkinet » Mon Sep 16, 2019 8:23 am

I have a 1048 temperature sensor. This Phidget has four thermocouple inputs and one onboard temp sensor. When I look for devices on the network in the onAttachHandler I get 9 responses:

Code: Select all

Serial   Phidget        Ch Name                   Ch   subCh
283587 - PHIDID_1048 -- Thermocouple Input       - 28 - 33
283587 - PHIDID_1048 -- Thermocouple Input       - 28 - 33
283587 - PHIDID_1048 -- Thermocouple Input       - 28 - 33
283587 - PHIDID_1048 -- Temperature Sensor (IC)  - 28 - 1
283587 - PHIDID_1048 -- Voltage Input            - 29 - 1
283587 - PHIDID_1048 -- Voltage Input            - 29 - 1
283587 - PHIDID_1048 -- Voltage Input            - 29 - 1
283587 - PHIDID_1048 -- Voltage Input            - 29 - 1
As you can see, the individual inputs attach twice, once as generic voltage devices and once with an identified class name.

I wish to present a user with a list of available Phidgets to select from and would like to use the actual class name rather than the generic name. Is there some straight forward way to do this, or must I resort to using logic I'm my program to discard generic names when a "real" class name is available for the same input?

fraser
Engineering
Posts: 268
Joined: Thu Nov 19, 2009 4:41 pm
Contact:

Re: Differentiating multiple appearances of a device

Postby fraser » Mon Sep 16, 2019 8:40 am

You will have to resort to logic, VoltageInput is not a generic form of the input, but instead a different way to interface with it. Some people need to directly reference the voltage from the thermocouple rather than the calculated temperature. As a result, both are made available as objects.

User avatar
Patrick
Lead Developer
Posts: 3140
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Differentiating multiple appearances of a device

Postby Patrick » Mon Sep 16, 2019 9:44 am

The channel name string is just a descriptive name that we set on a device-to-device basis. For the vast majority of cases, we just use the channel class name. For devices where there are different types of the same channel class, we offer a more descriptive name.

I'm not sure what you mean by 'actual' class name vs 'generic' class name - the actual class name IS the generic class name, and you can get it with getChannelClassName().

If you want to differentiate channels types in code, you should use getChannelClass() and getChannelSubclass() which return enums instead of strings.

-Patrick


Return to “Python”

Who is online

Users browsing this forum: No registered users and 2 guests