in data 01-03-2018 04:14 AM
Hi All,
I would like to trigger events at specific times of the day, and would like suggestions on how the attached vi can be improved.
The events will drive a state machine, as per this example by FuManWho:
The vi works (as long as the consumer is slower than the producer), but I'm sure there is a better way of doing this! Custom events? QMH?
Many thanks
Graham
Risolto Andare alla soluzione.
in data 01-03-2018 04:25 AM
in data 01-03-2018 04:34 AM
Oh I like that. Thanks.
I did have them in the timeout at one stage but moved them around to get over a different problem - my event queue was filling up (to 99 events) in the time the 60 seconds the test condition was true. Limiting the queue size and adding delays worked but I didn't like stalling the consumer to get around that.
in data 01-03-2018 04:40 AM
Hi Graham,
my event queue was filling up (to 99 events) in the time the 60 seconds the test condition was true.
You surely want to generate just one event when the conditions switches to TRUE!
So you need to include a comparison to check for changed conditions…
in data 01-03-2018 05:06 AM
Yes (at least I think so!). The event would be something like play mp3 file, switch light on, boil kettle etc. Single discrete events that begin at that time.
in data 01-03-2018 06:22 AM
@grahamwebb wrote:
I did have them in the timeout at one stage but moved them around to get over a different problem - my event queue was filling up (to 99 events) in the time the 60 seconds the test condition was true. Limiting the queue size and adding delays worked but I didn't like stalling the consumer to get around that.
What you should do is add a shift register to hold the current comparisons. Then you can do a if(current Value == TRUE AND previous value == FALSE) {do action}.
in data 01-03-2018 07:25 AM
Do you really need to check for a timeout every 10 ms? That seems extremely fast for the types of events you are triggering.
in data 01-03-2018 07:38 AM
Since I can't open the VI (Installing 2017 now) and it is in 2017
Why not use "Value Changed.vim" on the Time Date record.(Day, Hour, Month, Minute) element as appropriate?
Hint: for bonus points you can even add a "Quotient & Remainder" to a counter that increments every (Whatever)
Anyone up to Whip in a simple example firing a "User Event" every n Seconds? (Wire control "n" to the divisor of Q&R test R=0, if so generate "User Event"
🙂 Bonus points if the user event data type contains a date-time record
in data 01-03-2018 07:47 AM
@GerdW wrote:
Hi graham,
just a suggestion:
You could put those FOR loops into the timeout event of your event structure…
Also be aware of that issue with DST and the witching hour of 2:00 AM. One day of the year there are two hours that are "2:00 AM" and another day where there is NO "2:00 AM". As long as the trigger times are not in that window, just ignore me.
Ben
in data 01-03-2018 08:09 AM
@Ben wrote:
@GerdW wrote:
Hi graham,
just a suggestion:
You could put those FOR loops into the timeout event of your event structure…
Also be aware of that issue with DST and the witching hour of 2:00 AM. One day of the year there are two hours that are "2:00 AM" and another day where there is NO "2:00 AM". As long as the trigger times are not in that window, just ignore me.
Ben
Cast "To UTC" and ingore Ben this time. 😮