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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I optimize the structure of my code?

Hi all,

 

I'm doing a continuous synchronized AI/AO/DO tasks, under lv 8,5. And the users are able to write the data to the file and also display it when running. So I involved queue to write the data to the file, and a notifier to display it. But as the functions grows, the programme grows too big. Now it is hard for me to see them without scrolling back and forth (so, sorry, i can't get a snapshot). The following is my code. 

 

I tried to put the code in a state machine.  And I set the states as "Set configuration(idle)", "load waveforms files", "Set up AI/AO/DO tasks", "Acq&write&display", "close&release". And I used subVI to sustitude the blocks. Then I met with 2 problems:

1. I want to display the front panel of the subVI "Acq&write&display" , I failed to do that without (functional) global variables. So I divide this subVI to "acq", "write" and "display" subVIs.

2. The consumer loops of both the queue and notifier won't stop until they are released. The result is, the state wont change to the last "close &release" state because the consumer loops are all waiting. I then combined the last 2 states together like "acq&write&display&close" state...

 

Again, my code get messed up. Is there any way to optimize it? It is a long question and an annoying problem, thank you all for any suggestion.

 

Best wishes,

Bo 

------------------------
My blog Let's LabVIEW.
0 Kudos
Message 1 of 5
(2,392 Views)
Sorry, I dont know why i cant upload the vi at all.
Message Edited by foolooo on 10-01-2008 07:18 PM
------------------------
My blog Let's LabVIEW.
0 Kudos
Message 2 of 5
(2,391 Views)
 
------------------------
My blog Let's LabVIEW.
0 Kudos
Message 3 of 5
(2,387 Views)

foolooo wrote:
Sorry, I dont know why i cant upload the vi at all.

Try a different browser. Currently Safari and google chrome have some problems uploading VIs. You can also try to zip the VI before uploading.

Message 4 of 5
(2,369 Views)
Thank altenbach, and here are the VIs. The previous one and the later one.
------------------------
My blog Let's LabVIEW.
Download All
0 Kudos
Message 5 of 5
(2,341 Views)