diff options
Diffstat (limited to 'examples')
28 files changed, 1863 insertions, 0 deletions
diff --git a/examples/org.eclipse.etrice.tutorials.c/.cproject b/examples/org.eclipse.etrice.tutorials.c/.cproject new file mode 100644 index 000000000..f81c6738f --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/.cproject @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?> + +<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> + <storageModule moduleId="org.eclipse.cdt.core.settings"> + <cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.debug.332073761"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.debug.332073761" moduleId="org.eclipse.cdt.core.settings" name="Debug"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.debug.332073761" name="Debug" parent="cdt.managedbuild.config.gnu.mingw.exe.debug"> + <folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.debug.332073761." name="/" resourcePath=""> + <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.debug.398564850" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.debug"> + <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.debug.1829109580" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.debug"/> + <builder buildPath="${workspace_loc:/org.eclipse.etrice.tutorials.c/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.856247028" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/> + <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug.1509057272" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1460359562" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.48213125" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug.1958071026" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.debug"> + <option id="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level.1447113587" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> + <option id="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level.559425075" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.137613907" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug"> + <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.exe.debug.option.optimization.level.1729303001" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.debug.option.optimization.level" valueType="enumerated"/> + <option id="gnu.c.compiler.mingw.exe.debug.option.debugging.level.145157070" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> + <option id="gnu.c.compiler.option.include.paths.327861845" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/org.eclipse.etrice.runtime.c/src/common}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/org.eclipse.etrice.runtime.c/src/config}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/org.eclipse.etrice.runtime.c/src/platforms/generic}""/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.533629505" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug.319733671" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug"> + <option id="gnu.c.link.option.paths.819761090" superClass="gnu.c.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/org.eclipse.etrice.runtime.c/Debug}""/> + </option> + <option id="gnu.c.link.option.libs.1013803342" superClass="gnu.c.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" value="org.eclipse.etrice.runtime.c"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.506258125" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug.1214027870" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.debug"/> + </toolChain> + </folderInfo> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + <cconfiguration id="cdt.managedbuild.config.gnu.mingw.exe.release.1584531196"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.mingw.exe.release.1584531196" moduleId="org.eclipse.cdt.core.settings" name="Release"> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.mingw.exe.release.1584531196" name="Release" parent="cdt.managedbuild.config.gnu.mingw.exe.release"> + <folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.release.1584531196." name="/" resourcePath=""> + <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.release.1134127031" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.release"> + <targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.release.922928036" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.release"/> + <builder buildPath="${workspace_loc:/org.eclipse.etrice.tutorials.c/Release}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.462260253" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/> + <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release.372228887" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.release"> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.2135748071" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1157198261" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release.2109801791" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release"> + <option id="gnu.cpp.compiler.mingw.exe.release.option.optimization.level.223357319" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/> + <option id="gnu.cpp.compiler.mingw.exe.release.option.debugging.level.1181424034" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.48613690" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release"> + <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.exe.release.option.optimization.level.510402959" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.release.option.optimization.level" valueType="enumerated"/> + <option id="gnu.c.compiler.mingw.exe.release.option.debugging.level.1826357245" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1173535425" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + </tool> + <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release.121611690" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.release"> + <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.484005163" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release.489779988" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.exe.release"/> + </toolChain> + </folderInfo> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + </cconfiguration> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <project id="org.eclipse.etrice.tutorials.c.cdt.managedbuild.target.gnu.mingw.exe.395320964" name="Executable" projectType="cdt.managedbuild.target.gnu.mingw.exe"/> + </storageModule> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.release.1584531196;cdt.managedbuild.config.gnu.mingw.exe.release.1584531196.;cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.48613690;cdt.managedbuild.tool.gnu.c.compiler.input.1173535425"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.mingw.exe.debug.332073761;cdt.managedbuild.config.gnu.mingw.exe.debug.332073761.;cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.137613907;cdt.managedbuild.tool.gnu.c.compiler.input.533629505"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> + </scannerConfigBuildInfo> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="refreshScope" versionNumber="2"> + <configuration configurationName="Release"> + <resource resourceType="PROJECT" workspacePath="/org.eclipse.etrice.tutorials.c"/> + </configuration> + <configuration configurationName="Debug"> + <resource resourceType="PROJECT" workspacePath="/org.eclipse.etrice.tutorials.c"/> + </configuration> + </storageModule> +</cproject> diff --git a/examples/org.eclipse.etrice.tutorials.c/.project b/examples/org.eclipse.etrice.tutorials.c/.project new file mode 100644 index 000000000..0c9a8ad83 --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/.project @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.etrice.tutorials.c</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <triggers>clean,full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <triggers>full,incremental,</triggers> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + </natures> +</projectDescription> diff --git a/examples/org.eclipse.etrice.tutorials.c/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/examples/org.eclipse.etrice.tutorials.c/.settings/org.eclipse.cdt.managedbuilder.core.prefs new file mode 100644 index 000000000..0d1a951fd --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.332073761/CPATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.332073761/CPATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.332073761/C_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.332073761/C_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.332073761/append=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.332073761/appendContributed=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.332073761/LIBRARY_PATH/delimiter=; +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.332073761/LIBRARY_PATH/operation=remove +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.332073761/append=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.332073761/appendContributed=true diff --git a/examples/org.eclipse.etrice.tutorials.c/Debug/org.eclipse.etrice.tutorials.c.exe b/examples/org.eclipse.etrice.tutorials.c/Debug/org.eclipse.etrice.tutorials.c.exe Binary files differnew file mode 100644 index 000000000..3f7b4392e --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/Debug/org.eclipse.etrice.tutorials.c.exe diff --git a/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/ACParser.o b/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/ACParser.o Binary files differnew file mode 100644 index 000000000..c7e156a5c --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/ACParser.o diff --git a/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/AFileReader.o b/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/AFileReader.o Binary files differnew file mode 100644 index 000000000..db9b9fd55 --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/AFileReader.o diff --git a/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/ATop.o b/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/ATop.o Binary files differnew file mode 100644 index 000000000..77c7c243b --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/ATop.o diff --git a/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/FileReaderProtocol.o b/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/FileReaderProtocol.o Binary files differnew file mode 100644 index 000000000..a822d254b --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/FileReaderProtocol.o diff --git a/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/RemoveCommentSubSys.o b/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/RemoveCommentSubSys.o Binary files differnew file mode 100644 index 000000000..b0ee2e33e --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/RemoveCommentSubSys.o diff --git a/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/RemoveCommentSubSys_Runner.o b/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/RemoveCommentSubSys_Runner.o Binary files differnew file mode 100644 index 000000000..f4b2706d0 --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/Debug/src-gen/RemoveComment/RemoveCommentSubSys_Runner.o diff --git a/examples/org.eclipse.etrice.tutorials.c/gen_org.eclipse.etrice.tutorials.c.launch b/examples/org.eclipse.etrice.tutorials.c/gen_org.eclipse.etrice.tutorials.c.launch new file mode 100644 index 000000000..e95f078cf --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/gen_org.eclipse.etrice.tutorials.c.launch @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.etrice.generator.launch.c.launchConfigurationType"> +<booleanAttribute key="GenInstanceDiagram" value="false"/> +<stringAttribute key="GenModelPath" value=""/> +<booleanAttribute key="Lib" value="false"/> +<listAttribute key="ModelFiles"> +<listEntry value="${workspace_loc:/org.eclipse.etrice.tutorials.c/model/RemoveComment/RemoveComment.room}"/> +</listAttribute> +<booleanAttribute key="SaveGenModel" value="false"/> +<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/> +</launchConfiguration> diff --git a/examples/org.eclipse.etrice.tutorials.c/model/RemoveComment/RemoveComment.room b/examples/org.eclipse.etrice.tutorials.c/model/RemoveComment/RemoveComment.room new file mode 100644 index 000000000..6b360941b --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/model/RemoveComment/RemoveComment.room @@ -0,0 +1,178 @@ +RoomModel RemoveComment { + import room.basic.types.* from "Types.room" + SubSystemClass RemoveCommentSubSys { + ActorRef Topref:ATop + } + ActorClass ATop { + Structure { + ActorRef reader: AFileReader + ActorRef cParser: ACParser + Binding reader.outPort and cParser.readerPort + } + Behavior { } + } + ActorClass AFileReader{ + Interface { + Port outPort: FileReaderProtocol + } + Structure { + usercode3{"#include <stdio.h>" + } + external Port outPort + Attribute f:file ref + } + Behavior { + StateMachine { + Transition init: initial -> reading { + action { + "if ((f = fopen(\"test.txt\",\"r\")) != 0) {" + "\tprintf(\"file open ok !\\r\\n\");" + "\t}" + "\telse {" + "\tprintf(\"file not found !\\r\\n\");" + "\tSubSysClass_shutdown();" + "\t}" + } + } + Transition tr0: reading -> reading { + triggers { + <getNextChar: outPort> + } + action { + "int8 c;" + "if ((c=fgetc(f)) != EOF) {" + "\toutPort.nextChar(c);" + "\t}" + "\telse {" + "\tfclose(f);" + "\tprintf(\"file closed !\\r\\n\");" + "\tSubSysClass_shutdown();" + "\t}" + } + } + State reading + } + } + } + ActorClass ACParser{ + Interface { + conjugated Port readerPort: FileReaderProtocol + } + Structure { + external Port readerPort + } + Behavior { + StateMachine { + Transition init: initial -> code { + action { + "readerPort.getNextChar();" + } + } + Transition tr0: code -> cp cp0 { + triggers { + <nextChar: readerPort> + } + action { + "readerPort.getNextChar();" + } + } + Transition tr1: cp cp0 -> code { + action { + "printf(\"%c\",c);" + } + } + Transition tr2: cp cp0 -> firstSlash { + cond { + "c==\'/\'" + } + } + Transition tr3: firstSlash -> cp cp1 { + triggers { + <nextChar: readerPort> + } + action { + "readerPort.getNextChar();" + } + } + Transition tr4: cp cp1 -> cp cp4 + Transition tr5: cp cp1 -> blockComment { + cond { + "c==\'*\'" + } + } + Transition tr6: blockComment -> cp cp2 { + triggers { + <nextChar: readerPort> + } + action { + "readerPort.getNextChar();" + } + } + Transition tr7: cp cp2 -> blockComment + Transition tr8: cp cp2 -> firstStar { + cond { + "c==\'*\'" + } + } + Transition tr9: firstStar -> cp cp3 { + triggers { + <nextChar: readerPort> + } + action { + "readerPort.getNextChar();" + } + } + Transition tr10: cp cp3 -> blockComment + Transition tr11: cp cp3 -> code { + cond { + "c==\'/\'" + } + } + Transition tr12: cp cp4 -> code { + action { + "printf(\"%c%c\",\'/\',c);" + } + } + Transition tr13: cp cp4 -> lineComment { + cond { + "c==\'/\'" + } + } + Transition tr14: cp cp5 -> lineComment + Transition tr15: lineComment -> cp cp5 { + triggers { + <nextChar: readerPort> + } + action { + "readerPort.getNextChar();" + } + } + Transition tr16: cp cp5 -> code { + cond { + "c==\'\\n\'" + } + } + ChoicePoint cp0 + ChoicePoint cp1 + ChoicePoint cp2 + ChoicePoint cp3 + ChoicePoint cp4 + ChoicePoint cp5 + State code + State firstSlash + State blockComment + State firstStar + State lineComment + } + } + } + + ProtocolClass FileReaderProtocol { + incoming { + Message getNextChar() + } + outgoing { + Message nextChar(c:char) + } + } +}
\ No newline at end of file diff --git a/examples/org.eclipse.etrice.tutorials.c/model/RemoveComment/Types.room b/examples/org.eclipse.etrice.tutorials.c/model/RemoveComment/Types.room new file mode 100644 index 000000000..a9ccbf347 --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/model/RemoveComment/Types.room @@ -0,0 +1,22 @@ +RoomModel room.basic.types { + + PrimitiveType boolean: ptBoolean -> boolean default "FALSE" + PrimitiveType char: ptCharacter -> char default "0" + PrimitiveType int8: ptInteger -> int8 default "0" + PrimitiveType int16: ptInteger -> int16 default "0" + PrimitiveType int32: ptInteger -> int32 default "0" + PrimitiveType int64: ptInteger -> int64 default "0" + + PrimitiveType uint8: ptInteger -> uint8 default "0" + PrimitiveType uint16: ptInteger -> uint16 default "0" + PrimitiveType uint32: ptInteger -> uint32 default "0" + PrimitiveType uint64: ptInteger -> uint64 default "0" + + PrimitiveType float32:ptReal -> float32 default "0" + PrimitiveType float64:ptReal -> float64 default "0" + + // TODO: define strings for C + PrimitiveType charPtr:ptCharacter -> charPtr default "0" + PrimitiveType string:ptCharacter -> charPtr default "0" + PrimitiveType file:ptInteger -> FILE default "0" +}
\ No newline at end of file diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/ACParser.c b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/ACParser.c new file mode 100644 index 000000000..61e44a287 --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/ACParser.c @@ -0,0 +1,325 @@ +/** + * @author generated by eTrice + * + * Source File of ActorClass ACParser + * + */ + +#include "ACParser.h" + +#include "modelbase/etActor.h" +#include "debugging/etLogger.h" +#include "debugging/etMSCLogger.h" +#include "etUnit/etUnit.h" +#include "platform/etMemory.h" + +#include "FileReaderProtocol.h" + + +/* interface item IDs */ +enum interface_items { + IFITEM_readerPort = 1 +}; + + +/* state IDs */ +enum state_ids { + NO_STATE = 0, + STATE_TOP = 1, + STATE_code = 2, + STATE_firstSlash = 3, + STATE_blockComment = 4, + STATE_firstStar = 5, + STATE_lineComment = 6 +}; + +/* transition chains */ +enum chain_ids { + CHAIN_TRANS_INITIAL_TO__code = 1, + CHAIN_TRANS_tr0_FROM_code_TO_cp0_BY_nextCharreaderPort = 2, + CHAIN_TRANS_tr3_FROM_firstSlash_TO_cp1_BY_nextCharreaderPort = 3, + CHAIN_TRANS_tr6_FROM_blockComment_TO_cp2_BY_nextCharreaderPort = 4, + CHAIN_TRANS_tr9_FROM_firstStar_TO_cp3_BY_nextCharreaderPort = 5, + CHAIN_TRANS_tr15_FROM_lineComment_TO_cp5_BY_nextCharreaderPort = 6 +}; + +/* triggers */ +enum triggers { + POLLING = 0, + TRIG_readerPort__nextChar = IFITEM_readerPort + EVT_SHIFT*FileReaderProtocol_OUT_nextChar +}; + + +static void setState(ACParser* self, int new_state) { + self->state = new_state; +} + +/* Entry and Exit Codes */ + +/* Action Codes */ +static void action_TRANS_INITIAL_TO__code(ACParser* self) { + FileReaderProtocolConjPort_getNextChar(&self->constData->readerPort) /* ORIG: readerPort.getNextChar() */; +} +static void action_TRANS_tr0_FROM_code_TO_cp0_BY_nextCharreaderPort(ACParser* self, InterfaceItemBase ifitem, char c) { + FileReaderProtocolConjPort_getNextChar(&self->constData->readerPort) /* ORIG: readerPort.getNextChar() */; +} +static void action_TRANS_tr1_FROM_cp0_TO_code(ACParser* self, InterfaceItemBase ifitem, char c) { + printf("%c",c); +} +static void action_TRANS_tr3_FROM_firstSlash_TO_cp1_BY_nextCharreaderPort(ACParser* self, InterfaceItemBase ifitem, char c) { + FileReaderProtocolConjPort_getNextChar(&self->constData->readerPort) /* ORIG: readerPort.getNextChar() */; +} +static void action_TRANS_tr6_FROM_blockComment_TO_cp2_BY_nextCharreaderPort(ACParser* self, InterfaceItemBase ifitem, char c) { + FileReaderProtocolConjPort_getNextChar(&self->constData->readerPort) /* ORIG: readerPort.getNextChar() */; +} +static void action_TRANS_tr9_FROM_firstStar_TO_cp3_BY_nextCharreaderPort(ACParser* self, InterfaceItemBase ifitem, char c) { + FileReaderProtocolConjPort_getNextChar(&self->constData->readerPort) /* ORIG: readerPort.getNextChar() */; +} +static void action_TRANS_tr12_FROM_cp4_TO_code(ACParser* self, InterfaceItemBase ifitem, char c) { + printf("%c%c",'/',c); +} +static void action_TRANS_tr15_FROM_lineComment_TO_cp5_BY_nextCharreaderPort(ACParser* self, InterfaceItemBase ifitem, char c) { + FileReaderProtocolConjPort_getNextChar(&self->constData->readerPort) /* ORIG: readerPort.getNextChar() */; +} + +/** + * calls exit codes while exiting from the current state to one of its + * parent states while remembering the history + * @param current - the current state + * @param to - the final parent state + * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints) + */ +static void exitTo(ACParser* self, int current, int to, boolean handler) { + while (current!=to) { + switch (current) { + case STATE_code: + self->history[STATE_TOP] = STATE_code; + current = STATE_TOP; + break; + case STATE_firstSlash: + self->history[STATE_TOP] = STATE_firstSlash; + current = STATE_TOP; + break; + case STATE_blockComment: + self->history[STATE_TOP] = STATE_blockComment; + current = STATE_TOP; + break; + case STATE_firstStar: + self->history[STATE_TOP] = STATE_firstStar; + current = STATE_TOP; + break; + case STATE_lineComment: + self->history[STATE_TOP] = STATE_lineComment; + current = STATE_TOP; + break; + } + } +} + +/** + * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data + * matching the trigger of this chain. The ID of the final state is returned + * @param chain - the chain ID + * @param generic_data - the generic data pointer + * @return the ID of the final state + */ +static int executeTransitionChain(ACParser* self, int chain, InterfaceItemBase ifitem, void* generic_data) { + switch (chain) { + case CHAIN_TRANS_INITIAL_TO__code: + { + action_TRANS_INITIAL_TO__code(self); + return STATE_code; + } + case CHAIN_TRANS_tr0_FROM_code_TO_cp0_BY_nextCharreaderPort: + { + char c = *((char*) generic_data); + action_TRANS_tr0_FROM_code_TO_cp0_BY_nextCharreaderPort(self, ifitem, c); + if (c=='/') { + return STATE_firstSlash;} + else { + action_TRANS_tr1_FROM_cp0_TO_code(self, ifitem, c); + return STATE_code;} + } + case CHAIN_TRANS_tr3_FROM_firstSlash_TO_cp1_BY_nextCharreaderPort: + { + char c = *((char*) generic_data); + action_TRANS_tr3_FROM_firstSlash_TO_cp1_BY_nextCharreaderPort(self, ifitem, c); + if (c=='*') { + return STATE_blockComment;} + else { + if (c=='/') { + return STATE_lineComment;} + else { + action_TRANS_tr12_FROM_cp4_TO_code(self, ifitem, c); + return STATE_code;} + } + } + case CHAIN_TRANS_tr6_FROM_blockComment_TO_cp2_BY_nextCharreaderPort: + { + char c = *((char*) generic_data); + action_TRANS_tr6_FROM_blockComment_TO_cp2_BY_nextCharreaderPort(self, ifitem, c); + if (c=='*') { + return STATE_firstStar;} + else { + return STATE_blockComment;} + } + case CHAIN_TRANS_tr9_FROM_firstStar_TO_cp3_BY_nextCharreaderPort: + { + char c = *((char*) generic_data); + action_TRANS_tr9_FROM_firstStar_TO_cp3_BY_nextCharreaderPort(self, ifitem, c); + if (c=='/') { + return STATE_code;} + else { + return STATE_blockComment;} + } + case CHAIN_TRANS_tr15_FROM_lineComment_TO_cp5_BY_nextCharreaderPort: + { + char c = *((char*) generic_data); + action_TRANS_tr15_FROM_lineComment_TO_cp5_BY_nextCharreaderPort(self, ifitem, c); + if (c=='\n') { + return STATE_code;} + else { + return STATE_lineComment;} + } + } + return NO_STATE; +} + +/** + * calls entry codes while entering a state's history. The ID of the final leaf state is returned + * @param state - the state which is entered + * @param handler - entry code is executed if not handler + * @return - the ID of the final leaf state + */ +static int enterHistory(ACParser* self, int state, boolean handler, boolean skip_entry) { + while (TRUE) { + switch (state) { + case STATE_code: + // in leaf state: return state id + return STATE_code; + case STATE_firstSlash: + // in leaf state: return state id + return STATE_firstSlash; + case STATE_blockComment: + // in leaf state: return state id + return STATE_blockComment; + case STATE_firstStar: + // in leaf state: return state id + return STATE_firstStar; + case STATE_lineComment: + // in leaf state: return state id + return STATE_lineComment; + case STATE_TOP: + state = self->history[STATE_TOP]; + break; + } + skip_entry = FALSE; + } + //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) +} + +static void executeInitTransition(ACParser* self) { + int chain = CHAIN_TRANS_INITIAL_TO__code; + int next = executeTransitionChain(self, chain, NULL, NULL); + next = enterHistory(self, next, FALSE, FALSE); + setState(self, next); +} + +/* receiveEvent contains the main implementation of the FSM */ +static void receiveEvent(ACParser* self, InterfaceItemBase ifitem, int evt, void* generic_data) { + int trigger = ifitem->localId + EVT_SHIFT*evt; + int chain = NOT_CAUGHT; + int catching_state = NO_STATE; + boolean is_handler = FALSE; + boolean skip_entry = FALSE; + + if (!handleSystemEvent(ifitem, evt, generic_data)) { + switch (self->state) { + case STATE_code: + switch(trigger) { + case TRIG_readerPort__nextChar: + { + chain = CHAIN_TRANS_tr0_FROM_code_TO_cp0_BY_nextCharreaderPort; + catching_state = STATE_TOP; + } + break; + } + break; + case STATE_firstSlash: + switch(trigger) { + case TRIG_readerPort__nextChar: + { + chain = CHAIN_TRANS_tr3_FROM_firstSlash_TO_cp1_BY_nextCharreaderPort; + catching_state = STATE_TOP; + } + break; + } + break; + case STATE_blockComment: + switch(trigger) { + case TRIG_readerPort__nextChar: + { + chain = CHAIN_TRANS_tr6_FROM_blockComment_TO_cp2_BY_nextCharreaderPort; + catching_state = STATE_TOP; + } + break; + } + break; + case STATE_firstStar: + switch(trigger) { + case TRIG_readerPort__nextChar: + { + chain = CHAIN_TRANS_tr9_FROM_firstStar_TO_cp3_BY_nextCharreaderPort; + catching_state = STATE_TOP; + } + break; + } + break; + case STATE_lineComment: + switch(trigger) { + case TRIG_readerPort__nextChar: + { + chain = CHAIN_TRANS_tr15_FROM_lineComment_TO_cp5_BY_nextCharreaderPort; + catching_state = STATE_TOP; + } + break; + } + break; + } + } + if (chain != NOT_CAUGHT) { + exitTo(self, self->state, catching_state, is_handler); + int next = executeTransitionChain(self, chain, ifitem, generic_data); + next = enterHistory(self, next, is_handler, skip_entry); + setState(self, next); + } +} + +//****************************************** +// END of generated code for FSM +//****************************************** + +void ACParser_init(ACParser* self){ + ET_MSC_LOGGER_SYNC_ENTRY("ACParser", "init") + self->state = STATE_TOP; + { + int i; + for (i=0; i<ACPARSER_HISTORY_SIZE; ++i) + self->history[i] = NO_STATE; + } + executeInitTransition(self); + ET_MSC_LOGGER_SYNC_EXIT +} + + +void ACParser_receiveMessage(void* self, void* ifitem, const etMessage* msg){ + ET_MSC_LOGGER_SYNC_ENTRY("ACParser", "_receiveMessage") + + receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))); + + ET_MSC_LOGGER_SYNC_EXIT +} + + +/*--------------------- operations ---------------------*/ + diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/ACParser.h b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/ACParser.h new file mode 100644 index 000000000..a578244b3 --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/ACParser.h @@ -0,0 +1,60 @@ +/** + * @author generated by eTrice + * + * Header File of ActorClass ACParser + * + */ + +#ifndef _ACPARSER_H_ +#define _ACPARSER_H_ + +#include "etDatatypes.h" +#include "messaging/etMessage.h" + +#include "FileReaderProtocol.h" + + +typedef struct ACParser ACParser; + +/* const part of ActorClass (ROM) */ +typedef struct ACParser_const { + /* simple ports */ + const FileReaderProtocolConjPort readerPort; + + /* data receive ports */ + + /* saps */ + + /* replicated ports */ + + /* services */ +} ACParser_const; + + +/* constant for state machine data */ +#define ACPARSER_HISTORY_SIZE 2 + +/* variable part of ActorClass (RAM) */ +struct ACParser { + const ACParser_const* const constData; + + /* data send ports */ + + /*--------------------- attributes ---------------------*/ + + + /* state machine variables */ + etInt16 state; + etInt16 history[ACPARSER_HISTORY_SIZE]; +}; + +void ACParser_init(ACParser* self); + +void ACParser_receiveMessage(void* self, void* ifitem, const etMessage* msg); + + +/*--------------------- operations ---------------------*/ + + +#endif /* _ACPARSER_H_ */ + diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/AFileReader.c b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/AFileReader.c new file mode 100644 index 000000000..027ddf644 --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/AFileReader.c @@ -0,0 +1,202 @@ +/** + * @author generated by eTrice + * + * Source File of ActorClass AFileReader + * + */ + +#include "AFileReader.h" + +#include "modelbase/etActor.h" +#include "debugging/etLogger.h" +#include "debugging/etMSCLogger.h" +#include "etUnit/etUnit.h" +#include "platform/etMemory.h" + +#include "FileReaderProtocol.h" + +/*--------------------- begin user code ---------------------*/ +#include <stdio.h> +/*--------------------- end user code ---------------------*/ + +/* interface item IDs */ +enum interface_items { + IFITEM_outPort = 1 +}; + + +/* state IDs */ +enum state_ids { + NO_STATE = 0, + STATE_TOP = 1, + STATE_reading = 2 +}; + +/* transition chains */ +enum chain_ids { + CHAIN_TRANS_INITIAL_TO__reading = 1, + CHAIN_TRANS_tr0_FROM_reading_TO_reading_BY_getNextCharoutPort_tr0 = 2 +}; + +/* triggers */ +enum triggers { + POLLING = 0, + TRIG_outPort__getNextChar = IFITEM_outPort + EVT_SHIFT*FileReaderProtocol_IN_getNextChar +}; + + +static void setState(AFileReader* self, int new_state) { + self->state = new_state; +} + +/* Entry and Exit Codes */ + +/* Action Codes */ +static void action_TRANS_INITIAL_TO__reading(AFileReader* self) { + if ((self->f /* ORIG: f */ = fopen("test.txt","r")) != 0) { + printf("file open ok !\r\n"); + } + else { + printf("file not found !\r\n"); + SubSysClass_shutdown(); + } +} +static void action_TRANS_tr0_FROM_reading_TO_reading_BY_getNextCharoutPort_tr0(AFileReader* self, InterfaceItemBase ifitem) { + int8 c; + if ((c=fgetc(self->f /* ORIG: f */)) != EOF) { + FileReaderProtocolPort_nextChar(&self->constData->outPort, c) /* ORIG: outPort.nextChar(c) */; + } + else { + fclose(self->f /* ORIG: f */); + printf("file closed !\r\n"); + SubSysClass_shutdown(); + } +} + +/** + * calls exit codes while exiting from the current state to one of its + * parent states while remembering the history + * @param current - the current state + * @param to - the final parent state + * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints) + */ +static void exitTo(AFileReader* self, int current, int to, boolean handler) { + while (current!=to) { + switch (current) { + case STATE_reading: + self->history[STATE_TOP] = STATE_reading; + current = STATE_TOP; + break; + } + } +} + +/** + * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data + * matching the trigger of this chain. The ID of the final state is returned + * @param chain - the chain ID + * @param generic_data - the generic data pointer + * @return the ID of the final state + */ +static int executeTransitionChain(AFileReader* self, int chain, InterfaceItemBase ifitem, void* generic_data) { + switch (chain) { + case CHAIN_TRANS_INITIAL_TO__reading: + { + action_TRANS_INITIAL_TO__reading(self); + return STATE_reading; + } + case CHAIN_TRANS_tr0_FROM_reading_TO_reading_BY_getNextCharoutPort_tr0: + { + action_TRANS_tr0_FROM_reading_TO_reading_BY_getNextCharoutPort_tr0(self, ifitem); + return STATE_reading; + } + } + return NO_STATE; +} + +/** + * calls entry codes while entering a state's history. The ID of the final leaf state is returned + * @param state - the state which is entered + * @param handler - entry code is executed if not handler + * @return - the ID of the final leaf state + */ +static int enterHistory(AFileReader* self, int state, boolean handler, boolean skip_entry) { + while (TRUE) { + switch (state) { + case STATE_reading: + // in leaf state: return state id + return STATE_reading; + case STATE_TOP: + state = self->history[STATE_TOP]; + break; + } + skip_entry = FALSE; + } + //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) +} + +static void executeInitTransition(AFileReader* self) { + int chain = CHAIN_TRANS_INITIAL_TO__reading; + int next = executeTransitionChain(self, chain, NULL, NULL); + next = enterHistory(self, next, FALSE, FALSE); + setState(self, next); +} + +/* receiveEvent contains the main implementation of the FSM */ +static void receiveEvent(AFileReader* self, InterfaceItemBase ifitem, int evt, void* generic_data) { + int trigger = ifitem->localId + EVT_SHIFT*evt; + int chain = NOT_CAUGHT; + int catching_state = NO_STATE; + boolean is_handler = FALSE; + boolean skip_entry = FALSE; + + if (!handleSystemEvent(ifitem, evt, generic_data)) { + switch (self->state) { + case STATE_reading: + switch(trigger) { + case TRIG_outPort__getNextChar: + { + chain = CHAIN_TRANS_tr0_FROM_reading_TO_reading_BY_getNextCharoutPort_tr0; + catching_state = STATE_TOP; + } + break; + } + break; + } + } + if (chain != NOT_CAUGHT) { + exitTo(self, self->state, catching_state, is_handler); + int next = executeTransitionChain(self, chain, ifitem, generic_data); + next = enterHistory(self, next, is_handler, skip_entry); + setState(self, next); + } +} + +//****************************************** +// END of generated code for FSM +//****************************************** + +void AFileReader_init(AFileReader* self){ + ET_MSC_LOGGER_SYNC_ENTRY("AFileReader", "init") + self->state = STATE_TOP; + { + int i; + for (i=0; i<AFILEREADER_HISTORY_SIZE; ++i) + self->history[i] = NO_STATE; + } + executeInitTransition(self); + ET_MSC_LOGGER_SYNC_EXIT +} + + +void AFileReader_receiveMessage(void* self, void* ifitem, const etMessage* msg){ + ET_MSC_LOGGER_SYNC_ENTRY("AFileReader", "_receiveMessage") + + receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))); + + ET_MSC_LOGGER_SYNC_EXIT +} + + +/*--------------------- operations ---------------------*/ + diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/AFileReader.h b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/AFileReader.h new file mode 100644 index 000000000..933ec228c --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/AFileReader.h @@ -0,0 +1,61 @@ +/** + * @author generated by eTrice + * + * Header File of ActorClass AFileReader + * + */ + +#ifndef _AFILEREADER_H_ +#define _AFILEREADER_H_ + +#include "etDatatypes.h" +#include "messaging/etMessage.h" + +#include "FileReaderProtocol.h" + + +typedef struct AFileReader AFileReader; + +/* const part of ActorClass (ROM) */ +typedef struct AFileReader_const { + /* simple ports */ + const FileReaderProtocolPort outPort; + + /* data receive ports */ + + /* saps */ + + /* replicated ports */ + + /* services */ +} AFileReader_const; + + +/* constant for state machine data */ +#define AFILEREADER_HISTORY_SIZE 2 + +/* variable part of ActorClass (RAM) */ +struct AFileReader { + const AFileReader_const* const constData; + + /* data send ports */ + + /*--------------------- attributes ---------------------*/ + FILE* f; + + + /* state machine variables */ + etInt16 state; + etInt16 history[AFILEREADER_HISTORY_SIZE]; +}; + +void AFileReader_init(AFileReader* self); + +void AFileReader_receiveMessage(void* self, void* ifitem, const etMessage* msg); + + +/*--------------------- operations ---------------------*/ + + +#endif /* _AFILEREADER_H_ */ + diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/ATop.c b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/ATop.c new file mode 100644 index 000000000..7dcc75d39 --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/ATop.c @@ -0,0 +1,36 @@ +/** + * @author generated by eTrice + * + * Source File of ActorClass ATop + * + */ + +#include "ATop.h" + +#include "modelbase/etActor.h" +#include "debugging/etLogger.h" +#include "debugging/etMSCLogger.h" +#include "etUnit/etUnit.h" +#include "platform/etMemory.h" + + + +/* interface item IDs */ +/* empty enum not generated */ + + +void ATop_init(ATop* self){ + ET_MSC_LOGGER_SYNC_ENTRY("ATop", "init") + ET_MSC_LOGGER_SYNC_EXIT +} + + +void ATop_receiveMessage(void* self, void* ifitem, const etMessage* msg){ + ET_MSC_LOGGER_SYNC_ENTRY("ATop", "_receiveMessage") + + ET_MSC_LOGGER_SYNC_EXIT +} + + +/*--------------------- operations ---------------------*/ + diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/ATop.h b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/ATop.h new file mode 100644 index 000000000..b73f9f72b --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/ATop.h @@ -0,0 +1,39 @@ +/** + * @author generated by eTrice + * + * Header File of ActorClass ATop + * + */ + +#ifndef _ATOP_H_ +#define _ATOP_H_ + +#include "etDatatypes.h" +#include "messaging/etMessage.h" + + + +typedef struct ATop ATop; + +/* const part of ActorClass (ROM) */ +/* this actor class has no ports and thus no constant data */ + + +/* variable part of ActorClass (RAM) */ +struct ATop { + /* data send ports */ + + /*--------------------- attributes ---------------------*/ + +}; + +void ATop_init(ATop* self); + +void ATop_receiveMessage(void* self, void* ifitem, const etMessage* msg); + + +/*--------------------- operations ---------------------*/ + + +#endif /* _ATOP_H_ */ + diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/FileReaderProtocol.c b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/FileReaderProtocol.c new file mode 100644 index 000000000..63acb3720 --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/FileReaderProtocol.c @@ -0,0 +1,89 @@ +/** + * @author generated by eTrice + * + * Source File of ProtocolClass FileReaderProtocol + * + */ + +#include "FileReaderProtocol.h" +#include "debugging/etMSCLogger.h" + + +/*--------------------- port methods */ + +void FileReaderProtocolPort_nextChar(const FileReaderProtocolPort* self, char data) { + ET_MSC_LOGGER_SYNC_ENTRY("FileReaderProtocolPort", "nextChar") + etPort_sendMessage(self, FileReaderProtocol_OUT_nextChar, sizeof(char), &data); + ET_MSC_LOGGER_SYNC_EXIT +} + +void FileReaderProtocolReplPort_nextChar_broadcast(const FileReaderProtocolReplPort* self, char data) { + int i; + ET_MSC_LOGGER_SYNC_ENTRY("FileReaderProtocolReplPort", "nextChar") + for (i=0; i<((etReplPort*)self)->size; ++i) { + etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[i]), FileReaderProtocol_OUT_nextChar, sizeof(char), &data); + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void FileReaderProtocolReplPort_nextChar(const FileReaderProtocolReplPort* self, int idx, char data) { + ET_MSC_LOGGER_SYNC_ENTRY("FileReaderProtocolReplPort", "nextChar") + if (0<=idx && idx<((etReplPort*)self)->size) { + etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[idx]), FileReaderProtocol_OUT_nextChar, sizeof(char), &data); + } + ET_MSC_LOGGER_SYNC_EXIT +} + + +// getReplication +etInt32 FileReaderProtocolReplPort_getReplication(const FileReaderProtocolReplPort* self) { + return ((etReplPort*)self)->size; +} + + + +void FileReaderProtocolConjPort_getNextChar(const FileReaderProtocolConjPort* self) { + ET_MSC_LOGGER_SYNC_ENTRY("FileReaderProtocolConjPort", "getNextChar") + etPort_sendMessage(self, FileReaderProtocol_IN_getNextChar, 0, NULL); + ET_MSC_LOGGER_SYNC_EXIT +} + +void FileReaderProtocolConjReplPort_getNextChar_broadcast(const FileReaderProtocolConjReplPort* self) { + int i; + ET_MSC_LOGGER_SYNC_ENTRY("FileReaderProtocolConjReplPort", "getNextChar") + for (i=0; i<((etReplPort*)self)->size; ++i) { + etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[i]), FileReaderProtocol_IN_getNextChar, 0, NULL); + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void FileReaderProtocolConjReplPort_getNextChar(const FileReaderProtocolConjReplPort* self, int idx) { + ET_MSC_LOGGER_SYNC_ENTRY("FileReaderProtocolConjReplPort", "getNextChar") + if (0<=idx && idx<((etReplPort*)self)->size) { + etPort_sendMessage(((etPort*)&((etReplPort*)self)->ports[idx]), FileReaderProtocol_IN_getNextChar, 0, NULL); + } + ET_MSC_LOGGER_SYNC_EXIT +} + + +// getReplication +etInt32 FileReaderProtocolConjReplPort_getReplication(const FileReaderProtocolConjReplPort* self) { + return ((etReplPort*)self)->size; +} + + + +/*--------------------- debug helpers */ + +/* message names as strings for debugging (generate MSC) */ +static const char* const FileReaderProtocol_messageStrings[] = {"MIN", "nextChar","getNextChar", "MAX"}; + +const char* FileReaderProtocol_getMessageString(int msg_id) { + if (msg_id<FileReaderProtocol_MSG_MIN || msg_id>FileReaderProtocol_MSG_MAX+1){ + /* id out of range */ + return "Message ID out of range"; + } + else{ + return FileReaderProtocol_messageStrings[msg_id]; + } +} diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/FileReaderProtocol.h b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/FileReaderProtocol.h new file mode 100644 index 000000000..588fa2fff --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/FileReaderProtocol.h @@ -0,0 +1,54 @@ +/** + * @author generated by eTrice + * + * Header File of ProtocolClass FileReaderProtocol + * + */ + +#ifndef _FILEREADERPROTOCOL_H_ +#define _FILEREADERPROTOCOL_H_ + +#include "etDatatypes.h" +#include "modelbase/etPort.h" + + + + +/* message IDs */ +enum FileReaderProtocol_msg_ids { + FileReaderProtocol_MSG_MIN = 0, + FileReaderProtocol_OUT_nextChar = 1, + FileReaderProtocol_IN_getNextChar = 2, + FileReaderProtocol_MSG_MAX = 3 +}; + +/*--------------------- port structs and methods */ +typedef etPort FileReaderProtocolPort; +typedef etReplPort FileReaderProtocolReplPort; + + +void FileReaderProtocolPort_nextChar(const FileReaderProtocolPort* self, char data); +void FileReaderProtocolReplPort_nextChar_broadcast(const FileReaderProtocolReplPort* self, char data); +void FileReaderProtocolReplPort_nextChar(const FileReaderProtocolReplPort* self, int idx, char data); + + +etInt32 FileReaderProtocolReplPort_getReplication(const FileReaderProtocolReplPort* self); +typedef etPort FileReaderProtocolConjPort; +typedef etReplPort FileReaderProtocolConjReplPort; + + +void FileReaderProtocolConjPort_getNextChar(const FileReaderProtocolConjPort* self); +void FileReaderProtocolConjReplPort_getNextChar_broadcast(const FileReaderProtocolConjReplPort* self); +void FileReaderProtocolConjReplPort_getNextChar(const FileReaderProtocolConjReplPort* self, int idx); + + +etInt32 FileReaderProtocolConjReplPort_getReplication(const FileReaderProtocolConjReplPort* self); + +/*--------------------- debug helpers */ + +/* get message string for message id */ +const char* FileReaderProtocol_getMessageString(int msg_id); + + +#endif /* _FILEREADERPROTOCOL_H_ */ + diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys.c b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys.c new file mode 100644 index 000000000..24deffd85 --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys.c @@ -0,0 +1,111 @@ +/** + * @author generated by eTrice + * + * Source File of SubSystemClass RemoveCommentSubSys + * + */ + +#include "RemoveCommentSubSys.h" + +/* include instances for all classes */ +#include "RemoveCommentSubSys_Inst.h" +#include "RemoveCommentSubSys_Disp.h" + +#include "debugging/etLogger.h" +#include "debugging/etMSCLogger.h" + +#include "platform/etTimer.h" +#include "etRuntimeConfig.h" + + +/* data for SubSysten RemoveCommentSubSys */ +typedef struct RemoveCommentSubSys { + char *name; + volatile int shutdownRequest; +} RemoveCommentSubSys; + +static RemoveCommentSubSys RemoveCommentSubSysInst = {"RemoveCommentSubSys",0}; + +void RemoveCommentSubSys_initActorInstances(void); +void RemoveCommentSubSys_constructActorInstances(void); + +void RemoveCommentSubSys_init(void){ + ET_MSC_LOGGER_SYNC_ENTRY("SubSys", "init") + etLogger_logInfoF("%s_init", RemoveCommentSubSysInst.name); + + /* construct all actors */ + RemoveCommentSubSys_constructActorInstances(); + + /* initialization of all message services */ + etMessageService_init(&msgService_Thread1, msgBuffer_Thread1, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE, MsgDispatcher_Thread1_receiveMessage); + + /* init all actors */ + RemoveCommentSubSys_initActorInstances(); + + ET_MSC_LOGGER_SYNC_EXIT +} + +void RemoveCommentSubSys_start(void){ + ET_MSC_LOGGER_SYNC_ENTRY("SubSys", "start") + etLogger_logInfoF("%s_start", RemoveCommentSubSysInst.name); + ET_MSC_LOGGER_SYNC_EXIT +} + +void RemoveCommentSubSys_run(void){ + ET_MSC_LOGGER_SYNC_ENTRY("SubSys", "run") + + #ifdef ET_RUNTIME_ENDLESS + while(!(RemoveCommentSubSysInst.shutdownRequest)){ + if (etTimer_executeNeeded()){ + etMessageService_execute(&msgService_Thread1); + } + } + #else + uint32 loopCounter = 0; + while(!(RemoveCommentSubSysInst.shutdownRequest)){ + if (etTimer_executeNeeded()){ + etMessageService_execute(&msgService_Thread1); + etLogger_logInfo("Execute"); + if (loopCounter++ > ET_RUNTIME_MAXLOOP){ + break; + } + } + } + #endif + + ET_MSC_LOGGER_SYNC_EXIT +} + +void RemoveCommentSubSys_stop(void){ + ET_MSC_LOGGER_SYNC_ENTRY("SubSys", "stop") + etLogger_logInfoF("%s_stop", RemoveCommentSubSysInst.name); + ET_MSC_LOGGER_SYNC_EXIT +} + +void RemoveCommentSubSys_destroy(void){ + ET_MSC_LOGGER_SYNC_ENTRY("SubSys", "destroy") + etLogger_logInfoF("%s_destroy", RemoveCommentSubSysInst.name); + ET_MSC_LOGGER_SYNC_EXIT +} + +void SubSysClass_shutdown(void){ + ET_MSC_LOGGER_SYNC_ENTRY("SubSys", "shutdown") + etLogger_logInfoF("%s_shutdown", RemoveCommentSubSysInst.name); + RemoveCommentSubSysInst.shutdownRequest = 1; + ET_MSC_LOGGER_SYNC_EXIT +} + + +void RemoveCommentSubSys_constructActorInstances(void){ + ET_MSC_LOGGER_SYNC_ENTRY("RemoveCommentSubSys", "constructActorInstances") + ET_MSC_LOGGER_SYNC_EXIT +} + +void RemoveCommentSubSys_initActorInstances(void){ + ET_MSC_LOGGER_SYNC_ENTRY("RemoveCommentSubSys", "initActorInstances") + ATop_init(&_RemoveCommentSubSys_Topref); + AFileReader_init(&_RemoveCommentSubSys_Topref_reader); + ACParser_init(&_RemoveCommentSubSys_Topref_cParser); + ET_MSC_LOGGER_SYNC_EXIT +} + diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys.h b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys.h new file mode 100644 index 000000000..c910fc0a1 --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys.h @@ -0,0 +1,30 @@ +/** + * @author generated by eTrice + * + * Header File of SubSystemClass RemoveCommentSubSys + * + */ + +#ifndef _REMOVECOMMENTSUBSYS_H_ +#define _REMOVECOMMENTSUBSYS_H_ + + + +/* lifecycle functions + * init -> start -> run (loop) -> stop -> destroy + */ + +void RemoveCommentSubSys_init(void); /* lifecycle init */ +void RemoveCommentSubSys_start(void); /* lifecycle start */ + +void RemoveCommentSubSys_run(void); /* lifecycle run */ + +void RemoveCommentSubSys_stop(void); /* lifecycle stop */ +void RemoveCommentSubSys_destroy(void); /* lifecycle destroy */ + +void SubSysClass_shutdown(void); /* shutdown the dispatcher loop */ + + +#endif /* _REMOVECOMMENTSUBSYS_H_ */ + + diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys_Disp.h b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys_Disp.h new file mode 100644 index 000000000..8a53e12ca --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys_Disp.h @@ -0,0 +1,31 @@ +/** + * @author generated by eTrice + * + * Dispatcher File of SubSystemClass RemoveCommentSubSys + * - one generated dispatcher for each MessageService (Thread) + */ + +#include "messaging/etMessageReceiver.h" +#include "debugging/etLogger.h" +#include "debugging/etMSCLogger.h" + +static void MsgDispatcher_Thread1_receiveMessage(const etMessage* msg){ + ET_MSC_LOGGER_SYNC_ENTRY("MsgDispatcher_Thread1", "receiveMessage") + switch(msg->address){ + + /* interface items of /RemoveCommentSubSys/Topref */ + /* interface items of /RemoveCommentSubSys/Topref/reader */ + case 103: + AFileReader_receiveMessage((void*)&_RemoveCommentSubSys_Topref_reader,(etPort*)&_RemoveCommentSubSys_Topref_reader_const.outPort, msg); + break; + /* interface items of /RemoveCommentSubSys/Topref/cParser */ + case 105: + ACParser_receiveMessage((void*)&_RemoveCommentSubSys_Topref_cParser,(etPort*)&_RemoveCommentSubSys_Topref_cParser_const.readerPort, msg); + break; + + default: + etLogger_logErrorF("MessageService_Thread1_receiveMessage: address %d does not exist ", msg->address); + break; + } + ET_MSC_LOGGER_SYNC_EXIT +} diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys_Inst.h b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys_Inst.h new file mode 100644 index 000000000..ba606608f --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys_Inst.h @@ -0,0 +1,76 @@ +/** + * @author generated by eTrice + * + * Instance File of SubSystemClass RemoveCommentSubSys + * - instantiation of all actor instances and port instances + * - configuration of data and connection of ports + */ + +#include "messaging/etMessageService.h" +#include "platform/etMemory.h" + +/* instantiation of message services */ + +/* MessageService for Thread1 */ +static uint8 msgBuffer_Thread1[MESSAGE_POOL_MAX*MESSAGE_BLOCK_SIZE]; +static etMessageService msgService_Thread1; + + +/* include all used ActorClasses */ +#include "ATop.h" +#include "ACParser.h" +#include "AFileReader.h" + +/* include all used ProtcolClasses */ +#include "FileReaderProtocol.h" + + +/* declarations of all ActorClass instances (const and variable structs) */ + +/* forward declaration of variable actor structs */ +static ATop _RemoveCommentSubSys_Topref; +static AFileReader _RemoveCommentSubSys_Topref_reader; +static ACParser _RemoveCommentSubSys_Topref_cParser; + +/* forward declaration of variable port structs */ +/*nothing to do */ + + +/* instance _RemoveCommentSubSys_Topref */ +/* no ports/saps/services - nothing to initialize statically */ + +/* instance _RemoveCommentSubSys_Topref_reader */ +static const AFileReader_const _RemoveCommentSubSys_Topref_reader_const = { + /* Ports: {varData, msgService, peerAddress, localId} */ + {0,&msgService_Thread1, 105, 1} /* Port outPort */ + + /* data receive ports */ +}; +static AFileReader _RemoveCommentSubSys_Topref_reader = { + &_RemoveCommentSubSys_Topref_reader_const, + + /* data send ports */ + + /* attributes */ + 0, + + /* state and history are initialized in init fuction */ +}; + +/* instance _RemoveCommentSubSys_Topref_cParser */ +static const ACParser_const _RemoveCommentSubSys_Topref_cParser_const = { + /* Ports: {varData, msgService, peerAddress, localId} */ + {0,&msgService_Thread1, 103, 1} /* Port readerPort */ + + /* data receive ports */ +}; +static ACParser _RemoveCommentSubSys_Topref_cParser = { + &_RemoveCommentSubSys_Topref_cParser_const, + + /* data send ports */ + + /* attributes */ + + /* state and history are initialized in init fuction */ +}; + diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys_Runner.c b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys_Runner.c new file mode 100644 index 000000000..b613131cc --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/RemoveComment/RemoveCommentSubSys_Runner.c @@ -0,0 +1,49 @@ +/** + * @author generated by eTrice + * + * this class contains the main function running component RemoveCommentSubSys + * it instantiates RemoveCommentSubSys and starts and ends the lifecycle + */ + + +#include "RemoveCommentSubSys.h" + +#include "debugging/etLogger.h" +#include "debugging/etMSCLogger.h" +#include "platform/etPlatform.h" + + +/** + * main function + * creates component and starts and stops the lifecycle + */ + +int main(void) { + etUserEntry(); /* platform specific */ + + etLogger_logInfo("*** T H E B E G I N ***"); + ET_MSC_LOGGER_OPEN("main"); + + /* startup sequence of lifecycle */ + RemoveCommentSubSys_init(); /* lifecycle init */ + RemoveCommentSubSys_start(); /* lifecycle start */ + + etUserPreRun(); /* platform specific */ + + /* run Scheduler */ + RemoveCommentSubSys_run(); + + etUserPostRun(); /* platform specific */ + + /* shutdown sequence of lifecycle */ + RemoveCommentSubSys_stop(); /* lifecycle stop */ + RemoveCommentSubSys_destroy(); /* lifecycle destroy */ + + ET_MSC_LOGGER_CLOSE + etLogger_logInfo("*** T H E E N D ***"); + + etUserExit(); /* platform specific */ + + return 0; +} + diff --git a/examples/org.eclipse.etrice.tutorials.c/src-gen/readme.txt b/examples/org.eclipse.etrice.tutorials.c/src-gen/readme.txt new file mode 100644 index 000000000..1dc2b35ab --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/src-gen/readme.txt @@ -0,0 +1,4 @@ +This directory is an eTrice code generation target. +It will be erased every time the generator is executed. + +DO NOT PLACE OTHER FILES HERE! diff --git a/examples/org.eclipse.etrice.tutorials.c/test.txt b/examples/org.eclipse.etrice.tutorials.c/test.txt new file mode 100644 index 000000000..61e44a287 --- /dev/null +++ b/examples/org.eclipse.etrice.tutorials.c/test.txt @@ -0,0 +1,325 @@ +/** + * @author generated by eTrice + * + * Source File of ActorClass ACParser + * + */ + +#include "ACParser.h" + +#include "modelbase/etActor.h" +#include "debugging/etLogger.h" +#include "debugging/etMSCLogger.h" +#include "etUnit/etUnit.h" +#include "platform/etMemory.h" + +#include "FileReaderProtocol.h" + + +/* interface item IDs */ +enum interface_items { + IFITEM_readerPort = 1 +}; + + +/* state IDs */ +enum state_ids { + NO_STATE = 0, + STATE_TOP = 1, + STATE_code = 2, + STATE_firstSlash = 3, + STATE_blockComment = 4, + STATE_firstStar = 5, + STATE_lineComment = 6 +}; + +/* transition chains */ +enum chain_ids { + CHAIN_TRANS_INITIAL_TO__code = 1, + CHAIN_TRANS_tr0_FROM_code_TO_cp0_BY_nextCharreaderPort = 2, + CHAIN_TRANS_tr3_FROM_firstSlash_TO_cp1_BY_nextCharreaderPort = 3, + CHAIN_TRANS_tr6_FROM_blockComment_TO_cp2_BY_nextCharreaderPort = 4, + CHAIN_TRANS_tr9_FROM_firstStar_TO_cp3_BY_nextCharreaderPort = 5, + CHAIN_TRANS_tr15_FROM_lineComment_TO_cp5_BY_nextCharreaderPort = 6 +}; + +/* triggers */ +enum triggers { + POLLING = 0, + TRIG_readerPort__nextChar = IFITEM_readerPort + EVT_SHIFT*FileReaderProtocol_OUT_nextChar +}; + + +static void setState(ACParser* self, int new_state) { + self->state = new_state; +} + +/* Entry and Exit Codes */ + +/* Action Codes */ +static void action_TRANS_INITIAL_TO__code(ACParser* self) { + FileReaderProtocolConjPort_getNextChar(&self->constData->readerPort) /* ORIG: readerPort.getNextChar() */; +} +static void action_TRANS_tr0_FROM_code_TO_cp0_BY_nextCharreaderPort(ACParser* self, InterfaceItemBase ifitem, char c) { + FileReaderProtocolConjPort_getNextChar(&self->constData->readerPort) /* ORIG: readerPort.getNextChar() */; +} +static void action_TRANS_tr1_FROM_cp0_TO_code(ACParser* self, InterfaceItemBase ifitem, char c) { + printf("%c",c); +} +static void action_TRANS_tr3_FROM_firstSlash_TO_cp1_BY_nextCharreaderPort(ACParser* self, InterfaceItemBase ifitem, char c) { + FileReaderProtocolConjPort_getNextChar(&self->constData->readerPort) /* ORIG: readerPort.getNextChar() */; +} +static void action_TRANS_tr6_FROM_blockComment_TO_cp2_BY_nextCharreaderPort(ACParser* self, InterfaceItemBase ifitem, char c) { + FileReaderProtocolConjPort_getNextChar(&self->constData->readerPort) /* ORIG: readerPort.getNextChar() */; +} +static void action_TRANS_tr9_FROM_firstStar_TO_cp3_BY_nextCharreaderPort(ACParser* self, InterfaceItemBase ifitem, char c) { + FileReaderProtocolConjPort_getNextChar(&self->constData->readerPort) /* ORIG: readerPort.getNextChar() */; +} +static void action_TRANS_tr12_FROM_cp4_TO_code(ACParser* self, InterfaceItemBase ifitem, char c) { + printf("%c%c",'/',c); +} +static void action_TRANS_tr15_FROM_lineComment_TO_cp5_BY_nextCharreaderPort(ACParser* self, InterfaceItemBase ifitem, char c) { + FileReaderProtocolConjPort_getNextChar(&self->constData->readerPort) /* ORIG: readerPort.getNextChar() */; +} + +/** + * calls exit codes while exiting from the current state to one of its + * parent states while remembering the history + * @param current - the current state + * @param to - the final parent state + * @param handler - entry and exit codes are called only if not handler (for handler TransitionPoints) + */ +static void exitTo(ACParser* self, int current, int to, boolean handler) { + while (current!=to) { + switch (current) { + case STATE_code: + self->history[STATE_TOP] = STATE_code; + current = STATE_TOP; + break; + case STATE_firstSlash: + self->history[STATE_TOP] = STATE_firstSlash; + current = STATE_TOP; + break; + case STATE_blockComment: + self->history[STATE_TOP] = STATE_blockComment; + current = STATE_TOP; + break; + case STATE_firstStar: + self->history[STATE_TOP] = STATE_firstStar; + current = STATE_TOP; + break; + case STATE_lineComment: + self->history[STATE_TOP] = STATE_lineComment; + current = STATE_TOP; + break; + } + } +} + +/** + * calls action, entry and exit codes along a transition chain. The generic data are cast to typed data + * matching the trigger of this chain. The ID of the final state is returned + * @param chain - the chain ID + * @param generic_data - the generic data pointer + * @return the ID of the final state + */ +static int executeTransitionChain(ACParser* self, int chain, InterfaceItemBase ifitem, void* generic_data) { + switch (chain) { + case CHAIN_TRANS_INITIAL_TO__code: + { + action_TRANS_INITIAL_TO__code(self); + return STATE_code; + } + case CHAIN_TRANS_tr0_FROM_code_TO_cp0_BY_nextCharreaderPort: + { + char c = *((char*) generic_data); + action_TRANS_tr0_FROM_code_TO_cp0_BY_nextCharreaderPort(self, ifitem, c); + if (c=='/') { + return STATE_firstSlash;} + else { + action_TRANS_tr1_FROM_cp0_TO_code(self, ifitem, c); + return STATE_code;} + } + case CHAIN_TRANS_tr3_FROM_firstSlash_TO_cp1_BY_nextCharreaderPort: + { + char c = *((char*) generic_data); + action_TRANS_tr3_FROM_firstSlash_TO_cp1_BY_nextCharreaderPort(self, ifitem, c); + if (c=='*') { + return STATE_blockComment;} + else { + if (c=='/') { + return STATE_lineComment;} + else { + action_TRANS_tr12_FROM_cp4_TO_code(self, ifitem, c); + return STATE_code;} + } + } + case CHAIN_TRANS_tr6_FROM_blockComment_TO_cp2_BY_nextCharreaderPort: + { + char c = *((char*) generic_data); + action_TRANS_tr6_FROM_blockComment_TO_cp2_BY_nextCharreaderPort(self, ifitem, c); + if (c=='*') { + return STATE_firstStar;} + else { + return STATE_blockComment;} + } + case CHAIN_TRANS_tr9_FROM_firstStar_TO_cp3_BY_nextCharreaderPort: + { + char c = *((char*) generic_data); + action_TRANS_tr9_FROM_firstStar_TO_cp3_BY_nextCharreaderPort(self, ifitem, c); + if (c=='/') { + return STATE_code;} + else { + return STATE_blockComment;} + } + case CHAIN_TRANS_tr15_FROM_lineComment_TO_cp5_BY_nextCharreaderPort: + { + char c = *((char*) generic_data); + action_TRANS_tr15_FROM_lineComment_TO_cp5_BY_nextCharreaderPort(self, ifitem, c); + if (c=='\n') { + return STATE_code;} + else { + return STATE_lineComment;} + } + } + return NO_STATE; +} + +/** + * calls entry codes while entering a state's history. The ID of the final leaf state is returned + * @param state - the state which is entered + * @param handler - entry code is executed if not handler + * @return - the ID of the final leaf state + */ +static int enterHistory(ACParser* self, int state, boolean handler, boolean skip_entry) { + while (TRUE) { + switch (state) { + case STATE_code: + // in leaf state: return state id + return STATE_code; + case STATE_firstSlash: + // in leaf state: return state id + return STATE_firstSlash; + case STATE_blockComment: + // in leaf state: return state id + return STATE_blockComment; + case STATE_firstStar: + // in leaf state: return state id + return STATE_firstStar; + case STATE_lineComment: + // in leaf state: return state id + return STATE_lineComment; + case STATE_TOP: + state = self->history[STATE_TOP]; + break; + } + skip_entry = FALSE; + } + //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) +} + +static void executeInitTransition(ACParser* self) { + int chain = CHAIN_TRANS_INITIAL_TO__code; + int next = executeTransitionChain(self, chain, NULL, NULL); + next = enterHistory(self, next, FALSE, FALSE); + setState(self, next); +} + +/* receiveEvent contains the main implementation of the FSM */ +static void receiveEvent(ACParser* self, InterfaceItemBase ifitem, int evt, void* generic_data) { + int trigger = ifitem->localId + EVT_SHIFT*evt; + int chain = NOT_CAUGHT; + int catching_state = NO_STATE; + boolean is_handler = FALSE; + boolean skip_entry = FALSE; + + if (!handleSystemEvent(ifitem, evt, generic_data)) { + switch (self->state) { + case STATE_code: + switch(trigger) { + case TRIG_readerPort__nextChar: + { + chain = CHAIN_TRANS_tr0_FROM_code_TO_cp0_BY_nextCharreaderPort; + catching_state = STATE_TOP; + } + break; + } + break; + case STATE_firstSlash: + switch(trigger) { + case TRIG_readerPort__nextChar: + { + chain = CHAIN_TRANS_tr3_FROM_firstSlash_TO_cp1_BY_nextCharreaderPort; + catching_state = STATE_TOP; + } + break; + } + break; + case STATE_blockComment: + switch(trigger) { + case TRIG_readerPort__nextChar: + { + chain = CHAIN_TRANS_tr6_FROM_blockComment_TO_cp2_BY_nextCharreaderPort; + catching_state = STATE_TOP; + } + break; + } + break; + case STATE_firstStar: + switch(trigger) { + case TRIG_readerPort__nextChar: + { + chain = CHAIN_TRANS_tr9_FROM_firstStar_TO_cp3_BY_nextCharreaderPort; + catching_state = STATE_TOP; + } + break; + } + break; + case STATE_lineComment: + switch(trigger) { + case TRIG_readerPort__nextChar: + { + chain = CHAIN_TRANS_tr15_FROM_lineComment_TO_cp5_BY_nextCharreaderPort; + catching_state = STATE_TOP; + } + break; + } + break; + } + } + if (chain != NOT_CAUGHT) { + exitTo(self, self->state, catching_state, is_handler); + int next = executeTransitionChain(self, chain, ifitem, generic_data); + next = enterHistory(self, next, is_handler, skip_entry); + setState(self, next); + } +} + +//****************************************** +// END of generated code for FSM +//****************************************** + +void ACParser_init(ACParser* self){ + ET_MSC_LOGGER_SYNC_ENTRY("ACParser", "init") + self->state = STATE_TOP; + { + int i; + for (i=0; i<ACPARSER_HISTORY_SIZE; ++i) + self->history[i] = NO_STATE; + } + executeInitTransition(self); + ET_MSC_LOGGER_SYNC_EXIT +} + + +void ACParser_receiveMessage(void* self, void* ifitem, const etMessage* msg){ + ET_MSC_LOGGER_SYNC_ENTRY("ACParser", "_receiveMessage") + + receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))); + + ET_MSC_LOGGER_SYNC_EXIT +} + + +/*--------------------- operations ---------------------*/ + |