diff options
Diffstat (limited to 'plugins/org.eclipse.etrice.generator.c/src/org/eclipse')
8 files changed, 1123 insertions, 957 deletions
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/Main.java b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/Main.java index 35ddee8a2..3d1c8b641 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/Main.java +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/Main.java @@ -1,119 +1,119 @@ -/******************************************************************************* - * 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) - * - *******************************************************************************/ - -package org.eclipse.etrice.generator.c; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.etrice.generator.base.AbstractGenerator; -import org.eclipse.etrice.generator.etricegen.Root; -import org.eclipse.etrice.generator.doc.gen.InstanceDiagramGen; // TODO: fix import -import org.eclipse.etrice.generator.c.gen.Validator; -import org.eclipse.etrice.generator.c.setup.GeneratorModule; -import org.eclipse.xtext.generator.IGenerator; - -import com.google.inject.Inject; - -public class Main extends AbstractGenerator { - - public static final String OPTION_LIB = "-lib"; - public static final String OPTION_GEN_INST_DIAG = "-genInstDiag"; - public static final String OPTION_SAVE_GEN_MODEL = "-saveGenModel"; - - /** - * print usage message to stderr - */ - private static void printUsage() { - output.println(Main.class.getName()+" [-saveGenModel <genmodel path>] [-genInstDiag] [-lib] <list of model file paths>"); - output.println(" <list of model file paths> # model file paths may be specified as"); - output.println(" # e.g. C:\\path\\to\\model\\mymodel.room"); - output.println(" -saveGenModel <genmodel path> # if specified the generator model will be saved to this location"); - output.println(" -genInstDiag # if specified an instance diagram is created for each subsystem"); - output.println(" -lib # if specified all classes are generated and no instances"); - } - - public static void main(String[] args) { - createAndRunGenerator(new GeneratorModule(), args); - } - - @Inject - private IGenerator mainGenerator; - - @Inject - protected InstanceDiagramGen instanceDiagramGenerator; - - @Inject - private Validator validator; - - public void runGenerator(String[] args) { - if (args.length == 0) { - logger.logError(Main.class.getName()+" - aborting: no arguments!", null); - printUsage(); - return; - } - - // parsing arguments - String genModelPath = null; - List<String> uriList = new ArrayList<String>(); - boolean genInstDiag = false; - boolean asLibrary = false; - for (int i=0; i<args.length; ++i) { - if (args[i].equals(OPTION_SAVE_GEN_MODEL)) { - if (++i<args.length) { - genModelPath = convertToURI(args[i]+"/genmodel.egm"); - } - } - else if (args[i].equals(OPTION_GEN_INST_DIAG)) { - genInstDiag = true; - } - else if (args[i].equals(OPTION_LIB)) { - asLibrary = true; - } - else { - uriList.add(convertToURI(args[i])); - } - } - - setupRoomModel(); - - runGenerator(uriList, genModelPath, genInstDiag, asLibrary); - } - - protected boolean runGenerator(List<String> uriList, String genModelPath, boolean genInstDiag, boolean asLibrary) { - ResourceSet rs = resourceSetProvider.get(); - - loadModels(uriList, rs); - - if (!validateModels(rs)) - return false; - - Root genModel = createGeneratorModel(rs, asLibrary, genModelPath); - if (genModel==null) - return false; - - if (!validator.validate(genModel)) - return false; - - logger.logInfo("-- starting code generation"); - fileAccess.setOutputPath("src-gen/"); - mainGenerator.doGenerate(genModel.eResource(), fileAccess); - - if (genInstDiag) { - instanceDiagramGenerator.doGenerate(genModel); - } - logger.logInfo("-- finished code generation"); - - return true; - } -} +/*******************************************************************************
+ * 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)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.c;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.etrice.generator.base.AbstractGenerator;
+import org.eclipse.etrice.generator.etricegen.Root;
+import org.eclipse.etrice.generator.doc.gen.InstanceDiagramGen; // TODO: fix import
+import org.eclipse.etrice.generator.c.gen.Validator;
+import org.eclipse.etrice.generator.c.setup.GeneratorModule;
+import org.eclipse.xtext.generator.IGenerator;
+
+import com.google.inject.Inject;
+
+public class Main extends AbstractGenerator {
+
+ public static final String OPTION_LIB = "-lib";
+ public static final String OPTION_GEN_INST_DIAG = "-genInstDiag";
+ public static final String OPTION_SAVE_GEN_MODEL = "-saveGenModel";
+
+ /**
+ * print usage message to stderr
+ */
+ private static void printUsage() {
+ output.println(Main.class.getName()+" [-saveGenModel <genmodel path>] [-genInstDiag] [-lib] <list of model file paths>");
+ output.println(" <list of model file paths> # model file paths may be specified as");
+ output.println(" # e.g. C:\\path\\to\\model\\mymodel.room");
+ output.println(" -saveGenModel <genmodel path> # if specified the generator model will be saved to this location");
+ output.println(" -genInstDiag # if specified an instance diagram is created for each subsystem");
+ output.println(" -lib # if specified all classes are generated and no instances");
+ }
+
+ public static void main(String[] args) {
+ createAndRunGenerator(new GeneratorModule(), args);
+ }
+
+ @Inject
+ private IGenerator mainGenerator;
+
+ @Inject
+ protected InstanceDiagramGen instanceDiagramGenerator;
+
+ @Inject
+ private Validator validator;
+
+ public void runGenerator(String[] args) {
+ if (args.length == 0) {
+ logger.logError(Main.class.getName()+" - aborting: no arguments!", null);
+ printUsage();
+ return;
+ }
+
+ // parsing arguments
+ String genModelPath = null;
+ List<String> uriList = new ArrayList<String>();
+ boolean genInstDiag = false;
+ boolean asLibrary = false;
+ for (int i=0; i<args.length; ++i) {
+ if (args[i].equals(OPTION_SAVE_GEN_MODEL)) {
+ if (++i<args.length) {
+ genModelPath = convertToURI(args[i]+"/genmodel.egm");
+ }
+ }
+ else if (args[i].equals(OPTION_GEN_INST_DIAG)) {
+ genInstDiag = true;
+ }
+ else if (args[i].equals(OPTION_LIB)) {
+ asLibrary = true;
+ }
+ else {
+ uriList.add(convertToURI(args[i]));
+ }
+ }
+
+ setupRoomModel();
+
+ runGenerator(uriList, genModelPath, genInstDiag, asLibrary);
+ }
+
+ protected boolean runGenerator(List<String> uriList, String genModelPath, boolean genInstDiag, boolean asLibrary) {
+ ResourceSet rs = resourceSetProvider.get();
+
+ loadModels(uriList, rs);
+
+ if (!validateModels(rs))
+ return false;
+
+ Root genModel = createGeneratorModel(rs, asLibrary, genModelPath);
+ if (genModel==null)
+ return false;
+
+ if (!validator.validate(genModel))
+ return false;
+
+ logger.logInfo("-- starting code generation");
+ fileAccess.setOutputPath("src-gen/");
+ mainGenerator.doGenerate(genModel.eResource(), fileAccess);
+
+ if (genInstDiag) {
+ instanceDiagramGenerator.doGenerate(genModel);
+ }
+ logger.logInfo("-- finished code generation");
+
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend index ecb13f00e..33afb139e 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend @@ -1,104 +1,108 @@ -/******************************************************************************* - * 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) - * Thomas Schuetz (changed for C code generator) - * - *******************************************************************************/ - -/* - collection of convenience functions for code generation -*/ - - -package org.eclipse.etrice.generator.c.gen - -import com.google.inject.Inject -import com.google.inject.Singleton -import org.eclipse.etrice.core.room.Message -import org.eclipse.etrice.core.room.RoomClass -import org.eclipse.etrice.generator.etricegen.ExpandedActorClass -import org.eclipse.etrice.generator.etricegen.TransitionChain -import org.eclipse.etrice.generator.generic.ILanguageExtension -import org.eclipse.etrice.generator.generic.LanguageGenerator - - - -@Singleton -class CExtensions implements ILanguageExtension { - - @Inject LanguageGenerator languageGen - - - override String getTypedDataDefinition(Message m) { - return languageGen.getTypedData(m) - } - - // in C no access levels can be defined - override String accessLevelPrivate(){""} - override String accessLevelProtected(){""} - override String accessLevelPublic(){""} - - override String memberAccess(){"self->"} - override String selfPointer(String classname, int argumentCount){ - if (argumentCount>0){ - classname+"* self, " - } - else { - classname+"* self" - } - } - - override String operationScope(String classname, boolean isDeclaration){classname+"_"} - - /* TODO: unify OUT and in an add for loop (also for Java) */ - override String outMessageId(String classname, String messagename){ - return classname+"_OUT_"+messagename; - } - - override String inMessageId(String classname, String messagename){ - return classname+"_IN_"+messagename; - } - - - - - //**** C-Specific - /* TODO: move specific code elsewhere */ - // used - def String getCHeaderFileName(RoomClass rc) { - return rc.name+".h"; - } - - // used - def String getCSourceFileName(RoomClass rc) { - return rc.name+".c"; - } - - def getIncludeGuardString(String filename){ - '''_«filename.toUpperCase»_H_''' - } - - def generateIncludeGuardBegin(String filename){''' - #ifndef «filename.getIncludeGuardString» - #define «filename.getIncludeGuardString» - ''' - } - - def generateIncludeGuardEnd(String filename){''' - #endif /* «filename.getIncludeGuardString» */ - ''' - } - - //------------------------------------------------------- - // transition chain visitor - - def String getExecuteChainCode(ExpandedActorClass ac, TransitionChain tc) { - return languageGen.getExecuteChain(ac, tc) - } +/*******************************************************************************
+ * 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)
+ * Thomas Schuetz (changed for C code generator)
+ *
+ *******************************************************************************/
+
+/*
+ collection of convenience functions for code generation
+*/
+
+
+package org.eclipse.etrice.generator.c.gen
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.RoomClass
+import org.eclipse.etrice.generator.etricegen.ExpandedActorClass
+import org.eclipse.etrice.generator.etricegen.TransitionChain
+import org.eclipse.etrice.generator.generic.ILanguageExtension
+import org.eclipse.etrice.generator.generic.LanguageGenerator
+
+
+
+@Singleton
+class CExtensions implements ILanguageExtension {
+
+ @Inject LanguageGenerator languageGen
+
+
+ override String getTypedDataDefinition(Message m) {
+ return languageGen.getTypedData(m)
+ }
+
+ // in C no access levels can be defined
+ override String accessLevelPrivate(){""}
+ override String accessLevelProtected(){""}
+ override String accessLevelPublic(){""}
+
+ override String memberAccess(){"self->"}
+ override String selfPointer(String classname, int argumentCount){
+ if (argumentCount>0){
+ classname+"* self, "
+ }
+ else {
+ classname+"* self"
+ }
+ }
+
+ override String operationScope(String classname, boolean isDeclaration){classname+"_"}
+
+ /* TODO: unify OUT and in an add for loop (also for Java) */
+ override String outMessageId(String classname, String messagename){
+ return classname+"_OUT_"+messagename;
+ }
+
+ override String inMessageId(String classname, String messagename){
+ return classname+"_IN_"+messagename;
+ }
+
+
+
+
+ //**** C-Specific
+ /* TODO: move specific code elsewhere */
+ // used
+ def String getCHeaderFileName(RoomClass rc) {
+ return rc.name+".h";
+ }
+
+ // used
+ def String getCSourceFileName(RoomClass rc) {
+ return rc.name+".c";
+ }
+
+ def String getInstSourceFileName(RoomClass rc) {
+ return rc.name+"_Inst.h";
+ }
+
+ def getIncludeGuardString(String filename){
+ '''_«filename.toUpperCase»_H_'''
+ }
+
+ def generateIncludeGuardBegin(String filename){'''
+ #ifndef «filename.getIncludeGuardString»
+ #define «filename.getIncludeGuardString»
+ '''
+ }
+
+ def generateIncludeGuardEnd(String filename){'''
+ #endif /* «filename.getIncludeGuardString» */
+ '''
+ }
+
+ //-------------------------------------------------------
+ // transition chain visitor
+
+ def String getExecuteChainCode(ExpandedActorClass ac, TransitionChain tc) {
+ return languageGen.getExecuteChain(ac, tc)
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend index ec4181d09..95622ae79 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/MainGen.xtend @@ -1,53 +1,53 @@ -/******************************************************************************* - * 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.inject.Inject -import com.google.inject.Singleton -import org.eclipse.emf.ecore.resource.Resource -import org.eclipse.etrice.generator.etricegen.Root -import org.eclipse.xtext.generator.IFileSystemAccess -import org.eclipse.xtext.generator.IGenerator -import org.eclipse.etrice.generator.extensions.PrepareFileSystem - -@Singleton -class MainGen implements IGenerator { - - @Inject DataClassGen dataClassGen - @Inject ProtocolClassGen protocolClassGen - @Inject ActorClassGen actorClassGen - @Inject SubSystemClassGen subsystemClassGen - @Inject SubSystemRunnerGen subsystemRunnerGen - @Inject PrepareFileSystem prepFS - - override void doGenerate(Resource resource, IFileSystemAccess fsa) { - prepFS.prepare(resource) - for (e: resource.contents){ - if (e instanceof Root) { - doGenerate(e as Root) - } - } - } - - def void doGenerate(Root e) { - dataClassGen.doGenerate(e); - //protocolClassGen.doGenerate(e); - //actorClassGen.doGenerate(e); - subsystemClassGen.doGenerate(e); - - if (!e.library) { - subsystemRunnerGen.doGenerate(e); - } - } +/*******************************************************************************
+ * 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.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.emf.ecore.resource.Resource
+import org.eclipse.etrice.generator.etricegen.Root
+import org.eclipse.xtext.generator.IFileSystemAccess
+import org.eclipse.xtext.generator.IGenerator
+import org.eclipse.etrice.generator.extensions.PrepareFileSystem
+
+@Singleton
+class MainGen implements IGenerator {
+
+ @Inject DataClassGen dataClassGen
+ @Inject ProtocolClassGen protocolClassGen
+ @Inject ActorClassGen actorClassGen
+ @Inject SubSystemClassGen subsystemClassGen
+ @Inject SubSystemRunnerGen subsystemRunnerGen
+ @Inject PrepareFileSystem prepFS
+
+ override void doGenerate(Resource resource, IFileSystemAccess fsa) {
+ prepFS.prepare(resource)
+ for (e: resource.contents){
+ if (e instanceof Root) {
+ doGenerate(e as Root)
+ }
+ }
+ }
+
+ def void doGenerate(Root e) {
+ dataClassGen.doGenerate(e);
+ protocolClassGen.doGenerate(e);
+ actorClassGen.doGenerate(e);
+ subsystemClassGen.doGenerate(e);
+
+ if (!e.library) {
+ subsystemRunnerGen.doGenerate(e);
+ }
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend index 4210fe897..318ff490e 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ProtocolClassGen.xtend @@ -1,295 +1,346 @@ -/******************************************************************************* - * 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.inject.Inject -import com.google.inject.Singleton -import org.eclipse.etrice.core.room.Message -import org.eclipse.etrice.core.room.ProtocolClass -import org.eclipse.etrice.generator.base.ILogger -import org.eclipse.etrice.generator.etricegen.Root -import org.eclipse.xtext.generator.JavaIoFileSystemAccess - -import org.eclipse.etrice.generator.extensions.RoomExtensions -import org.eclipse.etrice.generator.generic.ProcedureHelpers - - -@Singleton -class ProtocolClassGen { - - @Inject extension JavaIoFileSystemAccess fileAccess - @Inject extension CExtensions stdExt - @Inject extension RoomExtensions roomExt - @Inject extension ProcedureHelpers helpers - @Inject ILogger logger - - def doGenerate(Root root) { - for (pc: root.usedProtocolClasses) { - var path = pc.generationTargetPath+pc.getPath - - logger.logInfo("generating ProtocolClass header '"+pc.getCHeaderFileName+"' in '"+path+"'") - fileAccess.setOutputPath(path) - fileAccess.generateFile(pc.getCHeaderFileName, root.generateHeaderFile(pc)) - - logger.logInfo("generating ProtocolClass source '"+pc.getCSourceFileName+"' in '"+path+"'") - fileAccess.setOutputPath(path) - fileAccess.generateFile(pc.getCSourceFileName, root.generateSourceFile(pc)) - - } - } - - - def generateHeaderFile(Root root, ProtocolClass pc) {''' - #ifndef _«pc.name»_H_ - #define _«pc.name»_H_ - - #include "etDatatypes.h" - - «helpers.UserCode(pc.userCode1)» - - «FOR dataClass : root.getReferencedDataClasses(pc)»#include "«dataClass.name».h" - «ENDFOR» - - typedef struct { - - - } «pc.name»; - - /* message IDs */ - enum { - «pc.name»_MSG_MIN = 0, - /* IDs for outgoing messages */ - «FOR message : pc.getAllOutgoingMessages()» - «outMessageId(pc.name, message.name)» = «pc.getAllOutgoingMessages().indexOf(message)+1», - «ENDFOR» - /* IDs for incoming messages */ - «FOR message : pc.getAllIncomingMessages()» - «inMessageId(pc.name, message.name)» = «pc.getAllIncomingMessages().indexOf(message)+pc.getAllOutgoingMessages().size+1», - «ENDFOR» - /* error if msgID >= MSG_MAX */ - «pc.name»_MSG_MAX = «pc.getAllOutgoingMessages().size + pc.getAllIncomingMessages().size+1» - }; - - /*--------------------- port classes */ - «portClassHeader(pc, false)» - «portClassHeader(pc, true)» -««« «portClass(pc, false)» -««« «portClass(pc, true)» - - /*--------------------- debug helpers */ - - /* get message string for message id */ - const char* «pc.name»_getMessageString(int msg_id); - - «helpers.UserCode(pc.userCode2)» - - - #endif /* _«pc.name»_H_ */ - - ''' - } - - def generateSourceFile(Root root, ProtocolClass pc) {''' - #include "«pc.getCHeaderFileName»" - - /*--------------------- port classes */ - «portClassSource(pc, false)» - «portClassSource(pc, true)» - - /*--------------------- debug helpers */ - «generateDebugHelpersImplementation(root, pc)» - ''' - } - - - - def portClass(ProtocolClass pc, Boolean conj) {''' -««« «var name = pc.getPortClassName(conj)» -««« «var pclass = pc.getPortClass(conj)» - -««« // port class -««« static public class «name» extends PortBase { -««« «IF pclass!=null» -««« «helpers.UserCode(pclass.userCode)» -««« «ENDIF» -««« // constructors -««« public «name»(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) { -««« super(actor, name, localId, 0, addr, peerAddress); -««« DebuggingService.getInstance().addPortInstance(this); -««« } -««« public «name»(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) { -««« super(actor, name, localId, idx, addr, peerAddress); -««« DebuggingService.getInstance().addPortInstance(this); -««« } -««« -««« @Override -««« public void receive(Message m) { -««« if (!(m instanceof EventMessage)) -««« return; -««« EventMessage msg = (EventMessage) m; -««« if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX) -««« System.out.println("unknown"); -««« else { -««« if (messageStrings[msg.getEvtId()] != "timerTick"){ -««« // TODOTS: model switch for activation -««« DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]); -««« } -««« «IF pc.handlesReceive(conj)» -««« switch (msg.getEvtId()) { -««« «FOR hdlr : pc.getReceiveHandlers(conj)» -««« case «hdlr.msg.getCodeName()»: -««« { -««« «FOR command : hdlr.detailCode.commands» -««« «command» -««« «ENDFOR» -««« } -««« break; -««« «ENDFOR» -««« default: -««« «ENDIF» -««« if (msg instanceof EventWithDataMessage) -««« getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData()); -««« else -««« getActor().receiveEvent(this, msg.getEvtId(), null); -««« «IF pc.handlesReceive(conj)» -««« } -««« «ENDIF» -««« } -««« } -««« -««« «IF pclass!=null» -««« «helpers.Attributes(pclass.attributes)» -««« «helpers.OperationsDeclaration(pclass.operations, name)» -««« «ENDIF» -««« -««« // sent messages -««« «FOR m : pc.getOutgoing(conj)» -««« «sendMessage(m, conj)» -««« «ENDFOR» -««« } - -««« // replicated port class -««« static public class «name»Repl { -««« private ArrayList<«name»> ports; -««« private int replication; -««« -««« public «name»Repl(IEventReceiver actor, String name, int localId, Address[] addr, -««« Address[] peerAddress) { -««« replication = addr.length; -««« ports = new ArrayList<«pc.name».«name»>(replication); -««« for (int i=0; i<replication; ++i) { -««« ports.add(new «name»( -««« actor, name+i, localId, i, addr[i], peerAddress[i])); -««« } -««« } -««« -««« public int getReplication() { -««« return replication; -««« } -««« -««« public int getIndexOf(InterfaceItemBase ifitem){ -««« return ifitem.getIdx(); -««« } -««« -««« public «name» get(int i) { -««« return ports.get(i); -««« } -««« -««« «IF conj» -««« // incoming messages -««« «FOR m : pc.getAllIncomingMessages()» -««« «messageSignature(m)»{ -««« for (int i=0; i<replication; ++i) { -««« ports.get(i).«messageCall(m)»; -««« } -««« } -««« «ENDFOR» -««« «ELSE» -««« // outgoing messages -««« «FOR m : pc.getAllOutgoingMessages()» -««« «messageSignature(m)»{ -««« for (int i=0; i<replication; ++i) { -««« ports.get(i).«messageCall(m)»; -««« } -««« } -««« «ENDFOR» -««« «ENDIF» -««« } - - ''' - } - - def portClassHeader(ProtocolClass pc, Boolean conj){ - ''' - «var portClassName = pc.getPortClassName(conj)» - «var pClass = pc.getPortClass(conj)» - - typedef etPort «portClassName»; - - «ClassOperationSignature(portClassName, "MyOperation1", "int a, int b", "void", true)» - «ClassOperationSignature(portClassName, "MyOperation2", "", "int", false)» - - - ''' - } - - def portClassSource(ProtocolClass pc, Boolean conj){ - ''' - «var name = pc.getPortClassName(conj)» - «var pclass = pc.getPortClass(conj)» - - ''' - } - - - def messageSignature(ProtocolClass pc, Message m) {''' - void «pc.name»_«m.name» («IF m.data!=null»«m.data.refType.type.name» «m.data.name»«ENDIF») - ''' - } - - def messageCall(Message m) {''' - «m.name»(«IF m.data!=null» «m.data.name»«ENDIF») - '''} - -// def sendMessage(Message m, boolean conj) {''' -// «var dir = if (conj) "IN" else "OUT"» -// «var hdlr = m.getSendHandler(conj)» -// «messageSignature(m)»{ -// if (getPeerAddress()!=null) -// «IF m.data==null»getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), «dir»_«m.name»)); -// «ELSE»getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), «dir»_«m.name», «m.data.name»«IF (!m.data.ref)».deepCopy()«ENDIF»)); -// «ENDIF» -// } -// ''' -// } - - def generateDebugHelpersImplementation(Root root, ProtocolClass pc){''' - - /* TODO: make this optional or different for smaller footprint */ - /* message names as strings for debugging (generate MSC) */ - static const char* «pc.name»_messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR»«FOR m : pc.getAllIncomingMessages()»"«m.name»", «ENDFOR»"MAX"}; - - const char* «pc.name»_getMessageString(int msg_id) { - if (msg_id<«pc.name»_MSG_MIN || msg_id>«pc.name»_MSG_MAX+1){ - /* id out of range */ - return "Message ID out of range"; - } - else{ - return «pc.name»_messageStrings[msg_id]; - } - } - ''' - } - +/*******************************************************************************
+ * 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.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.room.Message
+import org.eclipse.etrice.core.room.ProtocolClass
+import org.eclipse.etrice.generator.base.ILogger
+import org.eclipse.etrice.generator.etricegen.Root
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+
+import org.eclipse.etrice.generator.extensions.RoomExtensions
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+
+
+@Singleton
+class ProtocolClassGen {
+
+ @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject extension CExtensions stdExt
+ @Inject extension RoomExtensions roomExt
+ @Inject extension ProcedureHelpers helpers
+ @Inject ILogger logger
+
+ def doGenerate(Root root) {
+ for (pc: root.usedProtocolClasses) {
+ var path = pc.generationTargetPath+pc.getPath
+
+ logger.logInfo("generating ProtocolClass header '"+pc.getCHeaderFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(pc.getCHeaderFileName, root.generateHeaderFile(pc))
+
+ logger.logInfo("generating ProtocolClass source '"+pc.getCSourceFileName+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(pc.getCSourceFileName, root.generateSourceFile(pc))
+
+ }
+ }
+
+
+ def generateHeaderFile(Root root, ProtocolClass pc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of ProtocolClass «pc.name»
+ *
+ */
+
+ «generateIncludeGuardBegin(pc.name)»
+
+ #include "etDatatypes.h"
+ #include "etPort.h"
+
+ «helpers.UserCode(pc.userCode1)»
+
+ «FOR dataClass : root.getReferencedDataClasses(pc)»#include "«dataClass.name».h"
+ «ENDFOR»
+
+ /* message IDs */
+ enum {
+ «pc.name»_MSG_MIN = 0,
+ /* IDs for outgoing messages */
+ «FOR message : pc.getAllOutgoingMessages()»
+ «outMessageId(pc.name, message.name)» = «pc.getAllOutgoingMessages().indexOf(message)+1»,
+ «ENDFOR»
+ /* IDs for incoming messages */
+ «FOR message : pc.getAllIncomingMessages()»
+ «inMessageId(pc.name, message.name)» = «pc.getAllIncomingMessages().indexOf(message)+pc.getAllOutgoingMessages().size+1»,
+ «ENDFOR»
+ /* error if msgID >= MSG_MAX */
+ «pc.name»_MSG_MAX = «pc.getAllOutgoingMessages().size + pc.getAllIncomingMessages().size+1»
+ };
+
+ /*--------------------- port classes */
+ «portClassHeader(pc, false)»
+ «portClassHeader(pc, true)»
+««« «portClass(pc, false)»
+««« «portClass(pc, true)»
+
+ /*--------------------- debug helpers */
+
+ /* get message string for message id */
+ const char* «pc.name»_getMessageString(int msg_id);
+
+ «helpers.UserCode(pc.userCode2)»
+
+
+ «generateIncludeGuardEnd(pc.name)»
+
+ '''
+ }
+
+ def generateSourceFile(Root root, ProtocolClass pc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of ProtocolClass «pc.name»
+ *
+ */
+
+ #include "«pc.getCHeaderFileName»"
+
+ #include "etMSCLogger.h"
+
+ /*--------------------- port classes */
+ «portClassSource(pc, false)»
+ «portClassSource(pc, true)»
+
+ /*--------------------- debug helpers */
+ «generateDebugHelpersImplementation(root, pc)»
+ '''
+ }
+
+
+
+ def portClass(ProtocolClass pc, Boolean conj) {'''
+««« «var name = pc.getPortClassName(conj)»
+««« «var pclass = pc.getPortClass(conj)»
+
+««« // port class
+««« static public class «name» extends PortBase {
+««« «IF pclass!=null»
+««« «helpers.UserCode(pclass.userCode)»
+««« «ENDIF»
+««« // constructors
+««« public «name»(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+««« super(actor, name, localId, 0, addr, peerAddress);
+««« DebuggingService.getInstance().addPortInstance(this);
+««« }
+««« public «name»(IEventReceiver actor, String name, int localId, int idx, Address addr, Address peerAddress) {
+««« super(actor, name, localId, idx, addr, peerAddress);
+««« DebuggingService.getInstance().addPortInstance(this);
+««« }
+«««
+««« @Override
+««« public void receive(Message m) {
+««« if (!(m instanceof EventMessage))
+««« return;
+««« EventMessage msg = (EventMessage) m;
+««« if (msg.getEvtId() <= 0 || msg.getEvtId() >= MSG_MAX)
+««« System.out.println("unknown");
+««« else {
+««« if (messageStrings[msg.getEvtId()] != "timerTick"){
+««« // TODOTS: model switch for activation
+««« DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]);
+««« }
+««« «IF pc.handlesReceive(conj)»
+««« switch (msg.getEvtId()) {
+««« «FOR hdlr : pc.getReceiveHandlers(conj)»
+««« case «hdlr.msg.getCodeName()»:
+««« {
+««« «FOR command : hdlr.detailCode.commands»
+««« «command»
+««« «ENDFOR»
+««« }
+««« break;
+««« «ENDFOR»
+««« default:
+««« «ENDIF»
+««« if (msg instanceof EventWithDataMessage)
+««« getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
+««« else
+««« getActor().receiveEvent(this, msg.getEvtId(), null);
+««« «IF pc.handlesReceive(conj)»
+««« }
+««« «ENDIF»
+««« }
+««« }
+«««
+««« «IF pclass!=null»
+««« «helpers.Attributes(pclass.attributes)»
+««« «helpers.OperationsDeclaration(pclass.operations, name)»
+««« «ENDIF»
+«««
+««« // sent messages
+««« «FOR m : pc.getOutgoing(conj)»
+««« «sendMessage(m, conj)»
+««« «ENDFOR»
+««« }
+
+««« // replicated port class
+««« static public class «name»Repl {
+««« private ArrayList<«name»> ports;
+««« private int replication;
+«««
+««« public «name»Repl(IEventReceiver actor, String name, int localId, Address[] addr,
+««« Address[] peerAddress) {
+««« replication = addr.length;
+««« ports = new ArrayList<«pc.name».«name»>(replication);
+««« for (int i=0; i<replication; ++i) {
+««« ports.add(new «name»(
+««« actor, name+i, localId, i, addr[i], peerAddress[i]));
+««« }
+««« }
+«««
+««« public int getReplication() {
+««« return replication;
+««« }
+«««
+««« public int getIndexOf(InterfaceItemBase ifitem){
+««« return ifitem.getIdx();
+««« }
+«««
+««« public «name» get(int i) {
+««« return ports.get(i);
+««« }
+«««
+««« «IF conj»
+««« // incoming messages
+««« «FOR m : pc.getAllIncomingMessages()»
+««« «messageSignature(m)»{
+««« for (int i=0; i<replication; ++i) {
+««« ports.get(i).«messageCall(m)»;
+««« }
+««« }
+««« «ENDFOR»
+««« «ELSE»
+««« // outgoing messages
+««« «FOR m : pc.getAllOutgoingMessages()»
+««« «messageSignature(m)»{
+««« for (int i=0; i<replication; ++i) {
+««« ports.get(i).«messageCall(m)»;
+««« }
+««« }
+««« «ENDFOR»
+««« «ENDIF»
+««« }
+
+ '''
+ }
+
+ def portClassHeader(ProtocolClass pc, Boolean conj){
+ '''
+ «var portClassName = pc.getPortClassName(conj)»
+ «var pClass = pc.getPortClass(conj)»
+
+ typedef etPort «portClassName»;
+
+ «IF !conj»
+««« send functions for outgoing messages
+ «FOR message : pc.getAllOutgoingMessages()»
+ void «portClassName»_«message.name»(const «portClassName»* self);
+ «ENDFOR»
+ «ELSE»
+««« send functions for incoming messages
+ «FOR message : pc.getAllIncomingMessages()»
+ void «portClassName»_«message.name»(const «portClassName»* self);
+ «ENDFOR»
+ «ENDIF»
+
+
+««« «ClassOperationSignature(portClassName, "MyOperation1", "int a, int b", "void", true)»
+««« «ClassOperationSignature(portClassName, "MyOperation2", "", "int", false)»
+
+
+ '''
+ }
+
+ def portClassSource(ProtocolClass pc, Boolean conj){
+ '''
+ «var portClassName = pc.getPortClassName(conj)»
+ «var pClass = pc.getPortClass(conj)»
+
+ «IF !conj»
+««« send functions for outgoing messages
+ «FOR message : pc.getAllOutgoingMessages()»
+ void «portClassName»_«message.name»(const «portClassName»* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("«portClassName»", "«message.name»")
+ etMessage* msg = etMessageService_getMessageBuffer(self->msgService, sizeof(etMessage));
+ msg->address = self->peerAddress;
+ msg->evtID = «outMessageId(pc.name, message.name)»;
+ etMessageService_pushMessage(self->msgService, msg);
+ ET_MSC_LOGGER_SYNC_EXIT
+ }
+ «ENDFOR»
+ «ELSE»
+««« send functions for incoming messages
+ «FOR message : pc.getAllIncomingMessages()»
+ void «portClassName»_«message.name»(const «portClassName»* self){
+ ET_MSC_LOGGER_SYNC_ENTRY("«portClassName»", "«message.name»")
+ etMessage* msg = etMessageService_getMessageBuffer(self->msgService, sizeof(etMessage));
+ msg->address = self->peerAddress;
+ msg->evtID = «inMessageId(pc.name, message.name)»;
+ etMessageService_pushMessage(self->msgService, msg);
+ ET_MSC_LOGGER_SYNC_EXIT
+ }
+ «ENDFOR»
+ «ENDIF»
+
+
+ '''
+ }
+
+
+ def messageSignature(ProtocolClass pc, Message m) {'''
+ void «pc.name»_«m.name» («IF m.data!=null»«m.data.refType.type.name» «m.data.name»«ENDIF»)
+ '''
+ }
+
+ def messageCall(Message m) {'''
+ «m.name»(«IF m.data!=null» «m.data.name»«ENDIF»)
+ '''}
+
+// def sendMessage(Message m, boolean conj) {'''
+// «var dir = if (conj) "IN" else "OUT"»
+// «var hdlr = m.getSendHandler(conj)»
+// «messageSignature(m)»{
+// if (getPeerAddress()!=null)
+// «IF m.data==null»getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), «dir»_«m.name»));
+// «ELSE»getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), «dir»_«m.name», «m.data.name»«IF (!m.data.ref)».deepCopy()«ENDIF»));
+// «ENDIF»
+// }
+// '''
+// }
+
+ def generateDebugHelpersImplementation(Root root, ProtocolClass pc){'''
+
+ /* TODO: make this optional or different for smaller footprint */
+ /* message names as strings for debugging (generate MSC) */
+ static const char* «pc.name»_messageStrings[] = {"MIN", «FOR m : pc.getAllOutgoingMessages()»"«m.name»",«ENDFOR»«FOR m : pc.getAllIncomingMessages()»"«m.name»", «ENDFOR»"MAX"};
+
+ const char* «pc.name»_getMessageString(int msg_id) {
+ if (msg_id<«pc.name»_MSG_MIN || msg_id>«pc.name»_MSG_MAX+1){
+ /* id out of range */
+ return "Message ID out of range";
+ }
+ else{
+ return «pc.name»_messageStrings[msg_id];
+ }
+ }
+ '''
+ }
+
}
\ No newline at end of file diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend index 85e6a6dd0..fcbda3217 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemClassGen.xtend @@ -1,249 +1,356 @@ -/******************************************************************************* - * 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.inject.Inject -import com.google.inject.Singleton -import org.eclipse.etrice.core.room.SubSystemClass -import org.eclipse.etrice.generator.base.ILogger -import org.eclipse.etrice.generator.etricegen.Root -import org.eclipse.etrice.generator.etricegen.ServiceImplInstance -import org.eclipse.etrice.generator.etricegen.SubSystemInstance -import org.eclipse.xtext.generator.JavaIoFileSystemAccess -import org.eclipse.etrice.generator.extensions.RoomExtensions -import org.eclipse.etrice.generator.generic.ProcedureHelpers - -import static extension org.eclipse.etrice.generator.base.Indexed.* - - -@Singleton -class SubSystemClassGen { - - @Inject extension JavaIoFileSystemAccess fileAccess - @Inject extension CExtensions stdExt - @Inject extension RoomExtensions roomExt - @Inject extension ProcedureHelpers helpers - @Inject ILogger logger - - def doGenerate(Root root) { - for (ssi: root.subSystemInstances) { - var path = ssi.subSystemClass.generationTargetPath+ssi.subSystemClass.getPath - var file = ssi.subSystemClass.getCHeaderFileName - logger.logInfo("generating SubSystemClass declaration: '"+file+"' in '"+path+"'") - fileAccess.setOutputPath(path) - fileAccess.generateFile(file, root.generateHeaderFile(ssi, ssi.subSystemClass)) - - file = ssi.subSystemClass.getCSourceFileName - logger.logInfo("generating SubSystemClass implementation: '"+file+"' in '"+path+"'") - fileAccess.setOutputPath(path) - fileAccess.generateFile(file, root.generateSourceFile(ssi, ssi.subSystemClass)) - - } - } - - def generateHeaderFile(Root root, SubSystemInstance ssi, SubSystemClass ssc) {''' - /** - * @author generated by eTrice - * - * Header File of SubSystemClass «ssc.name» - * - */ - - «generateIncludeGuardBegin(ssc.name)» - - - /* lifecycle functions - * init -> start -> run (loop) -> stop -> destroy - */ - - void «ssc.name»_init(void); // lifecycle init - void «ssc.name»_start(void); // lifecycle start - - void «ssc.name»_run(void); - - void «ssc.name»_stop(void); // lifecycle stop - void «ssc.name»_destroy(void); // lifecycle destroy - - - «generateIncludeGuardEnd(ssc.name)» - - - ''' - } - - def generateSourceFile(Root root, SubSystemInstance ssi, SubSystemClass ssc) {''' - /** - * @author generated by eTrice - * - * Source File of SubSystemClass «ssc.name» - * - */ - - #include "«ssc.getCHeaderFileName»" - - #include "etLogger.h" - - /* data for SubSysten «ssc.name» */ - typedef struct «ssc.name» { - char *name; - } «ssc.name»; - - static «ssc.name» «ssc.name»Inst = {"«ssc.name»"}; - - void «ssc.name»_init(void){ - etLogger_logInfoF("%s_init", «ssc.name»Inst.name); - } - - void «ssc.name»_start(void){ - etLogger_logInfoF("%s_start", «ssc.name»Inst.name); - } - - void «ssc.name»_run(void){ - int32 i; - for (i=0; i<100; i++){ - etLogger_logInfoF("%s Scheduler tick %d", «ssc.name»Inst.name, i); - } - } - - void «ssc.name»_stop(void){ - etLogger_logInfoF("%s_stop", «ssc.name»Inst.name); - } - - void «ssc.name»_destroy(void){ - etLogger_logInfoF("%s_destroy", «ssc.name»Inst.name); - } - - - ''' - } - - -// «var models = root.getReferencedModels(ssc)» -// «FOR model : models»import «model.name».*;«ENDFOR» -// -// -// «helpers.UserCode(ssc.userCode1)» -// -// public class «ssi.name» extends SubSystemClassBase{ -// -// «helpers.UserCode(ssc.userCode2)» -// -// public «ssi.name»(IRTObject parent, String name) { -// super(parent, name); -// } -// -// @Override -// public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data){ -// } -// -// @Override -// public void instantiateMessageServices(){ -// -// RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),"MessageService_Main")); -// «FOR thread : ssc.threads» -// RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, «ssc.threads.indexOf(thread)+1», 0),"MessageService_«thread.name»", «thread.prio»)); -// «ENDFOR» -// } -// -// @Override -// public void instantiateActors(){ -// // all addresses -// // Addresses for the Subsystem Systemport -// «FOR ai : ssi.allContainedInstances.indexed(ssi.maxObjId)» -// Address addr_item_SystemPort_«ssi.allContainedInstances.indexOf(ai.value)» = new Address(0,0,«ai.index1»); -// «ENDFOR» -// -// «FOR ai : ssi.allContainedInstances» -// // actor instance «ai.path» itself => Systemport Address -// // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport) -// Address addr_item_«ai.path.getPathName()» = new Address(0,«ai.threadId»,«ai.objId»); -// // interface items of «ai.path» -// «FOR pi : ai.orderedIfItemInstances» -// «IF pi instanceof ServiceImplInstance || pi.peers.size>1» -// «FOR peer : pi.peers» -// «var i = pi.peers.indexOf(peer)» -// Address addr_item_«pi.path.getPathName()»_«i» = new Address(0,«pi.threadId»,«pi.objId+i»); -// «ENDFOR» -// «ELSE» -// Address addr_item_«pi.path.getPathName()» = new Address(0,«ai.threadId»,«pi.objId»); -// «ENDIF» -// «ENDFOR» -// «ENDFOR» -// -// // instantiate all actor instances -// instances = new ActorClassBase[«ssi.allContainedInstances.size»]; -// «FOR ai : ssi.allContainedInstances» -// instances[«ssi.allContainedInstances.indexOf(ai)»] = new «ai.actorClass.name»( -// «IF ai.eContainer instanceof SubSystemInstance» -// this, -// «ELSE» -// instances[«ssi.allContainedInstances.indexOf(ai.eContainer)»], -// «ENDIF» -// "«ai.name»", -// // own interface item addresses -// new Address[][] {{addr_item_«ai.path.getPathName()»}«IF !ai.orderedIfItemInstances.empty»,«ENDIF» -// «FOR pi : ai.orderedIfItemInstances SEPARATOR ","» -// { -// «IF pi instanceof ServiceImplInstance || pi.peers.size>1» -// «FOR peer : pi.peers SEPARATOR ","» -// addr_item_«pi.path.getPathName()»_«pi.peers.indexOf(peer)» -// «ENDFOR» -// «ELSE» -// addr_item_«pi.path.getPathName()» -// «ENDIF» -// } -// «ENDFOR» -// }, -// // peer interface item addresses -// new Address[][] {{addr_item_SystemPort_«ssi.allContainedInstances.indexOf(ai)»}«IF !ai.orderedIfItemInstances.empty»,«ENDIF» -// «FOR pi : ai.orderedIfItemInstances SEPARATOR ","» -// { -// «IF !(pi instanceof ServiceImplInstance) && pi.peers.isEmpty» -// null -// «ELSE» -// «FOR pp : pi.peers SEPARATOR ","» -// «IF pp instanceof ServiceImplInstance || pp.peers.size>1» -// addr_item_«pp.path.getPathName()»_«pp.peers.indexOf(pi)» -// «ELSE» -// addr_item_«pp.path.getPathName()» -// «ENDIF» -// «ENDFOR» -// «ENDIF» -// } -// «ENDFOR» -// } -// ); -// «ENDFOR» -// -// // create the subsystem system port -// RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, "RTSystemPort", -// 0, //local ID -// // own addresses -// new Address[]{ -// «FOR ai : ssi.allContainedInstances SEPARATOR ","» -// addr_item_SystemPort_«ssi.allContainedInstances.indexOf(ai)» -// «ENDFOR» -// }, -// // peer addresses -// new Address[]{ -// «FOR ai : ssi.allContainedInstances SEPARATOR ","» -// addr_item_«ai.path.getPathName()» -// «ENDFOR» -// }); -// -// } -// }; - - +/*******************************************************************************
+ * 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.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.room.SubSystemClass
+import org.eclipse.etrice.generator.base.ILogger
+import org.eclipse.etrice.generator.etricegen.Root
+import org.eclipse.etrice.generator.etricegen.ServiceImplInstance
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.generator.extensions.RoomExtensions
+import org.eclipse.etrice.generator.generic.ProcedureHelpers
+
+import static extension org.eclipse.etrice.generator.base.Indexed.*
+
+
+@Singleton
+class SubSystemClassGen {
+
+ @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject extension CExtensions stdExt
+ @Inject extension RoomExtensions roomExt
+ @Inject extension ProcedureHelpers helpers
+ @Inject ILogger logger
+
+ def doGenerate(Root root) {
+ for (ssi: root.subSystemInstances) {
+ var path = ssi.subSystemClass.generationTargetPath+ssi.subSystemClass.getPath
+ var file = ssi.subSystemClass.getCHeaderFileName
+ logger.logInfo("generating SubSystemClass declaration: '"+file+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(file, root.generateHeaderFile(ssi, ssi.subSystemClass))
+
+ file = ssi.subSystemClass.getCSourceFileName
+ logger.logInfo("generating SubSystemClass implementation: '"+file+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(file, root.generateSourceFile(ssi, ssi.subSystemClass))
+
+ file = ssi.subSystemClass.getInstSourceFileName
+ logger.logInfo("generating SubSystemClass instance file: '"+file+"' in '"+path+"'")
+ fileAccess.setOutputPath(path)
+ fileAccess.generateFile(file, root.generateInstanceFile(ssi, ssi.subSystemClass))
+ }
+ }
+
+ def generateHeaderFile(Root root, SubSystemInstance ssi, SubSystemClass ssc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Header File of SubSystemClass «ssc.name»
+ *
+ */
+
+ «generateIncludeGuardBegin(ssc.name)»
+
+
+ /* lifecycle functions
+ * init -> start -> run (loop) -> stop -> destroy
+ */
+
+ void «ssc.name»_init(void); /* lifecycle init */
+ void «ssc.name»_start(void); /* lifecycle start */
+
+ void «ssc.name»_run(void); /* lifecycle run */
+
+ void «ssc.name»_stop(void); /* lifecycle stop */
+ void «ssc.name»_destroy(void); /* lifecycle destroy */
+
+
+ «generateIncludeGuardEnd(ssc.name)»
+
+
+ '''
+ }
+
+ def generateSourceFile(Root root, SubSystemInstance ssi, SubSystemClass ssc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Source File of SubSystemClass «ssc.name»
+ *
+ */
+
+ #include "«ssc.getCHeaderFileName»"
+
+ /* include instances for all classes */
+ #include "«ssc.getInstSourceFileName»"
+
+ #include "etLogger.h"
+ #include "etMSCLogger.h"
+
+
+ /* data for SubSysten «ssc.name» */
+ typedef struct «ssc.name» {
+ char *name;
+ } «ssc.name»;
+
+ static «ssc.name» «ssc.name»Inst = {"«ssc.name»"};
+
+ void «ssc.name»_initActorInstances(void);
+
+ void «ssc.name»_init(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("SubSys", "init")
+ etLogger_logInfoF("%s_init", «ssc.name»Inst.name);
+
+ /* initialization of all message services */
+ etMessageService_init(&msgService_Thread1, msgBuffer_Thread1, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE);
+
+ /* init all actors */
+ «ssc.name»_initActorInstances();
+
+ ET_MSC_LOGGER_SYNC_EXIT
+ }
+
+ void «ssc.name»_start(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("SubSys", "start")
+ etLogger_logInfoF("%s_start", «ssc.name»Inst.name);
+ ET_MSC_LOGGER_SYNC_EXIT
+ }
+
+ void «ssc.name»_run(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("SubSys", "run")
+ int32 i;
+ for (i=0; i<100; i++){
+ etLogger_logInfoF("%s Scheduler tick %d", «ssc.name»Inst.name, i);
+ etMessageService_execute(&msgService_Thread1);
+ }
+ ET_MSC_LOGGER_SYNC_EXIT
+ }
+
+ void «ssc.name»_stop(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("SubSys", "stop")
+ etLogger_logInfoF("%s_stop", «ssc.name»Inst.name);
+ ET_MSC_LOGGER_SYNC_EXIT
+ }
+
+ void «ssc.name»_destroy(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("SubSys", "destroy")
+ etLogger_logInfoF("%s_destroy", «ssc.name»Inst.name);
+ ET_MSC_LOGGER_SYNC_EXIT
+ }
+
+ void «ssc.name»_initActorInstances(void){
+ ET_MSC_LOGGER_SYNC_ENTRY("«ssc.name»", "initActorInstances")
+ «FOR ai : ssi.allContainedInstances»
+ «ai.actorClass.name»_init(&«ai.path.getPathName()»);
+ «ENDFOR»
+ ET_MSC_LOGGER_SYNC_EXIT
+ }
+
+ '''
+ }
+
+ def generateInstanceFile(Root root, SubSystemInstance ssi, SubSystemClass ssc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * Instance File of SubSystemClass «ssc.name»
+ * - instantiation of all actor instances and port instances
+ * - configuration of data and connection of ports
+ */
+
+ #include "etMessageService.h"
+
+ /* instantiation of message services */
+ #define MESSAGE_POOL_MAX 10
+ #define MESSAGE_BLOCK_SIZE 32
+ /* MessageService for Thread1 */
+ uint8 msgBuffer_Thread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE];
+ etMessageService msgService_Thread1;
+
+
+ /* include all used ActorClasses */
+ /* TODO: only include used Actor Classes for current SubSystem */
+ «FOR actorClass : root.getUsedActorClasses()»#include "«actorClass.name».h"
+ «ENDFOR»
+
+ /* include all used ProtcolClasses */
+ «FOR protocolClass : root.getUsedProtocolClasses()»#include "«protocolClass.name».h"
+ «ENDFOR»
+
+
+ /* declarations of all ActorClass instances (const and variable structs) */
+
+ /* forward declaration of varible actor structs */
+ «FOR ai : ssi.allContainedInstances»
+ static «ai.actorClass.name» «ai.path.getPathName()»;
+ «ENDFOR»
+
+ «FOR ai : ssi.allContainedInstances»
+
+ /* instance «ai.path.getPathName()» */
+ static const «ai.actorClass.name»_const «ai.path.getPathName()»_const = {
+ &«ai.path.getPathName()»,
+ /* Ports: {myActor, etReceiveMessage, msgService, peerAddress, localId} */
+ «FOR port : ai.actorClass.endPorts»
+ {&«ai.path.getPathName()», «ai.actorClass.name»_ReceiveMessage, &msgService_Thread1, 1, 123} /* Port «port.name» */
+ «ENDFOR»
+
+ };
+ static «ai.actorClass.name» «ai.path.getPathName()» = {&«ai.path.getPathName()»_const};
+ «ENDFOR»
+
+
+««« «FOR ai : ssi.allContainedInstances»
+««« // actor instance «ai.path» itself => Systemport Address
+««« // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+««« Address addr_item_«ai.path.getPathName()» = new Address(0,«ai.threadId»,«ai.objId»);
+««« // interface items of «ai.path»
+««« «FOR pi : ai.orderedIfItemInstances»
+««« «IF pi instanceof ServiceImplInstance || pi.peers.size>1»
+««« «FOR peer : pi.peers»
+««« «var i = pi.peers.indexOf(peer)»
+««« Address addr_item_«pi.path.getPathName()»_«i» = new Address(0,«pi.threadId»,«pi.objId+i»);
+««« «ENDFOR»
+««« «ELSE»
+««« Address addr_item_«pi.path.getPathName()» = new Address(0,«ai.threadId»,«pi.objId»);
+««« «ENDIF»
+««« «ENDFOR»
+««« «ENDFOR»
+
+ '''
+ }
+
+
+// «var models = root.getReferencedModels(ssc)»
+// «FOR model : models»import «model.name».*;«ENDFOR»
+//
+//
+// «helpers.UserCode(ssc.userCode1)»
+//
+// public class «ssi.name» extends SubSystemClassBase{
+//
+// «helpers.UserCode(ssc.userCode2)»
+//
+// public «ssi.name»(IRTObject parent, String name) {
+// super(parent, name);
+// }
+//
+// @Override
+// public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data){
+// }
+//
+// @Override
+// public void instantiateMessageServices(){
+//
+// RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, 0, 0),"MessageService_Main"));
+// «FOR thread : ssc.threads»
+// RTServices.getInstance().getMsgSvcCtrl().addMsgSvc(new MessageService(this, new Address(0, «ssc.threads.indexOf(thread)+1», 0),"MessageService_«thread.name»", «thread.prio»));
+// «ENDFOR»
+// }
+//
+// @Override
+// public void instantiateActors(){
+// // all addresses
+// // Addresses for the Subsystem Systemport
+// «FOR ai : ssi.allContainedInstances.indexed(ssi.maxObjId)»
+// Address addr_item_SystemPort_«ssi.allContainedInstances.indexOf(ai.value)» = new Address(0,0,«ai.index1»);
+// «ENDFOR»
+//
+// «FOR ai : ssi.allContainedInstances»
+// // actor instance «ai.path» itself => Systemport Address
+// // TODOTJ: For each Actor, multiple addresses should be generated (actor?, systemport, debugport)
+// Address addr_item_«ai.path.getPathName()» = new Address(0,«ai.threadId»,«ai.objId»);
+// // interface items of «ai.path»
+// «FOR pi : ai.orderedIfItemInstances»
+// «IF pi instanceof ServiceImplInstance || pi.peers.size>1»
+// «FOR peer : pi.peers»
+// «var i = pi.peers.indexOf(peer)»
+// Address addr_item_«pi.path.getPathName()»_«i» = new Address(0,«pi.threadId»,«pi.objId+i»);
+// «ENDFOR»
+// «ELSE»
+// Address addr_item_«pi.path.getPathName()» = new Address(0,«ai.threadId»,«pi.objId»);
+// «ENDIF»
+// «ENDFOR»
+// «ENDFOR»
+//
+// // instantiate all actor instances
+// instances = new ActorClassBase[«ssi.allContainedInstances.size»];
+// «FOR ai : ssi.allContainedInstances»
+// instances[«ssi.allContainedInstances.indexOf(ai)»] = new «ai.actorClass.name»(
+// «IF ai.eContainer instanceof SubSystemInstance»
+// this,
+// «ELSE»
+// instances[«ssi.allContainedInstances.indexOf(ai.eContainer)»],
+// «ENDIF»
+// "«ai.name»",
+// // own interface item addresses
+// new Address[][] {{addr_item_«ai.path.getPathName()»}«IF !ai.orderedIfItemInstances.empty»,«ENDIF»
+// «FOR pi : ai.orderedIfItemInstances SEPARATOR ","»
+// {
+// «IF pi instanceof ServiceImplInstance || pi.peers.size>1»
+// «FOR peer : pi.peers SEPARATOR ","»
+// addr_item_«pi.path.getPathName()»_«pi.peers.indexOf(peer)»
+// «ENDFOR»
+// «ELSE»
+// addr_item_«pi.path.getPathName()»
+// «ENDIF»
+// }
+// «ENDFOR»
+// },
+// // peer interface item addresses
+// new Address[][] {{addr_item_SystemPort_«ssi.allContainedInstances.indexOf(ai)»}«IF !ai.orderedIfItemInstances.empty»,«ENDIF»
+// «FOR pi : ai.orderedIfItemInstances SEPARATOR ","»
+// {
+// «IF !(pi instanceof ServiceImplInstance) && pi.peers.isEmpty»
+// null
+// «ELSE»
+// «FOR pp : pi.peers SEPARATOR ","»
+// «IF pp instanceof ServiceImplInstance || pp.peers.size>1»
+// addr_item_«pp.path.getPathName()»_«pp.peers.indexOf(pi)»
+// «ELSE»
+// addr_item_«pp.path.getPathName()»
+// «ENDIF»
+// «ENDFOR»
+// «ENDIF»
+// }
+// «ENDFOR»
+// }
+// );
+// «ENDFOR»
+//
+// // create the subsystem system port
+// RTSystemPort = new RTSystemServicesProtocolConjPortRepl(this, "RTSystemPort",
+// 0, //local ID
+// // own addresses
+// new Address[]{
+// «FOR ai : ssi.allContainedInstances SEPARATOR ","»
+// addr_item_SystemPort_«ssi.allContainedInstances.indexOf(ai)»
+// «ENDFOR»
+// },
+// // peer addresses
+// new Address[]{
+// «FOR ai : ssi.allContainedInstances SEPARATOR ","»
+// addr_item_«ai.path.getPathName()»
+// «ENDFOR»
+// });
+//
+// }
+// };
+
+
}
\ No newline at end of file diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend index f6323b81d..740c0b0f9 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/SubSystemRunnerGen.xtend @@ -1,77 +1,81 @@ -/******************************************************************************* - * 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.inject.Inject -import com.google.inject.Singleton -import org.eclipse.etrice.core.room.SubSystemClass -import org.eclipse.etrice.generator.etricegen.Root -import org.eclipse.etrice.generator.etricegen.SubSystemInstance -import org.eclipse.xtext.generator.JavaIoFileSystemAccess -import org.eclipse.etrice.generator.extensions.RoomExtensions - -@Singleton -class SubSystemRunnerGen { - - @Inject extension JavaIoFileSystemAccess fileAccess - @Inject extension RoomExtensions roomExt - - def doGenerate(Root root) { - for (sc: root.subSystemInstances) { - fileAccess.setOutputPath(sc.subSystemClass.generationTargetPath+sc.subSystemClass.getPath) - fileAccess.generateFile( sc.name+"_Runner.c", root.generateSourceFile(sc, sc.subSystemClass)) - } - } - - def generateSourceFile(Root root, SubSystemInstance ssi, SubSystemClass ssc) {''' - /** - * @author generated by eTrice - * - * this class contains the main function running component «ssi.name» - * it instantiates «ssi.name» and starts and ends the lifecycle - */ - - - #include "«ssi.name».h" - - #include "etLogger.h" - - /** - * main function - * creates component and starts and stops the lifecycle - */ - - int main(void) { - - etLogger_logInfo("*** T H E B E G I N ***"); - - /* startup sequence of lifecycle */ - «ssi.name»_init(); /* lifecycle init */ - «ssi.name»_start(); /* lifecycle start */ - - /* run Scheduler */ - «ssi.name»_run(); - - /* shutdown sequence of lifecycle */ - «ssi.name»_stop(); /* lifecycle stop */ - «ssi.name»_destroy(); /* lifecycle destroy */ - - etLogger_logInfo("*** T H E E N D ***"); - - return 0; - } - - ''' - } +/*******************************************************************************
+ * 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.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.etrice.core.room.SubSystemClass
+import org.eclipse.etrice.generator.etricegen.Root
+import org.eclipse.etrice.generator.etricegen.SubSystemInstance
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess
+import org.eclipse.etrice.generator.extensions.RoomExtensions
+
+@Singleton
+class SubSystemRunnerGen {
+
+ @Inject extension JavaIoFileSystemAccess fileAccess
+ @Inject extension RoomExtensions roomExt
+
+ def doGenerate(Root root) {
+ for (sc: root.subSystemInstances) {
+ fileAccess.setOutputPath(sc.subSystemClass.generationTargetPath+sc.subSystemClass.getPath)
+ fileAccess.generateFile( sc.name+"_Runner.c", root.generateSourceFile(sc, sc.subSystemClass))
+ }
+ }
+
+ def generateSourceFile(Root root, SubSystemInstance ssi, SubSystemClass ssc) {'''
+ /**
+ * @author generated by eTrice
+ *
+ * this class contains the main function running component «ssi.name»
+ * it instantiates «ssi.name» and starts and ends the lifecycle
+ */
+
+
+ #include "«ssi.name».h"
+
+ #include "etLogger.h"
+ #include "etMSCLogger.h"
+
+
+ /**
+ * main function
+ * creates component and starts and stops the lifecycle
+ */
+
+ int main(void) {
+
+ etLogger_logInfo("*** T H E B E G I N ***");
+ ET_MSC_LOGGER_OPEN("main");
+
+ /* startup sequence of lifecycle */
+ «ssi.name»_init(); /* lifecycle init */
+ «ssi.name»_start(); /* lifecycle start */
+
+ /* run Scheduler */
+ «ssi.name»_run();
+
+ /* shutdown sequence of lifecycle */
+ «ssi.name»_stop(); /* lifecycle stop */
+ «ssi.name»_destroy(); /* lifecycle destroy */
+
+ ET_MSC_LOGGER_CLOSE
+ etLogger_logInfo("*** T H E E N D ***");
+
+ return 0;
+ }
+
+ '''
+ }
}
\ No newline at end of file diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/Validator.java b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/Validator.java index 7b6b5d98e..e46f7c165 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/Validator.java +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/Validator.java @@ -1,26 +1,26 @@ -/******************************************************************************* - * 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) - * - *******************************************************************************/ - -package org.eclipse.etrice.generator.c.gen; - -import org.eclipse.etrice.generator.etricegen.Root; - -/** - * @author Henrik Rentz-Reichert - * - */ -public class Validator { - - public boolean validate(Root genModel) { - return true; - } -} +/*******************************************************************************
+ * 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)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.c.gen;
+
+import org.eclipse.etrice.generator.etricegen.Root;
+
+/**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public class Validator {
+
+ public boolean validate(Root genModel) {
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java index 1c87ef5dc..32deefc75 100644 --- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java +++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorModule.java @@ -1,39 +1,39 @@ -/******************************************************************************* - * 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) - * - *******************************************************************************/ - -package org.eclipse.etrice.generator.c.setup; - -import org.eclipse.etrice.generator.base.AbstractGenerator; -import org.eclipse.etrice.generator.base.GeneratorBaseModule; -import org.eclipse.etrice.generator.c.Main; -import org.eclipse.etrice.generator.c.gen.MainGen; -import org.eclipse.etrice.generator.generic.ILanguageExtension; -import org.eclipse.xtext.generator.IGenerator; -import org.eclipse.etrice.generator.c.gen.CExtensions; - -import com.google.inject.Binder; - -public class GeneratorModule extends GeneratorBaseModule { - -// @Override - public void configure(Binder binder) { - super.configure(binder); - - binder.bind(AbstractGenerator.class).to(Main.class); - binder.bind(IGenerator.class).to(MainGen.class); - - // bind language specific code to generic Interfaces - binder.bind(ILanguageExtension.class).to(CExtensions.class); - - } - -} +/*******************************************************************************
+ * 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)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.c.setup;
+
+import org.eclipse.etrice.generator.base.AbstractGenerator;
+import org.eclipse.etrice.generator.base.GeneratorBaseModule;
+import org.eclipse.etrice.generator.c.Main;
+import org.eclipse.etrice.generator.c.gen.MainGen;
+import org.eclipse.etrice.generator.generic.ILanguageExtension;
+import org.eclipse.xtext.generator.IGenerator;
+import org.eclipse.etrice.generator.c.gen.CExtensions;
+
+import com.google.inject.Binder;
+
+public class GeneratorModule extends GeneratorBaseModule {
+
+// @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+
+ binder.bind(AbstractGenerator.class).to(Main.class);
+ binder.bind(IGenerator.class).to(MainGen.class);
+
+ // bind language specific code to generic Interfaces
+ binder.bind(ILanguageExtension.class).to(CExtensions.class);
+
+ }
+
+}
|