LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

unset event?

Hi all.
 
I want to have a light that turns on on mouseMove and turns off if no mouseMove is detected during some period.
 
The problem I have and can't find a solution for is the first event structure detecting the mouse movement that kepps executing.
 
How can I unset the mouseMove event so the event structure waits for the next mouse movement?
 
Thank you, Ondra
0 Kudos
Message 1 of 11
(3,730 Views)

why not simply use a "elapsed time" in the timeout event.

this might require some tracking of time of last event, but should be fairly simple:

on mouse move, record time and turn button on.

in timout, check every 50ms the time elapsed versus the previously recorded one. if above the time set by you, then a case selector becomes true in which you set the property of the button to false.

is it what you asking for? could you post the vi?

 

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 2 of 11
(3,712 Views)
First of all, do you have two event structure in the same while loop?
Handling two event structures in one VI is mentioned in the vent structure "Cevaets" (don't know if I spelled it OK) of the event structure help.

If so, remove one of them and add the registered event to the remaining. Then try again.

Regards,
André


Regards,
André (CLA, CLED)
0 Kudos
Message 3 of 11
(3,712 Views)
oops Andre is right, i didnt saw the pic
never two event structures! you can put all in one.
-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 4 of 11
(3,700 Views)

I'm not sure exactly what you want to do, but the two event structures in the same loop are definitely your problem.

I think this might actually be answered by one of the examples in a nugget I started writing a while back.


___________________
Try to take over the world!
0 Kudos
Message 5 of 11
(3,690 Views)
Thank you to both of you for trying to help.

Two event structures: I saw it in the manual, tested both and they yield the same behavior: the mouseMove event keeps executing.

I'll try to explain the problem better: I have a light source in my lab that I forget to switch off quite often. Since the bulbs are quite costly and there is a serial port on the light source, I decided to try to make a kind of timer in labview: when I move the mouse, the light source turns on (the mouseMove event); then after a while the light source is turned off (the timeout event).

The program begins as wanted: the light is off, an event is awaited; then on mouse move the light is switched on; after a while the light is turned off. But since the mouseMove event structure keeps executing, it's immediately switched on. So what I need is to tell it "forget that the mouse moved previously, lets wait for another mouse movement". But how do we "reset" an event that has already been registered? Can't find anything in this sense. Are event structures the good solution for my problem?

Thanks in advance for any help.
0 Kudos
Message 6 of 11
(3,669 Views)
i think if you just add the event from the second event structure into the first structure, your problem will be immediatly solved.
event structures are the right way to do it.
 
post your vi, we can look at it fully.
-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 7 of 11
(3,663 Views)

I can think of two simple options:

  1. Use my example and a boolean shift register. When the move event fires check the boolean and if it is F use a case structure to turn on the light and then set the boolean to T. If the boolean is T, simply pass it through.
    In the timeout event, turn off the light, set the timeout shift register to -1 and set the boolean SR to F.
    That way, after the timeout executes (x ms after you stopped moving the mouse) the light will go off and the event structure will go to sleep because of the -1 timeout.
  2. Use the mouse input VIs (search the palettes) and poll once every few seconds. If the position did not change for several times in a row (again, use a shift register), you know the mouse stopped moving and you can turn off the light.

I'm guessing you will actually have to use #2, because #1 will only be useful when the VI has focus and I assume most of your work will be done in other programs. Smiley Happy
You shouldn't be concerned about polling. If you do it once every second or two, you should be fine.


___________________
Try to take over the world!
0 Kudos
Message 8 of 11
(3,650 Views)
I made a test vi to enable you to see what thappens withou the light source, it's attached. Seems to me that one event structure doesn't solve the problem. (It did not before I posted the first message...)

The coords can be used as a solution to my problem. But even I'm not forged by LV I feel like there is a proper way to handle it.
0 Kudos
Message 9 of 11
(3,633 Views)

Did you look at my previous example?

You really should learn how shift registers work.

Here's another example, based on your recent one.


___________________
Try to take over the world!
Message 10 of 11
(3,627 Views)