09-19-2008 01:12 PM
Hello,
I have currently written 2 standalone applications (Visual C# .NET with Measurement Studio). The first application uses an NI 6008 (usb device), the second uses a NI 9234 thru a USB 9162. Both applications work well on my developement machine. However, if I put the applications on another machine, the Dev# might not agree with the numbers that occurred on my development machine. The result is that the applications fail.
What I would like to do at application startup is poll the system for NI devices that are currently plugged in and let the user select the one they want to use from the list. I created my application by using MAX to do all the dirty work for me. Can I easily change/modify that code to let me poll the system and then replace the MAX compiled device name with the user selected one?
Hope that this makes sense...
ttyl
09-22-2008 07:06 PM
Hey holdfast,
This functionality is actually already built into most of our DAQmx examples. A good example to start with is the AcqVoltageSamples_IntClk example that is located here: C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET2.0\Analog In\Measure Voltage\AcqVoltageSamples_IntClk\cs
You could either modify this example to fit your application or since it sounds like you've already developed two applications on your own, the code that you are interested in starts on line 111. This is where they populate the ComboBox with the available DAQmx channels.
Hope this helps!
Lars
09-23-2008 01:27 PM
Hello Lars,
Well I have had some success. Essentially I cribbed part of the code from the example and came up with the following:
1. I embed some code in the Configure() code that Max has created. I am able to get all of the information regarding all the devices currently connected.
2. I can check to see if there is only 1 9234 connected and then use the string id to manipulate the code for the task configuration that was hardcode to something like "Dev1/..."
3. I can also check to see if there are no 9234's connected and then put a message out to the user thru a message box.
4. I can check to see if there are multiple 9234's connected and output this message to a user. but have no way of getting them to select one over an other.
I guess that what I need to do now is figure out a way to get a dialog to pop up from the max Configure() code.
Alternatively I can look at probing the system before I create the task and then overload a constructor for the task with the user's select instrument and serial number.
I am a little concerned that I really should have done this without using max at all...
Why doesn't the max created code template foresee the possiblity that the computer could have more then one device of the same type (with different names) or different devices with the same name. It seems to me that the device name created by Max is next to useless. Really what we want to be able to do is define a device type (say 9234) for our application, and have the max code connect to the only one if only one is used or prompt the user to select one from a list based upon serial number if more then one is connected in a computer.
Thanks for your help, I hope that this isn't too confusing.
09-23-2008 02:00 PM
Hello All,
OK...spoke too soon. Added a dialog into the Configure() code to pass the serial number information to the user in a listbox. Then the user can select the value they want from the listbox.
Borrowed a 6008 from a friend. So now I have 2 6008's plugged into my machine.
Big Problem is now this:
The serial number contained in the device information does not match the serial number on the case of the 6008. Not even close.
So...unless I am doing something stupid (possible) it appears to me that there is no way to distinguish physically between multiple units on the same machine?
Why doesn't the serial number (in software) match the one on the case?
Thanks
09-23-2008 02:03 PM
I did do something stupid...
Serial number is a hex code...
Works great...Painful to arrive at but works great...