From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-02-2010 02:14 PM
Hi all,
I am a "groupaholic". What I meant is that I like to group a lot of functions in a single subvi. Sometimes, I think it is a great idea, and sometimes, it isn't so bright. I have a question.
I am thinking about creating a subvi that would allow me to choose what command I want to issue to MOBUS. I have about 40 commands. I have the approaches below. Please give me some suggestions.
1. a subvi with a enum input for command, and a generic array input for cmd parameters.
- pro: I can group all commands under this subvi.
- con: the cmd parameters array will not be descriptive at all. The user needs to know exactly what to input for each cmd.
2. grouping cmd with the same type of paramters under a sub, so one subvi will exist for each type of cmd. The subvi will have a enum input for command, and a enum input for parameter
- pro: descriptive command parameters.
- con: hard to describe each subvi
3. create one subvi for each cmd and group them under one polymorphic vi with enum cmd parameter input.
- pro: very descriptive.
- con: a lot of files to manage
Please give me some suggestion.
Yik
03-02-2010 02:29 PM
03-02-2010 03:09 PM
The question you ask isn't that much different than writing a regular instrument driver. You could (taking a power supply as an example):
I think the monolithic VI in this case is a bad idea. If you want to add functionality you have to add to your enum and make an already large VI big. Also, what happens if the VI gets corrupted?
The instrument drivers that you get in NI's IDNET tend to be the second option.
I always take the third approach unless you HAVE to set another parameter when you want to set some parameter. Why? Well, because I don't want to have to remember what I set the OV point to if I just want to change the voltage. I believe that instrument drivers should work similarly to the way you use instruments. Last time I checked when someone is twiddling the voltage knob they're not simultaneously setting the OV point, the current, the current limit, etc., etc.
That said, there are cases where the monolithic approach is the best. For example, in the test executive I have I call a top-level "test" VI. I pass in the name of the test to run (as a string), and the parameters for the test (as a string). This test VI calls the appropriate test and passes in the parameters (still as the same string). The test itself parses the parameters as it needs to. In this case the monolithic approach is best since the exec shell always sees the same signature for test modules.
03-02-2010 03:32 PM
I would say that in almost all circumstances many single purpose VIs are much *EASIER* to manage than a single monolithic VI (whether is be drivers, APIs, whatever). Not only can you have proper inputs (ie descriptive and appropriately flagged as "Required" / "Recommended" / "Optional") but as it was already said, the individual VIs can have descriptive VI descriptions and icons.
In addition, in 6 months when you need to make a change to one of the commands to extend the functionality of one of the commands, you change one single VI - the rest of the driver hasn't been touched and should therefore carry on working exactly as before (something that cannot be said for a monolithic VI). In addition if Source Code Control is used, you will be able to see through the change logs which functions are changed with time, etc.
My final point is really aimed at people with more than one LabVIEW developer working on a project - when you have separate VIs per function, etc the chances of somebody mistakenly making a change where the shouldn't is dramatically reduced.
03-03-2010 02:40 AM
03-03-2010 09:01 AM
rolfk wrote:
For the problem of related but not necessarily depending operation of parameters in one single VI I like to use a default option for the parameters that says "don't change" so unless you wire that input, it simply does nothing for that parameter.
Good point. I also do that, and should have mentioned it. Now, how come the NI instrument driver guidelines don't say that?
NOTE: It was not my intention to turn this thread into an instrument driver bashing thread. I'm just using them as an example of an instance of when to create one large monolithic VI, several subVIs with grouped controls, or separate subVIs for each action.