01-20-2016 01:52 AM
Hello,
I have problem with my program. I would like to print elapsed time in seconds inside while loop but the problem is the indicator update value only when I move my mouse on button [Case Event]. Any ideas why and how to correct it?
01-20-2016 02:04 AM - edited 01-20-2016 02:09 AM
Hi kamill,
THINK DATAFLOW!
the indicator update value only when I move my mouse on button [Case Event].
Yes, that's how you programmed it to work.
Again: THINK DATAFLOW and you will know why it behaves this way…
Any ideas why and how to correct it?
Remove the event structure. Replace it by a simple wait function with a reasonable input value!
Or add a timeout event to your event structure with the same reasonable time value…
What's the purpose of the "mouse move on button" event?
01-20-2016 02:21 AM
Ok, but i though dataflow is like:
Keep updating indicator inside while BUT when i enter on button then -> i'm getting inside mouse move event structure so updating stops.
This example is not my actual program, its just a sample of my problem.
In my program i can't remove event structure cuz i need mouse move event for my array to gets my mouse coords -> change them to correct array index. I also need timer to count 60 seconds and displaying it at the same time. If timer = 60 sec then stop while.
01-20-2016 02:40 AM
Hi kamill,
DATAFLOW: a node (structure, loop, whatever) is executed when all inputs are availabe or when all nodes inside your structure have been executed.
Result: your loop will iterate when the event structure has been executed.
Result: your indicator will be updated when the loop iterates. The loop iterates after the event structure has executed. The event structure executes on a "mouse over button" event…
Again: THINK DATAFLOW!
01-20-2016 05:07 AM
Ok, so i read about Multithreading and the answer is so simple. I just created two separeted while loops, one for mouse event and one for time elapsed 🙂 and now everything works fine.
01-21-2016 11:24 AM - edited 01-21-2016 11:24 AM
That's a solution. Probably the more scalable and correct answer too.
But just for completness I'd like to mention that you can do this in one loop. Just cause the event structure to timeout, and not always wait for a mouse event to execute. When you first drop an event structure there is a timeout event which happens if enough time has gone by. That amount of time is specified by the upper left terminal on the sturcure. Wire a constant of 500 and every 500ms the timeout case will be called, and your while loop will iterate again.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
01-21-2016 11:43 AM
You have a missunderstanding on how Dataflow works. For the while loop to iterate the event structure must execute one event. The indicator can only be updated once per loop iteration. WORSE, that is an infinate loop! you can't stop that code without using an abort! (Generally Bad, Bad ,Bad)