#
# $Id: baytech-rpc28-nc.dev 964 2008-06-13 13:40:47Z garlick $
# 
# Baytech RPC28-30NC 
#
# Default config, then disable confirmation, and disable status menu.
#
# Firmware version: F3.01 (C) 2000
#
# Maybe it is accumulated serial noise or some other issue, but this 
# model seems to require a little handshake:
#		send "\r\n"
#		expect ".*RPC-28[A]*>"
# before each command to avoid dropping the command.
#
specification "baytech-rpc28-nc" {
	timeout 	10   # about 5 sec for cycle command

	plug name { "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" 
		    "12" "13" "14" "15" "16" "17" "18" "19" "20" }

	script login {
		send "\r\n"
		expect ".*RPC-28[A]*>"
	}
	script logout {
		send "\r\n"
		expect ".*RPC-28[A]*>"
		send "exit\r\n"
	}
	script status_all {
		send "\r\n"
		expect ".*RPC-28[A]*>"
		send "status\r\n"
		foreachplug {
			expect "Outlet[ ]+([0-9]+)[^:0-9]+: (On|Off)"
			setplugstate $1 $2 on="On" off="Off"
		}
		expect "RPC-28[A]*>"
	}
	script on {
		send "\r\n"
		expect ".*RPC-28[A]*>"
		send "on %s\r\n"
		expect "RPC-28[A]*>"
	}
	script on_all {
		send "\r\n"
		expect ".*RPC-28[A]*>"
		send "on 0\r\n"
		expect "RPC-28[A]*>"
	}
	script off {
		send "\r\n"
		expect ".*RPC-28[A]*>"
		send "off %s\r\n"
		expect "RPC-28[A]*>"
	}
	script off_all {
		send "\r\n"
		expect ".*RPC-28[A]*>"
		send "off 0\r\n"
		expect "RPC-28[A]*>"
	}
	script cycle {
		send "\r\n"
		expect ".*RPC-28[A]*>"
		send "off %s\r\n"
		expect "RPC-28[A]*>"
		delay 4
		send "on %s\r\n"
		expect "RPC-28[A]*>"
	}
	script cycle_all {
		send "\r\n"
		expect ".*RPC-28[A]*>"
		send "off 0\r\n"
		expect "RPC-28[A]*>"
		delay 4
		send "on 0\r\n"
		expect "RPC-28[A]*>"
	}
}
