Difference between revisions of "How to implement Universal Binding"

From WeizmannWiki
Jump to: navigation, search
(New page: At present [http://www.wisdom.weizmann.ac.il/~maozs/s2a/ S2A Compiler], which is the mechanism used for playing out LSC specification, does not support [[LSC Reference#Universal_Binding|un...)
 
 
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
At present [http://www.wisdom.weizmann.ac.il/~maozs/s2a/ S2A Compiler], which is the mechanism used for playing out LSC specification, does not support [[LSC Reference#Universal_Binding|universal binding]].
+
At present, the [http://www.wisdom.weizmann.ac.il/~maozs/s2a/ S2A Compiler], which is the mechanism used for playing out LSC specifications, does not support [[LSC Reference#Universal Dynamic Lifeline |universal dynamic lifelines]].
  
We demonstrate 2 alternatives for defining LSC with equivalent semantics to universal binding.<br> We want to specify the requirement: After event A occurred, for each instance of ClassB event B must occur.
+
We demonstrate two alternatives for defining LSC, both with semantics equivalent to universal binding.<br> We want to specify the requirement: After event A occurred, for each instance of ClassB event B must occur.
  
 
== Using concrete LSC  ==
 
== Using concrete LSC  ==
Line 13: Line 13:
 
[[Image:ConcreteLSC.png]]
 
[[Image:ConcreteLSC.png]]
  
As a result when play out starts, PlayGo transforms the specification into specification with no dynamic lifelines. Instead of each dynamic lifeline it creates multiple LSCs, each containing only static lifelines. PlayGo translates the dynamic lifelines into concrete/static lifelines, based on the objects, of the type defined by the lifeline, in the system model. For example:
+
As a result, when play-out starts, PlayGo transforms the specification into one with no dynamic lifelines. Instead of each dynamic lifeline, it creates multiple LSCs, each containing only static lifelines. PlayGo translates the dynamic lifelines into concrete/static lifelines, based on the objects of the type defined by the lifeline, which appear in the system model. For example:
  
 
[[Image:concreteLSCSpec.png | 1000px]]
 
[[Image:concreteLSCSpec.png | 1000px]]
Line 19: Line 19:
 
== Combining LSC with Java code  ==
 
== Combining LSC with Java code  ==
  
Define an LSC in which after event A occurs, a Java method that iterates all ClassB instances is triggered. The ClassB iterate method should iterate ClassB objects, and trigger a certain event D on each object.
+
Define an LSC, in which, after event A occurs, a Java method that iterates all ClassB instances is triggered. The ClassB iterate method should iterate ClassB objects, and trigger a certain event D on each object.
  
 
[[Image:UniversalBindingViaCode1.png]] <br> <br> Here is an example for an 'iterate' method: <br><br> [[Image:UniversalBindingViaCode3.png]]
 
[[Image:UniversalBindingViaCode1.png]] <br> <br> Here is an example for an 'iterate' method: <br><br> [[Image:UniversalBindingViaCode3.png]]
 
<br><br>
 
<br><br>
Now define an LSC that monitors that event D and executes even B. <br> When event D is monitored, a new live copy is created for the concrete object allowing execution of event B and any other required behavior for this object.
+
Now define an LSC that monitors that event D and executes event B. <br> When event D is monitored, a new live copy is created for the concrete object, allowing execution of event B and any other required behavior for this object.
  
 
[[Image:UniversalBindingViaCode2.png]]
 
[[Image:UniversalBindingViaCode2.png]]
  
 
<br> Similarly, one can implement the iterate method to trigger event B on a subset of ClassB objects, subject to a certain condition. This is equivalent to defining a lifeline of type Universal Binding having a binding expression.
 
<br> Similarly, one can implement the iterate method to trigger event B on a subset of ClassB objects, subject to a certain condition. This is equivalent to defining a lifeline of type Universal Binding having a binding expression.

Latest revision as of 06:55, 29 April 2014

At present, the S2A Compiler, which is the mechanism used for playing out LSC specifications, does not support universal dynamic lifelines.

We demonstrate two alternatives for defining LSC, both with semantics equivalent to universal binding.
We want to specify the requirement: After event A occurred, for each instance of ClassB event B must occur.

Using concrete LSC

Define your specification using lifelines of type 'Universal Binding' as required. For example:

UniversalBindingViaConcretization.png

When playing out the specification, check the 'Concrete LSC' checkbox:

ConcreteLSC.png

As a result, when play-out starts, PlayGo transforms the specification into one with no dynamic lifelines. Instead of each dynamic lifeline, it creates multiple LSCs, each containing only static lifelines. PlayGo translates the dynamic lifelines into concrete/static lifelines, based on the objects of the type defined by the lifeline, which appear in the system model. For example:

ConcreteLSCSpec.png

Combining LSC with Java code

Define an LSC, in which, after event A occurs, a Java method that iterates all ClassB instances is triggered. The ClassB iterate method should iterate ClassB objects, and trigger a certain event D on each object.

UniversalBindingViaCode1.png

Here is an example for an 'iterate' method:

UniversalBindingViaCode3.png

Now define an LSC that monitors that event D and executes event B.
When event D is monitored, a new live copy is created for the concrete object, allowing execution of event B and any other required behavior for this object.

UniversalBindingViaCode2.png


Similarly, one can implement the iterate method to trigger event B on a subset of ClassB objects, subject to a certain condition. This is equivalent to defining a lifeline of type Universal Binding having a binding expression.