LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Structure in both Main Vi and in Sub Vi with separate queues

Hi all,

 

So I'm trying to design a Main VI which has a Subpanel and a Ring Enum to switch between two different SubVIs.

 

The Main VI would have a Producer/Consumer loop and Queue to first initialize the DAQmx and the Event structure handles the Subpanel (Inserting/Removing VI). It's important that the DAQmx is initialized and Read on the Main VI so that when the Sub VI can be inserted and removed multiple of times into the Subpanel without throwing the DAQ into error. 

 

However, the Sub VI would also have a Producer/Consumer loop with Queues with Events that the user fires via buttons. The data acquired by the DAQ is always shown in the Main VI but when the SUB Vi runs, an automated process change occurs and a separate indicator on the front panel of the Sub Vi would 'freeze' some of the new data.

 

My question is:

 

Is it possible to have two separate queues running in a Producer/Consumer structure (one in the Main VI and one in the SubVI)? The two queues would have nothing to do with each other. One would control the buttons in the Main VI and the other on the SubVi front panel which will appear in the Subpanel of the Main VI. Or will some process be trapped in the while loop somewhere? e.g Main VI control not working while Sub VI is running.

 

 

0 Kudos
Message 1 of 5
(2,424 Views)

@nikvl wrote:

However, the Sub VI would also have a Producer/Consumer loop with Queues with Events that the user fires via buttons. The data acquired by the DAQ is always shown in the Main VI but when the SUB Vi runs, an automated process change occurs and a separate indicator on the front panel of the Sub Vi would 'freeze' some of the new data.


Sounds like you are locking the front panel during a "long" process inside of an event case in the subVI.  Could you share some code that shows the issue?  You are using too many terms that mean a lot of things and it is not quite clear what your structure is.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 5
(2,395 Views)

Sorry but the VIs are only partly/not done so at this stage is just conceptualizing how it would run. Maybe it's easier to describe what should happen.

For better visualization. there's a picture of the front panel attached 

 

So the Main VI front panel has

1) A Subpanel 

2) An indicator for data acquired by the DAQ e.g pressure

3) A Menu Ring (so that user can choose between 2 SubVI)

 

SubVI 1 front panel has

1) 2 Indicators, A and B (separate from MainVI indicator)

2) Start button 

 

SubVI 2 front panel:

1) Buttons, no indicator

What is supposed to happen:

1) When the user first opens the programme, the DAQ is initialized and data reading starts.

2) Data displayed on indicator on Main

3) User chooses a SubVI from the Menu Ring, Sub VI is inserted into Main

4) User clicks on Start button on front panel of SubVI (No further input from user is required for the SubVI except for an emergency stop button just in case)

5) What the SubVI does is: Some valves will shut for a certain amount of time (let's call it Process A), then open, then another set of valves is closed (Process B). 

6) Pressure data is always shown in Indicator on Main (so user can always view the 'real-time', so to speak) and is always changing according to the valve movement. When Process A happens, an Indicator A on the Sub VI will show the pressure values at the end, then Process B starts and the data is shown on a second Indicator B but meanwhile the data in Indicator A should stay 'frozen'. 

7) When both Process A and B is done, the User can change the Menu Ring to another SubVI or press Start again for the whole thing to repeat. 

The data is displayed for as long as the user doesn't press Start again.

 

The second Sub VI will just consist of buttons for the User to manually control the valves and data is displayed on the Indicator already on Main VI

 

I was thinking maybe the SubVi should be a state machine with an Event structure and Queue (is a queue even necessary here?). When User press start, Process A, the 'frozen' values would be just those wired outside the while loop.

 

But the Main VI would also have an Event structure for when the User changes the Menu Ring and Stop button (not shown in picture) to stop the programme and a Queue for initializing and reading DAQ. 

 

I apologize in advance for posting JPEGs rather than actual code because it was very quickly made for this example and please ignore all the incomplete unwired error and queue wires. 

0 Kudos
Message 3 of 5
(2,353 Views)

I hate to find myself writing this, but it sounds like you might actually be better taking a look at tab controls...

 

The two VIs aren't simultaneously doing anything - you're switching between sets of functionality with different controls and indicators.

 

Caveat: tab controls are terrible for modularisation and make your block diagram explode in size if not careful, but since you'll probably then only need a single Event Structure and different cases will handle the states regardless of the tab control, it shouldn't be an issue.

You might want to disable the tab control when you click start (and re-enable when your subprocess finishes) if you choose to try this 


GCentral
0 Kudos
Message 4 of 5
(2,342 Views)

The two VIs aren't simultaneously doing anything - you're switching between sets of functionality with different controls and indicators.

True for the controls, but the indicator on main vi is probably going to be linked somehow to the sub vi's indicator (except that it goes outside of the while loop to 'freeze' it) to avoid throwing the DAQ into error

 

I did consider tab control but my programme is going to be more complicated (There's probably already going to be a tab control for one of the options in the custom menu bar for the user to change different parameters) and....yeah. Trying to avoid it as much as possible unless absolutely necessary 

 

Of course I could also just have the SubVI front panel as a pop-up but that feels inelegant and having more than one stop button will confuse users because I have to make it as easy and uncomplicated as it's possible for future users who wouldn't be able to troubleshoot the executable.

 

Also, if the SubVI's start button is pressed and once Process A starts, I wouldn't want the user to change the subpanel into the other SubVI or switch back and forth (who knows because operators are bored 😛 )  until it finishes

0 Kudos
Message 5 of 5
(2,336 Views)