Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
frascati
frascati
Commits
a7f1fa9a
Commit
a7f1fa9a
authored
Jul 30, 2012
by
Gwenael Cattez
Browse files
Final version of the Fire Detector CEP version
parent
c0e666d2
Changes
15
Hide whitespace changes
Inline
Side-by-side
demo/fire-emergency/fire-detector-dicepe/pom.xml
View file @
a7f1fa9a
...
...
@@ -32,6 +32,12 @@
</parent>
<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>
<dependency>
...
...
demo/fire-emergency/fire-detector-dicepe/src/main/java/org/ow2/frascati/firedetector/model/listeners/gui/FireDetectorControllerGUI.java
View file @
a7f1fa9a
...
...
@@ -26,8 +26,14 @@
package
org.ow2.frascati.firedetector.model.listeners.gui
;
import
itemis.demo.Alarm
;
import
itemis.demo.AlarmListener
;
import
java.awt.Color
;
import
java.awt.Container
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.GregorianCalendar
;
import
java.util.List
;
import
javax.swing.JFrame
;
...
...
@@ -58,6 +64,9 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R
@Reference
private
FireDetectorModelItf
fireDetectorModel
;
@Reference
(
required
=
false
)
private
AlarmListener
alarmListener
;
private
JLabel
coLabel
;
private
JSpinner
coSpinner
;
private
JLabel
temperatureLabel
;
...
...
@@ -88,8 +97,13 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R
{
JSpinner
source
=
(
JSpinner
)
e
.
getSource
();
Integer
newValue
=
(
Integer
)
source
.
getValue
();
Integer
currentCOValue
=
fireDetectorModel
.
setCurrentCOValue
(
newValue
);
coSpinner
.
setValue
(
currentCOValue
);
Integer
currentCOValue
=
fireDetectorModel
.
getCurrentCOValue
();
if
(
newValue
!=
currentCOValue
)
{
System
.
out
.
println
(
"fd listener set co value"
);
currentCOValue
=
fireDetectorModel
.
setCurrentCOValue
(
newValue
);
coSpinner
.
setValue
(
currentCOValue
);
}
}
};
coSpinner
.
addChangeListener
(
coSpinnerChangeListener
);
...
...
@@ -105,8 +119,12 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R
{
JSpinner
source
=
(
JSpinner
)
e
.
getSource
();
Integer
newValue
=
(
Integer
)
source
.
getValue
();
Integer
currentTemperatureValue
=
fireDetectorModel
.
setCurrentTemperatureValue
(
newValue
);
temperatureSpinner
.
setValue
(
currentTemperatureValue
);
Integer
currentTemperatureValue
=
fireDetectorModel
.
getCurrentTemperatureValue
();
if
(
newValue
!=
currentTemperatureValue
)
{
currentTemperatureValue
=
fireDetectorModel
.
setCurrentTemperatureValue
(
newValue
);
temperatureSpinner
.
setValue
(
currentTemperatureValue
);
}
}
};
temperatureSpinner
.
addChangeListener
(
temperatureSpinnerChangeListener
);
...
...
@@ -195,22 +213,6 @@ public class FireDetectorControllerGUI extends EventListenerAdaptor implements R
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)
* @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
{
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
);
}
}
...
...
demo/fire-emergency/fire-detector-dicepe/src/main/resources/fire-detector-dicepe.composite
View file @
a7f1fa9a
...
...
@@ -44,6 +44,7 @@
<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.TemperatureBean
</esperEvents:Event>
<esperEvents:Event
esperEvents:event-type=
'CLASS'
>
itemis.demo.Alarm
</esperEvents:Event>
</esperEvents:Events>
</property>
</component>
...
...
@@ -52,12 +53,12 @@
<implementation.java
class=
"org.ow2.frascati.firedetector.model.FireDetectorModel"
/>
<reference
name=
"esperEngine"
>
<interface.java
interface=
"org.ow2.frascati.esper.api.EsperEngine"
/>
<frascati:binding.rest
uri=
"http://localhost:9002/EsperEngine"
/>
</reference>
<service
name=
"fire-detector-model-service"
>
<interface.java
interface=
"org.ow2.frascati.firedetector.model.FireDetectorModelItf"
/>
<interface.java
interface=
"org.ow2.frascati.firedetector.model.FireDetectorModelItf"
/>
</service>
<service
name=
"run"
>
<interface.java
interface=
"java.lang.Runnable"
/>
...
...
@@ -69,7 +70,7 @@
</component>
<component
name=
"temperature-alert-statement"
>
<implementation.composite
name=
"stmt:temperature-alert-statement"
/>
<implementation.composite
name=
"stmt:temperature-alert-statement"
/>
</component>
<component
name=
"co-statement"
>
...
...
demo/fire-emergency/fire-detector-dicepe/src/main/resources/listeners/co-listener-gui.composite
View file @
a7f1fa9a
...
...
@@ -47,7 +47,7 @@
<service
name=
"run-co-gui"
promote=
"co-listener-gui/run"
></service>
<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>
</composite>
\ No newline at end of file
demo/fire-emergency/fire-detector-dicepe/src/main/resources/listeners/co-listener.composite
View file @
a7f1fa9a
...
...
@@ -22,7 +22,7 @@
<!-- 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: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:frascati=
"http://frascati.ow2.org/xmlns/sca/1.1"
name=
"co-listener"
>
...
...
@@ -37,7 +37,7 @@
</component>
<service
name=
"eventListener"
promote=
"co-listener/eventListener"
>
<frascati:binding.rest
uri=
"http://localhost:9023/EventListener"
/>
<!--
<frascati:binding.rest uri="http://localhost:9023/EventListener" />
-->
</service>
</composite>
\ No newline at end of file
demo/fire-emergency/fire-detector-dicepe/src/main/resources/listeners/fire-detector-controller.composite
View file @
a7f1fa9a
...
...
@@ -46,11 +46,15 @@
<service
name=
"run"
>
<interface.java
interface=
"java.lang.Runnable"
/>
</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>
<service
name=
"run-controller-gui"
promote=
"fire-detector-controller/run"
></service>
<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>
</composite>
\ No newline at end of file
demo/fire-emergency/fire-detector-dicepe/src/main/resources/listeners/temperature-listener-gui.composite
View file @
a7f1fa9a
...
...
@@ -48,7 +48,7 @@
<service
name=
"run-temperature-gui"
promote=
"temperature-listener-gui/run"
></service>
<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>
</composite>
\ No newline at end of file
demo/fire-emergency/fire-detector-dicepe/src/main/resources/listeners/temperature-listener.composite
View file @
a7f1fa9a
...
...
@@ -31,14 +31,13 @@
<property
name=
"statementIDs"
type=
"statementIDs:StatementIDs"
>
<statementIDs:StatementIDs>
<statementIDs:StatementID>
Temperature
</statementIDs:StatementID>
<statementIDs:StatementID>
TemperatureAlert
</statementIDs:StatementID>
<statementIDs:StatementID>
TemperatureAlert
</statementIDs:StatementID>
</statementIDs:StatementIDs>
</property>
</component>
<service
name=
"eventListener"
promote=
"temperature-listener/eventListener"
>
<frascati:binding.rest
uri=
"http://localhost:9020/EventListener"
/>
<!--
<frascati:binding.rest uri="http://localhost:9020/EventListener" />
-->
</service>
</composite>
\ No newline at end of file
demo/fire-emergency/fire-detector-dicepe/src/main/resources/statements/alarm-launcher-statement.composite
deleted
100644 → 0
View file @
c0e666d2
<?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
demo/fire-emergency/fire-detector-dicepe/src/main/resources/statements/co-alert-statement.composite
View file @
a7f1fa9a
...
...
@@ -33,7 +33,7 @@
</component>
<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>
</composite>
\ No newline at end of file
demo/fire-emergency/fire-detector-dicepe/src/main/resources/statements/co-statement.composite
View file @
a7f1fa9a
...
...
@@ -32,7 +32,7 @@
</component>
<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>
</composite>
...
...
demo/fire-emergency/fire-detector-dicepe/src/main/resources/statements/combined-alert-statement.composite
View file @
a7f1fa9a
...
...
@@ -34,7 +34,7 @@
</component>
<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>
</composite>
\ No newline at end of file
demo/fire-emergency/fire-detector-dicepe/src/main/resources/statements/temperature-alert-statement.composite
View file @
a7f1fa9a
...
...
@@ -33,7 +33,7 @@
</component>
<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>
</composite>
\ No newline at end of file
demo/fire-emergency/fire-detector-dicepe/src/main/resources/statements/temperature-statement.composite
View file @
a7f1fa9a
...
...
@@ -32,7 +32,7 @@
</component>
<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>
</composite>
\ No newline at end of file
demo/fire-emergency/fire-detector-dicepe/src/test/java/org/ow2/frascati/demo/firedector/test/FireDetectorDICEPETestCase.java
0 → 100644
View file @
a7f1fa9a
/**
* 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
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment