ECA-DL e Transformaes Patrcia Dockhorn Costa pdcosta@inf.ufes.br - - PowerPoint PPT Presentation

eca dl e transforma es
SMART_READER_LITE
LIVE PREVIEW

ECA-DL e Transformaes Patrcia Dockhorn Costa pdcosta@inf.ufes.br - - PowerPoint PPT Presentation

ECA-DL e Transformaes Patrcia Dockhorn Costa pdcosta@inf.ufes.br Context-Awareness Context-Awareness Context the set of possibly interrelated conditions in which an entity exists. Context-Aware Application Context Application


slide-1
SLIDE 1

ECA-DL e Transformações

Patrícia Dockhorn Costa pdcosta@inf.ufes.br

slide-2
SLIDE 2

Context-Awareness Context-Awareness

slide-3
SLIDE 3

Context

the set of possibly interrelated conditions in which an entity exists.

slide-4
SLIDE 4

Context-Aware Application

Context Application

Context-aware application is a distributed application whose behaviour is affected by its users’ context.

slide-5
SLIDE 5

Developing Context-Aware Context-Aware Applications

slide-6
SLIDE 6

Basic Requirements

Capture Capture Process Process React React Capture Capture Process Process React React

slide-7
SLIDE 7

Capture Context

slide-8
SLIDE 8

Model Behaviour

slide-9
SLIDE 9

Multitude of Sensors

slide-10
SLIDE 10

Distributed Application

slide-11
SLIDE 11

Context-Aware Application

slide-12
SLIDE 12

Supporting Context-Aware Application Development

slide-13
SLIDE 13

Supporting Context-Aware Application Development (cont.)

Quite some work on that: context-aware patterns; context-aware patterns; services platform (context sources, managers, controllers, action resolvers, etc.); context and situation models; situation reasoning and (distributed) detection; ECA language for modelling reactive behaviours, etc.

slide-14
SLIDE 14

ECA-DL ECA-DL

slide-15
SLIDE 15

Padrão Event-Control-Action Pattern

slide-16
SLIDE 16

Elementos Básicos de ECA- DL

slide-17
SLIDE 17

Navigation

Aims at reaching values or objects of concern in the context and situation models Navigation in ECA-DL is similar to navigation in OCL “dots” to navigate from objects to attributes The target element is always a primitive datatype The target element is always a primitive datatype (numeric, boolean or string) We also include the type of object being navigated

slide-18
SLIDE 18

Navigation (example)

  • !

"

  • #
  • $%&'

$%' $!"

  • #

()

  • #

()

  • %
  • &

'

  • %
  • '
  • #

()

  • # ()
  • #

()

slide-19
SLIDE 19

Navigation - collection

&* Supported by means of select clause

slide-20
SLIDE 20

Events in ECA-DL

Situation events (transitions EnterTrue (S) e EnterFalse(S)) Primitive events: not detected by means of situations IncomeCall (entityFrom, entityTo) IncomeCall (entityFrom, entityTo) Temporal events Generated from time-to-time OnEvery(t) Complex events Composition of primitive or situation events

slide-21
SLIDE 21

Complex Events

  • +,
  • ' . ,
  • /0,1 2 3 - ' ' . , 3

.' 4,

  • ' ,

0,

  • ' . ,

56 5)378&9::0; 56 5)378&9::

slide-22
SLIDE 22

Timestamps

An event occurs at a specific time: occurrence time (he time interval during which a composite event is being detected Initiator: initiates the composite detection Terminator: terminates the detection Terminator: terminates the detection The occurrence time of a composite/complex event is the terminator’s occurrence time

slide-23
SLIDE 23

Event Consumption

Events are consumed by ECA-DL rules “John enters the room and at most 15 minutes later he turns his computer on” John enters the room at 15:05 hrs, 15:10 hrs, and at 15:13 hrs 15:13 hrs John turns his computer on at 15:15 hrs (terminator)

Which notification is the initiator? In ECA-DL, the oldest (15:05) And this notification is NOT considered again: Notification is consumed by the rule! John turns his computer on again at 15:18 hrs Which notification is the initiator?

slide-24
SLIDE 24

Event Consumption

  • Event e3: (e1&e2)

Notifications: e1, e1, e2, e1, e2

slide-25
SLIDE 25

Detection Window

Event: (e1&e2) Notifications: e1, e1, e2, e1, e2

'

  • ,
  • 5

:

  • 3
  • ,

5.: '

slide-26
SLIDE 26

Upon-When-Action clause

<=> ?=> $=>

slide-27
SLIDE 27

Select clause

65=>0=>0= >: 65&*88>7: 65&*886?) 5:: 6565&*88>7:8,8 6565&*88>7:8,8 6?) 5,::

slide-28
SLIDE 28

Scope clause

65=>0: / <= > ?=> $=> 1 6565&*886 58::8:: / < 56 5:: $@58AB: 1

slide-29
SLIDE 29

Lifetime

< 56 5&98&C:: $@5&C8AC89 B:

  • '

' =>=>

slide-30
SLIDE 30

Metamodelo

  • #

%

#

  • #

D # % # D

  • !
  • "
  • *

* #

  • #

%

  • #

D

  • #
  • !
  • $
  • *
  • *
  • !
  • !
  • $
  • %
  • &
  • *
  • $

!

  • $
  • #
  • &
  • '
  • "

%

  • &
  • (
  • #
  • *
slide-31
SLIDE 31

Rule Execution

  • <
  • $
  • E
  • F

GD

  • G
  • E'
  • F
slide-32
SLIDE 32

Examples

<D 5&9: ?6$ 5&9: $66 5&98A98 H8B: 655&*00 IAB " IAB: 0: / <D 5: ?6$ 5: $66 58AJH8 B: 1

slide-33
SLIDE 33

Examples

655&*00 IA.B: 0: / <K6D 5: $66 58AJB: 1 6565&*00 D IA'GB0: / <- 5L: $@D 58 "585*8,0 6?) 58,: ,DIM'G:::

1

slide-34
SLIDE 34

ECA-DL to Jess ECA-DL to Jess

slide-35
SLIDE 35

Gerenal Mapping

) * ) + < ? $ 5: 5 : I> 5: 5: 5: I> 5: 5: 5:

slide-36
SLIDE 36

Upon clause

To implement event consumption

Events are always associated with a rule

Event types as Jess Fact Templates

  • # $

(6

  • # $

()

  • #

()

  • $

) $

!

  • #

