Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 23b4c9c93e6d7987ffc78da5172ab997f5bc585b (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
<?xml version='1.0' ?><!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<book>
	<title>eTrice User Guide</title>
	<chapter id="eTriceOverview">
		<title>eTrice Overview</title>
		<section id="WhatiseTrice">
			<title>What is eTrice?</title>
			<para>eTrice provides an implementation of the ROOM modeling language (Real Time Object Oriented Modeling) together with editors, code generators for Java, C++ and C code and exemplary target middleware.</para>
			<para>The model is defined in textual form (Xtext) with graphical editors (Graphiti) for the structural and behavioral (i.e. state machine) parts.  </para>
		</section>
		<section id="ReductionofComplexity">
			<title>Reduction of Complexity</title>
			<para>eTrice is all about the reduction of complexity:</para>
			<itemizedlist>
				<listitem>
					<para>structural complexity</para>
					<itemizedlist>
						<listitem>
							<para>by explicit modeling of hierarchical Actor containment, layering and inheritance</para>
						</listitem>
					</itemizedlist>
				</listitem>
				<listitem>
					<para>behavioral complexity</para>
					<itemizedlist>
						<listitem>
							<para>by hierachical statemachines with inheritance</para>
						</listitem>
					</itemizedlist>
				</listitem>
				<listitem>
					<para>teamwork complexity</para>
					<itemizedlist>
						<listitem>
							<para>because loosely coupled Actors provide a natural way to structure team work</para>
						</listitem>
						<listitem>
							<para>since textual model notation allows simple branching and merging</para>
						</listitem>
					</itemizedlist>
				</listitem>
				<listitem>
					<para>complexity of concurrent &amp; distributed systems</para>
					<itemizedlist>
						<listitem>
							<para>because loosely coupled Actors are deployable to threads, processes, nodes</para>
						</listitem>
					</itemizedlist>
				</listitem>
				<listitem>
					<para>complexity of variant handling and reuse (e.g. for product lines)</para>
					<itemizedlist>
						<listitem>
							<para>by composition of existing Actors to new structures</para>
						</listitem>
						<listitem>
							<para>since Protocols and Ports make Actors replaceable</para>
						</listitem>
						<listitem>
							<para>by inheritance for structure, behavior and Protocols</para>
						</listitem>
						<listitem>
							<para>by making use of model level libraries</para>
						</listitem>
					</itemizedlist>
				</listitem>
				<listitem>
					<para>complexity of debugging</para>
					<itemizedlist>
						<listitem>
							<para>model level debugging: state machine animation, data inspection and manipulation, message injection, generated message sequence charts</para>
						</listitem>
						<listitem>
							<para>model checking easier for model than for code (detect errors before they occur)</para>
						</listitem>
					</itemizedlist>
				</listitem>
			</itemizedlist>
		</section>
	</chapter>
	<chapter id="IntroductiontotheROOMLanguage">
		<title>Introduction to the ROOM Language</title>
		<section id="ScopeofROOM">
			<title>Scope of ROOM</title>
			<para>This chapter will give a rough overview of what ROOM (
				<emphasis role="bold">R</emphasis> eal time 
				<emphasis role="bold">O</emphasis> bject 
				<emphasis role="bold">O</emphasis> riented 
				<emphasis role="bold">M</emphasis> odeling) is and what it is good for. It will try to answer the following questions:
			</para>
			<itemizedlist>
				<listitem>
					<para>Where does it come from?</para>
				</listitem>
				<listitem>
					<para>Which kind of SW-Systems will be addressed?</para>
				</listitem>
				<listitem>
					<para>What is the relation between OOP and ROOM?</para>
				</listitem>
				<listitem>
					<para>What are the benefits of ROOM?</para>
				</listitem>
				<listitem>
					<para>Which consequences must be taken into account?</para>
				</listitem>
			</itemizedlist>
			<section id="Wheredoesitcomefrom">
				<title>Where does it come from?</title>
				<para>Room was developed in the 1990th on the background of the upcoming mobile applications with the goal to manage the complexity of such huge SW-Systems. From the very beginning ROOM has focused on a certain type of SW-Systems and is, in contrast to the UML, well suited for this kind of systems. In this sense, ROOM is a DSL (Domain Specific Language) for distributed, event driven, real time systems. </para>
				<para>Bran Selic, Garth Gullekson and Paul T. Ward have published the concepts 1994 in the book 
					<emphasis role="bold">Real-Time Object-Oriented Modeling</emphasis>. The company 
					<emphasis>object time</emphasis> &#8482; developed a ROOM tool which was taken over by 
					<emphasis>Rational SW</emphasis> &#8482; and later on by 
					<emphasis>IBM</emphasis> &#8482;. 
					The company 
					<emphasis>Protos Software Gmbh</emphasis> &#8482; also developed a ROOM tool called 
					<emphasis>Trice</emphasis> &#8482; for control software for production machines and automotive systems. 
					<emphasis>Trice</emphasis> &#8482; is the predecessor of eTrice (see Introduction to eTrice). 
				</para>
				<para>From our point of view ROOM provides still the clearest, simplest, most complete and best suited modeling concepts for the real time domain. All later proposals like the UML do not fit as well to this kind of problems.</para>
			</section>
			<section id="WhichkindofSWSystemswillbeaddressed">
				<title>Which kind of SW-Systems will be addressed?</title>
				<para>As mentioned before ROOM addresses distributed, event driven, real time systems. But what is a 
					<emphasis role="bold">real time system</emphasis>? ROOM defines a set of properties which are typical for a real time system. These properties are:
				</para>
				<itemizedlist>
					<listitem>
						<para>Timeliness</para>
					</listitem>
					<listitem>
						<para>Dynamic internal structure</para>
					</listitem>
					<listitem>
						<para>Reactiveness</para>
					</listitem>
					<listitem>
						<para>Concurrency</para>
					</listitem>
					<listitem>
						<para>Distribution</para>
					</listitem>
					<listitem>
						<para>Reliability</para>
					</listitem>
				</itemizedlist>
				<para>Each of these properties has potential to make SW development complex. If a given system can be characterized with a combination of or all of these properties, ROOM might be applied to such a system.  </para>
				<para>As an example take a look at a washing machine. The system has to react on user interactions, has to handle some error conditions like a closed water tap or a defective lye pump. It has to react simultaneously to all these inputs. It has to close the water valve in a certain time to avoid flooding the basement. 
					So, the system can be characterized as timely, concurrent and reactive. As long as the washing machine does not transform to a laundry drier by itself, the system has no dynamic internal structure and as long as all functions are running on a single micro controller the (SW)-system is not distributed. 
					ROOM fits perfect to such a system.</para>
				<para>A SW system which mainly consists of data transformations like signal/image processing or a loop controller (e.g. a PID controller) cannot be characterized with any of the above mentioned properties. However, in the real world most of the SW systems will be a combination of both. ROOM can be combined with such systems, so that for example an actor provides a 
					<emphasis role="bold">run to completion</emphasis> context for calculating an image processing algorithm or a PID controller.  
				</para>
			</section>
			<section id="WhatistherelationbetweenOOPandROOM">
				<title>What is the relation between OOP and ROOM?</title>
				<para>The relation between classical object oriented programming and ROOM is comparable to the relation between assembler programming and C programming. It provides a shift of the object paradigm. As the picture shows, the classic object paradigm provides some kind of information hiding. Attributes can be accessed via access methods. Logical higher level methods provide the requested behavior to the user.   </para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/010-RoomIntroduction01.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>As the figure illustrates, the classical object paradigm does not care about concurrency issues. The threads of control will be provided by the underlying operating system and the user is responsible to avoid access violations by using those operating system mechanisms directly (semaphore, mutex).</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/010-RoomIntroduction02.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>ROOM provides the concept of a logical machine (called actor) with its own thread of control. It provides some kind of cooperative communication infrastructure with 
					<emphasis role="bold">run to completion</emphasis> semantic. That makes developing of business logic easy and safe (see basic concepts). The logical machine provides an encapsulation shell including concurrency issues (see chapter 
					<emphasis role="bold">Run to completion</emphasis>). 
				</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/010-RoomIntroduction03.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>This thinking of an object is much more general than the classic one.  </para>
			</section>
			<section id="WhatarethebenefitsofROOM">
				<title>What are the benefits of ROOM?</title>
				<para>ROOM has a lot of benefits and it depends on the users point of view which is the most important one. From a general point of view the most important benefit is, that ROOM allows to create SW systems very efficient, robust and safe due to the fact that it provides some abstract, high level modeling concepts combined with code generation and a small efficient runtime environment.  </para>
				<para>In detail:</para>
				<itemizedlist>
					<listitem>
						<para>ROOM models contain well defined interfaces (protocols), which makes it easy to reuse components in different applications or e.g. in a test harness. </para>
					</listitem>
					<listitem>
						<para>Graphical modeling makes it easy to understand, maintain and share code with other developers</para>
					</listitem>
					<listitem>
						<para>Higher abstraction in combination with automated code generation provides very efficient mechanisms to the developer. </para>
					</listitem>
					<listitem>
						<para>ROOM provides graphical model execution, which makes it easy to understand the application or find defects in a very early phase. </para>
					</listitem>
				</itemizedlist>
			</section>
			<section id="Whichconsequencesmustbetakenintoaccount">
				<title>Which consequences must be taken into account?</title>
				<para>Generating code from models will introduce some overhead in terms of memory footprint as well as performance. For most systems the overhead will be negligible. However, the decision for using ROOM should be made explicitly and it is always a trade off between development costs, time to market and costs in terms of a little bit more of memory and performance. Thanks to the powerful component model, ROOM is especially well suited for the development of software product lines with their need for reusable core assets.  </para>
				<para>Care must be taken during the introduction of the new methodology. Due to the fact that ROOM provides a shift of the object paradigm, developers and teams need a phase of adaption. Every benefit comes at a price.</para>
			</section>
		</section>
		<section id="BasicConcepts">
			<title>Basic Concepts</title>
			<section id="ActorPortProtocol">
				<title>Actor, Port, Protocol</title>
				<para>The basic elements of ROOM are the actors with their ports and protocols. The protocol provides a formal interface description. The port is an interaction point where the actor interacts with its outside world. Each port has exactly one protocol attached. The sum of all ports builds up the complete interface of an actor. Each port can receive messages, with or without data, which are defined in the attached protocol. Each message will be handled by the actors behavior (state machine) or will be delegated to the actors internal structure.</para>
				<para><table title="Actor and Protocol Example">
						<tr>
							<td>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-ActorClass.png"/>
						</imageobject>
					</mediaobject></td>
							<td>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-ProtocolClassTextualNotation.png"/>
						</imageobject>
					</mediaobject></td>
						</tr>
						<tr>
							<td align="center">
					<emphasis role="bold">Actor with Subactors</emphasis></td>
							<td align="center">
					<emphasis role="bold">Protocol Definition</emphasis></td>
						</tr>
</table>
				</para>
				<para>The actor provides access protection for its own attributes (including complex types (classical objects)), including concurrency protection. An actor has neither public attributes nor public operations. The only interaction with the outside world takes place via interface ports. This ensures a high degree of reusability on actor level and provides an effective and safe programming model to the developer. </para>
				<para>Receiving a message via a port will trigger the internal state machine. A transition will be executed depending on the message and the current state. Within this transition, detail level code will be executed and response messages can be sent.</para>
				<para>
					<ulink url="http://eclipse.org/etrice/images/010-room-introduction01.avi">video: receiving a message</ulink>
				</para>
				<para>With this model, a complex behavior can be divided into many relatively simple, linked actors. To put it the other way round: The complex behavior will be provided by a network of relatively simple components which are communicating with each other via well defined interfaces.</para>
			</section>
			<section id="HierarchyinStructureandBehavior">
				<title>Hierarchy in Structure and Behavior</title>
				<para>ROOM provides two types of hierarchy. Behavioral hierarchy and structural hierarchy. Structural hierarchy means that actors can be nested to arbitrary depth. Usually you will add more and more details to your application with each nesting level. That means you can focus yourself on any level of abstraction with always the same element, the actor. Structural hierarchy provides a powerful mechanism to divide your problem in smaller pieces, so that you can focus on the level of abstraction you want to work on. </para>
				<para>The actor’s behavior will be described with a state machine. A state in turn may contain sub states. This is another possibility to focus on an abstraction level. Take the simple FSM from the blinky actor from the blinky tutorial. </para>
				<para>Top level:

					<mediaobject>
						<imageobject>
							<imagedata fileref="images/020-Blinky15.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>
					<emphasis>blinking</emphasis> Sub machine:

					<mediaobject>
						<imageobject>
							<imagedata fileref="images/020-Blinky151.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>From an abstract point of view there is a state 
					<emphasis>blinking</emphasis>. But a simple LED is not able to blink autonomously. Therefore you have to add more details to your model to make a LED blinking, but for the current work it is not of interest how the blinking is realized. This will be done in the next lower level of the hierarchy. 
				</para>
				<para>This simple example might give an idea how powerful this mechanisms is.</para>
				<para>The hierarchical FSM provides a rich tool box to describe real world problems (see 
					<emphasis role="bold">room concepts</emphasis>).
				</para>
			</section>
			<section id="Layering">
				<title>Layering</title>
				<para>Layering is another well known form of abstraction to reduce complexity in the structure of systems. ROOM is probably the only language that supports Layering directly as language feature.
					Layering can be expressed in ROOM by Actors with specialized Ports, called Service Access Points (
					<emphasis role="bold">SAP</emphasis>) and Service Provision Points (
					<emphasis role="bold">SPP</emphasis>).
				</para>
				<para>The Actor that provides a service implements an SPP and the client of that service implements an SAP. The Layer Connection connects all SAPs of a specific Protocol within an Actor hierarchy with an SPP that implements the service. From the Actors point of view, SAPs and SPPs behave almost like regular ports.</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/010-LayerExample.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>The Example shows a layered model. The Layer Connections define e.g. that the 
					<emphasis>ApplicationLayer</emphasis> can only use the services of the 
					<emphasis>ServiceLayer</emphasis> and the 
					<emphasis>CommunicationLayer</emphasis>. Actors inside the 
					<emphasis>ApplicationLayer</emphasis> that implement an SAP for those services are connected directly to the implementation of the services. 
					Layering and actor hierarchies with port to port connections can be mixed on every level of granularity. 
				</para>
			</section>
			<section id="RuntoCompletion">
				<title>Run to Completion</title>
				<para>
					<emphasis role="bold">Run to completion</emphasis> (RTC) is a very central concept of ROOM. It enables the developer to concentrate on the functional aspects of the system. The developer doesn’t have to care about concurrency issues all the time. This job is concentrated to the system designer in a very flexible way.
					What does 
					<emphasis role="bold">run to completion</emphasis> mean:
					RTC means that an actor, which is processing a message, can not receive the next message as long as the processing of the current message has been finished. Receiving of the next message will be queued from the underlying run time system.
				</para>
				<para>Note: It is very important not to confuse run to completion and preemption. Run to completion means that an actor will finish the processing of a message before he can receive a new one (regardless of its priority). That does not mean that an actor cannot be preempted from an higher priority thread of control. But even a message from this higher prior thread of control will be queued until the current processing has been finished. </para>
				<para>With this mechanism all actor internal attributes and data structures are protected. Due to the fact that multiple actors share one thread of control, all objects are protected which are accessed from one thread of control but multiple actors. This provides the possibility to decompose complex functionality to several actors without the risk to produce access violations or dead locks.</para>
			</section>
		</section>
		<section id="ExecutionModels">
			<title>Execution Models</title>
			<para>Since from ROOM models executable code can be generated, it is important to define the way the actors are executed and communicate with each other. The combination of communication and execution is called the Execution Model.
				Currently the eTrice tooling only supports the 
				<emphasis role="bold">message driven</emphasis> and parts of the 
				<emphasis role="bold">data driven</emphasis> execution model. In future releases more execution models will be supported, depending on the requirements of the community.
			</para>
			<section id="CommunicationMethods">
				<title>Communication Methods</title>
				<itemizedlist>
					<listitem>
						<para>
							<emphasis role="bold">message driven</emphasis> (asynchronous, non blocking, no return value): Usually the message driven communication is implemented with message queues. Message queues are inherently asynchronous and enable a very good decoupling of the communicating parties.
						</para>
					</listitem>
					<listitem>
						<para>
							<emphasis role="bold">data driven</emphasis> (asynchronous, non blocking, no return value): In data driven communication sender and receiver often have a shared block of data. The sender writes the data and the receiver polls the data.
						</para>
					</listitem>
					<listitem>
						<para>
							<emphasis role="bold">function call</emphasis> (synchronous, blocking, return value): Regular function call as known in most programming languages.
						</para>
					</listitem>
				</itemizedlist>
			</section>
			<section id="ExecutionMethods">
				<title>Execution Methods</title>
				<itemizedlist>
					<listitem>
						<para>
							<emphasis role="bold">execution by receive event</emphasis>: The message queue or the event dispatcher calls a 
							<emphasis role="bold">receive event</emphasis> function of the message receiver an thereby executes the processing of the event.
						</para>
					</listitem>
					<listitem>
						<para>
							<emphasis role="bold">polled execution</emphasis>: The objects are processed by a cyclic 
							<emphasis role="bold">execute</emphasis> call
						</para>
					</listitem>
					<listitem>
						<para>
							<emphasis role="bold">execution by function call</emphasis>: The caller executes the called object via function call
						</para>
					</listitem>
				</itemizedlist>
			</section>
			<section id="ExecutionModels2">
				<title>Execution Models</title>
				<para>In todays embedded systems in most cases one or several of the following execution models are used:</para>
				<section id="messagedriven">
					<title>message driven</title>
					<para>The message driven execution model is a combination of message driven communication and execution by receive event.
						This model allows for distributed systems with a very high throughput.
						It can be deterministic but the determinism is hard to proof.
						This execution model is often found in telecommunication systems and high performance automation control systems.</para>
				</section>
				<section id="datadriven">
					<title>data driven</title>
					<para>The data driven execution model is a combination of data driven communication and polled execution.
						This model is highly deterministic and very robust, but the polling creates a huge performance overhead.
						The determinism is easy to proof (simple mathematics). 
						The execution model is also compatible with the execution model of control software generated by Tools like Matlab&#8482; and LabView&#8482;.
						This model is usually used for systems with requirements for safety, such as automotive and avionic systems.</para>
				</section>
				<section id="synchronous">
					<title>synchronous</title>
					<para>The synchronous execution model could also be called 
						<emphasis role="bold">simple function calls</emphasis>. 
						This model is in general not very well suited to support the 
						<emphasis role="bold">run to completion</emphasis> semantic typical for ROOM models, but could also be generated from ROOM models. 
						With this execution model also lower levels of a software system, such as device drivers, could be generated from ROOM models.
					</para>
				</section>
			</section>
		</section>
	</chapter>
	<chapter id="WorkingwiththeeTriceTutorials">
		<title>Working with the eTrice Tutorials</title>
		<para>The eTrice Tutorials will help you to learn and understand the eTrice tool and concepts. ETrice supports several target languages. The concepts will not be explained for each language. </para>
		<para>Most of the common concepts will be described for Java as target language. To start with a new language the first steps to setup the workspace and to generate and run the first model will be described also. Target language specific aspects will be described as well.</para>
		<para>Therefore the best way to start with eTrice is to follow the Java Tutorials and after that switch to your target language.  </para>
	</chapter>
	<chapter id="SettinguptheWorkspaceforJavaProjects">
		<title>Setting up the Workspace for Java Projects</title>
		<para>ETrice generates code out of ROOM models. The code generator and the generated code relies on a runtime framework and on some ready to use model parts. This parts provide services like:</para>
		<itemizedlist>
			<listitem>
				<para>messaging</para>
			</listitem>
			<listitem>
				<para>logging</para>
			</listitem>
			<listitem>
				<para>timing</para>
			</listitem>
		</itemizedlist>
		<para>Additionally some tutorial models will be provided to make it easy to start with eTrice. All this parts must be available in our workspace before you can start working. After installation of eclipse (juno) and the eTrice plug in, your workspace should look like this:  </para>
		<para>
			<mediaobject>
				<imageobject>
					<imagedata fileref="images/013-SetupWorkspace01.png"/>
				</imageobject>
			</mediaobject>
		</para>
		<para>Just the 
			<emphasis>eTrice</emphasis> menu item is visible from the eTrice tool.
			From the 
			<emphasis>File</emphasis> menu select 
			<emphasis>File-&gt;New-&gt;Project</emphasis>
		</para>
		<para>
			<mediaobject>
				<imageobject>
					<imagedata fileref="images/013-SetupWorkspace02.png"/>
				</imageobject>
			</mediaobject>
		</para>
		<para>Open the 
			<emphasis>eTrice</emphasis> tab and select 
			<emphasis>eTrice Java Runtime</emphasis>
		</para>
		<para>Press 
			<emphasis>Next</emphasis> and 
			<emphasis>Finish</emphasis> to install the Runtime into your workspace.
		</para>
		<para>
			<mediaobject>
				<imageobject>
					<imagedata fileref="images/013-SetupWorkspace03.png"/>
				</imageobject>
			</mediaobject>
		</para>
		<para>Do the same steps for 
			<emphasis>eTrice Java Modellib</emphasis> and 
			<emphasis>eTrice Java Tutorials</emphasis>. To avoid temporary error markers you should keep the proposed order of installation. The resulting workspace should look like this:
		</para>
		<para>
			<mediaobject>
				<imageobject>
					<imagedata fileref="images/013-SetupWorkspace04.png"/>
				</imageobject>
			</mediaobject>
		</para>
		<para>Now workspace is set up and you can perform the tutorials or start with your work.</para>
		<para>The tutorial models are available in the 
			<emphasis>org.eclipse.etrice.tutorials</emphasis> project. All tutorials are ready to generate and run without any changes. To start the code generator simply run 
			<emphasis role="bold">gen_org.eclipse.etrice.tutorials.launch</emphasis> as 
			<emphasis role="bold">gen_org.eclipse.etrice.tutorials.launch</emphasis>: 
		</para>
		<para>
			<mediaobject>
				<imageobject>
					<imagedata fileref="images/013-SetupWorkspace05.png"/>
				</imageobject>
			</mediaobject>
		</para>
		<para>After generation for each tutorial a java file called 
			<emphasis role="bold">SubSystem_ModelnameRunner.java</emphasis> is generated. To run the model simply run this file as a java application:
		</para>
		<para>
			<mediaobject>
				<imageobject>
					<imagedata fileref="images/013-SetupWorkspace06.png"/>
				</imageobject>
			</mediaobject>
		</para>
		<para>To stop the application type 
			<emphasis>quit</emphasis> in the console window.
		</para>
		<para>
			<mediaobject>
				<imageobject>
					<imagedata fileref="images/013-SetupWorkspace07.png"/>
				</imageobject>
			</mediaobject>
		</para>
		<para>Performing the tutorials will setup an dedicated project for each tutorial. Therefore there are some slight changes especially whenever a path must be set (e.g. to the model library) within your own projects. All this is described in the tutorials.</para>
	</chapter>
	<chapter id="TutorialHelloWorldforJava">
		<title>Tutorial HelloWorld for Java</title>
		<section id="Scope">
			<title>Scope</title>
			<para>In this tutorial you will build your first very simple eTrice model. The goal is to learn the work flow of eTrice and to understand a few basic features of ROOM. You will perform the following steps:</para>
			<orderedlist>
				<listitem>
					<para>create a new model from scratch</para>
				</listitem>
				<listitem>
					<para>add a very simple state machine to an actor</para>
				</listitem>
				<listitem>
					<para>generate the source code</para>
				</listitem>
				<listitem>
					<para>run the model</para>
				</listitem>
				<listitem>
					<para>open the message sequence chart</para>
				</listitem>
			</orderedlist>
			<para>Make sure that you have set up the workspace as described in 
				<emphasis>Setting up the workspace</emphasis>.
			</para>
			<para>
				<ulink url="http://eclipse.org/etrice/images/015-HelloWorld01.avi">video hello world</ulink>
			</para>
		</section>
		<section id="Createanewmodelfromscratch">
			<title>Create a new model from scratch</title>
			<para>The easiest way to create a new eTrice Project is to use the eclipse project wizard. From the eclipse file menu select 
				<emphasis>File-&gt;New-&gt;Project</emphasis> and create a new eTrice project and name it 
				<emphasis>HelloWorld</emphasis>
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/015-HelloWorld10.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>The wizard creates everything that is needed to create, build and run an eTrice model. The resulting project should look like this:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/015-HelloWorld11.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Within the model directory the model file 
				<emphasis>HelloWorld.room</emphasis> was created. Open the 
				<emphasis>HelloWorld.room</emphasis> file and delete the contents of the file. Open the content assist with Ctrl+Space and select 
				<emphasis>model skeleton</emphasis>.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/015-HelloWorld12.png"/>
					</imageobject>
				</mediaobject>   
			</para>
			<para>Edit the template variables by typing the new names and jumping with Tab from name to name.</para>
			<para>The resulting model code should look like this:</para>
			<literallayout><code>RoomModel HelloWorld {

    LogicalSystem System_HelloWorld {
        SubSystemRef subsystem : SubSystem_HelloWorld
    }

    SubSystemClass SubSystem_HelloWorld {
        ActorRef application : HelloWorldTop
    }

    ActorClass HelloWorldTop {
    }
} 
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
			<para>The goal of eTrice is to describe distributed systems on a logical level. In the current version not all elements will be used. But as prerequisite for further versions the following elements can be defined:</para>
			<itemizedlist>
				<listitem>
					<para>the 
						<emphasis>LogicalSystem</emphasis> (currently optional)
					</para>
				</listitem>
				<listitem>
					<para>at least one 
						<emphasis>SubSystemClass</emphasis> (mandatory)
					</para>
				</listitem>
				<listitem>
					<para>at least one 
						<emphasis>ActorClass</emphasis> (mandatory)
					</para>
				</listitem>
			</itemizedlist>
			<para>The 
				<emphasis>LogicalSystem</emphasis> represents the complete distributed system and contains at least one 
				<emphasis>SubSystemRef</emphasis>. The 
				<emphasis>SubSystemClass</emphasis> represents an address space and contains at least one 
				<emphasis>ActorRef</emphasis>. The 
				<emphasis>ActorClass</emphasis> is the building block of which an application will be built of. It is in general a good idea to define a top level actor that can be used as reference within the subsystem.
			</para>
			<para>The outline view of the textual ROOM editor shows the main modeling elements in an easy to navigate tree.</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/015-HelloWorld02.png"/>
					</imageobject>
				</mediaobject>
			</para>
		</section>
		<section id="Createastatemachine">
			<title>Create a state machine</title>
			<para>We will implement the Hello World code on the initial transition of the 
				<emphasis>HelloWorldTop</emphasis> actor. Therefore open the state machine editor by right clicking the 
				<emphasis>HelloWorldTop</emphasis> actor in the outline view and select 
				<emphasis>Edit Behavior</emphasis>.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/015-HelloWorld03.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>The state machine editor will be opened. Drag and drop an 
				<emphasis>Initial Point</emphasis> from the tool box to the diagram into the top level state. Drag and drop a 
				<emphasis>State</emphasis> from the tool box to the diagram. Confirm the dialogue with 
				<emphasis>ok</emphasis>. Select the 
				<emphasis>Transition</emphasis> in the tool box and draw the transition from the 
				<emphasis>Initial Point</emphasis> to the State. Open the transition dialogue by double clicking the transition arrow and fill in the action code.
			</para>
			<literallayout><code>System.out.println("Hello World !");
</code></literallayout>
			<para>The result should look like this:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/015-HelloWorld04.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Save the diagram and inspect the model file. Note that the textual representation was created after saving the diagram.</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/015-HelloWorld05.png"/>
					</imageobject>
				</mediaobject>
			</para>
		</section>
		<section id="Buildandrunthemodel">
			<title>Build and run the model</title>
			<para>Now the model is finished and source code can be generated. The project wizard has created a launch configuration that is responsible for generating the source code. From 
				<emphasis>HelloWorld/</emphasis> right click 
				<emphasis role="bold">gen_HelloWorld.launch</emphasis> and run it as gen_HelloWorld. All model files in the model directory will be generated.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/015-HelloWorld06.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>The code will be generated to the src-gen directory. The main function will be contained in 
				<emphasis role="bold">SubSystem_HelloWorldRunner.java</emphasis>. Select this file and run it as Java application.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/015-HelloWorld07.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>The Hello World application starts and the string will be printed on the console window. To stop the application the user must type 
				<emphasis>quit</emphasis> in the console window.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/015-HelloWorld08.png"/>
					</imageobject>
				</mediaobject>
			</para>
		</section>
		<section id="OpentheMessageSequenceChart">
			<title>Open the Message Sequence Chart</title>
			<para>During runtime the application produced a MSC and wrote it to a file. Open HelloWorld/tmp/log/SubSystem_HelloWorld_Async.seq using Trace2UML (it is open source and can be obtained from  http://trace2uml.tigris.org/). You should see something like this:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/015-HelloWorld09.png"/>
					</imageobject>
				</mediaobject>
			</para>
		</section>
		<section id="Summary">
			<title>Summary</title>
			<para>Now you have generated your first eTrice model from scratch. You can switch between diagram editor and model (.room file) and you can see what will be generated during editing and saving the diagram files. 
				You should take a look at the generated source files to understand how the state machine is generated and the life cycle of the application. The next tutorials will deal with more complex hierarchies in structure and behavior.</para>
		</section>
	</chapter>
	<chapter id="TutorialBlinkyJava">
		<title>Tutorial Blinky (Java)</title>
		<section id="Scope2">
			<title>Scope</title>
			<para>This tutorial describes how to use the 
				<emphasis>TimingService</emphasis>, how to combine a generated model with manual code and how to model a hierarchical state machine. The idea of the tutorial is to switch a LED on and off. The behavior of the LED should be: blinking in a one second interval for 5 seconds, stop blinking for 5 seconds, blinking, stop,...  
				For this exercise we will use a little GUI class that will be used in more sophisticated tutorials too. The GUI simulates a pedestrian traffic crossing. For now, just a simple LED simulation will be used from the GUI. 
			</para>
			<para>After the exercise is created you must copy the GUI to your src directory (see below).</para>
			<para>The package contains four java classes which implements a small window with a 3-light traffic light which simulates the signals for the car traffic and a 2-light traffic light which simulates the pedestrian signals.</para>
			<para>The GUI looks like this:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky08.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Within this tutorial we will just toggle the yellow light.</para>
			<para>You will perform the following steps:</para>
			<orderedlist>
				<listitem>
					<para>create a new model from scratch</para>
				</listitem>
				<listitem>
					<para>define a protocol</para>
				</listitem>
				<listitem>
					<para>create an actor structure</para>
				</listitem>
				<listitem>
					<para>create a hierarchical state machine</para>
				</listitem>
				<listitem>
					<para>use the predefined 
						<emphasis>TimingService</emphasis>
					</para>
				</listitem>
				<listitem>
					<para>combine manual code with generated code</para>
				</listitem>
				<listitem>
					<para>build and run the model</para>
				</listitem>
				<listitem>
					<para>open the message sequence chart</para>
				</listitem>
			</orderedlist>
		</section>
		<section id="Createanewmodelfromscratch2">
			<title>Create a new model from scratch</title>
			<para>Remember the exercise 
				<emphasis>HelloWorld</emphasis>.
				Create a new eTrice project and name it 
				<emphasis>Blinky</emphasis>
			</para>
			<para>To use the GUI please copy the package 
				<emphasis>org.eclipse.etrice.tutorials.PedLightGUI</emphasis> from 
				<emphasis>org.eclipse.etrice.tutorials/src</emphasis> to your 
				<emphasis role="bold">src</emphasis> directory 
				<emphasis>Blinky/src</emphasis>. For this tutorial you must remove the error markers by editing the file 
				<emphasis>PedestrianLightWndNoTcp.java</emphasis>. Appropriate comments are provided to remove the error markers for this turorial.
			</para>
			<para>Open the 
				<emphasis>Blinky.room</emphasis> file and copy the following code into the file or use content assist to create the model.
			</para>
			<literallayout><code>RoomModel Blinky {

    LogicalSystem System_Blinky {
        SubSystemRef subsystem : SubSystem_Blinky
    }

    SubSystemClass SubSystem_Blinky {
        ActorRef application : BlinkyTop
    }

    ActorClass BlinkyTop {
    }
}
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
		</section>
		<section id="Addtwoadditionalactorclasses">
			<title>Add two additional actor classes</title>
			<para>Position the cursor outside any class definition and right click the mouse within the editor window. From the context menu select 
				<emphasis>Content Assist</emphasis>  
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky02.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Select 
				<emphasis>ActorClass – actor class skeleton</emphasis> and name it 
				<emphasis>Blinky</emphasis>.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky01.png"/>
					</imageobject>
				</mediaobject> 
			</para>
			<para>Repeat the described procedure and name the new actor 
				<emphasis>BlinkyController</emphasis>.
			</para>
			<para>With Ctrl+Shift+F you can beautify the model code. </para>
			<para>Save the model and visit the outline view.</para>
		</section>
		<section id="Createanewprotocol">
			<title>Create a new protocol</title>
			<para>With the help of 
				<emphasis>Content Assist</emphasis> create a 
				<emphasis>ProtocolClass</emphasis> and name it 
				<emphasis>BlinkyControlProtocol</emphasis>.
				Inside the brackets use the 
				<emphasis>Content Assist</emphasis> (CTRL+Space) to create two incoming messages called 
				<emphasis>start</emphasis> and 
				<emphasis>stop</emphasis>.
			</para>
			<para>The resulting code should look like this:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky03.png"/>
					</imageobject>
				</mediaobject> 
			</para>
			<para>With Ctrl-Shift+F or selecting 
				<emphasis>Format</emphasis> from the context menu you can format the text. Note that all elements are displayed in the outline view.
			</para>
		</section>
		<section id="ImporttheTimingService">
			<title>Import the Timing Service</title>
			<para>Switching on and off the LED is timing controlled. The timing service is provided from the model library and must be imported before it can be used from the model.</para>
			<para>This is the first time you use an element from the modellib. Make sure that your Java Build Path has the appropriate entry to the modellib. Otherwise the jave code, which will be generated from the modellib, can not be referenced.
				(right click to 
				<emphasis>Blinky</emphasis> and select properties. Select the 
				<emphasis>Java Build Path</emphasis> tab) 
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky16.png"/>
					</imageobject>
				</mediaobject> 
			</para>
			<para>After the build path is set up return to the model and navigate the cursor at the beginning of the model and import the timing service: </para>
			<literallayout><code>RoomModel Blinky {
    
    import room.basic.service.timing.* from "../../org.eclipse.etrice.modellib/models/TimingService.room" 
    
    LogicalSystem System_Blinky {
        SubSystemRef subsystem: SubSystem_Blinky
    }
}
...     
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
			<para>Make sure that the path fits to your folder structure. The original tutorial code is different due to the folder structure.  </para>
			<para>Now it can be used within the model. Right click to 
				<emphasis role="bold">SubSystem_Blinky</emphasis> within the outline view. Select 
				<emphasis>Edit Structure</emphasis>. The 
				<emphasis>application</emphasis> is already referenced in the subsystem. Drag and Drop an 
				<emphasis>ActorRef</emphasis> to the 
				<emphasis role="bold">SubSystem_Blinky</emphasis> and name it 
				<emphasis>timingService</emphasis>. From the actor class drop down list select 
				<emphasis>room.basic.service.timing.ATimingService</emphasis>. Draw a 
				<emphasis>LayerConnection</emphasis> from 
				<emphasis>application</emphasis> to each service provision point (SPP) of the 
				<emphasis>timingService</emphasis>. The resulting structure should look like this:
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky06.png"/>
					</imageobject>
				</mediaobject> 
			</para>
			<para>The current version of eTrice does not provide a graphical element for a service access point (SAP). Therefore the SAPs to access the timing service must be added in the .room file. Open the 
				<emphasis>Blinky.room</emphasis> file and navigate to the 
				<emphasis>Blinky</emphasis> actor. Add the following line to the structure of the actor:
			</para>
			<literallayout><code>SAP timer: room.basic.service.timing.PTimeout
</code></literallayout>
			<para>Do the same thing for 
				<emphasis>BlinkyController</emphasis>.
			</para>
			<para>The resulting code should look like this:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky07.png"/>
					</imageobject>
				</mediaobject>
			</para>
		</section>
		<section id="Finishthemodelstructure">
			<title>Finish the model structure</title>
			<para>From the outline view right click to 
				<emphasis>Blinky</emphasis> and select 
				<emphasis>Edit Structure</emphasis>. Drag and Drop an 
				<emphasis>Interface Port</emphasis> to the boarder of the 
				<emphasis>Blinky</emphasis> actor. Note that an interface port is not possible inside the actor. Name the port 
				<emphasis>ControlPort</emphasis> and select 
				<emphasis>BlinkyControlProtocol</emphasis> from the drop down list. Uncheck 
				<emphasis>Conjugated</emphasis> and 
				<emphasis>Is Relay Port</emphasis>. Click 
				<emphasis>ok</emphasis>. The resulting structure should look like this:
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky04.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Repeat the above steps for the 
				<emphasis>BlinkyController</emphasis>. Make the port 
				<emphasis>Conjugated</emphasis>
			</para>
			<para>Keep in mind that the protocol defines 
				<emphasis>start</emphasis> and 
				<emphasis>stop</emphasis> as incoming messages. 
				<emphasis>Blinky</emphasis> receives this messages and therefore 
				<emphasis>Blinky</emphasis>'s 
				<emphasis>ControlPort</emphasis> must be a regular port and 
				<emphasis>BlinkyController</emphasis>'s 
				<emphasis>ControlPort</emphasis> must be a conjugated port.
			</para>
			<para>From the outline view right click 
				<emphasis>BlinkyTop</emphasis> and select 
				<emphasis>Edit Structure</emphasis>.
			</para>
			<para>Drag and Drop an 
				<emphasis>ActorRef</emphasis> inside the 
				<emphasis>BlinkyTop</emphasis> actor. Name it 
				<emphasis>blinky</emphasis>. From the actor class drop down list select 
				<emphasis>Blinky</emphasis>. Do the same for 
				<emphasis>controller</emphasis>. Connect the ports via the binding tool. The resulting structure should look like this:
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky05.png"/>
					</imageobject>
				</mediaobject>
			</para>
		</section>
		<section id="ImplementtheBehavior">
			<title>Implement the Behavior</title>
			<para>The application should switch on and off the LED for 5 seconds in a 1 second interval, then stop blinking for 5 seconds and start again. To implement this behavior we will implement two FSMs. One for the 1 second interval and one for the 5 second interval. The 1 second blinking should be implemented in 
				<emphasis>Blinky</emphasis>. The 5 second interval should be implemented in 
				<emphasis>BlinkyController</emphasis>. First implement the Controller.
			</para>
			<para>Right click to 
				<emphasis>BlinkyController</emphasis> and select 
				<emphasis>Edit Behavior</emphasis>.
				Drag and Drop the 
				<emphasis>Initial Point</emphasis> and two 
				<emphasis>States</emphasis> into the top state. Name the states 
				<emphasis>on</emphasis> and 
				<emphasis>off</emphasis>. 
				Use the 
				<emphasis>Transition</emphasis> tool to draw transitions from 
				<emphasis>init</emphasis> to 
				<emphasis>on</emphasis> from 
				<emphasis>on</emphasis> to 
				<emphasis>off</emphasis> and from 
				<emphasis>off</emphasis> to 
				<emphasis>on</emphasis>.
			</para>
			<para>Open the transition dialog by double click the arrow to specify the trigger event and the action code of each transition. Note that the initial transition does not have a trigger event.</para>
			<para>The transition dialog should look like this:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky09.png"/>
					</imageobject>
				</mediaobject> 
			</para>
			<para>The defined ports will be generated as a member attribute of the actor class from type of the attached protocol. So, to send e message you must state 
				<emphasis>port.message(param);</emphasis>. In this example 
				<emphasis>ControlPort.start()</emphasis> sends the 
				<emphasis>start</emphasis> message via the 
				<emphasis>ControlPort</emphasis> to the outside world. Assuming that 
				<emphasis>Blinky</emphasis> is connected to this port, the message will start the one second blinking FSM. It is the same thing with the 
				<emphasis>timer</emphasis>. The SAP is also a port and follows the same rules. So it is clear that 
				<emphasis>timer.Start(5000);</emphasis> will send the 
				<emphasis>Start</emphasis> message to the timing service. The timing service will send a 
				<emphasis>timeoutTick</emphasis> message back after 5000ms.
			</para>
			<para>Within each transition the timer will be restarted and the appropriate message will be sent via the 
				<emphasis>ControlPort</emphasis>. 
			</para>
			<para>The resulting state machine should look like this:
				(Note that the arrows peak changes if the transition contains action code.)</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky10.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Save the diagram and inspect the 
				<emphasis>Blinky.room</emphasis> file. The 
				<emphasis>BlinkyController</emphasis> should look like this:
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky11.png"/>
					</imageobject>
				</mediaobject> 
			</para>
			<para>Now we will implement 
				<emphasis>Blinky</emphasis>. Due to the fact that 
				<emphasis>Blinky</emphasis> interacts with the GUI class a view things must to be done in the model file.
			</para>
			<para>Double click 
				<emphasis>Blinky</emphasis> in the outline view to navigate to 
				<emphasis>Blinky</emphasis> within the model file.
				Add the following code:
				(type it or simply copy it from the tutorial project)
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky12.png"/>
					</imageobject>
				</mediaobject> 
			</para>
			<para>
				<emphasis>usercode1</emphasis> will be generated at the beginning of the file, outside the class definition. 
				<emphasis>usercode2</emphasis> will be generated within the class definition. The code imports the GUI class and instantiates the window class. Attributes for the carLights and pedLights will be declared to easily access the lights in the state machine.
				The Operation 
				<emphasis>destroyUser()</emphasis> is a predefined operation that will be called during shutdown of the application. Within this operation, cleanup of manual coded classes can be done.
			</para>
			<para>Now design the FSM of 
				<emphasis>Blinky</emphasis>. Remember, as the name suggested 
				<emphasis>blinking</emphasis> is a state in which the LED must be switched on and off. We will realize that by an hierarchical FSM in which the 
				<emphasis>blinking</emphasis> state has two sub states.
			</para>
			<para>Open the behavior diagram of 
				<emphasis>Blinky</emphasis> by right clicking the 
				<emphasis>Blinky</emphasis> actor in the outline view. Create two states named 
				<emphasis>blinking</emphasis> and 
				<emphasis>off</emphasis>. Right click to 
				<emphasis>blinking</emphasis> and create a subgraph.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky13.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Create the following state machine. The trigger events between 
				<emphasis>on</emphasis> and 
				<emphasis>off</emphasis> are the 
				<emphasis>timeoutTick</emphasis> from the 
				<emphasis>timer</emphasis> port. 
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky14.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Create entry code for both states by right clicking the state and select 
				<emphasis>Edit State...</emphasis>
			</para>
			<para>Entry code of 
				<emphasis>on</emphasis> is:
			</para>
			<literallayout><code>timer.Start(1000);
carLights.setState(TrafficLight3.YELLOW); 
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
			<para>Entry code  of 
				<emphasis>off</emphasis> is:
			</para>
			<literallayout><code>timer.Start(1000);
carLights.setState(TrafficLight3.OFF);
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
			<para>Navigate to the Top level state by double clicking the 
				<emphasis>/blinking</emphasis> state. Create the following state machine:
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky15.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>The trigger event from 
				<emphasis>off</emphasis> to 
				<emphasis>blinking</emphasis> is the 
				<emphasis>start</emphasis> event from the 
				<emphasis>ControlPort</emphasis>.The trigger event from 
				<emphasis>blinking</emphasis> to 
				<emphasis>off</emphasis> is the 
				<emphasis>stop</emphasis> event from the 
				<emphasis>ControlPort</emphasis>.
				Note: The transition from 
				<emphasis>blinking</emphasis> to 
				<emphasis>off</emphasis> is a so called group transition. This is a outgoing transition from a super state (state with sub states) without specifying the concrete leave state (state without sub states). An incoming transition to a super state is called history transition.   
			</para>
			<para>Action code of the init transition is:</para>
			<literallayout><code>carLights = light.getCarLights();
pedLights = light.getPedLights();
carLights.setState(TrafficLight3.OFF);
pedLights.setState(TrafficLight2.OFF);
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
			<para>Action code from 
				<emphasis>blinking</emphasis> to 
				<emphasis>off</emphasis> is:
			</para>
			<literallayout><code>timer.Kill();
carLights.setState(TrafficLight3.OFF); 
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
			<para>The model is complete now. You can run and debug the model as described in getting started. Have fun.</para>
			<para>The complete model can be found in /org.eclipse.etrice.tutorials/model/Blinky.</para>
		</section>
		<section id="Summary2">
			<title>Summary</title>
			<para>Run the model and take a look at the generated MSCs. Inspect the generated code to understand the runtime model of eTrice. Within this tutorial you have learned how to create a hierarchical FSM with group transitions and history transitions and you have used entry code. You are now familiar with the basic features of eTrice. The further tutorials will take this knowledge as a precondition.</para>
		</section>
	</chapter>
	<chapter id="TutorialSendingDataJava">
		<title>Tutorial Sending Data (Java)</title>
		<section id="Scope3">
			<title>Scope</title>
			<para>This tutorial shows how data will be sent in a eTrice model. Within the example you will create two actors (MrPing and MrPong). MrPong will simply loop back every data it received.
				MrPing will send data and verify the result.   </para>
			<para>You will perform the following steps:</para>
			<orderedlist>
				<listitem>
					<para>create a new model from scratch</para>
				</listitem>
				<listitem>
					<para>create a data class</para>
				</listitem>
				<listitem>
					<para>define a protocol with attached data</para>
				</listitem>
				<listitem>
					<para>create an actor structure</para>
				</listitem>
				<listitem>
					<para>create two simple state machines</para>
				</listitem>
				<listitem>
					<para>build and run the model</para>
				</listitem>
			</orderedlist>
		</section>
		<section id="Createanewmodelfromscratch3">
			<title>Create a new model from scratch</title>
			<para>Remember exercise 
				<emphasis>HelloWorld</emphasis>.
				Create a new eTrice project and name it 
				<emphasis>SendingData</emphasis>
				Open the 
				<emphasis>SendingData.room</emphasis> file and copy the following code into the file or use content assist to create the model.
			</para>
			<literallayout><code>RoomModel SendingData {
    LogicalSystem SendingData_LogSystem {
        SubSystemRef SendingDataAppl:SendingData_SubSystem 
    }
    SubSystemClass SendingData_SubSystem {
        ActorRef SendigDataTopRef:SendingDataTop 
    }
    ActorClass SendingDataTop {
    }
}
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
		</section>
		<section id="Addadataclass">
			<title>Add a data class</title>
			<para>Position the cursor outside any class definition and right click the mouse within the editor window. From the context menu select 
				<emphasis>Content Assist</emphasis> (or Ctrl+Space).  
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/025-SendingData01.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Select 
				<emphasis>DataClass – data class skeleton</emphasis> and name it 
				<emphasis>DemoData</emphasis>.
				Remove the operations and add the following Attributes:
			</para>
			<literallayout><code>DataClass DemoData {
    Attribute int32Val: int32 = "4711"
    Attribute int8Array [ 10 ]: int8 = "{1,2,3,4,5,6,7,8,9,10}"
    Attribute float64Val: float64 = "0.0"
    Attribute stringVal: string = "\"empty\""
}
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
			<para>Save the model and visit the outline view.
				Note that the outline view contains all data elements as defined in the model. </para>
		</section>
		<section id="Createanewprotocol2">
			<title>Create a new protocol</title>
			<para>With the help of 
				<emphasis>Content Assist</emphasis> create a 
				<emphasis>ProtocolClass</emphasis> and name it 
				<emphasis>PingPongProtocol</emphasis>. Create the following messages:
			</para>
			<literallayout><code>ProtocolClass PingPongProtocol {
    incoming {
        Message ping(data: DemoData)
        Message pingSimple(data:int32)
    }
    outgoing {
        Message pong(data: DemoData)
        Message pongSimple(data:int32)
    }
}    
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
		</section>
		<section id="CreateMrPingandMrPongActors">
			<title>Create MrPing and MrPong Actors</title>
			<para>With the help of 
				<emphasis>Content Assist</emphasis> create two new actor classes and name them 
				<emphasis>MrPing</emphasis> and 
				<emphasis>MrPong</emphasis>. The resulting model should look like this:
			</para>
			<literallayout><code>RoomModel SendingData {

    LogicalSystem SendingData_LogSystem {
        SubSystemRef SendingDataAppl: SendingData_SubSystem
    }

    SubSystemClass SendingData_SubSystem {
        ActorRef SendigDataTopRef: SendingDataTop
    }

    ActorClass SendingDataTop { }

    DataClass DemoData {
        Attribute int32Val: int32 = "4711"
        Attribute int8Array [ 10 ]: int8 = "{1,2,3,4,5,6,7,8,9,10}"
        Attribute float64Val: float64 = "0.0"
        Attribute stringVal: string = "\"empty\""
    }

    ProtocolClass PingPongProtocol {
        incoming {
            Message ping(data: DemoData)
            Message pingSimple(data: int32)
        }
        outgoing {
            Message pong(data: DemoData)
            Message pongSimple(data: int32)
        }
    }

    ActorClass MrPing {
        Interface { }
        Structure { }
        Behavior { }
    }

    ActorClass MrPong {
        Interface { }
        Structure { }
        Behavior { }
    }
} 

</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
			<para>The outline view should look like this:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/025-SendingData03.png"/>
					</imageobject>
				</mediaobject>
			</para>
		</section>
		<section id="DefineActorStructureandBehavior">
			<title>Define Actor Structure and Behavior</title>
			<para>Save the model and visit the outline view. Within the outline view, right click on the 
				<emphasis>MrPong</emphasis> actor and select 
				<emphasis>Edit Structure</emphasis>. Select an 
				<emphasis>Interface Port</emphasis> from the toolbox and add it to MrPong. Name the Port 
				<emphasis>PingPongPort</emphasis> and select the 
				<emphasis>PingPongProtocol</emphasis>
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/025-SendingData02.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Do the same with MrPing but mark the port as 
				<emphasis>conjugated</emphasis>
			</para>
			<section id="DefineMrPongsbehavior">
				<title>Define MrPongs behavior</title>
				<para>Within the outline view, right click MrPong and select 
					<emphasis>Edit Behavior</emphasis>. Create the following state machine:
				</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/025-SendingData04.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>The transition dialogues should look like this:
					For 
					<emphasis>ping</emphasis>:
				</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/025-SendingData05.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>For 
					<emphasis>pingSimple</emphasis>:
				</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/025-SendingData06.png"/>
						</imageobject>
					</mediaobject>
				</para>
			</section>
			<section id="DefineMrPingbehavior">
				<title>Define MrPing behavior</title>
				<para>Within the outline view double click MrPing. Navigate the cursor to the behavior of MrPing. With the help of content assist create a new operation.</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/025-SendingData07.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>Name the operation 
					<emphasis>printData</emphasis> and define the DemoData as a parameter.
				</para>
				<para>Fill in the following code:</para>
				<literallayout><code>Operation printData(d: DemoData) : void {
            "System.out.printf(\"d.int32Val: %d\\n\",d.int32Val);"
            "System.out.printf(\"d.float64Val: %f\\n\",d.float64Val);"
            "System.out.printf(\"d.int8Array: \");"
            "for(int i = 0; i&lt;d.int8Array.length; i++) {"
            "System.out.printf(\"%d \",d.int8Array[i]);}"
            "System.out.printf(\"\\nd.stringVal: %s\\n\",d.stringVal);"
}
</code></literallayout>
				<blockquote>
					<para></para>
				</blockquote>
				<para>For MrPing create the following state machine:
					(Remember that you can copy and paste the action code from the tutorial directory.)</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/025-SendingData08.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>The transition dialogues should look like this:</para>
				<para>For 
					<emphasis>init</emphasis>:
				</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/025-SendingData09.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>For 
					<emphasis>wait1</emphasis>:
				</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/025-SendingData10.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>For 
					<emphasis>next</emphasis>:
				</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/025-SendingData11.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>For 
					<emphasis>wait2</emphasis>:
				</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/025-SendingData12.png"/>
						</imageobject>
					</mediaobject>
				</para>
			</section>
		</section>
		<section id="Definethetoplevel">
			<title>Define the top level</title>
			<para>Open the Structure from SendingDataTop and add MrPing and MrPong as a reference. Connect the ports.</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/025-SendingData13.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>The model is finished now and can be found in /org.eclipse.etrice.tutorials/model/SendingData.</para>
		</section>
		<section id="Generateandrunthemodel">
			<title>Generate and run the model</title>
			<para>Generate the code by right click to 
				<emphasis role="bold">gen_SendingData.launch</emphasis> and run it as 
				<emphasis role="bold">gen_SendingData</emphasis>. Run the model. 
				The output should look like this:
			</para>
			<blockquote>
				<para>
					type &#8218;quit’ to exit
					/SendingData_SubSystem/SendigDataTopRef/ref0 -&gt; waitForPongSimple
					/SendingData_SubSystem/SendigDataTopRef/ref1 -&gt; looping
					/SendingData_SubSystem/SendigDataTopRef/ref1 -&gt; looping
					data: 1
					/SendingData_SubSystem/SendigDataTopRef/ref0 -&gt; waitForPongSimple
					/SendingData_SubSystem/SendigDataTopRef/ref1 -&gt; looping
					data: 2
					/SendingData_SubSystem/SendigDataTopRef/ref0 -&gt; waitForPongSimple
					/SendingData_SubSystem/SendigDataTopRef/ref1 -&gt; looping
					data: 3
					/SendingData_SubSystem/SendigDataTopRef/ref0 -&gt; waitForPongSimple
					/SendingData_SubSystem/SendigDataTopRef/ref1 -&gt; looping
					data: 4
					/SendingData_SubSystem/SendigDataTopRef/ref0 -&gt; waitForPongSimple
					/SendingData_SubSystem/SendigDataTopRef/ref1 -&gt; looping
					data: 5
					/SendingData_SubSystem/SendigDataTopRef/ref0 -&gt; waitForPongSimple
					/SendingData_SubSystem/SendigDataTopRef/ref1 -&gt; looping
					data: 6
					/SendingData_SubSystem/SendigDataTopRef/ref0 -&gt; waitForPongSimple
					/SendingData_SubSystem/SendigDataTopRef/ref1 -&gt; looping
					data: 7
					/SendingData_SubSystem/SendigDataTopRef/ref0 -&gt; waitForPongSimple
					/SendingData_SubSystem/SendigDataTopRef/ref1 -&gt; looping
					data: 8
					/SendingData_SubSystem/SendigDataTopRef/ref0 -&gt; waitForPongSimple
					/SendingData_SubSystem/SendigDataTopRef/ref1 -&gt; looping
					data: 9
					/SendingData_SubSystem/SendigDataTopRef/ref0 -&gt; waitForPongSimple
					/SendingData_SubSystem/SendigDataTopRef/ref1 -&gt; looping
					data: 10
					/SendingData_SubSystem/SendigDataTopRef/ref0 -&gt; waitForPong
					/SendingData_SubSystem/SendigDataTopRef/ref1 -&gt; looping
					/SendingData_SubSystem/SendigDataTopRef/ref1 -&gt; looping
					d.int32Val: 4711
					d.float64Val: 0,000000
					d.int8Array: 1 2 3 4 5 6 7 8 9 10 
					d.stringVal: empty
					/SendingData_SubSystem/SendigDataTopRef/ref0 -&gt; waitForPong
					d.int32Val: 815
					d.float64Val: 3,141234
					d.int8Array: 100 101 102 103 104 105 106 107 108 109 
					d.stringVal: some contents
					/SendingData_SubSystem/SendigDataTopRef/ref0 -&gt; waitForPong
					quit
					echo: quit</para>
			</blockquote>
			<blockquote>
				<para></para>
			</blockquote>
		</section>
		<section id="Summary3">
			<title>Summary</title>
			<para>Within the first loop an integer value will be incremented by 
				<emphasis>MrPong</emphasis> and sent back to 
				<emphasis>MrPing</emphasis>. As long as the guard is true 
				<emphasis>MrPing</emphasis> sends back the value.
			</para>
			<para>Within the 
				<emphasis>next</emphasis> transition, 
				<emphasis>MrPing</emphasis> creates a data class and sends the default values. Then 
				<emphasis>MrPing</emphasis> changes the values and sends the class again. At this point you should note that during the send operation, a copy of the data class will be created and sent. Otherwise it would not be possible to send the same object two times, even more it would not be possible to send a stack object at all. This type of data passing is called 
				<emphasis>sending data by value</emphasis>.
				However, for performance reasons some applications requires 
				<emphasis>sending data by reference</emphasis>. In this case the user is responsible for the life cycle of the object. In Java the VM takes care of the life cycle of an object. This is not the case for C/C++. Consider that a object which is created within a transition of a state machine will be destroyed when the transition is finished. The receiving FSM would receive an invalid reference. Therefore care must be taken when sending references.      
			</para>
			<para>For sending data by reference you simply have to add the keyword 
				<emphasis>ref</emphasis> to the protocol definition.
			</para>
			<literallayout><code>Message ping(data: DemoData ref)
</code></literallayout>
			<para>Make the test and inspect the console output.</para>
		</section>
	</chapter>
	<chapter id="TutorialPedestrianLightsJava">
		<title>Tutorial Pedestrian Lights (Java)</title>
		<section id="Scope4">
			<title>Scope</title>
			<para>The scope of this tutorial is to demonstrate how to receive model messages from outside the model. Calling methods which are not part of the model is simple and you have already done this within the blinky tutorial (this is the other way round: model =&gt; external code). Receiving events from outside the model is a very common problem and a very frequently asked question. Therefore this tutorial shows how an external event (outside the model) can be received by the model.</para>
			<para>This tutorial is not like hello world or blinky. Being familiar with the basic tool features is mandatory for this tutorial. The goal is to understand the mechanism not to learn the tool features.</para>
			<para>The idea behind the exercise is, to control a Pedestrian crossing light. We will use the same GUI as for the blinky tutorial but now we will use the 
				<emphasis>REQUEST</emphasis> button to start a FSM, which controls the traffic lights.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/020-Blinky08.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>The 
				<emphasis>REQUEST</emphasis> must lead to a model message which starts the activity of the lights.
			</para>
			<para>There are several possibilities to receive external events (e.g. TCP/UDP Socket, using OS messaging mechanism), but the easiest way is, to make a port usable from outside the model. To do that a few steps are necessary:</para>
			<orderedlist>
				<listitem>
					<para>specify the messages (within a protocol) which should be sent into the model</para>
				</listitem>
				<listitem>
					<para>model an actor with a port (which uses the specified protocol) and connect the port to the receiver </para>
				</listitem>
				<listitem>
					<para>the external code should know the port (import of the port class)</para>
				</listitem>
				<listitem>
					<para>the external code should provide a registration method, so that the actor is able to allow access to this port</para>
				</listitem>
				<listitem>
					<para>the port can be used from the external code</para>
				</listitem>
			</orderedlist>
		</section>
		<section id="Setupthemodel">
			<title>Setup the model</title>
			<itemizedlist>
				<listitem>
					<para>Use the 
						<emphasis>New Model Wizzard</emphasis> to create a new eTrice project and name it 
						<emphasis>PedLightsController</emphasis>.
					</para>
				</listitem>
				<listitem>
					<para>Copy the package 
						<emphasis>org.eclipse.etrice.tutorials.PedLightGUI</emphasis> to your 
						<emphasis>src</emphasis> directory (see blinky tutorial).
					</para>
				</listitem>
				<listitem>
					<para>In PedestrianLightWndNoTcp.jav uncomment line 15 (import), 36, 122 (usage) and 132-134 (registration). The error markers will disappear after the code is generated from the model.</para>
				</listitem>
				<listitem>
					<para>Copy the model from /org.eclipse.etrice.tutorials/model/PedLightsController to your model file, or run the model directly in the tutorial directory. </para>
				</listitem>
				<listitem>
					<para>Adapt the import statement to your path.</para>
				</listitem>
			</itemizedlist>
			<literallayout><code>import room.basic.service.timing.* from "../../org.eclipse.etrice.modellib/models/TimingService.room" 
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
			<itemizedlist>
				<listitem>
					<para>Generate the code from the model.</para>
				</listitem>
				<listitem>
					<para>Add the org.eclipse.etrice.modellib to the Java Class Path of your project.</para>
				</listitem>
				<listitem>
					<para>All error markers should be disappeared and the model should be operable. </para>
				</listitem>
				<listitem>
					<para>Arrange the Structure and the Statemachines to understand the model</para>
				</listitem>
			</itemizedlist>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/030-PedLights01.png"/>
					</imageobject>
				</mediaobject>
				The 
				<emphasis>GuiAdapter</emphasis> represents the interface to the external code. It registers its 
				<emphasis>ControlPort</emphasis> by the external code.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/030-PedLights02.png"/>
					</imageobject>
				</mediaobject>
				Visit the initial transition to understand the registration. The actor handles the incoming messages as usual and controls the traffic lights as known from blinky. 
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/030-PedLights03.png"/>
					</imageobject>
				</mediaobject>
				The 
				<emphasis>Controller</emphasis> receives the 
				<emphasis>start</emphasis> message and controls the timing of the lights. Note that the 
				<emphasis>start</emphasis> message will be sent from the external code whenever the 
				<emphasis>REQUEST</emphasis> button is pressed.
			</para>
			<itemizedlist>
				<listitem>
					<para> Visit the model and take a closer look to the following elements:</para>
				</listitem>
			</itemizedlist>
			<orderedlist>
				<listitem>
					<para>PedControlProtocol =&gt; notice that the start message is defined as usual</para>
				</listitem>
				<listitem>
					<para>Initial transition of the 
						<emphasis>GuiAdapter</emphasis> =&gt; see the registration
					</para>
				</listitem>
				<listitem>
					<para>The 
						<emphasis>Controller</emphasis> =&gt; notice that the 
						<emphasis>Controller</emphasis> receives the external message (not the 
						<emphasis>GuiAdapter</emphasis>). The 
						<emphasis>GuiAdapter</emphasis> just provides its port and handles the incoming messages.
					</para>
				</listitem>
				<listitem>
					<para>Visit the hand written code =&gt; see the import statement of the protocol class and the usage of the port.</para>
				</listitem>
			</orderedlist>
			<itemizedlist>
				<listitem>
					<para>Generate and test the model</para>
				</listitem>
				<listitem>
					<para>Take a look at the generated MSC =&gt; notice that the start message will shown as if the 
						<emphasis>GuiAdapter</emphasis> had sent it.
					</para>
				</listitem>
			</itemizedlist>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/030-PedLights04.png"/>
					</imageobject>
				</mediaobject>
			</para>
		</section>
		<section id="Whydoesitworkandwhyisitsafe">
			<title>Why does it work and why is it safe?</title>
			<para>The tutorial shows that it is generally possible to use every port from outside the model as long as the port knows its peer. This is guaranteed by describing protocol and the complete structure (especially the bindings) within the model. 
				The only remaining question is: Why is it safe and does not violate the 
				<emphasis role="bold">run to completion</emphasis> semantic. To answer this question, take a look at the 
				<emphasis>MessageService.java</emphasis> from the runtime environment. There you will find the receive method which puts each message into the queue. 
			</para>
			<literallayout><code>    @Override
    public synchronized void receive(Message msg) {
        if (msg!=null) {
            messageQueue.push(msg);
            notifyAll(); // wake up thread to compute message
        }
    }
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
			<para>This method is synchronized. That means, regardless who sends the message, the queue is secured. If we later on (e.g. for performance reasons in C/C++) distinguish between internal and external senders (same thread or not), care must be taken to use the external (secure) queue.</para>
		</section>
	</chapter>
	<chapter id="SettinguptheWorkspaceforCProjects">
		<title>Setting up the Workspace for C Projects</title>
		<para>Before you can start with C, some preconditions must be fulfilled:</para>
		<para>- A C compiler must be installed on your machine (all tests and tutorials are based on MinGW)
			- The CDT-Eclipse plug in must be installed as the C development environment.</para>
		<para>Once the CDT is installed, the C runtime and model library must be imported. 
			(
			<emphasis>File-&gt;New-&gt;Project-&gt;eTrice</emphasis> select 
			<emphasis>eTrice C runtime</emphasis> / 
			<emphasis>eTrice C modellib</emphasis>)
		</para>
		<para>The resulting workspace should look like this:</para>
		<para>
			<mediaobject>
				<imageobject>
					<imagedata fileref="images/032-SetupWorkspaceC01.png"/>
				</imageobject>
			</mediaobject>
		</para>
		<section id="Testingtheenvironment">
			<title>Testing the environment</title>
			<para>To verify the C tool chain you should generate and run the Hello World example program of the CDT.
				 Activate the 
				<emphasis>C/C++</emphasis> perspective. 
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/032-SetupWorkspaceC03.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>From the main menu select 
				<emphasis>File-&gt;New-&gt;C Project</emphasis>.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/032-SetupWorkspaceC02.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Name the project. Select an 
				<emphasis>Executable-&gt;Hello World ANSI C</emphasis> as project type, 
				<emphasis>MinGW GCC</emphasis> as tool chain and click 
				<emphasis>Finish</emphasis>. 
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/032-SetupWorkspaceC04.png"/>
					</imageobject>
				</mediaobject> 
			</para>
			<para>Select the new project and click the build button (or right click the project and select 
				<emphasis>Build Project</emphasis>)
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/032-SetupWorkspaceC05.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>The binary should be generated. Run the binary as 
				<emphasis>Local C/C++ Application</emphasis>
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/032-SetupWorkspaceC06.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Verify the output.</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/032-SetupWorkspaceC07.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Remember these steps. In the following Tutorials these steps will be referenced as 
				<emphasis>build and run</emphasis>.
			</para>
		</section>
		<section id="BuildingtheCruntimesystem">
			<title>Building the C runtime system</title>
			<para>The C runtime system contains some basic functionalities to run the generated models. The so called runtime is common for all C projects. The requirements for several projects may differ depending on the functionality of the model or the resources of the different platforms. Therefore the runtime is configurable in terms of message queue size, frequency and memory alignment. The configuration file 
				<emphasis>etRuntimeConfig.h</emphasis> is located in 
				<emphasis>src/config</emphasis>.
			</para>
			<para>After changing the configuration, the runtime must be built.</para>
			<para>Open the properties of the 
				<emphasis>org.eclipse.runtime.c</emphasis> project and select 
				<emphasis>C/C++ Build-&gt;Settings-&gt;Tool Settings</emphasis> and select 
				<emphasis>Includes</emphasis>.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/032-SetupWorkspaceC08.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Verify the include paths</para>
			<para>
				<emphasis>src/config</emphasis>

				<emphasis>src/common</emphasis>

				<emphasis>src/platforms/generic</emphasis>
			</para>
			<para>Within the Setting dialog select the tab 
				<emphasis>Build Artefact</emphasis> and select 
				<emphasis>Static Library</emphasis>
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/032-SetupWorkspaceC09.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Build the runtime by clicking</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/032-SetupWorkspaceC10.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>The runtime library should be created.</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/032-SetupWorkspaceC11.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>For the tutorials one runtime library should be sufficient. For embedded projects it might be necessary to build project specific runtime libraries. In this case a separate project for the runtime should be created. Symbolic links to the sources might be used to avoid duplicate files. Just the configuration file must be duplicated. A specific library file must exist within the project. Such specific runtime libraries might be referenced from several applications.     </para>
		</section>
	</chapter>
	<chapter id="TutorialHelloWorldforC">
		<title>Tutorial HelloWorld for C</title>
		<section id="Scope5">
			<title>Scope</title>
			<para>In this tutorial you will learn how to create a model for C from scratch. There are some more steps to do in C compared to Java. The goal is to get familiar with the additional steps. The Java tutorial is a prerequisite for the following explanations. 
				You will perform the following steps:</para>
			<orderedlist>
				<listitem>
					<para>create a new model from scratch for C</para>
				</listitem>
				<listitem>
					<para>create structure and behavior similar to Java</para>
				</listitem>
				<listitem>
					<para>create a launch configuration for the C code generator</para>
				</listitem>
				<listitem>
					<para>setup the C environment</para>
				</listitem>
				<listitem>
					<para>generate the source code</para>
				</listitem>
				<listitem>
					<para>run the model</para>
				</listitem>
			</orderedlist>
			<para>Make sure that you have set up the workspace as described in 
				<emphasis>Setting up the Workspace for C Projects</emphasis>.
			</para>
		</section>
		<section id="Createanewmodelfromscratch4">
			<title>Create a new model from scratch</title>
			<para>Before you can create a new C-model, you have to create a new C project as described in 
				<emphasis>Setting up the Workspace for C Projects</emphasis>.
				Remember:
				- select the 
				<emphasis>C/C++</emphasis> perspective
				- From the main menue select 
				<emphasis>File-&gt;New-&gt;C Project</emphasis>
				- Name the project 
				<emphasis>HelloWorldC</emphasis>
				- Project type is 
				<emphasis>Executable / Empty C Project</emphasis>
				- Toolchain is 
				<emphasis>MinGW</emphasis>
			</para>
			<para>The workspace should look like this:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC01.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>The next step is to add the model folder:
				Right click on the new project. Select 
				<emphasis>New-&gt;Folder</emphasis> and name it 
				<emphasis>model</emphasis>.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC02.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Add the model file to the folder. Right click on the new folder. Select 
				<emphasis>New-&gt;file</emphasis> and name it 
				<emphasis>HelloWorldC.room</emphasis>.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC03.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Due to the file ending 
				<emphasis>.room</emphasis>, the tool will ask you to add the Xtext nature. Answer with 
				<emphasis>Yes</emphasis>. 
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC04.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>The workspace should look like this:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC05.png"/>
					</imageobject>
				</mediaobject>
			</para>
		</section>
		<section id="CreatetheHelloWorldmodel">
			<title>Create the HelloWorld model</title>
			<para>Once the model file is created and the Xtext nature is added, you can create the model as you did it for Java.
				Creating the model is not the focus of this tutorial. Therefore copy and paste the following code into your model file. Optionally you can open and layout the diagrams.  
				Recognize the C specific parts:
				- Import CTypes instead of JavaTypes
				- The action code contains C instead of Java. Later versions will contain a common action language, but for the moment the action language is target specific.
				- The application must be shutdown on model level (see also 
				<emphasis>etRuntimeConfig.h</emphasis>).  
			</para>
			<literallayout><code>RoomModel HelloWorldCModel {
	import room.basic.types.c.* from "../../org.eclipse.etrice.modellib.c/model/CTypes.room"
	SubSystemClass HelloWorldCSubSysClass {
		ActorRef HelloETriceTopRef:AHelloWorldCTop 
	}
	ActorClass AHelloWorldCTop {
		Structure { }
		Behavior {
			StateMachine {
				Transition init: initial -&gt; state0 { }
				State state0 {
					entry {
						"printf(\"HelloWorldC !\\n\");"
						"SubSysClass_shutdown();"
						"\t\t\t\t\t\t"
					}
				}
			}
		}
	}	
}
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
		</section>
		<section id="CreatealaunchconfigurationtostarttheCcodegenerator">
			<title>Create a launch configuration to start the C code generator</title>
			<para>Other than in Java a launch configuration for the C code generator must be created.</para>
			<para>From the 
				<emphasis>Run</emphasis> menu select 
				<emphasis>Run Configurations</emphasis>
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC06.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Within the dialog select 
				<emphasis>eTrice C Generator</emphasis> and click the 
				<emphasis>New</emphasis> button to create a new launch configuration.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC07.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>A new configuration should be created. Name it _gen_HelloWorldC_ and add the model via one of the 
				<emphasis>add</emphasis> buttons.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC08.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>In the 
				<emphasis>Refresh</emphasis> tab select 
				<emphasis>The entire workspace</emphasis> 
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC09.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>In the 
				<emphasis>Common</emphasis> tab select 
				<emphasis>Shared file</emphasis> and add the 
				<emphasis>HelloWorldC</emphasis> project via the 
				<emphasis>Browse</emphasis> button.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC10.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Apply your changes. The new configuration should now exist in your workspace.</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC11.png"/>
					</imageobject>
				</mediaobject>
			</para>
		</section>
		<section id="Generatethecode">
			<title>Generate the code</title>
			<para>Now you can generate the code as you know it from Java. Right click on the launch configuration and run it as _gen_HelloWorldC_.</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC12.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>The code should be generated.</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC13.png"/>
					</imageobject>
				</mediaobject>
			</para>
		</section>
		<section id="Setuptheincludepath">
			<title>Setup the include path</title>
			<para>Before you can build the application you must setup the include path for the runtime system. Right click the project and select 
				<emphasis>Properties</emphasis>. Add the include path as described in 
				<emphasis>setting up the workspace</emphasis>.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC14.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Add the runtime library.</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC15.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Recognize the name of the library (&#8222;org.eclipse.etrice.runtime.c”). The library file on your disk is &#8222;liborg.eclipse.etrice.runtime.c.a”. </para>
		</section>
		<section id="Buildandrunthemodel2">
			<title>Build and run the model</title>
			<para>Now you can build the application. Click the build button to build the application.
				Run the application as 
				<emphasis>Local C/C++ Application</emphasis>.
				Verify the output.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/034-HelloWorldC16.png"/>
					</imageobject>
				</mediaobject>
			</para>
		</section>
		<section id="Summary4">
			<title>Summary</title>
			<para>You are now familiar with all necessary steps to create, build and run an eTrice C model from scratch. You are able to create a launch configuration to start the code generator and to perform all necessary settings to compile and link the application.  </para>
			<para>The next tutorial provides an exercise to get more familiar with these working steps.</para>
		</section>
	</chapter>
	<chapter id="TutorialRemoveCCommentC">
		<title>Tutorial Remove C-Comment ( C )</title>
		<section id="Scope6">
			<title>Scope</title>
			<para>In this tutorial you will create a more complex model. The model implements a simple parser that removes comments (block comments and line comments) from a C source file. Therefore we will create two actors. One actor is responsible to perform the file operations, whether the second actor implements the parser.</para>
			<para>You will perform the following steps:</para>
			<orderedlist>
				<listitem>
					<para>create a new model from scratch for C</para>
				</listitem>
				<listitem>
					<para>define a protocol</para>
				</listitem>
				<listitem>
					<para>define your own data type</para>
				</listitem>
				<listitem>
					<para>create the structure and the behavior by yourself</para>
				</listitem>
				<listitem>
					<para>generate, build and run the model</para>
				</listitem>
			</orderedlist>
			<para>Make sure that you have set up the workspace as described in 
				<emphasis>Setting up the Workspace for C Projects</emphasis>.
			</para>
		</section>
		<section id="Createanewmodelfromscratch5">
			<title>Create a new model from scratch</title>
			<para>Remember the following steps from the previous tutorials:
				- select the 
				<emphasis>C/C++</emphasis> perspective
				- From the main menue select 
				<emphasis>File-&gt;New-&gt;C Project</emphasis>
				- Name the project 
				<emphasis>RemoveComment</emphasis>
				- Project type is 
				<emphasis>Executable / Empty C Project</emphasis>
				- Toolchain is 
				<emphasis>MinGW</emphasis>
				- Add the folder 
				<emphasis>model</emphasis>
				- Add the model file and name it 
				<emphasis>RemoveComment.room</emphasis>
				- Add the Xtext nature.
			</para>
			<para>The workspace should look like this:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/036-RemoveCommentC01.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Create a launch configuration for the C generator and add the include path and library as described in 
				<emphasis>HelloWorldC</emphasis>.
			</para>
			<para>The workspace should look like this:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/036-RemoveCommentC02.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Now the model is created and all settings for the code generator, compiler and linker are done.</para>
		</section>
		<section id="Createyourowndatatype">
			<title>Create your own data type</title>
			<para>The planed application should read a C source file and remove the comments. Therefore we need a file descriptor which is not part of the basic C types. The type for the file descriptor for MinGW is 
				<emphasis>FILE</emphasis>. To make this type available on the model level, you have to declare the type in CTypes.room. To not interfere with other models, make a copy of 
				<emphasis>CTypes.room</emphasis> from 
				<emphasis>org.eclipse.modellib.c</emphasis> to your model folder.
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/036-RemoveCommentC03.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Open 
				<emphasis>Ctypes.room</emphasis> and take a look at the declaration of 
				<emphasis>string</emphasis> (last line) which is not a basic C type.
			</para>
			<para>
				<emphasis>PrimitiveType string:ptCharacter -&gt; charPtr default "0"</emphasis>
			</para>
			<para>With this declaration, you make the 
				<emphasis>string</emphasis> keyword available on model level as a primitive type. This type will be translated to 
				<emphasis>charPtr</emphasis> in your C sources. 
				<emphasis>charPtr</emphasis> is defined in 
				<emphasis>etDatatypes.h</emphasis>. This header file is platform specific (
				<emphasis>generic</emphasis>). With this mechanism you can define your own type system on model level and map the model types to specific target/platform types. 
			</para>
			<para>Add the following line in 
				<emphasis>CTypes.room</emphasis>:
			</para>
			<literallayout><code>PrimitiveType file:ptInteger -&gt; FILE default "0"
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
			<para>
				<emphasis>FILE</emphasis> is the native type for MinGW. Therefore you don´t need a mapping within 
				<emphasis>etDatatypes.h</emphasis>. If your model should be portable across different platforms you should not take this shortcut.
			</para>
		</section>
		<section id="Createthemodel">
			<title>Create the model</title>
			<para>Due to the former tutorials you should be familiar with the steps to create the model with protocols, actors and state machines.</para>
			<para>The basic idea of the exercise is to create a file reader actor, which is responsible to open, close and read characters from the source file. Another actor receives the characters and filters the comments (parser). The remaining characters (pure source code) should be print out. </para>
			<para>Remember the logical steps: 
				- create the model by the help of content assist (CTRL Space)
				- name the model, subsystem and top level actor
				- define the protocol (in this case it should be able to send a char, and to request the next char from the file reader)
				- create the structure (file reader and parser with an appropriate port, create the references and connect the ports)
				- create the state machines</para>
			<para>Try to create the model by yourself and take the following solution as an example.</para>
			<para>Structure:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/036-RemoveCommentC04.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>File reader FSM:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/036-RemoveCommentC05.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Parser FSM:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/036-RemoveCommentC06.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Complete model:</para>
			<literallayout><code>RoomModel RemoveComment {
	import room.basic.types.c.* from "CTypes.room"
	SubSystemClass RemoveCommentSubSys {
		ActorRef Topref:ATop 
	}
	ActorClass ATop {
		Structure {
			ActorRef reader: AFileReader
			ActorRef cParser: ACParser
			Binding reader.outPort and cParser.readerPort
		}
		Behavior { }
	}
	ActorClass AFileReader{
		Interface {
			Port outPort: FileReaderProtocol
		}
		Structure {
			usercode3{"#include &lt;stdio.h&gt;"
			}
			external Port outPort
			Attribute f:file ref
		}
		Behavior {
			StateMachine {
				Transition init: initial -&gt; reading {
					action {
						"if ((f = fopen(\"test.txt\",\"r\")) != 0) {"
						"\tprintf(\"file open ok !\\r\\n\");"
						"\t}"
						"\telse {"
						"\tprintf(\"file not found !\\r\\n\");"
						"\tSubSysClass_shutdown();"
						"\t}"
					}
				}
				Transition tr0: reading -&gt; reading {
					triggers {
						&lt;getNextChar: outPort&gt;
					}
					action {
						"int8 c;"
						"if ((c=fgetc(f)) != EOF) {"
						"\toutPort.nextChar(c);"
						"\t}"
						"\telse {"
						"\tfclose(f);"
						"\tprintf(\"file closed !\\r\\n\");"
						"\tSubSysClass_shutdown();"
						"\t}"
					}
				}
				State reading
			}
		}
	}
	ActorClass ACParser{
		Interface {
			conjugated Port readerPort: FileReaderProtocol
		}
		Structure {
			external Port readerPort
		}
		Behavior {
			StateMachine {
				Transition init: initial -&gt; code {
					action {
						"readerPort.getNextChar();"
					}
				}
				Transition tr0: code -&gt; cp cp0 {
					triggers {
						&lt;nextChar: readerPort&gt;
					}
					action {
						"readerPort.getNextChar();"
					}
				}
				Transition tr1: cp cp0 -&gt; code {
					action {
						"printf(\"%c\",c);"
					}
				}
				Transition tr2: cp cp0 -&gt; firstSlash {
					cond {
						"c==\'/\'"
					}
				}
				Transition tr3: firstSlash -&gt; cp cp1 {
					triggers {
						&lt;nextChar: readerPort&gt;
					}
					action {
						"readerPort.getNextChar();"
					}
				}
				Transition tr4: cp cp1 -&gt; cp cp4
				Transition tr5: cp cp1 -&gt; blockComment {
					cond {
						"c==\'*\'"
					}
				}
				Transition tr6: blockComment -&gt; cp cp2 {
					triggers {
						&lt;nextChar: readerPort&gt;
					}
					action {
						"readerPort.getNextChar();"
					}
				}
				Transition tr7: cp cp2 -&gt; blockComment
				Transition tr8: cp cp2 -&gt; firstStar {
					cond {
						"c==\'*\'"
					}
				}
				Transition tr9: firstStar -&gt; cp cp3 {
					triggers {
						&lt;nextChar: readerPort&gt;
					}
					action {
						"readerPort.getNextChar();"
					}
				}
				Transition tr10: cp cp3 -&gt; blockComment
				Transition tr11: cp cp3 -&gt; code {
					cond {
						"c==\'/\'"
					}
				}
				Transition tr12: cp cp4 -&gt; code {
					action {
						"printf(\"%c%c\",\'/\',c);"
					}
				}
				Transition tr13: cp cp4 -&gt; lineComment {
					cond {
						"c==\'/\'"
					}
				}
				Transition tr14: cp cp5 -&gt; lineComment
				Transition tr15: lineComment -&gt; cp cp5 {
					triggers {
						&lt;nextChar: readerPort&gt;
					}
					action {
						"readerPort.getNextChar();"
					}
				}
				Transition tr16: cp cp5 -&gt; code {
					cond {
						"c==\'\\n\'"
					}
				}
				ChoicePoint cp0
				ChoicePoint cp1
				ChoicePoint cp2
				ChoicePoint cp3
				ChoicePoint cp4
				ChoicePoint cp5
				State code
				State firstSlash
				State blockComment
				State firstStar
				State lineComment
			}
		}
	}

	ProtocolClass FileReaderProtocol {
		incoming {
			Message getNextChar()
		}
		outgoing {
			Message nextChar(c:char)
		}
	}
}
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
			<para>Take a look at the file attribute of the file reader. </para>
			<literallayout><code>Attribute f:file ref
</code></literallayout>
			<blockquote>
				<para></para>
			</blockquote>
			<para>
				<emphasis>fopen</emphasis> expects a 
				<emphasis>FILE *</emphasis>. 
				<emphasis>f:file ref</emphasis> declares a variable 
				<emphasis>f</emphasis> from type reference to 
				<emphasis>file</emphasis>, which is a pointer to 
				<emphasis>FILE</emphasis>.
			</para>
		</section>
		<section id="Generatebuildandrunthemodel">
			<title>Generate, build and run the model</title>
			<para>Before you can run the model you should copy one of the generated C source files into the project folder and name it 
				<emphasis>test.txt</emphasis>. 
			</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/036-RemoveCommentC07.png"/>
					</imageobject>
				</mediaobject>
			</para>
			<para>Generate, build and run the model.</para>
			<para>Your output should start like this:</para>
			<para>
				<mediaobject>
					<imageobject>
						<imagedata fileref="images/036-RemoveCommentC08.png"/>
					</imageobject>
				</mediaobject>
			</para>
		</section>
		<section id="Summary5">
			<title>Summary</title>
			<para>This tutorial should help you to train the necessary steps to create a C model. By the way you have seen how to create your own type system for a real embedded project. An additional aspect was to show how simple it is to separate different aspects of the required functionality by the use of actors and protocols and make them reusable.</para>
		</section>
	</chapter>
	<chapter id="ROOMConcepts">
		<title>ROOM Concepts</title>
		<para>This chapter gives an overview over the ROOM language elements and their textual and graphical notation.
			The formal ROOM grammar based on Xtext (EBNF) you can find here: 
			<ulink url="http://git.eclipse.org/c/etrice/org.eclipse.etrice.git/tree/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/Room.xtext">ROOM Grammar</ulink>
		</para>
		<section id="Actors">
			<title>Actors</title>
			<section id="Description">
				<title>Description</title>
				<para>The actor is the basic structural building block for building systems with ROOM. An actor can be refined hierarchically and thus can be of arbitrarily large scope. Ports define the interface of an actor. An Actor can also have a behavior usually defined by a finite state machine.</para>
			</section>
			<section id="Motivation">
				<title>Motivation</title>
				<itemizedlist>
					<listitem>
						<para>Actors enable the construction of hierarchical structures by composition and layering</para>
					</listitem>
					<listitem>
						<para>Actors have their own logical thread of execution</para>
					</listitem>
					<listitem>
						<para>Actors can be freely deployed</para>
					</listitem>
					<listitem>
						<para>Actors define potentially reusable blocks</para>
					</listitem>
				</itemizedlist>
			</section>
			<section id="Notation">
				<title>Notation</title>
				<para><table title="Actor Class Notation" frame="box" border="2" cellpadding="3" cellspacing="0" >
						<tr>
							<td align="center">
					<emphasis role="bold">Element</emphasis></td>
							<td align="center">
					<emphasis role="bold">Graphical Notation</emphasis></td>
							<td align="center">
					<emphasis role="bold">Textual Notation</emphasis></td>
						</tr>
						<tr>
							<td>ActorClass</td>
							<td>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-ActorClassNotation.png"/>
						</imageobject>
					</mediaobject></td>
							<td>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-ActorClassTextualNotation.png"/>
						</imageobject>
					</mediaobject></td>
						</tr>
						<tr>
							<td>ActorRef</td>
							<td>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-ActorReferenceNotation.png"/>
						</imageobject>
					</mediaobject></td>
							<td>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-ActorReferenceTextualNotation.png"/>
						</imageobject>
					</mediaobject></td>
						</tr>
</table>					 
				</para>
			</section>
			<section id="Details">
				<title>Details</title>
				<section id="ActorClassesActorReferencesPortsandBindings">
					<title>Actor Classes, Actor References, Ports and Bindings</title>
					<para>An 
						<emphasis role="bold">ActorClass</emphasis> defines the type (or blueprint) of an actor. Hierarchies are built by ActorClasses that contain 
						<emphasis role="bold">ActorReferences</emphasis> which have another ActorClass as type. The interface of an ActorClass is always defined by Ports. The ActorClass can also contain Attributes, Operations and a finite state machine. 
					</para>
					<para>
						<emphasis role="bold">External Ports</emphasis> define the external interface of an actor and are defined in the 
						<emphasis role="bold">Interface</emphasis> section of the ActorClass.
					</para>
					<para>
						<emphasis role="bold">Internal Ports</emphasis> define the internal interface of an actor and are defined in the 
						<emphasis role="bold">Structure</emphasis> section of the ActorClass.
					</para>
					<para>
						<emphasis role="bold">Bindings</emphasis> connect Ports inside an ActorClass.
					</para>
					<para>Example:</para>
					<para><table title="Actor Class Example" frame="box" border="2" cellpadding="3" cellspacing="0" >
							<tr>
								<td align="center">
						<emphasis role="bold">Graphical Notation</emphasis></td>
								<td align="center">
						<emphasis role="bold">Textual Notation</emphasis></td>
							</tr>
							<tr>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ActorClass.png"/>
							</imageobject>
						</mediaobject></td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ActorClassExampleTextualNotation.png"/>
							</imageobject>
						</mediaobject></td>
							</tr>
</table>						 
					</para>
					<itemizedlist>
						<listitem>
							<para>
								<emphasis>ActorClass1</emphasis> contains two ActorReferences (of ActorClass2 and ActorClass3)
							</para>
						</listitem>
						<listitem>
							<para>
								<emphasis>port1</emphasis> is a 
								<emphasis role="bold">External End Port</emphasis>. Since it connects external Actors with the behavior of the ActorClass, it is defined in the 
								<emphasis role="bold">Interface</emphasis> section and the 
								<emphasis role="bold">Structure</emphasis> section of the ActorClass.
							</para>
						</listitem>
						<listitem>
							<para>
								<emphasis>port2</emphasis> and 
								<emphasis>port3</emphasis> are 
								<emphasis role="bold">Internal End Ports</emphasis> and can only be connected to the ports of contained ActorReferences. Internal End Ports connect the Behavior of an ActorClass with its contained ActorReferences.
							</para>
						</listitem>
						<listitem>
							<para>
								<emphasis>port4</emphasis> is a relay port and connects external Actors to contained ActorReferences. This port can not be accessed by the behavior of the ActorClass.
							</para>
						</listitem>
						<listitem>
							<para>
								<emphasis>port5</emphasis> through 
								<emphasis>port9</emphasis> are Ports of contained ActorReferences. 
								<emphasis>port8</emphasis> and 
								<emphasis>port9</emphasis> can communicate without interference with the containing ActorClass.
							</para>
						</listitem>
						<listitem>
							<para>
								<emphasis role="bold">Bindings</emphasis> can connect ports of the ActorClass and its contained ActorReferences. 
							</para>
						</listitem>
					</itemizedlist>
				</section>
				<section id="Attributes">
					<title>Attributes</title>
					<para>Attributes are part of the Structure of an ActorClass. They can be of a PrimitiveType or a DataClass.</para>
					<para>Example:</para>
					<para>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ActorClassAttributes.png"/>
							</imageobject>
						</mediaobject>
					</para>
				</section>
				<section id="Operations">
					<title>Operations</title>
					<para>Operations are part of the Behavior of an ActorClass.  Arguments and return values can be of a PrimitiveType or a DataClass. DataClasses can be passed by value (implicit) or by reference (keyword 
						<emphasis role="bold">ref</emphasis>).
					</para>
					<para>Example:</para>
					<para>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ActorClassOperations.png"/>
							</imageobject>
						</mediaobject>
					</para>
				</section>
			</section>
		</section>
		<section id="Protocols">
			<title>Protocols</title>
			<section id="Description2">
				<title>Description</title>
				<para>A ProtocolClass defines a set of incoming and outgoing messages that can be exchanged between two ports.
					The exact semantics of a message is defined by the execution model.</para>
			</section>
			<section id="Motivation2">
				<title>Motivation</title>
				<itemizedlist>
					<listitem>
						<para>ProtocolClasses provide a reusable interface specification for ports</para>
					</listitem>
					<listitem>
						<para>ProtocolClasses can optionally specify valid message exchange sequences</para>
					</listitem>
				</itemizedlist>
			</section>
			<section id="Notation2">
				<title>Notation</title>
				<para>ProtocolClasses have only textual notation. 
					The example defines a ProtocolClass with 2 incoming and two outgoing messages. Messages can have data attached. The data can be of a primitive type (e.g. int32, float64, ...) or a DataClass.</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-ProtocolClassTextualNotation.png"/>
						</imageobject>
					</mediaobject>
				</para>
			</section>
		</section>
		<section id="Ports">
			<title>Ports</title>
			<section id="Description3">
				<title>Description</title>
				<para>Ports are the only interfaces of actors. A port has always a protocol assigned. 
					Service Access Points (SAP) and Service Provision Points (SPP) are specialized ports that are used to define layering.</para>
			</section>
			<section id="Motivation3">
				<title>Motivation</title>
				<itemizedlist>
					<listitem>
						<para>Ports decouple interface definition (Protocols) from interface usage</para>
					</listitem>
					<listitem>
						<para>Ports decouple the logical interface from the transport </para>
					</listitem>
				</itemizedlist>
			</section>
			<section id="Notation3">
				<title>Notation</title>
				<section id="ClassPorts">
					<title>Class Ports</title>
					<para>These symbols can only appear on the border of an actor class symbol. </para>
					<para>Ports that define an external interface of the ActorClass, are defined in the 
						<emphasis>Interface</emphasis>. Ports that define an internal interface are defined in the 
						<emphasis>Structure</emphasis> (e.g. internal ports).
					</para>
					<itemizedlist>
						<listitem>
							<para>
								<emphasis role="bold">External End Ports</emphasis> are defined in the Interface and the Structure
							</para>
						</listitem>
						<listitem>
							<para>
								<emphasis role="bold">Internal End Ports</emphasis> are only defined in the Structure
							</para>
						</listitem>
						<listitem>
							<para>
								<emphasis role="bold">Relay Ports</emphasis> are only defined in the Interface
							</para>
						</listitem>
						<listitem>
							<para>
								<emphasis role="bold">End Ports</emphasis> are always connected to the internal behavior of the ActorClass
							</para>
						</listitem>
						<listitem>
							<para>
								<emphasis role="bold">Replicated Ports</emphasis> can be defined with a fixed replication factor ( e.g. 
								<emphasis>Port port18 [ 5 ]: ProtocolClass1</emphasis> ) or a variable replication factor (e.g. 
								<emphasis>Port port18[ * ]: ProtocolClass1</emphasis> )
							</para>
						</listitem>
					</itemizedlist>
					<para><table title="Class Port Notation" frame="box" border="2" cellpadding="3" cellspacing="0">
							<tr>
								<td align="center">
						<emphasis role="bold">Element</emphasis></td>
								<td align="center" width="15%">
						<emphasis role="bold">Graphical Notation</emphasis></td>
								<td align="center">
						<emphasis role="bold">Textual Notation</emphasis></td>
							</tr>
							<tr>
								<td>Class End Port</td>
								<td align="center">
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ClassEndPort.png"/>
							</imageobject>
						</mediaobject></td>
								<td>
									
						<emphasis role="bold">External Class End Port:</emphasis>
									
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ClassEndPortTextual.png"/>
							</imageobject>
						</mediaobject>
									
						<emphasis role="bold">Internal Class End Port:</emphasis>
									
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ClassEndPortInternalTextual.png"/>
							</imageobject>
						</mediaobject>
								</td>
							</tr>
							<tr>
								<td>Conjugated Class End Port</td>
								<td align="center">
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ConjugatedClassEndPort.png"/>
							</imageobject>
						</mediaobject></td>
								<td>
									
						<emphasis role="bold">External Conjugated Class End Port:</emphasis>
									
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ConjugatedClassEndPortTextual.png"/>
							</imageobject>
						</mediaobject>
									
						<emphasis role="bold">Internal Conjugated Class End Port:</emphasis>
									
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ConjugatedClassEndPortInternalTextual.png"/>
							</imageobject>
						</mediaobject>
								</td>
							</tr>
							<tr>
								<td>Class Relay Port</td>
								<td align="center">
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ClassRelayPort.png"/>
							</imageobject>
						</mediaobject></td>
								<td>
									
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ClassRelayPortTextual.png"/>
							</imageobject>
						</mediaobject>
								</td>
							</tr>
							<tr>
								<td>Conjugated Class Relay Port</td>
								<td align="center">
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ConjugatedClassRelayPort.png"/>
							</imageobject>
						</mediaobject></td>
								<td>
									
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ConjugatedClassRelayPortTextual.png"/>
							</imageobject>
						</mediaobject>
								</td>
							</tr>
							<tr>
								<td>Replicated Class End Port</td>
								<td align="center">
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ReplicatedClassEndPort.png"/>
							</imageobject>
						</mediaobject></td>
								<td>
									
						<emphasis role="bold">External Replicated Class End Port:</emphasis>
									
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ReplicatedClassEndPortTextual.png"/>
							</imageobject>
						</mediaobject>
									
						<emphasis role="bold">Internal Replicated Class End Port:</emphasis>
									
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ReplicatedClassEndPortInternalTextual.png"/>
							</imageobject>
						</mediaobject>
								</td>
							</tr>
							<tr>
								<td>Conjugated Replicated Class End Port</td>
								<td align="center">
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ConjugatedReplicatedClassEndPort.png"/>
							</imageobject>
						</mediaobject></td>
								<td>
									
						<emphasis role="bold">External Conjugated Replicated Class End Port:</emphasis>
									
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ConjugatedReplicatedClassEndPortTextual.png"/>
							</imageobject>
						</mediaobject>
									
						<emphasis role="bold">Internal Conjugated Replicated Class End Port:</emphasis>
									
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ConjugatedReplicatedClassEndPortInternalTextual.png"/>
							</imageobject>
						</mediaobject>
								</td>
							</tr>
							<tr>
								<td>Replicated Class Relay Port</td>
								<td align="center">
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ReplicatedClassRelayPort.png"/>
							</imageobject>
						</mediaobject></td>
								<td>
									
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ReplicatedClassRelayPortTextual.png"/>
							</imageobject>
						</mediaobject>
								</td>
							</tr>
							<tr>
								<td>Conjugated Replicated Class Relay Port</td>
								<td align="center">
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ConjugatedReplicatedClassRelayPort.png"/>
							</imageobject>
						</mediaobject></td>
								<td>
									
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ConjugatedReplicatedClassRelayPortTextual.png"/>
							</imageobject>
						</mediaobject>
								</td>
							</tr>
</table>
					</para>
				</section>
				<section id="ReferencePorts">
					<title>Reference Ports</title>
					<para>These symbols can only appear on the border of an ActorReference symbol. Since the type of port is defined in the ActorClass, no textual notation for the Reference Ports exists.</para>
					<para><table title="Title" frame="box" border="2" cellpadding="3" cellspacing="0">
							<tr>
								<td align="center">
						<emphasis role="bold">Element</emphasis></td>
								<td align="center">
						<emphasis role="bold">Graphical Notation</emphasis></td>
								<td align="center">
						<emphasis role="bold">Textual Notation</emphasis></td>
							</tr>
							<tr>
								<td>Reference Port</td>
								<td align="center">
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ReferencePort.png"/>
							</imageobject>
						</mediaobject></td>
								<td align="center">
						<emphasis>implicit</emphasis></td>
							</tr>
							<tr>
								<td>Conjugated Reference Port</td>
								<td align="center">
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ConjugatedReferencePort.png"/>
							</imageobject>
						</mediaobject></td>
								<td align="center">
						<emphasis>implicit</emphasis></td>
							</tr>
							<tr>
								<td>Replicated Reference Port</td>
								<td align="center">
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ReplicatedReferencePort.png"/>
							</imageobject>
						</mediaobject></td>
								<td align="center">
						<emphasis>implicit</emphasis></td>
							</tr>
							<tr>
								<td>Conjugated Replicated Reference Port</td>
								<td align="center">
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ConjugatedReplicatedReferencePort.png"/>
							</imageobject>
						</mediaobject></td>
								<td align="center">
						<emphasis>implicit</emphasis></td>
							</tr>
</table>
					</para>
				</section>
			</section>
		</section>
		<section id="DataClass">
			<title>DataClass</title>
			<section id="Description4">
				<title>Description</title>
				<para>The DataClass enables the modeling of hierarchical complex datatypes and operations on them. The DataClass is the equivalent to a Class in languages like Java or C++, but has less features. The content of a DataClass can always be sent via message between actors (defined as message data in ProtocolClass).</para>
			</section>
			<section id="Notation4">
				<title>Notation</title>
				<para>Example: DataClass using PrimitiveTypes</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-DataClass1.png"/>
						</imageobject>
					</mediaobject>
				</para>
				<para>Example: DataClass using other DataClasses:</para>
				<para>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-DataClass2.png"/>
						</imageobject>
					</mediaobject>
				</para>
			</section>
		</section>
		<section id="Layering2">
			<title>Layering</title>
			<section id="Description5">
				<title>Description</title>
				<para>In addition to the Actor containment hierarchies, Layering provides another method to hierarchically structure a software system. Layering and actor hierarchies with port to port connections can be mixed on every level of granularity.</para>
				<orderedlist>
					<listitem>
						<para>an ActorClass can define a Service Provision Point (SPP) to publish a specific service, defined by a ProtocolClass</para>
					</listitem>
					<listitem>
						<para>an ActorClass can define a Service Access Point (SAP) if it needs a service, defined by a ProtocolClass</para>
					</listitem>
					<listitem>
						<para>for a given Actor hierarchy, a LayerConnection defines which SAP will be satisfied by (connected to) which SPP</para>
					</listitem>
				</orderedlist>
			</section>
			<section id="Notation5">
				<title>Notation</title>
				<para><table title="Title" frame="box" border="2" cellpadding="3" cellspacing="0">
						<tr>
							<td align="center">
					<emphasis role="bold">Description</emphasis></td>
							<td align="center">
					<emphasis role="bold">Graphical Notation</emphasis></td>
							<td align="center">
					<emphasis role="bold">Textual Notation</emphasis></td>
						</tr>
						<tr>
							<td>The Layer Connections in this model define which services are provided by the 
					<emphasis>ServiceLayer</emphasis>  (
					<emphasis>digitalIO</emphasis> and 
					<emphasis>timer</emphasis>)</td>
							<td>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-LayeringModel.png"/>
						</imageobject>
					</mediaobject></td>
							<td>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-LayeringModelTextual.png"/>
						</imageobject>
					</mediaobject></td>
						</tr>
						<tr>
							<td>The implementation of the services (SPPs) can be delegated to sub actors. In this case the actor 
					<emphasis>ServiceLayer</emphasis> relays (delegates) the implementation services 
					<emphasis>digitalIO</emphasis> and 
					<emphasis>timer</emphasis> to sub actors</td>
							<td>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-LayeringServiceLayer.png"/>
						</imageobject>
					</mediaobject></td>
							<td>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-LayeringServiceLayerTextual.png"/>
						</imageobject>
					</mediaobject></td>
						</tr>
						<tr>
							<td>Every Actor inside the 
					<emphasis>ApplicationLayer</emphasis> that contains an SAP with the same Protocol as 
					<emphasis>timer</emphasis> or 
					<emphasis>digitalIO</emphasis> will be connected to the specified SPP</td>
							<td>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-LayeringApplicationLayer.png"/>
						</imageobject>
					</mediaobject></td>
							<td>
					<mediaobject>
						<imageobject>
							<imagedata fileref="images/040-LayeringApplicationLayerTextual.png"/>
						</imageobject>
					</mediaobject></td>
						</tr>
</table>
				</para>
			</section>
		</section>
		<section id="FiniteStateMachines">
			<title>Finite State Machines</title>
			<section id="Description6">
				<title>Description</title>
				<para>Definition from 
					<ulink url="http://en.wikipedia.org/wiki/Finite-state_machine">Wikipedia</ulink>:
				</para>
				<blockquote>
					<para>
						A finite-state machine (FSM) or finite-state automaton (plural: automata), or simply a state machine, is a mathematical model used to design computer programs and digital logic circuits. It is conceived as an abstract machine that can be in one of a finite number of states. The machine is in only one state at a time; the state it is in at any given time is called the current state. It can change from one state to another when initiated by a triggering event or condition, this is called a transition. A particular FSM is defined by a list of the possible states it can transition to from each state, and the triggering condition for each transition.</para>
				</blockquote>
				<para>In ROOM each actor class can implement its behavior using a state machine. Events occurring at the end ports of an actor will be forwarded to and processed by the state machine. Events possibly trigger state transitions.</para>
			</section>
			<section id="Motivation4">
				<title>Motivation</title>
				<para>For event driven systems a finite state machine is ideal for processing the stream of events. Typically during processing new events are produced which are sent to peer actors.</para>
				<para>We distinguish flat and hierarchical state machines.</para>
			</section>
			<section id="Notation6">
				<title>Notation</title>
				<section id="FlatFiniteStateMachine">
					<title>Flat Finite State Machine</title>
					<para>The simpler flat finite state machines are composed of the following elements:</para>
					<para><table title="Title" frame="box" border="2" cellpadding="3" cellspacing="0">
							<tr>
								<td align="center">
						<emphasis role="bold">Description</emphasis></td>
								<td align="center">
						<emphasis role="bold">Graphical Notation</emphasis></td>
								<td align="center">
						<emphasis role="bold">Textual Notation</emphasis></td>
							</tr>
							<tr>
								<td>State</td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-State.jpg"/>
							</imageobject>
						</mediaobject></td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-StateTextual.jpg"/>
							</imageobject>
						</mediaobject></td>
							</tr>
							<tr>
								<td>InitialPoint</td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-InitialPoint.jpg"/>
							</imageobject>
						</mediaobject></td>
								<td>
						<emphasis>implicit</emphasis></td>
							</tr>
							<tr>
								<td>TransitionPoint</td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-TransitionPoint.jpg"/>
							</imageobject>
						</mediaobject></td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-TransitionPointTextual.jpg"/>
							</imageobject>
						</mediaobject></td>
							</tr>
							<tr>
								<td>ChoicePoint</td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ChoicePoint.jpg"/>
							</imageobject>
						</mediaobject></td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ChoicePointTextual.jpg"/>
							</imageobject>
						</mediaobject></td>
							</tr>
							<tr>
								<td>Initial Transition</td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-InitialTransition.jpg"/>
							</imageobject>
						</mediaobject></td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-InitialTransitionTextual.jpg"/>
							</imageobject>
						</mediaobject></td>
							</tr>
							<tr>
								<td>Triggered Transition</td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-TriggeredTransition.jpg"/>
							</imageobject>
						</mediaobject></td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-TriggeredTransitionTextual.jpg"/>
							</imageobject>
						</mediaobject></td>
							</tr>
</table>
					</para>
				</section>
				<section id="HierarchicalFiniteStateMachine">
					<title>Hierarchical Finite State Machine</title>
					<para>The hierarchical finite state machine adds the notion of a sub state machine nested in a state.
						A few modeling elements are added to the set listed above:</para>
					<para><table title="Title" frame="box" border="2" cellpadding="3" cellspacing="0">
							<tr>
								<td align="center">
						<emphasis role="bold">Description</emphasis></td>
								<td align="center">
						<emphasis role="bold">Graphical Notation</emphasis></td>
								<td align="center">
						<emphasis role="bold">Textual Notation</emphasis></td>
							</tr>
							<tr>
								<td>State with sub state machine</td>
								<td>Parent State
								
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-StateWithSubFSM.jpg"/>
							</imageobject>
						</mediaobject>
								Sub state machine
								
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-SubFSM.jpg"/>
							</imageobject>
						</mediaobject></td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-StateWithSubFSMTextual.jpg"/>
							</imageobject>
						</mediaobject></td>
							</tr>
							<tr>
								<td>Entry Point</td>
								<td>In sub state machine
								
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-EntryPoint.jpg"/>
							</imageobject>
						</mediaobject>
								On parent state
								
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-EntryPointRef.jpg"/>
							</imageobject>
						</mediaobject></td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-EntryPointTextual.jpg"/>
							</imageobject>
						</mediaobject></td>
							</tr>
							<tr>
								<td>Exit Point</td>
								<td>In sub state machine
								
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ExitPoint.jpg"/>
							</imageobject>
						</mediaobject>
								On parent state
								
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ExitPointRef.jpg"/>
							</imageobject>
						</mediaobject></td>
								<td>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-ExitPointTextual.jpg"/>
							</imageobject>
						</mediaobject></td>
							</tr>
</table>
					</para>
				</section>
			</section>
			<section id="Examples">
				<title>Examples</title>
				<section id="Exampleofaflatfinitestatemachine">
					<title>Example of a flat finite state machine:</title>
					<para>
						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-FlatFSM.jpg"/>
							</imageobject>
						</mediaobject>
					</para>
				</section>
				<section id="Exampleofahierarchicalfinitestatemachine">
					<title>Example of a hierarchical finite state machine:</title>
					<para>Top level

						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-HierarchicalFSMTop.jpg"/>
							</imageobject>
						</mediaobject>
					</para>
					<para>Sub state machine of Initializing

						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-HierarchicalFSMInitializing.jpg"/>
							</imageobject>
						</mediaobject>
					</para>
					<para>Sub state machine of Running

						<mediaobject>
							<imageobject>
								<imagedata fileref="images/040-HierarchicalFSMRunning.jpg"/>
							</imageobject>
						</mediaobject>
					</para>
				</section>
			</section>
		</section>
	</chapter>
</book>

Back to the top