home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 8 Other
/
08-Other.zip
/
pwrprt.zip
/
X10.CMD
< prev
Wrap
OS/2 REXX Batch file
|
1994-12-18
|
7KB
|
245 lines
/*-----------------------------------------------------------+
| X10 Control Program
| (C)opyright 1994, Arthur F. Tyde III
|
+-----------------------------------------------------------*/
Signal on Syntax
Signal On Novalue
Signal on Halt
Version = '.01'
Parse upper Arg House_Code Unit_Code Command level
if house_code<>'' then do
Call Init
'@MODE' X10_Port':600,n,8,1 >NUL'
If Rc = 0 Then Do
Call X10_Direct House_Code,Unit_Code,Command,Level
End
Else
Say 'Error' rc 'from MODE.'
end
else do
say
say '-> Syntax Error: X10 HC UC (ON/OFF/DIM) LEVEL'
end
Bailout:
call stream X10_Port,'C','CLOSE'
Exit
Init:
X10_Port = 'COM2'
X10_Ack = Copies('FF'x,6)'01'x
X10_Header= Copies('FF'X,16)
Unit_code.1 = '0000000010000000'b
Unit_code.2 = '0000000001000000'b
Unit_code.3 = '0000000000100000'b
Unit_code.4 = '0000000000010000'b
Unit_code.5 = '0000000000001000'b
Unit_code.6 = '0000000000000100'b
Unit_code.7 = '0000000000000010'b
Unit_code.8 = '0000000000000001'b
Unit_code.9 = '1000000000000000'b
Unit_code.10 = '0100000000000000'b
Unit_code.11 = '0010000000000000'b
Unit_code.12 = '0001000000000000'b
Unit_code.13 = '0000100000000000'b
Unit_code.14 = '0000010000000000'b
Unit_code.15 = '0000001000000000'b
Unit_code.16 = '0000000100000000'b
X10_HouseCode.A = '60'x
X10_HouseCode.B = 'E0'x
X10_HouseCode.C = '20'x
X10_HouseCode.D = 'A0'x
X10_HouseCode.E = '10'x
X10_HouseCode.F = '90'x
X10_HouseCode.G = '50'x
X10_HouseCode.H = 'D0'x
X10_HouseCode.I = '70'x
X10_HouseCode.J = 'F0'x
X10_HouseCode.K = '30'x
X10_HouseCode.L = 'B0'x
X10_HouseCode.M = '00'x
X10_HouseCode.N = '80'x
X10_HouseCode.O = '40'x
X10_HouseCode.P = 'C0'x
X10_Function_code.ON = '00000010'b
X10_Function_code.OFF = '00000011'b
X10_Function_code.DIM = '00000101'b
X10_Level.1 = '11110000'b
X10_Level.2 = '11100000'b
X10_Level.3 = '11010000'b
X10_Level.4 = '11000000'b
X10_Level.5 = '10110000'b
X10_Level.6 = '10100000'b
X10_Level.7 = '10010000'b
X10_Level.8 = '10000000'b
X10_Level.9 = '01110000'b
X10_Level.10 = '01100000'b
X10_Level.11 = '01010000'b
X10_Level.12 = '01000000'b
X10_Level.13 = '00110000'b
X10_Level.14 = '00100000'b
X10_Level.15 = '00010000'b
X10_Level.16 = '00000000'b
Return
X10_Direct:
Parse Arg HouseCode,Unit_list,Command,Level
If Level = '' Then Level = 16
X10_Cmd = '01'x
X10_Function = X10_Function_Code.Command
X10_Level_Function = Bitor(X10_Function,X10_Level.Level)
X10_Unit_codes = X10_Units(Unit_list)
Checksum = Right(D2C(C2D(x10_level_function),
+C2D(X10_housecode.HouseCode)+C2D(X10_unit_codes)),1)
X10_Cmd_String = X10_Header||X10_Cmd||X10_Level_Function||,
X10_HouseCode.Housecode||X10_Unit_Codes||Checksum
Call Charout X10_Port,X10_Cmd_String
If X10_Ack() \= X10_Ack Then Do
Say 'EEK'
End
Return
/*-----------------------------------------------------------+
| X10_Ack - Receive ACK from CP290
+-----------------------------------------------------------*/
X10_Ack:
Ack_msg = ''
Do qqx = 1 to 7
New_Char = Charin(X10_Port)
If New_Char \= '' Then
Ack_msg = Ack_msg || New_Char
Else
Leave
End
Return Ack_msg
/*-----------------------------------------------------------+
| X10_Units: - Construct the Unit Bitmap from a list of Units
|
+-----------------------------------------------------------*/
X10_units:
Procedure Expose Unit_Code.
Parse Arg unit_list
Unit_bits = '0000'x
Do qqx = 1 To Words(Unit_list)
Unit = Word(Unit_list,qqx)
Unit_bits = bitor(Unit_bits,Unit_Code.unit)
End
Return Unit_bits
/*-----------------------------------------------------------------+
| Exception Handlers for intercepting Rexx errors. |
+-----------------------------------------------------------------*/
Failure:
Novalue:
Error:
Syntax:
Halt:
Trace 'O'
Signal Off Failure
Signal Off Novalue
Signal Off Error
Signal Off Syntax
Signal Off Halt
Rexx_err = Condition('Condition')
Rexxline = Sigl
Fault = ''
Select
When Rexx_err = 'NOVALUE' Then Do
/*------------------------------------------------------------+
| A Rexx NOVALUE Error has been detected.
+------------------------------------------------------------*/
Fault=Condition('Description')
Call Show_error
Call Log_it 'Rexx Novalue Error for:' Fault
End
When Rexx_err = 'ERROR' | Rexx_err = 'FAILURE' Then Do
/*------------------------------------------------------------+
| A System Error or Failure as been detected.
+------------------------------------------------------------*/
Call Show_Error
Call Log_it 'System Returned' Rc,
'Executing:' Condition('Description')
End
When Rexx_err = 'SYNTAX' Then Do
/*------------------------------------------------------------+
| A Rexx Syntax Error has been detected.
+------------------------------------------------------------*/
Call Show_Error
Call Log_it "REXX Error Message is:" Errortext(RC)
End
When Rexx_err = 'HALT' Then Do
Call Show_Error
Call Log_it "REXX interpreter Halted."
End
Otherwise
End
If Condition('Status') = 'DELAY' Then Return
Else Signal bailout
Show_error:
lc = 'abcdefghijklmnopqrstuvwxyz'
uc = Translate(lc)
special = '.!$_0123456789'
Parse Value 0 With,
1 in_sigl,
1 Line_disp,
1 Done
Parse Value '5 5' With Top_disp Bot_disp
Parse Source . . Prgname
Call Log_it 'Rexx' Rexx_err 'error on line' rexxline 'of' Prgname
Do Sline = Max(RexxLine-Top_disp,1) By 1 Until Done
If Sline = Rexxline | in_sigl Then Do
Prefix = '>'
In_sigl = Right(Sourceline(sline),1)=','
Line_disp = 1
End
Else Do
Prefix = ' '
If Line_disp Then Do
Vars_displayed. = 0
Line_disp = 0
Call Log_it ' ---Variable Display---'
Do Bline = rexxline By 1,
Until Right(Sourceline(Bline),1)\=','
VLine = Translate(Sourceline(Bline), uc||lc||special,,
uc||lc||Special||Xrange('00'x,'FF'x))
Do While VLine <> ''
Parse Value VLine With VWord VLine
If Symbol(Vword) = 'VAR' Then Do
/*------------------------------------------------+
| Display the Variable if:
| a) It is not the variable that raised Novalue
| b) It has not already been displayed
+------------------------------------------------*/
If Vword\=Fault & \Vars_displayed.vword Then Do
NLine = VWord '=' Value(VWord)
Vars_displayed.vword = 1
Call Log_it ' 'Nline
End
End
End
End
If Fault \= '' Then
Call Log_it ' 'fault' = ** No Value **'
Call Log_it ' ----------------------'
End
End
Call Log_it Right(Sline,5)prefix Sourceline(sline)
Done = Sline > Rexxline + Bot_disp | Sline > Sourceline()
End
Return
Log_it:
Parse Arg text
Say text
Return