Please help with task

nnCron and nnCron LITE discussion

Please help with task

Postby rucksman007 » Mon, 30 Jun 2008, 09:38

Hi,

although I tried for some hours now, I was not able to compose a task that matches my demands, Maybe a kind soul out there can help me. PLEASE!

The task is quite simple. I want my PC to wake up from standby every 30 minutes from 09:00-18:00 from Monday to Friday, perform some action and go to standby again. For some reason all my trials failed. Either the PC did not wake up, or dit not go to standby again, ...

Thanks for your help!
rucksman007
 
Posts: 11
Joined: Mon, 30 Jun 2008, 09:32

Re: Please help with task

Postby AlikasS » Tue, 01 Jul 2008, 04:50

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
%>

Code: Select all
#( CLASSIC-TASK-#-ON-8-55
WatchSuspend
NoLog
Action:
    WDay@ 5 <
    IF
        WakeAt: "08:55"
    ELSE
        WakeAtWd: "08:55" 1
    THEN
THEN
)#

Code: Select all
#( CLASSIC-TASK-#-OFF_Computer1800
C" 6OR7day?" FIND NIP 0=
[IF]
: 6OR7day? WDay@ 7  = WDay@ 6  = OR ;
[THEN]
SingleInstance
Action:
6OR7day? NOT INTERVAL: 08:55-18:00 AND IF EXIT THEN

TQUERY: "OFF?" 120 Yes
IF
   POWER-FORCE
   POWER-HIBERNATE
THEN
)#
User avatar
AlikasS
 
Posts: 1434
Joined: Wed, 28 Jun 2006, 05:39
Location: Khabarovsk

Re: Please help with task

Postby rucksman007 » Tue, 01 Jul 2008, 10:57

Hi,

first of all: Thank you so much for your help!

As far as I understand, each one of these three scripts does more or less the same?

Being no coder at all: Could you please describe very roughly line by line, what the scripts are doing so that I can modify them to fit my demands in the best way?

Thank you so much....
rucksman007
 
Posts: 11
Joined: Mon, 30 Jun 2008, 09:32

Re: Please help with task

Postby AlikasS » Tue, 01 Jul 2008, 16:15

Valery or Nicholas help :-) (я на моем техническом английском не объясню)
User avatar
AlikasS
 
Posts: 1434
Joined: Wed, 28 Jun 2006, 05:39
Location: Khabarovsk

Re: Please help with task

Postby rucksman007 » Tue, 01 Jul 2008, 19:41

forgot to mention: unfortunately I do not speak or read russian..... :(
rucksman007
 
Posts: 11
Joined: Mon, 30 Jun 2008, 09:32

Re: Please help with task

Postby SeMa » Fri, 04 Jul 2008, 16:41

rucksman007 wrote:As far as I understand, each one of these three scripts does more or less the same?

No, you're wrong.
1st script is the declaration of new words. It have to be placed at the beginning of crontab.
Previously download wakeup.spf and place it to plugins folder (see line 2 of this script).
You may "link" that plugin in nncron.ini. Then line 2 of this script must be deleted.
Code: Select all
<%
S" WakeAfter" S" plugins\wakeup.spf" REQUIRED
: WakeAtWd { a u N -- }       \ new word accepts string ("hh:mm") and number (weekday)
N WDay@ -                     \ calculates days differ
DUP                           \ duplicates it (for further usage)
0=                            \ compares number with today's weekday
IF
   DROP                       \ matched - delete days differ
   a u SH:M>Min TimeMin@ -    \ converts "hh:mm" to minutes and compares with current minutes
   DUP 0<
   IF                         \ this day, but time expired; thus - next week
   [ 7 24 60 * * ] LITERAL +  \ adds 10080 minutes till next week day
   THEN
   60000 *                    \ time in ms
   WakeAfter                  \ set up timer
ELSE
   DUP                        \ duplicates days differ again
   0<                         \ checks day before/after today
   IF
   7 + 1440 * a u SH:M>Min TimeMin@ - + 60000 * WakeAfter \ before - next week
   ELSE
   1440 * a u SH:M>Min TimeMin@ - + 60000 * WakeAfter  \ after - this week
   THEN
THEN
;

\ create infix variant of WakeAtWd
: WakeAtWd: eval-string, number, POSTPONE WakeAtWd ; IMMEDIATE
%>

Usage example:
Code: Select all
S" 08:30" 5  WakeAtWd   \ or
WakeAtWd: "08:30" 5     \ wakes at 8-30 next friday

WakeAtWd: "17:00" 1     \ wakes at 17-00 next monday

long-playing WakeAtWd: :-)
Code: Select all
WakeAtWday: "17:00" 8   \ wakes at 17-00 within second monday ( 1 + 7 )

WakeAtWday: "17:00" 10  \ wakes at 17-00 within second wednesday ( 3 + 7 )

This task sets up wakeup timer at 8-55 on weekdays if PC goes SUSPEND or HIBERNATE
Code: Select all
#( CLASSIC-TASK-#-ON-8-55
WatchSuspend
NoLog
Action:
    WDay@ 5 <                 \ is friday?
    IF
        WakeAt: "08:55"       \ no - set up timer at next day
    ELSE
        WakeAtWd: "08:55" 1   \ yes - set up timer at next monday
    THEN
THEN
)#

This task sends PC to hibernate at 18-01 every workday
Code: Select all
#( CLASSIC-TASK-#-OFF_Computer1800
C" 6OR7day?" FIND NIP 0=              \ finds word 6OR7day? in nnCron dictionary
[IF]                                  \ if not found
: 6OR7day? WDay@ 7  = WDay@ 6  = OR ; \ declares it - "either saturday or sunday (weekend)"
[THEN]
SingleInstance
Action:
\ if working time - nothing to do - quit task
6OR7day? NOT INTERVAL: 08:55-18:00 AND IF EXIT THEN
\ otherwise (workday at 18-01) - it's bedtime ;)
TQUERY: "OFF?" 120 Yes
IF
   POWER-FORCE
   POWER-HIBERNATE
THEN
)#
Компьютер ─ устройство, разработанное для ускорения и автоматизации человеческих ошибок
User avatar
SeMa
 
Posts: 637
Joined: Fri, 15 Apr 2005, 12:49
Location: Украина

Re: Please help with task

Postby rucksman007 » Mon, 07 Jul 2008, 09:28

Hi there,

thanks so much fpr your help. I think I found a solution for my problem, but there are still some "mysteries" I will put into another thread...

Anyway: Thanks again, I am sure I will use these tips for a different task...
rucksman007
 
Posts: 11
Joined: Mon, 30 Jun 2008, 09:32


Return to nnCron forum (English)

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests