Sophie

Sophie

distrib > * > cooker > x86_64 > by-pkgid > 1acc97dcf884c05b37321eab15ec4372 > files > 4

powerman-2.3.9-2.x86_64.rpm

#
# $Id:$
#
# Written by Martin K. Petersen <mkp@mkp.net>
# Based upon apcpdc.dev by Trent D'Hooge and Makia Minich
#
# APC MasterSwitch AP7900 (and most likely AP7901, AP7920 & AP7921)
# - Firmware: APP v2.7.3 / AOS v2.7.0
#
specification "apc7900" {
	timeout 	10  

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

	script login {
		expect "\rUser Name : "
		send "apc\r\n"
		expect "\rPassword  : "
		send "apc\r\n"
		expect "> "
		send "1\r\n"  # device manager menu
		expect "> "
		send "3\r\n"  # outlet control/configuration
		expect "> "
	}
	script logout {
		send "\033"
		expect "> "
		send "\033"
		expect "> "
		send "4\r\n"
	}
	script status_all {
		send "\r\n"  # refresh
		foreachplug {
			expect "([0-9]+)-[^\n]*(ON|OFF)[^\n]*\r\n"
			setplugstate $1 $2 on="ON" off="OFF"
		}
		expect "> "
	}
	script on {
		send "%s\r\n"
		expect "> "
		send "1\r\n" # select control outlet
		expect "> "

		send "7\r\n" # cancel any pending delays
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		send "1\r\n" # immediate on
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		send "\033"
		expect "> "
		send "\033"
		send "\r\n"
		expect "> "
	}
	script on_all {
		send "9\r\n"
		expect "> "
		send "1\r\n" # select outlet control
		expect "> "

		send "7\r\n" # cancel any pending delays
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		send "4\r\n" # delayed on
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		send "\033"
		expect "> "
		send "\033"
		send "\r\n"
		expect "> "
	}
	script off {
		send "%s\r\n"
		expect "> "
		send "1\r\n" # select outlet control
		expect "> "

		send "7\r\n" # cancel any pending delays
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		send "2\r\n" # immediate off
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		send "\033"
		expect "> "
		send "\033"
		send "\r\n"
		expect "> "
	}
	script off_all {
		send "9\r\n"
		expect "> "
		send "1\r\n" # select outlet control
		expect "> "

		send "7\r\n" # cancel any pending delays
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		send "5\r\n" # delayed off
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		send "\033"
		expect "> "
		send "\033"
		send "\r\n"
		expect "> "
	}
# If outlet is initially off, "immediate reboot" (4) will leave it off.
# This doesn't match PowerMan's semantics for cycle, therefore do explicit
# immediate off + immediate on.
	script cycle {
		send "%s\r\n"
		expect "> "
		send "1\r\n" # select outlet control
		expect "> "

		send "7\r\n" # cancel any pending delays
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		send "2\r\n" # immediate off
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		delay 4

		send "1\r\n" # immediate on
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		send "\033"
		expect "> "
		send "\033"
		send "\r\n"
	}
	script cycle_all {
		send "9\r\n"
		expect "> "
		send "1\r\n" # select outlet control
		expect "> "

		send "7\r\n" # cancel any pending delays
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		send "5\r\n" # delayed off
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		delay 4

		send "4\r\n" # delayed on
		expect "to cancel : "
		send "YES\r\n"
		expect "to continue..."
		send "\r\n"
		expect "> "

		send "\033"
		expect "> "
		send "\033"
		send "\r\n"
		expect "> "
	}
}