blob: a817842485c818b4781cc2af413f6110eeade731 [file] [log] [blame]
Matt Hart132d43c2015-02-25 18:19:53 +00001#! /usr/bin/python
2
3# Copyright 2013 Linaro Limited
4# Author Matt Hart <matthew.hart@linaro.org>
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19# MA 02110-1301, USA.
20
21import logging
22from lavapdu.drivers.apc7952 import APC7952
23
24
25class APC9210(APC7952):
26
27 @classmethod
28 def accepts(cls, drivername):
29 if drivername == "apc9210":
30 return True
31 return False
32
33 def _port_interaction(self, command, port_number):
Matt Hartfe042212015-07-09 14:13:29 +010034 logging.debug("Attempting command: %s port: %i", command, port_number)
35 # make sure in main menu here
Matt Hart132d43c2015-02-25 18:19:53 +000036 self._back_to_main()
37 self.connection.send("\r")
38 self.connection.expect("1- Outlet Manager")
39 self.connection.expect("> ")
40 logging.debug("Entering Outlet Manager")
41 self.connection.send("1\r")
42 self.connection.expect("------- Outlet Manager")
43 logging.debug("Got to Device Manager")
44 self._enter_outlet(port_number, False)
Matt Hartfe042212015-07-09 14:13:29 +010045 self.connection.expect(["1- Control of Outlet",
46 "1- Outlet Control/Configuration"])
Matt Hart132d43c2015-02-25 18:19:53 +000047 self.connection.expect("> ")
48 self.connection.send("1\r")
49 self.connection.expect("Turn Outlet On")
50 self.connection.expect("> ")
51 if command == "on":
52 self.connection.send("1\r")
53 self.connection.expect("Turn Outlet On")
54 self._do_it()
55 elif command == "off":
56 self.connection.send("2\r")
57 self.connection.expect("Turn Outlet Off")
58 self._do_it()
59 else:
Matt Hartfe042212015-07-09 14:13:29 +010060 logging.debug("Unknown command!")