WakeAt, WakeAfter und WakeAtWd

nnCron and nnCron LITE discussion

WakeAt, WakeAfter und WakeAtWd

Postby rucksman007 » Mon, 14 Jul 2008, 13:42

Hi everybody,

my last try with nncron before getting crazy. This is how my latest job looks like:
Code: Select all
<%
S" WakeAfter" S" plugins\wakeup.spf" REQUIRED
: WakeAtWd { a u N -- }
N WDay@ -  DUP 0=
IF DROP
   a u SH:M>Min TimeMin@ -
   DUP 0<
   IF
   [ 7 24 60 * * ] LITERAL +
   THEN
   60000 *
   WakeAfter
ELSE
   DUP
   0<
   IF
   7 + 1440 * a u SH:M>Min TimeMin@ - + 60000 * WakeAfter
   ELSE
   1440 * a u SH:M>Min TimeMin@ - + 60000 * WakeAfter
   THEN
THEN
;

: WakeAtWd: eval-string, number, POSTPONE WakeAtWd ; IMMEDIATE
%>

#( task1
WatchSuspend
Rule: WDay@ 1 = WDay@ 2 = WDay@ 3 = WDay@ 4 = WDay@ 5 = INTERVAL: 09:00-16:00 AND
Action:
   WakeAfter: 01:00
   GET-CUR-TIME
   LOG: "log\idle.log" "%hh%:%mm%:%ss% - task1"
POWER-SUSPEND
)#

#( task2
WatchSuspend
Rule: WDay@ 1 = WDay@ 2 = WDay@ 3 = WDay@ 4 = WDay@ 5 = INTERVAL: 09:00-16:00 0= AND
Action:
   WakeAt: 08:59
   GET-CUR-TIME
   LOG: "log\idle.log" "%hh%:%mm%:%ss% - task2"
POWER-SUSPEND
)#

#) task3
WatchSuspend
Rule: WDay@ 6 = WDay@ 7 =
Action:
   WakeAtWday: 08:59 1
   GET-CUR-TIME
   LOG: "log\idle.log" "%hh%:%mm%:%ss% - task3"
POWER-SUSPEND
)#

Unfortunaley, this damn job does not work. I did put the PC into standby yesterday (so task3 should be in charge), but it did not wake up the PC today at 8:59. Whats wrong here???????? Experts, please help!!!!!

I also tried to put these three tasks into one with nested IF sequencesm but obviously I have some errors in my script:
Code: Select all
#( task_if
Action:
WDay@ 1 = WDay@ 2 = WDay@ 3 = WDay@ 4 = WDay@ 5 = INTERVAL: 09:00-16:00 AND IF MSG: "if 1" ELSE
WDay@ 1 = WDay@ 2 = WDay@ 3 = WDay@ 4 = WDay@ 5 = INTERVAL: 09:00-16:00 0= AND IF MSG: "if 2" ELSE
WDay@ 6 = WDAY@ 7 = IF MSG: "if 3"
THEN THEN THEN
)#

It always returns a "Action: stack error".....
rucksman007
 
Posts: 11
Joined: Mon, 30 Jun 2008, 09:32

Re: WakeAt, WakeAfter und WakeAtWd

Postby SeMa » Wed, 16 Jul 2008, 19:15

1.
a) Rule: WDay@ 1 = WDay@ 2 = WDay@ 3 = WDay@ 4 = WDay@ 5 = INTERVAL: 09:00-16:00 AND
b) Rule: WDay@ 1 = WDay@ 2 = WDay@ 3 = WDay@ 4 = WDay@ 5 = INTERVAL: 09:00-16:00 0= AND
Wrong code! There are not used values stay on a stack after comparisons (=).
Here so it is correct:
a)
Code: Select all
Time: * 9-15 * * 1-5 *
Action:
=== or ===
Time: * * * * 1-5 *
Rule: INTERVAL: 09:00-16:00
Action:
b)
Code: Select all
Time: * 0-8,15-23 * * 1-5 *
Action:
=== or ===
Time: * * * * 1-5 *
Rule: INTERVAL: 09:00-16:00 NOT
Action:

2. WakeAtWday: 08:59 1 -- in word declaration WakeAtWd:

Correct code of your tasks:
Code: Select all
#( task1
WatchSuspend
Time: * * * * 1-5 *
Rule: INTERVAL: 09:00-16:00
Action:
   WakeAfter: 01:00
   GET-CUR-TIME
   LOG: "log\idle.log" "%hh%:%mm%:%ss% - task1"
POWER-SUSPEND
)#

#( task2
WatchSuspend
Time: * * * * 1-5 *
Rule: INTERVAL: 09:00-16:00 NOT
Action:
   WakeAt: 08:59
   GET-CUR-TIME
   LOG: "log\idle.log" "%hh%:%mm%:%ss% - task2"
POWER-SUSPEND
)#

#( task3
WatchSuspend
Time: * * * * 6,7 *
Action:
   WakeAtWd: 08:59 1
   GET-CUR-TIME
   LOG: "log\idle.log" "%hh%:%mm%:%ss% - task3"
POWER-SUSPEND
)#

