07-25-2008 09:45 AM
07-25-2008 09:19 PM - edited 07-25-2008 09:21 PM
I'm not 100% clear on what you are trying to do and which 2 case structures you are talking about.
In the bottom of cases 1 through5, I see an case structure of that has identical code in the true and false cases. That could all be a subVI. Select the case structure, = comparison and the wires of the two booleans going into it. Choose Edit then create subVI. It will create a subVI out of what you selected. You will likely need to clean up the connector panel on this subVI, and possible fix the names of the controls. Then you can drop the subVI into all the other cases and eliminate the duplicate code.
I noticed in you AutoSBR subVI which is in the True case of that case structure you have a DAQ Create task and a couple of "Create DAQ channels". But you never clear those DAQ channels at the end. If you call this subVI repeatedly, you will be constantly creating resources that will eventually eat up your memory and call your application to crash. You would be better off calling that subVI only once before your loop starts, or use a first call primitive and only execute that code on the first call of the subVI.
Be careful with your wiring, it needs to be cleaned up in some places where the wiring starts to flow from right to left instead of left to right. See the attachment. In here, there is no need for the second first call primitive. Since the true case only gets called if it is the first call, then the second selector must also be true.
As for making any other subVI's, you will have to determine which parts of your code you have in common and turn that into a subVI. If there are any parts that are similar, but vary depending on the case, you will have to use connectors on your subVI connector panel and feed constants into the subVI for whatever differs between the different cases. This may even be feeding in references to different controls.