示例#1
0
def AlertIfArmed(nodeId, current, previous):
    with alertLock:
        name = getNodeName(nodeId)
        alarmState = getCurrentAlarmState()
        if (alarmState != "DISARMED"):
            logger.info("Sensor tripped on node " + name + " in alarm state: " + alarmState + " on " + str(current.time))
            timeDelta = getLastAlertTimeDelta()
            if timeDelta.total_seconds() <= ignoreReAlertWithinSeconds:
                logger.info("Last alert was " + convert_timedelta_str(timeDelta) + " ago. Ignoring.")
                return
            setLastAlertTime()
            alarmStateDelay = getAlarmStateDelayForNode(nodeId, alarmState)
            if alarmStateDelay is None:
                logger.info("No delay defined for alarm state: [" + alarmState + "]. Defaulting to 10 seconds.")
                alarmStateDelay = 10
            then = datetime.datetime.now() + datetime.timedelta(seconds=alarmStateDelay)
            setAlertPanicTime(str(then))
            logger.info("We are in the following armed state: [" + alarmState + "]. Siren will be enabled in " + str(alarmStateDelay) + " seconds")
            subject = "[" + alarmState + "] Sensor tripped on node " + name + " on " + str(current.time)
            body = "Siren will fire in " + str(alarmStateDelay) + " seconds at " + str(then)
            sendEmail(mailto, subject, body)
            sleepWithBeep(then)
            # Now check is enduser has been able to disarm the alarm
            if (getCurrentAlarmState() != "DISARMED"):
                notification = getLatestNotification(nodeId)
                panic(nodeId = nodeId, info = "Triggered by " + name + ". " + name + " is currently " + getSensorState(notification.value) + ".")
            else:
                sendEmail(mailto, "Alarm disarmed in time!", "")
                logger.info("Alarm disarmed in time!")
            resetAlertPanicTime()
示例#2
0
def crux(*args):
    processArguments()
    panic(info=args[1])
示例#3
0
def crux(*args):
    processArguments()
    panic(info = args[1])