The STADiUM language framework for capturing domain-specific interaction patterns

448 views
425 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
448
On SlideShare
0
From Embeds
0
Number of Embeds
25
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

The STADiUM language framework for capturing domain-specific interaction patterns

  1. 1. Coen De Roover Christophe ScholliersSoftware Languages Lab, Brussels Wouter AmerijckxThe STADiUM language framework forcapturing domain-specific interaction patterns
  2. 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. 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. 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 perspectivedispatch expir ecompensate specify interactions declaratively ementstate manag network-centric perspective specify which rules govern which components configurable runtime application-specific semantics of events
  5. 5. nodThe 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. 6. nodDistributed Interaction Rules cen e-... publishing facts on the network tricfact in fact base temperatureReading(Celsius=27)@[factExpires(Seconds=600)]matching condition in rule celsiusReading(Celsius=?value)@[to(Mac=*)] ← temperatureReading(Celsius=?value)
  7. 7. nodDistributed 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. 8. nodDistributed 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. 9. nodReifying 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 Reificatione.g., temperature readings mapping temperatureReading(Celsius=?temp)@[factExpires(Seconds=600)] <=> Event_101(Integer=?temp).
  10. 10. nodReifying Events as Facts cen e-... fine-tuning the reification engine tric controlling fact subsumptione.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. 11. netWSN Application as a Whole wo cen rk-... which CrimeSPOT code goes where? tric quantify over components enumerate rules and supporting codee.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. 12. netWSN Application as a Whole wo cen rk-... reusing CrimeSPOT code tric macro definition and applicationComfortLevelMonitor { 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)] }
  13. 13. Motivating Example Revisited... lines of CrimeSPOT code for the entire WSN Application 73
  14. 14. Motivating Example Revisited... TemperatureSensor and HumiditySensor components 1. TemperatureSensor,  HumiditySensor,  HeatingController  { 2.        publishPresenceEvery($onlineInterval). 3. } 4. TemperatureSensor  { 5.        temperatureMapping($readingInterval).         6.        temperatureReading(Celsius=?temp)@[to(MAC=*), 7.                                                                              factExpires($readingInterval)]   8.            <-­‐  ?temp  is  this.getTemperature()@[renewEvery($readingInterval)]. 9.  } 10.   11.  TemperatureSensor.java  { 12.        private  CSValue  getTemperature()  {  return  ...  } 13.  } 14.  HumiditySensor  { 15.        humidityMapping($readingInterval). 16.        humidityReading(Percent=?p)@[to(MAC=*), 17.                                                                  factExpires($readingInterval)] 18.          <-­‐  ?p  is  this.getHumidity()@[renewEvery($readingInterval)]   19.  } 20.   21.  HumiditySensor.java  { 22.        private  CSValue  getHumidity()  {  return  ...  } 23.  }
  15. 15. Motivating Example Revisited... component HeatingController24. HeatingController  {25.        incoming  adjustHeating(Level=?new)  subsumes  adjustHeating(Level=?old).26.            27.        this.adjustHeater28.            <-­‐  adjustHeating(Level=?h).29. }30.  31. HeatingController.java  {32.    private  CSAction  adjustHeater  =  new  CSAction()  {33.          public  void  activated(CSVariableBindings  bindings)  {  //adjust  heating  }34.          public  void  deactivate(CSVariableBindings  bindings)  {  //reset  heating  }35.    };    36. }
  16. 16. Motivating Example Revisited... component ComfortLevelMonitor37.    ComfortLevelMonitor  {  38.        temperatureMapping($readingInterval).39.        humidityMapping($readingInterval).40.        subsumesOlderFromSameTent(humidityReading,Percent).41.        subsumesOlderFromSameTent(temperatureReading,Celsius).42.        incoming  online(Tent=?tnt,Component=?c)@[from(MAC=?m)]  43.        subsumes  online(Tent=?otnt,Component=?c)@[from(MAC=?m)].      44.                        45.        this.logComfortLevel46.            <-­‐  humidityReading(Percent=?h)@[from(MAC=?hm,ID=?hi)],              47.                  temperatureReading(Celsius=?t)@[from(MAC=?tm,ID=?ti)],48.                  online(Tent=?tnt)@[from(MAC=?hm,ID=?hi)],49.                  online(Tent=?tnt)@[from(MAC=?tm,ID=?ti)].50.            37.        adjustHeating(Level=?heatingLevel)@[to(MAC=?hcm,ID=?hci),38.                                                                                factExpires($readingInterval)]39.            <-­‐  temperatureReading(Celsius=?t)@[from(MAC=?tm,ID=?ti)],40.                  online(Tent=?tnt)@[from(MAC=?tm,ID=?ti)],41.                  ?heatingLevel  is  this.computeHeatingLevel((Number)?t),42.                  online(Component=`HeatingController,Tent=?tnt)@[from(MAC=?hcm,ID=?hci)].  43.    }  44.  45.    ComfortLevelMonitor.java  {46.      private  CSValue  computeHeatingLevel(Number  t)  {  return  ...  }47.  }
  17. 17. Motivating Example Revisited... code shared by all components48.  *.java  {49.        private  CSValue  getTentBasedOnGPSReading()  {  return  ...  }50.  }51.  52.  *  {        53.        defvar  $readingInterval:  Seconds=600.54.        defvar  $onlineInterval:  Seconds=3600.55.  56.        defmacro  temperatureMapping():57.                mapping  temperatureReading(Celsius=?temp)@[factExpires($readingInterval)]  58.            <=>  Event_101(Integer=?temp).59.                  60.        defmacro  humidityMapping():61.                mapping  humidityReading(Percent=?h)@[factExpires($readingInterval)]  62.            <=>  Event_102(Integer=?h).63.  64.        defmacro  publishPresenceEvery($time):65.              online(Tent=?tnt,Component=`$COMPONENT_NAME)@[to(MAC=*),factExpires($time)]    66.                    <-­‐  ?tnt  is  this.getTentBasedOnGPSReading()@[renewEvery($time)].67.                  68.        defmacro  subsumesOlderFromSameTent($reading,$type):69.              incoming  $reading($type=?new)@[from(MAC=?mac)]70.              subsumes  $reading($type=?old)@[from(MAC=?othermac)]71.              provided  online(Tent=?tnt)@[from(MAC=?mac)],72.                online(Tent=?tnt)@[from(MAC=?othermac)].73.  }
  18. 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. 19. Conclusions... and future worklanguage 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 readingssoftware engineering characteristics node-centric: interactions untangled from application logic interaction rules straightforward to compose network-centric: library of network configurationstowards analyses for application-specific middleware modules (WP3.1) profile application with respect to network and memory usage explicit in code: expirations, intervals

×