Page 1 of 1

Get the number of Digital Input channels

Posted: Tue Mar 24, 2020 1:37 pm
by TriviumDeveloper
I'm trying to figure out how to get the number of Digital Inputs (and in a similar fashion, the number of Digital Outputs) that are available.

In Phidget21, if you were using the InterfaceKit you could get the count via the InterfaceKitDigitalInputCollection.count member. You could then loop over the inputs field on the InterfaceKit using this count.

In Phidget22, you don't use the InterfaceKit class anymore, instead you open a DigitalInput on each of the channels. But I can't find a way to know how many channels are available? I could just hard code it (I'm using the DAQ1301_0 16x Isolated Digital Input, so 16 channels), but that seems... wrong from a coding perspective.

I seem to be able to get the number of channels using this code:

Code: Select all

digitalInput0 = new DigitalInput();
digitalInput0.Open();
digitalInput0.GetDeviceChannelCount(ChannelClass.None);
But this seems backwards - normally I should have to know there's a channel available before I connect to it?

Thank you!

Re: Get the number of Digital Input channels

Posted: Tue Mar 24, 2020 1:52 pm
by mparadis
You could use the Phidget Manager to get a list of all available channels, and then use the serial number and channel class to pick out all of the channels from a single device.

Re: Get the number of Digital Input channels

Posted: Tue Mar 24, 2020 2:45 pm
by TriviumDeveloper
mparadis wrote:You could use the Phidget Manager to get a list of all available channels, and then use the serial number and channel class to pick out all of the channels from a single device.
Yep this is what I was looking for. Thanks!