LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVI prority

Solved!
Go to solution

Hi,

I am currently working on the monitoring and control software for ground station. Since i cannot attach my whole code, i will try to explain my problem with a little example i made.

 

I have a main vi that has to call two subvis for counting and concatenating strings. My requirement is that when i open my main vi and press the boolean for counitng, the 'counting.vi' should start running. Now (while the counting.vi is still running) i want to be abel to press the string button on main vi so that the counting vi automatically stops and allows the string vi to run. Once the string.vi is done, counting.vi should resume running.

 

Is it possible? I tried changing the execution priorities but it dint work. 

Download All
0 Kudos
Message 1 of 7
(3,190 Views)

There are several solutions to it, and your program wont do what you described anyway. 🙂 

 

Since you're looking at 2 separate processes, use 2 loops in the main.vi. Use a local variable of the stop button to stop the 2nd loop (this is one instance where locals are ok to use).

 

Since you have loops inside your sub vi's they wont stop. Either make them 1 run with some internal memory (shift register for the counter) or you'll get into the use of global variables which is better to avoid. 🙂

 

A more advanced and prettier solution is to set up some User events which both sub-vi's listen to and you can send stop/pause/start-commands to them.

 

/Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 7
(3,180 Views)

I cannot put it in a while loop in the main, they have to be seperate subvis. As i mentioned earlier, this is just an example, in the actuall code i have 5 different subvis for the purpose of monitoring and control of the satellite ground station. If you can show me how to implement the prioity thing in this example i will be able to do it in my project. Just to be clear, it has to be done in a way that one subvi runs all the time while the other is allowed to run whenever interrupted; after which the program goes back to executing the previous subvi. 

May be it has something to do with interrupts instead of priority??? 

 

0 Kudos
Message 3 of 7
(3,153 Views)

Your loop cannot spin if one or two of your subVIs are open because of dataflow. The loop can only go to the next iteration once everything in it has completed. This has nothing to do with priorities.

 

There are many possible solutions. For example you could launch and close your subVIs via the run VI method, etc.

 

Would it be sufficient to run both subVIs all the time, but open/close one of the front panels as needed?

 

What you basically want is a state machine, where, depending on the current state, one or the other subVI is active. I assume your current subVIs are only simple examples. What do your subVIs actually do in the real application?

 


@Mylo wrote:

Just to be clear, it has to be done in a way that one subvi runs all the time while the other is allowed to run whenever interrupted; after which the program goes back to executing the previous subvi. 


Since you seem to have 5 different subVIs, there is more to it than "the other". Which subVI should launch when one returns?

 

Why are there two buttons for two subVIs in your current example if one should run by default? DOn't we only need one button to run the non-default VI? Should one of the subVIs always run or is there also a state where none of them run.

 

If never more than two should be active, maybe you want a radiobutton control to select the active subVI?



Mylo wrote:

May be it has something to do with interrupts instead of priority??? 


 It does not help if you throw around fancy words that have absolutely nothing to do with the problem at hand. A good problem description is all that's needed. Maybe an allen wrench or a vacuum pump can solve the problem??? How about some duct tape??? 😮

0 Kudos
Message 4 of 7
(3,145 Views)

@altenbach wrote:

 What you basically want is a state machine, where, depending on the current state, one or the other subVI is active. I assume your current subVIs are only simple examples. What do your subVIs actually do in the real application? 


In my real application i am using 4 subvis to control 4 subsystems of a ground station via GPIB and RS232. We can choose any subsytem from the main vi and it will open the associated subvi to send command to the subsystem. The fifth subvi is used to monitor ALL the subsystems. So the monitoring subvi is always running to acquire the state of the subsystems. (I have achieved this so far and all the subvis work OK independantly). Now we need the monitoring button on the main panel because the user must be able to turn off monitoring when he wants (so it is not default!!).
Anyways, the system is monitoring and now if the user wants to send some command to a subsystem,he will press the boolean on the main vi. The monitoring vi should pause (or stop) and one of the four vis should start running. Once the command has been successfully sent and acknowledgement received, the monitoring subvi should start running again.
I know its a lot to digest, that is why i made a simple example. 


 

0 Kudos
Message 5 of 7
(3,136 Views)

Sounds like you should use either queues to transfer quests to the loops controlling your widgets OR use an Action Engine or set of AE's to expose the various functions to the various loops. AE's may be better since they can remeber the action of a previous invokation (e.g Set abort).

 

I agree that this has nothing to do with the fancy computer terms.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 7
(3,100 Views)
Solution
Accepted by topic author Mylo

@Mylo wrote:

I cannot put it in a while loop in the main, they have to be seperate subvis. As i mentioned earlier, this is just an example, in the actuall code i have 5 different subvis for the purpose of monitoring and control of the satellite ground station. If you can show me how to implement the prioity thing in this example i will be able to do it in my project. Just to be clear, it has to be done in a way that one subvi runs all the time while the other is allowed to run whenever interrupted; after which the program goes back to executing the previous subvi. 

May be it has something to do with interrupts instead of priority??? 

 


Yes you can and in a well architected application you will almost always have a loop in your main (top level) VI. Without one it is difficult to run multiple iterations. From what you describe you will need parallel tasks to obtain your desired functionality. At a minimum I envision a while loop with an event structure which will process your button presses. Minimually you will also need a parallel task to ru the monitor code. This task would have a basic state machine and will accept meesages from your UI loop (the one with the event structure) to control when it starts and stops. It will even be possible for the user to turn off monitoring for a while and then turn it back on without having to start and stop your application. You may need additional tasks to handle your messages to the subsystems. This depends on what other types of things they may require and how long they will take to process. If they have long processing times you don't want them in your UI task.

 

To find more information about what I am talking about take a look at the producer/consumer examples that ship with LabVIEW.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 7 of 7
(3,089 Views)