LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event structure

Hello All

 

The attached vi is quite simple. It is an event structure inside a for loop, with some other code (current time compared to fixed time value).

 

When the vi starts, the first iteration of the while loop happens (as evidenced by the time update in the time string indicator). Successive loop iterations, I assume occur,  but it seems that whatever happens inside the event structure function stops the extra code in the while loop from performing (as evidenced by the indicator not updating in the time string indicator)

 

I'm not arguing that this is incorrect operation but would like somebody to give me a simple explanation as to what happens. I looked at the help, but it doesn't necessarily deal with this (that I can work out anyway)

 

What I intend to have happen is an event case to perfrom when a time value is reached (say shutdown the computer at 6:30 PM (my fixed string value)), and I wasn't aware of the above behaviour until I tried a few examples.

 

Any insights to what actually happens?

 

Regards

Ray

0 Kudos
Message 1 of 23
(4,129 Views)

You have nothing wired to the timeout value so the event structure is the only thing that runs - it never exits back to the main loop. Wire up a value (i.e. 500) and place the get time code inside the timeout event. You should place the stop button in it's own event, get rid of the wait, and you would need to write to the Value(Signaling) property to programatically fire the 'equal' event. Doing an equal is also wrong. You are requesting seconds so your comparison will never match.

0 Kudos
Message 2 of 23
(4,121 Views)

As Dennis already hinted, you have some beginners misconceptions about the events structure.

 

In this particular code, the event structure has no meaning or useful function, because you need to spin the loop anyway in order to do repetitive comparisons. All it currenty does is wait forever, thus blocking the loop from going to the next iteration. All you need is wire a case structure to the output of the "equal". Leave the FALSE case empty and place your desired conditional code in the TRUE case.

 

Events are (primarily) triggered by user interactions of front panel controls. Indicator updated don't fire events for good reason.

 

Useful debugging tool are "execution highlighting" and "probes". Run the VI is highlighting mode and watch the diagram to get a better feel of what's happening.

 

What are you actually tring to do? I am sure there are better ways to do timed actions?

0 Kudos
Message 3 of 23
(4,114 Views)

Dennis, Altenbach

 

Both your suggestion worked ( I had no doubts).

 

The vi I attached is a very heavily edited version of a much larger program in which I'm using a producer/consumer architecture. I cannot show the whole code due to proprietary issues and "in confidence" agreements with our client.

 

What I was aiming for with little snippet attached was simply to force any windows programs (including the vi) to close and the computer to shutdown mode at a particular time each day (6:30PM to be exact)

 

I have the code working for the forced shutdown and it is a small vi that I would run when the system clock read 6:30 PM.

 

I figured it would be a simple method to compare the current time to a fixed time constant and if true have the true case of a case structure call the shutdown vi.

 

That's the plan anyway. BTW...Dennis....I did try using the timeout event as you suggested and it worked just fine, but in my main program I am using the timeout event to cause a tab control to revert to a particular page witihn the control, so that's why I hadn't pressed it into service for this action.

 

Of course any advice is gladly accpeted.

 

Regards

Ray

 

0 Kudos
Message 4 of 23
(4,092 Views)

What about windows scheduler and "Shutdown -s"?

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 23
(4,066 Views)

Don't forget /t 0 to avoid the message and the one minute wait.

 

command will then be:

 

shutdown -s /t 0 

 

change 0 to something else if you want some timedelay.

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
0 Kudos
Message 6 of 23
(4,048 Views)

 


@altenbach wrote:
Indicator updated don't fire events for good reason.

 

Unless of course you write to the Value(Signaling) property of the indicator. I am sure you know that but I just wanted to clarify.

 

=====================
LabVIEW 2012


0 Kudos
Message 7 of 23
(4,017 Views)
That's much more than an "indicator update". 🙂
0 Kudos
Message 8 of 23
(3,995 Views)

Whoa.....starting to move off topic guys.

 

Thanks for all the suggestions, but I'm comitted to the method I suggested in my second reply post...that is.....no windows scheduler.....no shutdown command.......use event structure.

 

Regards

Ray

0 Kudos
Message 9 of 23
(3,976 Views)

I'm sure they were just going on the premise that "the best way isn't always LabVIEW" and were simply suggesting something that might solve your problem in a more efficient manner.  Since there was no background given on why you were attempting this, the windows scheduler comments weren't really too far off topic.  I'd seen this solution mentioned a few times before and in those other cases they responded with "why didn't I think of that!"  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 23
(3,962 Views)