I do not know how to title my question but the first thing that came into my mind is this "multi-device software" thing.
I'm an electronics engineering student and interested in instrument control. Using C# for this purpose and have a basic knowledge of C# form applications. Besides, there is a standart command set developed by IVI Foundation named "SCPI Commands". It's an easy approach for instrument control and you can't write some SCPI code for fully functional instrument control system. In here "drivers" take role. Most of the manufacturers provide device drivers when you buy their product. With this driver file you can create fully functional and responsive softwares. Also you can develop your own driver for your own needs. But although SCPI is standart for all kind of instruments, some multi commands are starts to create problem for you. For example you write a code for A brand, but that code does not work for the B brand's same device that does exactly the same thing with A brand's.
The main goal is creating a cable loss calculation software for several coaxial cables. You must use a spectrum analyzer and an RF signal generator to perform this task. We have a couple of spectrum analyzers and lots of signal generators in use.
With one program we have to control all of our devices. This is my problem.
I want to create a responsive software that works for all of our spectrum analyzers and signal generators. How can I do that ? First, I think I can create a driver for each device and the main program choose the correct driver by asking user with a prompt or something like that. But I don't know how to achieve this. Second, I can write the software's main part for each combination of devices and include that part with a .txt file to main software in runtime. I know this is a noob approach but I think I can do this without hassle. And I don't know anything about the first approach. Third, I can write all of the devices' commands for each one in the program and use if conditionals to choose between cases. Or switch-case structure. This is the only way If I can't do this with other options.
You may not understand me until here because I can't describe the problem exactly that's because I'm an amateur software developer.
Assume that you have a signal generator. You want to select frequency 10 MHZ. This is an Agilent 33120A. To achieve this with computer you need to send this command to device.
SOUR:FREQ 10 MHZ
After this, device sets the frequency to 10 MHZ. Let's assume you have another manufacturer's signal generator and to achieve exactly the same thing with this device you may have to send this;
SENS:FREQ 10 MHZ
This two performs the same thing but SOUR and SENS part depends on the device.
To create a program with C# we use an API to communicate with devices. If you use GPIB protocol the API's name is NI488.2. If you use RS232 you may use VISA API etc. Our protocol is GPIB by the way. With GPIB we use wrappers to easily integrate SCPI commands with C# environment. For example after you add GPIB libraries to references you can use this to send command over C# forms interface;
ibwrt("SOUR:FREQ 10 MHZ", "SOUR:FREQ 10 MHZ".Length);
Now I came to my biggest problem. How can I make this part of code to create a successful responsive program ? For example operator using Agilent Signal Generator and Rohde&Schwarz spectrum analyzer. Another operator is using IFR Signal Generator and HP Spectrum Analyzer. But they use the same software. IFR signal generator may use "SENS:FREQ" for the operation.
Before the operation start a prompt can pop-up and ask for the devices' drivers. I don't know. These came to my mind first. But If you were me, how you achieve this ? And if you choose an option please tell me how to do that. I'm stuck with this. And right now program has about 2000 lines of code. "ibwrt" is not the only part of the program, neither "SENS:FREQ"... There is also "SENS:BAND:RES", "INIT:CONT" etc. for other tasks. This is not important.
I hope you understand my question because I know I could not tell correctly.
If you have any question about the problem feel free to comment.
Thanks.
TL;DR
I need to send commands for each devices through C# Forms interface. I mean devices have their special commands and I need to create one software that can control every device with user selection instead of creating a software for each device.