Separating GLUT animation from variable processing - glut

My question is a very simple one: say I want to run a for loop, and for each sequence of the loop I want the GLUT window to redisplay. However, I want the for loop to be separate from any GLUT method. I don't want the processing of variables which the for loop does to intersect or to be subordinated to the graphical processing functions.

Related

LabVIEW Asynchronous call

I have two VIs. The first VI (AsynchronousCall.vi) performs an "asynchronous call." (see in the following picture)
The following VI (Test.vi) is started by the asynchronous call. (see in the following picture)
The first VI only iterates over an array and starts the Test.vi. An element from the array is passed. This element should then be used in Test.vi. However, the first entry from the array is not passed correctly after the first call.
It follows that my asynchronous program does not receive the correct input data.
Important: In order to recreate the Senario, the front panel of Test.vi can be opened first after the asynchronous call. Because when it's open, it works as intended!
The target/actual comparison is in the following list:
Target value
Asynchronous program should have "Test_0" as input parameter.
Asynchronous program should have "Test_1" as input parameter.
Asynchronous program should have "Test_2" as input parameter.
Asynchronous program should have "Test_3" as input parameter.
Actual value
Asynchronous program is "" (empty string) as input parameter.
Asynchronous program is "Test_1" as input parameter.
Asynchronous program is "Test_2" as input parameter.
Asynchronous program is "Test_3" as input parameter.
How can it be avoided that the string is empty the first time it is called?
The 32-bit version of LabView 2015 is used, but this Senerio also occurs with newer versions (32-Bit LabVIEW 2019)
When you call a VI asynchronously with the Front Panel closed, LabVIEW does not appear to update the values displayed in the controls - this makes sense from a resource perspective as why paint an update to a control that no one can see?
If you were to perform an operation on the passed value in your test VI - such as writing it to a file or some shared queue you should be able to verify that the correct value is indeed passed, just not displayed in control on the front panel. The one button dialog can also be used for debugging this but it might block the open VI reference call in the launcher VI and thus cause your launcher loop to stall. See this discussion on LAVA forums about the root loop and the built-in dialog windows.

Stuck in infinite loop. Any way to break vba into Code when Control+Break doesn't work

I have code stuck.
It might be in an infinite loop.
Not sure.
Is there a way to break the program to stop at the current line of code that it is running on?
I'd like to avoid shutting down excel because I want to be able to catch where in the loop it is, and by going into the code, I will be able to tell how much processing was done. I would like to break into the code, if possible.
It is stuck on hour glass.
Ctrl+Break doesn't seem to work
Seems like the running code has hijacked all the quota that cpu is giving to excel.
If there is nothing I can do now, is there something in the future I can do to where I can more easily break into the code?
I'm thinking that an intermittent wait within a loop might be a feasible solution.
In the future, include a DoEvents inside the loop. It will run a little slower, but you will be able to use Ctrl+Break to stop it from running.
Create a progress dialog when entering the loop and include a Cancel button. Within your loop check for the Cancel signal/event. This also gives you some flexibility on how you react to the Cancel - you could stop the loop and display key information in a new dialog box (for example).
Basic steps to achieve what I have described (not necessarily the most elegant or the most re-useable, but simple enough for those of lesser experience):
create a modeless (not modal) Form with either suitable labels or a progressbar item (for
visual effect). Include a public property (Boolean) for Cancel (e.g.
boolCancel)
Place a button on form and onClick set boolCancel = True
In your main code, show the form just before your problem loop.
while in your loop you can update some label or progress bar on the
form so that you have a visual indication of whether the loop is
doing something of value or if it is now simply spinning its wheels.
How you do this depends on what your loop is doing.
Also while in your loop check your boolCancel value. If true then
display any state information you want and break from the loop.
If your loop ends normally, hide/unload the progress dialog.

Open SubVI, update it multiple times, close it

