Commit 8ce9408f authored by Mufaddal Makati's avatar Mufaddal Makati

initial commit

parents

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

File added
<!-- File: build.xml-->
<!-- Author: Nick Nielsen <n.nielsen@cablelabs.com>-->
<!-- Date: Mon Feb 06 15:05:09 2012-->
<!-- Description: build.xml-->
<project name="alarm" default="dist" basedir=".">
<property name="eyes.base.dir" location=".." />
<property file="${eyes.base.dir}/build.properties" />
<property name="src" location="src/main/java"/>
<property name="build" location="build"/>
<property name="lib" location="../lib"/>
<property name="destfile" location="${lib}/alarm.jar" />
<property name="cp" value="${lib}/thirdparty/log4j-1.2.16.jar" /> <!--:${lib}/thirdparty/junit-4.10.jar:${lib}/thirdparty/easymock-3.1.jar"/> -->
<target name="init">
<tstamp/>
<mkdir dir="${build}"/>
</target>
<target name="compile" depends="init">
<javac debug="${javac.DEBUG}" srcdir="${src}" destdir="${build}" classpath="${cp}:${lib}/event.jar"/>
</target>
<target name="dist" depends="compile">
<jar destfile="${destfile}" basedir="${build}"/>
</target>
<target name="clean">
<delete dir="${build}"/>
<delete dir="${dist}"/>
<delete file="${destfile}"/>
</target>
</project>
# File: buildAlarm.sh
# Author: Nick Nielsen <n.nielsen@cablelabs.com>
# Date: Fri Mar 16 14:07:38 2012
# Description: builds all dependencies for alarm.
set -e
cd ../event && ant clean dist
cd ../alarm && ant clean dist
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.cablelabs</groupId>
<version>1.0.0-SNAPSHOT</version>
<!-- The artifact Id for this module -->
<artifactId>alarm</artifactId>
<!-- The packaging for this module (jar, war) -->
<packaging>jar</packaging>
<!-- The name for this module -->
<name>CableLabs - Alarm Module</name>
<!-- Description for this module -->
<description>CableLabs - Alarm Module</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!--
Parent information; should reference group, artifactId, and version of
the parent POM.
-->
<parent>
<groupId>org.cablelabs</groupId>
<artifactId>cablelabs-parent</artifactId>
<version>3.0</version>
</parent>
<dependencies>
<dependency>
<groupId>org.cablelabs</groupId>
<artifactId>event</artifactId>
<version>1.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>cablelabs-maven</id>
<url>https://community.cablelabs.com/mvn/eyes-ears-repo</url>
</repository>
</repositories>
<scm>
<developerConnection>scm:svn:https://community.cablelabs.com/svn/EYES/trunk/alarm</developerConnection>
<url>https://community.cablelabs.com/svn/EYES/trunk/alarm</url>
</scm>
</project>
package org.cablelabs.alarm;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Iterator;
import org.cablelabs.alarm.expression.EventCriteriaExpression;
import org.cablelabs.alarm.expression.EventCriteriaOperand;
import org.cablelabs.alarm.expression.OperandQueue;
import org.cablelabs.event.Event;
/**
* Represents an active or in-progress alarm that has matched an event against
* one or more positive event criteria in an event criteria expression
*/
public class Alarm
{
// List of events that track the history of this alarm in the
// RAISED state. This includes:
// - all events that had produced positive operands at the
// time the alarm transitions to the RAISED state
// - all events that produced any operand change during the
// time the alarm was in the RAISED state
// - the final event that transitioned the event from the
// RAISED to the CLEARED state
private List<Event<?>> m_events = new ArrayList<Event<?>>();
private State m_state = State.CLEARED;
private AlarmDescription m_description;
private EventCriteriaExpression m_expression;
private OperandQueue m_operands;
private Alarm m_lastRetired;
/**
* The states of an alarm
*/
public enum State
{
/**
* One or more of the positive event criteria has been matched, but the
* alarm is not yet raised
*/
IN_PROGRESS,
/**
* The alarm is currently in the raised state
*/
RAISED,
/**
* The alarm was cleared by a negative event
*/
CLEARED,
/**
* The alarm was cleared manually by calling {@link Alarm#clear}
*/
FORCE_CLEARED,
/**
* This alarm has none of its operands set to true, and is eligible to
* be disposed
*/
NOT_IN_PROGRESS
}
/**
* Creates a new in-progress or raised alarm.
*
* @param description
* the alarm description
* @param expression
* the alarm event criteria expression
* @param operands
* the initial operands for the expression
* @param initialState
* the initial state of this alarm. Must be one of
* {@link State#IN_PROGRESS} or {@link State#RAISED}
*/
public Alarm(AlarmDescription description,
EventCriteriaExpression expression, OperandQueue operands,
State initialState)
{
this(description, initialState);
if (expression == null