Another variant:
Code: Select all
#( task123
WatchSuspend
Action:
WDay@ 6 = WDay@ 7 = OR NOT
IF
    INTERVAL: 09:00-16:00
    IF
        WakeAfter: 01:00
    ELSE
        WakeAt: 08:59
    THEN
ELSE
    WakeAtWd: 08:59 1
THEN
)#

#( task456
WatchResumeAuto
Action:
GET-CUR-TIME
WDay@ 6 = WDay@ 7 = OR NOT
IF
    INTERVAL: 09:00-16:00
    IF
        LOG: "log\idle.log" "%hh%:%mm%:%ss% - task1"
    ELSE
        LOG: "log\idle.log" "%hh%:%mm%:%ss% - task2"
    THEN
ELSE
    LOG: "log\idle.log" "%hh%:%mm%:%ss% - task3"
THEN
POWER-SUSPEND
)#
Компьютер ─ устройство, разработанное для ускорения и автоматизации человеческих ошибок
User avatar
SeMa
 
Posts: 637
Joined: Fri, 15 Apr 2005, 12:49
Location: Украина

Re: WakeAt, WakeAfter und WakeAtWd

Postby rucksman007 » Sat, 19 Jul 2008, 13:19

Thanks again for your help.

In the meantime, I was able to find a solution!
Code: Select all
<%
S" WakeAfter" S" plugins\wakeup.spf" REQUIRED
: WakeAtWd { a u N -- }
N WDay@ -  DUP 0=
IF DROP
   a u SH:M>Min TimeMin@ -
   DUP 0<
   IF
   [ 7 24 60 * * ] LITERAL +
   THEN
   60000 *
   WakeAfter
ELSE
   DUP
   0<
   IF
   7 + 1440 * a u SH:M>Min TimeMin@ - + 60000 * WakeAfter
   ELSE
   1440 * a u SH:M>Min TimeMin@ - + 60000 * WakeAfter
   THEN
THEN
;

: WakeAtWd: eval-string, number, POSTPONE WakeAtWd ; IMMEDIATE
%>

#( right
WatchSuspend
Rule: WDay@ 1 = WDay@ 2 = OR WDay@ 3 = OR WDay@ 4 = OR WDay@ 5 = OR INTERVAL: 09:00-16:00 AND
Action:
   WakeAfter: 01:00

)#

#( evening
WatchSuspend
Rule: WDay@ 1 = WDay@ 2 = OR WDay@ 3 = OR WDay@ 4 = OR WDay@ 5 = OR INTERVAL: 09:00-16:00 0= AND
Action:
   WakeAt: 08:59
)#

#( weekend
WatchSuspend
Rule: WDay@ 6 = WDay@ 7 = OR
Action:
   WakeAtWd: 08:59 1
)#

#( task
WatchResumeAuto
Action:
...
POWER-SUSPEND
)#


This works ALMOST. The onl thing is, that the task starts on saturday morning also, which is not what I want. But this is quite clear, because when on friday it goes into standby mode, the task "evening" will be activated and not the task "weekend". So I wil have to look for a solution, but this shouldn't be too complicated (another task maybe???).
rucksman007
 
Posts: 11
Joined: Mon, 30 Jun 2008, 09:32

Re: WakeAt, WakeAfter und WakeAtWd

Postby SeMa » Mon, 21 Jul 2008, 15:58

Why so long redundant code in Rule:? I can't understand :rolleyes:.
Rule: WDay@ 1 = WDay@ 2 = OR WDay@ 3 = OR WDay@ 4 = OR WDay@ 5 = OR INTERVAL: 09:00-16:00 AND
equals
Time: * 9-15 * * 1-5 *

Next task replaces your first three and must work always correctly.
Code: Select all
#( task123
WatchSuspend
Action:
WDay@ 6 = WDay@ 7 = OR NOT
IF
    INTERVAL: 09:00-16:00
    IF
        WakeAfter: 01:00
    ELSE
        WDay@ 5 =
        IF
            WakeAtWd: 08:59 1
        THEN
        WakeAt: 08:59
    THEN
ELSE
    WakeAtWd: 08:59 1
THEN
)#
Компьютер ─ устройство, разработанное для ускорения и автоматизации человеческих ошибок
User avatar
SeMa
 
Posts: 637
Joined: Fri, 15 Apr 2005, 12:49
Location: Украина

Re: WakeAt, WakeAfter und WakeAtWd

Postby rucksman007 » Fri, 25 Jul 2008, 12:33

Hi again,

I was trying so many tasks, and all of them did not work. So I started with very simple ones, checked if they were working and expanded them step by step. So this is why this task with so much - maybe redundant - code came out. Funny enough, this "* * 9-15..." does not work for me, thats why I started with WDay. I know that my task can be done a lot simpler, and this is what I was intending to do within the next days or weeks. But it was more important to have a working task in the first place.

So thanks again for your help. I will try you script, maybe this saves me from investing a lot of time in simplyfying my own code...
rucksman007
 
Posts: 11
Joined: Mon, 30 Jun 2008, 09:32


Return to nnCron forum (English)

Who is online

Users browsing this forum: No registered users and 1 guest

cron