Get the number of Digital Input channels
Posted: Tue Mar 24, 2020 1:37 pm
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:
But this seems backwards - normally I should have to know there's a channel available before I connect to it?
Thank you!
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);
Thank you!