User Tools

Site Tools


v040:language

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
v040:language [2016/03/22 22:34]
deva [Ports and connectors]
v040:language [2016/03/24 10:45] (current)
deva [Ports and connectors]
Line 351: Line 351:
 <code java> <code java>
 // JtxtUML // JtxtUML
-public class HourValues ​extends Connector {+public class ExampleConnector ​extends Connector {
   public class connEnd1 extends One<​Comp1.b,​ B.P> {}   public class connEnd1 extends One<​Comp1.b,​ B.P> {}
   public class connEnd2 extends One<​Comp2.c,​ C.Q> {}   public class connEnd2 extends One<​Comp2.c,​ C.Q> {}
Line 383: Line 383:
 Currently only ''​One''​ is supported as connector end multiplicity. Currently only ''​One''​ is supported as connector end multiplicity.
  
-The above delegation connector is valid only if the interfaces of the ports are compatible, meaning that the required interface of R is the same as the required interface of S and similarly for the provided interfaces.+The above delegation connector is valid only if the interfaces of the ports are compatible, meaning that the required interface of ''​R'' ​is the same as the required interface of ''​S'' ​and similarly for the provided interfaces.
  
-=== Creacting connection instances in run time === +We suggest reviewing the //clock// and //​pingpong//​ models of the {{v040:​demo.zip|demo projects}} to see examples for port based communication.
- +
-TODO +
- +
-We suggest reviewing the //clock// and //​pingpong//​ models of the demo projects to see examples for port based communication.+
 ==== State machines ==== ==== State machines ====
  
Line 510: Line 506:
  
 In //​XtxtUML//,​ use the ''​sigdata''​ keyword inside effect or guard to obtain the signal instance that triggered the currently performed transition. Its type is automatically inferred as the common supertype of the possible triggers. In //​JtxtUML//,​ the protected ''​getSignal''​ method shall be used instead. In //​XtxtUML//,​ use the ''​sigdata''​ keyword inside effect or guard to obtain the signal instance that triggered the currently performed transition. Its type is automatically inferred as the common supertype of the possible triggers. In //​JtxtUML//,​ the protected ''​getSignal''​ method shall be used instead.
 +
 +Transitions can also be labeled by //ports//. In that case the transition is triggered only if the specified signal arrives from the specified port.
 +
 +<​code>​
 +transition ExampleTransition {
 +  from State1;
 +  to State2;
 +  port ExamplePort;​
 +  trigger ExampleSignal;​
 +}
 +</​code>​
 +
 +<code java>
 +@From(State1.class) @To(State2.class)
 +@Trigger(port = ExamplePort.class,​ value = ExampleSignal.class)
 +class ExampleTransition extends Transition {}
 +</​code>​
  
 === Choice nodes === === Choice nodes ===
Line 614: Line 627:
 <​code>​ <​code>​
 // XtxtUML: // XtxtUML:
-Collection<​B>​ all = instanceOfA->​AB::b;+Collection<​B>​ all = instanceOfA->​(AB.b)// the parentheses after -> are mandatory
 B obj = all.selectAny();​ B obj = all.selectAny();​
 </​code>​ </​code>​
Line 628: Line 641:
 <​code>​ <​code>​
 // XtxtUML: // XtxtUML:
-B obj = instanceOfA->​AB::b.selectAny();​+B obj = instanceOfA->​(AB.b).selectAny();​
 </​code>​ </​code>​
  
-=== Signal sending ===+=== Connector instantiation === 
 + 
 +<​code>​ 
 +// XtxtUML: 
 +connect(Comp1.a,​ aObj->​(A.P),​ Comp2.b, bObj->​(B.Q));​ 
 +</​code>​ 
 + 
 +<code java> 
 +// JtxtUML: 
 +Action.connect(Comp1.a.class,​ aObj.port(A.P.class),​ 
 +               ​Comp2.b.class,​ bObj.port(B.Q.class));​ 
 +</​code>​ 
 + 
 +=== Starting the state machine of an object === 
 + 
 +<​code>​ 
 +// XtxtUML: 
 +start(obj);​ 
 +</​code>​ 
 + 
 +<code java> 
 +// JtxtUML: 
 +Action.start(obj);​ 
 +</​code>​ 
 + 
 +=== Signal sending ​to objects ​===
  
 <​code>​ <​code>​
Line 640: Line 678:
 <code Java> <code Java>
 // JtxtUML: // JtxtUML:
-Action.send(obj, sig); // sig is a signal instance.+Action.send(sig, obj); // sig is a signal instance. 
 +</​code>​ 
 + 
 +=== Signal sending to ports === 
 + 
 +<​code>​ 
 +// XtxtUML 
 +send sig to this->​(MyPort);​ 
 +</​code>​ 
 + 
 +<code java> 
 +// JtxtUML 
 +Action.send(sig,​ port(MyPort.class).required::​reception);​
 </​code>​ </​code>​
  
v040/language.1458682474.txt.gz · Last modified: 2016/03/22 22:34 by deva