Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8d9e857dcc2b45802ff681244f527856cad04197 (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
/**
 * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * CONTRIBUTORS:
 * 		Henrik Rentz-Reichert (initial contribution)
 * 		Thomas Schuetz (changed for C code generator)
 */
package org.eclipse.etrice.generator.c.gen;

import com.google.common.base.Objects;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.etrice.core.fsm.fSM.ComponentCommunicationType;
import org.eclipse.etrice.core.fsm.fSM.DetailCode;
import org.eclipse.etrice.core.fsm.fSM.StateGraph;
import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.core.genmodel.fsm.base.ILogger;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.ClassStructor;
import org.eclipse.etrice.core.room.CommunicationType;
import org.eclipse.etrice.core.room.DataClass;
import org.eclipse.etrice.core.room.EnumerationType;
import org.eclipse.etrice.core.room.GeneralProtocolClass;
import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.core.room.Operation;
import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.PortClass;
import org.eclipse.etrice.core.room.PortOperation;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.SAP;
import org.eclipse.etrice.core.room.SPP;
import org.eclipse.etrice.core.room.ServiceImplementation;
import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.VarDecl;
import org.eclipse.etrice.generator.base.GlobalGeneratorSettings;
import org.eclipse.etrice.generator.c.Main;
import org.eclipse.etrice.generator.c.gen.CExtensions;
import org.eclipse.etrice.generator.c.gen.StateMachineGen;
import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo;
import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
import org.eclipse.etrice.generator.generic.ILanguageExtension;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;

@Singleton
@SuppressWarnings("all")
public class ActorClassGen extends GenericActorClassGenerator {
  @Inject
  @Extension
  protected RoomExtensions _roomExtensions;
  
  @Inject
  @Extension
  private CExtensions _cExtensions;
  
  @Inject
  @Extension
  private ProcedureHelpers _procedureHelpers;
  
  @Inject
  @Extension
  private StateMachineGen _stateMachineGen;
  
  @Inject
  protected ILanguageExtension langExt;
  
  @Inject
  private IGeneratorFileIo fileIO;
  
  @Inject
  private ILogger logger;
  
  public void doGenerate(final Root root) {
    EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
    for (final ExpandedActorClass xpac : _xpActorClasses) {
      {
        ActorClass _actorClass = xpac.getActorClass();
        String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(_actorClass);
        ActorClass _actorClass_1 = xpac.getActorClass();
        String _path = this._roomExtensions.getPath(_actorClass_1);
        final String path = (_generationTargetPath + _path);
        ActorClass _actorClass_2 = xpac.getActorClass();
        String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(_actorClass_2);
        ActorClass _actorClass_3 = xpac.getActorClass();
        String _path_1 = this._roomExtensions.getPath(_actorClass_3);
        final String infopath = (_generationInfoPath + _path_1);
        ActorClass _actorClass_4 = xpac.getActorClass();
        String file = this._cExtensions.getCHeaderFileName(_actorClass_4);
        CharSequence _generateHeaderFile = this.generateHeaderFile(root, xpac);
        this.fileIO.generateFile("generating ActorClass header", path, infopath, file, _generateHeaderFile);
        ActorClass _actorClass_5 = xpac.getActorClass();
        String _cUtilsFileName = this._cExtensions.getCUtilsFileName(_actorClass_5);
        file = _cUtilsFileName;
        CharSequence _generateUtilsFile = this.generateUtilsFile(root, xpac);
        this.fileIO.generateFile("generating ActorClass utils", path, infopath, file, _generateUtilsFile);
        ActorClass _actorClass_6 = xpac.getActorClass();
        boolean _isBehaviorAnnotationPresent = this._roomHelpers.isBehaviorAnnotationPresent(_actorClass_6, "BehaviorManual");
        if (_isBehaviorAnnotationPresent) {
          ActorClass _actorClass_7 = xpac.getActorClass();
          String _name = _actorClass_7.getName();
          String _plus = ("omitting ActorClass source for \'" + _name);
          String _plus_1 = (_plus + "\' since @BehaviorManual is specified");
          this.logger.logInfo(_plus_1);
        } else {
          ActorClass _actorClass_8 = xpac.getActorClass();
          String _cSourceFileName = this._cExtensions.getCSourceFileName(_actorClass_8);
          file = _cSourceFileName;
          CharSequence _generateSourceFile = this.generateSourceFile(root, xpac);
          this.fileIO.generateFile("generating ActorClass source", path, infopath, file, _generateSourceFile);
        }
      }
    }
  }
  
  private CharSequence generateHeaderFile(final Root root, final ExpandedActorClass xpac) {
    CharSequence _xblockexpression = null;
    {
      final ActorClass ac = xpac.getActorClass();
      List<Port> _allEndPorts = this._roomHelpers.getAllEndPorts(ac);
      final Function1<Port, Boolean> _function = new Function1<Port, Boolean>() {
        public Boolean apply(final Port p) {
          GeneralProtocolClass _protocol = p.getProtocol();
          CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
          return Boolean.valueOf(Objects.equal(_commType, CommunicationType.EVENT_DRIVEN));
        }
      };
      final Iterable<Port> eventPorts = IterableExtensions.<Port>filter(_allEndPorts, _function);
      List<Port> _allEndPorts_1 = this._roomHelpers.getAllEndPorts(ac);
      final Function1<Port, Boolean> _function_1 = new Function1<Port, Boolean>() {
        public Boolean apply(final Port p) {
          boolean _and = false;
          GeneralProtocolClass _protocol = p.getProtocol();
          CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
          boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN);
          if (!_equals) {
            _and = false;
          } else {
            boolean _isConjugated = p.isConjugated();
            _and = _isConjugated;
          }
          return Boolean.valueOf(_and);
        }
      };
      final Iterable<Port> sendPorts = IterableExtensions.<Port>filter(_allEndPorts_1, _function_1);
      List<Port> _allEndPorts_2 = this._roomHelpers.getAllEndPorts(ac);
      final Function1<Port, Boolean> _function_2 = new Function1<Port, Boolean>() {
        public Boolean apply(final Port p) {
          boolean _and = false;
          GeneralProtocolClass _protocol = p.getProtocol();
          CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
          boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN);
          if (!_equals) {
            _and = false;
          } else {
            boolean _isConjugated = p.isConjugated();
            boolean _not = (!_isConjugated);
            _and = _not;
          }
          return Boolean.valueOf(_and);
        }
      };
      final Iterable<Port> recvPorts = IterableExtensions.<Port>filter(_allEndPorts_2, _function_2);
      ComponentCommunicationType _commType = ac.getCommType();
      final boolean dataDriven = Objects.equal(_commType, ComponentCommunicationType.DATA_DRIVEN);
      ComponentCommunicationType _commType_1 = ac.getCommType();
      final boolean async = Objects.equal(_commType_1, ComponentCommunicationType.ASYNCHRONOUS);
      boolean _or = false;
      boolean _and = false;
      boolean _and_1 = false;
      boolean _and_2 = false;
      boolean _isEmpty = IterableExtensions.isEmpty(eventPorts);
      if (!_isEmpty) {
        _and_2 = false;
      } else {
        boolean _isEmpty_1 = IterableExtensions.isEmpty(recvPorts);
        _and_2 = _isEmpty_1;
      }
      if (!_and_2) {
        _and_1 = false;
      } else {
        List<SAP> _allSAPs = this._roomHelpers.getAllSAPs(ac);
        boolean _isEmpty_2 = _allSAPs.isEmpty();
        _and_1 = _isEmpty_2;
      }
      if (!_and_1) {
        _and = false;
      } else {
        List<ServiceImplementation> _allServiceImplementations = this._roomHelpers.getAllServiceImplementations(ac);
        boolean _isEmpty_3 = _allServiceImplementations.isEmpty();
        _and = _isEmpty_3;
      }
      boolean _not = (!_and);
      if (_not) {
        _or = true;
      } else {
        GlobalGeneratorSettings _settings = Main.getSettings();
        boolean _isGenerateMSCInstrumentation = _settings.isGenerateMSCInstrumentation();
        _or = _isGenerateMSCInstrumentation;
      }
      final boolean hasConstData = _or;
      boolean _and_3 = false;
      boolean _and_4 = false;
      boolean _and_5 = false;
      boolean _isEmpty_4 = IterableExtensions.isEmpty(sendPorts);
      if (!_isEmpty_4) {
        _and_5 = false;
      } else {
        List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(ac);
        boolean _isEmpty_5 = _allAttributes.isEmpty();
        _and_5 = _isEmpty_5;
      }
      if (!_and_5) {
        _and_4 = false;
      } else {
        StateGraph _stateMachine = xpac.getStateMachine();
        boolean _isEmpty_6 = this._roomHelpers.isEmpty(_stateMachine);
        _and_4 = _isEmpty_6;
      }
      if (!_and_4) {
        _and_3 = false;
      } else {
        _and_3 = (!hasConstData);
      }
      final boolean hasVarData = (!_and_3);
      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 ActorClass ");
      String _name = ac.getName();
      _builder.append(_name, " ");
      _builder.newLineIfNotEmpty();
      _builder.append(" ");
      _builder.append("* ");
      _builder.newLine();
      _builder.append(" ");
      _builder.append("*/");
      _builder.newLine();
      _builder.newLine();
      CharSequence _generateIncludeGuardBegin = this._cExtensions.generateIncludeGuardBegin(ac);
      _builder.append(_generateIncludeGuardBegin, "");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("#include \"etDatatypes.h\"");
      _builder.newLine();
      _builder.append("#include \"messaging/etMessage.h\"");
      _builder.newLine();
      _builder.newLine();
      {
        EList<DataClass> _referencedDataClasses = root.getReferencedDataClasses(ac);
        for(final DataClass dataClass : _referencedDataClasses) {
          _builder.append("#include ");
          String _includePath = this._cExtensions.getIncludePath(dataClass);
          _builder.append(_includePath, "");
          _builder.newLineIfNotEmpty();
        }
      }
      {
        EList<EnumerationType> _referencedEnumClasses = root.getReferencedEnumClasses(ac);
        for(final EnumerationType enumClass : _referencedEnumClasses) {
          _builder.append("#include ");
          String _includePath_1 = this._cExtensions.getIncludePath(enumClass);
          _builder.append(_includePath_1, "");
          _builder.newLineIfNotEmpty();
        }
      }
      {
        EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
        for(final ProtocolClass pc : _referencedProtocolClasses) {
          _builder.append("#include ");
          String _includePath_2 = this._cExtensions.getIncludePath(pc);
          _builder.append(_includePath_2, "");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.newLine();
      CharSequence _userCode = this._procedureHelpers.userCode(ac, 1, true);
      _builder.append(_userCode, "");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("typedef struct ");
      String _name_1 = ac.getName();
      _builder.append(_name_1, "");
      _builder.append(" ");
      String _name_2 = ac.getName();
      _builder.append(_name_2, "");
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("/* const part of ActorClass (ROM) */");
      _builder.newLine();
      {
        if (hasConstData) {
          _builder.append("typedef struct ");
          String _name_3 = ac.getName();
          _builder.append(_name_3, "");
          _builder.append("_const {");
          _builder.newLineIfNotEmpty();
          {
            GlobalGeneratorSettings _settings_1 = Main.getSettings();
            boolean _isGenerateMSCInstrumentation_1 = _settings_1.isGenerateMSCInstrumentation();
            if (_isGenerateMSCInstrumentation_1) {
              _builder.append("\t");
              _builder.append("const char* instName;");
              _builder.newLine();
              _builder.append("\t");
              _builder.newLine();
            }
          }
          _builder.append("\t");
          _builder.append("/* simple ports */");
          _builder.newLine();
          {
            for(final Port ep : eventPorts) {
              {
                int _multiplicity = ep.getMultiplicity();
                boolean _equals = (_multiplicity == 1);
                if (_equals) {
                  _builder.append("\t");
                  _builder.append("const ");
                  String _portClassName = this._roomExtensions.getPortClassName(ep);
                  _builder.append(_portClassName, "\t");
                  _builder.append(" ");
                  String _name_4 = ep.getName();
                  _builder.append(_name_4, "\t");
                  _builder.append(";");
                  _builder.newLineIfNotEmpty();
                }
              }
            }
          }
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("/* data receive ports */");
          _builder.newLine();
          {
            for(final Port ep_1 : recvPorts) {
              {
                int _multiplicity_1 = ep_1.getMultiplicity();
                boolean _equals_1 = (_multiplicity_1 == 1);
                if (_equals_1) {
                  _builder.append("\t");
                  _builder.append("const ");
                  String _portClassName_1 = this._roomExtensions.getPortClassName(ep_1);
                  _builder.append(_portClassName_1, "\t");
                  _builder.append(" ");
                  String _name_5 = ep_1.getName();
                  _builder.append(_name_5, "\t");
                  _builder.append(";");
                  _builder.newLineIfNotEmpty();
                }
              }
            }
          }
          _builder.newLine();
          _builder.append("\t");
          _builder.append("/* saps */");
          _builder.newLine();
          {
            List<SAP> _allSAPs_1 = this._roomHelpers.getAllSAPs(ac);
            for(final SAP sap : _allSAPs_1) {
              _builder.append("\t");
              _builder.append("const ");
              String _portClassName_2 = this._roomExtensions.getPortClassName(sap);
              _builder.append(_portClassName_2, "\t");
              _builder.append(" ");
              String _name_6 = sap.getName();
              _builder.append(_name_6, "\t");
              _builder.append(";");
              _builder.newLineIfNotEmpty();
            }
          }
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("/* replicated ports */");
          _builder.newLine();
          {
            List<Port> _allEndPorts_3 = this._roomHelpers.getAllEndPorts(ac);
            for(final Port ep_2 : _allEndPorts_3) {
              {
                int _multiplicity_2 = ep_2.getMultiplicity();
                boolean _notEquals = (_multiplicity_2 != 1);
                if (_notEquals) {
                  _builder.append("\t");
                  _builder.append("const etReplPort ");
                  String _name_7 = ep_2.getName();
                  _builder.append(_name_7, "\t");
                  _builder.append(";");
                  _builder.newLineIfNotEmpty();
                }
              }
            }
          }
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("/* services */");
          _builder.newLine();
          {
            List<ServiceImplementation> _allServiceImplementations_1 = this._roomHelpers.getAllServiceImplementations(ac);
            for(final ServiceImplementation svc : _allServiceImplementations_1) {
              _builder.append("\t");
              _builder.append("const etReplPort ");
              SPP _spp = svc.getSpp();
              String _name_8 = _spp.getName();
              _builder.append(_name_8, "\t");
              _builder.append(";");
              _builder.newLineIfNotEmpty();
            }
          }
          _builder.append("} ");
          String _name_9 = ac.getName();
          _builder.append(_name_9, "");
          _builder.append("_const;");
          _builder.newLineIfNotEmpty();
        } else {
          _builder.append("/* this actor class has no ports and thus no constant data */");
          _builder.newLine();
        }
      }
      _builder.newLine();
      {
        StateGraph _stateMachine_1 = xpac.getStateMachine();
        boolean _isEmpty_7 = this._roomHelpers.isEmpty(_stateMachine_1);
        boolean _not_1 = (!_isEmpty_7);
        if (_not_1) {
          _builder.newLine();
          CharSequence _genHeaderConstants = this._stateMachineGen.genHeaderConstants(xpac);
          _builder.append(_genHeaderConstants, "");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.newLine();
      _builder.append("/* variable part of ActorClass (RAM) */");
      _builder.newLine();
      {
        if (hasVarData) {
          _builder.append("struct ");
          String _name_10 = ac.getName();
          _builder.append(_name_10, "");
          _builder.append(" {");
          _builder.newLineIfNotEmpty();
          {
            if (hasConstData) {
              _builder.append("\t");
              _builder.append("const ");
              String _name_11 = ac.getName();
              _builder.append(_name_11, "\t");
              _builder.append("_const* const constData;");
              _builder.newLineIfNotEmpty();
              _builder.append("\t");
              _builder.newLine();
            }
          }
          _builder.append("\t");
          _builder.append("/* data send ports */");
          _builder.newLine();
          {
            for(final Port ep_3 : sendPorts) {
              {
                int _multiplicity_3 = ep_3.getMultiplicity();
                boolean _equals_2 = (_multiplicity_3 == 1);
                if (_equals_2) {
                  _builder.append("\t");
                  String _portClassName_3 = this._roomExtensions.getPortClassName(ep_3);
                  _builder.append(_portClassName_3, "\t");
                  _builder.append(" ");
                  String _name_12 = ep_3.getName();
                  _builder.append(_name_12, "\t");
                  _builder.append(";");
                  _builder.newLineIfNotEmpty();
                }
              }
            }
          }
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          List<Attribute> _allAttributes_1 = this._roomHelpers.getAllAttributes(ac);
          CharSequence _attributes = this._procedureHelpers.attributes(_allAttributes_1);
          _builder.append(_attributes, "\t");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          _builder.newLine();
          {
            StateGraph _stateMachine_2 = xpac.getStateMachine();
            boolean _isEmpty_8 = this._roomHelpers.isEmpty(_stateMachine_2);
            boolean _not_2 = (!_isEmpty_8);
            if (_not_2) {
              _builder.append("\t");
              _builder.newLine();
              _builder.append("\t");
              CharSequence _genDataMembers = this._stateMachineGen.genDataMembers(xpac);
              _builder.append(_genDataMembers, "\t");
              _builder.newLineIfNotEmpty();
            }
          }
          _builder.append("};");
          _builder.newLine();
        } else {
          _builder.append("struct ");
          String _name_13 = ac.getName();
          _builder.append(_name_13, "");
          _builder.append(" {");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          _builder.append("/* This actor class has no data at all.");
          _builder.newLine();
          _builder.append("\t   ");
          _builder.append("But the private actor instance data is passed to all life cycle functions.");
          _builder.newLine();
          _builder.append("\t   ");
          _builder.append("By introducing the dummy data we keep this case simple");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("*/");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("int dummy;");
          _builder.newLine();
          _builder.append("};");
          _builder.newLine();
        }
      }
      _builder.newLine();
      _builder.append("void ");
      String _name_14 = ac.getName();
      _builder.append(_name_14, "");
      _builder.append("_init(");
      String _name_15 = ac.getName();
      _builder.append(_name_15, "");
      _builder.append("* self);");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("void ");
      String _name_16 = ac.getName();
      _builder.append(_name_16, "");
      _builder.append("_receiveMessage(void* self, const void* ifitem, const etMessage* msg);");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      {
        boolean _or_1 = false;
        if (dataDriven) {
          _or_1 = true;
        } else {
          _or_1 = async;
        }
        if (_or_1) {
          _builder.append("void ");
          String _name_17 = ac.getName();
          _builder.append(_name_17, "");
          _builder.append("_execute(");
          String _name_18 = ac.getName();
          _builder.append(_name_18, "");
          _builder.append("* self);");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.newLine();
      {
        List<ClassStructor> _allStructors = this._roomHelpers.getAllStructors(ac);
        final Function1<ClassStructor, Boolean> _function_3 = new Function1<ClassStructor, Boolean>() {
          public Boolean apply(final ClassStructor it) {
            return Boolean.valueOf(it.isConstructor());
          }
        };
        boolean _exists = IterableExtensions.<ClassStructor>exists(_allStructors, _function_3);
        if (_exists) {
          String _name_19 = ac.getName();
          CharSequence _constructorSignature = this._procedureHelpers.getConstructorSignature(_name_19);
          _builder.append(_constructorSignature, "");
          _builder.append(";");
        }
      }
      _builder.newLineIfNotEmpty();
      {
        List<ClassStructor> _allStructors_1 = this._roomHelpers.getAllStructors(ac);
        final Function1<ClassStructor, Boolean> _function_4 = new Function1<ClassStructor, Boolean>() {
          public Boolean apply(final ClassStructor it) {
            boolean _isConstructor = it.isConstructor();
            return Boolean.valueOf((!_isConstructor));
          }
        };
        boolean _exists_1 = IterableExtensions.<ClassStructor>exists(_allStructors_1, _function_4);
        if (_exists_1) {
          String _name_20 = ac.getName();
          CharSequence _destructorSignature = this._procedureHelpers.getDestructorSignature(_name_20);
          _builder.append(_destructorSignature, "");
          _builder.append(";");
        }
      }
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      List<StandardOperation> _latestOperations = this._roomHelpers.getLatestOperations(ac);
      String _name_21 = ac.getName();
      CharSequence _operationsDeclaration = this._procedureHelpers.operationsDeclaration(_latestOperations, _name_21);
      _builder.append(_operationsDeclaration, "");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      CharSequence _userCode_1 = this._procedureHelpers.userCode(ac, 2, true);
      _builder.append(_userCode_1, "");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(ac);
      _builder.append(_generateIncludeGuardEnd, "");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  private CharSequence generateUtilsFile(final Root root, final ExpandedActorClass xpac) {
    CharSequence _xblockexpression = null;
    {
      final ActorClass ac = xpac.getActorClass();
      List<Port> _allEndPorts = this._roomHelpers.getAllEndPorts(ac);
      final Function1<Port, Boolean> _function = new Function1<Port, Boolean>() {
        public Boolean apply(final Port p) {
          GeneralProtocolClass _protocol = p.getProtocol();
          CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
          return Boolean.valueOf(Objects.equal(_commType, CommunicationType.EVENT_DRIVEN));
        }
      };
      final Iterable<Port> eventPorts = IterableExtensions.<Port>filter(_allEndPorts, _function);
      final Function1<Port, Boolean> _function_1 = new Function1<Port, Boolean>() {
        public Boolean apply(final Port it) {
          int _multiplicity = it.getMultiplicity();
          return Boolean.valueOf((_multiplicity != 1));
        }
      };
      final Iterable<Port> replEventPorts = IterableExtensions.<Port>filter(eventPorts, _function_1);
      List<Port> _allEndPorts_1 = this._roomHelpers.getAllEndPorts(ac);
      final Function1<Port, Boolean> _function_2 = new Function1<Port, Boolean>() {
        public Boolean apply(final Port p) {
          boolean _and = false;
          boolean _and_1 = false;
          GeneralProtocolClass _protocol = p.getProtocol();
          CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
          boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN);
          if (!_equals) {
            _and_1 = false;
          } else {
            boolean _isConjugated = p.isConjugated();
            _and_1 = _isConjugated;
          }
          if (!_and_1) {
            _and = false;
          } else {
            int _multiplicity = p.getMultiplicity();
            boolean _equals_1 = (_multiplicity == 1);
            _and = _equals_1;
          }
          return Boolean.valueOf(_and);
        }
      };
      final Iterable<Port> sendPorts = IterableExtensions.<Port>filter(_allEndPorts_1, _function_2);
      List<Port> _allEndPorts_2 = this._roomHelpers.getAllEndPorts(ac);
      final Function1<Port, Boolean> _function_3 = new Function1<Port, Boolean>() {
        public Boolean apply(final Port p) {
          boolean _and = false;
          boolean _and_1 = false;
          GeneralProtocolClass _protocol = p.getProtocol();
          CommunicationType _commType = ((ProtocolClass) _protocol).getCommType();
          boolean _equals = Objects.equal(_commType, CommunicationType.DATA_DRIVEN);
          if (!_equals) {
            _and_1 = false;
          } else {
            boolean _isConjugated = p.isConjugated();
            boolean _not = (!_isConjugated);
            _and_1 = _not;
          }
          if (!_and_1) {
            _and = false;
          } else {
            int _multiplicity = p.getMultiplicity();
            boolean _equals_1 = (_multiplicity == 1);
            _and = _equals_1;
          }
          return Boolean.valueOf(_and);
        }
      };
      final Iterable<Port> recvPorts = IterableExtensions.<Port>filter(_allEndPorts_2, _function_3);
      List<InterfaceItem> _allInterfaceItems = this._roomHelpers.getAllInterfaceItems(ac);
      final Function1<InterfaceItem, Boolean> _function_4 = new Function1<InterfaceItem, Boolean>() {
        public Boolean apply(final InterfaceItem p) {
          boolean _and = false;
          PortClass _portClass = ActorClassGen.this._roomHelpers.getPortClass(p);
          boolean _notEquals = (!Objects.equal(_portClass, null));
          if (!_notEquals) {
            _and = false;
          } else {
            PortClass _portClass_1 = ActorClassGen.this._roomHelpers.getPortClass(p);
            EList<PortOperation> _operations = _portClass_1.getOperations();
            int _size = _operations.size();
            boolean _greaterThan = (_size > 0);
            _and = _greaterThan;
          }
          return Boolean.valueOf(_and);
        }
      };
      final Iterable<InterfaceItem> portsWithOperations = IterableExtensions.<InterfaceItem>filter(_allInterfaceItems, _function_4);
      EObject _eContainer = ac.eContainer();
      String _name = ((RoomModel) _eContainer).getName();
      String _replaceAll = _name.replaceAll("\\.", "_");
      String _plus = (_replaceAll + "_");
      String _name_1 = ac.getName();
      String _plus_1 = (_plus + _name_1);
      final String filename = (_plus_1 + "_Utils");
      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("* Utils File of ActorClass ");
      String _name_2 = ac.getName();
      _builder.append(_name_2, " ");
      _builder.newLineIfNotEmpty();
      _builder.append(" ");
      _builder.append("* ");
      _builder.newLine();
      _builder.append(" ");
      _builder.append("*/");
      _builder.newLine();
      _builder.newLine();
      CharSequence _generateIncludeGuardBegin = this._cExtensions.generateIncludeGuardBegin(filename);
      _builder.append(_generateIncludeGuardBegin, "");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("#include ");
      String _includePath = this._cExtensions.getIncludePath(ac);
      _builder.append(_includePath, "");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("/*");
      _builder.newLine();
      _builder.append(" ");
      _builder.append("* access macros for ports, operations and attributes");
      _builder.newLine();
      _builder.append("*/");
      _builder.newLine();
      _builder.newLine();
      _builder.append("/* simple event ports */");
      _builder.newLine();
      {
        final Function1<Port, Boolean> _function_5 = new Function1<Port, Boolean>() {
          public Boolean apply(final Port it) {
            int _multiplicity = it.getMultiplicity();
            return Boolean.valueOf((_multiplicity == 1));
          }
        };
        Iterable<Port> _filter = IterableExtensions.<Port>filter(eventPorts, _function_5);
        for(final Port ep : _filter) {
          {
            List<Message> _outgoing = this._roomHelpers.getOutgoing(ep);
            for(final Message msg : _outgoing) {
              String _xifexpression = null;
              VarDecl _data = msg.getData();
              boolean _notEquals = (!Objects.equal(_data, null));
              if (_notEquals) {
                _xifexpression = "data";
              } else {
                _xifexpression = "";
              }
              final String data1 = _xifexpression;
              _builder.newLineIfNotEmpty();
              String _xifexpression_1 = null;
              VarDecl _data_1 = msg.getData();
              boolean _notEquals_1 = (!Objects.equal(_data_1, null));
              if (_notEquals_1) {
                _xifexpression_1 = ", data";
              } else {
                _xifexpression_1 = "";
              }
              final String data2 = _xifexpression_1;
              _builder.newLineIfNotEmpty();
              _builder.append("#define ");
              String _name_3 = ep.getName();
              _builder.append(_name_3, "");
              _builder.append("_");
              String _name_4 = msg.getName();
              _builder.append(_name_4, "");
              _builder.append("(");
              _builder.append(data1, "");
              _builder.append(") ");
              String _portClassName = this._roomExtensions.getPortClassName(ep);
              _builder.append(_portClassName, "");
              _builder.append("_");
              String _name_5 = msg.getName();
              _builder.append(_name_5, "");
              _builder.append("(&self->constData->");
              String _name_6 = ep.getName();
              _builder.append(_name_6, "");
              _builder.append(data2, "");
              _builder.append(")");
              _builder.newLineIfNotEmpty();
            }
          }
        }
      }
      _builder.newLine();
      _builder.append("/* data receive ports */");
      _builder.newLine();
      {
        for(final Port ep_1 : recvPorts) {
          {
            List<Message> _incoming = this._roomHelpers.getIncoming(ep_1);
            for(final Message msg_1 : _incoming) {
              _builder.append("#define ");
              String _name_7 = ep_1.getName();
              _builder.append(_name_7, "");
              _builder.append("_");
              String _name_8 = msg_1.getName();
              _builder.append(_name_8, "");
              _builder.append(" ");
              String _portClassName_1 = this._roomExtensions.getPortClassName(ep_1);
              _builder.append(_portClassName_1, "");
              _builder.append("_");
              String _name_9 = msg_1.getName();
              _builder.append(_name_9, "");
              _builder.append("_get(&self->constData->");
              String _name_10 = ep_1.getName();
              _builder.append(_name_10, "");
              _builder.append(")");
              _builder.newLineIfNotEmpty();
            }
          }
        }
      }
      _builder.newLine();
      _builder.append("/* data send ports */");
      _builder.newLine();
      {
        for(final Port ep_2 : sendPorts) {
          {
            List<Message> _outgoing_1 = this._roomHelpers.getOutgoing(ep_2);
            for(final Message msg_2 : _outgoing_1) {
              String _xifexpression_2 = null;
              VarDecl _data_2 = msg_2.getData();
              boolean _notEquals_2 = (!Objects.equal(_data_2, null));
              if (_notEquals_2) {
                _xifexpression_2 = "data";
              } else {
                _xifexpression_2 = "";
              }
              final String data1_1 = _xifexpression_2;
              _builder.newLineIfNotEmpty();
              String _xifexpression_3 = null;
              VarDecl _data_3 = msg_2.getData();
              boolean _notEquals_3 = (!Objects.equal(_data_3, null));
              if (_notEquals_3) {
                _xifexpression_3 = ", data";
              } else {
                _xifexpression_3 = "";
              }
              final String data2_1 = _xifexpression_3;
              _builder.newLineIfNotEmpty();
              _builder.append("#define ");
              String _name_11 = ep_2.getName();
              _builder.append(_name_11, "");
              _builder.append("_");
              String _name_12 = msg_2.getName();
              _builder.append(_name_12, "");
              _builder.append("(");
              _builder.append(data1_1, "");
              _builder.append(") ");
              String _portClassName_2 = this._roomExtensions.getPortClassName(ep_2);
              _builder.append(_portClassName_2, "");
              _builder.append("_");
              String _name_13 = msg_2.getName();
              _builder.append(_name_13, "");
              _builder.append("_set(&self->");
              String _name_14 = ep_2.getName();
              _builder.append(_name_14, "");
              _builder.append(data2_1, "");
              _builder.append(")");
              _builder.newLineIfNotEmpty();
            }
          }
        }
      }
      _builder.newLine();
      _builder.append("/* saps */");
      _builder.newLine();
      {
        List<SAP> _allSAPs = this._roomHelpers.getAllSAPs(ac);
        for(final SAP sap : _allSAPs) {
          {
            List<Message> _outgoing_2 = this._roomHelpers.getOutgoing(sap);
            for(final Message msg_3 : _outgoing_2) {
              String _xifexpression_4 = null;
              VarDecl _data_4 = msg_3.getData();
              boolean _notEquals_4 = (!Objects.equal(_data_4, null));
              if (_notEquals_4) {
                _xifexpression_4 = "data";
              } else {
                _xifexpression_4 = "";
              }
              final String data1_2 = _xifexpression_4;
              _builder.newLineIfNotEmpty();
              String _xifexpression_5 = null;
              VarDecl _data_5 = msg_3.getData();
              boolean _notEquals_5 = (!Objects.equal(_data_5, null));
              if (_notEquals_5) {
                _xifexpression_5 = ", data";
              } else {
                _xifexpression_5 = "";
              }
              final String data2_2 = _xifexpression_5;
              _builder.newLineIfNotEmpty();
              _builder.append("#define ");
              String _name_15 = sap.getName();
              _builder.append(_name_15, "");
              _builder.append("_");
              String _name_16 = msg_3.getName();
              _builder.append(_name_16, "");
              _builder.append("(");
              _builder.append(data1_2, "");
              _builder.append(") ");
              String _portClassName_3 = this._roomExtensions.getPortClassName(sap);
              _builder.append(_portClassName_3, "");
              _builder.append("_");
              String _name_17 = msg_3.getName();
              _builder.append(_name_17, "");
              _builder.append("(&self->constData->");
              String _name_18 = sap.getName();
              _builder.append(_name_18, "");
              _builder.append(data2_2, "");
              _builder.append(")");
              _builder.newLineIfNotEmpty();
            }
          }
        }
      }
      _builder.newLine();
      _builder.append("/* replicated event ports */");
      _builder.newLine();
      {
        boolean _isEmpty = IterableExtensions.isEmpty(replEventPorts);
        boolean _not = (!_isEmpty);
        if (_not) {
          _builder.append("#define ifitem_index (((etReplSubPort*)ifitem)->index)");
          _builder.newLine();
        }
      }
      {
        for(final Port ep_3 : replEventPorts) {
          {
            List<Message> _outgoing_3 = this._roomHelpers.getOutgoing(ep_3);
            for(final Message msg_4 : _outgoing_3) {
              String _xifexpression_6 = null;
              VarDecl _data_6 = msg_4.getData();
              boolean _notEquals_6 = (!Objects.equal(_data_6, null));
              if (_notEquals_6) {
                _xifexpression_6 = "data";
              } else {
                _xifexpression_6 = "";
              }
              final String data1_3 = _xifexpression_6;
              _builder.newLineIfNotEmpty();
              String _xifexpression_7 = null;
              VarDecl _data_7 = msg_4.getData();
              boolean _notEquals_7 = (!Objects.equal(_data_7, null));
              if (_notEquals_7) {
                _xifexpression_7 = ", data";
              } else {
                _xifexpression_7 = "";
              }
              final String data2_3 = _xifexpression_7;
              _builder.newLineIfNotEmpty();
              _builder.append("#define ");
              String _name_19 = ep_3.getName();
              _builder.append(_name_19, "");
              _builder.append("_");
              String _name_20 = msg_4.getName();
              _builder.append(_name_20, "");
              _builder.append("_broadcast(");
              _builder.append(data1_3, "");
              _builder.append(") ");
              String _portClassName_4 = this._roomExtensions.getPortClassName(ep_3);
              _builder.append(_portClassName_4, "");
              _builder.append("_");
              String _name_21 = msg_4.getName();
              _builder.append(_name_21, "");
              _builder.append("_broadcast(&self->constData->");
              String _name_22 = ep_3.getName();
              _builder.append(_name_22, "");
              _builder.append(data2_3, "");
              _builder.append(")");
              _builder.newLineIfNotEmpty();
              _builder.append("#define ");
              String _name_23 = ep_3.getName();
              _builder.append(_name_23, "");
              _builder.append("_");
              String _name_24 = msg_4.getName();
              _builder.append(_name_24, "");
              _builder.append("(idx");
              _builder.append(data2_3, "");
              _builder.append(") ");
              String _portClassName_5 = this._roomExtensions.getPortClassName(ep_3);
              _builder.append(_portClassName_5, "");
              _builder.append("_");
              String _name_25 = msg_4.getName();
              _builder.append(_name_25, "");
              _builder.append("(&self->constData->");
              String _name_26 = ep_3.getName();
              _builder.append(_name_26, "");
              _builder.append(", idx");
              _builder.append(data2_3, "");
              _builder.append(")");
              _builder.newLineIfNotEmpty();
            }
          }
        }
      }
      _builder.newLine();
      _builder.append("/* services */");
      _builder.newLine();
      {
        List<ServiceImplementation> _allServiceImplementations = this._roomHelpers.getAllServiceImplementations(ac);
        for(final ServiceImplementation svc : _allServiceImplementations) {
          {
            SPP _spp = svc.getSpp();
            List<Message> _outgoing_4 = this._roomHelpers.getOutgoing(_spp);
            for(final Message msg_5 : _outgoing_4) {
              String _xifexpression_8 = null;
              VarDecl _data_8 = msg_5.getData();
              boolean _notEquals_8 = (!Objects.equal(_data_8, null));
              if (_notEquals_8) {
                _xifexpression_8 = "data";
              } else {
                _xifexpression_8 = "";
              }
              final String data1_4 = _xifexpression_8;
              _builder.newLineIfNotEmpty();
              String _xifexpression_9 = null;
              VarDecl _data_9 = msg_5.getData();
              boolean _notEquals_9 = (!Objects.equal(_data_9, null));
              if (_notEquals_9) {
                _xifexpression_9 = ", data";
              } else {
                _xifexpression_9 = "";
              }
              final String data2_4 = _xifexpression_9;
              _builder.newLineIfNotEmpty();
              _builder.append("#define ");
              SPP _spp_1 = svc.getSpp();
              String _name_27 = _spp_1.getName();
              _builder.append(_name_27, "");
              _builder.append("_");
              String _name_28 = msg_5.getName();
              _builder.append(_name_28, "");
              _builder.append("_broadcast(");
              _builder.append(data1_4, "");
              _builder.append(") ");
              SPP _spp_2 = svc.getSpp();
              String _portClassName_6 = this._roomExtensions.getPortClassName(_spp_2);
              _builder.append(_portClassName_6, "");
              _builder.append("_");
              String _name_29 = msg_5.getName();
              _builder.append(_name_29, "");
              _builder.append("_broadcast(&self->constData->");
              SPP _spp_3 = svc.getSpp();
              String _name_30 = _spp_3.getName();
              _builder.append(_name_30, "");
              _builder.append(data2_4, "");
              _builder.append(")");
              _builder.newLineIfNotEmpty();
              _builder.append("#define ");
              SPP _spp_4 = svc.getSpp();
              String _name_31 = _spp_4.getName();
              _builder.append(_name_31, "");
              _builder.append("_");
              String _name_32 = msg_5.getName();
              _builder.append(_name_32, "");
              _builder.append("(idx");
              _builder.append(data2_4, "");
              _builder.append(") ");
              SPP _spp_5 = svc.getSpp();
              String _portClassName_7 = this._roomExtensions.getPortClassName(_spp_5);
              _builder.append(_portClassName_7, "");
              _builder.append("_");
              String _name_33 = msg_5.getName();
              _builder.append(_name_33, "");
              _builder.append("(&self->constData->");
              SPP _spp_6 = svc.getSpp();
              String _name_34 = _spp_6.getName();
              _builder.append(_name_34, "");
              _builder.append(", idx");
              _builder.append(data2_4, "");
              _builder.append(")");
              _builder.newLineIfNotEmpty();
            }
          }
        }
      }
      _builder.newLine();
      _builder.append("/* operations */");
      _builder.newLine();
      {
        List<StandardOperation> _latestOperations = this._roomHelpers.getLatestOperations(ac);
        for(final StandardOperation op : _latestOperations) {
          final CharSequence args = this.argList(op);
          _builder.newLineIfNotEmpty();
          _builder.append("#define ");
          String _name_35 = op.getName();
          _builder.append(_name_35, "");
          _builder.append("(");
          _builder.append(args, "");
          _builder.append(") ");
          String _name_36 = ac.getName();
          _builder.append(_name_36, "");
          _builder.append("_");
          String _name_37 = op.getName();
          _builder.append(_name_37, "");
          _builder.append("(self");
          {
            EList<VarDecl> _arguments = op.getArguments();
            boolean _isEmpty_1 = _arguments.isEmpty();
            boolean _not_1 = (!_isEmpty_1);
            if (_not_1) {
              _builder.append(", ");
              _builder.append(args, "");
            }
          }
          _builder.append(")");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.newLine();
      _builder.append("/* attributes */");
      _builder.newLine();
      {
        List<Attribute> _allAttributes = this._roomHelpers.getAllAttributes(ac);
        for(final Attribute a : _allAttributes) {
          _builder.append("#define ");
          String _name_38 = a.getName();
          _builder.append(_name_38, "");
          _builder.append(" (self->");
          String _name_39 = a.getName();
          _builder.append(_name_39, "");
          _builder.append(")");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.newLine();
      _builder.append("/* port operations */");
      _builder.newLine();
      {
        for(final InterfaceItem p : portsWithOperations) {
          {
            PortClass _portClass = this._roomHelpers.getPortClass(p);
            EList<PortOperation> _operations = _portClass.getOperations();
            for(final PortOperation op_1 : _operations) {
              final CharSequence args_1 = this.argList(op_1);
              _builder.newLineIfNotEmpty();
              _builder.append("#define ");
              String _name_40 = p.getName();
              _builder.append(_name_40, "");
              _builder.append("_");
              String _name_41 = op_1.getName();
              _builder.append(_name_41, "");
              _builder.append("(");
              _builder.append(args_1, "");
              _builder.append(") ");
              String _portClassName_8 = this._roomExtensions.getPortClassName(p);
              _builder.append(_portClassName_8, "");
              _builder.append("_");
              String _name_42 = op_1.getName();
              _builder.append(_name_42, "");
              _builder.append("((");
              String _portClassName_9 = this._roomExtensions.getPortClassName(p);
              _builder.append(_portClassName_9, "");
              _builder.append("*)&self->constData->");
              String _name_43 = p.getName();
              _builder.append(_name_43, "");
              {
                EList<VarDecl> _arguments_1 = op_1.getArguments();
                boolean _isEmpty_2 = _arguments_1.isEmpty();
                boolean _not_2 = (!_isEmpty_2);
                if (_not_2) {
                  _builder.append(", ");
                  _builder.append(args_1, "");
                }
              }
              _builder.append(")");
              _builder.newLineIfNotEmpty();
            }
          }
        }
      }
      _builder.newLine();
      CharSequence _generateIncludeGuardEnd = this._cExtensions.generateIncludeGuardEnd(filename);
      _builder.append(_generateIncludeGuardEnd, "");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  private CharSequence argList(final Operation op) {
    StringConcatenation _builder = new StringConcatenation();
    {
      EList<VarDecl> _arguments = op.getArguments();
      boolean _hasElements = false;
      for(final VarDecl a : _arguments) {
        if (!_hasElements) {
          _hasElements = true;
        } else {
          _builder.appendImmediate(", ", "");
        }
        String _name = a.getName();
        _builder.append(_name, "");
      }
    }
    return _builder;
  }
  
  private CharSequence generateSourceFile(final Root root, final ExpandedActorClass xpac) {
    CharSequence _xblockexpression = null;
    {
      final ActorClass ac = xpac.getActorClass();
      ComponentCommunicationType _commType = ac.getCommType();
      final boolean async = Objects.equal(_commType, ComponentCommunicationType.ASYNCHRONOUS);
      ComponentCommunicationType _commType_1 = ac.getCommType();
      final boolean eventDriven = Objects.equal(_commType_1, ComponentCommunicationType.EVENT_DRIVEN);
      ComponentCommunicationType _commType_2 = ac.getCommType();
      final boolean dataDriven = Objects.equal(_commType_2, ComponentCommunicationType.DATA_DRIVEN);
      boolean _or = false;
      if (async) {
        _or = true;
      } else {
        _or = eventDriven;
      }
      final boolean handleEvents = _or;
      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 ActorClass ");
      String _name = ac.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._cExtensions.getCHeaderFileName(ac);
      _builder.append(_cHeaderFileName, "");
      _builder.append("\"");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("#include \"modelbase/etActor.h\"");
      _builder.newLine();
      _builder.append("#include \"debugging/etLogger.h\"");
      _builder.newLine();
      _builder.append("#include \"debugging/etMSCLogger.h\"");
      _builder.newLine();
      _builder.append("#include \"etUnit/etUnit.h\"");
      _builder.newLine();
      _builder.append("#include \"base/etMemory.h\"");
      _builder.newLine();
      _builder.newLine();
      {
        EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
        for(final ProtocolClass pc : _referencedProtocolClasses) {
          _builder.append("#include ");
          String _includePath = this._cExtensions.getIncludePath(pc);
          _builder.append(_includePath, "");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.newLine();
      _builder.append("#include \"");
      String _cUtilsFileName = this._cExtensions.getCUtilsFileName(ac);
      _builder.append(_cUtilsFileName, "");
      _builder.append("\"");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      CharSequence _userCode = this._procedureHelpers.userCode(ac, 3, true);
      _builder.append(_userCode, "");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("/* interface item IDs */");
      _builder.newLine();
      String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac);
      _builder.append(_genInterfaceItemConstants, "");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      {
        StateGraph _stateMachine = xpac.getStateMachine();
        boolean _isEmpty = this._roomHelpers.isEmpty(_stateMachine);
        boolean _not = (!_isEmpty);
        if (_not) {
          CharSequence _genStateMachine = this._stateMachineGen.genStateMachine(xpac);
          _builder.append(_genStateMachine, "");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.newLine();
      _builder.append("void ");
      String _name_1 = ac.getName();
      _builder.append(_name_1, "");
      _builder.append("_init(");
      String _name_2 = ac.getName();
      _builder.append(_name_2, "");
      _builder.append("* self){");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
      String _name_3 = ac.getName();
      _builder.append(_name_3, "\t");
      _builder.append("\", \"init\")");
      _builder.newLineIfNotEmpty();
      {
        StateGraph _stateMachine_1 = xpac.getStateMachine();
        boolean _isEmpty_1 = this._roomHelpers.isEmpty(_stateMachine_1);
        boolean _not_1 = (!_isEmpty_1);
        if (_not_1) {
          _builder.append("\t");
          CharSequence _genInitialization = this._stateMachineGen.genInitialization(xpac);
          _builder.append(_genInitialization, "\t");
          _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_4 = ac.getName();
      _builder.append(_name_4, "");
      _builder.append("_receiveMessage(void* self, const void* ifitem, const etMessage* msg){");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
      String _name_5 = ac.getName();
      _builder.append(_name_5, "\t");
      _builder.append("\", \"_receiveMessage\")");
      _builder.newLineIfNotEmpty();
      {
        StateGraph _stateMachine_2 = xpac.getStateMachine();
        boolean _isEmpty_2 = this._roomHelpers.isEmpty(_stateMachine_2);
        boolean _not_2 = (!_isEmpty_2);
        if (_not_2) {
          {
            if (handleEvents) {
              _builder.append("\t");
              String _name_6 = ac.getName();
              String _operationScope = this.langExt.operationScope(_name_6, false);
              _builder.append(_operationScope, "\t");
              _builder.append("receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage))));");
              _builder.newLineIfNotEmpty();
            } else {
              _builder.append("\t");
              String _name_7 = ac.getName();
              String _operationScope_1 = this.langExt.operationScope(_name_7, false);
              _builder.append(_operationScope_1, "\t");
              _builder.append("receiveEventInternal(self);");
              _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();
      {
        boolean _or_1 = false;
        if (dataDriven) {
          _or_1 = true;
        } else {
          _or_1 = async;
        }
        if (_or_1) {
          _builder.append("void ");
          String _name_8 = ac.getName();
          _builder.append(_name_8, "");
          _builder.append("_execute(");
          String _name_9 = ac.getName();
          _builder.append(_name_9, "");
          _builder.append("* self) {");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          _builder.append("ET_MSC_LOGGER_SYNC_ENTRY(\"");
          String _name_10 = ac.getName();
          _builder.append(_name_10, "\t");
          _builder.append("\", \"_execute\")");
          _builder.newLineIfNotEmpty();
          {
            StateGraph _stateMachine_3 = xpac.getStateMachine();
            boolean _isEmpty_3 = this._roomHelpers.isEmpty(_stateMachine_3);
            boolean _not_3 = (!_isEmpty_3);
            if (_not_3) {
              _builder.append("\t");
              _builder.newLine();
              {
                if (handleEvents) {
                  _builder.append("\t");
                  String _name_11 = ac.getName();
                  String _operationScope_2 = this.langExt.operationScope(_name_11, false);
                  _builder.append(_operationScope_2, "\t");
                  _builder.append("receiveEvent(self, NULL, 0, NULL);");
                  _builder.newLineIfNotEmpty();
                } else {
                  _builder.append("\t");
                  String _name_12 = ac.getName();
                  String _operationScope_3 = this.langExt.operationScope(_name_12, false);
                  _builder.append(_operationScope_3, "\t");
                  _builder.append("receiveEventInternal(self);");
                  _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();
      CharSequence _classStructors = this.classStructors(ac);
      _builder.append(_classStructors, "");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      List<StandardOperation> _latestOperations = this._roomHelpers.getLatestOperations(ac);
      String _name_13 = ac.getName();
      CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_latestOperations, _name_13);
      _builder.append(_operationsImplementation, "");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  protected CharSequence classStructors(final ActorClass ac) {
    CharSequence _xblockexpression = null;
    {
      List<ClassStructor> _allStructors = this._roomHelpers.getAllStructors(ac);
      final Function1<ClassStructor, Boolean> _function = new Function1<ClassStructor, Boolean>() {
        public Boolean apply(final ClassStructor it) {
          return Boolean.valueOf(it.isConstructor());
        }
      };
      final Iterable<ClassStructor> ctors = IterableExtensions.<ClassStructor>filter(_allStructors, _function);
      List<ClassStructor> _allStructors_1 = this._roomHelpers.getAllStructors(ac);
      final Function1<ClassStructor, Boolean> _function_1 = new Function1<ClassStructor, Boolean>() {
        public Boolean apply(final ClassStructor it) {
          boolean _isConstructor = it.isConstructor();
          return Boolean.valueOf((!_isConstructor));
        }
      };
      final Iterable<ClassStructor> dtors = IterableExtensions.<ClassStructor>filter(_allStructors_1, _function_1);
      StringConcatenation _builder = new StringConcatenation();
      {
        boolean _isEmpty = IterableExtensions.isEmpty(ctors);
        boolean _not = (!_isEmpty);
        if (_not) {
          String _name = ac.getName();
          CharSequence _constructorSignature = this._procedureHelpers.getConstructorSignature(_name);
          _builder.append(_constructorSignature, "");
          _builder.append("{");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          final Function1<ClassStructor, CharSequence> _function_2 = new Function1<ClassStructor, CharSequence>() {
            public CharSequence apply(final ClassStructor it) {
              DetailCode _detailCode = it.getDetailCode();
              String _translatedCode = ActorClassGen.this._stateMachineGen.translator.getTranslatedCode(_detailCode);
              return ActorClassGen.this._procedureHelpers.asBlock(_translatedCode);
            }
          };
          Iterable<CharSequence> _map = IterableExtensions.<ClassStructor, CharSequence>map(ctors, _function_2);
          String _join = IterableExtensions.join(_map);
          _builder.append(_join, "\t");
          _builder.newLineIfNotEmpty();
          _builder.append("}");
          _builder.newLine();
        }
      }
      {
        boolean _isEmpty_1 = IterableExtensions.isEmpty(dtors);
        boolean _not_1 = (!_isEmpty_1);
        if (_not_1) {
          String _name_1 = ac.getName();
          CharSequence _destructorSignature = this._procedureHelpers.getDestructorSignature(_name_1);
          _builder.append(_destructorSignature, "");
          _builder.append("{");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          final Function1<ClassStructor, CharSequence> _function_3 = new Function1<ClassStructor, CharSequence>() {
            public CharSequence apply(final ClassStructor it) {
              DetailCode _detailCode = it.getDetailCode();
              String _translatedCode = ActorClassGen.this._stateMachineGen.translator.getTranslatedCode(_detailCode);
              return ActorClassGen.this._procedureHelpers.asBlock(_translatedCode);
            }
          };
          Iterable<CharSequence> _map_1 = IterableExtensions.<ClassStructor, CharSequence>map(dtors, _function_3);
          String _join_1 = IterableExtensions.join(_map_1);
          _builder.append(_join_1, "\t");
          _builder.newLineIfNotEmpty();
          _builder.append("}");
          _builder.newLine();
        }
      }
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
}

Back to the top