Get the number of Digital Input channels

Supporting Visual Studio on Windows
Post Reply
TriviumDeveloper
Fresh meat
Posts: 2
Joined: Tue Mar 24, 2020 1:14 pm
Contact:

Get the number of Digital Input channels

Post 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!
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Get the number of Digital Input channels

Post 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.
TriviumDeveloper
Fresh meat
Posts: 2
Joined: Tue Mar 24, 2020 1:14 pm
Contact:

Re: Get the number of Digital Input channels

Post 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!
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests