Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5c0466c2791eeedb24de9616374f4383567c855e (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
package org.eclipse.etrice.generator.c.gen;

import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.genmodel.base.ILogger;
import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
import org.eclipse.etrice.core.genmodel.etricegen.InterfaceItemInstance;
import org.eclipse.etrice.core.genmodel.etricegen.PortInstance;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.core.genmodel.etricegen.SubSystemInstance;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorCommunicationType;
import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.CommunicationType;
import org.eclipse.etrice.core.room.DataType;
import org.eclipse.etrice.core.room.DetailCode;
import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.core.room.MessageHandler;
import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.PortClass;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RefableType;
import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.c.gen.CExtensions;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.etrice.generator.generic.TypeHelpers;
import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.xbase.lib.BooleanExtensions;
import org.eclipse.xtext.xbase.lib.CollectionExtensions;
import org.eclipse.xtext.xbase.lib.ComparableExtensions;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IntegerExtensions;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.ListExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.eclipse.xtext.xtend2.lib.StringConcatenation;

@SuppressWarnings("all")
@Singleton
public class SubSystemClassGen {
  @Inject
  private JavaIoFileSystemAccess fileAccess;
  
  @Inject
  private CExtensions stdExt;
  
  @Inject
  private RoomExtensions roomExt;
  
  @Inject
  private ProcedureHelpers helpers;
  
  @Inject
  private TypeHelpers _typeHelpers;
  
  @Inject
  private ILogger logger;
  
  public void doGenerate(final Root root) {
    EList<SubSystemInstance> _subSystemInstances = root.getSubSystemInstances();
    for (final SubSystemInstance ssi : _subSystemInstances) {
      {
        SubSystemClass _subSystemClass = ssi.getSubSystemClass();
        String _generationTargetPath = this.roomExt.getGenerationTargetPath(_subSystemClass);
        SubSystemClass _subSystemClass_1 = ssi.getSubSystemClass();
        String _path = this.roomExt.getPath(_subSystemClass_1);
        String _operator_plus = StringExtensions.operator_plus(_generationTargetPath, _path);
        String path = _operator_plus;
        SubSystemClass _subSystemClass_2 = ssi.getSubSystemClass();
        String _cHeaderFileName = this.stdExt.getCHeaderFileName(_subSystemClass_2);
        String file = _cHeaderFileName;
        String _operator_plus_1 = StringExtensions.operator_plus("generating SubSystemClass declaration: \'", file);
        String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "\' in \'");
        String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, path);
        String _operator_plus_4 = StringExtensions.operator_plus(_operator_plus_3, "\'");
        this.logger.logInfo(_operator_plus_4);
        this.fileAccess.setOutputPath(path);
        SubSystemClass _subSystemClass_3 = ssi.getSubSystemClass();
        StringConcatenation _generateHeaderFile = this.generateHeaderFile(root, ssi, _subSystemClass_3);
        this.fileAccess.generateFile(file, _generateHeaderFile);
        SubSystemClass _subSystemClass_4 = ssi.getSubSystemClass();
        String _cSourceFileName = this.stdExt.getCSourceFileName(_subSystemClass_4);
        file = _cSourceFileName;
        String _operator_plus_5 = StringExtensions.operator_plus("generating SubSystemClass implementation: \'", file);
        String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "\' in \'");
        String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, path);
        String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, "\'");
        this.logger.logInfo(_operator_plus_8);
        this.fileAccess.setOutputPath(path);
        SubSystemClass _subSystemClass_5 = ssi.getSubSystemClass();
        StringConcatenation _generateSourceFile = this.generateSourceFile(root, ssi, _subSystemClass_5);
        this.fileAccess.generateFile(file, _generateSourceFile);
        SubSystemClass _subSystemClass_6 = ssi.getSubSystemClass();
        String _instSourceFileName = this.stdExt.getInstSourceFileName(_subSystemClass_6);
        file = _instSourceFileName;
        String _operator_plus_9 = StringExtensions.operator_plus("generating SubSystemClass instance file: \'", file);
        String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, "\' in \'");
        String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, path);
        String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, "\'");
        this.logger.logInfo(_operator_plus_12);
        this.fileAccess.setOutputPath(path);
        SubSystemClass _subSystemClass_7 = ssi.getSubSystemClass();
        StringConcatenation _generateInstanceFile = this.generateInstanceFile(root, ssi, _subSystemClass_7);
        this.fileAccess.generateFile(file, _generateInstanceFile);
        SubSystemClass _subSystemClass_8 = ssi.getSubSystemClass();
        String _dispSourceFileName = this.stdExt.getDispSourceFileName(_subSystemClass_8);
        file = _dispSourceFileName;
        String _operator_plus_13 = StringExtensions.operator_plus("generating SubSystemClass dispatcher file: \'", file);
        String _operator_plus_14 = StringExtensions.operator_plus(_operator_plus_13, "\' in \'");
        String _operator_plus_15 = StringExtensions.operator_plus(_operator_plus_14, path);
        String _operator_plus_16 = StringExtensions.operator_plus(_operator_plus_15, "\'");
        this.logger.logInfo(_operator_plus_16);
        this.fileAccess.setOutputPath(path);
        SubSystemClass _subSystemClass_9 = ssi.getSubSystemClass();
        StringConcatenation _generateDispatcherFile = this.generateDispatcherFile(root, ssi, _subSystemClass_9);
        this.fileAccess.generateFile(file, _generateDispatcherFile);
      }
    }
  }
  
  private StringConcatenation generateHeaderFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("/**");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* @author generated by eTrice");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("*");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* Header File of SubSystemClass ");
    String _name = ssc.getName();
    _builder.append(_name, " ");
    _builder.newLineIfNotEmpty();
    _builder.append(" ");
    _builder.append("* ");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("*/");
    _builder.newLine();
    _builder.newLine();
    String _name_1 = ssc.getName();
    StringConcatenation _generateIncludeGuardBegin = this.stdExt.generateIncludeGuardBegin(_name_1);
    _builder.append(_generateIncludeGuardBegin, "");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    DetailCode _userCode1 = ssc.getUserCode1();
    StringConcatenation _userCode = this.helpers.userCode(_userCode1);
    _builder.append(_userCode, "");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.newLine();
    _builder.append("/* lifecycle functions");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* init -> start -> run (loop) -> stop -> destroy");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("*/");
    _builder.newLine();
    _builder.newLine();
    _builder.append("void ");
    String _name_2 = ssc.getName();
    _builder.append(_name_2, "");
    _builder.append("_init(void);\t\t/* lifecycle init  \t */");
    _builder.newLineIfNotEmpty();
    _builder.append("void ");
    String _name_3 = ssc.getName();
    _builder.append(_name_3, "");
    _builder.append("_start(void);\t/* lifecycle start \t */");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("void ");
    String _name_4 = ssc.getName();
    _builder.append(_name_4, "");
    _builder.append("_run(void);\t\t/* lifecycle run \t */");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("void ");
    String _name_5 = ssc.getName();
    _builder.append(_name_5, "");
    _builder.append("_stop(void); \t/* lifecycle stop\t */");
    _builder.newLineIfNotEmpty();
    _builder.append("void ");
    String _name_6 = ssc.getName();
    _builder.append(_name_6, "");
    _builder.append("_destroy(void); \t/* lifecycle destroy */");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("void ");
    String _name_7 = ssc.getName();
    _builder.append(_name_7, "");
    _builder.append("_shutdown(void);  /* shutdown the dispatcher loop */");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    DetailCode _userCode2 = ssc.getUserCode2();
    StringConcatenation _userCode_1 = this.helpers.userCode(_userCode2);
    _builder.append(_userCode_1, "");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    String _name_8 = ssc.getName();
    StringConcatenation _generateIncludeGuardEnd = this.stdExt.generateIncludeGuardEnd(_name_8);
    _builder.append(_generateIncludeGuardEnd, "");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.newLine();
    return _builder;
  }
  
  private StringConcatenation generateSourceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("/**");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* @author generated by eTrice");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("*");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* Source File of SubSystemClass ");
    String _name = ssc.getName();
    _builder.append(_name, " ");
    _builder.newLineIfNotEmpty();
    _builder.append(" ");
    _builder.append("* ");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("*/");
    _builder.newLine();
    _builder.newLine();
    _builder.append("#include \"");
    String _cHeaderFileName = this.stdExt.getCHeaderFileName(ssc);
    _builder.append(_cHeaderFileName, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("/* include instances for all classes */");
    _builder.newLine();
    _builder.append("#include \"");
    String _instSourceFileName = this.stdExt.getInstSourceFileName(ssc);
    _builder.append(_instSourceFileName, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.append("#include \"");
    String _dispSourceFileName = this.stdExt.getDispSourceFileName(ssc);
    _builder.append(_dispSourceFileName, "");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("#include \"debugging/etLogger.h\"");
    _builder.newLine();
    _builder.append("#include \"debugging/etMSCLogger.h\"");
    _builder.newLine();
    _builder.newLine();
    _builder.append("#include \"platform/etTimer.h\"");
    _builder.newLine();
    _builder.append("#include \"etGlobalFlags.h\"");
    _builder.newLine();
    _builder.newLine();
    DetailCode _userCode3 = ssc.getUserCode3();
    StringConcatenation _userCode = this.helpers.userCode(_userCode3);
    _builder.append(_userCode, "");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("/* data for SubSysten ");
    String _name_1 = ssc.getName();
    _builder.append(_name_1, "");
    _builder.append(" */");
    _builder.newLineIfNotEmpty();
    _builder.append("typedef struct ");
    String _name_2 = ssc.getName();
    _builder.append(_name_2, "");
    _builder.append(" {");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("char *name;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("volatile int shutdownRequest;");
    _builder.newLine();
    _builder.append("} ");
    String _name_3 = ssc.getName();
    _builder.append(_name_3, "");
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("static ");
    String _name_4 = ssc.getName();
    _builder.append(_name_4, "");
    _builder.append(" ");
    String _name_5 = ssc.getName();
    _builder.append(_name_5, "");
    _builder.append("Inst = {\"");
    String _name_6 = ssc.getName();
    _builder.append(_name_6, "");
    _builder.append("\",0};");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("void ");
    String _name_7 = ssc.getName();
    _builder.append(_name_7, "");
    _builder.append("_initActorInstances(void);");
    _builder.newLineIfNotEmpty();
    _builder.append("void ");
    String _name_8 = ssc.getName();
    _builder.append(_name_8, "");
    _builder.append("_constructActorInstances(void);");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("void ");
    String _name_9 = ssc.getName();
    _builder.append(_name_9, "");
    _builder.append("_init(void){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"init\")");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("etLogger_logInfoF(\"%s_init\", ");
    String _name_10 = ssc.getName();
    _builder.append(_name_10, "	");
    _builder.append("Inst.name);");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("/* construct all actors */");
    _builder.newLine();
    _builder.append("\t");
    String _name_11 = ssc.getName();
    _builder.append(_name_11, "	");
    _builder.append("_constructActorInstances();");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("/* initialization of all message services */");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("etMessageService_init(&msgService_Thread1, msgBuffer_Thread1, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE, MsgDispatcher_Thread1_receiveMessage);");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("/* init all actors */");
    _builder.newLine();
    _builder.append("\t");
    String _name_12 = ssc.getName();
    _builder.append(_name_12, "	");
    _builder.append("_initActorInstances();");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("void ");
    String _name_13 = ssc.getName();
    _builder.append(_name_13, "");
    _builder.append("_start(void){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"start\")");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("etLogger_logInfoF(\"%s_start\", ");
    String _name_14 = ssc.getName();
    _builder.append(_name_14, "	");
    _builder.append("Inst.name);");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("void ");
    String _name_15 = ssc.getName();
    _builder.append(_name_15, "");
    _builder.append("_run(void){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"run\")");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("#ifdef ET_RUNTIME_ENDLESS");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("while(!(");
    String _name_16 = ssc.getName();
    _builder.append(_name_16, "		");
    _builder.append("Inst.shutdownRequest)){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t\t");
    _builder.append("if (etTimer_executeNeeded()){");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("etMessageService_execute(&msgService_Thread1);");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    StringConcatenation _generateDatadrivenExecutes = this.generateDatadrivenExecutes(root, ssi);
    _builder.append(_generateDatadrivenExecutes, "				");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("#else");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("uint32 loopCounter = 0;");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("while(!(");
    String _name_17 = ssc.getName();
    _builder.append(_name_17, "		");
    _builder.append("Inst.shutdownRequest)){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t\t");
    _builder.append("if (etTimer_executeNeeded()){");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("etMessageService_execute(&msgService_Thread1);");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    StringConcatenation _generateDatadrivenExecutes_1 = this.generateDatadrivenExecutes(root, ssi);
    _builder.append(_generateDatadrivenExecutes_1, "				");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t\t\t");
    _builder.append("etLogger_logInfo(\"Execute\");");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("if (loopCounter++ > ET_RUNTIME_MAXLOOP){");
    _builder.newLine();
    _builder.append("\t\t\t\t\t");
    _builder.append("break;");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("#endif");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("void ");
    String _name_18 = ssc.getName();
    _builder.append(_name_18, "");
    _builder.append("_stop(void){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"stop\")");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("etLogger_logInfoF(\"%s_stop\", ");
    String _name_19 = ssc.getName();
    _builder.append(_name_19, "	");
    _builder.append("Inst.name);");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("void ");
    String _name_20 = ssc.getName();
    _builder.append(_name_20, "");
    _builder.append("_destroy(void){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"destroy\")");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("etLogger_logInfoF(\"%s_destroy\", ");
    String _name_21 = ssc.getName();
    _builder.append(_name_21, "	");
    _builder.append("Inst.name);");
    _builder.newLineIfNotEmpty();
    {
      EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
      Iterable<ActorInstance> _reverseView = ListExtensions.<ActorInstance>reverseView(_allContainedInstances);
      for(final ActorInstance ai : _reverseView) {
        {
          ActorClass _actorClass = ai.getActorClass();
          EList<StandardOperation> _operations = _actorClass.getOperations();
          final Function1<StandardOperation,Boolean> _function = new Function1<StandardOperation,Boolean>() {
              public Boolean apply(final StandardOperation op) {
                boolean _isDestructor = op.isDestructor();
                return ((Boolean)_isDestructor);
              }
            };
          Iterable<StandardOperation> _filter = IterableExtensions.<StandardOperation>filter(_operations, _function);
          boolean _isEmpty = IterableExtensions.isEmpty(_filter);
          boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
          if (_operator_not) {
            _builder.append("\t");
            ActorClass _actorClass_1 = ai.getActorClass();
            String _name_22 = _actorClass_1.getName();
            _builder.append(_name_22, "	");
            _builder.append("_dtor(&");
            String _path = ai.getPath();
            String _pathName = this.roomExt.getPathName(_path);
            _builder.append(_pathName, "	");
            _builder.append(");");
            _builder.newLineIfNotEmpty();
          }
        }
      }
    }
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("void ");
    String _name_23 = ssc.getName();
    _builder.append(_name_23, "");
    _builder.append("_shutdown(void){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"SubSys\", \"shutdown\")");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("etLogger_logInfoF(\"%s_shutdown\", ");
    String _name_24 = ssc.getName();
    _builder.append(_name_24, "	");
    _builder.append("Inst.name);");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    String _name_25 = ssc.getName();
    _builder.append(_name_25, "	");
    _builder.append("Inst.shutdownRequest = 1;");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.newLine();
    _builder.append("void ");
    String _name_26 = ssc.getName();
    _builder.append(_name_26, "");
    _builder.append("_constructActorInstances(void){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
    String _name_27 = ssc.getName();
    _builder.append(_name_27, "	");
    _builder.append("\", \"constructActorInstances\")");
    _builder.newLineIfNotEmpty();
    {
      EList<ActorInstance> _allContainedInstances_1 = ssi.getAllContainedInstances();
      for(final ActorInstance ai_1 : _allContainedInstances_1) {
        {
          ActorClass _actorClass_2 = ai_1.getActorClass();
          EList<StandardOperation> _operations_1 = _actorClass_2.getOperations();
          final Function1<StandardOperation,Boolean> _function_1 = new Function1<StandardOperation,Boolean>() {
              public Boolean apply(final StandardOperation op) {
                boolean _isConstructor = RoomHelpers.isConstructor(op);
                return ((Boolean)_isConstructor);
              }
            };
          Iterable<StandardOperation> _filter_1 = IterableExtensions.<StandardOperation>filter(_operations_1, _function_1);
          boolean _isEmpty_1 = IterableExtensions.isEmpty(_filter_1);
          boolean _operator_not_1 = BooleanExtensions.operator_not(_isEmpty_1);
          if (_operator_not_1) {
            _builder.append("\t");
            ActorClass _actorClass_3 = ai_1.getActorClass();
            String _name_28 = _actorClass_3.getName();
            _builder.append(_name_28, "	");
            _builder.append("_ctor(&");
            String _path_1 = ai_1.getPath();
            String _pathName_1 = this.roomExt.getPathName(_path_1);
            _builder.append(_pathName_1, "	");
            _builder.append(");");
            _builder.newLineIfNotEmpty();
          }
        }
      }
    }
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("void ");
    String _name_29 = ssc.getName();
    _builder.append(_name_29, "");
    _builder.append("_initActorInstances(void){");
    _builder.newLineIfNotEmpty();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
    String _name_30 = ssc.getName();
    _builder.append(_name_30, "	");
    _builder.append("\", \"initActorInstances\")");
    _builder.newLineIfNotEmpty();
    {
      EList<ActorInstance> _allContainedInstances_2 = ssi.getAllContainedInstances();
      for(final ActorInstance ai_2 : _allContainedInstances_2) {
        _builder.append("\t");
        ActorClass _actorClass_4 = ai_2.getActorClass();
        String _name_31 = _actorClass_4.getName();
        _builder.append(_name_31, "	");
        _builder.append("_init(&");
        String _path_2 = ai_2.getPath();
        String _pathName_2 = this.roomExt.getPathName(_path_2);
        _builder.append(_pathName_2, "	");
        _builder.append(");");
        _builder.newLineIfNotEmpty();
      }
    }
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    return _builder;
  }
  
  private StringConcatenation generateInstanceFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("/**");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* @author generated by eTrice");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("*");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* Instance File of SubSystemClass ");
    String _name = ssc.getName();
    _builder.append(_name, " ");
    _builder.newLineIfNotEmpty();
    _builder.append(" ");
    _builder.append("* - instantiation of all actor instances and port instances");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* - configuration of data and connection of ports");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("*/");
    _builder.newLine();
    _builder.newLine();
    _builder.append("#include \"messaging/etMessageService.h\"");
    _builder.newLine();
    _builder.append("#include \"platform/etMemory.h\"");
    _builder.newLine();
    _builder.newLine();
    _builder.append("/* instantiation of message services */");
    _builder.newLine();
    _builder.newLine();
    _builder.append("/* MessageService for Thread1 */");
    _builder.newLine();
    _builder.append("static uint8 msgBuffer_Thread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];");
    _builder.newLine();
    _builder.append("static etMessageService msgService_Thread1;");
    _builder.newLine();
    _builder.newLine();
    _builder.newLine();
    _builder.append("/* include all used ActorClasses */");
    _builder.newLine();
    {
      EList<ActorClass> _usedActorClasses = root.getUsedActorClasses();
      for(final ActorClass actorClass : _usedActorClasses) {
        _builder.append("#include \"");
        String _name_1 = actorClass.getName();
        _builder.append(_name_1, "");
        _builder.append(".h\"");
        _builder.newLineIfNotEmpty();
      }
    }
    _builder.newLine();
    _builder.append("/* include all used ProtcolClasses */");
    _builder.newLine();
    {
      EList<ProtocolClass> _usedProtocolClasses = root.getUsedProtocolClasses();
      for(final ProtocolClass protocolClass : _usedProtocolClasses) {
        _builder.append("#include \"");
        String _name_2 = protocolClass.getName();
        _builder.append(_name_2, "");
        _builder.append(".h\"");
        _builder.newLineIfNotEmpty();
      }
    }
    _builder.newLine();
    _builder.newLine();
    _builder.append("/* declarations of all ActorClass instances (const and variable structs) */");
    _builder.newLine();
    _builder.newLine();
    _builder.append("/* forward declaration of variable actor structs */");
    _builder.newLine();
    {
      EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
      for(final ActorInstance ai : _allContainedInstances) {
        _builder.append("static ");
        ActorClass _actorClass = ai.getActorClass();
        String _name_3 = _actorClass.getName();
        _builder.append(_name_3, "");
        _builder.append(" ");
        String _path = ai.getPath();
        String _pathName = this.roomExt.getPathName(_path);
        _builder.append(_pathName, "");
        _builder.append(";");
        _builder.newLineIfNotEmpty();
      }
    }
    _builder.newLine();
    _builder.append("/* forward declaration of variable port structs */\t\t");
    _builder.newLine();
    {
      EList<ActorInstance> _allContainedInstances_1 = ssi.getAllContainedInstances();
      for(final ActorInstance ai_1 : _allContainedInstances_1) {
        {
          EList<InterfaceItemInstance> _orderedIfItemInstances = ai_1.getOrderedIfItemInstances();
          boolean _isEmpty = _orderedIfItemInstances.isEmpty();
          if (_isEmpty) {
            _builder.append("/*nothing to do */");
            _builder.newLine();
          } else {
            {
              EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai_1.getOrderedIfItemInstances();
              for(final InterfaceItemInstance pi : _orderedIfItemInstances_1) {
                {
                  InterfaceItem _interfaceItem = pi.getInterfaceItem();
                  ProtocolClass _protocol = _interfaceItem.getProtocol();
                  boolean _isConjugated = this.roomExt.isConjugated(pi);
                  PortClass _portClass = this.roomExt.getPortClass(_protocol, _isConjugated);
                  boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_portClass, null);
                  if (_operator_notEquals) {
                    {
                      InterfaceItem _interfaceItem_1 = pi.getInterfaceItem();
                      ProtocolClass _protocol_1 = _interfaceItem_1.getProtocol();
                      boolean _isConjugated_1 = this.roomExt.isConjugated(pi);
                      PortClass _portClass_1 = this.roomExt.getPortClass(_protocol_1, _isConjugated_1);
                      EList<Attribute> _attributes = _portClass_1.getAttributes();
                      boolean _isEmpty_1 = _attributes.isEmpty();
                      boolean _operator_not = BooleanExtensions.operator_not(_isEmpty_1);
                      if (_operator_not) {
                        {
                          boolean _isReplicated = pi.isReplicated();
                          if (_isReplicated) {
                            _builder.append("static ");
                            InterfaceItem _interfaceItem_2 = pi.getInterfaceItem();
                            ProtocolClass _protocol_2 = _interfaceItem_2.getProtocol();
                            boolean _isConjugated_2 = this.roomExt.isConjugated(pi);
                            String _portClassName = this.roomExt.getPortClassName(_protocol_2, _isConjugated_2);
                            _builder.append(_portClassName, "");
                            _builder.append("_var ");
                            String _path_1 = pi.getPath();
                            String _pathName_1 = this.roomExt.getPathName(_path_1);
                            _builder.append(_pathName_1, "");
                            _builder.append("_var[");
                            EList<InterfaceItemInstance> _peers = pi.getPeers();
                            int _size = _peers.size();
                            _builder.append(_size, "");
                            _builder.append("]={");
                            String _genReplPortAttributeInitializer = this.genReplPortAttributeInitializer(pi);
                            _builder.append(_genReplPortAttributeInitializer, "");
                            _builder.append("};");
                            _builder.newLineIfNotEmpty();
                          } else {
                            _builder.append("static ");
                            InterfaceItem _interfaceItem_3 = pi.getInterfaceItem();
                            ProtocolClass _protocol_3 = _interfaceItem_3.getProtocol();
                            boolean _isConjugated_3 = this.roomExt.isConjugated(pi);
                            String _portClassName_1 = this.roomExt.getPortClassName(_protocol_3, _isConjugated_3);
                            _builder.append(_portClassName_1, "");
                            _builder.append("_var ");
                            String _path_2 = pi.getPath();
                            String _pathName_2 = this.roomExt.getPathName(_path_2);
                            _builder.append(_pathName_2, "");
                            _builder.append("_var={");
                            StringConcatenation _genPortAttributeInitializer = this.genPortAttributeInitializer(pi);
                            _builder.append(_genPortAttributeInitializer, "");
                            _builder.append("};");
                            _builder.newLineIfNotEmpty();
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    _builder.newLine();
    {
      EList<ActorInstance> _allContainedInstances_2 = ssi.getAllContainedInstances();
      for(final ActorInstance ai_2 : _allContainedInstances_2) {
        _builder.newLine();
        _builder.append("/* instance ");
        String _path_3 = ai_2.getPath();
        String _pathName_3 = this.roomExt.getPathName(_path_3);
        _builder.append(_pathName_3, "");
        _builder.append(" */");
        _builder.newLineIfNotEmpty();
        {
          EList<InterfaceItemInstance> _orderedIfItemInstances_2 = ai_2.getOrderedIfItemInstances();
          boolean _isEmpty_2 = _orderedIfItemInstances_2.isEmpty();
          if (_isEmpty_2) {
            _builder.append("/* no ports/saps/services - nothing to initialize statically */");
            _builder.newLine();
          } else {
            StringConcatenation _genActorInstanceInitializer = this.genActorInstanceInitializer(root, ai_2);
            _builder.append(_genActorInstanceInitializer, "");
            _builder.newLineIfNotEmpty();
          }
        }
      }
    }
    _builder.newLine();
    return _builder;
  }
  
  private String genReplPortAttributeInitializer(final InterfaceItemInstance pi) {
      int i = 0;
      String retval = "";
      EList<InterfaceItemInstance> _peers = pi.getPeers();
      int _size = _peers.size();
      i = _size;
      boolean _operator_greaterThan = ComparableExtensions.<Integer>operator_greaterThan(((Integer)i), ((Integer)0));
      Boolean _xwhileexpression = _operator_greaterThan;
      while (_xwhileexpression) {
        {
          String _operator_plus = StringExtensions.operator_plus(retval, "\r\n\t\t\t{");
          StringConcatenation _genPortAttributeInitializer = this.genPortAttributeInitializer(pi);
          String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, _genPortAttributeInitializer);
          String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, "}");
          retval = _operator_plus_2;
          int _operator_minus = IntegerExtensions.operator_minus(((Integer)i), ((Integer)1));
          i = _operator_minus;
          boolean _operator_greaterThan_1 = ComparableExtensions.<Integer>operator_greaterThan(((Integer)i), ((Integer)0));
          if (_operator_greaterThan_1) {
            String _operator_plus_3 = StringExtensions.operator_plus(retval, ",");
            retval = _operator_plus_3;
          }
        }
        boolean _operator_greaterThan_2 = ComparableExtensions.<Integer>operator_greaterThan(((Integer)i), ((Integer)0));
        _xwhileexpression = _operator_greaterThan_2;
      }
      return retval;
  }
  
  private StringConcatenation genPortAttributeInitializer(final InterfaceItemInstance pi) {
    StringConcatenation _builder = new StringConcatenation();
    {
      InterfaceItem _interfaceItem = pi.getInterfaceItem();
      ProtocolClass _protocol = _interfaceItem.getProtocol();
      boolean _isConjugated = this.roomExt.isConjugated(pi);
      PortClass _portClass = this.roomExt.getPortClass(_protocol, _isConjugated);
      EList<Attribute> _attributes = _portClass.getAttributes();
      boolean hasAnyElements = false;
      for(final Attribute attr : _attributes) {
        if (!hasAnyElements) {
          hasAnyElements = true;
        } else {
          _builder.appendImmediate(",", "");
        }
        {
          String _defaultValueLiteral = attr.getDefaultValueLiteral();
          boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_defaultValueLiteral, null);
          if (_operator_notEquals) {
            String _defaultValueLiteral_1 = attr.getDefaultValueLiteral();
            _builder.append(_defaultValueLiteral_1, "");
          } else {
            RefableType _refType = attr.getRefType();
            DataType _type = _refType.getType();
            String _defaultValue = this._typeHelpers.defaultValue(_type);
            _builder.append(_defaultValue, "");
          }
        }
      }
    }
    return _builder;
  }
  
  private StringConcatenation genActorInstanceInitializer(final Root root, final ActorInstance ai) {
    StringConcatenation _xblockexpression = null;
    {
      String _path = ai.getPath();
      String _pathName = this.roomExt.getPathName(_path);
      String instName = _pathName;
      ArrayList<InterfaceItemInstance> _arrayList = new ArrayList<InterfaceItemInstance>();
      ArrayList<InterfaceItemInstance> replPorts = _arrayList;
      EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
      final Function1<InterfaceItemInstance,Boolean> _function = new Function1<InterfaceItemInstance,Boolean>() {
          public Boolean apply(final InterfaceItemInstance e) {
            boolean _isReplicated = e.isReplicated();
            return ((Boolean)_isReplicated);
          }
        };
      Iterable<InterfaceItemInstance> _filter = IterableExtensions.<InterfaceItemInstance>filter(_orderedIfItemInstances, _function);
      CollectionExtensions.<InterfaceItemInstance>addAll(replPorts, _filter);
      final Function1<InterfaceItemInstance,Boolean> _function_1 = new Function1<InterfaceItemInstance,Boolean>() {
          public Boolean apply(final InterfaceItemInstance e) {
            EList<InterfaceItemInstance> _peers = e.getPeers();
            boolean _isEmpty = _peers.isEmpty();
            boolean _operator_not = BooleanExtensions.operator_not(_isEmpty);
            return ((Boolean)_operator_not);
          }
        };
      InterfaceItemInstance _findFirst = IterableExtensions.<InterfaceItemInstance>findFirst(replPorts, _function_1);
      boolean _operator_notEquals = ObjectExtensions.operator_notEquals(_findFirst, null);
      boolean haveReplSubPorts = _operator_notEquals;
      EList<InterfaceItemInstance> _orderedIfItemInstances_1 = ai.getOrderedIfItemInstances();
      final Function1<InterfaceItemInstance,Boolean> _function_2 = new Function1<InterfaceItemInstance,Boolean>() {
          public Boolean apply(final InterfaceItemInstance e) {
            boolean _isSimple = e.isSimple();
            return ((Boolean)_isSimple);
          }
        };
      Iterable<InterfaceItemInstance> _filter_1 = IterableExtensions.<InterfaceItemInstance>filter(_orderedIfItemInstances_1, _function_2);
      Iterable<InterfaceItemInstance> simplePorts = _filter_1;
      ArrayList<InterfaceItemInstance> _arrayList_1 = new ArrayList<InterfaceItemInstance>();
      ArrayList<InterfaceItemInstance> eventPorts = _arrayList_1;
      final Function1<InterfaceItemInstance,Boolean> _function_3 = new Function1<InterfaceItemInstance,Boolean>() {
          public Boolean apply(final InterfaceItemInstance p) {
            InterfaceItem _interfaceItem = p.getInterfaceItem();
            ProtocolClass _protocol = _interfaceItem.getProtocol();
            CommunicationType _commType = _protocol.getCommType();
            boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
            return ((Boolean)_operator_equals);
          }
        };
      Iterable<InterfaceItemInstance> _filter_2 = IterableExtensions.<InterfaceItemInstance>filter(simplePorts, _function_3);
      Iterable<InterfaceItemInstance> _union = this.roomExt.<InterfaceItemInstance>union(_filter_2, replPorts);
      CollectionExtensions.<InterfaceItemInstance>addAll(eventPorts, _union);
      final Function1<InterfaceItemInstance,Boolean> _function_4 = new Function1<InterfaceItemInstance,Boolean>() {
          public Boolean apply(final InterfaceItemInstance p) {
            InterfaceItem _interfaceItem = p.getInterfaceItem();
            ProtocolClass _protocol = _interfaceItem.getProtocol();
            CommunicationType _commType = _protocol.getCommType();
            boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.DATA_DRIVEN);
            return ((Boolean)_operator_equals);
          }
        };
      Iterable<InterfaceItemInstance> _filter_3 = IterableExtensions.<InterfaceItemInstance>filter(simplePorts, _function_4);
      Iterable<InterfaceItemInstance> dataPorts = _filter_3;
      final Function1<InterfaceItemInstance,Boolean> _function_5 = new Function1<InterfaceItemInstance,Boolean>() {
          public Boolean apply(final InterfaceItemInstance p) {
            boolean _operator_and = false;
            if (!(p instanceof PortInstance)) {
              _operator_and = false;
            } else {
              Port _port = ((PortInstance) p).getPort();
              boolean _isConjugated = _port.isConjugated();
              boolean _operator_not = BooleanExtensions.operator_not(_isConjugated);
              _operator_and = BooleanExtensions.operator_and((p instanceof PortInstance), _operator_not);
            }
            return ((Boolean)_operator_and);
          }
        };
      Iterable<InterfaceItemInstance> _filter_4 = IterableExtensions.<InterfaceItemInstance>filter(dataPorts, _function_5);
      Iterable<InterfaceItemInstance> recvPorts = _filter_4;
      final Function1<InterfaceItemInstance,Boolean> _function_6 = new Function1<InterfaceItemInstance,Boolean>() {
          public Boolean apply(final InterfaceItemInstance p) {
            boolean _operator_and = false;
            if (!(p instanceof PortInstance)) {
              _operator_and = false;
            } else {
              Port _port = ((PortInstance) p).getPort();
              boolean _isConjugated = _port.isConjugated();
              _operator_and = BooleanExtensions.operator_and((p instanceof PortInstance), _isConjugated);
            }
            return ((Boolean)_operator_and);
          }
        };
      Iterable<InterfaceItemInstance> _filter_5 = IterableExtensions.<InterfaceItemInstance>filter(dataPorts, _function_6);
      Iterable<InterfaceItemInstance> sendPorts = _filter_5;
      HashMap<InterfaceItemInstance,Integer> _hashMap = new HashMap<InterfaceItemInstance,Integer>();
      HashMap<InterfaceItemInstance,Integer> offsets = _hashMap;
      int offset = 0;
      for (final InterfaceItemInstance p : replPorts) {
        {
          offsets.put(p, ((Integer)offset));
          EList<InterfaceItemInstance> _peers = p.getPeers();
          int _size = _peers.size();
          int _operator_plus = IntegerExtensions.operator_plus(((Integer)offset), ((Integer)_size));
          offset = _operator_plus;
        }
      }
      String _xifexpression = null;
      if (haveReplSubPorts) {
        String _operator_plus_1 = StringExtensions.operator_plus(instName, "_repl_sub_ports");
        _xifexpression = _operator_plus_1;
      } else {
        _xifexpression = "NULL";
      }
      String replSubPortsArray = _xifexpression;
      StringConcatenation _builder = new StringConcatenation();
      {
        if (haveReplSubPorts) {
          _builder.append("static const etReplSubPort ");
          _builder.append(replSubPortsArray, "");
          _builder.append("[");
          _builder.append(offset, "");
          _builder.append("] = {");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          _builder.append("/* Replicated Sub Ports: {varData, msgService, peerAddress, localId, index} */");
          _builder.newLine();
          {
            boolean hasAnyElements = false;
            for(final InterfaceItemInstance pi : replPorts) {
              if (!hasAnyElements) {
                hasAnyElements = true;
              } else {
                _builder.appendImmediate(",", "	");
              }
              _builder.append("\t");
              String _genReplSubPortInitializers = this.genReplSubPortInitializers(root, ai, pi);
              _builder.append(_genReplSubPortInitializers, "	");
              _builder.newLineIfNotEmpty();
            }
          }
          _builder.append("};");
          _builder.newLine();
        }
      }
      {
        boolean _operator_and = false;
        boolean _isEmpty = eventPorts.isEmpty();
        if (!_isEmpty) {
          _operator_and = false;
        } else {
          boolean _isEmpty_1 = IterableExtensions.isEmpty(recvPorts);
          _operator_and = BooleanExtensions.operator_and(_isEmpty, _isEmpty_1);
        }
        boolean _operator_not = BooleanExtensions.operator_not(_operator_and);
        if (_operator_not) {
          _builder.append("static const ");
          ActorClass _actorClass = ai.getActorClass();
          String _name = _actorClass.getName();
          _builder.append(_name, "");
          _builder.append("_const ");
          _builder.append(instName, "");
          _builder.append("_const = {");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          _builder.append("/* Ports: {varData, msgService, peerAddress, localId} */");
          _builder.newLine();
          {
            boolean hasAnyElements_1 = false;
            for(final InterfaceItemInstance pi_1 : eventPorts) {
              if (!hasAnyElements_1) {
                hasAnyElements_1 = true;
              } else {
                _builder.appendImmediate(",", "	");
              }
              {
                boolean _isSimple = pi_1.isSimple();
                if (_isSimple) {
                  _builder.append("\t");
                  String _genPortInitializer = this.genPortInitializer(root, ai, pi_1);
                  _builder.append(_genPortInitializer, "	");
                  _builder.newLineIfNotEmpty();
                } else {
                  _builder.append("\t");
                  _builder.append("{");
                  EList<InterfaceItemInstance> _peers_1 = pi_1.getPeers();
                  int _size_1 = _peers_1.size();
                  _builder.append(_size_1, "	");
                  _builder.append(", ");
                  _builder.append(replSubPortsArray, "	");
                  _builder.append("+");
                  Integer _get = offsets.get(pi_1);
                  _builder.append(_get, "	");
                  _builder.append("}");
                  _builder.newLineIfNotEmpty();
                }
              }
            }
          }
          _builder.append("\t");
          {
            boolean _operator_and_1 = false;
            boolean _isEmpty_2 = eventPorts.isEmpty();
            boolean _operator_not_1 = BooleanExtensions.operator_not(_isEmpty_2);
            if (!_operator_not_1) {
              _operator_and_1 = false;
            } else {
              boolean _isEmpty_3 = IterableExtensions.isEmpty(recvPorts);
              boolean _operator_not_2 = BooleanExtensions.operator_not(_isEmpty_3);
              _operator_and_1 = BooleanExtensions.operator_and(_operator_not_1, _operator_not_2);
            }
            if (_operator_and_1) {
              _builder.append(",");
            }
          }
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("/* data receive ports */");
          _builder.newLine();
          {
            boolean hasAnyElements_2 = false;
            for(final InterfaceItemInstance pi_2 : recvPorts) {
              if (!hasAnyElements_2) {
                hasAnyElements_2 = true;
              } else {
                _builder.appendImmediate(",", "	");
              }
              _builder.append("\t");
              String _genRecvPortInitializer = this.genRecvPortInitializer(root, ai, pi_2);
              _builder.append(_genRecvPortInitializer, "	");
              _builder.newLineIfNotEmpty();
            }
          }
          _builder.append("};");
          _builder.newLine();
          _builder.append("static ");
          ActorClass _actorClass_1 = ai.getActorClass();
          String _name_1 = _actorClass_1.getName();
          _builder.append(_name_1, "");
          _builder.append(" ");
          _builder.append(instName, "");
          _builder.append(" = {&");
          _builder.append(instName, "");
          _builder.append("_const};");
          _builder.newLineIfNotEmpty();
        }
      }
      _xblockexpression = (_builder);
    }
    return _xblockexpression;
  }
  
  private String genPortInitializer(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) {
    String _xblockexpression = null;
    {
      String _xifexpression = null;
      EList<InterfaceItemInstance> _peers = pi.getPeers();
      boolean _isEmpty = _peers.isEmpty();
      if (_isEmpty) {
        _xifexpression = "NULL";
      } else {
        ActorClass _actorClass = ai.getActorClass();
        String _name = _actorClass.getName();
        String _operator_plus = StringExtensions.operator_plus(_name, "_receiveMessage");
        _xifexpression = _operator_plus;
      }
      String recvMsg = _xifexpression;
      int _xifexpression_1 = (int) 0;
      EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
      boolean _isEmpty_1 = _peers_1.isEmpty();
      if (_isEmpty_1) {
        _xifexpression_1 = 0;
      } else {
        EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
        InterfaceItemInstance _get = _peers_2.get(0);
        int _objId = _get.getObjId();
        _xifexpression_1 = _objId;
      }
      int objId = _xifexpression_1;
      int _xifexpression_2 = (int) 0;
      EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
      boolean _isEmpty_2 = _peers_3.isEmpty();
      if (_isEmpty_2) {
        _xifexpression_2 = 0;
      } else {
        EList<InterfaceItemInstance> _peers_4 = pi.getPeers();
        InterfaceItemInstance _get_1 = _peers_4.get(0);
        EList<InterfaceItemInstance> _peers_5 = _get_1.getPeers();
        int _indexOf = _peers_5.indexOf(pi);
        _xifexpression_2 = _indexOf;
      }
      int idx = _xifexpression_2;
      String _interfaceItemInstanceData = this.getInterfaceItemInstanceData(pi);
      String _operator_plus_1 = StringExtensions.operator_plus("{", _interfaceItemInstanceData);
      String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ",");
      String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "&msgService_Thread1, ");
      int _operator_plus_4 = IntegerExtensions.operator_plus(((Integer)objId), ((Integer)idx));
      String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_3, ((Integer)_operator_plus_4));
      String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, ", ");
      ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
      InterfaceItem _interfaceItem = pi.getInterfaceItem();
      int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_interfaceItem);
      int _operator_plus_7 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
      String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_6, ((Integer)_operator_plus_7));
      String _operator_plus_9 = StringExtensions.operator_plus(_operator_plus_8, "} /* Port ");
      String _name_1 = pi.getName();
      String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_9, _name_1);
      String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, " */");
      _xblockexpression = (_operator_plus_11);
    }
    return _xblockexpression;
  }
  
  private String getInterfaceItemInstanceData(final InterfaceItemInstance pi) {
      InterfaceItem _interfaceItem = pi.getInterfaceItem();
      ProtocolClass _protocol = _interfaceItem.getProtocol();
      boolean _isConjugated = this.roomExt.isConjugated(pi);
      PortClass _portClass = this.roomExt.getPortClass(_protocol, _isConjugated);
      boolean _operator_equals = ObjectExtensions.operator_equals(_portClass, null);
      if (_operator_equals) {
        return "0";
      }
      InterfaceItem _interfaceItem_1 = pi.getInterfaceItem();
      ProtocolClass _protocol_1 = _interfaceItem_1.getProtocol();
      boolean _isConjugated_1 = this.roomExt.isConjugated(pi);
      PortClass _portClass_1 = this.roomExt.getPortClass(_protocol_1, _isConjugated_1);
      EList<Attribute> _attributes = _portClass_1.getAttributes();
      boolean _isEmpty = _attributes.isEmpty();
      if (_isEmpty) {
        return "0";
      } else {
        String _path = pi.getPath();
        String _pathName = this.roomExt.getPathName(_path);
        String _operator_plus = StringExtensions.operator_plus("&", _pathName);
        String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, "_var");
        return _operator_plus_1;
      }
  }
  
  private String genRecvPortInitializer(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) {
    String _xblockexpression = null;
    {
      EList<InterfaceItemInstance> _peers = pi.getPeers();
      boolean _isEmpty = _peers.isEmpty();
      if (_isEmpty) {
        return "{NULL}";
      }
      EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
      InterfaceItemInstance _get = _peers_1.get(0);
      InterfaceItemInstance peer = _get;
      EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
      InterfaceItemInstance _get_1 = _peers_2.get(0);
      EObject _eContainer = _get_1.eContainer();
      ActorInstance peerInst = ((ActorInstance) _eContainer);
      String _path = peerInst.getPath();
      String _pathName = this.roomExt.getPathName(_path);
      String instName = _pathName;
      String _operator_plus = StringExtensions.operator_plus("{&", instName);
      String _operator_plus_1 = StringExtensions.operator_plus(_operator_plus, ".");
      String _name = peer.getName();
      String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, _name);
      String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "}");
      _xblockexpression = (_operator_plus_3);
    }
    return _xblockexpression;
  }
  
  private String genReplSubPortInitializers(final Root root, final ActorInstance ai, final InterfaceItemInstance pi) {
      String result = "";
      EList<InterfaceItemInstance> _peers = pi.getPeers();
      for (final InterfaceItemInstance p : _peers) {
        {
          EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
          int _indexOf = _peers_1.indexOf(p);
          int idx = _indexOf;
          String _xifexpression = null;
          EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
          int _size = _peers_2.size();
          int _operator_minus = IntegerExtensions.operator_minus(((Integer)_size), ((Integer)1));
          boolean _operator_lessThan = ComparableExtensions.<Integer>operator_lessThan(((Integer)idx), ((Integer)_operator_minus));
          if (_operator_lessThan) {
            _xifexpression = ",";
          } else {
            _xifexpression = "";
          }
          String comma = _xifexpression;
          String _interfaceItemInstanceData = this.getInterfaceItemInstanceData(pi);
          String iiiD = _interfaceItemInstanceData;
          String _xifexpression_1 = null;
          boolean _equals = iiiD.equals("0");
          if (_equals) {
            String _operator_plus = StringExtensions.operator_plus(iiiD, ",");
            _xifexpression_1 = _operator_plus;
          } else {
            String _operator_plus_1 = StringExtensions.operator_plus(iiiD, "[");
            String _operator_plus_2 = StringExtensions.operator_plus(_operator_plus_1, ((Integer)idx));
            String _operator_plus_3 = StringExtensions.operator_plus(_operator_plus_2, "],");
            _xifexpression_1 = _operator_plus_3;
          }
          iiiD = _xifexpression_1;
          String _operator_plus_4 = StringExtensions.operator_plus(result, "{");
          String _operator_plus_5 = StringExtensions.operator_plus(_operator_plus_4, iiiD);
          String _operator_plus_6 = StringExtensions.operator_plus(_operator_plus_5, "&msgService_Thread1, ");
          int _objId = p.getObjId();
          String _operator_plus_7 = StringExtensions.operator_plus(_operator_plus_6, ((Integer)_objId));
          String _operator_plus_8 = StringExtensions.operator_plus(_operator_plus_7, ", ");
          ExpandedActorClass _expandedActorClass = root.getExpandedActorClass(ai);
          InterfaceItem _interfaceItem = pi.getInterfaceItem();
          int _interfaceItemLocalId = _expandedActorClass.getInterfaceItemLocalId(_interfaceItem);
          int _operator_plus_9 = IntegerExtensions.operator_plus(((Integer)_interfaceItemLocalId), ((Integer)1));
          String _operator_plus_10 = StringExtensions.operator_plus(_operator_plus_8, ((Integer)_operator_plus_9));
          String _operator_plus_11 = StringExtensions.operator_plus(_operator_plus_10, ", ");
          String _operator_plus_12 = StringExtensions.operator_plus(_operator_plus_11, ((Integer)idx));
          String _operator_plus_13 = StringExtensions.operator_plus(_operator_plus_12, "}");
          String _operator_plus_14 = StringExtensions.operator_plus(_operator_plus_13, comma);
          String _operator_plus_15 = StringExtensions.operator_plus(_operator_plus_14, " /* Repl Sub Port ");
          String _name = pi.getName();
          String _operator_plus_16 = StringExtensions.operator_plus(_operator_plus_15, _name);
          String _operator_plus_17 = StringExtensions.operator_plus(_operator_plus_16, " idx +");
          String _operator_plus_18 = StringExtensions.operator_plus(_operator_plus_17, ((Integer)idx));
          String _operator_plus_19 = StringExtensions.operator_plus(_operator_plus_18, "*/\n");
          result = _operator_plus_19;
        }
      }
      return result;
  }
  
  private StringConcatenation generateDispatcherFile(final Root root, final SubSystemInstance ssi, final SubSystemClass ssc) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("/**");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* @author generated by eTrice");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("*");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("* Dispatcher File of SubSystemClass ");
    String _name = ssc.getName();
    _builder.append(_name, " ");
    _builder.newLineIfNotEmpty();
    _builder.append(" ");
    _builder.append("* - one generated dispatcher for each MessageService (Thread)");
    _builder.newLine();
    _builder.append(" ");
    _builder.append("*/");
    _builder.newLine();
    _builder.newLine();
    _builder.append("#include \"messaging/etMessageReceiver.h\"");
    _builder.newLine();
    _builder.append("#include \"debugging/etLogger.h\"");
    _builder.newLine();
    _builder.append("#include \"debugging/etMSCLogger.h\"");
    _builder.newLine();
    _builder.newLine();
    _builder.append("static void MsgDispatcher_Thread1_receiveMessage(const etMessage* msg){");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"MsgDispatcher_Thread1\", \"receiveMessage\")");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("switch(msg->address){");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    {
      EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
      for(final ActorInstance ai : _allContainedInstances) {
        _builder.append("\t\t");
        _builder.append("/* interface items of ");
        String _path = ai.getPath();
        _builder.append(_path, "		");
        _builder.append(" */");
        _builder.newLineIfNotEmpty();
        {
          EList<InterfaceItemInstance> _orderedIfItemInstances = ai.getOrderedIfItemInstances();
          final Function1<InterfaceItemInstance,Boolean> _function = new Function1<InterfaceItemInstance,Boolean>() {
              public Boolean apply(final InterfaceItemInstance p) {
                InterfaceItem _interfaceItem = p.getInterfaceItem();
                ProtocolClass _protocol = _interfaceItem.getProtocol();
                CommunicationType _commType = _protocol.getCommType();
                boolean _operator_equals = ObjectExtensions.operator_equals(_commType, CommunicationType.EVENT_DRIVEN);
                return ((Boolean)_operator_equals);
              }
            };
          Iterable<InterfaceItemInstance> _filter = IterableExtensions.<InterfaceItemInstance>filter(_orderedIfItemInstances, _function);
          for(final InterfaceItemInstance pi : _filter) {
            {
              boolean _isReplicated = pi.isReplicated();
              if (_isReplicated) {
                {
                  EList<InterfaceItemInstance> _peers = pi.getPeers();
                  for(final InterfaceItemInstance peer : _peers) {
                    _builder.append("\t\t");
                    _builder.append("case ");
                    int _objId = pi.getObjId();
                    EList<InterfaceItemInstance> _peers_1 = pi.getPeers();
                    int _indexOf = _peers_1.indexOf(peer);
                    int _operator_plus = IntegerExtensions.operator_plus(((Integer)_objId), ((Integer)_indexOf));
                    _builder.append(_operator_plus, "		");
                    _builder.append(":");
                    _builder.newLineIfNotEmpty();
                    {
                      InterfaceItem _interfaceItem = pi.getInterfaceItem();
                      ProtocolClass _protocol = _interfaceItem.getProtocol();
                      boolean _isConjugated = this.roomExt.isConjugated(pi);
                      boolean _handlesReceive = this.roomExt.handlesReceive(_protocol, _isConjugated);
                      if (_handlesReceive) {
                        _builder.append("\t\t");
                        _builder.append("switch (msg->evtID){");
                        _builder.newLine();
                        {
                          InterfaceItem _interfaceItem_1 = pi.getInterfaceItem();
                          ProtocolClass _protocol_1 = _interfaceItem_1.getProtocol();
                          boolean _isConjugated_1 = this.roomExt.isConjugated(pi);
                          List<MessageHandler> _receiveHandlers = this.roomExt.getReceiveHandlers(_protocol_1, _isConjugated_1);
                          for(final MessageHandler h : _receiveHandlers) {
                            _builder.append("\t\t");
                            _builder.append("\t");
                            _builder.append("case ");
                            InterfaceItem _interfaceItem_2 = pi.getInterfaceItem();
                            ProtocolClass _protocol_2 = _interfaceItem_2.getProtocol();
                            String _name_1 = _protocol_2.getName();
                            _builder.append(_name_1, "			");
                            _builder.append("_");
                            Message _msg = h.getMsg();
                            String _codeName = this.roomExt.getCodeName(_msg);
                            _builder.append(_codeName, "			");
                            _builder.append(":");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t\t");
                            _builder.append("\t");
                            _builder.append("\t");
                            InterfaceItem _interfaceItem_3 = pi.getInterfaceItem();
                            ProtocolClass _protocol_3 = _interfaceItem_3.getProtocol();
                            boolean _isConjugated_2 = this.roomExt.isConjugated(pi);
                            String _portClassName = this.roomExt.getPortClassName(_protocol_3, _isConjugated_2);
                            _builder.append(_portClassName, "				");
                            _builder.append("_");
                            Message _msg_1 = h.getMsg();
                            String _name_2 = _msg_1.getName();
                            _builder.append(_name_2, "				");
                            _builder.append("_receiveHandler((etPort *)&");
                            String _path_1 = ai.getPath();
                            String _pathName = this.roomExt.getPathName(_path_1);
                            _builder.append(_pathName, "				");
                            _builder.append("_const.");
                            String _name_3 = pi.getName();
                            _builder.append(_name_3, "				");
                            _builder.append(".ports[");
                            EList<InterfaceItemInstance> _peers_2 = pi.getPeers();
                            int _indexOf_1 = _peers_2.indexOf(peer);
                            _builder.append(_indexOf_1, "				");
                            _builder.append("],msg,(void*)&");
                            String _path_2 = ai.getPath();
                            String _pathName_1 = this.roomExt.getPathName(_path_2);
                            _builder.append(_pathName_1, "				");
                            _builder.append(",");
                            ActorClass _actorClass = ai.getActorClass();
                            String _name_4 = _actorClass.getName();
                            _builder.append(_name_4, "				");
                            _builder.append("_receiveMessage);");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t\t");
                            _builder.append("\t");
                            _builder.append("break;");
                            _builder.newLine();
                          }
                        }
                        _builder.append("\t\t");
                        _builder.append("\t");
                        _builder.append("default: ");
                        ActorClass _actorClass_1 = ai.getActorClass();
                        String _name_5 = _actorClass_1.getName();
                        _builder.append(_name_5, "			");
                        _builder.append("_receiveMessage((void*)&");
                        String _path_3 = ai.getPath();
                        String _pathName_2 = this.roomExt.getPathName(_path_3);
                        _builder.append(_pathName_2, "			");
                        _builder.append(",(etPort*)&");
                        String _path_4 = ai.getPath();
                        String _pathName_3 = this.roomExt.getPathName(_path_4);
                        _builder.append(_pathName_3, "			");
                        _builder.append("_const.");
                        String _name_6 = pi.getName();
                        _builder.append(_name_6, "			");
                        _builder.append(".ports[");
                        EList<InterfaceItemInstance> _peers_3 = pi.getPeers();
                        int _indexOf_2 = _peers_3.indexOf(peer);
                        _builder.append(_indexOf_2, "			");
                        _builder.append("], msg);");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t\t");
                        _builder.append("\t");
                        _builder.append("break;");
                        _builder.newLine();
                        _builder.append("\t\t");
                        _builder.append("\t");
                        _builder.append("}\t\t\t\t\t\t\t\t\t\t");
                        _builder.newLine();
                      } else {
                        _builder.append("\t\t");
                        ActorClass _actorClass_2 = ai.getActorClass();
                        String _name_7 = _actorClass_2.getName();
                        _builder.append(_name_7, "		");
                        _builder.append("_receiveMessage((void*)&");
                        String _path_5 = ai.getPath();
                        String _pathName_4 = this.roomExt.getPathName(_path_5);
                        _builder.append(_pathName_4, "		");
                        _builder.append(",(etPort*)&");
                        String _path_6 = ai.getPath();
                        String _pathName_5 = this.roomExt.getPathName(_path_6);
                        _builder.append(_pathName_5, "		");
                        _builder.append("_const.");
                        String _name_8 = pi.getName();
                        _builder.append(_name_8, "		");
                        _builder.append(".ports[");
                        EList<InterfaceItemInstance> _peers_4 = pi.getPeers();
                        int _indexOf_3 = _peers_4.indexOf(peer);
                        _builder.append(_indexOf_3, "		");
                        _builder.append("], msg);");
                        _builder.newLineIfNotEmpty();
                      }
                    }
                    _builder.append("\t\t");
                    _builder.append("break;");
                    _builder.newLine();
                  }
                }
              } else {
                _builder.append("\t\t");
                _builder.append("case ");
                int _objId_1 = pi.getObjId();
                _builder.append(_objId_1, "		");
                _builder.append(":");
                _builder.newLineIfNotEmpty();
                {
                  InterfaceItem _interfaceItem_4 = pi.getInterfaceItem();
                  ProtocolClass _protocol_4 = _interfaceItem_4.getProtocol();
                  boolean _isConjugated_3 = this.roomExt.isConjugated(pi);
                  boolean _handlesReceive_1 = this.roomExt.handlesReceive(_protocol_4, _isConjugated_3);
                  if (_handlesReceive_1) {
                    _builder.append("\t\t");
                    _builder.append("switch (msg->evtID){");
                    _builder.newLine();
                    {
                      InterfaceItem _interfaceItem_5 = pi.getInterfaceItem();
                      ProtocolClass _protocol_5 = _interfaceItem_5.getProtocol();
                      boolean _isConjugated_4 = this.roomExt.isConjugated(pi);
                      List<MessageHandler> _receiveHandlers_1 = this.roomExt.getReceiveHandlers(_protocol_5, _isConjugated_4);
                      for(final MessageHandler h_1 : _receiveHandlers_1) {
                        _builder.append("\t\t");
                        _builder.append("case ");
                        InterfaceItem _interfaceItem_6 = pi.getInterfaceItem();
                        ProtocolClass _protocol_6 = _interfaceItem_6.getProtocol();
                        String _name_9 = _protocol_6.getName();
                        _builder.append(_name_9, "		");
                        _builder.append("_");
                        Message _msg_2 = h_1.getMsg();
                        String _codeName_1 = this.roomExt.getCodeName(_msg_2);
                        _builder.append(_codeName_1, "		");
                        _builder.append(":");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t\t");
                        _builder.append("\t");
                        InterfaceItem _interfaceItem_7 = pi.getInterfaceItem();
                        ProtocolClass _protocol_7 = _interfaceItem_7.getProtocol();
                        boolean _isConjugated_5 = this.roomExt.isConjugated(pi);
                        String _portClassName_1 = this.roomExt.getPortClassName(_protocol_7, _isConjugated_5);
                        _builder.append(_portClassName_1, "			");
                        _builder.append("_");
                        Message _msg_3 = h_1.getMsg();
                        String _name_10 = _msg_3.getName();
                        _builder.append(_name_10, "			");
                        _builder.append("_receiveHandler((etPort *)&");
                        String _path_7 = ai.getPath();
                        String _pathName_6 = this.roomExt.getPathName(_path_7);
                        _builder.append(_pathName_6, "			");
                        _builder.append("_const.");
                        String _name_11 = pi.getName();
                        _builder.append(_name_11, "			");
                        _builder.append(",msg,(void*)&");
                        String _path_8 = ai.getPath();
                        String _pathName_7 = this.roomExt.getPathName(_path_8);
                        _builder.append(_pathName_7, "			");
                        _builder.append(",");
                        ActorClass _actorClass_3 = ai.getActorClass();
                        String _name_12 = _actorClass_3.getName();
                        _builder.append(_name_12, "			");
                        _builder.append("_receiveMessage);");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t\t");
                        _builder.append("break;");
                        _builder.newLine();
                      }
                    }
                    _builder.append("\t\t");
                    _builder.append("default: ");
                    ActorClass _actorClass_4 = ai.getActorClass();
                    String _name_13 = _actorClass_4.getName();
                    _builder.append(_name_13, "		");
                    _builder.append("_receiveMessage((void*)&");
                    String _path_9 = ai.getPath();
                    String _pathName_8 = this.roomExt.getPathName(_path_9);
                    _builder.append(_pathName_8, "		");
                    _builder.append(",(etPort*)&");
                    String _path_10 = ai.getPath();
                    String _pathName_9 = this.roomExt.getPathName(_path_10);
                    _builder.append(_pathName_9, "		");
                    _builder.append("_const.");
                    String _name_14 = pi.getName();
                    _builder.append(_name_14, "		");
                    _builder.append(", msg);");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t\t");
                    _builder.append("break;");
                    _builder.newLine();
                    _builder.append("\t\t");
                    _builder.append("}");
                    _builder.newLine();
                  } else {
                    _builder.append("\t\t");
                    ActorClass _actorClass_5 = ai.getActorClass();
                    String _name_15 = _actorClass_5.getName();
                    _builder.append(_name_15, "		");
                    _builder.append("_receiveMessage((void*)&");
                    String _path_11 = ai.getPath();
                    String _pathName_10 = this.roomExt.getPathName(_path_11);
                    _builder.append(_pathName_10, "		");
                    _builder.append(",(etPort*)&");
                    String _path_12 = ai.getPath();
                    String _pathName_11 = this.roomExt.getPathName(_path_12);
                    _builder.append(_pathName_11, "		");
                    _builder.append("_const.");
                    String _name_16 = pi.getName();
                    _builder.append(_name_16, "		");
                    _builder.append(", msg);");
                    _builder.newLineIfNotEmpty();
                  }
                }
                _builder.append("\t\t");
                _builder.append("break;");
                _builder.newLine();
              }
            }
          }
        }
      }
    }
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("default:");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("etLogger_logErrorF(\"MessageService_Thread1_receiveMessage: address %d does not exist \", msg->address);");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("break;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("ET_MSC_LOGGER_SYNC_EXIT");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
  }
  
  private StringConcatenation generateDatadrivenExecutes(final Root root, final SubSystemInstance ssi) {
    StringConcatenation _builder = new StringConcatenation();
    {
      EList<ActorInstance> _allContainedInstances = ssi.getAllContainedInstances();
      for(final ActorInstance ai : _allContainedInstances) {
        {
          boolean _operator_or = false;
          ActorClass _actorClass = ai.getActorClass();
          ActorCommunicationType _commType = _actorClass.getCommType();
          boolean _operator_equals = ObjectExtensions.operator_equals(_commType, ActorCommunicationType.ASYNCHRONOUS);
          if (_operator_equals) {
            _operator_or = true;
          } else {
            ActorClass _actorClass_1 = ai.getActorClass();
            ActorCommunicationType _commType_1 = _actorClass_1.getCommType();
            boolean _operator_equals_1 = ObjectExtensions.operator_equals(_commType_1, ActorCommunicationType.DATA_DRIVEN);
            _operator_or = BooleanExtensions.operator_or(_operator_equals, _operator_equals_1);
          }
          if (_operator_or) {
            ActorClass _actorClass_2 = ai.getActorClass();
            String _name = _actorClass_2.getName();
            _builder.append(_name, "");
            _builder.append("_execute(&");
            String _path = ai.getPath();
            String _pathName = this.roomExt.getPathName(_path);
            _builder.append(_pathName, "");
            _builder.append(");");
            _builder.newLineIfNotEmpty();
          }
        }
      }
    }
    return _builder;
  }
}

Back to the top