Пример #1
0
 def __init__(self):
     self.errorState = False  # If an error has occured
     self.x10 = None  # Pointer back to X10 to re-open
     self.boilerSwitch = None
     self.powerOn = False
     self.active = False
     self.unit = None
     self.target = 200
     self.unit = "F"
     self.sensor = sensors.temperSensor()
Пример #2
0
def countFails(scale, count):
    zeros = 0
    exceptions = 0

    drone1 = sensors.thermometer()
    drone2 = sensors.temperSensor()
    switch1 = switches.coolerSwitch()
    switch2 = switches.myX10('/dev/serial/by-id/usb-Prolific_Technology'
                             '_Inc._USB-Serial_Controller-if00-port0')
    switch3 = switches.pumpUSB()

    for x in range(0, count):

        try:
            d1 = drone1.getValue()
        except:
            sys.stdout.write('v')
        try:
            d2 = drone2.getValue()
        except:
            sys.stdout.write('t')
        try:
            s1 = switch1.off()
        except:
            sys.stdout.write('c')
        try:
            s2 = switch2.off()
        except:
            sys.stdout.write('x')
        try:
            s3 = switch3.off()
        except:
            sys.stdout.write('u')
        try:
            val = scale.getRaw()
            if int(val) == 0:
                zeros = zeros + 1
                sys.stdout.write("0")
            else:
                sys.stdout.write(".")
        except:
            exceptions = exceptions + 1
            sys.stdout.write("*")

        sys.stdout.flush()
        if x % 25 == 24:
            print ""

    print ""
    print "Exceptions:", exceptions
    print "Zeros     :", zeros
Пример #3
0
    def getValue(self):
        if not self.simulation:
            newval = self.readVol()
            if newval is not None:
                self.val = newval
            else:
                self.data.setHWerror(myid=__name__, errorText="dymoScale read error", retries=10)
        return self.val

    def setValue(self, val):
        if self.simulation:
            self.val = val

    def HWOK(self):
        if self.simulation:
            return False
        else:
            self.dev = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)
            # was it found?
            if self.dev is None:
                return False
        return True


if __name__ == "__main__":  # pragma: no cover
    d = dymoScaleSensor()
    t = sensors.temperSensor()
    while 1:
        print d.getValue(), t.getValue()
        time.sleep(1)