예제 #1
0
    def isDoorOpen(self, door):
        """Checks to see if the specified `door` is open.

        Parameters
        ----------
        door : str
            Acceptable values are right or left, otherwise object
            defaults will be used.

        Returns
        -------
        bool
            True for open
            False for closed
        """
        print "starting door open function"
        config = self._getConfig()
        mode = self._getMode(config)
        he = self._ConfigSectionMap(config, "HallEffect")

        if door == "right":
            # setup right sensor
            opened = int(he['rightopen'])
            closed = int(he['rightclosed'])
        elif door == "left":
            # setup left sensor
            opened = int(he['leftopen'])
            closed = int(he['leftclosed'])

        print "creating sensor object"
        print(opened, closed, mode)
        halleffect = HallEffectPair(opened, closed, mode)

        print "reading the state and returning"
        if halleffect.get_state(opened):
            print "yes"
            return "yes"
        else:
            print "no"
            return "no"
예제 #2
0
 def setup(self):
     self.halleffectpair = HallEffectPair()
예제 #3
0
class TestHallEffectPair:
    def setup(self):
        self.halleffectpair = HallEffectPair()

    def teardown(self):
        self.halleffectpair.cleanup()
예제 #4
0
def wait_for_door():
    halleffectpair = HallEffectPair()
    halleffectpair.add_event_detect(channel=halleffectpair.OPENDOOR, callback=park_assist)
    
    while 1:
        time.sleep(600)
예제 #5
0
        except:
            "exception on {0}!".format(option)
            dict1[option] = None
    return dict1

mode = ConfigSectionMap("General")['mode']
if mode == 'bcm':
    mode = GPIO.BCM
elif mode == 'board':
    mode = GPIO.BOARD
else:
    mode = ''
he = ConfigSectionMap("HallEffect")
re = ConfigSectionMap("Relay")

heleft = HallEffectPair(int(he['leftopen']), int(he['leftclosed']), mode)
heright = HallEffectPair(int(he['rightopen']), int(he['rightclosed']), mode)
relay = Relay(int(re['red']), int(re['yellow']), int(re['green']), mode)

def leftopen(channel):
    print "left door open"
    relay.turn_on_only(relay.green)

def leftclosed(channel):
    print "left door closed"
    relay.turn_on_only(relay.red)

def rightopen(channel):
    print "right door open"
    relay.turn_on_only(relay.green)
    relay.turn_on(relay.yellow)
예제 #6
0
    """Read the config parameters, initialize all the sensors,
    and loop the logic show the proper light.
    """
    config.read(configfile)
    mode = ConfigSectionMap("General")["mode"]
    if mode == "bcm":
        mode = GPIO.BCM
    elif mode == "board":
        mode = GPIO.BOARD
    else:
        mode = ""
    he = ConfigSectionMap("HallEffect")
    us = ConfigSectionMap("UltraSonic")
    re = ConfigSectionMap("Relay")

    halleffectleft = HallEffectPair(int(he["leftopen"]), int(he["leftclosed"]), mode)
    halleffectright = HallEffectPair(int(he["rightopen"]), int(he["rightclosed"]), mode)
    ultrasonicleft = USonic(int(us["lefttrigger"]), int(us["leftecho"]), mode)
    ultrasonicright = USonic(int(us["righttrigger"]), int(us["rightecho"]), mode)
    relay = Relay(int(re["red"]), int(re["yellow"]), int(re["green"]), mode)

    halleffectleft.add_event_detect(channel=halleffectleft.open_door, callback=set_left_time)
    halleffectright.add_event_detect(channel=halleffectright.open_door, callback=set_right_time)

    while 1:
        left_threshold = distance_threshold(left_open_time, ultrasonicleft)
        right_threshold = distance_threshold(right_open_time, ultrasonicright)
        thresholds = [left_threshold, right_threshold]
        threshold = min(thresholds)

        if threshold == 1: