LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a better way to do this pop up?

Solved!
Go to solution

I have a VI that has over 900 sub VIs that has been in development since V5 of Labview.  It has a control loop and a data loop.   It currently has a half dozen or so sub vi windows it pops up for different reasons.   Most all get data passed to them but does not need to return data.  I call the sub, it opens and data is passed but it shares time with the main window so I can not edit anything on the main window because the sub keeps grabbing control.

I came up with this solution attached below but it seems there must be a better way?  I am sure I am just missing it.   I need to be able to launch it in one area of the program running on one while loop and pass data to it in another while loop that collects the data all while leaving full control at the main VI.
Thanks for any help.

Download All
0 Kudos
Message 1 of 23
(5,022 Views)

I can't open your VIs because they're 2015 and I'm still on 2014, but I'll give you the general info I think you need.

 

You can launch as many parallel loops as you want in LabVIEW, you just need a communication protocol between them. This is usually a queue: initialize both loops with the queue reference known to each and use the reference to enqueue and dequeue.

 

From the name of your VI, I assume you're launching a popup using a Start Asynchronous Call node. This is fine as long as you include some reference that you can use within the subVI to get information. The simplest would be a Global Variable, but that's not the way to do it (race conditions galore). Ideally a queue, maybe a notifier.

You also need to get the reference to whatever you're using to communicate over to the other loop that is collecting the data. That part would depend entirely on your current architecture.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 23
(5,013 Views)

I am not sure what you are trying to do here but I receive this error when running your code.

 

Error 1026 occurred at Invoke Node in AsyncOpenVi.vi

Possible reason(s):

LabVIEW: VI Reference is invalid

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 23
(5,007 Views)
  • Your lower loop uses 100% CPU until it gets a reference.
  • You cannot guarantee that the stop resets to FALSE, the local variable can be potentially written in parallel of the while loops starting. In the worst case, one or even both loops might stop immediately. (wiring the FALSE ot the loop boundary does not affect the branch to the local variable.
  • Your "AND(invert)" of a boolean with a FALSE diagram constant is pure Rube Goldberg code. (result is true no matter if there is an error or not!)
  • ...
  • Maybe you can create a shared popup window that just collects all warning and appends/prepends them to a list. It could be an action engine that returns imemdiately but pops its front panel frontmost whenever an item is added.
  • ...
0 Kudos
Message 4 of 23
(5,003 Views)

An error will occure if the two VIs are not in the same folder

0 Kudos
Message 5 of 23
(5,000 Views)

@altenbach wrote:
  • Your lower loop uses 100% CPU until it gets a reference.
  • You cannot guarantee that the stop resets to FALSE, the local variable can be potentially written in parallel of the while loops starting. In the worst case, one or even both loops might stop immediately. (wiring the FALSE ot the loop boundary does not affect the branch to the local variable.
  • Your "AND(invert)" of a boolean with a FALSE diagram constant is pure Rube Goldberg code.
  • ...
  • Maybe you can create a shared popup window that just collects all warning and appends/prepends them to a list. It could be an action engine that returns imemdiately but pops its front panel frontmost whenever an item is added.
  • ...


Yes the lower loop is simulated data colection so it needs 100% attention.

 

I am not worried if the stop works perfect or not.  It is just an example of what I am trying to do.

 

Thanks.  I did want to impress someone 😕

 

It is window "Sharing" that is the problem"  Maybe some example code would make you point clearer to me.

0 Kudos
Message 6 of 23
(4,989 Views)

Yes the lower loop is simulated data colection so it needs 100% attention.

 

??? Smiley Surprised

 

0 Kudos
Message 7 of 23
(4,944 Views)

Ok so I went back and your right, a wait got moved and not copied out of the lower loop.

Now that we are over bashing my poor skills I still have a job to do, I still spend loads of money at NI and I still started all this before most of the features LV has today so my programming is self taught and old school. Real feedback on my problem would be nice anyway.

I want a sub window graph to pop up, pass continuous data to it from the main vi and have the pop up not interfere with the operation of the main vi. I am hoping I am trying to do a simple task the hard way with my example.

If I move the pop up VIs to a separate loop in the main vi (That will make 6 loops running), then pass the data when open using global variable will one window not interfere with the other or is the only way to do like my example and open a async reference?
?

0 Kudos
Message 8 of 23
(4,888 Views)

As a simple solution, all you probably need is a popup subVI that does not contain any loops and returns immediately so the main code does not stall.

 

Set its windows appearance to show the front panel when called, but don't close afterwards. This will make the panel stay open for inspection while the main program continues and you can close it at any time with the [X] in the upper right corner.

 

99% less code and 99% fewer places where bugs can hide! 😄

0 Kudos
Message 9 of 23
(4,875 Views)

I'm not sure where you think that personal attacks on your coding skill were taking place but I only see valid criticism in this thread.

 

One thing I saw is that your code is pretty static.  You mentioned if you wanted 4 windows you'd need 4 loops, and that isn't necessarily true.  You could have an array of references that contains all of your floating windows.  Then you could pass data to and from each of them using something like a queue or user event.  Working with controls can work, but gets clunky and I never have a good way to send data back.  User events are usually what I choose so I can have UI events, and request events in the same place, assuming I neither interrupts my state machine for long.

 

Oh one other thing I haven't seen mentioned yet is how cleanup needs to make sure it closes these floating windows, and close references appropriately.

0 Kudos
Message 10 of 23
(4,871 Views)