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)
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)
def sound(): while (True): siren.exterior(3, 1) # check for disarm try: panic = req.panic() except Exception: sound() if (panic['action'] == 'off'): try: req.updateAlarm('off') except Exception: wait() wait()
def wait(): print('Panic button ready. Waiting for action.') while (True): try: panic = req.panic() except Exception: wait() # check for an action if (panic['action'] == 'on'): # Sound the alarm try: req.updateAlarm('on') except Exception: sound() sound() time.sleep(config.searchFreq)
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