Example #1
0
def armed(armedSensors):
    while(True):
        # request alarm action
        try:
            alarm = req.alarm()
        except Exception:
            armed(armedSensors)
        # check for disarm
        if (alarm['action'] == 'disarm'):
            try:
                req.updateAlarm('off')
            except Exception:
                unarmed()
            unarmed()
        # see if there are any faults
        stat = status.Status()
        stat.refresh()
        fault = stat.detectFaults(armedSensors)
        if (fault != 'nofault'):
            # if there are any faults, sound alarm and update status of alarm
            try:
                req.updateAlarm('on')
            except Exception:
                sound(fault)
            sound(fault)
Example #2
0
def sound(fault):
    i = 0
    while(True):
        try:
            alarm = req.alarm()
        except Exception:
            sound(fault)
        if (alarm['action'] == 'disarm'):
            try:
                req.updateAlarm('off')
            except Exception:
                unarmed()
            unarmed()
        siren.interior(.05, 2)
        i += 1
        # after the predefined number of warning
        # tones, sound the loud siren
        if (i > config.delay):
            # send messages
            try:
                req.mailFault(fault)
                req.addFault(fault)
            except Exception:
                loud(fault)
            # trigger siren
            loud(fault)
Example #3
0
def unarmed():
    print('Alarm ready. Waiting for action.')
    while (True):
        # get the action
        try:
            alarm = req.alarm()
        except Exception:
            unarmed()
        # arm the alarm?
        if (alarm['action'] == 'arm'):
            # wait for user to escape
            time.sleep(config.escapeTime)
            # begin to listen to faults
            armed(alarm['sensors'])
        time.sleep(config.searchFreq)
Example #4
0
def loud(fault):
    i = 0
    while(True):
        try:
            alarm = req.alarm()
        except Exception:
            loud(fault)
        # check for disarm
        # if i >= 60, the siren has been going off for 4 minutes
        if (alarm['action'] == 'disarm') or (i >= 60):
            try:
                req.updateAlarm('off')
            except Exception:
                unarmed()
            unarmed()
        siren.exterior(3, 1)
        i += 1