Originally Posted by
menta
I got a solution from a friend:
HH>StartHH ||
HH=StartHH & MM>StartMM ||
HH=StartHH & MM=StartMM & SS>=StartSS
Looks like that will work (with some parenthesis added).
This should work for the rest of it ...
Code:
TimeCmpFlags VAR BYTE
PastStart VAR TimeCmpFlags.0
PastStop VAR TimeCmpFlags.1
NextDay VAR TimeCmpFlags.2
ProgON VAR TimeCmpFlags.3
CheckTimes:
TimeCmpFlags = 0 ; clear flags first
; if the Start and Stop times are the same, then Always OFF
if (Stop_H=Start_H) AND _
(Stop_M=Start_M) AND _
(Stop_S=Start_S) then AlwaysOFF
; is it past the Start time?
if (Hours>Start_H) OR _
(Hours=Start_H AND Minutes>Start_M) OR _
(Hours=Start_H AND Minutes=Start_M AND Seconds>=Start_S) then PastStart=1
; is it past the Stop time?
if (Hours>Stop_H) OR _
(Hours=Stop_H AND Minutes>Stop_M) OR _
(Hours=Stop_H AND Minutes=Stop_M AND Seconds>=Stop_S) then PastStop=1
; does the period end the following day?
if (Stop_H< Start_H) OR _
(Stop_H=Start_H AND Stop_M < Start_M) OR _
(Stop_H=Start_H AND Stop_M=Start_M AND Stop_S < Start_S) then NextDay=1
;---------------
if !NextDay then ; same day, use AND
if PastStart AND !PastStop then ProgON = 1
else ; next day, use OR
IF PastStart OR !PastStop then ProgON = 1
endif
AlwaysOFF:
return
Added: You should keep in touch with your "Friend". It was a good "Tip".
Bookmarks