home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: OtherApp
/
OtherApp.zip
/
house290.zip
/
HOUSE290.EXE
/
MODCTRL.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-06-01
|
3KB
|
85 lines
/* MODCTRL.CMD - Controls module whenever this program is run. */
/* Written by A. Schwarz. See http://home.att.net/~ASchw */
/* This is an example to show how to access the HOUSE/290 Comm Engine functions. */
/* Load X10LDLL.DLL */
call RxFuncAdd 'X10LLoadFuncs', 'X10LDLL', 'X10LLoadFuncs'
call X10LLoadFuncs
/* Load REXXUTIL.DLL */
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
pipename = '\PIPE\HOUSE290' /* 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\HOUSE290' */ /* note the _two_ backslashes preceding the computer name */
rc = CLOpenPipe(pipename)
IF rc = 0 then
DO
rc = CLPeekPipe('0')
IF Right(rc, 1) = 3 THEN
SAY 'Connected to Comm Engine.'
ELSE
DO
SAY 'Comm Engine unavailable, closing.'
rc = CLClosePipe('0')
SAY 'Press any key to exit...'
PARSE PULL keyhit
Signal ExitError
END
END
ELSE
DO
SAY 'Comm Engine not available.'
SAY 'Press any key to exit...'
PARSE PULL keyhit
Signal ExitError
END
/* change address, function and dim level here */
Module = 'A1' /* House and device code */
Command = 'ON' /* X-10 function: ON, OFF, DIM */
DimLevel = 0 /* Percentage 0-100 */
temp = '}ID1 ' || Module || ' ' || Command || ' ' || DimLevel /* send command */
rc = CLWritePipe(temp) /* write data to pipe */
Loop = 0
DO WHILE Loop < 5 /* wait for confirmation */
call SysSleep(1) /* wait one second */
rc = CLPeekPipe('0') /* peek into pipe */
PARSE VALUE rc WITH rcPeekNPipe ' ' BytesWait ' ' PipeState
IF BytesWait > 0 THEN /* pipe has data */
DO
rc = CLReadPipe('0') /* read pipe */
IF POS('{0 }ID1', rc) > 0 THEN /* no error */
DO
IF Command = 'DIM' THEN
SAY rc || ' ' || Module || ' set to ' || Command || '. Level = ' || DimLevel || '%'
ELSE
SAY rc || ' ' || Module || ' set to ' || Command
Loop = 10
END
ELSE /* Comm Engine reports errors */
DO
SAY 'Direct command ERROR: ' || rc
Loop = 11
END
END
Loop = Loop + 1
END /* While Loop */
IF Loop = 5 THEN
SAY 'Comm Engine did not respond. Time out.'
ExitNow:
rc = CLClosePipe('0')
ExitError:
call X10LDropFuncs
EXIT