Jump to content

how organize wide code


Recommended Posts

Good Evening All

sorry if the question is basic but the project that I have written is very large and difficult to manage in g language.

Let me explain better. It is a VI in which three different programs co-exist (3 vi with while loop which make them remain active). The three programs exchange data in real time and manage separate acquisition, data processing and control actuators. Now it becomes difficult to manage the navigation windows and pan, for scrolling and showing the code.

I would therefore like to know how I can do. I thought of the creation of 3 subVI for the three programs so that they will be included in a so called main vi but in that way the 3 subVI do not exchange data with each other. In fact FIFO system allow the exchange of data only if the subvi exits from while loop but so the subvi is closed and the program do not work

isThere no way to hide parts of code in order to better manage the project? or can I work with subroutine or with class in my code

Thank you very much

Cromax

Link to post
Share on other sites

You might want to look into the Producer/Consumer design pattern and the use of Queues. There are certainly many ways to communicate between parallel VIs (global variables, Queues, Notifiers, Action Engines). Based on what little I understand about your situation, I would say the Queue if probably your best bet.

As far as reducing block diagram size (for a main VI), subVIs are your friend, especially if you are performing the same action in different places.

Edited by crossrulz
Link to post
Share on other sites

You were on the right track with your first idea in making 3 seprate vi's. Queues can exchange information in between seperate vi's so if you use queues you will have a handy way of exchanging data in between the seperate vi's. Again, sub-vis are your friend. The world is simply a better place when your vi fits on one screen. :cool:

Link to post
Share on other sites

Amen !

There is no excuse for it not to.

One page is best, but an example of when this can be hard/impossible is with ActiveX/dotNET/Reference-y-type calls with wide nodes.

In this case, as long as you only have to scroll in one direction, thats ok IMO.

Link to post
Share on other sites

One page is best, but an example of when this can be hard/impossible is with ActiveX/dotNET/Reference-y-type calls with wide nodes.

In this case, as long as you only have to scroll in one direction, thats ok IMO.

well. ActiveX and dotNET are banned in my applications rolleyes.gif

Link to post
Share on other sites

thank you very much

but how can I do if i have many connectors for output?!icone is small

Hi Cromax

You could use a Cluster as an output if you wanted to maintain a standardised connector pane e.g. 4x2x2x4

You could also look at Classes.

Link to post
Share on other sites

thanks a loto jgcode but I do not know the function that you tell me to use.

I have also another problem.

thanks again

I use notifiers to communicate between subVIs loaded in the same main VI ,but if the graphics of a subvi had to be displayed in real-time control panel how can I do

to see them again. If I load in the main vi a subVI with its graphics functio on control pannel the graphics windows of the subVI does not appear on the control panel of the main VI.

How can I do?

thanks

Link to post
Share on other sites

If I load in the main vi a subVI with its graphics functio on control pannel the graphics windows of the subVI does not appear on the control panel of the main VI.

How can I do?

thanks

Sounds like you could use a subpanel control on your main VI (top-level front panel) to select between your 3 subVIs. Look at the "Subpanel Viewer.vi" in the Example Finder. (Help -> Find Examples...).

~Dan

Edited by Dan DeFriese
Link to post
Share on other sites
  • 3 weeks later...

sooo... it's kind of a sin to do this in an excercise as simple as this one...

Hey if it works it works? One issue with tying your logical code to your UI code is that you can't easily test your logic. I would say you definitely have scope to use subVIs. How far you what to go with it depends on e.g. What is the life-cycle of the code? Does some one else have to work on it? Will the project be expand to include more functionality? etc...

Link to post
Share on other sites

sooo... it's kind of a sin to do this in an excercise as simple as this one...

Sin? Noooo.

But this is an interesting one. It will fit on 1 screen. Just do a "Clean Up Diagram" with shorter variable names and you're pretty much there. But that's not the interesting bit cool.gif

There is a large number of operations that are identical. Identical operations easily be encapsulated into sub-vis. This not only shrinks your diagram, but also segments it into easy to digest chunks of code.

Consider this piece of code....

this is replicated no less that 6 times.

I would be tempted to do something like this :

It achieves several benedits.

1. it is more compact

2. It is easier to identify repeated functions..

3. It reduces wiring errors

4. It gives more control (you can, for example make it a "Subroutine" for faster execution)

5. You can re-use it .

There are many more places within this piece of code where it could benefit from sub-vis. The net result would be that it will probably fit on 1/4 of a screen and be a lot easier to read/maintain.

There are also a few areas that would benefit from "For Loops" too.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.