Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3eb03a2e1c2757e7b0ef204f3cad5e6f4b738d4b (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
«REM»
/*******************************************************************************
 * Copyright (c) 2010 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:
 * 		Thomas Schuetz and Henrik Rentz-Reichert (initial contribution)
 * 
 *******************************************************************************/
«ENDREM»
«IMPORT room»;
«IMPORT etricegen»;

«EXTENSION extensions::Extensions»
«EXTENSION org::eclipse::xtend::util::stdlib::io»

«DEFINE subSystemClass FOR Root»

«FOREACH this.subSystems AS comp»

«LET comp.subSystemClass AS cc»

«("generating "+getPath(cc)+cc.name+"_controller.java").info()»
«FILE getPath(cc)+cc.name+".java"»
package «getPackage(cc)»;

import org.eclipse.etrice.runtime.java.messaging.MessageService;
import org.eclipse.etrice.runtime.java.messaging.RTServices;
import org.eclipse.etrice.runtime.java.messaging.Address;
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;

«LET this.getReferencedModels(cc) AS models»
«FOREACH models AS model»import «model.name».*;«ENDFOREACH»
«ENDLET»


public class «comp.name» extends SubSystemClassBase {
	
	public «comp.name»(IRTObject parent, String name) {
		super(parent, name);
	}

	@Override	
	public void instantiateMessageServices(){
	
		RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),"MessageService_Main"));
		«FOREACH comp.subSystemClass.threads AS thread ITERATOR tid»
			RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, «tid.counter0»+1, 0),"MessageService_«thread.name»"));
		«ENDFOREACH»
		}

	@Override
	public void instantiateActors(){
		// all addresses
		«FOREACH comp.allContainedInstances AS ai»
		// actor instance «ai.path» itself
		Address addr«ai.path.getPathName()»= new Address(0,«ai.threadId»,«ai.objId»);
			// interface items of «ai.path»«FOREACH ai.orderedIfItemInstances AS pi»
				«IF ServiceImplInstance.isInstance(pi) || pi.peers.size>1»«FOREACH pi.peers AS peer ITERATOR i»Address addr«pi.path.getPathName()»_«i.counter0» = new Address(0,«pi.threadId»,«pi.objId»+«i.counter0»);
					«ENDFOREACH»
				«ELSE»Address addr«pi.path.getPathName()» = new Address(0,«ai.threadId»,«pi.objId»);
				«ENDIF»
			«ENDFOREACH»
		«ENDFOREACH»

		// instantiate all actor instances
		instances = new ActorClassBase[«comp.allContainedInstances.size»];
		«FOREACH comp.allContainedInstances AS ai»instances[«comp.allContainedInstances.indexOf(ai)»] = new «ai.actorClass.name»(
				«IF SubSystemInstance.isInstance(ai.eContainer)»this«ELSE»instances[«comp.allContainedInstances.indexOf(ai.eContainer)»]«ENDIF»,
				"«ai.name»",
				addr«ai.path.getPathName()»,
				// own interface item addresses
				new Address[][] {«FOREACH ai.orderedIfItemInstances AS pi SEPARATOR ","»{«IF ServiceImplInstance.isInstance(pi) || pi.peers.size>1»«FOREACH pi.peers AS peer ITERATOR i SEPARATOR ","»addr«pi.path.getPathName()»_«i.counter0»«ENDFOREACH»
					«ELSE»addr«pi.path.getPathName()»
					«ENDIF»}
				«ENDFOREACH»},
				// peer interface item addresses
				new Address[][] {«FOREACH ai.orderedIfItemInstances AS pi SEPARATOR ","»{«IF !ServiceImplInstance.isInstance(pi) && pi.peers.isEmpty»null«ELSE»«FOREACH pi.peers AS pp SEPARATOR ","»«IF ServiceImplInstance.isInstance(pp) || pp.peers.size>1»addr«pp.path.getPathName()»_«pp.peers.indexOf(pi)»
					«ELSE»addr«pp.path.getPathName()»
					«ENDIF»
					«ENDFOREACH»«ENDIF»}
				«ENDFOREACH»}
			); 
		«ENDFOREACH»
	}
};
«ENDFILE»

«ENDLET»
«ENDFOREACH»
«ENDDEFINE»

Back to the top