Commit a7f1fa9a authored by Gwenael Cattez's avatar Gwenael Cattez
Browse files

Final version of the Fire Detector CEP version

parent c0e666d2
...@@ -32,6 +32,12 @@ ...@@ -32,6 +32,12 @@
</parent> </parent>
<artifactId>fire-detector-dicepe</artifactId> <artifactId>fire-detector-dicepe</artifactId>
<properties>
<composite.file>fire-detector-dicepe</composite.file>
<composite.file.local>fire-detector-dicepe</composite.file.local>
<composite.file.deploy>fire-detector-dicepe</composite.file.deploy>
</properties>
<dependencies> <dependencies>
<dependency> <dependency>
......
...@@ -26,8 +26,14 @@ ...@@ -26,8 +26,14 @@
package org.ow2.frascati.firedetector.model.listeners.gui; package org.ow2.frascati.firedetector.model.listeners.gui;
import itemis.demo.Alarm;
import itemis.demo.AlarmListener;
import java.awt.Color; import java.awt.Color;
import java.awt.Container; import java.awt.Container;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import javax.swing.JFrame; import javax.swing.JFrame;
...@@ -58,6 +64,9 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R ...@@ -58,6 +64,9 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R
@Reference @Reference
private FireDetectorModelItf fireDetectorModel; private FireDetectorModelItf fireDetectorModel;
@Reference(required = false)
private AlarmListener alarmListener;
private JLabel coLabel; private JLabel coLabel;
private JSpinner coSpinner; private JSpinner coSpinner;
private JLabel temperatureLabel; private JLabel temperatureLabel;
...@@ -88,8 +97,13 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R ...@@ -88,8 +97,13 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R
{ {
JSpinner source = (JSpinner) e.getSource(); JSpinner source = (JSpinner) e.getSource();
Integer newValue = (Integer) source.getValue(); Integer newValue = (Integer) source.getValue();
Integer currentCOValue = fireDetectorModel.setCurrentCOValue(newValue); Integer currentCOValue=fireDetectorModel.getCurrentCOValue();
coSpinner.setValue(currentCOValue); if(newValue!=currentCOValue)
{
System.out.println("fd listener set co value");
currentCOValue = fireDetectorModel.setCurrentCOValue(newValue);
coSpinner.setValue(currentCOValue);
}
} }
}; };
coSpinner.addChangeListener(coSpinnerChangeListener); coSpinner.addChangeListener(coSpinnerChangeListener);
...@@ -105,8 +119,12 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R ...@@ -105,8 +119,12 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R
{ {
JSpinner source = (JSpinner) e.getSource(); JSpinner source = (JSpinner) e.getSource();
Integer newValue = (Integer) source.getValue(); Integer newValue = (Integer) source.getValue();
Integer currentTemperatureValue = fireDetectorModel.setCurrentTemperatureValue(newValue); Integer currentTemperatureValue=fireDetectorModel.getCurrentTemperatureValue();
temperatureSpinner.setValue(currentTemperatureValue); if(newValue!=currentTemperatureValue)
{
currentTemperatureValue = fireDetectorModel.setCurrentTemperatureValue(newValue);
temperatureSpinner.setValue(currentTemperatureValue);
}
} }
}; };
temperatureSpinner.addChangeListener(temperatureSpinnerChangeListener); temperatureSpinner.addChangeListener(temperatureSpinnerChangeListener);
...@@ -195,22 +213,6 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R ...@@ -195,22 +213,6 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R
mainFrame.setVisible(true); mainFrame.setVisible(true);
} }
private void clearAllLabel()
{
coLabel.setBackground(Color.white);
coLabel.repaint();
coAlertLabel.setBackground(Color.white);
coAlertLabel.repaint();
temperatureLabel.setBackground(Color.white);
temperatureLabel.repaint();
temperatureAlertLabel.setBackground(Color.white);
temperatureAlertLabel.repaint();
combinedCOLabel.setBackground(Color.white);
combinedCOLabel.repaint();
combinedTemperatureLabel.setBackground(Color.white);
combinedTemperatureLabel.repaint();
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.ow2.frascati.esper.api.EventListener#update(java.lang.String, java.util.List) * @see org.ow2.frascati.esper.api.EventListener#update(java.lang.String, java.util.List)
*/ */
...@@ -237,7 +239,15 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R ...@@ -237,7 +239,15 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R
{ {
temperatureSpinner.setValue(beanTemperatureValue); temperatureSpinner.setValue(beanTemperatureValue);
} }
}
else if(eventID.contains("Alert"))
{
Alarm alarm=new Alarm();
alarm.setId("fire detector");
Calendar calendar=GregorianCalendar.getInstance();
Date date=calendar.getTime();
alarm.setTimestramp(date);
alarmListener.notifyAlarm(alarm);
} }
} }
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
<esperEvents:Events> <esperEvents:Events>
<esperEvents:Event esperEvents:event-type='CLASS'>org.ow2.frascati.esper.bean.COBean</esperEvents:Event> <esperEvents:Event esperEvents:event-type='CLASS'>org.ow2.frascati.esper.bean.COBean</esperEvents:Event>
<esperEvents:Event esperEvents:event-type='CLASS'>org.ow2.frascati.esper.bean.TemperatureBean</esperEvents:Event> <esperEvents:Event esperEvents:event-type='CLASS'>org.ow2.frascati.esper.bean.TemperatureBean</esperEvents:Event>
<esperEvents:Event esperEvents:event-type='CLASS'>itemis.demo.Alarm</esperEvents:Event>
</esperEvents:Events> </esperEvents:Events>
</property> </property>
</component> </component>
...@@ -52,12 +53,12 @@ ...@@ -52,12 +53,12 @@
<implementation.java class="org.ow2.frascati.firedetector.model.FireDetectorModel" /> <implementation.java class="org.ow2.frascati.firedetector.model.FireDetectorModel" />
<reference name="esperEngine"> <reference name="esperEngine">
<interface.java interface="org.ow2.frascati.esper.api.EsperEngine" />
<frascati:binding.rest uri="http://localhost:9002/EsperEngine" /> <frascati:binding.rest uri="http://localhost:9002/EsperEngine" />
</reference> </reference>
<service name="fire-detector-model-service"> <service name="fire-detector-model-service">
<interface.java <interface.java interface="org.ow2.frascati.firedetector.model.FireDetectorModelItf" />
interface="org.ow2.frascati.firedetector.model.FireDetectorModelItf" />
</service> </service>
<service name="run"> <service name="run">
<interface.java interface="java.lang.Runnable" /> <interface.java interface="java.lang.Runnable" />
...@@ -69,7 +70,7 @@ ...@@ -69,7 +70,7 @@
</component> </component>
<component name="temperature-alert-statement"> <component name="temperature-alert-statement">
<implementation.composite name="stmt:temperature-alert-statement" /> <implementation.composite name="stmt:temperature-alert-statement"/>
</component> </component>
<component name="co-statement"> <component name="co-statement">
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
<service name="run-co-gui" promote="co-listener-gui/run"></service> <service name="run-co-gui" promote="co-listener-gui/run"></service>
<service name="eventListener" promote="co-listener-gui/eventListener" > <service name="eventListener" promote="co-listener-gui/eventListener" >
<frascati:binding.rest uri="http://localhost:9024/EventListener" /> <!-- <frascati:binding.rest uri="http://localhost:9024/EventListener" /> -->
</service> </service>
</composite> </composite>
\ No newline at end of file
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<!-- Contributors : --> <!-- Contributors : -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:esper="org/ow2/frascati/esper" xmlns:esperEvents="http://frascati.ow2.org/esper" xmlns:esper="org/ow2/frascati/esper" xmlns:esperEvents="http://frascati.ow2.org/esper" xmlns:wsdli="http://www.w3.org/2004/08/wsdl-instance"
xmlns:statementIDs="http://frascati.ow2.org/esper" xsi:schemaLocation="http://frascati.ow2.org/esper StatementIds.xsd" xmlns:statementIDs="http://frascati.ow2.org/esper" xsi:schemaLocation="http://frascati.ow2.org/esper StatementIds.xsd"
xmlns:frascati="http://frascati.ow2.org/xmlns/sca/1.1" name="co-listener"> xmlns:frascati="http://frascati.ow2.org/xmlns/sca/1.1" name="co-listener">
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
</component> </component>
<service name="eventListener" promote="co-listener/eventListener"> <service name="eventListener" promote="co-listener/eventListener">
<frascati:binding.rest uri="http://localhost:9023/EventListener" /> <!-- <frascati:binding.rest uri="http://localhost:9023/EventListener" /> -->
</service> </service>
</composite> </composite>
\ No newline at end of file
...@@ -46,11 +46,15 @@ ...@@ -46,11 +46,15 @@
<service name="run"> <service name="run">
<interface.java interface="java.lang.Runnable" /> <interface.java interface="java.lang.Runnable" />
</service> </service>
<reference name="alarmListener">
<interface.wsdl interface="AlarmListener.wsdl#wsdl.interface(AlarmListener)" />
<gcs:binding.jgroups xmlns:gcs="http://frascati.ow2.org/xmlns/gcs/1.0" cluster="fire_detector"/>
</reference>
</component> </component>
<service name="run-controller-gui" promote="fire-detector-controller/run"></service> <service name="run-controller-gui" promote="fire-detector-controller/run"></service>
<service name="eventListener" promote="fire-detector-controller/eventListener" > <service name="eventListener" promote="fire-detector-controller/eventListener" >
<frascati:binding.rest uri="http://localhost:9022/EventListener" /> <!-- <frascati:binding.rest uri="http://localhost:9022/EventListener" /> -->
</service> </service>
</composite> </composite>
\ No newline at end of file
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<service name="run-temperature-gui" promote="temperature-listener-gui/run"></service> <service name="run-temperature-gui" promote="temperature-listener-gui/run"></service>
<service name="eventListener" promote="temperature-listener-gui/eventListener" > <service name="eventListener" promote="temperature-listener-gui/eventListener" >
<frascati:binding.rest uri="http://localhost:9021/EventListener" /> <!-- <frascati:binding.rest uri="http://localhost:9021/EventListener" /> -->
</service> </service>
</composite> </composite>
\ No newline at end of file
...@@ -31,14 +31,13 @@ ...@@ -31,14 +31,13 @@
<property name="statementIDs" type="statementIDs:StatementIDs"> <property name="statementIDs" type="statementIDs:StatementIDs">
<statementIDs:StatementIDs> <statementIDs:StatementIDs>
<statementIDs:StatementID>Temperature</statementIDs:StatementID> <statementIDs:StatementID>Temperature</statementIDs:StatementID>
<statementIDs:StatementID>TemperatureAlert <statementIDs:StatementID>TemperatureAlert</statementIDs:StatementID>
</statementIDs:StatementID>
</statementIDs:StatementIDs> </statementIDs:StatementIDs>
</property> </property>
</component> </component>
<service name="eventListener" promote="temperature-listener/eventListener" > <service name="eventListener" promote="temperature-listener/eventListener" >
<frascati:binding.rest uri="http://localhost:9020/EventListener" /> <!-- <frascati:binding.rest uri="http://localhost:9020/EventListener" /> -->
</service> </service>
</composite> </composite>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2008-2012 Inria, University of Lille -->
<!-- -->
<!-- This library is free software; you can redistribute it and/or -->
<!-- modify it under the terms of the GNU Lesser General Public -->
<!-- License as published by the Free Software Foundation; either -->
<!-- version 2 of the License, or (at your option) any later version. -->
<!-- -->
<!-- This library is distributed in the hope that it will be useful, -->
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -->
<!-- Lesser General Public License for more details. -->
<!-- -->
<!-- You should have received a copy of the GNU Lesser General Public -->
<!-- License along with this library; if not, write to the Free Software -->
<!-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -->
<!-- -->
<!-- Contact: frascati@ow2.org -->
<!-- -->
<!-- Author: Gwenael CATTEZ -->
<!-- -->
<!-- Contributors : -->
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:esper="org/ow2/frascati/esper" xmlns:esperEvents="http://frascati.ow2.org/esper"
xmlns:frascati="http://frascati.ow2.org/xmlns/sca/1.1" name="alarm-launcher-statement">
<component name="alarm-launcher-statement" constrainingType="esper:Statement">
<implementation.java class="org.ow2.frascati.esper.impl.StatementImpl" />
<property name="eventID">AlarmLauncher</property>
<property name="statement">select * from Alarm</property>
</component>
<service name="alarm-launcher-statement" promote="alarm-launcher-statement/statement" />
</composite>
\ No newline at end of file
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
</component> </component>
<service name="co-alert-statement" promote="co-alert-statement/statement"> <service name="co-alert-statement" promote="co-alert-statement/statement">
<frascati:binding.rest uri="http://localhost:9014/Statement" /> <!-- <frascati:binding.rest uri="http://localhost:9014/Statement" /> -->
</service> </service>
</composite> </composite>
\ No newline at end of file
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</component> </component>
<service name="co-statement" promote="co-statement/statement"> <service name="co-statement" promote="co-statement/statement">
<frascati:binding.rest uri="http://localhost:9013/Statement" /> <!-- <frascati:binding.rest uri="http://localhost:9013/Statement" /> -->
</service> </service>
</composite> </composite>
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</component> </component>
<service name="combined-alert-statement" promote="combined-alert-statement/statement"> <service name="combined-alert-statement" promote="combined-alert-statement/statement">
<frascati:binding.rest uri="http://localhost:9012/Statement" /> <!-- <frascati:binding.rest uri="http://localhost:9012/Statement" /> -->
</service> </service>
</composite> </composite>
\ No newline at end of file
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
</component> </component>
<service name="temperature-alert-statement" promote="temperature-alert-statement/statement"> <service name="temperature-alert-statement" promote="temperature-alert-statement/statement">
<frascati:binding.rest uri="http://localhost:9011/Statement" /> <!-- <frascati:binding.rest uri="http://localhost:9011/Statement" /> -->
</service> </service>
</composite> </composite>
\ No newline at end of file
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</component> </component>
<service name="temperature-statement" promote="temperature-statement/statement"> <service name="temperature-statement" promote="temperature-statement/statement">
<frascati:binding.rest uri="http://localhost:9010/Statement" /> <!-- <frascati:binding.rest uri="http://localhost:9010/Statement" /> -->
</service> </service>
</composite> </composite>
\ No newline at end of file
/**
* OW2 FraSCAti Assembly Factory
* Copyright (C) 2008-2012 Inria, University of Lille
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: frascati@ow2.org
*
* Author: Gwenael Cattez
*
* Contributor(s):
*
*/
package org.ow2.frascati.demo.firedector.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import org.junit.Test;
import org.ow2.frascati.examples.test.FraSCAtiTestCase;
import org.ow2.frascati.firedetector.model.FireDetectorModelItf;
/**
*
*/
public class FireDetectorDICEPETestCase extends FraSCAtiTestCase
{
public static final String COMPOSITE = "fire-detector-dicepe.composite";
/* (non-Javadoc)
* @see org.ow2.frascati.examples.test.FraSCAtiTestCase#getComposite()
*/
@Override
public String getComposite()
{
return COMPOSITE;
}
@Test
public void test()
{
Runnable fireDetectorModelRun=(Runnable) getService(Runnable.class, "fire-detector-model-run");
fireDetectorModelRun.run();
FireDetectorModelItf fireDetectorModel= getService(FireDetectorModelItf.class, "fire-detector-model-service");
Integer newCOValue=new Integer(12);
fireDetectorModel.setCurrentCOValue(newCOValue);
Integer currentCOValue=fireDetectorModel.getCurrentCOValue();
assertEquals(newCOValue, currentCOValue);
Integer newTooHighCOValue=new Integer(100);
fireDetectorModel.setCurrentCOValue(newTooHighCOValue);
currentCOValue=fireDetectorModel.getCurrentCOValue();
assertNotSame(newTooHighCOValue, currentCOValue);
Integer newLowHighCOValue=new Integer(-100);
fireDetectorModel.setCurrentCOValue(newLowHighCOValue);
currentCOValue=fireDetectorModel.getCurrentCOValue();
assertNotSame(newLowHighCOValue, currentCOValue);
Integer newTemperatureValue=new Integer(60);
fireDetectorModel.setCurrentTemperatureValue(newTemperatureValue);
Integer currentTemperatureValue=fireDetectorModel.getCurrentTemperatureValue();
assertEquals(newTemperatureValue, currentTemperatureValue);
Integer newTooHighTemperatureValue=new Integer(100);
fireDetectorModel.setCurrentTemperatureValue(newTooHighTemperatureValue);
currentTemperatureValue=fireDetectorModel.getCurrentTemperatureValue();
assertNotSame(newTooHighTemperatureValue, currentTemperatureValue);
Integer newLowHighTemperatureValue=new Integer(-100);
fireDetectorModel.setCurrentTemperatureValue(newLowHighTemperatureValue);
currentTemperatureValue=fireDetectorModel.getCurrentTemperatureValue();
assertNotSame(newLowHighTemperatureValue, currentTemperatureValue);
Integer newCOAlertValue=new Integer(15);
fireDetectorModel.setCurrentCOAlertValue(newCOAlertValue);
Integer currentCOAlertValue=fireDetectorModel.getCurrentCOAlertValue();
assertEquals(newCOAlertValue, currentCOAlertValue);
Integer newTemperatureAlertValue=new Integer(60);
fireDetectorModel.setCurrentTemperatureAlertValue(newTemperatureAlertValue);
Integer currentTemperatureAlertValue=fireDetectorModel.getCurrentTemperatureAlertValue();
assertEquals(newTemperatureAlertValue, currentTemperatureAlertValue);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment