blob: a153e50a934bfece834a9e5399414e0287ea8125 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
RoomModel DCParserTests {
import room.basic.types.* from "Types.room"
async ActorClass AC {
Interface {
Port prt: PC
Port replPrt[2]: PC
Port dataPort: PCData
}
Structure {
external Port prt
external Port replPrt
external Port dataPort
Attribute p[2]: Point
Attribute pt: Point
Attribute c: Circle
}
Behavior {
Operation distance(p1: Point, p2: Point): float64 '''
return p1.distance(p2);
'''
StateMachine {
State first {
entry '''
prt.start();
Point lpt = new Point(1,2);
prt.result(lpt);'''
}
State second {
entry '''
double d = c.diameter();
d = p[0].distance(p[1]);
d = distance(p[0], p[1]);
d = c.c.x;
'''
exit '''
replPrt[0].start();
replPrt.start();
prt[0].start();
'''
}
Transition init0: initial -> first
Transition tr0: first -> second {
triggers {
<circle: prt>
}
action '''transitionData.west().distance(transitionData.c);'''
}
State third
Transition tr1: second -> third {
guard '''true'''
action '''pt.set(dataPort.point);'''
}
}
}
}
datadriven ProtocolClass PCData {
incoming {
Message point(Point)
}
}
ProtocolClass PC {
incoming {
Message point(Point)
Message circle(Circle)
}
outgoing {
Message start()
Message result(Point)
}
}
DataClass Circle {
Operation diameter(): float64 '''
return 2*r;
'''
Operation west(): Point '''
return new Point(c.x + r, c.y);
'''
Operation isInside(other: Point): boolean '''
return c.distance(other) < r;
'''
Attribute r: float64
Attribute c: Point
}
DataClass Point {
Operation distance(other: Point): float64 '''
double dx = x - other.x;
double dy = y - other.y;
return Math.sqrt(dx*dx + dy*dy);
'''
Attribute x: float64
Attribute y: float64
}
}
|