(6

  • #

$ (6

  • #

$ (6

  • ,
  • # ;

(6

  • #

(6

  • !
  • #
  • '
  • #

(6

  • # $

(6

  • # ,$

(6

  • $

+, 5 5$ AB: 5$ AB:: 5, 5$ A,B: 5$ AB:: /0,1 2 3 5 5$ AB: 5$ AB: 5 N:: 5, 5$ A,A: 5$ AA: 5 N,+(5> N, N::: 5 53 5$ A3A: 5$ AA: 5 N3+(5 5>N3 N: 5=N3 N,::::: 4, 5 5 5$ AA: 5$ AA:: 5, 5$ A,A: 5$ AA::: 0, 5 5$ AA: 5$ AA: 5 N:: 5, 5$ A,A: 5$ AA: 5 N,+(5> N, N:::

slide-37
SLIDE 37

Upon clause (Detection Window)

5 $?' D 55,:: N = 556 5$ AB: 5N+(5>5#N':56C:::: 5 5$ AB: 5N+(5>5#N':56C:::: 5N+(5>5#N':56C:::: 56?) 5$ AB: 5N+(5>5#N':56C::::: I> 5N::

slide-38
SLIDE 38

Example (upon)

D$"( <; 56 5&98 %K9::0 ; 56 5&C8%K9:: 966( 966( 56 5$ AB:5$ AB: 5$ AK9B: 5$ A9B:5 N:: 56 5$ O,O:5$ OO: 5$ AK9B: 5$ ACB: 5 N,+(5> N, N:::

slide-39
SLIDE 39

Example (ECA-DL)

65&*0:/ <D 5: ?KHDH $@&D 5:1

  • 5

D) P N = 5 D

  • 5OO:5OO:5

$ N

  • :5

N :: 5 &

  • 5-

%9

  • N
  • :5N
  • :5

H D N :: 55K H

  • D

5- %9

  • N
  • :5

H

  • N
  • +(5I N
  • )

<

  • ::::

55K H

  • D

5- %9

  • N
  • :5

H

  • N
  • +(5I N
  • )

<

  • ::::

I > 5 N ::

  • 5

D ) P, N = 5 D

  • 5OO:5OO:5

$ N

  • :5

N:: 5 &

  • 5-

%9

  • N
  • :5N
  • :5

H

  • DN
  • ::

5K

  • H

D 5- % 9

  • N
  • :5

H

  • N
  • +(5I N
  • )

<

  • :::

I > 5 N : 5 K

  • D

) &

  • D
  • N
  • ::
slide-40
SLIDE 40

ECA-DL to NCL ECA-DL to NCL

slide-41
SLIDE 41

The SBTVD

Better quality of images/videos; Provides interactivity; Includes standards for data modulation, transmission, data encoding, and a transmission, data encoding, and a middleware (coined Ginga).

slide-42
SLIDE 42

Middleware Ginga

56-D)6 D6)-8,Q:

slide-43
SLIDE 43

Nested Context Language

Hypermedia authoring language used to describe multimedia applications with space- time synchronization between media objects (e.g., video, audio, images, etc.); As such, it does not have built-in concepts for context-handling and reactivity; NCLua

Scripting language; Allows execution of imperative code in the declarative environment

slide-44
SLIDE 44

Context in the SBTVD Context in the SBTVD

slide-45
SLIDE 45

Capturing Context

Context- External Context- Aware Application External Entities NCLua

slide-46
SLIDE 46

Interactivity Channel

5D%@@%)LRS8,Q:

slide-47
SLIDE 47

... in Ginga

NCL Interactivity NCL Document Interactivity Channel NCLua

slide-48
SLIDE 48

Representing Context

NCL Interactivity NCL Document Interactivity Channel NCLua Property Anchors

slide-49
SLIDE 49

The Event Channel

NCL Interactivity Event Channel NCL Document Interactivity Channel NCLua Event-based interactions

slide-50
SLIDE 50

Events

NCL Interactivity Event Channel NCL Document Interactivity Channel NCLua events of type “tcp” events of type “ncl”

slide-51
SLIDE 51

It gets cumbersome when handling various context sources and context events

Problems with the standard

Event Channel NCLua handler handler Interactivity Channel

slide-52
SLIDE 52

Contribution

We have defined and implemented a programming framework that solves issues related to (context) event handling in the Ginga middleware;

TCPEventHandler: reusable code for facilitating the communication between NCL applications and external communication between NCL applications and external devices; Properties: provides reusable code to help managing property anchor values in NCLua scripts

Available

  • nline

at [http://code.google.com/p/itveventframework/].

slide-53
SLIDE 53

The Libraries

Properties TCPEventHandler NCL Document NCLua Interactivity Channel

slide-54
SLIDE 54

Reacting upon Context Changes

NCL Document NCLua Context Sources Properties TCPEventHandler Document NCLua Sources Monitoring Context

slide-55
SLIDE 55

Connectors and Links

Used to implement synchronism between NCL elements

E.g.: at the end of a video, starts another video

Allows (with some adaptation) Allows (with some adaptation) implementation of context-aware reaction rules

slide-56
SLIDE 56

Now we know how to...

NCLDocument NCLua Properties TCPEventHandler Context Sources Sources External Services conector link

slide-57
SLIDE 57

Prototypes Prototypes

slide-58
SLIDE 58

Audience Detector

slide-59
SLIDE 59

Audience Detector

Execution examples

slide-60
SLIDE 60

Heart Frequency Monitor

slide-61
SLIDE 61

Heart Frequency Monitor

slide-62
SLIDE 62

Context and Situation Models, ECA-DL TVD Models, ECA-DL TVD and a Services Platform

slide-63
SLIDE 63

Ginga lacks generic services and there is no methodology for supporting context-aware development; The architecture should be in line with context models, situation models and ECA rules.

Motivation

models, situation models and ECA rules.

slide-64
SLIDE 64

Flexible and extensible; Perform context and situation reasoning; Support distribution;

Requirements for a Context Management Platform

Support distribution; Mobile; Facilitate rapid development of context-aware applications.

slide-65
SLIDE 65

The Context Management Platform Architecture

slide-66
SLIDE 66

An MDA Approach An MDA Approach

slide-67
SLIDE 67

Overview

Context and Situation Models (UML Profile ECA-DL TVD Rules Context-Aware Application Models Controller (NCL Document) Context Sources Action Resolvers Context-Aware Application (implementation) T1 developer Resolvers Context Manager Platform Ginga Platform

slide-68
SLIDE 68

Transformation Overview

ECA-DL TVD transformation NCL transformation language (java)

instance of defined in defined in terms of

ECA-DL TVD metamodel transformation specification NCL metamodel context and situation models and ECA-DL rules NCL model NCL document (XML-like) and NCLua scripts transformation activities (eclipse tools)

defined in terms of terms of instance of instance of generated by

slide-69
SLIDE 69

Transforming a rule-based specification at the platform-independent level into an implementation platform that is not rule-

Main Challenge of the Transformation

implementation platform that is not rule-

  • riented, while preserving conformance to the

standard.

slide-70
SLIDE 70

Case Study

'.G

  • 9'.

..G T

slide-71
SLIDE 71

Case Study: Context Model

slide-72
SLIDE 72

Case Study: Situation Model

Situation “One person in the room”:

slide-73
SLIDE 73

Case Study: Situation Model

Situation “Accessing”:

slide-74
SLIDE 74

ECA-DL TVD rules

Upon EnterTrue SituationAccessing (person1) When SituationOnePersonInRoom (room1) Do startWithBalance(account1) Upon EnterTrue SituationAccessing (person1) When SituationMoreThanOnePersonInRoom (room1) Do startWithoutBalance(account1) Upon EnterTrue SituationOnePersonInRoom (room1) Do showBalance(account1) Upon EnterTrue SituationMoreThanOnePersonInRoom (room1) Do hideBalance(account1) Upon EnterTrue SituationNoPersonInRoom (room1) Do logout(account1)

slide-75
SLIDE 75

Ecore Model

slide-76
SLIDE 76

Generated NCL Document

Entities and Intrinsic Context types:

  • Relational Context types:
slide-77
SLIDE 77

Generated Context Situations

  • !"#$%&'(

) "*

  • *+ ,#- *"

"* + +

  • + " "*
  • . !"#$%&'(

* ) * ,#- * !"#$%& .

slide-78
SLIDE 78

Generated ECA-DL TVD

  • /

*+ 1 *" "* +

  • + 2 " "*

+ 2 " "*

  • . /

* $%& * $%& 1 * #,3 2 .

slide-79
SLIDE 79

Quite a few running context-aware applications; A programming framework; A methodology for developing context-aware applications, including:

Contributions to the SBTVD

applications, including:

U modelling artefacts (context, situation and ECA-DL TVD) U a reference architecture; U a model-driven approach to generate NCL documents (+ NCL scripts) from high-level context-aware application specifications.

slide-80
SLIDE 80

ECA-DL to Drools ECA-DL to Drools

slide-81
SLIDE 81

Upon Clause with primitive events

Upon IncomeCall (Person.John, Person.Mary) Do StartMonitoring()

declare IncomeCall @role(event) rule ”rule 1” when @role(event) end when $event: IncomeCall(entityFrom == “John”, entityTo == “Mary”) then startMonitoring(); retract($event); end

slide-82
SLIDE 82

Upon Clause with primitive events (cont.)

Upon IncomeCall(Person.Mary, Person.John) ; IncomeCall(Person.Mary, Person.Fabio) Do startMonitoring()

declare IncomeCall @role(event) rule ”rule 1” when @role(event) end when $event1: IncomeCall(entityFrom == “Mary”, entityTo == “John”) $event2: IncomeCall(entityFrom == “Mary”, entityTo == “Fabio”, this after $event1) then startMonitoring(); retract($event1); retract($event2); end

slide-83
SLIDE 83

Upon Clause with primitive events and When Clause

Upon IncomeCall(Person.Mary, Person.John) When Person.Mary.inRoom Do startMonitoring()

rule ”rule 1” when rule ”rule 1-2” when when //event $event1: IncomeCall(entityFrom == “Mary”, entityTo == “John”) //condition Person(name == “Mary”, inRoom == true) then startMonitoring(); retract($event1); End when //event $event1: IncomeCall(entityFrom == “Mary”, entityTo == “John”) //not condition not( exists( Person(name == “Mary”, inRoom == true))) then retract($event1); end

slide-84
SLIDE 84

Upon with EnterTrue() e EnterFalse() – Solution 1

Upon EnterTrue(Person.Mary.inRoom) Do startWorking() rule “Mary enters room” when when Person(name == “Mary”, inRoom == true) then startWorking(); End

slide-85
SLIDE 85

Upon with EnterTrue() e EnterFalse() – Solution 2

Upon EnterTrue(Person.Mary.inRoom) Do startWorking()

declare EnterTruePerson

rule “rule 1” when rule “rule 2” when

EnterTruePerson Room @role(event) person: Person end

when $mary: Person(name == “Mary”, inRoom == true) then insert(new EnterTruePersonRoom($mary)); end when $e: EnterTruePersonRoom(person. name == “Mary”, person.inRoom == true) Then startWorking(); retract($e); End

slide-86
SLIDE 86

Upon with EnterTrue() e EnterFalse() – Solution 3

Upon EnterTrue(Person.Mary.inRoom) Do startWorking()

declare SituationFact end

Declare PersonInRoom extends SituationFact person: Person

end declare EnterTrueTransition @role(event) SituationFact: SituationFact end declare EnterFalseTransition @role(event) SituationFact: SituationFact End

person: Person end

slide-87
SLIDE 87

Upon EnterTrue(Person.Mary.inRoom) Do startWorking()

rule “rule 1” when $mary: Person(name == “Mary”, iRoom == true) not (exists (PersonInRoom(person == $mary))) then PersonInRoom spir = new rule “rule 2” when not (exists (Person(name == “Mary”, iRoom == true))) $spir: PersonInRoom(person.name == “Mary”, person.inRoom == true) then PersonInRoom spir = new PersonInRoom($mary); insert(spir); insert(new EnterTrueTransition ((SituationFact)spir)); end then retract($spir); //inserir enterfalsetransition end

slide-88
SLIDE 88

Upon EnterTrue(Person.Mary.inRoom) Do startWorking()

rule "rule 3 - evento EnterTrue desejado ocorre" when $situation: PersonInRoom(person.name == "Mary", person.inRoom==true) $e: EnterTrueSituation(situationFact == $situation) then startWorking(); retract($e); end

slide-89
SLIDE 89

Upon EnterTrue(Person.Pablo.inRoom) ; EnterTrue (Person.Pablo.hasSkypeStatus == SkypeStatus.online)

declare PersonInRoom extends SituationFact person: Pessoa end declare SkypeStatusOnline extends SituationFact declare SkypeStatusOnline extends SituationFact person: Pessoa end

slide-90
SLIDE 90

Upon EnterTrue(Person.Pablo.inRoom) ; EnterTrue (Person.Pablo.hasSkypeStatus == SkypeStatus.online)

//Geramos 5 regras em Drools! rule "rule 1 – person in room" when $pablo: Pessoa(nome == " Pablo", inRoom == true) $pablo: Pessoa(nome == " Pablo", inRoom == true) not (exists (PersonInRoom(person == $mary))) then PersonInRoom situation = new PersonInRoom($pablo); insert(situation); insert(new EnterTrueSituation ((SituationFact)situation)); end

// Regra para gerar EnterFalse, mais duas regras para SkypeStatus....

slide-91
SLIDE 91

Upon EnterTrue(Person.Pablo.inRoom) ; EnterTrue (Person.Pablo.hasSkypeStatus == SkypeStatus.online)

rule “rule 5” when $sitPablo: PersonInRoom( person.nome == "Pablo", person.inRoom == true) $sitSkypeOnLine: SkypeStatus( person.nome == "Pablo", person.hasSkypeStatus == SkypeStatus.online) //events //events $e1: EnterTrueSituation (situationFact == $sitPablo) $e2: EnterTrueSituationS (situationSKS == $sitSkypeOnLine, this after $e1) then <…> retract($e1); retract($e2); end

slide-92
SLIDE 92