Beispiel #1
0
class C3WayCharger(ACharger):

    def __init__(self, config):
        ACharger.__init__(self, config)
        from relay08 import get_three_way_cutter
        from energy import Energy
        self.charger = get_three_way_cutter()
        self.config = config
        self.energy = Energy()

    def charge(self, charger_unit):
        if charger_unit[0] == None:
            self.charger.set_usb_line_status(0)
            time.sleep(charger_unit[1])
        elif charger_unit[0] == CDP:
            self.charger.enable_cdp_charging(charger_unit[1], charger_unit[2])
        elif charger_unit[0] == DCP:
            self.charger.enable_dcp_charging(charger_unit[1], charger_unit[2])
        else:
            self.charger.enable_sdp_charging(charger_unit[1], charger_unit[2])

    def reconnect_usb(self):
        for i in range(3):
            info = self.energy.get_battery_info()
            if info and info["USB"]:
                break
            self.charger.enable_sdp_charging(2, 5)
        else:
            assert False
Beispiel #2
0
class ALevelVoltage(object):
    def __init__(self, level, voltage):
        self.energy = Energy()
        self.level = level
        self.voltage = voltage

    def make_level_voltage(self):
        assert False, "needs be implemented in subclass"

    def verify_level_voltage_match(self):
        self.make_level_voltage()
        info = self.energy.get_battery_info()
        print info
        assert abs(self.level - info["level"]) <= 5
        assert abs(self.voltage - info["voltage"]) <= 50