The STADiUM language framework for capturing domain-specific interaction patterns
1. Coen De Roover Christophe Scholliers
Software Languages Lab, Brussels Wouter Amerijckx
The STADiUM language framework for
capturing domain-specific interaction patterns
2. Motivating Example
... SE problems associated with event-based programming
Tent C
Tent B
Tent A
Component:
subscribed to single event
Component:
HumiditySensor
TemperatureSensor
Component:
receiveEvent(Event e) {
online
HeatingController
// invoke application logic
online
temperatureReading online
// publish new event
humidityReading
adjustHeating
}
Decentralized Event Bus
difficult to compose event handlers
online
humidityReading
adjustHeating
temperatureReading subscribed to multiple events
Component:
dispatch over received events
ComfortLevelMonitor
manage state (event sequences)
relate events through matching
3. Motivating Example
... problems inherent to the STADiUM domain
Tent C
Tent B
Tent A
compensate reactions to stale readings
Component:
TemperatureSensor
Component:
HumiditySensor
Component:
state changes
HeatingController
online
online
context-dependent behavioral adaptions
temperatureReading online
humidityReading
adjustHeating
Decentralized Event Bus
online
adjustHeating
humidityReading events carry sensor readings
temperatureReading
readings expire
Component:
ComfortLevelMonitor
readings subsume others
application-specific: time, content, origin
4. CrimeSPOT in a Nutshell
... a domain-specific language for programming WSN interactions
minimize accidental complexity so developers can
focus on essential complexity
m atch sub
sume node-centric perspective
dispatch expir
e
compensate specify interactions declaratively
ement
state manag
network-centric perspective
specify which rules govern which components
configurable runtime
application-specific semantics of events
5. nod
The CrimeSPOT runtime cen e-
... architectural overview
tric
CrimeSPOT runtime
inference engine
Inference Layer evaluates rules against facts
Fact Inference Rule tracks causality
Base Engine Base
Reification Layer reification engine
Reification Configuration reifies events as facts
Engine Base
expiration and subsumption
Infrastructure Layer
Middleware Bridge
Middleware Bridge middleware bridge
transfers events to and from bus
bridge to LooCI
6. nod
Distributed Interaction Rules cen e-
... publishing facts on the network tric
fact in fact base
temperatureReading(Celsius=27)@[factExpires(Seconds=600)]
matching condition in rule
celsiusReading(Celsius=?value)@[to(Mac=*)]
← temperatureReading(Celsius=?value)
7. nod
Distributed Interaction Rules cen e-
... invoking application logic tric
from body of rule
e.g., unicast a reading upon a request
humidityReading(Percent=?p)@[to(MAC=?mac, ID=?id)]
← requestForHumidity()@[from(MAC=?mac, ID=?id)],
?p is this.getHumidity()
e.g., broadcast a reading at set intervals
humidityReading(Percent=?p)@[to(MAC=*),factExpires(Seconds=600)]
← ?p is this.getHumidity()@[renewEvery(Seconds = 600)]
8. nod
Distributed Interaction Rules cen e-
... invoking application logic tric
in head of rule
e.g., a state change that has to be undone
this.adjustHeater
← adjustHeating(Level=?h)
class HeatingController
private CSAction adjustHeater = new CSAction() {
public void activated(CSVariableBindings bindings) { //adjust heating }
public void deactivate(CSVariableBindings bindings) { //reset heating }
};
}
9. nod
Reifying Events as Facts cen e-
... fine-tuning the reification engine tric
mapping LooCI events to CrimeSPOT facts
Configuration
Base
Decentralized
Event Bus
Middleware Reification Fact
Event Fact
Bridge Engine Base
Event Drop? Subsumes? Assert
Reification
e.g., temperature readings
mapping temperatureReading(Celsius=?temp)@[factExpires(Seconds=600)]
<=> Event_101(Integer=?temp).
10. nod
Reifying Events as Facts cen e-
... fine-tuning the reification engine tric
controlling fact subsumption
e.g., a humidity reading subsumes others from same tent
incoming humidityReading(Percent=?new)@[from(ID=?id)]
subsumes humidityReading(Percent=?old)@[from(ID=?otherid)]
provided online(Tent=?tent)@[from(ID=?id)],
online(Tent=?tent)@[from(ID=?otherid)]
11. net
WSN Application as a Whole wo
cen rk-
... which CrimeSPOT code goes where?
tric
quantify over components
enumerate rules and supporting code
e.g., tent-related code shared by all components
*{
online(Tent=?tnt)@[to(MAC=*),factExpires(Seconds=3600)]
← ?tnt is this.getTentBasedOnGPSReading()@[renewEvery(Seconds=3600)].
}
*.java {
private CSValue getTentBasedOnGPSReading() { return ... }
}
12. net
WSN Application as a Whole wo
cen rk-
... reusing CrimeSPOT code
tric
macro definition and application
ComfortLevelMonitor {
subsumesOlderFromSameTent(humidityReading,Percent).
subsumesOlderFromSameTent(temperatureReading,Celsius).
}
* { defmacro subsumesOlderFromSameTent($reading,$type):
incoming $reading($type =?new)@[from(ID=?id)]
subsumes $reading($type =?old)@[from(ID=?otherid)]
provided online(Tent=?tent)@[from(ID=?id)],
online(Tent=?tent)@[from(ID=?otherid)]
}
18. Evaluation
... using CrimeSPOT on top of LooCI on SunSPOT motes
73 lines of code for motivating example
LooCI: component deployment, wiring
event routing, service discovery 73
node-centric CrimeSPOT: event dispatching, storage, matching
expiration, subsumption, causality, exceptions
network-centric CrimeSPOT: untangles application logic from interaction rules
library of interaction rules
validated expressiveness using 6 representative STADiUM applications (R.2.2.4)
temperature monitoring, fire detection, flood monitoring, range coverage
on average 0.22 mappings, 4.14 interaction rules, 3.72 component methods
overhead
∆ROM: +460kB ∆RAM: 3kB / fact, 30kB / worst-case rule with 6 conditions
assertion latency: 30ms (LooCI event) 80ms (CrimeSPOT fact)
19. Conclusions
... and future work
language for programming WSN interactions
minimizes accidental complexity so developer can focus on essential complexity
node-centric: declarative rules specify interactions
network-centric: which rules govern which components
domain-specific: semantics for events that carry sensor readings
software engineering characteristics
node-centric: interactions untangled from application logic
interaction rules straightforward to compose
network-centric: library of network configurations
towards analyses for application-specific middleware modules (WP3.1)
profile application with respect to network and memory usage
explicit in code: expirations, intervals