I have a problem with a task in LabView that I thought would be simple and pretty standard, but I am failing to acomplish it nonetheless.
The task: I have a measurement VI that aquires data in a loop. This may take a while, so I want to show the incomplete dataset to the user "as it grows". This should be done in an extra window so I want (need?) to use a SubVI. I want this SubVI's front panel to open at the beginning of the measurement and close at the end.
I put it in the measurement loop, so it gets called after each new datapoint is taken and can display the updated dataset. I set it to "show front panel when called", so it opens at the beginning of the measurement (first iteration of the loop), just as I want it to. But it doesn't close. If I check "Close afterwards if originally closed" it closes after each iteration of the loop, which is very annoying.
Also I tried calling FP.Open, FP.Run and FP.Close with an Invoke node but then I have no idea how to actually call the SubVI in the measurement loop and feed data to it.
Is there a general misconception in my approach? Or is there an obvious solution I failed to spot?
It sounds as if you have the SubVI displaying the data you want and it's just closing the front panel at the right time that you're stuck on. In that case the simplest way to do it is to keep the VI in the measurement loop, with the Show Front Panel When Called setting checked, and just use the FP.Close method to close the front panel when the loop is finished:
This implies that you're passing all of your acquired data to the subVI every time round the loop; that's not a problem if the size of the data is small, but a more scalable approach would be a producer/consumer pattern using a queue as Joe suggests. To do this:
Create the queue in your top level VI and pass the reference in to your measurement loop
Also pass the queue reference to your subVI, which sits outside your measurement loop
Your subVI contains the consumer loop which waits for data on the queue and updates the subVI's display with it
Don't set the subVI to show its front panel when called; use the FP.Open and FP.Close methods on it in your top level VI to open and close its front panel when needed.
You'll need to give the subVI some way of knowing when to exit when your top level VI is finished; a convenient way of doing this is to force-destroy the queue in the top level VI which will cause the Dequeue Element in the subVI to exit with an error.
Another option would be to keep your subVI in the measurement loop, pass it only the new data each time round the loop, but give it a 'memory' using an uninitialized shift register in which it accumulates the acquired data for display. Search the LabVIEW help for functional global variable for more detail on this approach. Again, use the open/close methods from your top level VI to show or hide the front panel.
Both approaches are workable, good for small project, not ideal for a larger/complicated setup where more precise control over what displayed data is required.
With the first approach you would have to find a reference to the open VI somehow, to manipulate with its front panel state by reference. Say, global variable of VI reference type will work.
With the second approach, what you are missing to call the vi with all the parameters is Call by reference node
For a more controllable approach, I would start the subVI on the start of the program (FP closed) and then communicate panel open/close and data update by firing custom user events to the subVI events structure.
If you use the Producer/Consumer pattern, you can use a queue to send the data as it arrives to another VI.

An effective way to display multiple labels

I am looking for an effective, quick way to show multiple labels in a quick fashion. What's a good way to do this other than replacing all the .text properties of the labels one after another? It is my understanding that whenever you update a .text property the UI has to be repainted which will add to latency if you have 50+ controls to update.
I know threading is an option but when I tried this I didn't see much of a difference as I wasn't able to load 2 labels at once, I still had to wait for the UI thread before the labels would update. What other ways are there to effectively load 50+ labels quickly? The way it is now takes quite awhile(3-4s) and I feel this could be lowered. The information is being taken from a backend system so I don't have the option for datasets/etc.
You have to separate the code that retrieves the data from the database (which you do using a background thread) and the code that updates the UI (which should happen as quickly as possible because you don't want to block the UI for too long).
My suggestion would be to use the BackgroundWorker component to do retrieve the data for all 50 labels. When the BackgroundWorker raises the RunWorkerCompleted event you call the forms' SuspendLayout function, update all the values of the labels and then you call ResumeLayout. SuspendLayout stops a control from redrawing until you call ResumeLayout.
More info: BackgroundWorker, SuspendLayout, ResumeLayout

What is event loop in ios life cycle and what is its usage and what it does?

I need to know what the event loop in the ios life cycle does?.
Can any one suggest me regarding this??
The best answer is probably the one provided by Apple in the "Main event loop" section of the Cocoa Application Competencies for iOS document.
In the main event loop, an application continuously routes incoming events to objects for handling and, as a result of that handling, updates its appearance and state. An event loop is simply a run loop: an event-processing loop for scheduling work and coordinating the receipt of events from various input sources attached to the run loop. Every thread has access to a run loop. In all but the main thread, the run loop must be configured and run manually by your code. In Cocoa applications, the run loop for the main thread—the main event loop—is run automatically by the application object. What distinguishes the main event loop is that its primary input source receives events from the operating system that are generated by user actions—for example, tapping a view or entering text using a keyboard.
Incidentally, if you're relatively new to iOS development, I'd really recommend a read of this document, as it'll answer a lot of questions you probably have.