LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Elapsed time controls inside while loop doesnt refresh value

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?

 

 

example.png

0 Kudos
Message 1 of 7
(3,246 Views)

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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(3,230 Views)

 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.

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

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(3,195 Views)

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.

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

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.

0 Kudos
Message 6 of 7
(3,087 Views)

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)


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 7
(3,078 Views)