Lookout

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a Day of the Week control.

I need to create an expression that looks at Monday through Friday separately from Saturday and Sunday year in and year out. This is so I can trigger different events for the normal shift work week versus the Weekend shift work.
0 Kudos
Message 1 of 6
(3,773 Views)
"A picture is worth a 1000 words..."

Attached you will find and example file built in Lookout 4.5.1 Build 18.

Note: If you change the reference pot's value the days of the week will not be correct. I chose 1/1/01 as my reference date, That happens to be a Monday.

Quick Summary of how to do it:
Truncate system time- this gives you a whole number.
Subtract the reference date from the truncated system time- this gives the # of days since the reference.
Use the Mod function on the # of days since the reference using 7 as the divisor. Since our reference was on a Monday this gives you the days since Monday (0=Monday,6=Sunday).This is the value that you can use to initiate action in the process file. I used it to display the day of the
week using an if statement displayed as text: IF(Days_since_monday=0,"Monday",IF(Days_since_monday=1,"Tuesday", etc....

Hope this gets you going.

Regards,
Tommy Scharmann
Download All
Message 2 of 6
(3,773 Views)
You can use a Sequencer to step through the days of the week. Pulse the Sequencer with a Time of Day timer.
Set:
On/Off signal=true
Timer Offset=00:00:00
Duration=0

Attached is the LKS file from LK 4.0.1
0 Kudos
Message 3 of 6
(3,773 Views)
Zork,

There is a problem with your solution:

In some circumstances a process file may not be running 24 hours a day- like multiple clients connected to a server-- maybe some of the clients are shutdown at various times of the day. If you implement your solution on a client and the client is not running at the time of day required to step the sequencer then your day of the week will be off. Another circumstance where there can be a problem is the change to or from daylight savings time.

In any programming it is important to minimize the need for human intervention unless, of course, human intervention is desired. In this case the need for human intervention (setting the day using a pushbutton) will, invariably, be forgotten and the day off the w
eek will be wrong resulting in unexpected and undesirable process file results.

Regards,
Tommy Scharmann
0 Kudos
Message 4 of 6
(3,773 Views)
I hate to oversimplify this - but I just use a single TimeOfWeek object with a 1 day offset (1:00:00:00) and a duration of 5 days (5:00:00:00). The week begins on sunday for the TimeOfWeek object, thus the one day offset. If the object returns "True" it's Monday thru Friday - if it returns "False" it's Saturday or Sunday. And it works no matter when the process is started.
Message 5 of 6
(3,773 Views)
You are correct. That does give you a "quantitative" indication (1=weekday 0=weekend) of weekday vs. weekend and since the timeofxxxx timers look at the systems clock it works regardless of wether the process file was shutdown for a few hours or not. I have never used these types of timers and because of your posting I learned something new. Thank-you.

The method I offered gives you more of a "qualitative" indication as to what day of week it is. Using a time of week timer for this functionality would require a timer for each day of the week. But in answer to the question posted verbatim, I would definetly choose your offer.

Regards,
Tommy Scharmann
0 Kudos
Message 6 of 6
(3,773 Views)