#
# $Id: icebox3.dev 1039 2008-08-18 04:00:54Z garlick $
#
# Linux Networx ICE Box firmware version 3.x and 4.x on port 1010.
#
# For 3.0 B70 or better, 2 sec delays in beacon_on/beacon_off can be 
# commented out.
#
specification "icebox3" {
	timeout 	20

	plug name { "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" }

	script login {
		expect "V[34][^\n]*\r\n"
		send "auth icebox\r\n"
		expect "OK\r\n"
	}
	script logout {
		send "q\r\n"
	}
	script status_all {
		send "ps *\r\n"
		expect "N1:([01]) N2:([01]) N3:([01]) N4:([01]) N5:([01]) N6:([01]) N7:([01]) N8:([01]) N9:([01]) N10:([01])[[:space:]]*\r\n"
		setplugstate "1" $1 off="0" on="1"
		setplugstate "2" $2 off="0" on="1"
		setplugstate "3" $3 off="0" on="1"
		setplugstate "4" $4 off="0" on="1"
		setplugstate "5" $5 off="0" on="1"
		setplugstate "6" $6 off="0" on="1"
		setplugstate "7" $7 off="0" on="1"
		setplugstate "8" $8 off="0" on="1"
		setplugstate "9" $9 off="0" on="1"
		setplugstate "10" $10 off="0" on="1"
	}
	# Assumption: v3 implies that "ts" is deprecated in favor of "is"
	script status_temp_all {
                send "is *\r\n"
                expect "N1:([^ ]+) N2:([^ ]+) N3:([^ ]+) N4:([^ ]+) N5:([^ ]+) N6:([^ ]+) N7:([^ ]+) N8:([^ ]+) N9:([^ ]+) N10:([^ ]+) N11:[^ ]+ N12:[^ ]+[[:space:]]*\r\n"
                setplugstate "1" $1
                setplugstate "2" $2
                setplugstate "3" $3
                setplugstate "4" $4
                setplugstate "5" $5
                setplugstate "6" $6
                setplugstate "7" $7
                setplugstate "8" $8
                setplugstate "9" $9
                setplugstate "10" $10
        }
	script status_beacon_all {
                send "be *\r\n"
                expect "N1:([A-Z]+) N2:([A-Z]+) N3:([A-Z]+) N4:([A-Z]+) N5:([A-Z]+) N6:([A-Z]+) N7:([A-Z]+) N8:([A-Z]+) N9:([A-Z]+) N10:([A-Z]+) N11:[A-Z]+ N12:[A-Z]+[[:space:]]*\r\n"
                setplugstate "1" $1 off="OFF" on="ON"
                setplugstate "2" $2 off="OFF" on="ON"
                setplugstate "3" $3 off="OFF" on="ON"
                setplugstate "4" $4 off="OFF" on="ON"
                setplugstate "5" $5 off="OFF" on="ON"
                setplugstate "6" $6 off="OFF" on="ON"
                setplugstate "7" $7 off="OFF" on="ON"
                setplugstate "8" $8 off="OFF" on="ON"
                setplugstate "9" $9 off="OFF" on="ON"
                setplugstate "10" $10 off="OFF" on="ON"
        }
	script on {
		send "ph %s\r\n"
		expect "OK\r\n"
		delay 0.7
	}
	script on_all {
		send "ph *\r\n"
		expect "OK\r\n"
		delay 7
	}
	script off {
		send "pl %s\r\n"
		expect "OK\r\n"
		delay 0.7
	}
	script off_all {
		send "pl *\r\n"
		expect "OK\r\n"
		delay 7
	}
	script cycle {
		send "pl %s\r\n"
		expect "OK\r\n"
		delay 4
		send "ph %s\r\n"
		expect "OK\r\n"
		delay 0.7
	}
	script cycle_all {
		send "pl *\r\n"
		expect "OK\r\n"
		delay 9
		send "ph *\r\n"
		expect "OK\r\n"
		delay 7
	}
	script reset {
		send "rp %s\r\n"
		expect "OK\r\n"
		delay 0.7
	}
	script reset_all {
		send "rp *\r\n"
		expect "OK\r\n"
		delay 7
	}
	script beacon_on {
		send "be %s on\r\n"
		expect "OK\r\n"
		delay 2
	}
	script beacon_off {
		send "be %s off\r\n"
		expect "OK\r\n"
		delay 2
	}
}
