Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2011-10-07 11:03:53 +0000
committerHenrik Rentz-Reichert2011-10-07 11:03:53 +0000
commit268ca20b64a4dc190e817007edb92e274fad0676 (patch)
tree61c5f4fa72ca74420f6ea26ae945337083bbde65 /runtime
parenta8d5de0214dc90d180435b5cf97cd375ffcd583d (diff)
downloadorg.eclipse.etrice-268ca20b64a4dc190e817007edb92e274fad0676.tar.gz
org.eclipse.etrice-268ca20b64a4dc190e817007edb92e274fad0676.tar.xz
org.eclipse.etrice-268ca20b64a4dc190e817007edb92e274fad0676.zip
[ui.runtime] added wizards to create runtime and modellib projects
Diffstat (limited to 'runtime')
-rw-r--r--runtime/org.eclipse.etrice.modellib/.classpath8
-rw-r--r--runtime/org.eclipse.etrice.modellib/.gitignore2
-rw-r--r--runtime/org.eclipse.etrice.modellib/.project34
-rw-r--r--runtime/org.eclipse.etrice.modellib/.settings/org.eclipse.jdt.core.prefs71
-rw-r--r--runtime/org.eclipse.etrice.modellib/META-INF/MANIFEST.MF8
-rw-r--r--runtime/org.eclipse.etrice.modellib/about.html28
-rw-r--r--runtime/org.eclipse.etrice.modellib/build.properties3
-rw-r--r--runtime/org.eclipse.etrice.modellib/models/Socket.room41
-rw-r--r--runtime/org.eclipse.etrice.modellib/models/SocketTest.room18
-rw-r--r--runtime/org.eclipse.etrice.modellib/models/TimingService.room314
-rw-r--r--runtime/org.eclipse.etrice.modellib/models/diagrams/org.eclipse.etrice.modellib.Socket.SocketClient.structure35
-rw-r--r--runtime/org.eclipse.etrice.modellib/models/diagrams/org.eclipse.etrice.modellib.Socket.test.SocketTest.structure19
-rw-r--r--runtime/org.eclipse.etrice.modellib/models/diagrams/room.basic.service.timing.ATimingService.structure47
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/readme.txt4
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java272
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java337
-rw-r--r--runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java336
17 files changed, 1577 insertions, 0 deletions
diff --git a/runtime/org.eclipse.etrice.modellib/.classpath b/runtime/org.eclipse.etrice.modellib/.classpath
new file mode 100644
index 000000000..328066fad
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="src" path="src-gen"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.etrice.runtime.java"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/runtime/org.eclipse.etrice.modellib/.gitignore b/runtime/org.eclipse.etrice.modellib/.gitignore
new file mode 100644
index 000000000..f68b3dddc
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/.gitignore
@@ -0,0 +1,2 @@
+bin
+
diff --git a/runtime/org.eclipse.etrice.modellib/.project b/runtime/org.eclipse.etrice.modellib/.project
new file mode 100644
index 000000000..bed032a1f
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.etrice.modellib</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/runtime/org.eclipse.etrice.modellib/.settings/org.eclipse.jdt.core.prefs b/runtime/org.eclipse.etrice.modellib/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..6a5ce29df
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,71 @@
+#Mon Sep 19 09:34:05 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=ignore
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/runtime/org.eclipse.etrice.modellib/META-INF/MANIFEST.MF b/runtime/org.eclipse.etrice.modellib/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..60c0dc3cb
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/META-INF/MANIFEST.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: eTrice Model Library
+Bundle-SymbolicName: org.eclipse.etrice.modellib
+Bundle-Version: 0.1.0.qualifier
+Bundle-Vendor: eTrice (Incubation)
+Export-Package: room.basic.service.timing
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/runtime/org.eclipse.etrice.modellib/about.html b/runtime/org.eclipse.etrice.modellib/about.html
new file mode 100644
index 000000000..f47dbddbb
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/runtime/org.eclipse.etrice.modellib/build.properties b/runtime/org.eclipse.etrice.modellib/build.properties
new file mode 100644
index 000000000..ef9db09a9
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/build.properties
@@ -0,0 +1,3 @@
+source.. = src-gen/
+output.. = bin/
+bin.includes = META-INF/
diff --git a/runtime/org.eclipse.etrice.modellib/models/Socket.room b/runtime/org.eclipse.etrice.modellib/models/Socket.room
new file mode 100644
index 000000000..829d21180
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/models/Socket.room
@@ -0,0 +1,41 @@
+RoomModel org.eclipse.etrice.modellib.Socket {
+
+ ActorClass SocketClient {
+ Interface {
+ Port fct: PSocket
+ }
+ Structure {
+ external Port fct
+ }
+ Behavior { }
+ }
+
+ ProtocolClass PSocket {
+ incoming {
+ Message connect(config: DSocketConfiguration)
+ Message disconnect()
+ Message sendData(data: DSocketData)
+ }
+ outgoing {
+ Message connected()
+ Message disconnected()
+ Message receivedData()
+ Message sentData()
+ Message error()
+ }
+ }
+
+ DataClass DSocketConfiguration {
+ Attribute serverName: string
+ Attribute portNumber: int32
+ Attribute protocol: int32
+ Attribute checkCookie: boolean
+ Attribute mode: int32
+ }
+
+ DataClass DSocketData {
+ Attribute size: int32
+ Attribute data: string
+ }
+
+} \ No newline at end of file
diff --git a/runtime/org.eclipse.etrice.modellib/models/SocketTest.room b/runtime/org.eclipse.etrice.modellib/models/SocketTest.room
new file mode 100644
index 000000000..673ec380b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/models/SocketTest.room
@@ -0,0 +1,18 @@
+RoomModel org.eclipse.etrice.modellib.Socket.test {
+ //import org.eclipse.etrice.modellib.Socket
+
+ ActorClass SocketTest {
+ Interface { }
+ Structure { }
+ Behavior { }
+ }
+
+ SubSystemClass SubSystemSocketTest {
+ ActorRef Tester : SocketTest
+ }
+
+ LogicalSystem LogicalSystemSocketTest {
+ SubSystemRef SubSystem: SubSystemSocketTest
+ }
+
+} \ No newline at end of file
diff --git a/runtime/org.eclipse.etrice.modellib/models/TimingService.room b/runtime/org.eclipse.etrice.modellib/models/TimingService.room
new file mode 100644
index 000000000..73d5dcea3
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/models/TimingService.room
@@ -0,0 +1,314 @@
+RoomModel room.basic.service.timing {
+
+ ActorClass ATimingService {
+ Interface {
+ SPP timer: PTimer
+ SPP timeout: PTimeout
+ }
+ Structure {
+ usercode1 {
+ "import java.util.Timer;"
+ }
+ usercode2 {
+ "private Timer timerService = null;"
+ "private int taskCount = 0;"
+ "private static final int PURGE_LIMIT = 1000;"
+ }
+ ServiceImplementation of timer
+ ServiceImplementation of timeout
+ }
+ Behavior {
+ Operation stop() {
+ "System.out.println(toString() + \"::stop()\");"
+ "timerService.cancel();"
+ "timerService = null;"
+ }
+ StateMachine {
+ Transition tr0: initial -> Operational {
+ action {
+ "timerService = new Timer();"
+ }
+ }
+ Transition tr1: Operational -> Operational {
+ triggers {
+ <Start:timeout>
+ }
+ action {
+ "// start timeout"
+ "taskCount++;"
+ "if (taskCount>PURGE_LIMIT) timerService.purge();"
+ "timerService.schedule(((PTimeoutPort)ifitem).getTask(), time_ms);"
+ }
+ }
+ Transition tr2: Operational -> Operational {
+ triggers {
+ <Kill:timeout>
+ }
+ // nothing to do to kill timeout (handled by timerService)
+ }
+ Transition tr3: Operational -> Operational {
+ triggers {
+ <Start:timer>
+ }
+ action {
+ "// start timer"
+ "taskCount++;"
+ "if (taskCount>PURGE_LIMIT) timerService.purge();"
+ "timerService.scheduleAtFixedRate(((PTimerPort)ifitem).getTask(), time_ms, time_ms);"
+ }
+ }
+ Transition tr4: Operational -> Operational {
+ triggers {
+ <Kill:timer>
+ }
+ // nothing to do to kill timer (handled by timer)
+ }
+ State Operational {
+ entry {
+ "// prepare"
+ }
+ }
+ }
+ }
+ }
+
+ ProtocolClass PTimer {
+ usercode1 {
+ "import java.util.TimerTask;"
+ }
+ usercode2 {
+ "static protected class FireTimerTask extends TimerTask {
+
+ private int time;
+ private int id;
+ private PTimerPort port;
+
+ public FireTimerTask(int time, int id, PTimerPort port) {
+ this.time = time;
+ this.id = id;
+ this.port = port;
+ }
+
+ @Override
+ public void run() {
+ port.timer(id);
+ }
+
+ public int getTime() {
+ return time;
+ }
+
+ public int getId() {
+ return id;
+ }
+ }
+
+ static protected class TimerData {
+ int time;
+ int id;
+ public TimerData(int time, int id) {
+ this.time = time;
+ this.id = id;
+ }
+ }"
+ }
+ incoming {
+ Message Start (time_ms : int32)
+ Message Kill ()
+ }
+ outgoing {
+ Message timerTick ()
+ }
+ regular PortClass {
+ usercode {
+ "private FireTimerTask task = null;
+
+ public TimerTask getTask() { return task; }"
+ }
+ handle Start {
+ "//regular PortClass handle start
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ TimerData td = (TimerData)dataMsg.getData();
+ task = new FireTimerTask(td.time, td.id, this);
+ getActor().receiveEvent(this, IN_Start, td.time);"
+ }
+ handle Kill {
+ "//regular PortClass handle kill
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ int id = (Integer)dataMsg.getData();
+ if (task!=null && task.getId()==id) {
+ task.cancel();
+ }"
+ }
+ Operation timer(id: Integer) {
+ "//regular PortClass Operation timer
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[OUT_timerTick]);
+
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), OUT_timerTick, id));"
+ }
+ }
+
+ conjugate PortClass {
+ usercode {
+ "private int currentId = 0;
+ private boolean active = false;"
+ }
+ handle timerTick {
+ "//conjugate PortClass handle timer
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ int id = (Integer)dataMsg.getData();
+ if (active && id==currentId) {
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }"
+ }
+ handle Start {
+ "//conjugate PortClass handle start
+ if (active)
+ return;
+
+ active = true;
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[IN_Start]);
+
+ getPeerMsgReceiver()
+ .receive(
+ new EventWithDataMessage(getPeerAddress(),
+ IN_Start, new TimerData(time_ms, ++currentId)));"
+ }
+ handle Kill {
+ "//conjugate PortClass kill
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[IN_Kill]);
+
+ if (active) {
+ active = false;
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), IN_Kill, currentId));
+ }"
+ }
+ }
+ }
+
+ ProtocolClass PTimeout {
+ usercode1 {
+ "import java.util.TimerTask;"
+ }
+ usercode2 {
+ "static protected class FireTimeoutTask extends TimerTask {
+
+ private int time;
+ private int id;
+ private PTimeoutPort port;
+
+ public FireTimeoutTask(int time, int id, PTimeoutPort port) {
+ this.time = time;
+ this.id = id;
+ this.port = port;
+ }
+
+ @Override
+ public void run() {
+ port.timeout(id);
+ }
+
+ public int getTime() {
+ return time;
+ }
+
+ public int getId() {
+ return id;
+ }
+ }
+
+ static protected class TimeoutData {
+ int time;
+ int id;
+ public TimeoutData(int time, int id) {
+ this.time = time;
+ this.id = id;
+ }
+ }"
+ }
+ incoming {
+ Message Start (time_ms : int32)
+ Message Kill ()
+ }
+ outgoing {
+ Message timeoutTick ()
+ }
+ regular PortClass {
+ usercode {
+ "private FireTimeoutTask task = null;
+
+ public TimerTask getTask() { return task; }"
+ }
+ handle Start {
+ "//regular PortClass handle start
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ TimeoutData td = (TimeoutData)dataMsg.getData();
+ task = new FireTimeoutTask(td.time, td.id, this);
+ getActor().receiveEvent(this, IN_Start, td.time);"
+ }
+ handle Kill {
+ "//regular PortClass handle kill
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ int id = (Integer)dataMsg.getData();
+ if (task!=null && task.getId()==id) {
+ task.cancel();
+ }"
+ }
+ Operation timeout(id: Integer) {
+ "//regular PortClass Operation timeout
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[OUT_timeoutTick]);
+
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), OUT_timeoutTick, id));"
+ }
+ }
+
+ conjugate PortClass {
+ usercode {
+ "private int currentId = 0;
+ private boolean active = false;"
+ }
+ handle timeoutTick {
+ "//conjugate PortClass handle timeout
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ int id = (Integer)dataMsg.getData();
+ if (active && id==currentId) {
+ active = false;
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }"
+ }
+ handle Start {
+ "//conjugate PortClass handle start
+ if (active)
+ return;
+
+ active = true;
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[IN_Start]);
+
+ getPeerMsgReceiver()
+ .receive(
+ new EventWithDataMessage(getPeerAddress(),
+ IN_Start, new TimeoutData(time_ms, ++currentId)));"
+ }
+ handle Kill {
+ "//conjugate PortClass kill
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[IN_Kill]);
+
+ if (active) {
+ active = false;
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), IN_Kill, new Integer(currentId)));
+ }"
+ }
+ }
+ }
+
+} \ No newline at end of file
diff --git a/runtime/org.eclipse.etrice.modellib/models/diagrams/org.eclipse.etrice.modellib.Socket.SocketClient.structure b/runtime/org.eclipse.etrice.modellib/models/diagrams/org.eclipse.etrice.modellib.Socket.SocketClient.structure
new file mode 100644
index 000000000..1d399f13c
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/models/diagrams/org.eclipse.etrice.modellib.Socket.SocketClient.structure
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ASCII"?>
+<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" gridUnit="10" diagramTypeId="room.structure" name="Structure of SocketClient" snapToGrid="true" showGuides="true" pictogramLinks="//@children.0/@link //@link //@children.0/@children.0/@link">
+ <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/>
+ <link>
+ <businessObjects href="../Socket.room#ActorClass:SocketClient"/>
+ </link>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="cls"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="880" height="580" x="40" y="40">
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="4" transparency="0.0" width="800" height="500" x="40" y="40"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../Socket.room#ActorClass:SocketClient"/>
+ </link>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="port"/>
+ <properties key="item-kind" value=""/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="80" height="80" x="418">
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.2" foreground="//@colors.2" lineWidth="2" transparency="0.0" width="40" height="40" x="20" y="20"/>
+ <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.1" foreground="//@colors.1" lineWidth="2" transparency="0.0" width="20" height="20" x="30" y="30"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../Socket.room#Port:SocketClient$fct"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" referencedGraphicsAlgorithm="//@children.0/@children.0/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" lineWidth="1" transparency="0.0" width="80" height="20" font="//@fonts.0" horizontalAlignment="ALIGNMENT_CENTER" value="fct"/>
+ </children>
+ </children>
+ </children>
+ <colors red="227" green="238" blue="249"/>
+ <colors red="255" green="255" blue="255"/>
+ <colors/>
+ <fonts name="Arial" size="8"/>
+</pi:Diagram>
diff --git a/runtime/org.eclipse.etrice.modellib/models/diagrams/org.eclipse.etrice.modellib.Socket.test.SocketTest.structure b/runtime/org.eclipse.etrice.modellib/models/diagrams/org.eclipse.etrice.modellib.Socket.test.SocketTest.structure
new file mode 100644
index 000000000..f6d6a587a
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/models/diagrams/org.eclipse.etrice.modellib.Socket.test.SocketTest.structure
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="ASCII"?>
+<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" gridUnit="10" diagramTypeId="room.structure" name="Structure of SocketTest" snapToGrid="true" showGuides="true" pictogramLinks="//@children.0/@link //@link">
+ <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/>
+ <link>
+ <businessObjects href="../SocketTest.room#ActorClass:SocketTest"/>
+ </link>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="cls"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" lineWidth="1" filled="false" lineVisible="false" transparency="0.0" width="880" height="580" x="40" y="40">
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="4" transparency="0.0" width="800" height="500" x="40" y="40"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../SocketTest.room#ActorClass:SocketTest"/>
+ </link>
+ </children>
+ <colors red="227" green="238" blue="249"/>
+ <colors red="255" green="255" blue="255"/>
+ <colors/>
+</pi:Diagram>
diff --git a/runtime/org.eclipse.etrice.modellib/models/diagrams/room.basic.service.timing.ATimingService.structure b/runtime/org.eclipse.etrice.modellib/models/diagrams/room.basic.service.timing.ATimingService.structure
new file mode 100644
index 000000000..cb50244e9
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/models/diagrams/room.basic.service.timing.ATimingService.structure
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="ASCII"?>
+<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" gridUnit="10" diagramTypeId="room.structure" name="Structure of ATimingService" snapToGrid="true" showGuides="true" pictogramLinks="//@children.0/@link //@link //@children.0/@children.0/@link //@children.0/@children.1/@link">
+ <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" width="1000" height="1000"/>
+ <link>
+ <businessObjects href="../TimingService.room#ActorClass:ATimingService"/>
+ </link>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="cls"/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" filled="false" lineVisible="false" width="880" height="580" x="40" y="40">
+ <graphicsAlgorithmChildren xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="4" width="800" height="500" x="40" y="40"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../TimingService.room#ActorClass:ATimingService"/>
+ </link>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="port"/>
+ <properties key="item-kind" value=""/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" filled="false" lineVisible="false" width="80" height="80" x="266">
+ <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.2" foreground="//@colors.2" lineWidth="2" width="40" height="40" x="20" y="20"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../TimingService.room#SPPRef:ATimingService$timer"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" referencedGraphicsAlgorithm="//@children.0/@children.0/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" width="80" height="20" horizontalAlignment="ALIGNMENT_CENTER" value="timer"/>
+ </children>
+ </children>
+ <children xsi:type="pi:ContainerShape" visible="true" active="true">
+ <properties key="obj-type" value="port"/>
+ <properties key="item-kind" value=""/>
+ <graphicsAlgorithm xsi:type="al:Rectangle" filled="false" lineVisible="false" width="80" height="80" x="532">
+ <graphicsAlgorithmChildren xsi:type="al:Ellipse" background="//@colors.2" foreground="//@colors.2" lineWidth="2" width="40" height="40" x="20" y="20"/>
+ </graphicsAlgorithm>
+ <link>
+ <businessObjects href="../TimingService.room#SPPRef:ATimingService$timeout"/>
+ </link>
+ <anchors xsi:type="pi:ChopboxAnchor" referencedGraphicsAlgorithm="//@children.0/@children.1/@graphicsAlgorithm/@graphicsAlgorithmChildren.0"/>
+ <children visible="true">
+ <graphicsAlgorithm xsi:type="al:Text" background="//@colors.2" foreground="//@colors.2" width="80" height="20" horizontalAlignment="ALIGNMENT_CENTER" value="timeout"/>
+ </children>
+ </children>
+ </children>
+ <colors red="227" green="238" blue="249"/>
+ <colors red="255" green="255" blue="255"/>
+ <colors/>
+</pi:Diagram>
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/readme.txt b/runtime/org.eclipse.etrice.modellib/src-gen/readme.txt
new file mode 100644
index 000000000..c3b99d458
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/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/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java
new file mode 100644
index 000000000..61036b823
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/ATimingService.java
@@ -0,0 +1,272 @@
+package room.basic.service.timing;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
+import org.eclipse.etrice.runtime.java.modelbase.ActorClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.SubSystemClassBase;
+import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+
+import room.basic.service.timing.PTimeout.*;
+import room.basic.service.timing.PTimer.*;
+
+//--------------------- begin user code
+ import java.util.Timer;
+ //--------------------- end user code
+
+
+public class ATimingService extends ActorClassBase {
+
+ //--------------------- begin user code
+ private Timer timerService = null;
+ private int taskCount = 0;
+ private static final int PURGE_LIMIT = 1000;
+ //--------------------- end user code
+
+ //--------------------- ports
+ //--------------------- saps
+ //--------------------- services
+ protected PTimerPortRepl timer = null;
+ protected PTimeoutPortRepl timeout = null;
+
+ //--------------------- interface item IDs
+ protected static final int IFITEM_timer = 1;
+ protected static final int IFITEM_timeout = 2;
+
+ //--------------------- attributes
+ //--------------------- operations
+ public void stop (){
+ System.out.println(toString() + "::stop()");
+ timerService.cancel();
+ timerService = null;
+ }
+
+ //--------------------- construction
+ public ATimingService(IRTObject parent, String name, Address[][] port_addr, Address[][] peer_addr){
+ super(parent, name, port_addr[0][0], peer_addr[0][0]);
+ setClassName("ATimingService");
+
+ // initialize attributes
+
+ // own ports
+ // own saps
+ // own service implementations
+ timer = new PTimerPortRepl(this, "timer", IFITEM_timer, port_addr[IFITEM_timer], peer_addr[IFITEM_timer]);
+ timeout = new PTimeoutPortRepl(this, "timeout", IFITEM_timeout, port_addr[IFITEM_timeout], peer_addr[IFITEM_timeout]);
+ }
+
+
+ //--------------------- lifecycle functions
+ public void init(){
+ initUser();
+ }
+
+ public void start(){
+ startUser();
+ }
+
+
+ public void destroy(){
+ destroyUser();
+ }
+
+ //******************************************
+ // START of generated code for FSM
+ //******************************************
+
+ // State IDs for FSM
+ protected static final int STATE_Operational = 2;
+ protected static final String stateStrings[] = {"<no state>","<top>","Operational"
+ };
+
+ // history
+ // TODOHRR: history defined in ActorClassBase, init in constructor
+ // history = new int[5];
+ // for (int i = 0; i < history.length; i++) {
+ // history[i] = NO_STATE;
+ // }
+ protected int history[] = {NO_STATE,NO_STATE,NO_STATE};
+
+ // transition chains
+ protected static final int CHAIN_TRANS_INITIAL_TO__Operational = 1;
+ protected static final int CHAIN_TRANS_Operational_TO_Operational_BY_Killtimeout_tr2 = 2;
+ protected static final int CHAIN_TRANS_Operational_TO_Operational_BY_Killtimer_tr4 = 3;
+ protected static final int CHAIN_TRANS_Operational_TO_Operational_BY_Starttimeout_tr1 = 4;
+ protected static final int CHAIN_TRANS_Operational_TO_Operational_BY_Starttimer_tr3 = 5;
+
+ // triggers for FSM
+ protected static final int TRIG_timeout__Kill = IFITEM_timeout + EVT_SHIFT*PTimeout.IN_Kill;
+ protected static final int TRIG_timeout__Start = IFITEM_timeout + EVT_SHIFT*PTimeout.IN_Start;
+ protected static final int TRIG_timer__Kill = IFITEM_timer + EVT_SHIFT*PTimer.IN_Kill;
+ protected static final int TRIG_timer__Start = IFITEM_timer + EVT_SHIFT*PTimer.IN_Start;
+
+ // receiveEvent contains the main implementation of the FSM
+ @Override
+ public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {
+ int trigger = ifitem.getLocalId() + 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 (state) {
+ case STATE_Operational:
+ switch(trigger) {
+ case TRIG_timeout__Start:
+ {
+ chain = CHAIN_TRANS_Operational_TO_Operational_BY_Starttimeout_tr1;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_timeout__Kill:
+ {
+ chain = CHAIN_TRANS_Operational_TO_Operational_BY_Killtimeout_tr2;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_timer__Start:
+ {
+ chain = CHAIN_TRANS_Operational_TO_Operational_BY_Starttimer_tr3;
+ catching_state = STATE_TOP;
+ }
+ break;
+ case TRIG_timer__Kill:
+ {
+ chain = CHAIN_TRANS_Operational_TO_Operational_BY_Killtimer_tr4;
+ catching_state = STATE_TOP;
+ }
+ break;
+ }
+ break;
+ }
+ }
+ if (chain != NOT_CAUGHT) {
+ exitTo(state, catching_state, is_handler);
+ int next = executeTransitionChain(chain, ifitem, generic_data);
+ next = enterHistory(next, is_handler, skip_entry);
+ setState(next);
+ }
+ }
+
+ private void setState(int new_state) {
+ DebuggingService.getInstance().addActorState(this,stateStrings[new_state]);
+ if (stateStrings[new_state]!="Idle") {
+ // TODOTS: model switch for activation
+ System.out.println(getInstancePath() + " -> " + stateStrings[new_state]);
+ }
+ this.state = new_state;
+ }
+
+ @Override
+ public void executeInitTransition() {
+ int chain = CHAIN_TRANS_INITIAL_TO__Operational;
+ int next = executeTransitionChain(chain, null, null);
+ next = enterHistory(next, false, false);
+ setState(next);
+ }
+
+ /**
+ * 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)
+ */
+ private void exitTo(int current, int to, boolean handler) {
+ while (current!=to) {
+ switch (current) {
+ case STATE_Operational:
+ history[STATE_TOP] = STATE_Operational;
+ 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
+ */
+ private int executeTransitionChain(int chain, InterfaceItemBase ifitem, Object generic_data) {
+ switch (chain) {
+ case CHAIN_TRANS_INITIAL_TO__Operational:
+ {
+ action_TRANS_INITIAL_TO__Operational();
+ return STATE_Operational;
+ }
+ case CHAIN_TRANS_Operational_TO_Operational_BY_Starttimeout_tr1:
+ {
+ int time_ms = (Integer) generic_data;
+ action_TRANS_Operational_TO_Operational_BY_Starttimeout_tr1(ifitem, time_ms);
+ return STATE_Operational;
+ }
+ case CHAIN_TRANS_Operational_TO_Operational_BY_Killtimeout_tr2:
+ {
+ return STATE_Operational;
+ }
+ case CHAIN_TRANS_Operational_TO_Operational_BY_Starttimer_tr3:
+ {
+ int time_ms = (Integer) generic_data;
+ action_TRANS_Operational_TO_Operational_BY_Starttimer_tr3(ifitem, time_ms);
+ return STATE_Operational;
+ }
+ case CHAIN_TRANS_Operational_TO_Operational_BY_Killtimer_tr4:
+ {
+ return STATE_Operational;
+ }
+ }
+ 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
+ */
+ private int enterHistory(int state, boolean handler, boolean skip_entry) {
+ while (true) {
+ switch (state) {
+ case STATE_Operational:
+ if (!(skip_entry || handler)) entry_Operational();
+ // in leaf state: return state id
+ return STATE_Operational;
+ case STATE_TOP:
+ state = history[STATE_TOP];
+ break;
+ }
+ skip_entry = false;
+ }
+ //return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true)
+ }
+
+ //*** Entry and Exit Codes
+ protected void entry_Operational() {
+ // prepare
+ }
+
+ //*** Action Codes
+ protected void action_TRANS_INITIAL_TO__Operational() {
+ timerService = new Timer();
+ }
+ protected void action_TRANS_Operational_TO_Operational_BY_Starttimeout_tr1(InterfaceItemBase ifitem, int time_ms) {
+ // start timeout
+ taskCount++;
+ if (taskCount>PURGE_LIMIT) timerService.purge();
+ timerService.schedule(((PTimeoutPort)ifitem).getTask(), time_ms);
+ }
+ protected void action_TRANS_Operational_TO_Operational_BY_Starttimer_tr3(InterfaceItemBase ifitem, int time_ms) {
+ // start timer
+ taskCount++;
+ if (taskCount>PURGE_LIMIT) timerService.purge();
+ timerService.scheduleAtFixedRate(((PTimerPort)ifitem).getTask(), time_ms, time_ms);
+ }
+
+ //******************************************
+ // END of generated code for FSM
+ //******************************************
+};
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java
new file mode 100644
index 000000000..81cb8ec53
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimeout.java
@@ -0,0 +1,337 @@
+package room.basic.service.timing;
+
+import java.util.ArrayList;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.Message;
+import org.eclipse.etrice.runtime.java.modelbase.*;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+//--------------------- begin user code
+ import java.util.TimerTask;
+ //--------------------- end user code
+
+
+public class PTimeout {
+ // message IDs
+ // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
+ // error if msgID <= MSG_MIN
+ public static final int MSG_MIN = 0;
+ //IDs for outgoing messages
+ public static final int OUT_timeoutTick = 1;
+ //IDs for incoming messages
+ public static final int IN_Start = 2;
+ public static final int IN_Kill = 3;
+ //error if msgID >= MSG_MAX
+ public static final int MSG_MAX = 4;
+
+ //--------------------- begin user code
+ static protected class FireTimeoutTask extends TimerTask {
+
+ private int time;
+ private int id;
+ private PTimeoutPort port;
+
+ public FireTimeoutTask(int time, int id, PTimeoutPort port) {
+ this.time = time;
+ this.id = id;
+ this.port = port;
+ }
+
+ @Override
+ public void run() {
+ port.timeout(id);
+ }
+
+ public int getTime() {
+ return time;
+ }
+
+ public int getId() {
+ return id;
+ }
+ }
+
+ static protected class TimeoutData {
+ int time;
+ int id;
+ public TimeoutData(int time, int id) {
+ this.time = time;
+ this.id = id;
+ }
+ }
+ //--------------------- end user code
+
+ private static String messageStrings[] = {"MIN", "timeoutTick", "Start","Kill","MAX"};
+
+ public String getMessageString(int msg_id) {
+ if (msg_id<0 || msg_id>MSG_MAX+1){
+ // id out of range
+ return "Message ID out of range";
+ }
+ else{
+ return messageStrings[msg_id];
+ }
+ }
+
+
+ // port class
+ static public class PTimeoutPort extends PortBase {
+ //--------------------- begin user code
+ private FireTimeoutTask task = null;
+
+ public TimerTask getTask() { return task; }
+ //--------------------- end user code
+ // constructors
+ public PTimeoutPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ super(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PTimeoutPort(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()]);
+ }
+ switch (msg.getEvtId()) {
+ case IN_Start:
+ {
+ //regular PortClass handle start
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ TimeoutData td = (TimeoutData)dataMsg.getData();
+ task = new FireTimeoutTask(td.time, td.id, this);
+ getActor().receiveEvent(this, IN_Start, td.time);
+ }
+ break;
+ case IN_Kill:
+ {
+ //regular PortClass handle kill
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ int id = (Integer)dataMsg.getData();
+ if (task!=null && task.getId()==id) {
+ task.cancel();
+ }
+ }
+ break;
+ default:
+ if (msg instanceof EventWithDataMessage)
+ getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
+ else
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }
+ }
+ }
+
+ //--------------------- attributes
+ //--------------------- operations
+ public void timeout (Integer id){
+ //regular PortClass Operation timeout
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[OUT_timeoutTick]);
+
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), OUT_timeoutTick, id));
+ }
+
+ // sent messages
+ public void timeoutTick ()
+ {
+ if (messageStrings[ OUT_timeoutTick] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_timeoutTick]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_timeoutTick));
+ }
+ }
+
+ // replicated port class
+ static public class PTimeoutPortRepl {
+ private ArrayList<PTimeoutPort> ports;
+ private int replication;
+
+ public PTimeoutPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr.length;
+ ports = new ArrayList<PTimeout.PTimeoutPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PTimeoutPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PTimeoutPort get(int i) {
+ return ports.get(i);
+ }
+
+ // outgoing messages
+ public void timeoutTick ()
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).timeoutTick()
+ ;
+ }
+ }
+ }
+
+ // interface for port class
+ public interface IPTimeoutPort{
+ // incoming messages
+ public void Start (int time_ms)
+ ;
+ public void Kill ()
+ ;
+ }
+
+ // port class
+ static public class PTimeoutConjPort extends PortBase {
+ //--------------------- begin user code
+ private int currentId = 0;
+ private boolean active = false;
+ //--------------------- end user code
+ // constructors
+ public PTimeoutConjPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ super(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PTimeoutConjPort(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()]);
+ }
+ switch (msg.getEvtId()) {
+ case OUT_timeoutTick:
+ {
+ //conjugate PortClass handle timeout
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ int id = (Integer)dataMsg.getData();
+ if (active && id==currentId) {
+ active = false;
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }
+ }
+ break;
+ default:
+ if (msg instanceof EventWithDataMessage)
+ getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
+ else
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }
+ }
+ }
+
+ //--------------------- attributes
+ //--------------------- operations
+
+ // sent messages
+ public void Start (int time_ms)
+ {
+ //conjugate PortClass handle start
+ if (active)
+ return;
+
+ active = true;
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[IN_Start]);
+
+ getPeerMsgReceiver()
+ .receive(
+ new EventWithDataMessage(getPeerAddress(),
+ IN_Start, new TimeoutData(time_ms, ++currentId)));
+ }
+ public void Kill ()
+ {
+ //conjugate PortClass kill
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[IN_Kill]);
+
+ if (active) {
+ active = false;
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), IN_Kill, new Integer(currentId)));
+ }
+ }
+ }
+
+ // replicated port class
+ static public class PTimeoutConjPortRepl {
+ private ArrayList<PTimeoutConjPort> ports;
+ private int replication;
+
+ public PTimeoutConjPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr.length;
+ ports = new ArrayList<PTimeout.PTimeoutConjPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PTimeoutConjPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PTimeoutConjPort get(int i) {
+ return ports.get(i);
+ }
+
+ // incoming messages
+ public void Start (int time_ms)
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).Start( time_ms)
+ ;
+ }
+ }
+ public void Kill ()
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).Kill()
+ ;
+ }
+ }
+ }
+
+ // interface for port class
+ public interface IPTimeoutConjPort{
+ // outgoing messages
+ public void timeoutTick ()
+ ;
+ }
+}
diff --git a/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java
new file mode 100644
index 000000000..ad38c6340
--- /dev/null
+++ b/runtime/org.eclipse.etrice.modellib/src-gen/room/basic/service/timing/PTimer.java
@@ -0,0 +1,336 @@
+package room.basic.service.timing;
+
+import java.util.ArrayList;
+
+import org.eclipse.etrice.runtime.java.messaging.Address;
+import org.eclipse.etrice.runtime.java.messaging.Message;
+import org.eclipse.etrice.runtime.java.modelbase.*;
+import org.eclipse.etrice.runtime.java.debugging.DebuggingService;
+
+//--------------------- begin user code
+ import java.util.TimerTask;
+ //--------------------- end user code
+
+
+public class PTimer {
+ // message IDs
+ // TODO: separate class for message IDs: class MSG{public static volatile int MSG_MIN = 0; ...} -> better structure
+ // error if msgID <= MSG_MIN
+ public static final int MSG_MIN = 0;
+ //IDs for outgoing messages
+ public static final int OUT_timerTick = 1;
+ //IDs for incoming messages
+ public static final int IN_Start = 2;
+ public static final int IN_Kill = 3;
+ //error if msgID >= MSG_MAX
+ public static final int MSG_MAX = 4;
+
+ //--------------------- begin user code
+ static protected class FireTimerTask extends TimerTask {
+
+ private int time;
+ private int id;
+ private PTimerPort port;
+
+ public FireTimerTask(int time, int id, PTimerPort port) {
+ this.time = time;
+ this.id = id;
+ this.port = port;
+ }
+
+ @Override
+ public void run() {
+ port.timer(id);
+ }
+
+ public int getTime() {
+ return time;
+ }
+
+ public int getId() {
+ return id;
+ }
+ }
+
+ static protected class TimerData {
+ int time;
+ int id;
+ public TimerData(int time, int id) {
+ this.time = time;
+ this.id = id;
+ }
+ }
+ //--------------------- end user code
+
+ private static String messageStrings[] = {"MIN", "timerTick", "Start","Kill","MAX"};
+
+ public String getMessageString(int msg_id) {
+ if (msg_id<0 || msg_id>MSG_MAX+1){
+ // id out of range
+ return "Message ID out of range";
+ }
+ else{
+ return messageStrings[msg_id];
+ }
+ }
+
+
+ // port class
+ static public class PTimerPort extends PortBase {
+ //--------------------- begin user code
+ private FireTimerTask task = null;
+
+ public TimerTask getTask() { return task; }
+ //--------------------- end user code
+ // constructors
+ public PTimerPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ super(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PTimerPort(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()]);
+ }
+ switch (msg.getEvtId()) {
+ case IN_Start:
+ {
+ //regular PortClass handle start
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ TimerData td = (TimerData)dataMsg.getData();
+ task = new FireTimerTask(td.time, td.id, this);
+ getActor().receiveEvent(this, IN_Start, td.time);
+ }
+ break;
+ case IN_Kill:
+ {
+ //regular PortClass handle kill
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ int id = (Integer)dataMsg.getData();
+ if (task!=null && task.getId()==id) {
+ task.cancel();
+ }
+ }
+ break;
+ default:
+ if (msg instanceof EventWithDataMessage)
+ getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
+ else
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }
+ }
+ }
+
+ //--------------------- attributes
+ //--------------------- operations
+ public void timer (Integer id){
+ //regular PortClass Operation timer
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[OUT_timerTick]);
+
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), OUT_timerTick, id));
+ }
+
+ // sent messages
+ public void timerTick ()
+ {
+ if (messageStrings[ OUT_timerTick] != "timerTick"){
+ // TODOTS: model switch for activation
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_timerTick]);
+ }
+ if (getPeerAddress()!=null)
+ getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_timerTick));
+ }
+ }
+
+ // replicated port class
+ static public class PTimerPortRepl {
+ private ArrayList<PTimerPort> ports;
+ private int replication;
+
+ public PTimerPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr.length;
+ ports = new ArrayList<PTimer.PTimerPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PTimerPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PTimerPort get(int i) {
+ return ports.get(i);
+ }
+
+ // outgoing messages
+ public void timerTick ()
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).timerTick()
+ ;
+ }
+ }
+ }
+
+ // interface for port class
+ public interface IPTimerPort{
+ // incoming messages
+ public void Start (int time_ms)
+ ;
+ public void Kill ()
+ ;
+ }
+
+ // port class
+ static public class PTimerConjPort extends PortBase {
+ //--------------------- begin user code
+ private int currentId = 0;
+ private boolean active = false;
+ //--------------------- end user code
+ // constructors
+ public PTimerConjPort(IEventReceiver actor, String name, int localId, Address addr, Address peerAddress) {
+ super(actor, name, localId, 0, addr, peerAddress);
+ DebuggingService.getInstance().addPortInstance(this);
+ }
+ public PTimerConjPort(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()]);
+ }
+ switch (msg.getEvtId()) {
+ case OUT_timerTick:
+ {
+ //conjugate PortClass handle timer
+ EventWithDataMessage dataMsg = (EventWithDataMessage) msg;
+ int id = (Integer)dataMsg.getData();
+ if (active && id==currentId) {
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }
+ }
+ break;
+ default:
+ if (msg instanceof EventWithDataMessage)
+ getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData());
+ else
+ getActor().receiveEvent(this, msg.getEvtId(), null);
+ }
+ }
+ }
+
+ //--------------------- attributes
+ //--------------------- operations
+
+ // sent messages
+ public void Start (int time_ms)
+ {
+ //conjugate PortClass handle start
+ if (active)
+ return;
+
+ active = true;
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[IN_Start]);
+
+ getPeerMsgReceiver()
+ .receive(
+ new EventWithDataMessage(getPeerAddress(),
+ IN_Start, new TimerData(time_ms, ++currentId)));
+ }
+ public void Kill ()
+ {
+ //conjugate PortClass kill
+ DebuggingService.getInstance().addMessageAsyncOut(getAddress(),
+ getPeerAddress(), messageStrings[IN_Kill]);
+
+ if (active) {
+ active = false;
+ getPeerMsgReceiver().receive(
+ new EventWithDataMessage(getPeerAddress(), IN_Kill, currentId));
+ }
+ }
+ }
+
+ // replicated port class
+ static public class PTimerConjPortRepl {
+ private ArrayList<PTimerConjPort> ports;
+ private int replication;
+
+ public PTimerConjPortRepl(IEventReceiver actor, String name, int localId, Address[] addr,
+ Address[] peerAddress) {
+ replication = addr.length;
+ ports = new ArrayList<PTimer.PTimerConjPort>(replication);
+ for (int i=0; i<replication; ++i) {
+ ports.add(new PTimerConjPort(
+ actor, name+i, localId, i, addr[i], peerAddress[i]));
+ }
+ }
+
+ public int getReplication() {
+ return replication;
+ }
+
+ public int getIndexOf(InterfaceItemBase ifitem){
+ return ifitem.getIdx();
+ }
+
+ public PTimerConjPort get(int i) {
+ return ports.get(i);
+ }
+
+ // incoming messages
+ public void Start (int time_ms)
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).Start( time_ms)
+ ;
+ }
+ }
+ public void Kill ()
+ {
+ for (int i=0; i<replication; ++i) {
+ ports.get(i).Kill()
+ ;
+ }
+ }
+ }
+
+ // interface for port class
+ public interface IPTimerConjPort{
+ // outgoing messages
+ public void timerTick ()
+ ;
+ }
+}

Back to the top