home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: OtherApp
/
OtherApp.zip
/
cm17ce.zip
/
fcinst.EXE
/
timemod.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
2000-01-18
|
5KB
|
142 lines
/* TIMEMOD.CMD - Start Module at a certain time, then turn it off at a certain time. */
/*
Written by: Lone Peak Automation, LLC
Date: Jan. 15, 2000
This program requires the CM17A Comm Engine.
See http://home.att.net/~ASchw for more information.
Important: The CM17A Comm Engine must be running and be connected
to the X10 FireCracker before using this script.
This is an example to show how to access the CM17A Comm Engine functions.
*/
/* Load CM17A Comm Engine Functions */
call RxFuncAdd 'X10FLLoadFuncs', 'X10FLDLL', 'X10FLLoadFuncs'
call X10FLLoadFuncs
/* Load REXXUTIL.DLL */
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
pipename = '\PIPE\CM17ACE' /* single backslashes only when using on single computer */
/* Note: If running over a network, precede the pipe name with the computer name as shown below. */
/* pipename = '\\CLIENT527\PIPE\CM17ACE' */ /* note the _two_ backslashes preceding the computer name */
SAY ' '
SAY 'This program turns module A1 on and off at a certain time.'
SAY 'The Comm Engine must be running and be connected to'
SAY 'the CM17A for this program to work.'
SAY ' '
SAY 'Press C to continue, any other key to exit...'
PARSE PULL keyhit
IF keyhit <> 'c' & keyhit <> 'C' THEN
EXIT
rc = FCLOpenPipe(pipename)
IF rc = 0 then
DO
rc = FCLPeekPipe('0')
IF Right(rc, 1) = 3 THEN
SAY 'Connected to Comm Engine.'
ELSE
DO
SAY 'Comm Engine unavailable, closing.'
rc = FCLClosePipe('0')
SAY 'Press any key to exit...'
PARSE PULL keyhit
Signal ExitError1
END
END
ELSE
DO
SAY 'Comm Engine not available.'
SAY 'Press any key to exit...'
PARSE PULL keyhit
Signal ExitError1
END
Module = 'A1'
TimeOn = '16:59:00' /* time in HH:MM:SS to turn A1 on (use 24hr time format) */
TimeOff = '16:59:30' /* time in HH:MM:SS to turn A1 off */
Waitflag = 0
SAY ' '
SAY "Waiting to turn " || Module || " on at " || TimeOn
SAY "Press CTRL-Break to Exit..."
DO FOREVER
call SysSleep(1) /* wait one second */
CurrentTime = TIME()
IF CurrentTime = TimeOn & Waitflag = 0 THEN
DO
temp = '}ID1 ' || Module || " ON" /* turn on A1 */
rc = FCLWritePipe(temp) /* write data to pipe */
Loop = 0
DO WHILE Loop < 5 /* wait for confirmation */
call SysSleep(1) /* wait one second */
rc = FCLPeekPipe('0') /* peek into pipe */
PARSE VALUE rc WITH rcPeekNPipe ' ' BytesWait ' ' PipeState
IF BytesWait > 0 THEN /* pipe has data */
DO
rc = FCLReadPipe('0') /* read pipe */
IF POS('{0 }ID1', rc) > 0 THEN /* no error */
DO
SAY rc || Module || ' turned on. Waiting to turn off at ' || TimeOff || ' ...'
Loop = 10
Waitflag = 1 /* set flag to wait for turn-off */
END
ELSE /* Comm Engine reports errors */
DO
SAY 'Direct command ERROR: ' || rc
Signal ExitError
END
END
Loop = Loop + 1
END /* While Loop */
END /* IF CurrentTime = TimeOn */
IF CurrentTime = TimeOff & Waitflag = 1 THEN
DO
temp = '}ID1 ' || Module || " OFF" /* turn on A1 */
rc = FCLWritePipe(temp) /* write data to pipe */
Loop = 0
DO WHILE Loop < 5 /* wait for confirmation */
call SysSleep(1) /* wait one second */
rc = FCLPeekPipe('0') /* peek into pipe */
PARSE VALUE rc WITH rcPeekNPipe ' ' BytesWait ' ' PipeState
IF BytesWait > 0 THEN /* pipe has data */
DO
rc = FCLReadPipe('0') /* read pipe */
IF POS('{0 }ID1', rc) > 0 THEN /* no error */
DO
SAY rc || "Waiting to turn " || Module || " on at " || TimeOn
SAY "Press CTRL-Break to Exit..."
Loop = 10 /* exit the while loop */
Waitflag = 0 /* set flag to wait for turn-on */
END
ELSE /* Comm Engine reports errors */
DO
SAY 'Direct command ERROR: ' || rc
Signal ExitError
END
END
Loop = Loop + 1
END /* While Loop */
END /* IF CurrentTime = TimeOff */
END
ExitError:
rc = FCLClosePipe('0')
ExitError1:
call X10FLDropFuncs
EXIT