This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
v040:language [2016/03/22 22:59] deva |
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 385: | Line 385: | ||
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. | ||
- | We suggest reviewing the //clock// and //pingpong// models of the demo projects to see examples for port based communication. | + | We suggest reviewing the //clock// and //pingpong// models of the {{v040:demo.zip|demo projects}} to see examples for port based communication. |
==== State machines ==== | ==== State machines ==== | ||
Line 627: | 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 641: | Line 641: | ||
<code> | <code> | ||
// XtxtUML: | // XtxtUML: | ||
- | B obj = instanceOfA->AB::b.selectAny(); | + | B obj = instanceOfA->(AB.b).selectAny(); |
</code> | </code> | ||
Line 647: | Line 647: | ||
<code> | <code> | ||
+ | // XtxtUML: | ||
connect(Comp1.a, aObj->(A.P), Comp2.b, bObj->(B.Q)); | connect(Comp1.a, aObj->(A.P), Comp2.b, bObj->(B.Q)); | ||
</code> | </code> | ||
<code java> | <code java> | ||
+ | // JtxtUML: | ||
Action.connect(Comp1.a.class, aObj.port(A.P.class), | Action.connect(Comp1.a.class, aObj.port(A.P.class), | ||
Comp2.b.class, bObj.port(B.Q.class)); | Comp2.b.class, bObj.port(B.Q.class)); | ||
</code> | </code> | ||
- | === Signal sending === | + | === 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 664: | 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> | ||