From 0b73aabf556d52108cc50facb810359ac6c019a1 Mon Sep 17 00:00:00 2001 From: Juergen Haug Date: Thu, 31 Aug 2017 12:02:25 +0200 Subject: update of launch configs Change-Id: I75d5d153fe99294ca7a0cdd479eb4c2c6246c25c --- .../model/Features/gen_features.launch | 1 + .../gen_TrafficLight_step1.launch | 2 + .../gen_TrafficLight_step2.launch | 2 + .../gen_TrafficLight_step3.launch | 2 + .../gen_TrafficLight_step4.launch | 2 + .../model/dynamicactors1/gen_DynAct1.launch | 1 + .../model/dynamicactors2/gen_DynAct2.launch | 1 + .../model/dynamicactors3/gen_DynAct3.launch | 1 + .../model/dynamicactors4/gen_DynAct4.launch | 1 + .../model/dynamicactors5/gen_DynAct5.launch | 1 + .../model/dynamicactors6/gen_DynAct6.launch | 1 + .../model/dynamicactors7/gen_DynAct7.launch | 1 + .../model/dynamicactors8/gen_DynAct8.launch | 1 + .../model/dynamicactors9/gen_DynAct9.launch | 1 + .../Henrik-Test.launch | 1 + .../gen_MSCgen.launch | 1 + .../gen_MassiveMultiThreading.launch | 1 + .../gen_cGenRef.launch | 1 + .../generate_Reference.launch | 4 + .../generate_Template.launch | 1 + .../generate_Template.launch | 1 + .../model/HelloWorld/generate_HelloWorldC.launch | 1 + .../model/PingPong/generate_PingPongC.launch | 1 + .../model/HelloWorld/generate_HelloWorldCpp.launch | 1 + .../model/PingPong/generate_PingPongCpp.launch | 1 + .../gen_PingPongJava_aspecttrace.launch | 1 + .../HelloWorld/generate_HelloWorldJava.launch | 1 + .../model/PingPong/generate_PingPongJava.launch | 1 + .../gen_trafficlight.example.launch | 1 + .../generator/ui/wizard/EmptyProjectWizard.java | 2 +- .../etrice/generator/ui/wizard/ProjectCreator.java | 8 +- .../generator/ui/wizard/ProjectFileFragments.xtend | 5 +- .../generator/ui/wizard/ProjectFileFragments.java | 10 +- .../contents/org.eclipse.etrice.examples.c.zip | Bin 104131 -> 104212 bytes .../contents/org.eclipse.etrice.examples.java.zip | Bin 210088 -> 210217 bytes .../contents/org.eclipse.etrice.modellib.c.zip | Bin 194420 -> 99520 bytes .../contents/org.eclipse.etrice.modellib.cpp.zip | Bin 15875 -> 33905 bytes .../contents/org.eclipse.etrice.modellib.java.zip | Bin 47905 -> 69198 bytes .../contents/org.eclipse.etrice.runtime.c.zip | Bin 200344 -> 200515 bytes .../contents/org.eclipse.etrice.runtime.cpp.zip | Bin 87358 -> 84023 bytes .../contents/org.eclipse.etrice.runtime.java.zip | Bin 70307 -> 70329 bytes .../contents/org.eclipse.etrice.template.c.zip | Bin 12275 -> 12289 bytes .../contents/org.eclipse.etrice.template.cpp.zip | Bin 14006 -> 14017 bytes .../contents/org.eclipse.etrice.tutorials.c.zip | Bin 20906 -> 20931 bytes .../contents/org.eclipse.etrice.tutorials.cpp.zip | Bin 22173 -> 22199 bytes .../contents/org.eclipse.etrice.tutorials.java.zip | Bin 17881 -> 17906 bytes runtime/org.eclipse.etrice.modellib.c/.cproject | 12 +- runtime/org.eclipse.etrice.modellib.c/.gitignore | 5 +- .../doc-gen/images/ATimingService_behavior.jpg | Bin 22267 -> 0 bytes .../doc-gen/images/ATimingService_structure.jpg | Bin 15075 -> 0 bytes .../doc-gen/images/dot2jpg.bat | 0 .../doc-gen/readme.txt | 4 - .../doc-gen/room.basic.service.tcp.tex | 91 ----- .../doc-gen/room.basic.service.tcp/ATcpClient.tex | 76 ---- .../doc-gen/room.basic.service.tcp/ATcpServer.tex | 76 ---- .../doc-gen/room.basic.service.tcp/DTcpControl.tex | 13 - .../doc-gen/room.basic.service.tcp/DTcpPayload.tex | 35 -- .../doc-gen/room.basic.service.tcp/PTcpControl.tex | 24 -- .../doc-gen/room.basic.service.tcp/PTcpPayload.tex | 18 - .../doc-gen/room.basic.service.timing.pdf | Bin 116055 -> 0 bytes .../doc-gen/room.basic.service.timing.tex | 85 ----- .../room.basic.service.timing/ATimingService.tex | 97 ----- .../doc-gen/room.basic.service.timing/PTimer.tex | 22 -- .../doc-gen/room.basic.types.pdf | Bin 45320 -> 0 bytes .../doc-gen/room.basic.types.tex | 80 ---- .../gen_modellib_c.launch | 12 +- .../room/basic/service/pinterrupt/PInterrupt.c | 82 ++++ .../room/basic/service/pinterrupt/PInterrupt.h | 62 +++ .../basic/service/pinterrupt/PInterrupt_Utils.h | 30 ++ .../src-gen/room/basic/service/tcp/ATcpClient.c | 355 +++++++++++++++++ .../src-gen/room/basic/service/tcp/ATcpClient.h | 77 ++++ .../room/basic/service/tcp/ATcpClient_Utils.h | 45 +++ .../src-gen/room/basic/service/tcp/ATcpServer.c | 352 +++++++++++++++++ .../src-gen/room/basic/service/tcp/ATcpServer.h | 77 ++++ .../room/basic/service/tcp/ATcpServer_Utils.h | 45 +++ .../src-gen/room/basic/service/tcp/DTcpControl.c | 21 + .../src-gen/room/basic/service/tcp/DTcpControl.h | 30 ++ .../room/basic/service/tcp/DTcpControl_Utils.h | 24 ++ .../src-gen/room/basic/service/tcp/DTcpPayload.c | 41 ++ .../src-gen/room/basic/service/tcp/DTcpPayload.h | 36 ++ .../room/basic/service/tcp/DTcpPayload_Utils.h | 29 ++ .../src-gen/room/basic/service/tcp/PTcpControl.c | 173 +++++++++ .../src-gen/room/basic/service/tcp/PTcpControl.h | 67 ++++ .../room/basic/service/tcp/PTcpControl_Utils.h | 19 + .../src-gen/room/basic/service/tcp/PTcpPayload.c | 92 +++++ .../src-gen/room/basic/service/tcp/PTcpPayload.h | 55 +++ .../room/basic/service/tcp/PTcpPayload_Utils.h | 19 + .../room/basic/service/timing/ATimingService.c | 406 ++++++++++++++++++++ .../room/basic/service/timing/ATimingService.h | 89 +++++ .../basic/service/timing/ATimingService_Utils.h | 47 +++ .../src-gen/room/basic/service/timing/PTimer.c | 141 +++++++ .../src-gen/room/basic/service/timing/PTimer.h | 76 ++++ .../room/basic/service/timing/PTimer_Utils.h | 25 ++ .../src-gen/room/basic/test/PTestControl.c | 119 ++++++ .../src-gen/room/basic/test/PTestControl.h | 58 +++ .../src-gen/room/basic/test/PTestControl_Utils.h | 19 + .../room/basic/test/SequentialTestExecutor.c | 220 +++++++++++ .../room/basic/test/SequentialTestExecutor.h | 65 ++++ .../room/basic/test/SequentialTestExecutor_Utils.h | 42 ++ runtime/org.eclipse.etrice.modellib.cpp/.cproject | 9 +- runtime/org.eclipse.etrice.modellib.cpp/.gitignore | 4 - .../gen_modellib.launch | 2 +- .../room/basic/service/timing/ATimingService.cpp | 399 +++++++++++++++++++ .../room/basic/service/timing/ATimingService.h | 176 +++++++++ .../src-gen/room/basic/service/timing/PTimer.cpp | 226 +++++++++++ .../src-gen/room/basic/service/timing/PTimer.h | 145 +++++++ .../org.eclipse.etrice.modellib.java/.gitignore | 2 - .../gen_modellib.launch | 1 + .../room.basic.etunit.TestCaseActor.behavior | 284 -------------- .../room/basic/service/logging/ALogService.java | 307 +++++++++++++++ .../basic/service/logging/InternalLogData.java | 71 ++++ .../src-gen/room/basic/service/logging/Log.java | 217 +++++++++++ .../src-gen/room/basic/service/tcp/ATcpClient.java | 383 +++++++++++++++++++ .../src-gen/room/basic/service/tcp/ATcpServer.java | 421 +++++++++++++++++++++ .../room/basic/service/tcp/DTcpControl.java | 61 +++ .../room/basic/service/tcp/DTcpPayload.java | 78 ++++ .../room/basic/service/tcp/PTcpControl.java | 202 ++++++++++ .../room/basic/service/tcp/PTcpPayload.java | 183 +++++++++ .../room/basic/service/timing/ATimingService.java | 289 ++++++++++++++ .../src-gen/room/basic/service/timing/PTimer.java | 361 ++++++++++++++++++ .../room/basic/service/timing/TimerData.java | 60 +++ 121 files changed, 6689 insertions(+), 941 deletions(-) delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/images/ATimingService_behavior.jpg delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/images/ATimingService_structure.jpg delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/images/dot2jpg.bat delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/readme.txt delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp.tex delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/ATcpClient.tex delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/ATcpServer.tex delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/DTcpControl.tex delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/DTcpPayload.tex delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/PTcpControl.tex delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/PTcpPayload.tex delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing.pdf delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing.tex delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing/ATimingService.tex delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing/PTimer.tex delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.types.pdf delete mode 100644 runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.types.tex create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt.c create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt_Utils.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.c create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient_Utils.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.c create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer_Utils.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl.c create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl_Utils.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload.c create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload_Utils.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl.c create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl_Utils.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload.c create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload_Utils.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.c create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService_Utils.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer.c create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer_Utils.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/PTestControl.c create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/PTestControl.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/PTestControl_Utils.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/SequentialTestExecutor.c create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/SequentialTestExecutor.h create mode 100644 runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/SequentialTestExecutor_Utils.h create mode 100644 runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp create mode 100644 runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h create mode 100644 runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.cpp create mode 100644 runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.h delete mode 100644 runtime/org.eclipse.etrice.modellib.java/model/diagrams/room.basic.etunit.TestCaseActor.behavior create mode 100644 runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/ALogService.java create mode 100644 runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/InternalLogData.java create mode 100644 runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/Log.java create mode 100644 runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpClient.java create mode 100644 runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpServer.java create mode 100644 runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpControl.java create mode 100644 runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpPayload.java create mode 100644 runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpControl.java create mode 100644 runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpPayload.java create mode 100644 runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/ATimingService.java create mode 100644 runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/PTimer.java create mode 100644 runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/TimerData.java diff --git a/examples/org.eclipse.etrice.examples.c/model/Features/gen_features.launch b/examples/org.eclipse.etrice.examples.c/model/Features/gen_features.launch index 36c8f4bd0..9cd81a8b7 100644 --- a/examples/org.eclipse.etrice.examples.c/model/Features/gen_features.launch +++ b/examples/org.eclipse.etrice.examples.c/model/Features/gen_features.launch @@ -5,6 +5,7 @@ + diff --git a/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step1/gen_TrafficLight_step1.launch b/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step1/gen_TrafficLight_step1.launch index 1b2ca1c71..4ca4ef19d 100644 --- a/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step1/gen_TrafficLight_step1.launch +++ b/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step1/gen_TrafficLight_step1.launch @@ -5,6 +5,8 @@ + + diff --git a/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step2/gen_TrafficLight_step2.launch b/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step2/gen_TrafficLight_step2.launch index 05c407b63..006e9d955 100644 --- a/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step2/gen_TrafficLight_step2.launch +++ b/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step2/gen_TrafficLight_step2.launch @@ -5,6 +5,8 @@ + + diff --git a/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step3/gen_TrafficLight_step3.launch b/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step3/gen_TrafficLight_step3.launch index 5d124d6d9..101900702 100644 --- a/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step3/gen_TrafficLight_step3.launch +++ b/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step3/gen_TrafficLight_step3.launch @@ -5,6 +5,8 @@ + + diff --git a/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step4/gen_TrafficLight_step4.launch b/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step4/gen_TrafficLight_step4.launch index bee104e09..9af8355ea 100644 --- a/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step4/gen_TrafficLight_step4.launch +++ b/examples/org.eclipse.etrice.examples.c/model/TrafficLight_step4/gen_TrafficLight_step4.launch @@ -5,6 +5,8 @@ + + diff --git a/examples/org.eclipse.etrice.examples.java/model/dynamicactors1/gen_DynAct1.launch b/examples/org.eclipse.etrice.examples.java/model/dynamicactors1/gen_DynAct1.launch index 1d81912cd..d927b8481 100644 --- a/examples/org.eclipse.etrice.examples.java/model/dynamicactors1/gen_DynAct1.launch +++ b/examples/org.eclipse.etrice.examples.java/model/dynamicactors1/gen_DynAct1.launch @@ -8,6 +8,7 @@ + diff --git a/examples/org.eclipse.etrice.examples.java/model/dynamicactors2/gen_DynAct2.launch b/examples/org.eclipse.etrice.examples.java/model/dynamicactors2/gen_DynAct2.launch index 34afbb795..913571009 100644 --- a/examples/org.eclipse.etrice.examples.java/model/dynamicactors2/gen_DynAct2.launch +++ b/examples/org.eclipse.etrice.examples.java/model/dynamicactors2/gen_DynAct2.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.examples.java/model/dynamicactors3/gen_DynAct3.launch b/examples/org.eclipse.etrice.examples.java/model/dynamicactors3/gen_DynAct3.launch index 6874f24ff..5ae340ad2 100644 --- a/examples/org.eclipse.etrice.examples.java/model/dynamicactors3/gen_DynAct3.launch +++ b/examples/org.eclipse.etrice.examples.java/model/dynamicactors3/gen_DynAct3.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.examples.java/model/dynamicactors4/gen_DynAct4.launch b/examples/org.eclipse.etrice.examples.java/model/dynamicactors4/gen_DynAct4.launch index 2304f3a8e..a2485b748 100644 --- a/examples/org.eclipse.etrice.examples.java/model/dynamicactors4/gen_DynAct4.launch +++ b/examples/org.eclipse.etrice.examples.java/model/dynamicactors4/gen_DynAct4.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.examples.java/model/dynamicactors5/gen_DynAct5.launch b/examples/org.eclipse.etrice.examples.java/model/dynamicactors5/gen_DynAct5.launch index f8da46431..827396475 100644 --- a/examples/org.eclipse.etrice.examples.java/model/dynamicactors5/gen_DynAct5.launch +++ b/examples/org.eclipse.etrice.examples.java/model/dynamicactors5/gen_DynAct5.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.examples.java/model/dynamicactors6/gen_DynAct6.launch b/examples/org.eclipse.etrice.examples.java/model/dynamicactors6/gen_DynAct6.launch index 3ed6d29b0..afb596e14 100644 --- a/examples/org.eclipse.etrice.examples.java/model/dynamicactors6/gen_DynAct6.launch +++ b/examples/org.eclipse.etrice.examples.java/model/dynamicactors6/gen_DynAct6.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.examples.java/model/dynamicactors7/gen_DynAct7.launch b/examples/org.eclipse.etrice.examples.java/model/dynamicactors7/gen_DynAct7.launch index fbdd8cb17..ea45899e9 100644 --- a/examples/org.eclipse.etrice.examples.java/model/dynamicactors7/gen_DynAct7.launch +++ b/examples/org.eclipse.etrice.examples.java/model/dynamicactors7/gen_DynAct7.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.examples.java/model/dynamicactors8/gen_DynAct8.launch b/examples/org.eclipse.etrice.examples.java/model/dynamicactors8/gen_DynAct8.launch index 517e19057..51e91ccd8 100644 --- a/examples/org.eclipse.etrice.examples.java/model/dynamicactors8/gen_DynAct8.launch +++ b/examples/org.eclipse.etrice.examples.java/model/dynamicactors8/gen_DynAct8.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.examples.java/model/dynamicactors9/gen_DynAct9.launch b/examples/org.eclipse.etrice.examples.java/model/dynamicactors9/gen_DynAct9.launch index 9e00f6932..10729e976 100644 --- a/examples/org.eclipse.etrice.examples.java/model/dynamicactors9/gen_DynAct9.launch +++ b/examples/org.eclipse.etrice.examples.java/model/dynamicactors9/gen_DynAct9.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.generator.c.reference/Henrik-Test.launch b/examples/org.eclipse.etrice.generator.c.reference/Henrik-Test.launch index 65974de59..3018c9137 100644 --- a/examples/org.eclipse.etrice.generator.c.reference/Henrik-Test.launch +++ b/examples/org.eclipse.etrice.generator.c.reference/Henrik-Test.launch @@ -8,6 +8,7 @@ + diff --git a/examples/org.eclipse.etrice.generator.c.reference/gen_MSCgen.launch b/examples/org.eclipse.etrice.generator.c.reference/gen_MSCgen.launch index e703e2791..e4d8bf4b8 100644 --- a/examples/org.eclipse.etrice.generator.c.reference/gen_MSCgen.launch +++ b/examples/org.eclipse.etrice.generator.c.reference/gen_MSCgen.launch @@ -8,6 +8,7 @@ + diff --git a/examples/org.eclipse.etrice.generator.c.reference/gen_MassiveMultiThreading.launch b/examples/org.eclipse.etrice.generator.c.reference/gen_MassiveMultiThreading.launch index b63f63cf4..eb99b2595 100644 --- a/examples/org.eclipse.etrice.generator.c.reference/gen_MassiveMultiThreading.launch +++ b/examples/org.eclipse.etrice.generator.c.reference/gen_MassiveMultiThreading.launch @@ -8,6 +8,7 @@ + diff --git a/examples/org.eclipse.etrice.generator.c.reference/gen_cGenRef.launch b/examples/org.eclipse.etrice.generator.c.reference/gen_cGenRef.launch index fcd4535e1..5576bd023 100644 --- a/examples/org.eclipse.etrice.generator.c.reference/gen_cGenRef.launch +++ b/examples/org.eclipse.etrice.generator.c.reference/gen_cGenRef.launch @@ -8,6 +8,7 @@ + diff --git a/examples/org.eclipse.etrice.generator.cpp.reference/generate_Reference.launch b/examples/org.eclipse.etrice.generator.cpp.reference/generate_Reference.launch index cb341528c..19f3d8ac3 100644 --- a/examples/org.eclipse.etrice.generator.cpp.reference/generate_Reference.launch +++ b/examples/org.eclipse.etrice.generator.cpp.reference/generate_Reference.launch @@ -9,6 +9,10 @@ + + + + diff --git a/examples/org.eclipse.etrice.template.c/generate_Template.launch b/examples/org.eclipse.etrice.template.c/generate_Template.launch index 8530db744..5cdd89122 100644 --- a/examples/org.eclipse.etrice.template.c/generate_Template.launch +++ b/examples/org.eclipse.etrice.template.c/generate_Template.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.template.cpp/generate_Template.launch b/examples/org.eclipse.etrice.template.cpp/generate_Template.launch index 970394f6a..37298c3e5 100644 --- a/examples/org.eclipse.etrice.template.cpp/generate_Template.launch +++ b/examples/org.eclipse.etrice.template.cpp/generate_Template.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.tutorials.c/model/HelloWorld/generate_HelloWorldC.launch b/examples/org.eclipse.etrice.tutorials.c/model/HelloWorld/generate_HelloWorldC.launch index ebdecdb97..4b58f1402 100644 --- a/examples/org.eclipse.etrice.tutorials.c/model/HelloWorld/generate_HelloWorldC.launch +++ b/examples/org.eclipse.etrice.tutorials.c/model/HelloWorld/generate_HelloWorldC.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.tutorials.c/model/PingPong/generate_PingPongC.launch b/examples/org.eclipse.etrice.tutorials.c/model/PingPong/generate_PingPongC.launch index 0a1337a4a..d8d44b4e8 100644 --- a/examples/org.eclipse.etrice.tutorials.c/model/PingPong/generate_PingPongC.launch +++ b/examples/org.eclipse.etrice.tutorials.c/model/PingPong/generate_PingPongC.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.tutorials.cpp/model/HelloWorld/generate_HelloWorldCpp.launch b/examples/org.eclipse.etrice.tutorials.cpp/model/HelloWorld/generate_HelloWorldCpp.launch index fbb1ccdb4..6680599b9 100644 --- a/examples/org.eclipse.etrice.tutorials.cpp/model/HelloWorld/generate_HelloWorldCpp.launch +++ b/examples/org.eclipse.etrice.tutorials.cpp/model/HelloWorld/generate_HelloWorldCpp.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.tutorials.cpp/model/PingPong/generate_PingPongCpp.launch b/examples/org.eclipse.etrice.tutorials.cpp/model/PingPong/generate_PingPongCpp.launch index 702765a93..a6ad5f145 100644 --- a/examples/org.eclipse.etrice.tutorials.cpp/model/PingPong/generate_PingPongCpp.launch +++ b/examples/org.eclipse.etrice.tutorials.cpp/model/PingPong/generate_PingPongCpp.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.tutorials.java.aspecttrace/gen_PingPongJava_aspecttrace.launch b/examples/org.eclipse.etrice.tutorials.java.aspecttrace/gen_PingPongJava_aspecttrace.launch index 0e3efd8b2..6c8f70932 100644 --- a/examples/org.eclipse.etrice.tutorials.java.aspecttrace/gen_PingPongJava_aspecttrace.launch +++ b/examples/org.eclipse.etrice.tutorials.java.aspecttrace/gen_PingPongJava_aspecttrace.launch @@ -8,6 +8,7 @@ + diff --git a/examples/org.eclipse.etrice.tutorials.java/model/HelloWorld/generate_HelloWorldJava.launch b/examples/org.eclipse.etrice.tutorials.java/model/HelloWorld/generate_HelloWorldJava.launch index eaffe38f3..66e66dd58 100644 --- a/examples/org.eclipse.etrice.tutorials.java/model/HelloWorld/generate_HelloWorldJava.launch +++ b/examples/org.eclipse.etrice.tutorials.java/model/HelloWorld/generate_HelloWorldJava.launch @@ -10,6 +10,7 @@ + diff --git a/examples/org.eclipse.etrice.tutorials.java/model/PingPong/generate_PingPongJava.launch b/examples/org.eclipse.etrice.tutorials.java/model/PingPong/generate_PingPongJava.launch index 64f3ae681..c30de87a6 100644 --- a/examples/org.eclipse.etrice.tutorials.java/model/PingPong/generate_PingPongJava.launch +++ b/examples/org.eclipse.etrice.tutorials.java/model/PingPong/generate_PingPongJava.launch @@ -9,6 +9,7 @@ + diff --git a/examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/gen_trafficlight.example.launch b/examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/gen_trafficlight.example.launch index 76b6b7c38..833bda462 100644 --- a/examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/gen_trafficlight.example.launch +++ b/examples/org.eclipse.etrice.tutorials.simulators.trafficlight.example/gen_trafficlight.example.launch @@ -8,6 +8,7 @@ + diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/EmptyProjectWizard.java b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/EmptyProjectWizard.java index 526d1eaa1..c44c949e6 100644 --- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/EmptyProjectWizard.java +++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/EmptyProjectWizard.java @@ -164,7 +164,7 @@ public class EmptyProjectWizard extends Wizard implements INewWizard { ProjectCreator.createBuildProperties(projectURI.appendSegment("build.properties"), modelName); ProjectCreator.createLaunchGeneratorConfig(projectURI.appendSegment("generate_Template.launch"), - "java", "/" + projectName + "/model", "Mapping", AbstractGenerator.DEFAULT_MAIN_NAME, additionalLaunchConfigLines); + "java", "/" + projectName + "/model", AbstractGenerator.DEFAULT_MAIN_NAME, additionalLaunchConfigLines); ProjectCreator.createLaunchJavaApplicationConfig(projectURI.appendSegment("run_Template.launch"), projectName, MODEL_NAME, "Node_node_subSystemRefRunner"); diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectCreator.java b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectCreator.java index 401975de3..8ce45091c 100644 --- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectCreator.java +++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectCreator.java @@ -364,8 +364,8 @@ public class ProjectCreator { } public static void createLaunchGeneratorConfig(URI uri, - String targetLanguage, String modelPath, String baseName, String mainMethodName, String[] addLines) { - writeFile(uri, ProjectFileFragments.getGeneratorLaunchConfig(targetLanguage, modelPath, baseName, mainMethodName, addLines)); + String targetLanguage, String modelPath, String mainMethodName, String[] addLines) { + writeFile(uri, ProjectFileFragments.getGeneratorLaunchConfig(targetLanguage, modelPath, mainMethodName, addLines)); } public static void createLaunchJavaApplicationConfig(URI uri, @@ -385,7 +385,7 @@ public class ProjectCreator { ProjectCreator.createLaunchGeneratorConfig( URI.createPlatformResourceURI("/" + project.getName() + "/gen_" + baseName + ".launch", true), "java", - mdlPath, baseName, mainMethodName, additionalLaunchConfigLines); + mdlPath, mainMethodName, additionalLaunchConfigLines); ProjectCreator.createLaunchJavaApplicationConfig( URI.createPlatformResourceURI("/" + project.getName() + "/run_" + baseName + ".launch", true), @@ -401,7 +401,7 @@ public class ProjectCreator { ProjectCreator.createLaunchGeneratorConfig( URI.createPlatformResourceURI("/" + project.getName() + "/gen_" + baseName + ".launch", true), language, - mdlPath, baseName, mainMethodName, additionalLaunchConfigLines); + mdlPath, mainMethodName, additionalLaunchConfigLines); ProjectCreator.createLaunchCApplicationConfig( URI.createPlatformResourceURI("/" + project.getName() + "/run_" + baseName + ".launch", true), diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend index e698f80b6..2320db262 100644 --- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend +++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend @@ -85,7 +85,7 @@ class ProjectFileFragments { ''' } - def static String getGeneratorLaunchConfig(String targetLanguage, String modelPath, String baseName, String mainMethodName, String[] addLines) { + def static String getGeneratorLaunchConfig(String targetLanguage, String modelPath, String mainMethodName, String[] addLines) { val prefStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.etrice.generator.ui"); val useTranslation = prefStore.getBoolean(PreferenceConstants::GEN_USE_TRANSLATION) ''' @@ -96,7 +96,8 @@ class ProjectFileFragments { - + + diff --git a/plugins/org.eclipse.etrice.generator.ui/xtend-gen/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.java b/plugins/org.eclipse.etrice.generator.ui/xtend-gen/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.java index f1fe99688..3dabced7b 100644 --- a/plugins/org.eclipse.etrice.generator.ui/xtend-gen/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.java +++ b/plugins/org.eclipse.etrice.generator.ui/xtend-gen/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.java @@ -180,7 +180,7 @@ public class ProjectFileFragments { return _builder.toString(); } - public static String getGeneratorLaunchConfig(final String targetLanguage, final String modelPath, final String baseName, final String mainMethodName, final String[] addLines) { + public static String getGeneratorLaunchConfig(final String targetLanguage, final String modelPath, final String mainMethodName, final String[] addLines) { String _xblockexpression = null; { final ScopedPreferenceStore prefStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.etrice.generator.ui"); @@ -208,9 +208,11 @@ public class ProjectFileFragments { _builder.newLine(); _builder.append(""); + _builder.append("/Mapping.etmap}\"/>"); + _builder.newLineIfNotEmpty(); + _builder.append(""); _builder.newLineIfNotEmpty(); _builder.append(""); _builder.newLine(); diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zip index 3ecace8a9..8ff624aa9 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.c.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zip index acc143640..4ff8baf37 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.examples.java.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip index 01b556e8a..14f2417cf 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.c.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip index cd2962219..f54c3fe49 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.cpp.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip index 5df63c0f7..609bff7a1 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.modellib.java.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip index 1914fe307..35c8763c9 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.c.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip index 32cf6d8f7..374f8defd 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.cpp.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip index db59e9965..135792e1e 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.runtime.java.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zip index 24536ada3..b2c3bd678 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.c.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zip index 79db259db..eafc5f815 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.template.cpp.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip index 56e9239e0..1c423fe04 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.c.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zip index bad2140fb..008390a21 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.cpp.zip differ diff --git a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip index a86dfd48d..75b568abf 100644 Binary files a/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip and b/plugins/org.eclipse.etrice.ui.runtime/contents/org.eclipse.etrice.tutorials.java.zip differ diff --git a/runtime/org.eclipse.etrice.modellib.c/.cproject b/runtime/org.eclipse.etrice.modellib.c/.cproject index 45eb63297..7392f8315 100644 --- a/runtime/org.eclipse.etrice.modellib.c/.cproject +++ b/runtime/org.eclipse.etrice.modellib.c/.cproject @@ -12,9 +12,9 @@ + - @@ -86,11 +86,11 @@ + - @@ -162,11 +162,11 @@ + - @@ -238,9 +238,9 @@ + - @@ -302,9 +302,6 @@ - - - @@ -336,4 +333,5 @@ + diff --git a/runtime/org.eclipse.etrice.modellib.c/.gitignore b/runtime/org.eclipse.etrice.modellib.c/.gitignore index c572611b1..b8cb068ff 100644 --- a/runtime/org.eclipse.etrice.modellib.c/.gitignore +++ b/runtime/org.eclipse.etrice.modellib.c/.gitignore @@ -2,8 +2,6 @@ WindowsMinGW LinuxPosix WindowsMinGW_ST -src-gen/* -!src-gen/readme.txt src-gen-info/* !src-gen-info/readme.txt @@ -11,5 +9,4 @@ src-gen-info/* *.lof *.gz *.toc -*.log -/MinGWDebug/ +*.log \ No newline at end of file diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/images/ATimingService_behavior.jpg b/runtime/org.eclipse.etrice.modellib.c/doc-gen/images/ATimingService_behavior.jpg deleted file mode 100644 index 5599e352e..000000000 Binary files a/runtime/org.eclipse.etrice.modellib.c/doc-gen/images/ATimingService_behavior.jpg and /dev/null differ diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/images/ATimingService_structure.jpg b/runtime/org.eclipse.etrice.modellib.c/doc-gen/images/ATimingService_structure.jpg deleted file mode 100644 index d2ea00fa1..000000000 Binary files a/runtime/org.eclipse.etrice.modellib.c/doc-gen/images/ATimingService_structure.jpg and /dev/null differ diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/images/dot2jpg.bat b/runtime/org.eclipse.etrice.modellib.c/doc-gen/images/dot2jpg.bat deleted file mode 100644 index e69de29bb..000000000 diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/readme.txt b/runtime/org.eclipse.etrice.modellib.c/doc-gen/readme.txt deleted file mode 100644 index 1dc2b35ab..000000000 --- a/runtime/org.eclipse.etrice.modellib.c/doc-gen/readme.txt +++ /dev/null @@ -1,4 +0,0 @@ -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.c/doc-gen/room.basic.service.tcp.tex b/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp.tex deleted file mode 100644 index ad3903f17..000000000 --- a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp.tex +++ /dev/null @@ -1,91 +0,0 @@ -\documentclass[titlepage]{article} -\usepackage{import} -\usepackage{graphicx} -\usepackage{xr} -\usepackage{hyperref} -\IfFileExists{../doc/userinputs.tex}{\subimport{../doc/}{userinputs.tex}}{} %hook for conditional user-specific inputs, includes, macros, ... -\usepackage[a4paper,text={160mm,255mm},centering,headsep=5mm,footskip=10mm]{geometry} -\usepackage{nonfloat} -\parindent 0pt -\makeatletter -\newcommand\level[1]{% - \ifcase#1\relax\expandafter\chapter\or - \expandafter\section\or - \expandafter\subsection\or - \expandafter\subsubsection\else - \def\next{\@level{#1}}\expandafter\next - \fi} - -\newcommand{\@level}[1]{% -\@startsection{level#1} - {#1} - {\z@}% - {-3.25ex\@plus -1ex \@minus -.2ex}% - {1.5ex \@plus .2ex}% - {\normalfont\normalsize\bfseries}} - -\newdimen\@leveldim - \newdimen\@dotsdim - {\normalfont\normalsize - \sbox\z@{0}\global\@leveldim=\wd\z@ - \sbox\z@{.}\global\@dotsdim=\wd\z@ - } -\newcounter{level4}[subsubsection] - \@namedef{thelevel4}{\thesubsubsection.\arabic{level4}} - \@namedef{level4mark}#1{} - \def\l@section{\@dottedtocline{1}{0pt}{\dimexpr\@leveldim*4+\@dotsdim*1+6pt\relax}} - \def\l@subsection{\@dottedtocline{2}{0pt}{\dimexpr\@leveldim*5+\@dotsdim*2+6pt\relax}} - \def\l@subsubsection{\@dottedtocline{3}{0pt}{\dimexpr\@leveldim*6+\@dotsdim*3+6pt\relax}} - \@namedef{l@level4}{\@dottedtocline{4}{0pt}{\dimexpr\@leveldim*7+\@dotsdim*4+6pt\relax}} - -\count@=4 - \def\@ncp#1{\number\numexpr\count@+#1\relax} - \loop\ifnum\count@<100 - \begingroup\edef\x{\endgroup - \noexpand\newcounter{level\@ncp{1}}[level\number\count@] - \noexpand\@namedef{thelevel\@ncp{1}}{% - \noexpand\@nameuse{thelevel\@ncp{0}}.\noexpand\arabic{level\@ncp{0}}} - \noexpand\@namedef{level\@ncp{1}mark}####1{}% - \noexpand\@namedef{l@level\@ncp{1}}% - {\noexpand\@dottedtocline{\@ncp{1}}{0pt}{\the\dimexpr\@leveldim*\@ncp{5}+\@dotsdim*\@ncp{0}\relax}}}% - \x - \advance\count@\@ne - \repeat - \makeatother - \setcounter{secnumdepth}{100} - \setcounter{tocdepth}{100} - - -\title{room.basic.service.tcp Model Documentation} -\date{\today} -\author{generated by eTrice} - -\begin{document} - -\pagestyle{plain} -\maketitle -\tableofcontents - -\newpage -\listoffigures -\newpage -\section{Model Description} - - - - -\section{Protocol Classes} -\subimport*{room.basic.service.tcp/}{PTcpControl.tex} -\subimport*{room.basic.service.tcp/}{PTcpPayload.tex} -\newpage - - -\section{Data Classes} -\subimport*{room.basic.service.tcp/}{DTcpControl.tex} -\subimport*{room.basic.service.tcp/}{DTcpPayload.tex} -\newpage - -\section{Actor Classes} -\subimport*{room.basic.service.tcp/}{ATcpServer.tex} -\subimport*{room.basic.service.tcp/}{ATcpClient.tex} -\end{document} diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/ATcpClient.tex b/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/ATcpClient.tex deleted file mode 100644 index cabf2e955..000000000 --- a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/ATcpClient.tex +++ /dev/null @@ -1,76 +0,0 @@ -\level{2}{ATcpClient} - - -\level{3}{Ports} -\begin{tabular}[ht]{|l|l|l|l|l|p{5cm}|} -\hline -\textbf{Name} & \textbf{Protocol} & \textbf{Type} & \textbf{Kind} & \textbf{Multiplicity} & \textbf{Description}\\ -\hline -controlPort & PTcpControl & reg. & external & 1 & \\ -\hline -payloadPort & PTcpPayload & reg. & external & 1 & \\ -\hline -\end{tabular} - -\level{3}{Behavior} -\level{4}{Top Level} - -\begin{par} - -\end{par} - - -\level{3}{Attributes} -\begin{tabular}[ht]{|l|l|p{8cm}|} -\hline -\textbf{Name} & \textbf{Type} & \textbf{Description}\\ -\hline -lastError & int32 & \\ -\hline -payload & DTcpPayload & \\ -\hline -client & etSocketConnectionData & \\ -\hline -\end{tabular} - -\level{3}{Operations} -\begin{tabular}[ht]{|l|l|} -\hline - Name: & ATcpClient\\ - \hline - ReturnType: & void\\ - \hline - Arguments: & \\ - \hline -\end{tabular} -\newline\newline\newline -\begin{tabular}[ht]{|l|l|} -\hline - Name: & ATcpClient\\ - \hline - ReturnType: & void\\ - \hline - Arguments: & \\ - \hline -\end{tabular} -\newline\newline\newline -\begin{tabular}[ht]{|l|l|} -\hline - Name: & hasError\\ - \hline - ReturnType: & boolean\\ - \hline - Arguments: & \\ - \hline -\end{tabular} -\newline\newline\newline -\begin{tabular}[ht]{|l|l|} -\hline - Name: & setErrorCode\\ - \hline - ReturnType: & void\\ - \hline - Arguments: & value:int32\\ - \hline -\end{tabular} -\newline\newline\newline diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/ATcpServer.tex b/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/ATcpServer.tex deleted file mode 100644 index 076c42260..000000000 --- a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/ATcpServer.tex +++ /dev/null @@ -1,76 +0,0 @@ -\level{2}{ATcpServer} - - -\level{3}{Ports} -\begin{tabular}[ht]{|l|l|l|l|l|p{5cm}|} -\hline -\textbf{Name} & \textbf{Protocol} & \textbf{Type} & \textbf{Kind} & \textbf{Multiplicity} & \textbf{Description}\\ -\hline -controlPort & PTcpControl & reg. & external & 1 & \\ -\hline -payloadPort & PTcpPayload & reg. & external & 1 & \\ -\hline -\end{tabular} - -\level{3}{Behavior} -\level{4}{Top Level} - -\begin{par} - -\end{par} - - -\level{3}{Attributes} -\begin{tabular}[ht]{|l|l|p{8cm}|} -\hline -\textbf{Name} & \textbf{Type} & \textbf{Description}\\ -\hline -lastError & int32 & \\ -\hline -payloadPortReplocation & int32 & \\ -\hline -server & etSocketServerData & \\ -\hline -\end{tabular} - -\level{3}{Operations} -\begin{tabular}[ht]{|l|l|} -\hline - Name: & ATcpServer\\ - \hline - ReturnType: & void\\ - \hline - Arguments: & \\ - \hline -\end{tabular} -\newline\newline\newline -\begin{tabular}[ht]{|l|l|} -\hline - Name: & ATcpServer\\ - \hline - ReturnType: & void\\ - \hline - Arguments: & \\ - \hline -\end{tabular} -\newline\newline\newline -\begin{tabular}[ht]{|l|l|} -\hline - Name: & hasError\\ - \hline - ReturnType: & boolean\\ - \hline - Arguments: & \\ - \hline -\end{tabular} -\newline\newline\newline -\begin{tabular}[ht]{|l|l|} -\hline - Name: & setErrorCode\\ - \hline - ReturnType: & void\\ - \hline - Arguments: & value:int32\\ - \hline -\end{tabular} -\newline\newline\newline diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/DTcpControl.tex b/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/DTcpControl.tex deleted file mode 100644 index f15d98420..000000000 --- a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/DTcpControl.tex +++ /dev/null @@ -1,13 +0,0 @@ -\level{2} {DTcpControl} -\level{3}{Attributes} -\begin{tabular}[ht]{|l|l|p{8cm}|} -\hline -\textbf{Name} & \textbf{Type} & \textbf{Description}\\ -\hline -IPAddr & string & \\ -\hline -TcpPort & int32 & \\ -\hline -\end{tabular} - -\level{3}{Operations} diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/DTcpPayload.tex b/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/DTcpPayload.tex deleted file mode 100644 index fd80f9c2c..000000000 --- a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/DTcpPayload.tex +++ /dev/null @@ -1,35 +0,0 @@ -\level{2} {DTcpPayload} -\level{3}{Attributes} -\begin{tabular}[ht]{|l|l|p{8cm}|} -\hline -\textbf{Name} & \textbf{Type} & \textbf{Description}\\ -\hline -connectionId & int32 & \\ -\hline -length & int32 & \\ -\hline -data & int8 & \\ -\hline -\end{tabular} - -\level{3}{Operations} -\begin{tabular}[ht]{|l|l|} -\hline - Name: & setAsString\\ - \hline - ReturnType: & void\\ - \hline - Arguments: & value:charPtr\\ - \hline -\end{tabular} -\newline\newline\newline -\begin{tabular}[ht]{|l|l|} -\hline - Name: & getAsString\\ - \hline - ReturnType: & void\\ - \hline - Arguments: & value:charPtr\\ - \hline -\end{tabular} -\newline\newline\newline diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/PTcpControl.tex b/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/PTcpControl.tex deleted file mode 100644 index d6f4ed000..000000000 --- a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/PTcpControl.tex +++ /dev/null @@ -1,24 +0,0 @@ -\level{2} {PTcpControl} -\level{3}{Incoming Messages} - -\begin{tabular}[ht]{|l|l|l|p{8cm}|} -\hline -Message & Data & Type & Description\\ -\hline -connect & data & DTcpControl & \\ -\hline -disconnect & & & \\ -\hline -\end{tabular} -\level{3}{Outgoing Messages} -\begin{tabular}[ht]{|l|l|l|p{8cm}|} -\hline -Message & Data & Type & Description\\ -\hline -connected & & & \\ -\hline -disconnected & & & \\ -\hline -error & & & \\ -\hline -\end{tabular} diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/PTcpPayload.tex b/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/PTcpPayload.tex deleted file mode 100644 index 4c4931872..000000000 --- a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.tcp/PTcpPayload.tex +++ /dev/null @@ -1,18 +0,0 @@ -\level{2} {PTcpPayload} -\level{3}{Incoming Messages} - -\begin{tabular}[ht]{|l|l|l|p{8cm}|} -\hline -Message & Data & Type & Description\\ -\hline -dataPackage & data & DTcpPayload & \\ -\hline -\end{tabular} -\level{3}{Outgoing Messages} -\begin{tabular}[ht]{|l|l|l|p{8cm}|} -\hline -Message & Data & Type & Description\\ -\hline -dataPackage & data & DTcpPayload & \\ -\hline -\end{tabular} diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing.pdf b/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing.pdf deleted file mode 100644 index fb9df2de3..000000000 Binary files a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing.pdf and /dev/null differ diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing.tex b/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing.tex deleted file mode 100644 index fcda0bc46..000000000 --- a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing.tex +++ /dev/null @@ -1,85 +0,0 @@ -\documentclass[titlepage]{article} -\usepackage{import} -\usepackage{graphicx} -\usepackage{xr} -\usepackage{hyperref} -\IfFileExists{../doc/userinputs.tex}{\subimport{../doc/}{userinputs.tex}}{} %hook for conditional user-specific inputs, includes, macros, ... -\usepackage[a4paper,text={160mm,255mm},centering,headsep=5mm,footskip=10mm]{geometry} -\usepackage{nonfloat} -\parindent 0pt -\makeatletter -\newcommand\level[1]{% - \ifcase#1\relax\expandafter\chapter\or - \expandafter\section\or - \expandafter\subsection\or - \expandafter\subsubsection\else - \def\next{\@level{#1}}\expandafter\next - \fi} - -\newcommand{\@level}[1]{% -\@startsection{level#1} - {#1} - {\z@}% - {-3.25ex\@plus -1ex \@minus -.2ex}% - {1.5ex \@plus .2ex}% - {\normalfont\normalsize\bfseries}} - -\newdimen\@leveldim - \newdimen\@dotsdim - {\normalfont\normalsize - \sbox\z@{0}\global\@leveldim=\wd\z@ - \sbox\z@{.}\global\@dotsdim=\wd\z@ - } -\newcounter{level4}[subsubsection] - \@namedef{thelevel4}{\thesubsubsection.\arabic{level4}} - \@namedef{level4mark}#1{} - \def\l@section{\@dottedtocline{1}{0pt}{\dimexpr\@leveldim*4+\@dotsdim*1+6pt\relax}} - \def\l@subsection{\@dottedtocline{2}{0pt}{\dimexpr\@leveldim*5+\@dotsdim*2+6pt\relax}} - \def\l@subsubsection{\@dottedtocline{3}{0pt}{\dimexpr\@leveldim*6+\@dotsdim*3+6pt\relax}} - \@namedef{l@level4}{\@dottedtocline{4}{0pt}{\dimexpr\@leveldim*7+\@dotsdim*4+6pt\relax}} - -\count@=4 - \def\@ncp#1{\number\numexpr\count@+#1\relax} - \loop\ifnum\count@<100 - \begingroup\edef\x{\endgroup - \noexpand\newcounter{level\@ncp{1}}[level\number\count@] - \noexpand\@namedef{thelevel\@ncp{1}}{% - \noexpand\@nameuse{thelevel\@ncp{0}}.\noexpand\arabic{level\@ncp{0}}} - \noexpand\@namedef{level\@ncp{1}mark}####1{}% - \noexpand\@namedef{l@level\@ncp{1}}% - {\noexpand\@dottedtocline{\@ncp{1}}{0pt}{\the\dimexpr\@leveldim*\@ncp{5}+\@dotsdim*\@ncp{0}\relax}}}% - \x - \advance\count@\@ne - \repeat - \makeatother - \setcounter{secnumdepth}{100} - \setcounter{tocdepth}{100} - - -\title{room.basic.service.timing Model Documentation} -\date{\today} -\author{generated by eTrice} - -\begin{document} - -\pagestyle{plain} -\maketitle -\tableofcontents - -\newpage -\listoffigures -\newpage -\section{Model Description} - - - - -\section{Protocol Classes} -\subimport*{room.basic.service.timing/}{PTimer.tex} -\newpage - - - -\section{Actor Classes} -\subimport*{room.basic.service.timing/}{ATimingService.tex} -\end{document} diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing/ATimingService.tex b/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing/ATimingService.tex deleted file mode 100644 index 861041016..000000000 --- a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing/ATimingService.tex +++ /dev/null @@ -1,97 +0,0 @@ -\level{2}{ATimingService} - -\level{3}{Structure} -{ -\centering{} -\includegraphics[width=1.0\textwidth]{./images/ATimingService_structure.jpg} -\figcaption{ATimingService Structure} -} - - -\level{3}{Behavior} -\level{4}{Top Level} -{ -\centering{} -\includegraphics[width=1.0\textwidth]{./images/ATimingService_behavior.jpg} -\figcaption{ATimingService Top State} -} - -\begin{par} - -\end{par} - - -\level{3}{Attributes} -\begin{tabular}[ht]{|l|l|p{8cm}|} -\hline -\textbf{Name} & \textbf{Type} & \textbf{Description}\\ -\hline -tcbs & tcb & \\ -\hline -usedTcbsRoot & tcb & \\ -\hline -freeTcbsRoot & tcb & \\ -\hline -\end{tabular} - -\level{3}{Operations} -\begin{tabular}[ht]{|l|l|} -\hline - Name: & getTcb\\ - \hline - ReturnType: & tcb\\ - \hline - Arguments: & \\ - \hline -\end{tabular} -\newline\newline\newline -\begin{tabular}[ht]{|l|l|} -\hline - Name: & returnTcb\\ - \hline - ReturnType: & void\\ - \hline - Arguments: & block:tcb\\ - \hline -\end{tabular} -\newline\newline\newline -\begin{tabular}[ht]{|l|l|} -\hline - Name: & removeTcbFromUsedList\\ - \hline - ReturnType: & void\\ - \hline - Arguments: & idx:int32\\ - \hline -\end{tabular} -\newline\newline\newline -\begin{tabular}[ht]{|l|l|} -\hline - Name: & putTcbToUsedList\\ - \hline - ReturnType: & void\\ - \hline - Arguments: & block:tcb\\ - \hline -\end{tabular} -\newline\newline\newline -\begin{tabular}[ht]{|l|l|} -\hline - Name: & isTimeGreater\\ - \hline - ReturnType: & boolean\\ - \hline - Arguments: & t1:targetTime, t2:targetTime\\ - \hline -\end{tabular} -\newline\newline\newline -\begin{tabular}[ht]{|l|l|} -\hline - Name: & addTime\\ - \hline - ReturnType: & void\\ - \hline - Arguments: & t1:targetTime, t2:targetTime\\ - \hline -\end{tabular} -\newline\newline\newline diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing/PTimer.tex b/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing/PTimer.tex deleted file mode 100644 index 9319ec255..000000000 --- a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.service.timing/PTimer.tex +++ /dev/null @@ -1,22 +0,0 @@ -\level{2} {PTimer} -\level{3}{Incoming Messages} - -\begin{tabular}[ht]{|l|l|l|p{8cm}|} -\hline -Message & Data & Type & Description\\ -\hline -startTimer & time & uint32 & \\ -\hline -startTimeout & time & uint32 & \\ -\hline -kill & & & \\ -\hline -\end{tabular} -\level{3}{Outgoing Messages} -\begin{tabular}[ht]{|l|l|l|p{8cm}|} -\hline -Message & Data & Type & Description\\ -\hline -timeout & & & \\ -\hline -\end{tabular} diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.types.pdf b/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.types.pdf deleted file mode 100644 index 4b999f165..000000000 Binary files a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.types.pdf and /dev/null differ diff --git a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.types.tex b/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.types.tex deleted file mode 100644 index 5cb44f958..000000000 --- a/runtime/org.eclipse.etrice.modellib.c/doc-gen/room.basic.types.tex +++ /dev/null @@ -1,80 +0,0 @@ -\documentclass[titlepage]{article} -\usepackage{import} -\usepackage{graphicx} -\usepackage{xr} -\usepackage{hyperref} -\IfFileExists{../doc/userinputs.tex}{\subimport{../doc/}{userinputs.tex}}{} %hook for conditional user-specific inputs, includes, macros, ... -\usepackage[a4paper,text={160mm,255mm},centering,headsep=5mm,footskip=10mm]{geometry} -\usepackage{nonfloat} -\parindent 0pt -\makeatletter -\newcommand\level[1]{% - \ifcase#1\relax\expandafter\chapter\or - \expandafter\section\or - \expandafter\subsection\or - \expandafter\subsubsection\else - \def\next{\@level{#1}}\expandafter\next - \fi} - -\newcommand{\@level}[1]{% -\@startsection{level#1} - {#1} - {\z@}% - {-3.25ex\@plus -1ex \@minus -.2ex}% - {1.5ex \@plus .2ex}% - {\normalfont\normalsize\bfseries}} - -\newdimen\@leveldim - \newdimen\@dotsdim - {\normalfont\normalsize - \sbox\z@{0}\global\@leveldim=\wd\z@ - \sbox\z@{.}\global\@dotsdim=\wd\z@ - } -\newcounter{level4}[subsubsection] - \@namedef{thelevel4}{\thesubsubsection.\arabic{level4}} - \@namedef{level4mark}#1{} - \def\l@section{\@dottedtocline{1}{0pt}{\dimexpr\@leveldim*4+\@dotsdim*1+6pt\relax}} - \def\l@subsection{\@dottedtocline{2}{0pt}{\dimexpr\@leveldim*5+\@dotsdim*2+6pt\relax}} - \def\l@subsubsection{\@dottedtocline{3}{0pt}{\dimexpr\@leveldim*6+\@dotsdim*3+6pt\relax}} - \@namedef{l@level4}{\@dottedtocline{4}{0pt}{\dimexpr\@leveldim*7+\@dotsdim*4+6pt\relax}} - -\count@=4 - \def\@ncp#1{\number\numexpr\count@+#1\relax} - \loop\ifnum\count@<100 - \begingroup\edef\x{\endgroup - \noexpand\newcounter{level\@ncp{1}}[level\number\count@] - \noexpand\@namedef{thelevel\@ncp{1}}{% - \noexpand\@nameuse{thelevel\@ncp{0}}.\noexpand\arabic{level\@ncp{0}}} - \noexpand\@namedef{level\@ncp{1}mark}####1{}% - \noexpand\@namedef{l@level\@ncp{1}}% - {\noexpand\@dottedtocline{\@ncp{1}}{0pt}{\the\dimexpr\@leveldim*\@ncp{5}+\@dotsdim*\@ncp{0}\relax}}}% - \x - \advance\count@\@ne - \repeat - \makeatother - \setcounter{secnumdepth}{100} - \setcounter{tocdepth}{100} - - -\title{room.basic.types Model Documentation} -\date{\today} -\author{generated by eTrice} - -\begin{document} - -\pagestyle{plain} -\maketitle -\tableofcontents - -\newpage -\listoffigures -\newpage -\section{Model Description} - - - - - - - -\end{document} diff --git a/runtime/org.eclipse.etrice.modellib.c/gen_modellib_c.launch b/runtime/org.eclipse.etrice.modellib.c/gen_modellib_c.launch index da0481584..cb2bf6824 100644 --- a/runtime/org.eclipse.etrice.modellib.c/gen_modellib_c.launch +++ b/runtime/org.eclipse.etrice.modellib.c/gen_modellib_c.launch @@ -1,16 +1,22 @@ + - - + + + + + + + - + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt.c new file mode 100644 index 000000000..4109a1a28 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt.c @@ -0,0 +1,82 @@ +/** + * @author generated by eTrice + * + * Source File of ProtocolClass PInterrupt + * + */ + +#include "PInterrupt.h" +#include "debugging/etMSCLogger.h" +#include "PInterrupt_Utils.h" + + +/*--------------------- port methods */ +etInt32 PInterruptReplPort_getReplication(const PInterruptReplPort* self) { + return ((etReplPort*)self)->size; +} + + + +void PInterruptConjPort_event(const PInterruptConjPort* self) { + // the message should be sent via the fire operation !! +} + +void PInterruptConjReplPort_event_broadcast(const PInterruptConjReplPort* self) { + int i; + for (i=0; i<((etReplPort*)self)->size; ++i) { + PInterruptConjPort_event(&((etReplPort*)self)->ports[i].port); + } +} + +void PInterruptConjReplPort_event(const PInterruptConjReplPort* self, int idx__et) { + PInterruptConjPort_event(&((etReplPort*)self)->ports[idx__et].port); +} + +/* begin PInterruptConjPort specific (including base classes) */ +/*--------------------- begin user code ---------------------*/ +#include "messaging/etMessageService.h" +/*--------------------- end user code ---------------------*/ + +/*--------------------- operations ---------------------*/ + PInterruptConjPort* PInterruptConjPort_export(PInterruptConjPort* self) { + msg.address = self->peerAddress; + msg.evtID = PInterrupt_IN_event; + callback.func=(void (*)(void*))PInterruptConjPort_dispatch; + callback.param=(void *)self; + etMessageService_registerHighPrioFunc(self->msgService,&callback); + return self; +} + void PInterruptConjPort_dispatch(PInterruptConjPort* self) { + // this operation will be executed from the message service + if (enable){ + enable=0; + self->msgService->msgDispatcher(&msg); + } +} + void PInterruptConjPort_fire(PInterruptConjPort* self) { + // this method runs on interrupt level + enable=1; + etSema_wakeupFromISR(&self->msgService->executionSemaphore); +} +/* end PInterruptConjPort specific (including base classes) */ + +etInt32 PInterruptConjReplPort_getReplication(const PInterruptConjReplPort* self) { + return ((etReplPort*)self)->size; +} + + + +/*--------------------- debug helpers */ + +/* message names as strings for debugging (generate MSC) */ +static const char* const PInterrupt_messageStrings[] = {"MIN", "event", "MAX"}; + +const char* PInterrupt_getMessageString(int msg_id) { + if (msg_idPInterrupt_MSG_MAX+1){ + /* id out of range */ + return "Message ID out of range"; + } + else{ + return PInterrupt_messageStrings[msg_id]; + } +} diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt.h new file mode 100644 index 000000000..602d5601a --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt.h @@ -0,0 +1,62 @@ +/** + * @author generated by eTrice + * + * Header File of ProtocolClass PInterrupt + * + */ + +#ifndef _ROOM_BASIC_SERVICE_PINTERRUPT_PINTERRUPT_H_ +#define _ROOM_BASIC_SERVICE_PINTERRUPT_PINTERRUPT_H_ + +#include "etDatatypes.h" +#include "modelbase/etPort.h" + + + + +/* message IDs */ +enum PInterrupt_msg_ids { + PInterrupt_MSG_MIN = 0, + PInterrupt_IN_event = 1, + PInterrupt_MSG_MAX = 2 +}; + +/*--------------------- port structs and methods */ +typedef etPort PInterruptPort; +typedef etReplPort PInterruptReplPort; + + + + +etInt32 PInterruptReplPort_getReplication(const PInterruptReplPort* self); +typedef etPort PInterruptConjPort; +typedef etReplPort PInterruptConjReplPort; + +/* variable part of PortClass (RAM) */ +typedef struct PInterruptConjPort_var PInterruptConjPort_var; +struct PInterruptConjPort_var { + /*--------------------- attributes ---------------------*/ + etMessage msg; + etHighPrioFunc callback; + uint8 enable; +}; + +void PInterruptConjPort_event(const PInterruptConjPort* self); +void PInterruptConjReplPort_event_broadcast(const PInterruptConjReplPort* self); +void PInterruptConjReplPort_event(const PInterruptConjReplPort* self, int idx); + +/*--------------------- operations ---------------------*/ + PInterruptConjPort* PInterruptConjPort_export(PInterruptConjPort* self); + void PInterruptConjPort_dispatch(PInterruptConjPort* self); + void PInterruptConjPort_fire(PInterruptConjPort* self); + +etInt32 PInterruptConjReplPort_getReplication(const PInterruptConjReplPort* self); + +/*--------------------- debug helpers */ + +/* get message string for message id */ +const char* PInterrupt_getMessageString(int msg_id); + + +#endif /* _ROOM_BASIC_SERVICE_PINTERRUPT_PINTERRUPT_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt_Utils.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt_Utils.h new file mode 100644 index 000000000..edca92e35 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/pinterrupt/PInterrupt_Utils.h @@ -0,0 +1,30 @@ +/** + * @author generated by eTrice + * + * Utils File of ProtocolClass PInterrupt + * + */ + +#ifndef _ROOM_BASIC_SERVICE_PINTERRUPT_PINTERRUPT_UTILS_H_ +#define _ROOM_BASIC_SERVICE_PINTERRUPT_PINTERRUPT_UTILS_H_ + +#include "room/basic/service/pinterrupt/PInterrupt.h" + +/* + * access macros for operations and attributes +*/ + +/* conjugate port class */ + +/* operations */ +#define export() PInterruptConjPort_export(self) +#define dispatch() PInterruptConjPort_dispatch(self) +#define fire() PInterruptConjPort_fire(self) + +/* attributes */ +#define msg (((PInterruptConjPort_var*)(self->varData))->msg) +#define callback (((PInterruptConjPort_var*)(self->varData))->callback) +#define enable (((PInterruptConjPort_var*)(self->varData))->enable) + +#endif /* _ROOM_BASIC_SERVICE_PINTERRUPT_PINTERRUPT_UTILS_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.c new file mode 100644 index 000000000..b72cf1235 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.c @@ -0,0 +1,355 @@ +/** + * @author generated by eTrice + * + * Source File of ActorClass ATcpClient + * + */ + +#include "ATcpClient.h" + +#include "modelbase/etActor.h" +#include "debugging/etLogger.h" +#include "debugging/etMSCLogger.h" +#include "etUnit/etUnit.h" +#include "base/etMemory.h" + +#include "room/basic/service/tcp/PTcpControl.h" +#include "room/basic/service/tcp/PTcpPayload.h" + +#include "ATcpClient_Utils.h" + +/*--------------------- begin user code ---------------------*/ +static int8* bufferProvider(void* slf, int* size) { + ATcpClient* self = (ATcpClient*) slf; + *size = DTcpPayload_getMaxLength(&payloadRecvBuffer); + return payloadRecvBuffer.data; +} + +static int socketReceiver(void* slf, int channel, int size, const int8* data) { + ATcpClient* self = (ATcpClient*) slf; + DTcpPayload_setData(&payloadRecvBuffer, /* cast away constness to avoid warning*/(int8*)data, size); + payloadPort_dataPackage(&payloadRecvBuffer); + return ETSOCKET_OK; +} +/*--------------------- end user code ---------------------*/ + +/* interface item IDs */ +enum interface_items { + IFITEM_controlPort = 1, + IFITEM_payloadPort = 2 +}; + +/* state IDs */ +enum state_ids { + NO_STATE = 0, + STATE_TOP = 1, + STATE_unconnected = 2, + STATE_connected = 3, + STATE_initError = 4, + STATE_MAX = 5 +}; + +/* transition chains */ +enum ChainIDs { + CHAIN_TRANS_INITIAL_TO__cp1 = 1, + CHAIN_TRANS_tr0_FROM_unconnected_TO_cp0_BY_connectcontrolPort = 2, + CHAIN_TRANS_tr1_FROM_connected_TO_unconnected_BY_disconnectcontrolPort = 3, + CHAIN_TRANS_tr3_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr3 = 4, + CHAIN_TRANS_tr6_FROM_initError_TO_initError_BY_connectcontrolPort_tr6 = 5 +}; + +/* triggers */ +enum triggers { + POLLING = 0, + TRIG_controlPort__connect = IFITEM_controlPort + EVT_SHIFT*PTcpControl_IN_connect, + TRIG_controlPort__disconnect = IFITEM_controlPort + EVT_SHIFT*PTcpControl_IN_disconnect, + TRIG_payloadPort__dataPackage = IFITEM_payloadPort + EVT_SHIFT*PTcpPayload_IN_dataPackage +}; + +/* state names */ +static char* stateStrings[] = {"","","unconnected", +"connected", +"initError" +}; + +static void setState(ATcpClient* self, etInt16 new_state) { + self->state = new_state; + ET_MSC_LOGGER_CHANGE_STATE(self->constData->instName, stateStrings[new_state]) +} + +static etInt16 getState(ATcpClient* self) { + return self->state; +} + +/* Entry and Exit Codes */ +static void entry_initError(ATcpClient* self) { + controlPort_error(); +} + +/* Action Codes */ +static void action_TRANS_INITIAL_TO__cp1(ATcpClient* self) { + printf("Client Init!\n"); +} +static void action_TRANS_tr0_FROM_unconnected_TO_cp0_BY_connectcontrolPort(ATcpClient* self, const InterfaceItemBase* ifitem, DTcpControl* data) { + /* connect to server */ + setErrorCode(etConnectServer(client, data->IPAddr, data->TcpPort)); +} +static void action_TRANS_tr1_FROM_connected_TO_unconnected_BY_disconnectcontrolPort(ATcpClient* self, const InterfaceItemBase* ifitem) { + /* close read thread */ + etCloseSocket(client); + + controlPort_disconnected(); +} +static void action_TRANS_tr2_FROM_cp0_TO_connected(ATcpClient* self, const InterfaceItemBase* ifitem, DTcpControl* data) { + controlPort_connected(); +} +static void action_TRANS_tr7_FROM_cp0_TO_unconnected_COND_tr7(ATcpClient* self, const InterfaceItemBase* ifitem, DTcpControl* data) { + controlPort_error(); +} +static void action_TRANS_tr3_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr3(ATcpClient* self, const InterfaceItemBase* ifitem, DTcpPayload* data) { + setErrorCode(etWriteSocket(client, data->length, data->data)); + if(hasError()) + controlPort_error(); +} + +/* State Switch Methods */ +/** + * calls exit codes while exiting from the current state to one of its + * parent states while remembering the history + * @param current__et - the current state + * @param to - the final parent state + */ +static void exitTo(ATcpClient* self, etInt16 current__et, etInt16 to) { + while (current__et!=to) { + switch (current__et) { + case STATE_unconnected: + self->history[STATE_TOP] = STATE_unconnected; + current__et = STATE_TOP; + break; + case STATE_connected: + self->history[STATE_TOP] = STATE_connected; + current__et = STATE_TOP; + break; + case STATE_initError: + self->history[STATE_TOP] = STATE_initError; + current__et = STATE_TOP; + break; + default: + /* should not occur */ + 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__et - the chain ID + * @param generic_data__et - the generic data pointer + * @return the +/- ID of the final state either with a positive sign, that indicates to execute the state's entry code, or a negative sign vice versa + */ +static etInt16 executeTransitionChain(ATcpClient* self, int chain__et, const InterfaceItemBase* ifitem, void* generic_data__et) { + switch (chain__et) { + case CHAIN_TRANS_INITIAL_TO__cp1: + { + action_TRANS_INITIAL_TO__cp1(self); + if (hasError()) { + return STATE_initError;} + else { + return STATE_unconnected;} + } + case CHAIN_TRANS_tr0_FROM_unconnected_TO_cp0_BY_connectcontrolPort: + { + DTcpControl* data = ((DTcpControl*) generic_data__et); + action_TRANS_tr0_FROM_unconnected_TO_cp0_BY_connectcontrolPort(self, ifitem, data); + if (hasError()) { + action_TRANS_tr7_FROM_cp0_TO_unconnected_COND_tr7(self, ifitem, data); + return STATE_unconnected;} + else { + action_TRANS_tr2_FROM_cp0_TO_connected(self, ifitem, data); + return STATE_connected;} + } + case CHAIN_TRANS_tr1_FROM_connected_TO_unconnected_BY_disconnectcontrolPort: + { + action_TRANS_tr1_FROM_connected_TO_unconnected_BY_disconnectcontrolPort(self, ifitem); + return STATE_unconnected; + } + case CHAIN_TRANS_tr3_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr3: + { + DTcpPayload* data = ((DTcpPayload*) generic_data__et); + action_TRANS_tr3_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr3(self, ifitem, data); + return STATE_connected; + } + case CHAIN_TRANS_tr6_FROM_initError_TO_initError_BY_connectcontrolPort_tr6: + { + DTcpControl* data = ((DTcpControl*) generic_data__et); + return STATE_initError; + } + default: + /* should not occur */ + break; + } + return NO_STATE; +} + +/** + * calls entry codes while entering a state's history. The ID of the final leaf state is returned + * @param state__et - the state which is entered + * @return - the ID of the final leaf state + */ +static etInt16 enterHistory(ATcpClient* self, etInt16 state__et) { + etBool skip_entry__et = ET_FALSE; + if (state__et >= STATE_MAX) { + state__et = (etInt16) (state__et - STATE_MAX); + skip_entry__et = ET_TRUE; + } + while (ET_TRUE) { + switch (state__et) { + case STATE_unconnected: + /* in leaf state: return state id */ + return STATE_unconnected; + case STATE_connected: + /* in leaf state: return state id */ + return STATE_connected; + case STATE_initError: + if (!(skip_entry__et)) entry_initError(self); + /* in leaf state: return state id */ + return STATE_initError; + case STATE_TOP: + state__et = self->history[STATE_TOP]; + break; + default: + /* should not occur */ + break; + } + skip_entry__et = ET_FALSE; + } + /* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */ +} + +static void ATcpClient_executeInitTransition(ATcpClient* self) { + int chain__et = CHAIN_TRANS_INITIAL_TO__cp1; + etInt16 next__et = executeTransitionChain(self, chain__et, NULL, NULL); + next__et = enterHistory(self, next__et); + setState(self, next__et); +} + +/* receiveEvent contains the main implementation of the FSM */ +static void ATcpClient_receiveEventInternal(ATcpClient* self, InterfaceItemBase* ifitem, int localId, int evt, void* generic_data__et) { + int trigger__et = localId + EVT_SHIFT*evt; + int chain__et = NOT_CAUGHT; + etInt16 catching_state__et = NO_STATE; + ((void)trigger__et); /* avoids unused warning */ + + if (!handleSystemEvent(ifitem, evt, generic_data__et)) { + switch (getState(self)) { + case STATE_unconnected: + switch(trigger__et) { + case TRIG_controlPort__connect: + { + chain__et = CHAIN_TRANS_tr0_FROM_unconnected_TO_cp0_BY_connectcontrolPort; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_connected: + switch(trigger__et) { + case TRIG_controlPort__disconnect: + { + chain__et = CHAIN_TRANS_tr1_FROM_connected_TO_unconnected_BY_disconnectcontrolPort; + catching_state__et = STATE_TOP; + } + break; + case TRIG_payloadPort__dataPackage: + { + chain__et = CHAIN_TRANS_tr3_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr3; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_initError: + switch(trigger__et) { + case TRIG_controlPort__connect: + { + chain__et = CHAIN_TRANS_tr6_FROM_initError_TO_initError_BY_connectcontrolPort_tr6; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; + } + } + if (chain__et != NOT_CAUGHT) { + exitTo(self, getState(self), catching_state__et); + { + etInt16 next__et = executeTransitionChain(self, chain__et, ifitem, generic_data__et); + next__et = enterHistory(self, next__et); + setState(self, next__et); + } + } +} +static void ATcpClient_receiveEvent(ATcpClient* self, InterfaceItemBase* ifitem, int evt, void* generic_data__et) { + int localId = (ifitem==NULL)? 0 : ifitem->localId; + ATcpClient_receiveEventInternal(self, ifitem, localId, evt, generic_data__et); +} + +void ATcpClient_init(ATcpClient* self){ + ET_MSC_LOGGER_SYNC_ENTRY("ATcpClient", "init") + self->state = STATE_TOP; + { + int i; + for (i=0; ihistory[i] = NO_STATE; + } + ATcpClient_executeInitTransition(self); + ET_MSC_LOGGER_SYNC_EXIT +} + + +void ATcpClient_receiveMessage(void* self, const void* ifitem, const etMessage* msg){ + ET_MSC_LOGGER_SYNC_ENTRY("ATcpClient", "_receiveMessage") + ATcpClient_receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))); + + ET_MSC_LOGGER_SYNC_EXIT +} + + +/*--------------------- user constructor/destructor ---------------------*/ + void ATcpClient_ctor(ATcpClient* self){ + /* user defined constructor body */ + setErrorCode(etInitSockets()); + client = etCreateSocketConnectionData(); + client->receiver = socketReceiver; + client->bufferProvider = bufferProvider; + client->userData = self; +} + + void ATcpClient_dtor(ATcpClient* self){ + /* user defined destructor body */ + etCloseSocket(client); + etCleanupSockets(); + etFreeSocketConnectionData(client); +} + +/*--------------------- operations ---------------------*/ + bool ATcpClient_hasError(ATcpClient* self) { + return lastError != ETSOCKET_OK; +} + void ATcpClient_setErrorCode(ATcpClient* self, int32 value) { + lastError = value; +} + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.h new file mode 100644 index 000000000..3f6962c52 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient.h @@ -0,0 +1,77 @@ +/** + * @author generated by eTrice + * + * Header File of ActorClass ATcpClient + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TCP_ATCPCLIENT_H_ +#define _ROOM_BASIC_SERVICE_TCP_ATCPCLIENT_H_ + +#include "etDatatypes.h" +#include "messaging/etMessage.h" + +#include "room/basic/service/tcp/DTcpPayload.h" +#include "room/basic/service/tcp/PTcpControl.h" +#include "room/basic/service/tcp/PTcpPayload.h" + +/*--------------------- begin user code ---------------------*/ +#include "osal/etTcpSockets.h" +/*--------------------- end user code ---------------------*/ + +typedef struct ATcpClient ATcpClient; + +/* const part of ActorClass (ROM) */ +typedef struct ATcpClient_const { + const char* instName; + + /* simple ports */ + const PTcpControlPort controlPort; + const PTcpPayloadPort payloadPort; + + /* data receive ports */ + + /* saps */ + + /* replicated ports */ + + /* services */ +} ATcpClient_const; + + +/* constant for state machine data */ +#define ATCPCLIENT_HISTORY_SIZE 2 + +/* variable part of ActorClass (RAM) */ +struct ATcpClient { + const ATcpClient_const* const constData; + + /* data send ports */ + + /*--------------------- attributes ---------------------*/ + int32 lastError; + DTcpPayload payloadRecvBuffer; + etSocketConnectionData* client; + + + /* state machine variables */ + etInt16 state; + etInt16 history[ATCPCLIENT_HISTORY_SIZE]; +}; + +void ATcpClient_init(ATcpClient* self); + +void ATcpClient_receiveMessage(void* self, const void* ifitem, const etMessage* msg); + + +/*--------------------- user constructor/destructor ---------------------*/ + void ATcpClient_ctor(ATcpClient* self); + void ATcpClient_dtor(ATcpClient* self); + +/*--------------------- operations ---------------------*/ + bool ATcpClient_hasError(ATcpClient* self); + void ATcpClient_setErrorCode(ATcpClient* self, int32 value); + + +#endif /* _ROOM_BASIC_SERVICE_TCP_ATCPCLIENT_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient_Utils.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient_Utils.h new file mode 100644 index 000000000..c83489382 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpClient_Utils.h @@ -0,0 +1,45 @@ +/** + * @author generated by eTrice + * + * Utils File of ActorClass ATcpClient + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TCP_ATCPCLIENT_UTILS_H_ +#define _ROOM_BASIC_SERVICE_TCP_ATCPCLIENT_UTILS_H_ + +#include "room/basic/service/tcp/ATcpClient.h" + +/* + * access macros for ports, operations and attributes +*/ + +/* simple event ports */ +#define controlPort_connected() PTcpControlPort_connected(&self->constData->controlPort) +#define controlPort_disconnected() PTcpControlPort_disconnected(&self->constData->controlPort) +#define controlPort_error() PTcpControlPort_error(&self->constData->controlPort) +#define payloadPort_dataPackage(data) PTcpPayloadPort_dataPackage(&self->constData->payloadPort, data) + +/* data receive ports */ + +/* data send ports */ + +/* saps */ + +/* replicated event ports */ + +/* services */ + +/* operations */ +#define hasError() ATcpClient_hasError(self) +#define setErrorCode(value) ATcpClient_setErrorCode(self, value) + +/* attributes */ +#define lastError (self->lastError) +#define payloadRecvBuffer (self->payloadRecvBuffer) +#define client (self->client) + +/* port operations */ + +#endif /* _ROOM_BASIC_SERVICE_TCP_ATCPCLIENT_UTILS_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.c new file mode 100644 index 000000000..17d9dc398 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.c @@ -0,0 +1,352 @@ +/** + * @author generated by eTrice + * + * Source File of ActorClass ATcpServer + * + */ + +#include "ATcpServer.h" + +#include "modelbase/etActor.h" +#include "debugging/etLogger.h" +#include "debugging/etMSCLogger.h" +#include "etUnit/etUnit.h" +#include "base/etMemory.h" + +#include "room/basic/service/tcp/PTcpControl.h" +#include "room/basic/service/tcp/PTcpPayload.h" + +#include "ATcpServer_Utils.h" + +/*--------------------- begin user code ---------------------*/ +static int8* bufferProvider(void* slf, int* size) { + ATcpServer* self = (ATcpServer*) slf; + *size = DTcpPayload_getMaxLength(&payloadRecvBuffer); + return payloadRecvBuffer.data; +} + +static int socketReceiver(void* slf, int channel, int size, const int8* data) { + ATcpServer* self = (ATcpServer*) slf; + DTcpPayload_setData(&payloadRecvBuffer, data, size); + payloadPort_dataPackage(&payloadRecvBuffer); + return ETSOCKET_OK; +} +/*--------------------- end user code ---------------------*/ + +/* interface item IDs */ +enum interface_items { + IFITEM_controlPort = 1, + IFITEM_payloadPort = 2 +}; + +/* state IDs */ +enum state_ids { + NO_STATE = 0, + STATE_TOP = 1, + STATE_connected = 2, + STATE_unconnected = 3, + STATE_initError = 4, + STATE_MAX = 5 +}; + +/* transition chains */ +enum ChainIDs { + CHAIN_TRANS_INITIAL_TO__cp0 = 1, + CHAIN_TRANS_tr5_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr5 = 2, + CHAIN_TRANS_tr6_FROM_connected_TO_unconnected_BY_disconnectcontrolPort = 3, + CHAIN_TRANS_tr7_FROM_unconnected_TO_cp1_BY_connectcontrolPort = 4, + CHAIN_TRANS_tr2_FROM_initError_TO_initError_BY_connectcontrolPort_tr2 = 5 +}; + +/* triggers */ +enum triggers { + POLLING = 0, + TRIG_controlPort__connect = IFITEM_controlPort + EVT_SHIFT*PTcpControl_IN_connect, + TRIG_controlPort__disconnect = IFITEM_controlPort + EVT_SHIFT*PTcpControl_IN_disconnect, + TRIG_payloadPort__dataPackage = IFITEM_payloadPort + EVT_SHIFT*PTcpPayload_IN_dataPackage +}; + +/* state names */ +static char* stateStrings[] = {"","","connected", +"unconnected", +"initError" +}; + +static void setState(ATcpServer* self, etInt16 new_state) { + self->state = new_state; + ET_MSC_LOGGER_CHANGE_STATE(self->constData->instName, stateStrings[new_state]) +} + +static etInt16 getState(ATcpServer* self) { + return self->state; +} + +/* Entry and Exit Codes */ +static void entry_initError(ATcpServer* self) { + controlPort_error(); +} + +/* Action Codes */ +static void action_TRANS_tr5_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr5(ATcpServer* self, const InterfaceItemBase* ifitem, DTcpPayload* data) { + /* send payload to connection */ + setErrorCode(etWriteServerSocket(server, data->connectionId, data->length, data->data)); + if(hasError()) + controlPort_error(); +} +static void action_TRANS_tr6_FROM_connected_TO_unconnected_BY_disconnectcontrolPort(ATcpServer* self, const InterfaceItemBase* ifitem) { + /* close accept thread */ + etCloseAllServerSockets(server); + etStopSocketServer(server); + + controlPort_disconnected(); +} +static void action_TRANS_tr7_FROM_unconnected_TO_cp1_BY_connectcontrolPort(ATcpServer* self, const InterfaceItemBase* ifitem, DTcpControl* data) { + /* start accept thread */ + setErrorCode(etStartListening(server, data->TcpPort)); +} +static void action_TRANS_tr4_FROM_cp1_TO_connected(ATcpServer* self, const InterfaceItemBase* ifitem, DTcpControl* data) { + controlPort_connected(); +} +static void action_TRANS_tr8_FROM_cp1_TO_unconnected_COND_tr8(ATcpServer* self, const InterfaceItemBase* ifitem, DTcpControl* data) { + controlPort_error(); +} + +/* State Switch Methods */ +/** + * calls exit codes while exiting from the current state to one of its + * parent states while remembering the history + * @param current__et - the current state + * @param to - the final parent state + */ +static void exitTo(ATcpServer* self, etInt16 current__et, etInt16 to) { + while (current__et!=to) { + switch (current__et) { + case STATE_connected: + self->history[STATE_TOP] = STATE_connected; + current__et = STATE_TOP; + break; + case STATE_unconnected: + self->history[STATE_TOP] = STATE_unconnected; + current__et = STATE_TOP; + break; + case STATE_initError: + self->history[STATE_TOP] = STATE_initError; + current__et = STATE_TOP; + break; + default: + /* should not occur */ + 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__et - the chain ID + * @param generic_data__et - the generic data pointer + * @return the +/- ID of the final state either with a positive sign, that indicates to execute the state's entry code, or a negative sign vice versa + */ +static etInt16 executeTransitionChain(ATcpServer* self, int chain__et, const InterfaceItemBase* ifitem, void* generic_data__et) { + switch (chain__et) { + case CHAIN_TRANS_INITIAL_TO__cp0: + { + if (hasError()) { + return STATE_initError;} + else { + return STATE_unconnected;} + } + case CHAIN_TRANS_tr5_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr5: + { + DTcpPayload* data = ((DTcpPayload*) generic_data__et); + action_TRANS_tr5_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr5(self, ifitem, data); + return STATE_connected; + } + case CHAIN_TRANS_tr6_FROM_connected_TO_unconnected_BY_disconnectcontrolPort: + { + action_TRANS_tr6_FROM_connected_TO_unconnected_BY_disconnectcontrolPort(self, ifitem); + return STATE_unconnected; + } + case CHAIN_TRANS_tr7_FROM_unconnected_TO_cp1_BY_connectcontrolPort: + { + DTcpControl* data = ((DTcpControl*) generic_data__et); + action_TRANS_tr7_FROM_unconnected_TO_cp1_BY_connectcontrolPort(self, ifitem, data); + if (hasError()) { + action_TRANS_tr8_FROM_cp1_TO_unconnected_COND_tr8(self, ifitem, data); + return STATE_unconnected;} + else { + action_TRANS_tr4_FROM_cp1_TO_connected(self, ifitem, data); + return STATE_connected;} + } + case CHAIN_TRANS_tr2_FROM_initError_TO_initError_BY_connectcontrolPort_tr2: + { + DTcpControl* data = ((DTcpControl*) generic_data__et); + return STATE_initError; + } + default: + /* should not occur */ + break; + } + return NO_STATE; +} + +/** + * calls entry codes while entering a state's history. The ID of the final leaf state is returned + * @param state__et - the state which is entered + * @return - the ID of the final leaf state + */ +static etInt16 enterHistory(ATcpServer* self, etInt16 state__et) { + etBool skip_entry__et = ET_FALSE; + if (state__et >= STATE_MAX) { + state__et = (etInt16) (state__et - STATE_MAX); + skip_entry__et = ET_TRUE; + } + while (ET_TRUE) { + switch (state__et) { + case STATE_connected: + /* in leaf state: return state id */ + return STATE_connected; + case STATE_unconnected: + /* in leaf state: return state id */ + return STATE_unconnected; + case STATE_initError: + if (!(skip_entry__et)) entry_initError(self); + /* in leaf state: return state id */ + return STATE_initError; + case STATE_TOP: + state__et = self->history[STATE_TOP]; + break; + default: + /* should not occur */ + break; + } + skip_entry__et = ET_FALSE; + } + /* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */ +} + +static void ATcpServer_executeInitTransition(ATcpServer* self) { + int chain__et = CHAIN_TRANS_INITIAL_TO__cp0; + etInt16 next__et = executeTransitionChain(self, chain__et, NULL, NULL); + next__et = enterHistory(self, next__et); + setState(self, next__et); +} + +/* receiveEvent contains the main implementation of the FSM */ +static void ATcpServer_receiveEventInternal(ATcpServer* self, InterfaceItemBase* ifitem, int localId, int evt, void* generic_data__et) { + int trigger__et = localId + EVT_SHIFT*evt; + int chain__et = NOT_CAUGHT; + etInt16 catching_state__et = NO_STATE; + ((void)trigger__et); /* avoids unused warning */ + + if (!handleSystemEvent(ifitem, evt, generic_data__et)) { + switch (getState(self)) { + case STATE_connected: + switch(trigger__et) { + case TRIG_payloadPort__dataPackage: + { + chain__et = CHAIN_TRANS_tr5_FROM_connected_TO_connected_BY_dataPackagepayloadPort_tr5; + catching_state__et = STATE_TOP; + } + break; + case TRIG_controlPort__disconnect: + { + chain__et = CHAIN_TRANS_tr6_FROM_connected_TO_unconnected_BY_disconnectcontrolPort; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_unconnected: + switch(trigger__et) { + case TRIG_controlPort__connect: + { + chain__et = CHAIN_TRANS_tr7_FROM_unconnected_TO_cp1_BY_connectcontrolPort; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_initError: + switch(trigger__et) { + case TRIG_controlPort__connect: + { + chain__et = CHAIN_TRANS_tr2_FROM_initError_TO_initError_BY_connectcontrolPort_tr2; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; + } + } + if (chain__et != NOT_CAUGHT) { + exitTo(self, getState(self), catching_state__et); + { + etInt16 next__et = executeTransitionChain(self, chain__et, ifitem, generic_data__et); + next__et = enterHistory(self, next__et); + setState(self, next__et); + } + } +} +static void ATcpServer_receiveEvent(ATcpServer* self, InterfaceItemBase* ifitem, int evt, void* generic_data__et) { + int localId = (ifitem==NULL)? 0 : ifitem->localId; + ATcpServer_receiveEventInternal(self, ifitem, localId, evt, generic_data__et); +} + +void ATcpServer_init(ATcpServer* self){ + ET_MSC_LOGGER_SYNC_ENTRY("ATcpServer", "init") + self->state = STATE_TOP; + { + int i; + for (i=0; ihistory[i] = NO_STATE; + } + ATcpServer_executeInitTransition(self); + ET_MSC_LOGGER_SYNC_EXIT +} + + +void ATcpServer_receiveMessage(void* self, const void* ifitem, const etMessage* msg){ + ET_MSC_LOGGER_SYNC_ENTRY("ATcpServer", "_receiveMessage") + ATcpServer_receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))); + + ET_MSC_LOGGER_SYNC_EXIT +} + + +/*--------------------- user constructor/destructor ---------------------*/ + void ATcpServer_ctor(ATcpServer* self){ + /* user defined constructor body */ + setErrorCode(etInitSockets()); + server = etCreateSocketServerData(); + server->receiver = socketReceiver; + server->bufferProvider = bufferProvider; + server->userData = self; +} + + void ATcpServer_dtor(ATcpServer* self){ + /* user defined destructor body */ + etCleanupSockets(); + etFreeSocketServerData(server); +} + +/*--------------------- operations ---------------------*/ + bool ATcpServer_hasError(ATcpServer* self) { + return lastError != ETSOCKET_OK; +} + void ATcpServer_setErrorCode(ATcpServer* self, int32 value) { + lastError = value; +} + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.h new file mode 100644 index 000000000..2bff8d75e --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer.h @@ -0,0 +1,77 @@ +/** + * @author generated by eTrice + * + * Header File of ActorClass ATcpServer + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TCP_ATCPSERVER_H_ +#define _ROOM_BASIC_SERVICE_TCP_ATCPSERVER_H_ + +#include "etDatatypes.h" +#include "messaging/etMessage.h" + +#include "room/basic/service/tcp/DTcpPayload.h" +#include "room/basic/service/tcp/PTcpControl.h" +#include "room/basic/service/tcp/PTcpPayload.h" + +/*--------------------- begin user code ---------------------*/ +#include "osal/etTcpSockets.h" +/*--------------------- end user code ---------------------*/ + +typedef struct ATcpServer ATcpServer; + +/* const part of ActorClass (ROM) */ +typedef struct ATcpServer_const { + const char* instName; + + /* simple ports */ + const PTcpControlPort controlPort; + const PTcpPayloadPort payloadPort; + + /* data receive ports */ + + /* saps */ + + /* replicated ports */ + + /* services */ +} ATcpServer_const; + + +/* constant for state machine data */ +#define ATCPSERVER_HISTORY_SIZE 2 + +/* variable part of ActorClass (RAM) */ +struct ATcpServer { + const ATcpServer_const* const constData; + + /* data send ports */ + + /*--------------------- attributes ---------------------*/ + int32 lastError; + DTcpPayload payloadRecvBuffer; + etSocketServerData* server; + + + /* state machine variables */ + etInt16 state; + etInt16 history[ATCPSERVER_HISTORY_SIZE]; +}; + +void ATcpServer_init(ATcpServer* self); + +void ATcpServer_receiveMessage(void* self, const void* ifitem, const etMessage* msg); + + +/*--------------------- user constructor/destructor ---------------------*/ + void ATcpServer_ctor(ATcpServer* self); + void ATcpServer_dtor(ATcpServer* self); + +/*--------------------- operations ---------------------*/ + bool ATcpServer_hasError(ATcpServer* self); + void ATcpServer_setErrorCode(ATcpServer* self, int32 value); + + +#endif /* _ROOM_BASIC_SERVICE_TCP_ATCPSERVER_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer_Utils.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer_Utils.h new file mode 100644 index 000000000..64063760e --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/ATcpServer_Utils.h @@ -0,0 +1,45 @@ +/** + * @author generated by eTrice + * + * Utils File of ActorClass ATcpServer + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TCP_ATCPSERVER_UTILS_H_ +#define _ROOM_BASIC_SERVICE_TCP_ATCPSERVER_UTILS_H_ + +#include "room/basic/service/tcp/ATcpServer.h" + +/* + * access macros for ports, operations and attributes +*/ + +/* simple event ports */ +#define controlPort_connected() PTcpControlPort_connected(&self->constData->controlPort) +#define controlPort_disconnected() PTcpControlPort_disconnected(&self->constData->controlPort) +#define controlPort_error() PTcpControlPort_error(&self->constData->controlPort) +#define payloadPort_dataPackage(data) PTcpPayloadPort_dataPackage(&self->constData->payloadPort, data) + +/* data receive ports */ + +/* data send ports */ + +/* saps */ + +/* replicated event ports */ + +/* services */ + +/* operations */ +#define hasError() ATcpServer_hasError(self) +#define setErrorCode(value) ATcpServer_setErrorCode(self, value) + +/* attributes */ +#define lastError (self->lastError) +#define payloadRecvBuffer (self->payloadRecvBuffer) +#define server (self->server) + +/* port operations */ + +#endif /* _ROOM_BASIC_SERVICE_TCP_ATCPSERVER_UTILS_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl.c new file mode 100644 index 000000000..10dc9c9e7 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl.c @@ -0,0 +1,21 @@ +/** + * @author generated by eTrice + * + * Source File of DataClass DTcpControl + * + */ + +#include + +#include "DTcpControl.h" +#include "DTcpControl_Utils.h" + + + +/*--------------------- operations ---------------------*/ + +void DTcpControl_deepCopy(DTcpControl* source, DTcpControl* target) { + memcpy(target, source, sizeof(DTcpControl)); +} + + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl.h new file mode 100644 index 000000000..0d1c71664 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl.h @@ -0,0 +1,30 @@ +/** + * @author generated by eTrice + * + * Header File of DataClass DTcpControl + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TCP_DTCPCONTROL_H_ +#define _ROOM_BASIC_SERVICE_TCP_DTCPCONTROL_H_ + +#include "etDatatypes.h" + + + +typedef struct { + /*--------------------- attributes ---------------------*/ + charPtr IPAddr; + int32 TcpPort; +} DTcpControl; + + + +/*--------------------- operations ---------------------*/ + +/* deep copy */ +void DTcpControl_deepCopy(DTcpControl* source, DTcpControl* target); + + +#endif /* _ROOM_BASIC_SERVICE_TCP_DTCPCONTROL_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl_Utils.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl_Utils.h new file mode 100644 index 000000000..72ec2d877 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpControl_Utils.h @@ -0,0 +1,24 @@ +/** + * @author generated by eTrice + * + * Utils File of DataClass DTcpControl + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TCP_DTCPCONTROL_UTILS_H_ +#define _ROOM_BASIC_SERVICE_TCP_DTCPCONTROL_UTILS_H_ + +#include "room/basic/service/tcp/DTcpControl.h" + +/* + * access macros for operations and attributes +*/ + +/* operations */ + +/* attributes */ +#define IPAddr (self->IPAddr) +#define TcpPort (self->TcpPort) + +#endif /* _ROOM_BASIC_SERVICE_TCP_DTCPCONTROL_UTILS_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload.c new file mode 100644 index 000000000..3b10701ad --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload.c @@ -0,0 +1,41 @@ +/** + * @author generated by eTrice + * + * Source File of DataClass DTcpPayload + * + */ + +#include + +#include "DTcpPayload.h" +#include "DTcpPayload_Utils.h" + + + +/*--------------------- operations ---------------------*/ + int32 DTcpPayload_getMaxLength(DTcpPayload* self) { + return 32; +} + void DTcpPayload_setAsString(DTcpPayload* self, charPtr value) { + /* used macros: data, length */ + int valLength = (strlen(value)+1 > 32)? 32 : strlen(value) + 1; + memcpy(data, value, valLength); + data[31] = '\0'; + length = valLength; +} + void DTcpPayload_setData(DTcpPayload* self, int8* value, int32 size) { + /* used macros: data, length */ + strncpy(data, value, ((size>32)?32:size)); + length = size; +} + charPtr DTcpPayload_getAsString(DTcpPayload* self) { + /* used macros: data */ + data[31] = '\0'; + return data; +} + +void DTcpPayload_deepCopy(DTcpPayload* source, DTcpPayload* target) { + memcpy(target, source, sizeof(DTcpPayload)); +} + + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload.h new file mode 100644 index 000000000..23aa03dd3 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload.h @@ -0,0 +1,36 @@ +/** + * @author generated by eTrice + * + * Header File of DataClass DTcpPayload + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TCP_DTCPPAYLOAD_H_ +#define _ROOM_BASIC_SERVICE_TCP_DTCPPAYLOAD_H_ + +#include "etDatatypes.h" + + + +typedef struct { + /*--------------------- attributes ---------------------*/ + int32 connectionId; + int32 length; + int8 data[32] + ; +} DTcpPayload; + + + +/*--------------------- operations ---------------------*/ + int32 DTcpPayload_getMaxLength(DTcpPayload* self); + void DTcpPayload_setAsString(DTcpPayload* self, charPtr value); + void DTcpPayload_setData(DTcpPayload* self, int8* value, int32 size); + charPtr DTcpPayload_getAsString(DTcpPayload* self); + +/* deep copy */ +void DTcpPayload_deepCopy(DTcpPayload* source, DTcpPayload* target); + + +#endif /* _ROOM_BASIC_SERVICE_TCP_DTCPPAYLOAD_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload_Utils.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload_Utils.h new file mode 100644 index 000000000..d25b6bfca --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/DTcpPayload_Utils.h @@ -0,0 +1,29 @@ +/** + * @author generated by eTrice + * + * Utils File of DataClass DTcpPayload + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TCP_DTCPPAYLOAD_UTILS_H_ +#define _ROOM_BASIC_SERVICE_TCP_DTCPPAYLOAD_UTILS_H_ + +#include "room/basic/service/tcp/DTcpPayload.h" + +/* + * access macros for operations and attributes +*/ + +/* operations */ +#define getMaxLength() DTcpPayload_getMaxLength(self) +#define setAsString(value) DTcpPayload_setAsString(self, value) +#define setData(value, size) DTcpPayload_setData(self, value, size) +#define getAsString() DTcpPayload_getAsString(self) + +/* attributes */ +#define connectionId (self->connectionId) +#define length (self->length) +#define data (self->data) + +#endif /* _ROOM_BASIC_SERVICE_TCP_DTCPPAYLOAD_UTILS_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl.c new file mode 100644 index 000000000..3c5c87a6d --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl.c @@ -0,0 +1,173 @@ +/** + * @author generated by eTrice + * + * Source File of ProtocolClass PTcpControl + * + */ + +#include "PTcpControl.h" +#include "debugging/etMSCLogger.h" +#include "PTcpControl_Utils.h" + + +/*--------------------- port methods */ + +void PTcpControlPort_connected(const PTcpControlPort* self) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlPort", "connected") + etPort_sendMessage(self, PTcpControl_OUT_connected, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(self->myInstName, "connected", self->peerInstName) + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpControlReplPort_connected_broadcast(const PTcpControlReplPort* self) { + int i; + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlReplPort", "connected") + for (i=0; i<((etReplPort*)self)->size; ++i) { + etPort_sendMessage((&((etReplPort*)self)->ports[i].port), PTcpControl_OUT_connected, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[i].port.myInstName, "connected", ((etReplPort*)self)->ports[i].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpControlReplPort_connected(const PTcpControlReplPort* self, int idx__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlReplPort", "connected") + if (0<=idx__et && idx__et<((etReplPort*)self)->size) { + etPort_sendMessage((&((etReplPort*)self)->ports[idx__et].port), PTcpControl_OUT_connected, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[idx__et].port.myInstName, "connected", ((etReplPort*)self)->ports[idx__et].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + + +void PTcpControlPort_disconnected(const PTcpControlPort* self) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlPort", "disconnected") + etPort_sendMessage(self, PTcpControl_OUT_disconnected, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(self->myInstName, "disconnected", self->peerInstName) + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpControlReplPort_disconnected_broadcast(const PTcpControlReplPort* self) { + int i; + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlReplPort", "disconnected") + for (i=0; i<((etReplPort*)self)->size; ++i) { + etPort_sendMessage((&((etReplPort*)self)->ports[i].port), PTcpControl_OUT_disconnected, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[i].port.myInstName, "disconnected", ((etReplPort*)self)->ports[i].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpControlReplPort_disconnected(const PTcpControlReplPort* self, int idx__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlReplPort", "disconnected") + if (0<=idx__et && idx__et<((etReplPort*)self)->size) { + etPort_sendMessage((&((etReplPort*)self)->ports[idx__et].port), PTcpControl_OUT_disconnected, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[idx__et].port.myInstName, "disconnected", ((etReplPort*)self)->ports[idx__et].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + + +void PTcpControlPort_error(const PTcpControlPort* self) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlPort", "error") + etPort_sendMessage(self, PTcpControl_OUT_error, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(self->myInstName, "error", self->peerInstName) + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpControlReplPort_error_broadcast(const PTcpControlReplPort* self) { + int i; + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlReplPort", "error") + for (i=0; i<((etReplPort*)self)->size; ++i) { + etPort_sendMessage((&((etReplPort*)self)->ports[i].port), PTcpControl_OUT_error, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[i].port.myInstName, "error", ((etReplPort*)self)->ports[i].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpControlReplPort_error(const PTcpControlReplPort* self, int idx__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlReplPort", "error") + if (0<=idx__et && idx__et<((etReplPort*)self)->size) { + etPort_sendMessage((&((etReplPort*)self)->ports[idx__et].port), PTcpControl_OUT_error, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[idx__et].port.myInstName, "error", ((etReplPort*)self)->ports[idx__et].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +etInt32 PTcpControlReplPort_getReplication(const PTcpControlReplPort* self) { + return ((etReplPort*)self)->size; +} + + + +void PTcpControlConjPort_connect(const PTcpControlConjPort* self, DTcpControl* data__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlConjPort", "connect") + etPort_sendMessage(self, PTcpControl_IN_connect, sizeof(DTcpControl), data__et); + ET_MSC_LOGGER_ASYNC_OUT(self->myInstName, "connect", self->peerInstName) + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpControlConjReplPort_connect_broadcast(const PTcpControlConjReplPort* self, DTcpControl* data__et) { + int i; + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlConjReplPort", "connect") + for (i=0; i<((etReplPort*)self)->size; ++i) { + etPort_sendMessage((&((etReplPort*)self)->ports[i].port), PTcpControl_IN_connect, sizeof(DTcpControl), data__et); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[i].port.myInstName, "connect", ((etReplPort*)self)->ports[i].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpControlConjReplPort_connect(const PTcpControlConjReplPort* self, int idx__et, DTcpControl* data__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlConjReplPort", "connect") + if (0<=idx__et && idx__et<((etReplPort*)self)->size) { + etPort_sendMessage((&((etReplPort*)self)->ports[idx__et].port), PTcpControl_IN_connect, sizeof(DTcpControl), data__et); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[idx__et].port.myInstName, "connect", ((etReplPort*)self)->ports[idx__et].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + + +void PTcpControlConjPort_disconnect(const PTcpControlConjPort* self) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlConjPort", "disconnect") + etPort_sendMessage(self, PTcpControl_IN_disconnect, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(self->myInstName, "disconnect", self->peerInstName) + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpControlConjReplPort_disconnect_broadcast(const PTcpControlConjReplPort* self) { + int i; + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlConjReplPort", "disconnect") + for (i=0; i<((etReplPort*)self)->size; ++i) { + etPort_sendMessage((&((etReplPort*)self)->ports[i].port), PTcpControl_IN_disconnect, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[i].port.myInstName, "disconnect", ((etReplPort*)self)->ports[i].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpControlConjReplPort_disconnect(const PTcpControlConjReplPort* self, int idx__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpControlConjReplPort", "disconnect") + if (0<=idx__et && idx__et<((etReplPort*)self)->size) { + etPort_sendMessage((&((etReplPort*)self)->ports[idx__et].port), PTcpControl_IN_disconnect, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[idx__et].port.myInstName, "disconnect", ((etReplPort*)self)->ports[idx__et].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +etInt32 PTcpControlConjReplPort_getReplication(const PTcpControlConjReplPort* self) { + return ((etReplPort*)self)->size; +} + + + +/*--------------------- debug helpers */ + +/* message names as strings for debugging (generate MSC) */ +static const char* const PTcpControl_messageStrings[] = {"MIN", "connected","disconnected","error","connect", "disconnect", "MAX"}; + +const char* PTcpControl_getMessageString(int msg_id) { + if (msg_idPTcpControl_MSG_MAX+1){ + /* id out of range */ + return "Message ID out of range"; + } + else{ + return PTcpControl_messageStrings[msg_id]; + } +} diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl.h new file mode 100644 index 000000000..2809a5f03 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl.h @@ -0,0 +1,67 @@ +/** + * @author generated by eTrice + * + * Header File of ProtocolClass PTcpControl + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TCP_PTCPCONTROL_H_ +#define _ROOM_BASIC_SERVICE_TCP_PTCPCONTROL_H_ + +#include "etDatatypes.h" +#include "modelbase/etPort.h" + + +#include "room/basic/service/tcp/DTcpControl.h" + + +/* message IDs */ +enum PTcpControl_msg_ids { + PTcpControl_MSG_MIN = 0, + PTcpControl_OUT_connected = 1, + PTcpControl_OUT_disconnected = 2, + PTcpControl_OUT_error = 3, + PTcpControl_IN_connect = 4, + PTcpControl_IN_disconnect = 5, + PTcpControl_MSG_MAX = 6 +}; + +/*--------------------- port structs and methods */ +typedef etPort PTcpControlPort; +typedef etReplPort PTcpControlReplPort; + + +void PTcpControlPort_connected(const PTcpControlPort* self); +void PTcpControlReplPort_connected_broadcast(const PTcpControlReplPort* self); +void PTcpControlReplPort_connected(const PTcpControlReplPort* self, int idx); +void PTcpControlPort_disconnected(const PTcpControlPort* self); +void PTcpControlReplPort_disconnected_broadcast(const PTcpControlReplPort* self); +void PTcpControlReplPort_disconnected(const PTcpControlReplPort* self, int idx); +void PTcpControlPort_error(const PTcpControlPort* self); +void PTcpControlReplPort_error_broadcast(const PTcpControlReplPort* self); +void PTcpControlReplPort_error(const PTcpControlReplPort* self, int idx); + + +etInt32 PTcpControlReplPort_getReplication(const PTcpControlReplPort* self); +typedef etPort PTcpControlConjPort; +typedef etReplPort PTcpControlConjReplPort; + + +void PTcpControlConjPort_connect(const PTcpControlConjPort* self, DTcpControl* data); +void PTcpControlConjReplPort_connect_broadcast(const PTcpControlConjReplPort* self, DTcpControl* data); +void PTcpControlConjReplPort_connect(const PTcpControlConjReplPort* self, int idx, DTcpControl* data); +void PTcpControlConjPort_disconnect(const PTcpControlConjPort* self); +void PTcpControlConjReplPort_disconnect_broadcast(const PTcpControlConjReplPort* self); +void PTcpControlConjReplPort_disconnect(const PTcpControlConjReplPort* self, int idx); + + +etInt32 PTcpControlConjReplPort_getReplication(const PTcpControlConjReplPort* self); + +/*--------------------- debug helpers */ + +/* get message string for message id */ +const char* PTcpControl_getMessageString(int msg_id); + + +#endif /* _ROOM_BASIC_SERVICE_TCP_PTCPCONTROL_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl_Utils.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl_Utils.h new file mode 100644 index 000000000..06b3b7792 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpControl_Utils.h @@ -0,0 +1,19 @@ +/** + * @author generated by eTrice + * + * Utils File of ProtocolClass PTcpControl + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TCP_PTCPCONTROL_UTILS_H_ +#define _ROOM_BASIC_SERVICE_TCP_PTCPCONTROL_UTILS_H_ + +#include "room/basic/service/tcp/PTcpControl.h" + +/* + * access macros for operations and attributes +*/ + + +#endif /* _ROOM_BASIC_SERVICE_TCP_PTCPCONTROL_UTILS_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload.c new file mode 100644 index 000000000..1d89e5600 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload.c @@ -0,0 +1,92 @@ +/** + * @author generated by eTrice + * + * Source File of ProtocolClass PTcpPayload + * + */ + +#include "PTcpPayload.h" +#include "debugging/etMSCLogger.h" +#include "PTcpPayload_Utils.h" + + +/*--------------------- port methods */ + +void PTcpPayloadPort_dataPackage(const PTcpPayloadPort* self, DTcpPayload* data__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpPayloadPort", "dataPackage") + etPort_sendMessage(self, PTcpPayload_OUT_dataPackage, sizeof(DTcpPayload), data__et); + ET_MSC_LOGGER_ASYNC_OUT(self->myInstName, "dataPackage", self->peerInstName) + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpPayloadReplPort_dataPackage_broadcast(const PTcpPayloadReplPort* self, DTcpPayload* data__et) { + int i; + ET_MSC_LOGGER_SYNC_ENTRY("PTcpPayloadReplPort", "dataPackage") + for (i=0; i<((etReplPort*)self)->size; ++i) { + etPort_sendMessage((&((etReplPort*)self)->ports[i].port), PTcpPayload_OUT_dataPackage, sizeof(DTcpPayload), data__et); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[i].port.myInstName, "dataPackage", ((etReplPort*)self)->ports[i].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpPayloadReplPort_dataPackage(const PTcpPayloadReplPort* self, int idx__et, DTcpPayload* data__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpPayloadReplPort", "dataPackage") + if (0<=idx__et && idx__et<((etReplPort*)self)->size) { + etPort_sendMessage((&((etReplPort*)self)->ports[idx__et].port), PTcpPayload_OUT_dataPackage, sizeof(DTcpPayload), data__et); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[idx__et].port.myInstName, "dataPackage", ((etReplPort*)self)->ports[idx__et].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +etInt32 PTcpPayloadReplPort_getReplication(const PTcpPayloadReplPort* self) { + return ((etReplPort*)self)->size; +} + + + +void PTcpPayloadConjPort_dataPackage(const PTcpPayloadConjPort* self, DTcpPayload* data__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpPayloadConjPort", "dataPackage") + etPort_sendMessage(self, PTcpPayload_IN_dataPackage, sizeof(DTcpPayload), data__et); + ET_MSC_LOGGER_ASYNC_OUT(self->myInstName, "dataPackage", self->peerInstName) + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpPayloadConjReplPort_dataPackage_broadcast(const PTcpPayloadConjReplPort* self, DTcpPayload* data__et) { + int i; + ET_MSC_LOGGER_SYNC_ENTRY("PTcpPayloadConjReplPort", "dataPackage") + for (i=0; i<((etReplPort*)self)->size; ++i) { + etPort_sendMessage((&((etReplPort*)self)->ports[i].port), PTcpPayload_IN_dataPackage, sizeof(DTcpPayload), data__et); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[i].port.myInstName, "dataPackage", ((etReplPort*)self)->ports[i].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTcpPayloadConjReplPort_dataPackage(const PTcpPayloadConjReplPort* self, int idx__et, DTcpPayload* data__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTcpPayloadConjReplPort", "dataPackage") + if (0<=idx__et && idx__et<((etReplPort*)self)->size) { + etPort_sendMessage((&((etReplPort*)self)->ports[idx__et].port), PTcpPayload_IN_dataPackage, sizeof(DTcpPayload), data__et); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[idx__et].port.myInstName, "dataPackage", ((etReplPort*)self)->ports[idx__et].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +etInt32 PTcpPayloadConjReplPort_getReplication(const PTcpPayloadConjReplPort* self) { + return ((etReplPort*)self)->size; +} + + + +/*--------------------- debug helpers */ + +/* message names as strings for debugging (generate MSC) */ +static const char* const PTcpPayload_messageStrings[] = {"MIN", "dataPackage","dataPackage", "MAX"}; + +const char* PTcpPayload_getMessageString(int msg_id) { + if (msg_idPTcpPayload_MSG_MAX+1){ + /* id out of range */ + return "Message ID out of range"; + } + else{ + return PTcpPayload_messageStrings[msg_id]; + } +} diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload.h new file mode 100644 index 000000000..b27deac85 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload.h @@ -0,0 +1,55 @@ +/** + * @author generated by eTrice + * + * Header File of ProtocolClass PTcpPayload + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TCP_PTCPPAYLOAD_H_ +#define _ROOM_BASIC_SERVICE_TCP_PTCPPAYLOAD_H_ + +#include "etDatatypes.h" +#include "modelbase/etPort.h" + + +#include "room/basic/service/tcp/DTcpPayload.h" + + +/* message IDs */ +enum PTcpPayload_msg_ids { + PTcpPayload_MSG_MIN = 0, + PTcpPayload_OUT_dataPackage = 1, + PTcpPayload_IN_dataPackage = 2, + PTcpPayload_MSG_MAX = 3 +}; + +/*--------------------- port structs and methods */ +typedef etPort PTcpPayloadPort; +typedef etReplPort PTcpPayloadReplPort; + + +void PTcpPayloadPort_dataPackage(const PTcpPayloadPort* self, DTcpPayload* data); +void PTcpPayloadReplPort_dataPackage_broadcast(const PTcpPayloadReplPort* self, DTcpPayload* data); +void PTcpPayloadReplPort_dataPackage(const PTcpPayloadReplPort* self, int idx, DTcpPayload* data); + + +etInt32 PTcpPayloadReplPort_getReplication(const PTcpPayloadReplPort* self); +typedef etPort PTcpPayloadConjPort; +typedef etReplPort PTcpPayloadConjReplPort; + + +void PTcpPayloadConjPort_dataPackage(const PTcpPayloadConjPort* self, DTcpPayload* data); +void PTcpPayloadConjReplPort_dataPackage_broadcast(const PTcpPayloadConjReplPort* self, DTcpPayload* data); +void PTcpPayloadConjReplPort_dataPackage(const PTcpPayloadConjReplPort* self, int idx, DTcpPayload* data); + + +etInt32 PTcpPayloadConjReplPort_getReplication(const PTcpPayloadConjReplPort* self); + +/*--------------------- debug helpers */ + +/* get message string for message id */ +const char* PTcpPayload_getMessageString(int msg_id); + + +#endif /* _ROOM_BASIC_SERVICE_TCP_PTCPPAYLOAD_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload_Utils.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload_Utils.h new file mode 100644 index 000000000..260b9e6ee --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/tcp/PTcpPayload_Utils.h @@ -0,0 +1,19 @@ +/** + * @author generated by eTrice + * + * Utils File of ProtocolClass PTcpPayload + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TCP_PTCPPAYLOAD_UTILS_H_ +#define _ROOM_BASIC_SERVICE_TCP_PTCPPAYLOAD_UTILS_H_ + +#include "room/basic/service/tcp/PTcpPayload.h" + +/* + * access macros for operations and attributes +*/ + + +#endif /* _ROOM_BASIC_SERVICE_TCP_PTCPPAYLOAD_UTILS_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.c new file mode 100644 index 000000000..c2f7f4acd --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.c @@ -0,0 +1,406 @@ +/** + * @author generated by eTrice + * + * Source File of ActorClass ATimingService + * + */ + +#include "ATimingService.h" + +#include "modelbase/etActor.h" +#include "debugging/etLogger.h" +#include "debugging/etMSCLogger.h" +#include "etUnit/etUnit.h" +#include "base/etMemory.h" + +#include "room/basic/service/timing/PTimer.h" + +#include "ATimingService_Utils.h" + +/*--------------------- begin user code ---------------------*/ +/*uc3*/ +/*--------------------- end user code ---------------------*/ + +/* interface item IDs */ +enum interface_items { + IFITEM_timer = 1 +}; + +/* state IDs */ +enum state_ids { + NO_STATE = 0, + STATE_TOP = 1, + STATE_Operational = 2, + STATE_MAX = 3 +}; + +/* transition chains */ +enum ChainIDs { + CHAIN_TRANS_INITIAL_TO__Operational = 1, + CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1 = 2, + CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3 = 3, + CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4 = 4 +}; + +/* triggers */ +enum triggers { + POLLING = 0, + TRIG_timer__startTimer = IFITEM_timer + EVT_SHIFT*PTimer_IN_startTimer, + TRIG_timer__startTimeout = IFITEM_timer + EVT_SHIFT*PTimer_IN_startTimeout, + TRIG_timer__kill = IFITEM_timer + EVT_SHIFT*PTimer_IN_kill +}; + +/* state names */ +static char* stateStrings[] = {"","","Operational" +}; + +static void setState(ATimingService* self, etInt16 new_state) { + self->state = new_state; + ET_MSC_LOGGER_CHANGE_STATE(self->constData->instName, stateStrings[new_state]) +} + +static etInt16 getState(ATimingService* self) { + return self->state; +} + +/* Entry and Exit Codes */ +static void entry_Operational(ATimingService* self) { + /* prepare */ +} +static void do_Operational(ATimingService* self) { + /* maintain timers */ + etTimerControlBlock* temp; + etTime t; + + getTimeFromTarget(&t); + while (usedTcbsRoot !=0 ){ + if (isTimeGreater(&t,&(usedTcbsRoot->expTime))){ + timer_timeout(usedTcbsRoot->portIdx); + temp=usedTcbsRoot; + usedTcbsRoot=usedTcbsRoot->next; + if((temp->pTime.sec==0)&&(temp->pTime.nSec==0)){ + /* single shot timer */ + returnTcb(temp); + }else{ + /* periodic timer */ + addTime(&temp->expTime,&temp->pTime); + putTcbToUsedList(temp); + } + }else{ + break; + } + } +} + +/* Action Codes */ +static void action_TRANS_INITIAL_TO__Operational(ATimingService* self) { + int i; + usedTcbsRoot=0; + freeTcbsRoot=&tcbs[0]; + tcbs[ET_NB_OF_TCBS-1].next=0; + for (i=0;ipTime.sec = 0; + timer->pTime.nSec = 0; + timer->portIdx=((etReplSubPort*)ifitem)->index; + getTimeFromTarget(&(timer->expTime)); + addTime(&(timer->expTime),&t); + putTcbToUsedList(timer); + } +} +static void action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(ATimingService* self, const InterfaceItemBase* ifitem, uint32 time) { + etTimerControlBlock* timer = getTcb(); + etTime t; + if (timer!= 0){ + t.sec=time/1000; + t.nSec=(time%1000)*1000000L; + timer->pTime = t; + timer->portIdx=((etReplSubPort*)ifitem)->index; + getTimeFromTarget(&(timer->expTime)); + addTime(&(timer->expTime),&t); + putTcbToUsedList(timer); + } +} +static void action_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4(ATimingService* self, const InterfaceItemBase* ifitem) { + removeTcbFromUsedList(((etReplSubPort*)ifitem)->index); +} + +/* State Switch Methods */ +/** + * calls exit codes while exiting from the current state to one of its + * parent states while remembering the history + * @param current__et - the current state + * @param to - the final parent state + */ +static void exitTo(ATimingService* self, etInt16 current__et, etInt16 to) { + while (current__et!=to) { + switch (current__et) { + case STATE_Operational: + self->history[STATE_TOP] = STATE_Operational; + current__et = STATE_TOP; + break; + default: + /* should not occur */ + 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__et - the chain ID + * @param generic_data__et - the generic data pointer + * @return the +/- ID of the final state either with a positive sign, that indicates to execute the state's entry code, or a negative sign vice versa + */ +static etInt16 executeTransitionChain(ATimingService* self, int chain__et, const InterfaceItemBase* ifitem, void* generic_data__et) { + switch (chain__et) { + case CHAIN_TRANS_INITIAL_TO__Operational: + { + action_TRANS_INITIAL_TO__Operational(self); + return STATE_Operational; + } + case CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1: + { + uint32 time = *((uint32*) generic_data__et); + action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(self, ifitem, time); + return STATE_Operational; + } + case CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3: + { + uint32 time = *((uint32*) generic_data__et); + action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(self, ifitem, time); + return STATE_Operational; + } + case CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4: + { + action_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4(self, ifitem); + return STATE_Operational; + } + default: + /* should not occur */ + break; + } + return NO_STATE; +} + +/** + * calls entry codes while entering a state's history. The ID of the final leaf state is returned + * @param state__et - the state which is entered + * @return - the ID of the final leaf state + */ +static etInt16 enterHistory(ATimingService* self, etInt16 state__et) { + etBool skip_entry__et = ET_FALSE; + if (state__et >= STATE_MAX) { + state__et = (etInt16) (state__et - STATE_MAX); + skip_entry__et = ET_TRUE; + } + while (ET_TRUE) { + switch (state__et) { + case STATE_Operational: + if (!(skip_entry__et)) entry_Operational(self); + /* in leaf state: return state id */ + return STATE_Operational; + case STATE_TOP: + state__et = self->history[STATE_TOP]; + break; + default: + /* should not occur */ + break; + } + skip_entry__et = ET_FALSE; + } + /* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */ +} + +static void ATimingService_executeInitTransition(ATimingService* self) { + int chain__et = CHAIN_TRANS_INITIAL_TO__Operational; + etInt16 next__et = executeTransitionChain(self, chain__et, NULL, NULL); + next__et = enterHistory(self, next__et); + setState(self, next__et); +} + +/* receiveEvent contains the main implementation of the FSM */ +static void ATimingService_receiveEventInternal(ATimingService* self, InterfaceItemBase* ifitem, int localId, int evt, void* generic_data__et) { + int trigger__et = (ifitem==NULL)? POLLING : localId + EVT_SHIFT*evt; + int chain__et = NOT_CAUGHT; + etInt16 catching_state__et = NO_STATE; + ((void)trigger__et); /* avoids unused warning */ + + if (!handleSystemEvent(ifitem, evt, generic_data__et)) { + switch (getState(self)) { + case STATE_Operational: + switch(trigger__et) { + case POLLING: + do_Operational(self); + break; + case TRIG_timer__startTimeout: + { + chain__et = CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1; + catching_state__et = STATE_TOP; + } + break; + case TRIG_timer__startTimer: + { + chain__et = CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3; + catching_state__et = STATE_TOP; + } + break; + case TRIG_timer__kill: + { + chain__et = CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; + } + } + if (chain__et != NOT_CAUGHT) { + exitTo(self, getState(self), catching_state__et); + { + etInt16 next__et = executeTransitionChain(self, chain__et, ifitem, generic_data__et); + next__et = enterHistory(self, next__et); + setState(self, next__et); + } + } +} +static void ATimingService_receiveEvent(ATimingService* self, InterfaceItemBase* ifitem, int evt, void* generic_data__et) { + int localId = (ifitem==NULL)? 0 : ifitem->localId; + ATimingService_receiveEventInternal(self, ifitem, localId, evt, generic_data__et); +} + +void ATimingService_init(ATimingService* self){ + ET_MSC_LOGGER_SYNC_ENTRY("ATimingService", "init") + self->state = STATE_TOP; + { + int i; + for (i=0; ihistory[i] = NO_STATE; + } + ATimingService_executeInitTransition(self); + ET_MSC_LOGGER_SYNC_EXIT +} + + +void ATimingService_receiveMessage(void* self, const void* ifitem, const etMessage* msg){ + ET_MSC_LOGGER_SYNC_ENTRY("ATimingService", "_receiveMessage") + ATimingService_receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))); + + ET_MSC_LOGGER_SYNC_EXIT +} + +void ATimingService_execute(ATimingService* self) { + ET_MSC_LOGGER_SYNC_ENTRY("ATimingService", "_execute") + + ATimingService_receiveEvent(self, NULL, 0, NULL); + + ET_MSC_LOGGER_SYNC_EXIT +} + +/*--------------------- user constructor/destructor ---------------------*/ + +/*--------------------- operations ---------------------*/ + void ATimingService_returnTcb(ATimingService* self, etTimerControlBlock* block) { + block->next=freeTcbsRoot; + freeTcbsRoot=block; +} + void ATimingService_putTcbToUsedList(ATimingService* self, etTimerControlBlock* block) { + etTimerControlBlock* temp=usedTcbsRoot; + etTimerControlBlock* temp2=usedTcbsRoot; + + if (temp==0){ + /* list empty put new block to root */ + block->next=0; + usedTcbsRoot=block; + return; + } + + while(1){ + if (temp != 0){ + if (isTimeGreater(&block->expTime,&temp->expTime)){ + /* try next position */ + temp2=temp; + temp=temp->next; + }else{ + /* right position found */ + block->next=temp; + if(temp==usedTcbsRoot){ + usedTcbsRoot=block; + }else{ + temp2->next=block; + } + return; + } + }else{ + /* end of list reached */ + block->next=0; + temp2->next=block; + return; + } + } +} + void ATimingService_addTime(ATimingService* self, etTime* t1, etTime* t2) { + t1->sec += t2->sec; + t1->nSec += t2->nSec; + while(t1->nSec >= 1000000000L){ + t1->sec++; + t1->nSec-=1000000000L; + } +} + etTimerControlBlock* ATimingService_getTcb(ATimingService* self) { + etTimerControlBlock* temp = freeTcbsRoot; + + if(freeTcbsRoot!=0) { + freeTcbsRoot=freeTcbsRoot->next; + temp->next=0; + } + return temp; +} + void ATimingService_removeTcbFromUsedList(ATimingService* self, int32 idx) { + etTimerControlBlock* temp=usedTcbsRoot; + etTimerControlBlock* temp2=usedTcbsRoot; + + if (temp==0) return; + + if (usedTcbsRoot->portIdx == idx){ + /* element found, the first one */ + usedTcbsRoot = usedTcbsRoot->next; + returnTcb(temp); + return; + } + + temp=temp->next; + while(temp!=0){ + if(temp->portIdx==idx){ + temp2->next=temp->next; + returnTcb(temp); + return; + }else{ + /* try next */ + temp2=temp; + temp=temp->next; + } + } +} + bool ATimingService_isTimeGreater(ATimingService* self, etTime* t1, etTime* t2) { + if (t1->sec > t2->sec) return ET_TRUE; + if (t1->sec < t2->sec) return ET_FALSE; + if (t1->nSec > t2->nSec) return ET_TRUE; + return ET_FALSE; +} + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.h new file mode 100644 index 000000000..36e86ddc9 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService.h @@ -0,0 +1,89 @@ +/** + * @author generated by eTrice + * + * Header File of ActorClass ATimingService + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TIMING_ATIMINGSERVICE_H_ +#define _ROOM_BASIC_SERVICE_TIMING_ATIMINGSERVICE_H_ + +#include "etDatatypes.h" +#include "messaging/etMessage.h" + +#include "room/basic/service/timing/PTimer.h" + +/*--------------------- begin user code ---------------------*/ +#include "osal/etTime.h" +#define ET_NB_OF_TCBS 30 +typedef struct etTCB etTimerControlBlock; +struct etTCB { + etTime expTime; + etTime pTime; + int32 portIdx; + etTimerControlBlock* next; + }; +/*--------------------- end user code ---------------------*/ + +typedef struct ATimingService ATimingService; + +/* const part of ActorClass (ROM) */ +typedef struct ATimingService_const { + const char* instName; + + /* simple ports */ + + /* data receive ports */ + + /* saps */ + + /* replicated ports */ + + /* services */ + const etReplPort timer; +} ATimingService_const; + + +/* constant for state machine data */ +#define ATIMINGSERVICE_HISTORY_SIZE 2 + +/* variable part of ActorClass (RAM) */ +struct ATimingService { + const ATimingService_const* const constData; + + /* data send ports */ + + /*--------------------- attributes ---------------------*/ + etTimerControlBlock tcbs[30] + ; + etTimerControlBlock* usedTcbsRoot; + etTimerControlBlock* freeTcbsRoot; + + + /* state machine variables */ + etInt16 state; + etInt16 history[ATIMINGSERVICE_HISTORY_SIZE]; +}; + +void ATimingService_init(ATimingService* self); + +void ATimingService_receiveMessage(void* self, const void* ifitem, const etMessage* msg); + +void ATimingService_execute(ATimingService* self); + +/*--------------------- user constructor/destructor ---------------------*/ + +/*--------------------- operations ---------------------*/ + void ATimingService_returnTcb(ATimingService* self, etTimerControlBlock* block); + void ATimingService_putTcbToUsedList(ATimingService* self, etTimerControlBlock* block); + void ATimingService_addTime(ATimingService* self, etTime* t1, etTime* t2); + etTimerControlBlock* ATimingService_getTcb(ATimingService* self); + void ATimingService_removeTcbFromUsedList(ATimingService* self, int32 idx); + bool ATimingService_isTimeGreater(ATimingService* self, etTime* t1, etTime* t2); + +/*--------------------- begin user code ---------------------*/ +/*uc2*/ +/*--------------------- end user code ---------------------*/ + +#endif /* _ROOM_BASIC_SERVICE_TIMING_ATIMINGSERVICE_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService_Utils.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService_Utils.h new file mode 100644 index 000000000..572eac37c --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/ATimingService_Utils.h @@ -0,0 +1,47 @@ +/** + * @author generated by eTrice + * + * Utils File of ActorClass ATimingService + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TIMING_ATIMINGSERVICE_UTILS_H_ +#define _ROOM_BASIC_SERVICE_TIMING_ATIMINGSERVICE_UTILS_H_ + +#include "room/basic/service/timing/ATimingService.h" + +/* + * access macros for ports, operations and attributes +*/ + +/* simple event ports */ + +/* data receive ports */ + +/* data send ports */ + +/* saps */ + +/* replicated event ports */ + +/* services */ +#define timer_timeout_broadcast() PTimerReplPort_timeout_broadcast(&self->constData->timer) +#define timer_timeout(idx) PTimerReplPort_timeout(&self->constData->timer, idx) + +/* operations */ +#define returnTcb(block) ATimingService_returnTcb(self, block) +#define putTcbToUsedList(block) ATimingService_putTcbToUsedList(self, block) +#define addTime(t1, t2) ATimingService_addTime(self, t1, t2) +#define getTcb() ATimingService_getTcb(self) +#define removeTcbFromUsedList(idx) ATimingService_removeTcbFromUsedList(self, idx) +#define isTimeGreater(t1, t2) ATimingService_isTimeGreater(self, t1, t2) + +/* attributes */ +#define tcbs (self->tcbs) +#define usedTcbsRoot (self->usedTcbsRoot) +#define freeTcbsRoot (self->freeTcbsRoot) + +/* port operations */ + +#endif /* _ROOM_BASIC_SERVICE_TIMING_ATIMINGSERVICE_UTILS_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer.c new file mode 100644 index 000000000..1f6395e05 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer.c @@ -0,0 +1,141 @@ +/** + * @author generated by eTrice + * + * Source File of ProtocolClass PTimer + * + */ + +#include "PTimer.h" +#include "debugging/etMSCLogger.h" +#include "PTimer_Utils.h" + + +/*--------------------- port methods */ + +void PTimerPort_timeout(const PTimerPort* self) { + ET_MSC_LOGGER_SYNC_ENTRY("PTimerPort", "timeout") + etPort_sendMessage(self, PTimer_OUT_timeout, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(self->myInstName, "timeout", self->peerInstName) + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTimerReplPort_timeout_broadcast(const PTimerReplPort* self) { + int i; + ET_MSC_LOGGER_SYNC_ENTRY("PTimerReplPort", "timeout") + for (i=0; i<((etReplPort*)self)->size; ++i) { + etPort_sendMessage((&((etReplPort*)self)->ports[i].port), PTimer_OUT_timeout, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[i].port.myInstName, "timeout", ((etReplPort*)self)->ports[i].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTimerReplPort_timeout(const PTimerReplPort* self, int idx__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTimerReplPort", "timeout") + if (0<=idx__et && idx__et<((etReplPort*)self)->size) { + etPort_sendMessage((&((etReplPort*)self)->ports[idx__et].port), PTimer_OUT_timeout, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[idx__et].port.myInstName, "timeout", ((etReplPort*)self)->ports[idx__et].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +etInt32 PTimerReplPort_getReplication(const PTimerReplPort* self) { + return ((etReplPort*)self)->size; +} + + + +void PTimerConjPort_startTimer(const PTimerConjPort* self, uint32 data__et) { + if (status==0){ + status=ET_TIMER_RUNNING | ET_TIMER_PERIODIC; + etPort_sendMessage(self, PTimer_IN_startTimer, sizeof(int32), &data__et); + } +} + +void PTimerConjReplPort_startTimer_broadcast(const PTimerConjReplPort* self, uint32 data__et) { + int i; + for (i=0; i<((etReplPort*)self)->size; ++i) { + PTimerConjPort_startTimer(&((etReplPort*)self)->ports[i].port, data__et); + } +} + +void PTimerConjReplPort_startTimer(const PTimerConjReplPort* self, int idx__et, uint32 data__et) { + PTimerConjPort_startTimer(&((etReplPort*)self)->ports[idx__et].port, data__et); +} + + +void PTimerConjPort_startTimeout(const PTimerConjPort* self, uint32 data__et) { + if (status==0){ + status = ET_TIMER_RUNNING; + etPort_sendMessage(self, PTimer_IN_startTimeout, sizeof(int32), &data__et); + } +} + +void PTimerConjReplPort_startTimeout_broadcast(const PTimerConjReplPort* self, uint32 data__et) { + int i; + for (i=0; i<((etReplPort*)self)->size; ++i) { + PTimerConjPort_startTimeout(&((etReplPort*)self)->ports[i].port, data__et); + } +} + +void PTimerConjReplPort_startTimeout(const PTimerConjReplPort* self, int idx__et, uint32 data__et) { + PTimerConjPort_startTimeout(&((etReplPort*)self)->ports[idx__et].port, data__et); +} + + +void PTimerConjPort_kill(const PTimerConjPort* self) { + if (status!=0){ + status=0; + etPort_sendMessage(self, PTimer_IN_kill, 0,NULL); + } +} + +void PTimerConjReplPort_kill_broadcast(const PTimerConjReplPort* self) { + int i; + for (i=0; i<((etReplPort*)self)->size; ++i) { + PTimerConjPort_kill(&((etReplPort*)self)->ports[i].port); + } +} + +void PTimerConjReplPort_kill(const PTimerConjReplPort* self, int idx__et) { + PTimerConjPort_kill(&((etReplPort*)self)->ports[idx__et].port); +} + +/* begin PTimerConjPort specific (including base classes) */ + +/*--------------------- operations ---------------------*/ +/* end PTimerConjPort specific (including base classes) */ + +etInt32 PTimerConjReplPort_getReplication(const PTimerConjReplPort* self) { + return ((etReplPort*)self)->size; +} + +/* receiver handlers */ +void PTimerConjPort_timeout_receiveHandler(PTimerConjPort* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc){ + /* TODO: clear active bit in case of single shot timer */ + if (status!=0){ + if (status==ET_TIMER_RUNNING){ + /* single shot timer */ + status=0; + } + /* msg to fsm */ + (*receiveMessageFunc)(actor, self, msg); + } + /* hand over the message to the actor: */ + /* (*receiveMessageFunc)(actor, self, msg); */ +} + + +/*--------------------- debug helpers */ + +/* message names as strings for debugging (generate MSC) */ +static const char* const PTimer_messageStrings[] = {"MIN", "timeout","startTimer", "startTimeout", "kill", "MAX"}; + +const char* PTimer_getMessageString(int msg_id) { + if (msg_idPTimer_MSG_MAX+1){ + /* id out of range */ + return "Message ID out of range"; + } + else{ + return PTimer_messageStrings[msg_id]; + } +} diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer.h new file mode 100644 index 000000000..585239128 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer.h @@ -0,0 +1,76 @@ +/** + * @author generated by eTrice + * + * Header File of ProtocolClass PTimer + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TIMING_PTIMER_H_ +#define _ROOM_BASIC_SERVICE_TIMING_PTIMER_H_ + +#include "etDatatypes.h" +#include "modelbase/etPort.h" + +/*--------------------- begin user code ---------------------*/ +#define ET_TIMER_RUNNING 0x01 +#define ET_TIMER_PERIODIC 0x02 +/*--------------------- end user code ---------------------*/ + + + +/* message IDs */ +enum PTimer_msg_ids { + PTimer_MSG_MIN = 0, + PTimer_OUT_timeout = 1, + PTimer_IN_startTimer = 2, + PTimer_IN_startTimeout = 3, + PTimer_IN_kill = 4, + PTimer_MSG_MAX = 5 +}; + +/*--------------------- port structs and methods */ +typedef etPort PTimerPort; +typedef etReplPort PTimerReplPort; + + +void PTimerPort_timeout(const PTimerPort* self); +void PTimerReplPort_timeout_broadcast(const PTimerReplPort* self); +void PTimerReplPort_timeout(const PTimerReplPort* self, int idx); + + +etInt32 PTimerReplPort_getReplication(const PTimerReplPort* self); +typedef etPort PTimerConjPort; +typedef etReplPort PTimerConjReplPort; + +/* variable part of PortClass (RAM) */ +typedef struct PTimerConjPort_var PTimerConjPort_var; +struct PTimerConjPort_var { + /*--------------------- attributes ---------------------*/ + int8 status; +}; + +void PTimerConjPort_startTimer(const PTimerConjPort* self, uint32 data); +void PTimerConjReplPort_startTimer_broadcast(const PTimerConjReplPort* self, uint32 data); +void PTimerConjReplPort_startTimer(const PTimerConjReplPort* self, int idx, uint32 data); +void PTimerConjPort_startTimeout(const PTimerConjPort* self, uint32 data); +void PTimerConjReplPort_startTimeout_broadcast(const PTimerConjReplPort* self, uint32 data); +void PTimerConjReplPort_startTimeout(const PTimerConjReplPort* self, int idx, uint32 data); +void PTimerConjPort_kill(const PTimerConjPort* self); +void PTimerConjReplPort_kill_broadcast(const PTimerConjReplPort* self); +void PTimerConjReplPort_kill(const PTimerConjReplPort* self, int idx); + + +void PTimerConjPort_timeout_receiveHandler(PTimerConjPort* self, const etMessage* msg, void * actor, etActorReceiveMessage receiveMessageFunc); +etInt32 PTimerConjReplPort_getReplication(const PTimerConjReplPort* self); + +/*--------------------- debug helpers */ + +/* get message string for message id */ +const char* PTimer_getMessageString(int msg_id); + +/*--------------------- begin user code ---------------------*/ +/*uc2*/ +/*--------------------- end user code ---------------------*/ + +#endif /* _ROOM_BASIC_SERVICE_TIMING_PTIMER_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer_Utils.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer_Utils.h new file mode 100644 index 000000000..fe7e4ff1e --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/service/timing/PTimer_Utils.h @@ -0,0 +1,25 @@ +/** + * @author generated by eTrice + * + * Utils File of ProtocolClass PTimer + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TIMING_PTIMER_UTILS_H_ +#define _ROOM_BASIC_SERVICE_TIMING_PTIMER_UTILS_H_ + +#include "room/basic/service/timing/PTimer.h" + +/* + * access macros for operations and attributes +*/ + +/* conjugate port class */ + +/* operations */ + +/* attributes */ +#define status (((PTimerConjPort_var*)(self->varData))->status) + +#endif /* _ROOM_BASIC_SERVICE_TIMING_PTIMER_UTILS_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/PTestControl.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/PTestControl.c new file mode 100644 index 000000000..7d5c5db58 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/PTestControl.c @@ -0,0 +1,119 @@ +/** + * @author generated by eTrice + * + * Source File of ProtocolClass PTestControl + * + */ + +#include "PTestControl.h" +#include "debugging/etMSCLogger.h" +#include "PTestControl_Utils.h" + + +/*--------------------- port methods */ + +void PTestControlPort_done(const PTestControlPort* self, bool data__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTestControlPort", "done") + etPort_sendMessage(self, PTestControl_OUT_done, sizeof(bool), &data__et); + ET_MSC_LOGGER_ASYNC_OUT(self->myInstName, "done", self->peerInstName) + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTestControlReplPort_done_broadcast(const PTestControlReplPort* self, bool data__et) { + int i; + ET_MSC_LOGGER_SYNC_ENTRY("PTestControlReplPort", "done") + for (i=0; i<((etReplPort*)self)->size; ++i) { + etPort_sendMessage((&((etReplPort*)self)->ports[i].port), PTestControl_OUT_done, sizeof(bool), &data__et); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[i].port.myInstName, "done", ((etReplPort*)self)->ports[i].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTestControlReplPort_done(const PTestControlReplPort* self, int idx__et, bool data__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTestControlReplPort", "done") + if (0<=idx__et && idx__et<((etReplPort*)self)->size) { + etPort_sendMessage((&((etReplPort*)self)->ports[idx__et].port), PTestControl_OUT_done, sizeof(bool), &data__et); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[idx__et].port.myInstName, "done", ((etReplPort*)self)->ports[idx__et].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +etInt32 PTestControlReplPort_getReplication(const PTestControlReplPort* self) { + return ((etReplPort*)self)->size; +} + + + +void PTestControlConjPort_start(const PTestControlConjPort* self) { + ET_MSC_LOGGER_SYNC_ENTRY("PTestControlConjPort", "start") + etPort_sendMessage(self, PTestControl_IN_start, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(self->myInstName, "start", self->peerInstName) + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTestControlConjReplPort_start_broadcast(const PTestControlConjReplPort* self) { + int i; + ET_MSC_LOGGER_SYNC_ENTRY("PTestControlConjReplPort", "start") + for (i=0; i<((etReplPort*)self)->size; ++i) { + etPort_sendMessage((&((etReplPort*)self)->ports[i].port), PTestControl_IN_start, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[i].port.myInstName, "start", ((etReplPort*)self)->ports[i].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTestControlConjReplPort_start(const PTestControlConjReplPort* self, int idx__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTestControlConjReplPort", "start") + if (0<=idx__et && idx__et<((etReplPort*)self)->size) { + etPort_sendMessage((&((etReplPort*)self)->ports[idx__et].port), PTestControl_IN_start, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[idx__et].port.myInstName, "start", ((etReplPort*)self)->ports[idx__et].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + + +void PTestControlConjPort_abort(const PTestControlConjPort* self) { + ET_MSC_LOGGER_SYNC_ENTRY("PTestControlConjPort", "abort") + etPort_sendMessage(self, PTestControl_IN_abort, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(self->myInstName, "abort", self->peerInstName) + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTestControlConjReplPort_abort_broadcast(const PTestControlConjReplPort* self) { + int i; + ET_MSC_LOGGER_SYNC_ENTRY("PTestControlConjReplPort", "abort") + for (i=0; i<((etReplPort*)self)->size; ++i) { + etPort_sendMessage((&((etReplPort*)self)->ports[i].port), PTestControl_IN_abort, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[i].port.myInstName, "abort", ((etReplPort*)self)->ports[i].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +void PTestControlConjReplPort_abort(const PTestControlConjReplPort* self, int idx__et) { + ET_MSC_LOGGER_SYNC_ENTRY("PTestControlConjReplPort", "abort") + if (0<=idx__et && idx__et<((etReplPort*)self)->size) { + etPort_sendMessage((&((etReplPort*)self)->ports[idx__et].port), PTestControl_IN_abort, 0, NULL); + ET_MSC_LOGGER_ASYNC_OUT(((etReplPort*)self)->ports[idx__et].port.myInstName, "abort", ((etReplPort*)self)->ports[idx__et].port.peerInstName) + } + ET_MSC_LOGGER_SYNC_EXIT +} + +etInt32 PTestControlConjReplPort_getReplication(const PTestControlConjReplPort* self) { + return ((etReplPort*)self)->size; +} + + + +/*--------------------- debug helpers */ + +/* message names as strings for debugging (generate MSC) */ +static const char* const PTestControl_messageStrings[] = {"MIN", "done","start", "abort", "MAX"}; + +const char* PTestControl_getMessageString(int msg_id) { + if (msg_idPTestControl_MSG_MAX+1){ + /* id out of range */ + return "Message ID out of range"; + } + else{ + return PTestControl_messageStrings[msg_id]; + } +} diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/PTestControl.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/PTestControl.h new file mode 100644 index 000000000..380b03803 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/PTestControl.h @@ -0,0 +1,58 @@ +/** + * @author generated by eTrice + * + * Header File of ProtocolClass PTestControl + * + */ + +#ifndef _ROOM_BASIC_TEST_PTESTCONTROL_H_ +#define _ROOM_BASIC_TEST_PTESTCONTROL_H_ + +#include "etDatatypes.h" +#include "modelbase/etPort.h" + + + + +/* message IDs */ +enum PTestControl_msg_ids { + PTestControl_MSG_MIN = 0, + PTestControl_OUT_done = 1, + PTestControl_IN_start = 2, + PTestControl_IN_abort = 3, + PTestControl_MSG_MAX = 4 +}; + +/*--------------------- port structs and methods */ +typedef etPort PTestControlPort; +typedef etReplPort PTestControlReplPort; + + +void PTestControlPort_done(const PTestControlPort* self, bool data); +void PTestControlReplPort_done_broadcast(const PTestControlReplPort* self, bool data); +void PTestControlReplPort_done(const PTestControlReplPort* self, int idx, bool data); + + +etInt32 PTestControlReplPort_getReplication(const PTestControlReplPort* self); +typedef etPort PTestControlConjPort; +typedef etReplPort PTestControlConjReplPort; + + +void PTestControlConjPort_start(const PTestControlConjPort* self); +void PTestControlConjReplPort_start_broadcast(const PTestControlConjReplPort* self); +void PTestControlConjReplPort_start(const PTestControlConjReplPort* self, int idx); +void PTestControlConjPort_abort(const PTestControlConjPort* self); +void PTestControlConjReplPort_abort_broadcast(const PTestControlConjReplPort* self); +void PTestControlConjReplPort_abort(const PTestControlConjReplPort* self, int idx); + + +etInt32 PTestControlConjReplPort_getReplication(const PTestControlConjReplPort* self); + +/*--------------------- debug helpers */ + +/* get message string for message id */ +const char* PTestControl_getMessageString(int msg_id); + + +#endif /* _ROOM_BASIC_TEST_PTESTCONTROL_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/PTestControl_Utils.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/PTestControl_Utils.h new file mode 100644 index 000000000..1528e06f5 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/PTestControl_Utils.h @@ -0,0 +1,19 @@ +/** + * @author generated by eTrice + * + * Utils File of ProtocolClass PTestControl + * + */ + +#ifndef _ROOM_BASIC_TEST_PTESTCONTROL_UTILS_H_ +#define _ROOM_BASIC_TEST_PTESTCONTROL_UTILS_H_ + +#include "room/basic/test/PTestControl.h" + +/* + * access macros for operations and attributes +*/ + + +#endif /* _ROOM_BASIC_TEST_PTESTCONTROL_UTILS_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/SequentialTestExecutor.c b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/SequentialTestExecutor.c new file mode 100644 index 000000000..4f5bf3747 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/SequentialTestExecutor.c @@ -0,0 +1,220 @@ +/** + * @author generated by eTrice + * + * Source File of ActorClass SequentialTestExecutor + * + */ + +#include "SequentialTestExecutor.h" + +#include "modelbase/etActor.h" +#include "debugging/etLogger.h" +#include "debugging/etMSCLogger.h" +#include "etUnit/etUnit.h" +#include "base/etMemory.h" + +#include "room/basic/test/PTestControl.h" + +#include "SequentialTestExecutor_Utils.h" + +/*--------------------- begin user code ---------------------*/ +#include "etUnit/etUnit.h" +/*--------------------- end user code ---------------------*/ + +/* interface item IDs */ +enum interface_items { + IFITEM_control = 1 +}; + +/* state IDs */ +enum state_ids { + NO_STATE = 0, + STATE_TOP = 1, + STATE_execute = 2, + STATE_MAX = 3 +}; + +/* transition chains */ +enum ChainIDs { + CHAIN_TRANS_INITIAL_TO__execute = 1, + CHAIN_TRANS_tr0_FROM_execute_TO_execute_BY_donecontrol_tr0 = 2 +}; + +/* triggers */ +enum triggers { + POLLING = 0, + TRIG_control__done = IFITEM_control + EVT_SHIFT*PTestControl_OUT_done +}; + +/* state names */ +static char* stateStrings[] = {"","","execute" +}; + +static void setState(SequentialTestExecutor* self, etInt16 new_state) { + self->state = new_state; + ET_MSC_LOGGER_CHANGE_STATE(self->constData->instName, stateStrings[new_state]) +} + +static etInt16 getState(SequentialTestExecutor* self) { + return self->state; +} + +/* Entry and Exit Codes */ +static void entry_execute(SequentialTestExecutor* self) { + if(next < self->constData->control.size){ + control_start(next++); + } else { + etUnit_testFinished(0); + } +} + +/* Action Codes */ + +/* State Switch Methods */ +/** + * calls exit codes while exiting from the current state to one of its + * parent states while remembering the history + * @param current__et - the current state + * @param to - the final parent state + */ +static void exitTo(SequentialTestExecutor* self, etInt16 current__et, etInt16 to) { + while (current__et!=to) { + switch (current__et) { + case STATE_execute: + self->history[STATE_TOP] = STATE_execute; + current__et = STATE_TOP; + break; + default: + /* should not occur */ + 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__et - the chain ID + * @param generic_data__et - the generic data pointer + * @return the +/- ID of the final state either with a positive sign, that indicates to execute the state's entry code, or a negative sign vice versa + */ +static etInt16 executeTransitionChain(SequentialTestExecutor* self, int chain__et, const InterfaceItemBase* ifitem, void* generic_data__et) { + switch (chain__et) { + case CHAIN_TRANS_INITIAL_TO__execute: + { + return STATE_execute; + } + case CHAIN_TRANS_tr0_FROM_execute_TO_execute_BY_donecontrol_tr0: + { + bool success = *((bool*) generic_data__et); + return STATE_execute; + } + default: + /* should not occur */ + break; + } + return NO_STATE; +} + +/** + * calls entry codes while entering a state's history. The ID of the final leaf state is returned + * @param state__et - the state which is entered + * @return - the ID of the final leaf state + */ +static etInt16 enterHistory(SequentialTestExecutor* self, etInt16 state__et) { + etBool skip_entry__et = ET_FALSE; + if (state__et >= STATE_MAX) { + state__et = (etInt16) (state__et - STATE_MAX); + skip_entry__et = ET_TRUE; + } + while (ET_TRUE) { + switch (state__et) { + case STATE_execute: + if (!(skip_entry__et)) entry_execute(self); + /* in leaf state: return state id */ + return STATE_execute; + case STATE_TOP: + state__et = self->history[STATE_TOP]; + break; + default: + /* should not occur */ + break; + } + skip_entry__et = ET_FALSE; + } + /* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */ +} + +static void SequentialTestExecutor_executeInitTransition(SequentialTestExecutor* self) { + int chain__et = CHAIN_TRANS_INITIAL_TO__execute; + etInt16 next__et = executeTransitionChain(self, chain__et, NULL, NULL); + next__et = enterHistory(self, next__et); + setState(self, next__et); +} + +/* receiveEvent contains the main implementation of the FSM */ +static void SequentialTestExecutor_receiveEventInternal(SequentialTestExecutor* self, InterfaceItemBase* ifitem, int localId, int evt, void* generic_data__et) { + int trigger__et = localId + EVT_SHIFT*evt; + int chain__et = NOT_CAUGHT; + etInt16 catching_state__et = NO_STATE; + ((void)trigger__et); /* avoids unused warning */ + + if (!handleSystemEvent(ifitem, evt, generic_data__et)) { + switch (getState(self)) { + case STATE_execute: + switch(trigger__et) { + case TRIG_control__done: + { + chain__et = CHAIN_TRANS_tr0_FROM_execute_TO_execute_BY_donecontrol_tr0; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; + } + } + if (chain__et != NOT_CAUGHT) { + exitTo(self, getState(self), catching_state__et); + { + etInt16 next__et = executeTransitionChain(self, chain__et, ifitem, generic_data__et); + next__et = enterHistory(self, next__et); + setState(self, next__et); + } + } +} +static void SequentialTestExecutor_receiveEvent(SequentialTestExecutor* self, InterfaceItemBase* ifitem, int evt, void* generic_data__et) { + int localId = (ifitem==NULL)? 0 : ifitem->localId; + SequentialTestExecutor_receiveEventInternal(self, ifitem, localId, evt, generic_data__et); +} + +void SequentialTestExecutor_init(SequentialTestExecutor* self){ + ET_MSC_LOGGER_SYNC_ENTRY("SequentialTestExecutor", "init") + self->state = STATE_TOP; + { + int i; + for (i=0; ihistory[i] = NO_STATE; + } + SequentialTestExecutor_executeInitTransition(self); + ET_MSC_LOGGER_SYNC_EXIT +} + + +void SequentialTestExecutor_receiveMessage(void* self, const void* ifitem, const etMessage* msg){ + ET_MSC_LOGGER_SYNC_ENTRY("SequentialTestExecutor", "_receiveMessage") + SequentialTestExecutor_receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage)))); + + ET_MSC_LOGGER_SYNC_EXIT +} + + +/*--------------------- user constructor/destructor ---------------------*/ + +/*--------------------- operations ---------------------*/ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/SequentialTestExecutor.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/SequentialTestExecutor.h new file mode 100644 index 000000000..597d0a43e --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/SequentialTestExecutor.h @@ -0,0 +1,65 @@ +/** + * @author generated by eTrice + * + * Header File of ActorClass SequentialTestExecutor + * + */ + +#ifndef _ROOM_BASIC_TEST_SEQUENTIALTESTEXECUTOR_H_ +#define _ROOM_BASIC_TEST_SEQUENTIALTESTEXECUTOR_H_ + +#include "etDatatypes.h" +#include "messaging/etMessage.h" + +#include "room/basic/test/PTestControl.h" + + +typedef struct SequentialTestExecutor SequentialTestExecutor; + +/* const part of ActorClass (ROM) */ +typedef struct SequentialTestExecutor_const { + const char* instName; + + /* simple ports */ + + /* data receive ports */ + + /* saps */ + + /* replicated ports */ + const etReplPort control; + + /* services */ +} SequentialTestExecutor_const; + + +/* constant for state machine data */ +#define SEQUENTIALTESTEXECUTOR_HISTORY_SIZE 2 + +/* variable part of ActorClass (RAM) */ +struct SequentialTestExecutor { + const SequentialTestExecutor_const* const constData; + + /* data send ports */ + + /*--------------------- attributes ---------------------*/ + int16 next; + + + /* state machine variables */ + etInt16 state; + etInt16 history[SEQUENTIALTESTEXECUTOR_HISTORY_SIZE]; +}; + +void SequentialTestExecutor_init(SequentialTestExecutor* self); + +void SequentialTestExecutor_receiveMessage(void* self, const void* ifitem, const etMessage* msg); + + +/*--------------------- user constructor/destructor ---------------------*/ + +/*--------------------- operations ---------------------*/ + + +#endif /* _ROOM_BASIC_TEST_SEQUENTIALTESTEXECUTOR_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/SequentialTestExecutor_Utils.h b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/SequentialTestExecutor_Utils.h new file mode 100644 index 000000000..65c142abb --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.c/src-gen/room/basic/test/SequentialTestExecutor_Utils.h @@ -0,0 +1,42 @@ +/** + * @author generated by eTrice + * + * Utils File of ActorClass SequentialTestExecutor + * + */ + +#ifndef _ROOM_BASIC_TEST_SEQUENTIALTESTEXECUTOR_UTILS_H_ +#define _ROOM_BASIC_TEST_SEQUENTIALTESTEXECUTOR_UTILS_H_ + +#include "room/basic/test/SequentialTestExecutor.h" + +/* + * access macros for ports, operations and attributes +*/ + +/* simple event ports */ + +/* data receive ports */ + +/* data send ports */ + +/* saps */ + +/* replicated event ports */ +#define ifitem_index (((etReplSubPort*)ifitem)->index) +#define control_start_broadcast() PTestControlConjReplPort_start_broadcast(&self->constData->control) +#define control_start(idx) PTestControlConjReplPort_start(&self->constData->control, idx) +#define control_abort_broadcast() PTestControlConjReplPort_abort_broadcast(&self->constData->control) +#define control_abort(idx) PTestControlConjReplPort_abort(&self->constData->control, idx) + +/* services */ + +/* operations */ + +/* attributes */ +#define next (self->next) + +/* port operations */ + +#endif /* _ROOM_BASIC_TEST_SEQUENTIALTESTEXECUTOR_UTILS_H_ */ + diff --git a/runtime/org.eclipse.etrice.modellib.cpp/.cproject b/runtime/org.eclipse.etrice.modellib.cpp/.cproject index 17353cf60..e68f8efe2 100644 --- a/runtime/org.eclipse.etrice.modellib.cpp/.cproject +++ b/runtime/org.eclipse.etrice.modellib.cpp/.cproject @@ -12,9 +12,9 @@ + - @@ -99,11 +99,11 @@ + - @@ -182,11 +182,11 @@ + - @@ -259,9 +259,9 @@ + - @@ -382,4 +382,5 @@ + diff --git a/runtime/org.eclipse.etrice.modellib.cpp/.gitignore b/runtime/org.eclipse.etrice.modellib.cpp/.gitignore index 0c47e95b1..15c665a36 100644 --- a/runtime/org.eclipse.etrice.modellib.cpp/.gitignore +++ b/runtime/org.eclipse.etrice.modellib.cpp/.gitignore @@ -2,8 +2,6 @@ WindowsMinGW LinuxPosix WindowsMinGW_ST -src-gen/* -!src-gen/readme.txt src-gen-info/* !src-gen-info/readme.txt @@ -12,5 +10,3 @@ src-gen-info/* *.gz *.toc *.log -/MinGWDebug/ -/Debug/ diff --git a/runtime/org.eclipse.etrice.modellib.cpp/gen_modellib.launch b/runtime/org.eclipse.etrice.modellib.cpp/gen_modellib.launch index 20bfb754c..2b4e6e99d 100644 --- a/runtime/org.eclipse.etrice.modellib.cpp/gen_modellib.launch +++ b/runtime/org.eclipse.etrice.modellib.cpp/gen_modellib.launch @@ -9,7 +9,7 @@ - + diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp new file mode 100644 index 000000000..8639764df --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.cpp @@ -0,0 +1,399 @@ +/** + * @author generated by eTrice + * + * Source File of ActorClass ATimingService + * + */ + +#include "ATimingService.h" + +#include "common/messaging/RTObject.h" +#include "common/messaging/RTServices.h" +#include "common/debugging/DebuggingService.h" +#include "common/debugging/MSCFunctionObject.h" + +using namespace etRuntime; + + +/*--------------------- begin user code ---------------------*/ +// uc3 +/*--------------------- end user code ---------------------*/ + +ATimingService::ATimingService(etRuntime::IRTObject* parent, const String& name) + : ActorClassBase(parent, name) + , timer(this, "timer", IFITEM_timer) + , tcbs() + , usedTcbsRoot(0) + , freeTcbsRoot(0) +{ + MSCFunctionObject mscFunctionObject(getInstancePathName(), "Constructor"); + + for (int i = 0; i < s_numberOfStates; i++) { + history[i] = NO_STATE; + } + setClassName("ATimingService"); + + // sub actors + + /* user defined constructor body */ + memset(tcbs.getData(), sizeof(tcbs), 0); +} + +void ATimingService::initialize() { + MSCFunctionObject mscFunctionObject(getInstancePathName(), "initialize()"); + + ActorClassBase::initialize(); + + + // wiring + + // activate polling for data-driven communication + RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(getThread())->addPollingMessageReceiver(*this); +} + +void ATimingService::setProbesActive(bool recursive, bool active) { + DebuggingService::getInstance().addPortInstance(m_RTSystemPort); + for(int i = 0; i < timer.getNInterfaceItems(); i++) + DebuggingService::getInstance().addPortInstance(*(timer.getInterfaceItem(i))); +} + +void ATimingService::destroy(){ + MSCFunctionObject mscFunctionObject(getInstancePathName(), "destroy()"); + + /* user defined destructor body */ + DebuggingService::getInstance().addMessageActorDestroy(*this); + RTServices::getInstance().getMsgSvcCtrl().getMsgSvc(getThread())->removePollingMessageReceiver(*this); + ActorClassBase::destroy(); +} + +/*--------------------- operations ---------------------*/ + etTimerControlBlock* ATimingService::getTcb() { + etTimerControlBlock* temp = freeTcbsRoot; + + if (freeTcbsRoot != 0) { + freeTcbsRoot = freeTcbsRoot->next; + temp->next = 0; + } + return temp; +} + void ATimingService::returnTcb(etTimerControlBlock* block) { + block->next = freeTcbsRoot; + freeTcbsRoot = block; +} + void ATimingService::removeTcbFromUsedList(int32 idx) { + etTimerControlBlock* temp = usedTcbsRoot; + etTimerControlBlock* temp2 = usedTcbsRoot; + + if (temp == 0) + return; + + if (usedTcbsRoot->portIdx == idx) { + /* element found, the first one */ + usedTcbsRoot = usedTcbsRoot->next; + returnTcb(temp); + return; + } + + temp = temp->next; + while (temp != 0) { + if (temp->portIdx == idx) { + temp2->next = temp->next; + returnTcb(temp); + return; + } else { + /* try next */ + temp2 = temp; + temp = temp->next; + } + } +} + void ATimingService::putTcbToUsedList(etTimerControlBlock* block) { + etTimerControlBlock* temp = usedTcbsRoot; + etTimerControlBlock* temp2 = usedTcbsRoot; + + if (temp == 0) { + /* list empty put new block to root */ + block->next = 0; + usedTcbsRoot = block; + return; + } + + while (1) { + if (temp != 0) { + if (isTimeGreater(&block->expTime, &temp->expTime)) { + /* try next position */ + temp2 = temp; + temp = temp->next; + } else { + /* right position found */ + block->next = temp; + if (temp == usedTcbsRoot) { + usedTcbsRoot = block; + } else { + temp2->next = block; + } + return; + } + } else { + /* end of list reached */ + block->next = 0; + temp2->next = block; + return; + } + } +} + bool ATimingService::isTimeGreater(etTime* t1, etTime* t2) { + if (t1->sec > t2->sec) + return ET_TRUE; + if (t1->sec < t2->sec) + return ET_FALSE; + if (t1->nSec > t2->nSec) + return ET_TRUE; + return ET_FALSE; +} + void ATimingService::addTime(etTime* t1, etTime* t2) { + t1->sec += t2->sec; + t1->nSec += t2->nSec; + while (t1->nSec >= 1000000000L) { + t1->sec++; + t1->nSec -= 1000000000L; + } +} + +// state names +const String ATimingService::s_stateStrings[] = { + "", + "", + "Operational" +}; +const int ATimingService::s_numberOfStates = 3; + +void ATimingService::setState(int new_state) { + DebuggingService::getInstance().addActorState(*this, s_stateStrings[new_state].c_str()); + m_state = new_state; +} + +/* Entry and Exit Codes */ +void ATimingService::entry_Operational() { + // prepare +} + void ATimingService::do_Operational() { + // maintain timers + etTimerControlBlock* temp; + etTime t; + + getTimeFromTarget(&t); + while (usedTcbsRoot != 0) { + if (isTimeGreater(&t, &(usedTcbsRoot->expTime))) { + timer.get(usedTcbsRoot->portIdx).timeout(); + temp = usedTcbsRoot; + usedTcbsRoot = usedTcbsRoot->next; + if ((temp->pTime.sec == 0) && (temp->pTime.nSec == 0)) { + // single shot timer + returnTcb(temp); + } else { + // periodic timer + addTime(&temp->expTime, &temp->pTime); + putTcbToUsedList(temp); + } + } else { + break; + } + } +} + +/* Action Codes */ +void ATimingService::action_TRANS_INITIAL_TO__Operational() { + int i; + usedTcbsRoot = 0; + freeTcbsRoot = &tcbs[0]; + tcbs[ET_NB_OF_TCBS - 1].next = 0; + for (i = 0; i < ET_NB_OF_TCBS - 1; i++) { + tcbs[i].next = &tcbs[i + 1]; + } +} +void ATimingService::action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(const InterfaceItemBase* ifitem, uint32 time) { + etTimerControlBlock* timer = getTcb(); + etTime t; + if (timer != 0) { + t.sec = time / 1000; + t.nSec = (time % 1000) * 1000000L; + timer->pTime.sec = 0; + timer->pTime.nSec = 0; + timer->portIdx = ifitem->getIdx(); + getTimeFromTarget(&(timer->expTime)); + addTime(&(timer->expTime), &t); + putTcbToUsedList(timer); + } +} +void ATimingService::action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(const InterfaceItemBase* ifitem, uint32 time) { + etTimerControlBlock* timer = getTcb(); + etTime t; + if (timer != 0) { + t.sec = time / 1000; + t.nSec = (time % 1000) * 1000000L; + timer->pTime = t; + timer->portIdx = ifitem->getIdx(); + getTimeFromTarget(&(timer->expTime)); + addTime(&(timer->expTime), &t); + putTcbToUsedList(timer); + } +} +void ATimingService::action_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4(const InterfaceItemBase* ifitem) { + removeTcbFromUsedList(ifitem->getIdx()); +} + +/* State Switch Methods */ +/** + * calls exit codes while exiting from the current state to one of its + * parent states while remembering the history + * @param current__et - the current state + * @param to - the final parent state + */ +void ATimingService::exitTo(etInt16 current__et, etInt16 to) { + while (current__et!=to) { + switch (current__et) { + case STATE_Operational: + this->history[STATE_TOP] = STATE_Operational; + current__et = STATE_TOP; + break; + default: + /* should not occur */ + 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__et - the chain ID + * @param generic_data__et - the generic data pointer + * @return the +/- ID of the final state either with a positive sign, that indicates to execute the state's entry code, or a negative sign vice versa + */ +etInt16 ATimingService::executeTransitionChain(int chain__et, const InterfaceItemBase* ifitem, void* generic_data__et) { + switch (chain__et) { + case ATimingService::CHAIN_TRANS_INITIAL_TO__Operational: + { + action_TRANS_INITIAL_TO__Operational(); + return STATE_Operational; + } + case ATimingService::CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1: + { + uint32 time = *(static_cast(generic_data__et)); + action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(ifitem, time); + return STATE_Operational; + } + case ATimingService::CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3: + { + uint32 time = *(static_cast(generic_data__et)); + action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(ifitem, time); + return STATE_Operational; + } + case ATimingService::CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4: + { + action_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4(ifitem); + return STATE_Operational; + } + default: + /* should not occur */ + break; + } + return NO_STATE; +} + +/** + * calls entry codes while entering a state's history. The ID of the final leaf state is returned + * @param state__et - the state which is entered + * @return - the ID of the final leaf state + */ +etInt16 ATimingService::enterHistory(etInt16 state__et) { + etBool skip_entry__et = false; + if (state__et >= STATE_MAX) { + state__et = (state__et - STATE_MAX); + skip_entry__et = true; + } + while (true) { + switch (state__et) { + case STATE_Operational: + if (!(skip_entry__et)) entry_Operational(); + /* in leaf state: return state id */ + return STATE_Operational; + case STATE_TOP: + state__et = this->history[STATE_TOP]; + break; + default: + /* should not occur */ + break; + } + skip_entry__et = false; + } + /* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */ +} + +void ATimingService::executeInitTransition() { + int chain__et = ATimingService::CHAIN_TRANS_INITIAL_TO__Operational; + etInt16 next__et = ATimingService::executeTransitionChain(chain__et, 0, 0); + next__et = ATimingService::enterHistory(next__et); + setState(next__et); +} + +/* receiveEvent contains the main implementation of the FSM */ +void ATimingService::receiveEventInternal(InterfaceItemBase* ifitem, int localId, int evt, void* generic_data__et) { + int trigger__et = (ifitem==0)? POLLING : localId + EVT_SHIFT*evt; + int chain__et = NOT_CAUGHT; + etInt16 catching_state__et = NO_STATE; + + if (!handleSystemEvent(ifitem, evt, generic_data__et)) { + switch (getState()) { + case STATE_Operational: + switch(trigger__et) { + case POLLING: + do_Operational(); + break; + case TRIG_timer__startTimeout: + { + chain__et = ATimingService::CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1; + catching_state__et = STATE_TOP; + } + break; + case TRIG_timer__startTimer: + { + chain__et = ATimingService::CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3; + catching_state__et = STATE_TOP; + } + break; + case TRIG_timer__kill: + { + chain__et = ATimingService::CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; + } + } + if (chain__et != NOT_CAUGHT) { + ATimingService::exitTo(getState(), catching_state__et); + { + etInt16 next__et = ATimingService::executeTransitionChain(chain__et, ifitem, generic_data__et); + next__et = ATimingService::enterHistory(next__et); + setState(next__et); + } + } +} +void ATimingService::receiveEvent(InterfaceItemBase* ifitem, int evt, void* generic_data__et) { + int localId = (ifitem==0)? 0 : ifitem->getLocalId(); + ATimingService::receiveEventInternal(ifitem, localId, evt, generic_data__et); +} +void ATimingService::receive(const Message* msg) { + receiveEvent(0, -1, 0); +} + + diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h new file mode 100644 index 000000000..d351dd0aa --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/ATimingService.h @@ -0,0 +1,176 @@ +/** + * @author generated by eTrice + * + * Header File of ActorClass ATimingService + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TIMING_ATIMINGSERVICE_H_ +#define _ROOM_BASIC_SERVICE_TIMING_ATIMINGSERVICE_H_ + +#include "common/etDatatypesCpp.hpp" +#include "common/messaging/IRTObject.h" +#include "common/modelbase/PortBase.h" +#include "common/modelbase/ReplicatedActorClassBase.h" +#include "common/modelbase/InterfaceItemBase.h" +#include "common/modelbase/SubSystemClassBase.h" +#include "common/messaging/Address.h" +#include "common/messaging/IMessageReceiver.h" +#include "common/debugging/DebuggingService.h" + +#include "room/basic/service/timing/PTimer.h" + +#include "common/modelbase/ActorClassBase.h" + +/*--------------------- begin user code ---------------------*/ +#include "osal/etTime.h" +#define ET_NB_OF_TCBS 30 +typedef struct etTCB etTimerControlBlock; +struct etTCB { + etTime expTime; + etTime pTime; + int32 portIdx; + etTimerControlBlock* next; +}; +/*--------------------- end user code ---------------------*/ + +using namespace etRuntime; + + +class ATimingService : public etRuntime::ActorClassBase { + + + protected: + //--------------------- ports + + //--------------------- sub actors + + //--------------------- saps + + //--------------------- services + PTimerReplPort timer; + + //--------------------- interface item IDs + typedef enum { + IFITEM_timer = 1 + } interface_items; + + /*--------------------- attributes ---------------------*/ + StaticArray tcbs; + etTimerControlBlock* usedTcbsRoot; + etTimerControlBlock* freeTcbsRoot; + + /*--------------------- operations ---------------------*/ + etTimerControlBlock* getTcb(); + void returnTcb(etTimerControlBlock* block); + void removeTcbFromUsedList(int32 idx); + void putTcbToUsedList(etTimerControlBlock* block); + bool isTimeGreater(etTime* t1, etTime* t2); + void addTime(etTime* t1, etTime* t2); + + public: + //--------------------- construction + ATimingService(etRuntime::IRTObject* parent, const String& name); + void initialize(void); + void setProbesActive(bool recursive, bool active); + + //--------------------- port getters + + + PTimerReplPort& getTimer (){ + return this->timer; + } + + //--------------------- lifecycle functions + virtual void destroy(); + + /* state IDs */ + typedef enum { + STATE_Operational = 2, + STATE_MAX = 3 + } state_ids; + + /* transition chains */ + typedef enum { + CHAIN_TRANS_INITIAL_TO__Operational = 1, + CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1 = 2, + CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3 = 3, + CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4 = 4 + } ChainIDs; + + /* triggers */ + typedef enum { + POLLING = 0, + TRIG_timer__startTimer = IFITEM_timer + EVT_SHIFT*PTimer::IN_startTimer, + TRIG_timer__startTimeout = IFITEM_timer + EVT_SHIFT*PTimer::IN_startTimeout, + TRIG_timer__kill = IFITEM_timer + EVT_SHIFT*PTimer::IN_kill + } triggers; + + static const String s_stateStrings[]; + static const int s_numberOfStates; + + int history[3]; + + void setState(int new_state); + + /* Entry and Exit Codes */ + virtual void entry_Operational(); + virtual void do_Operational(); + + /* Action Codes */ + virtual void action_TRANS_INITIAL_TO__Operational(); + virtual void action_TRANS_tr1_FROM_Operational_TO_Operational_BY_startTimeouttimer_tr1(const InterfaceItemBase* ifitem, uint32 time); + virtual void action_TRANS_tr3_FROM_Operational_TO_Operational_BY_startTimertimer_tr3(const InterfaceItemBase* ifitem, uint32 time); + virtual void action_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4(const InterfaceItemBase* ifitem); + + /* State Switch Methods */ + /** + * calls exit codes while exiting from the current state to one of its + * parent states while remembering the history + * @param current__et - the current state + * @param to - the final parent state + */ + void exitTo(etInt16 current__et, etInt16 to); + + /** + * 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__et - the chain ID + * @param generic_data__et - the generic data pointer + * @return the +/- ID of the final state either with a positive sign, that indicates to execute the state's entry code, or a negative sign vice versa + */ + etInt16 executeTransitionChain(int chain__et, const InterfaceItemBase* ifitem, void* generic_data__et); + + /** + * calls entry codes while entering a state's history. The ID of the final leaf state is returned + * @param state__et - the state which is entered + * @return - the ID of the final leaf state + */ + etInt16 enterHistory(etInt16 state__et); + + void executeInitTransition(); + + /* receiveEvent contains the main implementation of the FSM */ + void receiveEventInternal(InterfaceItemBase* ifitem, int localId, int evt, void* generic_data__et); + void receiveEvent(InterfaceItemBase* ifitem, int evt, void* generic_data__et); + virtual void receive(const etRuntime::Message* msg); + + /*--------------------- begin user code ---------------------*/ + // uc2 + /*--------------------- end user code ---------------------*/ + +}; + +class ReplicatedATimingService : public ReplicatedActorClassBase { +public: + ReplicatedATimingService(IRTObject* parent, const String& name) : + ReplicatedActorClassBase(parent, name) {} + +protected: + ActorClassBase* createActor(IRTObject* parent, const String& name) { + return new ATimingService(parent, name); + } +}; + + +#endif /* _ROOM_BASIC_SERVICE_TIMING_ATIMINGSERVICE_H_ */ diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.cpp b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.cpp new file mode 100644 index 000000000..dce6afef7 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.cpp @@ -0,0 +1,226 @@ +/** + * @author generated by eTrice + * + * Source File of ProtocolClass PTimer + * + */ + +#include "PTimer.h" + +#include "common/debugging/DebuggingService.h" +#include "common/debugging/MSCFunctionObject.h" +#include "common/messaging/AbstractMessageReceiver.h" +#include "common/messaging/Address.h" +#include "common/messaging/Message.h" +#include "common/modelbase/IEventReceiver.h" + +using namespace etRuntime; + + + +/* message names as strings for debugging (generate MSC) */ +const String PTimer::s_messageStrings[] = {"MIN", "timeout", "startTimer","startTimeout","kill","MAX"}; + +const String& PTimer::getMessageString(int msg_id) { + if ((MSG_MIN < msg_id ) && ( msg_id < MSG_MAX )) { + return s_messageStrings[msg_id]; + } else { + // id out of range + static const String errorMsg = "Message ID out of range"; + return errorMsg; + } +} + +//------------------------------------------------------------------------------------------------------------ +// port class +//------------------------------------------------------------------------------------------------------------ + +PTimerPort::PTimerPort(IInterfaceItemOwner* actor, const String& name, int localId) + : PortBase(actor, name, localId, 0) +{ +} + +PTimerPort::PTimerPort(IInterfaceItemOwner* actor, const String& name, int localId, int idx) + : PortBase(actor, name, localId, idx) +{ +} + +void PTimerPort::destroy() { + DebuggingService::getInstance().removePortInstance(*this); + PortBase::destroy(); +} + +void PTimerPort::receive(const Message* msg) { + // TODO JH further + if (! PTimer::isValidIncomingEvtID(msg->getEvtId())) { + //std::cout << "unknown" << std::endl; + } + + DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), PTimer::getMessageString(msg->getEvtId()).c_str()); + + getActor()->receiveEvent(this, msg->getEvtId(), msg->getData()); +} + + +// sent messages +void PTimerPort::timeout() { + timeout_impl(); +} + +void PTimerPort::timeout_impl() { + DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), + PTimer::getMessageString(PTimer::OUT_timeout).c_str()); + if (getPeerAddress().isValid()) { + Message* buffer = dynamic_cast(getPeerMsgReceiver())->getMessageBuffer(sizeof(Message)); + if (buffer) { + getPeerMsgReceiver()->receive(new (buffer) Message(getPeerAddress(), PTimer::OUT_timeout)); + } + } +} + +//------------------------------------------------------------------------------------------------------------ +// replicated port class +//------------------------------------------------------------------------------------------------------------ +PTimerReplPort::PTimerReplPort(IInterfaceItemOwner* actor, const String& name, int localId) : + ReplicatedPortBase(actor, name, localId) +{ +} + +// outgoing messages +void PTimerReplPort::timeout(){ + for (Vector::iterator it = getItems().begin(); it != getItems().end(); ++it) { + (dynamic_cast(*it))->timeout(); + } +} +//------------------------------------------------------------------------------------------------------------ +// conjugated port class +//------------------------------------------------------------------------------------------------------------ + +PTimerConjPort::PTimerConjPort(IInterfaceItemOwner* actor, const String& name, int localId) + : PortBase(actor, name, localId, 0) + , status(0) +{ +} + +PTimerConjPort::PTimerConjPort(IInterfaceItemOwner* actor, const String& name, int localId, int idx) + : PortBase(actor, name, localId, idx) + , status(0) +{ +} + +void PTimerConjPort::destroy() { + DebuggingService::getInstance().removePortInstance(*this); + PortBase::destroy(); +} + +void PTimerConjPort::receive(const Message* msg) { + // TODO JH further + if (! PTimer::isValidOutgoingEvtID(msg->getEvtId())) { + //std::cout << "unknown" << std::endl; + } + + DebuggingService::getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), PTimer::getMessageString(msg->getEvtId()).c_str()); + + switch (msg->getEvtId()) { + case PTimer::OUT_timeout: + { + + //TODO: clear active bit in case of single shot timer + if (status!=0){ + if (status==ET_TIMER_RUNNING){ + // single shot timer + status=0; + } + // msg to fsm + getActor()->receiveEvent(this, msg->getEvtId(), msg->getData()); + } + } + break; + default: + getActor()->receiveEvent(this, msg->getEvtId(), msg->getData()); + break; + } +} + +/*--------------------- operations ---------------------*/ + +// sent messages +void PTimerConjPort::startTimer(uint32 time) { + if (status==0){ + status=ET_TIMER_RUNNING | ET_TIMER_PERIODIC; + startTimer_impl(time); + } +} + +void PTimerConjPort::startTimer_impl(uint32 time) { + DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), + PTimer::getMessageString(PTimer::IN_startTimer).c_str()); + if (getPeerAddress().isValid()) { + Message* buffer = dynamic_cast(getPeerMsgReceiver())->getMessageBuffer(sizeof(DataMessage)); + if (buffer) { + getPeerMsgReceiver()->receive(new (buffer) DataMessage(getPeerAddress(), PTimer::IN_startTimer, time)); + } + } +} +void PTimerConjPort::startTimeout(uint32 time) { + if (status==0){ + status = ET_TIMER_RUNNING; + startTimeout_impl(time); + } +} + +void PTimerConjPort::startTimeout_impl(uint32 time) { + DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), + PTimer::getMessageString(PTimer::IN_startTimeout).c_str()); + if (getPeerAddress().isValid()) { + Message* buffer = dynamic_cast(getPeerMsgReceiver())->getMessageBuffer(sizeof(DataMessage)); + if (buffer) { + getPeerMsgReceiver()->receive(new (buffer) DataMessage(getPeerAddress(), PTimer::IN_startTimeout, time)); + } + } +} +void PTimerConjPort::kill() { + + if (status!=0){ + status=0; + kill_impl(); + } +} + +void PTimerConjPort::kill_impl() { + DebuggingService::getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), + PTimer::getMessageString(PTimer::IN_kill).c_str()); + if (getPeerAddress().isValid()) { + Message* buffer = dynamic_cast(getPeerMsgReceiver())->getMessageBuffer(sizeof(Message)); + if (buffer) { + getPeerMsgReceiver()->receive(new (buffer) Message(getPeerAddress(), PTimer::IN_kill)); + } + } +} + +//------------------------------------------------------------------------------------------------------------ +// conjugated replicated port class +//------------------------------------------------------------------------------------------------------------ +PTimerConjReplPort::PTimerConjReplPort(IInterfaceItemOwner* actor, const String& name, int localId) : + ReplicatedPortBase(actor, name, localId) +{ +} + +// incoming messages +void PTimerConjReplPort::startTimer(uint32 time){ + for (Vector::iterator it = getItems().begin(); it != getItems().end(); ++it) { + (dynamic_cast(*it))->startTimer( time); + } +} +void PTimerConjReplPort::startTimeout(uint32 time){ + for (Vector::iterator it = getItems().begin(); it != getItems().end(); ++it) { + (dynamic_cast(*it))->startTimeout( time); + } +} +void PTimerConjReplPort::kill(){ + for (Vector::iterator it = getItems().begin(); it != getItems().end(); ++it) { + (dynamic_cast(*it))->kill(); + } +} + + diff --git a/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.h b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.h new file mode 100644 index 000000000..be5e64f10 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.cpp/src-gen/room/basic/service/timing/PTimer.h @@ -0,0 +1,145 @@ +/** + * @author generated by eTrice + * + * Header File of ProtocolClass PTimer + * + */ + +#ifndef _ROOM_BASIC_SERVICE_TIMING_PTIMER_H_ +#define _ROOM_BASIC_SERVICE_TIMING_PTIMER_H_ + +#include "common/modelbase/InterfaceItemBase.h" +#include "common/modelbase/PortBase.h" +#include "common/modelbase/ReplicatedInterfaceItemBase.h" +#include "common/modelbase/ReplicatedPortBase.h" +#include "common/etDatatypesCpp.hpp" + + +/*--------------------- begin user code ---------------------*/ +#define ET_TIMER_RUNNING 0x01 +#define ET_TIMER_PERIODIC 0x02 +/*--------------------- end user code ---------------------*/ + + +class PTimer { + public: + /* message IDs */ + typedef enum { + MSG_MIN = 0, + OUT_timeout = 1, + IN_startTimer = 2, + IN_startTimeout = 3, + IN_kill = 4, + MSG_MAX = 5 + } msg_ids; + + /*--------------------- begin user code ---------------------*/ + //uc2 + /*--------------------- end user code ---------------------*/ + + static bool isValidEvtID(int evtId) { + return ((MSG_MIN < evtId) && (evtId < MSG_MAX)); + } + static bool isValidOutgoingEvtID(int evtId) { + return ((MSG_MIN < evtId) && (evtId < IN_startTimer)); + } + static bool isValidIncomingEvtID(int evtId) { + return ((IN_startTimer <= evtId) && (evtId < MSG_MAX)); + } + static const etRuntime::String& getMessageString(int msg_id); + + private: + static const etRuntime::String s_messageStrings[]; + +}; + +//------------------------------------------------------------------------------------------------------------ +// port class +//------------------------------------------------------------------------------------------------------------ +class PTimerPort : public etRuntime::PortBase { + public: + PTimerPort(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId); + PTimerPort(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId, int idx); + + virtual void destroy(); + + virtual void receive(const etRuntime::Message* m); + + + // sent messages + public: void timeout(); + private: void timeout_impl(); +}; + +//------------------------------------------------------------------------------------------------------------ +// replicated port class +//------------------------------------------------------------------------------------------------------------ +class PTimerReplPort : public etRuntime::ReplicatedPortBase { + + public: + PTimerReplPort(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId); + + int getReplication() const { return getNInterfaceItems(); } + int getIndexOf(const etRuntime::InterfaceItemBase& ifitem) const { return ifitem.getIdx(); } + PTimerPort& get(int idx) const { return *dynamic_cast(getInterfaceItem(idx)); } + + // outgoing messages + public: void timeout(); + + protected: + virtual etRuntime::InterfaceItemBase* createInterfaceItem(etRuntime::IInterfaceItemOwner* rcv, const etRuntime::String& name, int lid, int idx) { + return new PTimerPort(rcv, name, lid, idx); + } + +}; +//------------------------------------------------------------------------------------------------------------ +// conjugated port class +//------------------------------------------------------------------------------------------------------------ +class PTimerConjPort : public etRuntime::PortBase { + public: + PTimerConjPort(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId); + PTimerConjPort(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId, int idx); + + virtual void destroy(); + + virtual void receive(const etRuntime::Message* m); + + /*--------------------- attributes ---------------------*/ + int8 status; + /*--------------------- operations ---------------------*/ + + // sent messages + public: void startTimer(uint32 time); + private: void startTimer_impl(uint32 time); + public: void startTimeout(uint32 time); + private: void startTimeout_impl(uint32 time); + public: void kill(); + private: void kill_impl(); +}; + +//------------------------------------------------------------------------------------------------------------ +// conjugated replicated port class +//------------------------------------------------------------------------------------------------------------ +class PTimerConjReplPort : public etRuntime::ReplicatedPortBase { + + public: + PTimerConjReplPort(etRuntime::IInterfaceItemOwner* actor, const etRuntime::String& name, int localId); + + int getReplication() const { return getNInterfaceItems(); } + int getIndexOf(const etRuntime::InterfaceItemBase& ifitem) const { return ifitem.getIdx(); } + PTimerConjPort& get(int idx) const { return *dynamic_cast(getInterfaceItem(idx)); } + + // incoming messages + public: void startTimer(uint32 time); + public: void startTimeout(uint32 time); + public: void kill(); + + protected: + virtual etRuntime::InterfaceItemBase* createInterfaceItem(etRuntime::IInterfaceItemOwner* rcv, const etRuntime::String& name, int lid, int idx) { + return new PTimerConjPort(rcv, name, lid, idx); + } + +}; + + +#endif /* _ROOM_BASIC_SERVICE_TIMING_PTIMER_H_ */ diff --git a/runtime/org.eclipse.etrice.modellib.java/.gitignore b/runtime/org.eclipse.etrice.modellib.java/.gitignore index db5801d65..53efcc01b 100644 --- a/runtime/org.eclipse.etrice.modellib.java/.gitignore +++ b/runtime/org.eclipse.etrice.modellib.java/.gitignore @@ -1,6 +1,4 @@ bin -src-gen/* -!src-gen/readme.txt src-gen-info/* !src-gen-info/readme.txt doc-gen/* diff --git a/runtime/org.eclipse.etrice.modellib.java/gen_modellib.launch b/runtime/org.eclipse.etrice.modellib.java/gen_modellib.launch index 3ee35bcf0..cf281c2f4 100644 --- a/runtime/org.eclipse.etrice.modellib.java/gen_modellib.launch +++ b/runtime/org.eclipse.etrice.modellib.java/gen_modellib.launch @@ -10,6 +10,7 @@ + diff --git a/runtime/org.eclipse.etrice.modellib.java/model/diagrams/room.basic.etunit.TestCaseActor.behavior b/runtime/org.eclipse.etrice.modellib.java/model/diagrams/room.basic.etunit.TestCaseActor.behavior deleted file mode 100644 index f74c98dbf..000000000 --- a/runtime/org.eclipse.etrice.modellib.java/model/diagrams/room.basic.etunit.TestCaseActor.behavior +++ /dev/null @@ -1,284 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/ALogService.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/ALogService.java new file mode 100644 index 000000000..427ed97bb --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/ALogService.java @@ -0,0 +1,307 @@ +package room.basic.service.logging; + +import org.eclipse.etrice.runtime.java.messaging.*; +import org.eclipse.etrice.runtime.java.modelbase.*; +import org.eclipse.etrice.runtime.java.debugging.*; + +import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*; + +import room.basic.service.logging.Log.*; + +/*--------------------- begin user code ---------------------*/ +import java.io.*; +import java.util.*; +/*--------------------- end user code ---------------------*/ + + +public class ALogService extends ActorClassBase { + + /*--------------------- begin user code ---------------------*/ + FileOutputStream file = null; + PrintStream p = null; + static long tStart = System.currentTimeMillis(); + /*--------------------- end user code ---------------------*/ + + //--------------------- ports + + //--------------------- saps + + //--------------------- services + protected LogReplPort log = null; + + //--------------------- optional actors + + //--------------------- interface item IDs + public static final int IFITEM_log = 1; + + /*--------------------- attributes ---------------------*/ + + /*--------------------- operations ---------------------*/ + public void destroyUser() { + if (p!= null) { + p.flush(); + p.close(); + p=null; + } + } + + + //--------------------- construction + public ALogService(IRTObject parent, String name) { + super(parent, name); + setClassName("ALogService"); + + // initialize attributes + + // own ports + + // own saps + + // own service implementations + log = new LogReplPort(this, "log", IFITEM_log); + + // sub actors + + // wiring + + + /* user defined constructor body */ + + } + + /* --------------------- attribute setters and getters */ + + + //--------------------- port getters + public LogReplPort getLog (){ + return this.log; + } + + //--------------------- lifecycle functions + public void stop(){ + super.stop(); + } + + public void destroy(){ + /* user defined destructor body */ + DebuggingService.getInstance().addMessageActorDestroy(this); + super.destroy(); + } + + /* state IDs */ + public static final int STATE_closed = 2; + public static final int STATE_opened = 3; + public static final int STATE_MAX = 4; + + /* transition chains */ + public static final int CHAIN_TRANS_INITIAL_TO__closed = 1; + public static final int CHAIN_TRANS_open_FROM_closed_TO_opened_BY_openlog = 2; + public static final int CHAIN_TRANS_tr0_FROM_opened_TO_closed_BY_closelog = 3; + public static final int CHAIN_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1 = 4; + + /* triggers */ + public static final int POLLING = 0; + public static final int TRIG_log__open = IFITEM_log + EVT_SHIFT*Log.IN_open; + public static final int TRIG_log__close = IFITEM_log + EVT_SHIFT*Log.IN_close; + public static final int TRIG_log__internalLog = IFITEM_log + EVT_SHIFT*Log.IN_internalLog; + + // state names + protected static final String stateStrings[] = { + "", + "", + "closed", + "opened" + }; + + // history + protected int history[] = {NO_STATE, NO_STATE, NO_STATE, NO_STATE}; + + private void setState(int new_state) { + DebuggingService.getInstance().addActorState(this,stateStrings[new_state]); + this.state = new_state; + } + + /* Entry and Exit Codes */ + + /* Action Codes */ + protected void action_TRANS_open_FROM_closed_TO_opened_BY_openlog(InterfaceItemBase ifitem, String fileName) { + Date d=new Date(tStart); + try{ + file=new FileOutputStream(fileName); + p=new PrintStream(file); + p.println("Log opened at "+ d.toString()); + p.println("--------------------------------------------------"); + } catch (Exception e){ + System.out.println("Log file not opened !"); + } + } + protected void action_TRANS_tr0_FROM_opened_TO_closed_BY_closelog(InterfaceItemBase ifitem) { + p.flush(); + p.close(); + p=null; + } + protected void action_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1(InterfaceItemBase ifitem, InternalLogData data) { + p.println("Timestamp: " + Long.toString(data.timeStamp-tStart) + "ms"); + p.println("SenderInstance: "+ data.sender); + p.println("UserString: " + data.userString); + p.println("--------------------------------------------------"); + System.out.printf(data.userString); + } + + /* State Switch Methods */ + /** + * calls exit codes while exiting from the current state to one of its + * parent states while remembering the history + * @param current__et - the current state + * @param to - the final parent state + */ + private void exitTo(int current__et, int to) { + while (current__et!=to) { + switch (current__et) { + case STATE_closed: + this.history[STATE_TOP] = STATE_closed; + current__et = STATE_TOP; + break; + case STATE_opened: + this.history[STATE_TOP] = STATE_opened; + current__et = STATE_TOP; + break; + default: + /* should not occur */ + 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__et - the chain ID + * @param generic_data__et - the generic data pointer + * @return the +/- ID of the final state either with a positive sign, that indicates to execute the state's entry code, or a negative sign vice versa + */ + private int executeTransitionChain(int chain__et, InterfaceItemBase ifitem, Object generic_data__et) { + switch (chain__et) { + case ALogService.CHAIN_TRANS_INITIAL_TO__closed: + { + return STATE_closed; + } + case ALogService.CHAIN_TRANS_open_FROM_closed_TO_opened_BY_openlog: + { + String fileName = (String) generic_data__et; + action_TRANS_open_FROM_closed_TO_opened_BY_openlog(ifitem, fileName); + return STATE_opened; + } + case ALogService.CHAIN_TRANS_tr0_FROM_opened_TO_closed_BY_closelog: + { + action_TRANS_tr0_FROM_opened_TO_closed_BY_closelog(ifitem); + return STATE_closed; + } + case ALogService.CHAIN_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1: + { + InternalLogData data = (InternalLogData) generic_data__et; + action_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1(ifitem, data); + return STATE_opened; + } + default: + /* should not occur */ + break; + } + return NO_STATE; + } + + /** + * calls entry codes while entering a state's history. The ID of the final leaf state is returned + * @param state__et - the state which is entered + * @return - the ID of the final leaf state + */ + private int enterHistory(int state__et) { + if (state__et >= STATE_MAX) { + state__et = (state__et - STATE_MAX); + } + while (true) { + switch (state__et) { + case STATE_closed: + /* in leaf state: return state id */ + return STATE_closed; + case STATE_opened: + /* in leaf state: return state id */ + return STATE_opened; + case STATE_TOP: + state__et = this.history[STATE_TOP]; + break; + default: + /* should not occur */ + break; + } + } + /* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */ + } + + public void executeInitTransition() { + int chain__et = ALogService.CHAIN_TRANS_INITIAL_TO__closed; + int next__et = executeTransitionChain(chain__et, null, null); + next__et = enterHistory(next__et); + setState(next__et); + } + + /* receiveEvent contains the main implementation of the FSM */ + public void receiveEventInternal(InterfaceItemBase ifitem, int localId, int evt, Object generic_data__et) { + int trigger__et = localId + EVT_SHIFT*evt; + int chain__et = NOT_CAUGHT; + int catching_state__et = NO_STATE; + + if (!handleSystemEvent(ifitem, evt, generic_data__et)) { + switch (getState()) { + case STATE_closed: + switch(trigger__et) { + case TRIG_log__open: + { + chain__et = ALogService.CHAIN_TRANS_open_FROM_closed_TO_opened_BY_openlog; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_opened: + switch(trigger__et) { + case TRIG_log__close: + { + chain__et = ALogService.CHAIN_TRANS_tr0_FROM_opened_TO_closed_BY_closelog; + catching_state__et = STATE_TOP; + } + break; + case TRIG_log__internalLog: + { + chain__et = ALogService.CHAIN_TRANS_tr1_FROM_opened_TO_opened_BY_internalLoglog_tr1; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; + } + } + if (chain__et != NOT_CAUGHT) { + exitTo(getState(), catching_state__et); + { + int next__et = executeTransitionChain(chain__et, ifitem, generic_data__et); + next__et = enterHistory(next__et); + setState(next__et); + } + } + } + public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data__et) { + int localId = (ifitem==null)? 0 : ifitem.getLocalId(); + receiveEventInternal(ifitem, localId, evt, generic_data__et); + } + +}; diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/InternalLogData.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/InternalLogData.java new file mode 100644 index 000000000..d14c2e35e --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/InternalLogData.java @@ -0,0 +1,71 @@ +package room.basic.service.logging; + +import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*; +import java.io.Serializable; + + + + +public class InternalLogData implements Serializable { + + private static final long serialVersionUID = 463634558L; + + + /*--------------------- attributes ---------------------*/ + public String userString; + public String sender; + public long timeStamp; + + /* --------------------- attribute setters and getters */ + public void setUserString(String userString) { + this.userString = userString; + } + public String getUserString() { + return this.userString; + } + public void setSender(String sender) { + this.sender = sender; + } + public String getSender() { + return this.sender; + } + public void setTimeStamp(long timeStamp) { + this.timeStamp = timeStamp; + } + public long getTimeStamp() { + return this.timeStamp; + } + + /*--------------------- operations ---------------------*/ + + // default constructor + public InternalLogData() { + super(); + + // initialize attributes + this.setUserString(""); + this.setSender(""); + + /* user defined constructor body */ + } + + // constructor using fields + public InternalLogData(String userString, String sender, long timeStamp) { + super(); + + this.userString = userString; + this.sender = sender; + this.timeStamp = timeStamp; + + /* user defined constructor body */ + } + + // deep copy + public InternalLogData deepCopy() { + InternalLogData copy = new InternalLogData(); + copy.userString = userString; + copy.sender = sender; + copy.timeStamp = timeStamp; + return copy; + } +}; diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/Log.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/Log.java new file mode 100644 index 000000000..6939ebcad --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/logging/Log.java @@ -0,0 +1,217 @@ +package room.basic.service.logging; + +import org.eclipse.etrice.runtime.java.messaging.Message; +import org.eclipse.etrice.runtime.java.modelbase.EventMessage; +import org.eclipse.etrice.runtime.java.modelbase.EventWithDataMessage; +import org.eclipse.etrice.runtime.java.modelbase.IInterfaceItemOwner; +import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase; +import org.eclipse.etrice.runtime.java.modelbase.PortBase; +import org.eclipse.etrice.runtime.java.modelbase.ReplicatedPortBase; +import org.eclipse.etrice.runtime.java.debugging.DebuggingService; +import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*; + + + +public class Log { + // message IDs + public static final int MSG_MIN = 0; + public static final int IN_open = 1; + public static final int IN_close = 2; + public static final int IN_internalLog = 3; + public static final int MSG_MAX = 4; + + /*--------------------- begin user code ---------------------*/ + public static final int LOG_LEVEL_LOW = 1; + public static final int LOG_LEVEL_MEDIUM = 2; + public static final int LOG_LEVEL_HIGH = 3; + /*--------------------- end user code ---------------------*/ + + private static String messageStrings[] = {"MIN", "open","close","internalLog","MAX"}; + + public String getMessageString(int msg_id) { + if (msg_idMSG_MAX+1){ + // id out of range + return "Message ID out of range"; + } + else{ + return messageStrings[msg_id]; + } + } + + + // port class + static public class LogPort extends PortBase { + // constructors + public LogPort(IInterfaceItemOwner actor, String name, int localId) { + this(actor, name, localId, 0); + } + public LogPort(IInterfaceItemOwner actor, String name, int localId, int idx) { + super(actor, name, localId, idx); + DebuggingService.getInstance().addPortInstance(this); + } + + public void destroy() { + DebuggingService.getInstance().removePortInstance(this); + super.destroy(); + } + + @Override + public void receive(Message m) { + if (!(m instanceof EventMessage)) + return; + EventMessage msg = (EventMessage) m; + if (0 < msg.getEvtId() && msg.getEvtId() < MSG_MAX) { + DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]); + if (msg instanceof EventWithDataMessage) + getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData()); + else + getActor().receiveEvent(this, msg.getEvtId(), null); + } + } + + + // sent messages + } + + // replicated port class + static public class LogReplPort extends ReplicatedPortBase { + + public LogReplPort(IInterfaceItemOwner actor, String name, int localId) { + super(actor, name, localId); + } + + public int getReplication() { + return getNInterfaceItems(); + } + + public int getIndexOf(InterfaceItemBase ifitem){ + return ifitem.getIdx(); + } + + public LogPort get(int idx) { + return (LogPort) getInterfaceItem(idx); + } + + protected InterfaceItemBase createInterfaceItem(IInterfaceItemOwner rcv, String name, int lid, int idx) { + return new LogPort(rcv, name, lid, idx); + } + + // outgoing messages + } + + + // port class + static public class LogConjPort extends PortBase { + /*--------------------- begin user code ---------------------*/ + static int logLevel=0; + InternalLogData d = new InternalLogData(); + /*--------------------- end user code ---------------------*/ + // constructors + public LogConjPort(IInterfaceItemOwner actor, String name, int localId) { + this(actor, name, localId, 0); + } + public LogConjPort(IInterfaceItemOwner actor, String name, int localId, int idx) { + super(actor, name, localId, idx); + // initialize attributes + DebuggingService.getInstance().addPortInstance(this); + } + + public void destroy() { + DebuggingService.getInstance().removePortInstance(this); + super.destroy(); + } + + @Override + public void receive(Message m) { + if (!(m instanceof EventMessage)) + return; + EventMessage msg = (EventMessage) m; + if (0 < msg.getEvtId() && msg.getEvtId() < MSG_MAX) { + DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]); + if (msg instanceof EventWithDataMessage) + getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData()); + else + getActor().receiveEvent(this, msg.getEvtId(), null); + } + } + + /*--------------------- attributes ---------------------*/ + /* --------------------- attribute setters and getters */ + /*--------------------- operations ---------------------*/ + public void setLogLevel(int l) { + logLevel=l; + if (logLevel > LOG_LEVEL_HIGH) logLevel=LOG_LEVEL_HIGH; + } + public void log(int logLevel, String userString) { + if (logLevel>LogConjPort.logLevel){ + d.userString=userString; + d.timeStamp=System.currentTimeMillis(); + d.sender=getInstancePath(); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalLog, d.deepCopy())); + } + } + + // sent messages + public void open(String fileName) { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_open]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_open, fileName)); + } + public void close() { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_close]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_close)); + } + private void internalLog(InternalLogData data) { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_internalLog]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalLog, data.deepCopy())); + } + public void internalLog(String userString, String sender, long timeStamp) { + internalLog(new InternalLogData(userString, sender, timeStamp)); + } + } + + // replicated port class + static public class LogConjReplPort extends ReplicatedPortBase { + + public LogConjReplPort(IInterfaceItemOwner actor, String name, int localId) { + super(actor, name, localId); + } + + public int getReplication() { + return getNInterfaceItems(); + } + + public int getIndexOf(InterfaceItemBase ifitem){ + return ifitem.getIdx(); + } + + public LogConjPort get(int idx) { + return (LogConjPort) getInterfaceItem(idx); + } + + protected InterfaceItemBase createInterfaceItem(IInterfaceItemOwner rcv, String name, int lid, int idx) { + return new LogConjPort(rcv, name, lid, idx); + } + + // incoming messages + public void open(String fileName){ + for (InterfaceItemBase item : getItems()) { + ((LogConjPort)item).open( fileName); + } + } + public void close(){ + for (InterfaceItemBase item : getItems()) { + ((LogConjPort)item).close(); + } + } + private void internalLog(InternalLogData data){ + for (InterfaceItemBase item : getItems()) { + ((LogConjPort)item).internalLog( data); + } + } + } + +} diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpClient.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpClient.java new file mode 100644 index 000000000..212e2e702 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpClient.java @@ -0,0 +1,383 @@ +package room.basic.service.tcp; + +import org.eclipse.etrice.runtime.java.messaging.*; +import org.eclipse.etrice.runtime.java.modelbase.*; +import org.eclipse.etrice.runtime.java.debugging.*; + +import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*; + +import room.basic.service.tcp.PTcpControl.*; +import room.basic.service.tcp.PTcpPayload.*; + +/*--------------------- begin user code ---------------------*/ +import java.net.Socket; +import java.io.*; + +class ClientRxThread extends Thread{ + private Socket sock; + PTcpPayloadPort port; + public ClientRxThread (PTcpPayloadPort port, Socket sock){ + this.sock = sock; + this.port = port; + } + public void run(){ + try{ + InputStream in = sock.getInputStream(); + DTcpPayload d = new DTcpPayload(); + d.setConnectionId(0); + int c; + while ((c=in.read(d.getData()))!=-1){ + d.setLength(c); + port.receive(d); + } + }catch (IOException e){ + System.err.println("ClientRx: " + e.toString()); + } + + } +} + +/*--------------------- end user code ---------------------*/ + + +public class ATcpClient extends ActorClassBase { + + /*--------------------- begin user code ---------------------*/ + Socket socket; + InputStream in; + OutputStream out; + /*--------------------- end user code ---------------------*/ + + //--------------------- ports + protected PTcpControlPort ControlPort = null; + protected PTcpPayloadPort PayloadPort = null; + + //--------------------- saps + + //--------------------- services + + //--------------------- optional actors + + //--------------------- interface item IDs + public static final int IFITEM_ControlPort = 1; + public static final int IFITEM_PayloadPort = 2; + + /*--------------------- attributes ---------------------*/ + public int lastError; + + /*--------------------- operations ---------------------*/ + public void stopUser() { + try{ + if(socket != null){ + socket.close(); + } + }catch(IOException e){ + System.err.println(e.toString());} + } + + + //--------------------- construction + public ATcpClient(IRTObject parent, String name) { + super(parent, name); + setClassName("ATcpClient"); + + // initialize attributes + this.setLastError(0); + + // own ports + ControlPort = new PTcpControlPort(this, "ControlPort", IFITEM_ControlPort); + PayloadPort = new PTcpPayloadPort(this, "PayloadPort", IFITEM_PayloadPort); + + // own saps + + // own service implementations + + // sub actors + + // wiring + + + /* user defined constructor body */ + + } + + /* --------------------- attribute setters and getters */ + public void setLastError(int lastError) { + this.lastError = lastError; + } + public int getLastError() { + return this.lastError; + } + + + //--------------------- port getters + public PTcpControlPort getControlPort (){ + return this.ControlPort; + } + public PTcpPayloadPort getPayloadPort (){ + return this.PayloadPort; + } + + //--------------------- lifecycle functions + public void stop(){ + super.stop(); + } + + public void destroy(){ + /* user defined destructor body */ + DebuggingService.getInstance().addMessageActorDestroy(this); + super.destroy(); + } + + /* state IDs */ + public static final int STATE_closed = 2; + public static final int STATE_opened = 3; + public static final int STATE_error = 4; + public static final int STATE_MAX = 5; + + /* transition chains */ + public static final int CHAIN_TRANS_INITIAL_TO__closed = 1; + public static final int CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort = 2; + public static final int CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort = 3; + public static final int CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3 = 4; + + /* triggers */ + public static final int POLLING = 0; + public static final int TRIG_ControlPort__open = IFITEM_ControlPort + EVT_SHIFT*PTcpControl.IN_open; + public static final int TRIG_ControlPort__close = IFITEM_ControlPort + EVT_SHIFT*PTcpControl.IN_close; + public static final int TRIG_PayloadPort__send = IFITEM_PayloadPort + EVT_SHIFT*PTcpPayload.IN_send; + + // state names + protected static final String stateStrings[] = { + "", + "", + "closed", + "opened", + "error" + }; + + // history + protected int history[] = {NO_STATE, NO_STATE, NO_STATE, NO_STATE, NO_STATE}; + + private void setState(int new_state) { + DebuggingService.getInstance().addActorState(this,stateStrings[new_state]); + this.state = new_state; + } + + /* Entry and Exit Codes */ + + /* Action Codes */ + protected void action_TRANS_INITIAL_TO__closed() { + System.out.println("Client Init !"); + } + protected void action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(InterfaceItemBase ifitem, DTcpControl data) { + lastError=0; + try{ + socket = new Socket(data.IPAddr,data.TcpPort); + (new ClientRxThread(PayloadPort, socket)).start(); + out = socket.getOutputStream(); + }catch(IOException e){ + System.err.println(e.toString()); + lastError=1; + } + } + protected void action_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort(InterfaceItemBase ifitem) { + try{ + if (socket!=null){ + socket.close(); + } + } catch (IOException e){ + System.err.println(e.toString()); + } + } + protected void action_TRANS_tr2_FROM_cp0_TO_opened(InterfaceItemBase ifitem, DTcpControl data) { + ControlPort.established(); + } + protected void action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(InterfaceItemBase ifitem, DTcpControl data) { + ControlPort.error(); + try{ + socket.close(); + } catch(IOException e){ + System.err.println(e.toString()); + } + } + protected void action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(InterfaceItemBase ifitem, DTcpPayload data) { + try{ + out.write(data.getData(),0,data.length); + }catch(IOException e){ + System.err.println(e.toString()); + } + } + + /* State Switch Methods */ + /** + * calls exit codes while exiting from the current state to one of its + * parent states while remembering the history + * @param current__et - the current state + * @param to - the final parent state + */ + private void exitTo(int current__et, int to) { + while (current__et!=to) { + switch (current__et) { + case STATE_closed: + this.history[STATE_TOP] = STATE_closed; + current__et = STATE_TOP; + break; + case STATE_opened: + this.history[STATE_TOP] = STATE_opened; + current__et = STATE_TOP; + break; + case STATE_error: + this.history[STATE_TOP] = STATE_error; + current__et = STATE_TOP; + break; + default: + /* should not occur */ + 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__et - the chain ID + * @param generic_data__et - the generic data pointer + * @return the +/- ID of the final state either with a positive sign, that indicates to execute the state's entry code, or a negative sign vice versa + */ + private int executeTransitionChain(int chain__et, InterfaceItemBase ifitem, Object generic_data__et) { + switch (chain__et) { + case ATcpClient.CHAIN_TRANS_INITIAL_TO__closed: + { + action_TRANS_INITIAL_TO__closed(); + return STATE_closed; + } + case ATcpClient.CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort: + { + DTcpControl data = (DTcpControl) generic_data__et; + action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(ifitem, data); + if (lastError!=0) { + action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(ifitem, data); + return STATE_error;} + else { + action_TRANS_tr2_FROM_cp0_TO_opened(ifitem, data); + return STATE_opened;} + } + case ATcpClient.CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort: + { + action_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort(ifitem); + return STATE_closed; + } + case ATcpClient.CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3: + { + DTcpPayload data = (DTcpPayload) generic_data__et; + action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(ifitem, data); + return STATE_opened; + } + default: + /* should not occur */ + break; + } + return NO_STATE; + } + + /** + * calls entry codes while entering a state's history. The ID of the final leaf state is returned + * @param state__et - the state which is entered + * @return - the ID of the final leaf state + */ + private int enterHistory(int state__et) { + if (state__et >= STATE_MAX) { + state__et = (state__et - STATE_MAX); + } + while (true) { + switch (state__et) { + case STATE_closed: + /* in leaf state: return state id */ + return STATE_closed; + case STATE_opened: + /* in leaf state: return state id */ + return STATE_opened; + case STATE_error: + /* in leaf state: return state id */ + return STATE_error; + case STATE_TOP: + state__et = this.history[STATE_TOP]; + break; + default: + /* should not occur */ + break; + } + } + /* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */ + } + + public void executeInitTransition() { + int chain__et = ATcpClient.CHAIN_TRANS_INITIAL_TO__closed; + int next__et = executeTransitionChain(chain__et, null, null); + next__et = enterHistory(next__et); + setState(next__et); + } + + /* receiveEvent contains the main implementation of the FSM */ + public void receiveEventInternal(InterfaceItemBase ifitem, int localId, int evt, Object generic_data__et) { + int trigger__et = localId + EVT_SHIFT*evt; + int chain__et = NOT_CAUGHT; + int catching_state__et = NO_STATE; + + if (!handleSystemEvent(ifitem, evt, generic_data__et)) { + switch (getState()) { + case STATE_closed: + switch(trigger__et) { + case TRIG_ControlPort__open: + { + chain__et = ATcpClient.CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_opened: + switch(trigger__et) { + case TRIG_ControlPort__close: + { + chain__et = ATcpClient.CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort; + catching_state__et = STATE_TOP; + } + break; + case TRIG_PayloadPort__send: + { + chain__et = ATcpClient.CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_error: + break; + default: + /* should not occur */ + break; + } + } + if (chain__et != NOT_CAUGHT) { + exitTo(getState(), catching_state__et); + { + int next__et = executeTransitionChain(chain__et, ifitem, generic_data__et); + next__et = enterHistory(next__et); + setState(next__et); + } + } + } + public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data__et) { + int localId = (ifitem==null)? 0 : ifitem.getLocalId(); + receiveEventInternal(ifitem, localId, evt, generic_data__et); + } + +}; diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpServer.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpServer.java new file mode 100644 index 000000000..a5f807a7b --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/ATcpServer.java @@ -0,0 +1,421 @@ +package room.basic.service.tcp; + +import org.eclipse.etrice.runtime.java.messaging.*; +import org.eclipse.etrice.runtime.java.modelbase.*; +import org.eclipse.etrice.runtime.java.debugging.*; + +import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*; + +import room.basic.service.tcp.PTcpControl.*; +import room.basic.service.tcp.PTcpPayload.*; + +/*--------------------- begin user code ---------------------*/ +import java.net.ServerSocket; +import java.net.Socket; +import java.io.*; +import java.util.*; + +class ServerRxThread extends Thread{ + private int connectionId; + private Socket sock; + PTcpPayloadPort port; + + public ServerRxThread (int connectionId, PTcpPayloadPort port, Socket sock){ + this.sock = sock; + this.connectionId = connectionId; + this.port = port; + } + + public void run(){ + try{ + InputStream in = sock.getInputStream(); + DTcpPayload d = new DTcpPayload(); + d.setConnectionId(connectionId); + int c; + while ((c=in.read(d.getData()))!=-1){ + d.setLength(c); + port.receive(d); + } + }catch (IOException e){ + System.err.println("ServerRx: " + e.toString()); + } + } +} + +class ServerAcceptThread extends Thread{ + private ServerSocket sock; + private PTcpPayloadPort port; + private ATcpServer parent; + public ServerAcceptThread (PTcpPayloadPort port, ServerSocket sock, ATcpServer parent){ + this.sock = sock; + this.port = port; + this.parent = parent; + } + public void run(){ + int cnt=0; + try{ + while (true){ + Socket s = sock.accept(); + parent.addOutStreamToHashmap(cnt, s.getOutputStream()); + (new ServerRxThread(cnt, port, s)).start(); + cnt++; + } + }catch (IOException e){ + System.err.println("Server Accept: " + e.toString()); + } + } +} + +/*--------------------- end user code ---------------------*/ + + +public class ATcpServer extends ActorClassBase { + + /*--------------------- begin user code ---------------------*/ + ServerSocket socket = null; + InputStream in = null; + OutputStream out = null; + Hashtable outStreams = new Hashtable(); + + synchronized protected void addOutStreamToHashmap(int cnt, OutputStream out){ + outStreams.put(cnt,out); + } + + /*--------------------- end user code ---------------------*/ + + //--------------------- ports + protected PTcpControlPort ControlPort = null; + protected PTcpPayloadPort PayloadPort = null; + + //--------------------- saps + + //--------------------- services + + //--------------------- optional actors + + //--------------------- interface item IDs + public static final int IFITEM_ControlPort = 1; + public static final int IFITEM_PayloadPort = 2; + + /*--------------------- attributes ---------------------*/ + public int lastError; + public int payloadPortReplocation; + + /*--------------------- operations ---------------------*/ + public void stopUser() { + try{ + if(socket != null){ + socket.close(); + } + }catch(IOException e){ + System.err.println(e.toString());} + } + + + //--------------------- construction + public ATcpServer(IRTObject parent, String name) { + super(parent, name); + setClassName("ATcpServer"); + + // initialize attributes + this.setLastError(0); + this.setPayloadPortReplocation(0); + + // own ports + ControlPort = new PTcpControlPort(this, "ControlPort", IFITEM_ControlPort); + PayloadPort = new PTcpPayloadPort(this, "PayloadPort", IFITEM_PayloadPort); + + // own saps + + // own service implementations + + // sub actors + + // wiring + + + /* user defined constructor body */ + + } + + /* --------------------- attribute setters and getters */ + public void setLastError(int lastError) { + this.lastError = lastError; + } + public int getLastError() { + return this.lastError; + } + public void setPayloadPortReplocation(int payloadPortReplocation) { + this.payloadPortReplocation = payloadPortReplocation; + } + public int getPayloadPortReplocation() { + return this.payloadPortReplocation; + } + + + //--------------------- port getters + public PTcpControlPort getControlPort (){ + return this.ControlPort; + } + public PTcpPayloadPort getPayloadPort (){ + return this.PayloadPort; + } + + //--------------------- lifecycle functions + public void stop(){ + super.stop(); + } + + public void destroy(){ + /* user defined destructor body */ + DebuggingService.getInstance().addMessageActorDestroy(this); + super.destroy(); + } + + /* state IDs */ + public static final int STATE_closed = 2; + public static final int STATE_opened = 3; + public static final int STATE_error = 4; + public static final int STATE_MAX = 5; + + /* transition chains */ + public static final int CHAIN_TRANS_INITIAL_TO__closed = 1; + public static final int CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort = 2; + public static final int CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort = 3; + public static final int CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3 = 4; + + /* triggers */ + public static final int POLLING = 0; + public static final int TRIG_ControlPort__open = IFITEM_ControlPort + EVT_SHIFT*PTcpControl.IN_open; + public static final int TRIG_ControlPort__close = IFITEM_ControlPort + EVT_SHIFT*PTcpControl.IN_close; + public static final int TRIG_PayloadPort__send = IFITEM_PayloadPort + EVT_SHIFT*PTcpPayload.IN_send; + + // state names + protected static final String stateStrings[] = { + "", + "", + "closed", + "opened", + "error" + }; + + // history + protected int history[] = {NO_STATE, NO_STATE, NO_STATE, NO_STATE, NO_STATE}; + + private void setState(int new_state) { + DebuggingService.getInstance().addActorState(this,stateStrings[new_state]); + this.state = new_state; + } + + /* Entry and Exit Codes */ + + /* Action Codes */ + protected void action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(InterfaceItemBase ifitem, DTcpControl data) { + lastError=0; + try{ + socket = new ServerSocket(data.TcpPort); + (new ServerAcceptThread(PayloadPort, socket, this)).start(); + }catch(IOException e){ + System.err.println(e.toString()); + lastError=1; + } + } + protected void action_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort(InterfaceItemBase ifitem) { + try{ + if(socket!=null){ + socket.close(); + } + }catch(IOException e){ + System.err.println(e.toString()); + } + } + protected void action_TRANS_tr2_FROM_cp0_TO_opened(InterfaceItemBase ifitem, DTcpControl data) { + ControlPort.established(); + } + protected void action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(InterfaceItemBase ifitem, DTcpControl data) { + ControlPort.error(); + try{ + socket.close(); + } catch(IOException e){ + System.err.println(e.toString()); + } + } + protected void action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(InterfaceItemBase ifitem, DTcpPayload data) { + try{ + outStreams.get(data.getConnectionId()).write(data.getData(),0,data.length); + }catch(IOException e){ + System.err.println(e.toString()); + } + } + + /* State Switch Methods */ + /** + * calls exit codes while exiting from the current state to one of its + * parent states while remembering the history + * @param current__et - the current state + * @param to - the final parent state + */ + private void exitTo(int current__et, int to) { + while (current__et!=to) { + switch (current__et) { + case STATE_closed: + this.history[STATE_TOP] = STATE_closed; + current__et = STATE_TOP; + break; + case STATE_opened: + this.history[STATE_TOP] = STATE_opened; + current__et = STATE_TOP; + break; + case STATE_error: + this.history[STATE_TOP] = STATE_error; + current__et = STATE_TOP; + break; + default: + /* should not occur */ + 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__et - the chain ID + * @param generic_data__et - the generic data pointer + * @return the +/- ID of the final state either with a positive sign, that indicates to execute the state's entry code, or a negative sign vice versa + */ + private int executeTransitionChain(int chain__et, InterfaceItemBase ifitem, Object generic_data__et) { + switch (chain__et) { + case ATcpServer.CHAIN_TRANS_INITIAL_TO__closed: + { + return STATE_closed; + } + case ATcpServer.CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort: + { + DTcpControl data = (DTcpControl) generic_data__et; + action_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort(ifitem, data); + if (lastError!=0) { + action_TRANS_socketError_FROM_cp0_TO_error_COND_socketError(ifitem, data); + return STATE_error;} + else { + action_TRANS_tr2_FROM_cp0_TO_opened(ifitem, data); + return STATE_opened;} + } + case ATcpServer.CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort: + { + action_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort(ifitem); + return STATE_closed; + } + case ATcpServer.CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3: + { + DTcpPayload data = (DTcpPayload) generic_data__et; + action_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3(ifitem, data); + return STATE_opened; + } + default: + /* should not occur */ + break; + } + return NO_STATE; + } + + /** + * calls entry codes while entering a state's history. The ID of the final leaf state is returned + * @param state__et - the state which is entered + * @return - the ID of the final leaf state + */ + private int enterHistory(int state__et) { + if (state__et >= STATE_MAX) { + state__et = (state__et - STATE_MAX); + } + while (true) { + switch (state__et) { + case STATE_closed: + /* in leaf state: return state id */ + return STATE_closed; + case STATE_opened: + /* in leaf state: return state id */ + return STATE_opened; + case STATE_error: + /* in leaf state: return state id */ + return STATE_error; + case STATE_TOP: + state__et = this.history[STATE_TOP]; + break; + default: + /* should not occur */ + break; + } + } + /* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */ + } + + public void executeInitTransition() { + int chain__et = ATcpServer.CHAIN_TRANS_INITIAL_TO__closed; + int next__et = executeTransitionChain(chain__et, null, null); + next__et = enterHistory(next__et); + setState(next__et); + } + + /* receiveEvent contains the main implementation of the FSM */ + public void receiveEventInternal(InterfaceItemBase ifitem, int localId, int evt, Object generic_data__et) { + int trigger__et = localId + EVT_SHIFT*evt; + int chain__et = NOT_CAUGHT; + int catching_state__et = NO_STATE; + + if (!handleSystemEvent(ifitem, evt, generic_data__et)) { + switch (getState()) { + case STATE_closed: + switch(trigger__et) { + case TRIG_ControlPort__open: + { + chain__et = ATcpServer.CHAIN_TRANS_tr0_FROM_closed_TO_cp0_BY_openControlPort; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_opened: + switch(trigger__et) { + case TRIG_ControlPort__close: + { + chain__et = ATcpServer.CHAIN_TRANS_tr1_FROM_opened_TO_closed_BY_closeControlPort; + catching_state__et = STATE_TOP; + } + break; + case TRIG_PayloadPort__send: + { + chain__et = ATcpServer.CHAIN_TRANS_tr3_FROM_opened_TO_opened_BY_sendPayloadPort_tr3; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + case STATE_error: + break; + default: + /* should not occur */ + break; + } + } + if (chain__et != NOT_CAUGHT) { + exitTo(getState(), catching_state__et); + { + int next__et = executeTransitionChain(chain__et, ifitem, generic_data__et); + next__et = enterHistory(next__et); + setState(next__et); + } + } + } + public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data__et) { + int localId = (ifitem==null)? 0 : ifitem.getLocalId(); + receiveEventInternal(ifitem, localId, evt, generic_data__et); + } + +}; diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpControl.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpControl.java new file mode 100644 index 000000000..c8fbef7ed --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpControl.java @@ -0,0 +1,61 @@ +package room.basic.service.tcp; + +import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*; +import java.io.Serializable; + + + + +public class DTcpControl implements Serializable { + + private static final long serialVersionUID = -156692117L; + + + /*--------------------- attributes ---------------------*/ + public String IPAddr; + public int TcpPort; + + /* --------------------- attribute setters and getters */ + public void setIPAddr(String IPAddr) { + this.IPAddr = IPAddr; + } + public String getIPAddr() { + return this.IPAddr; + } + public void setTcpPort(int TcpPort) { + this.TcpPort = TcpPort; + } + public int getTcpPort() { + return this.TcpPort; + } + + /*--------------------- operations ---------------------*/ + + // default constructor + public DTcpControl() { + super(); + + // initialize attributes + this.setIPAddr(""); + + /* user defined constructor body */ + } + + // constructor using fields + public DTcpControl(String IPAddr, int TcpPort) { + super(); + + this.IPAddr = IPAddr; + this.TcpPort = TcpPort; + + /* user defined constructor body */ + } + + // deep copy + public DTcpControl deepCopy() { + DTcpControl copy = new DTcpControl(); + copy.IPAddr = IPAddr; + copy.TcpPort = TcpPort; + return copy; + } +}; diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpPayload.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpPayload.java new file mode 100644 index 000000000..c08b6630f --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/DTcpPayload.java @@ -0,0 +1,78 @@ +package room.basic.service.tcp; + +import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*; +import java.io.Serializable; + + + + +public class DTcpPayload implements Serializable { + + private static final long serialVersionUID = -1894937188L; + + + /*--------------------- attributes ---------------------*/ + public int connectionId; + public int length; + public byte data[]; + + /* --------------------- attribute setters and getters */ + public void setConnectionId(int connectionId) { + this.connectionId = connectionId; + } + public int getConnectionId() { + return this.connectionId; + } + public void setLength(int length) { + this.length = length; + } + public int getLength() { + return this.length; + } + public void setData(byte[] data) { + this.data = data; + } + public byte[] getData() { + return this.data; + } + + /*--------------------- operations ---------------------*/ + + // default constructor + public DTcpPayload() { + super(); + + // initialize attributes + { + byte[] array = new byte[1000]; + for (int i=0;i<1000;i++){ + array[i] = (byte)0; + } + this.setData(array); + } + + /* user defined constructor body */ + } + + // constructor using fields + public DTcpPayload(int connectionId, int length, byte[] data) { + super(); + + this.connectionId = connectionId; + this.length = length; + this.data = data; + + /* user defined constructor body */ + } + + // deep copy + public DTcpPayload deepCopy() { + DTcpPayload copy = new DTcpPayload(); + copy.connectionId = connectionId; + copy.length = length; + for (int i=0;iMSG_MAX+1){ + // id out of range + return "Message ID out of range"; + } + else{ + return messageStrings[msg_id]; + } + } + + + // port class + static public class PTcpControlPort extends PortBase { + // constructors + public PTcpControlPort(IInterfaceItemOwner actor, String name, int localId) { + this(actor, name, localId, 0); + } + public PTcpControlPort(IInterfaceItemOwner actor, String name, int localId, int idx) { + super(actor, name, localId, idx); + DebuggingService.getInstance().addPortInstance(this); + } + + public void destroy() { + DebuggingService.getInstance().removePortInstance(this); + super.destroy(); + } + + @Override + public void receive(Message m) { + if (!(m instanceof EventMessage)) + return; + EventMessage msg = (EventMessage) m; + if (0 < msg.getEvtId() && msg.getEvtId() < MSG_MAX) { + DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]); + if (msg instanceof EventWithDataMessage) + getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData()); + else + getActor().receiveEvent(this, msg.getEvtId(), null); + } + } + + + // sent messages + public void established() { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_established]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_established)); + } + public void error() { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_error]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_error)); + } + } + + // replicated port class + static public class PTcpControlReplPort extends ReplicatedPortBase { + + public PTcpControlReplPort(IInterfaceItemOwner actor, String name, int localId) { + super(actor, name, localId); + } + + public int getReplication() { + return getNInterfaceItems(); + } + + public int getIndexOf(InterfaceItemBase ifitem){ + return ifitem.getIdx(); + } + + public PTcpControlPort get(int idx) { + return (PTcpControlPort) getInterfaceItem(idx); + } + + protected InterfaceItemBase createInterfaceItem(IInterfaceItemOwner rcv, String name, int lid, int idx) { + return new PTcpControlPort(rcv, name, lid, idx); + } + + // outgoing messages + public void established(){ + for (InterfaceItemBase item : getItems()) { + ((PTcpControlPort)item).established(); + } + } + public void error(){ + for (InterfaceItemBase item : getItems()) { + ((PTcpControlPort)item).error(); + } + } + } + + + // port class + static public class PTcpControlConjPort extends PortBase { + // constructors + public PTcpControlConjPort(IInterfaceItemOwner actor, String name, int localId) { + this(actor, name, localId, 0); + } + public PTcpControlConjPort(IInterfaceItemOwner actor, String name, int localId, int idx) { + super(actor, name, localId, idx); + DebuggingService.getInstance().addPortInstance(this); + } + + public void destroy() { + DebuggingService.getInstance().removePortInstance(this); + super.destroy(); + } + + @Override + public void receive(Message m) { + if (!(m instanceof EventMessage)) + return; + EventMessage msg = (EventMessage) m; + if (0 < msg.getEvtId() && msg.getEvtId() < MSG_MAX) { + DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]); + if (msg instanceof EventWithDataMessage) + getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData()); + else + getActor().receiveEvent(this, msg.getEvtId(), null); + } + } + + + // sent messages + public void open(DTcpControl data) { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_open]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_open, data.deepCopy())); + } + public void open(String IPAddr, int TcpPort) { + open(new DTcpControl(IPAddr, TcpPort)); + } + public void close() { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_close]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), IN_close)); + } + } + + // replicated port class + static public class PTcpControlConjReplPort extends ReplicatedPortBase { + + public PTcpControlConjReplPort(IInterfaceItemOwner actor, String name, int localId) { + super(actor, name, localId); + } + + public int getReplication() { + return getNInterfaceItems(); + } + + public int getIndexOf(InterfaceItemBase ifitem){ + return ifitem.getIdx(); + } + + public PTcpControlConjPort get(int idx) { + return (PTcpControlConjPort) getInterfaceItem(idx); + } + + protected InterfaceItemBase createInterfaceItem(IInterfaceItemOwner rcv, String name, int lid, int idx) { + return new PTcpControlConjPort(rcv, name, lid, idx); + } + + // incoming messages + public void open(DTcpControl data){ + for (InterfaceItemBase item : getItems()) { + ((PTcpControlConjPort)item).open( data); + } + } + public void close(){ + for (InterfaceItemBase item : getItems()) { + ((PTcpControlConjPort)item).close(); + } + } + } + +} diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpPayload.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpPayload.java new file mode 100644 index 000000000..824f95db1 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/tcp/PTcpPayload.java @@ -0,0 +1,183 @@ +package room.basic.service.tcp; + +import org.eclipse.etrice.runtime.java.messaging.Message; +import org.eclipse.etrice.runtime.java.modelbase.EventMessage; +import org.eclipse.etrice.runtime.java.modelbase.EventWithDataMessage; +import org.eclipse.etrice.runtime.java.modelbase.IInterfaceItemOwner; +import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase; +import org.eclipse.etrice.runtime.java.modelbase.PortBase; +import org.eclipse.etrice.runtime.java.modelbase.ReplicatedPortBase; +import org.eclipse.etrice.runtime.java.debugging.DebuggingService; +import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*; + + + +public class PTcpPayload { + // message IDs + public static final int MSG_MIN = 0; + public static final int OUT_receive = 1; + public static final int IN_send = 2; + public static final int MSG_MAX = 3; + + + private static String messageStrings[] = {"MIN", "receive", "send","MAX"}; + + public String getMessageString(int msg_id) { + if (msg_idMSG_MAX+1){ + // id out of range + return "Message ID out of range"; + } + else{ + return messageStrings[msg_id]; + } + } + + + // port class + static public class PTcpPayloadPort extends PortBase { + // constructors + public PTcpPayloadPort(IInterfaceItemOwner actor, String name, int localId) { + this(actor, name, localId, 0); + } + public PTcpPayloadPort(IInterfaceItemOwner actor, String name, int localId, int idx) { + super(actor, name, localId, idx); + DebuggingService.getInstance().addPortInstance(this); + } + + public void destroy() { + DebuggingService.getInstance().removePortInstance(this); + super.destroy(); + } + + @Override + public void receive(Message m) { + if (!(m instanceof EventMessage)) + return; + EventMessage msg = (EventMessage) m; + if (0 < msg.getEvtId() && msg.getEvtId() < MSG_MAX) { + DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]); + if (msg instanceof EventWithDataMessage) + getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData()); + else + getActor().receiveEvent(this, msg.getEvtId(), null); + } + } + + + // sent messages + public void receive(DTcpPayload data) { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_receive]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_receive, data.deepCopy())); + } + public void receive(int connectionId, int length, byte[] data) { + receive(new DTcpPayload(connectionId, length, data)); + } + } + + // replicated port class + static public class PTcpPayloadReplPort extends ReplicatedPortBase { + + public PTcpPayloadReplPort(IInterfaceItemOwner actor, String name, int localId) { + super(actor, name, localId); + } + + public int getReplication() { + return getNInterfaceItems(); + } + + public int getIndexOf(InterfaceItemBase ifitem){ + return ifitem.getIdx(); + } + + public PTcpPayloadPort get(int idx) { + return (PTcpPayloadPort) getInterfaceItem(idx); + } + + protected InterfaceItemBase createInterfaceItem(IInterfaceItemOwner rcv, String name, int lid, int idx) { + return new PTcpPayloadPort(rcv, name, lid, idx); + } + + // outgoing messages + public void receive(DTcpPayload data){ + for (InterfaceItemBase item : getItems()) { + ((PTcpPayloadPort)item).receive( data); + } + } + } + + + // port class + static public class PTcpPayloadConjPort extends PortBase { + // constructors + public PTcpPayloadConjPort(IInterfaceItemOwner actor, String name, int localId) { + this(actor, name, localId, 0); + } + public PTcpPayloadConjPort(IInterfaceItemOwner actor, String name, int localId, int idx) { + super(actor, name, localId, idx); + DebuggingService.getInstance().addPortInstance(this); + } + + public void destroy() { + DebuggingService.getInstance().removePortInstance(this); + super.destroy(); + } + + @Override + public void receive(Message m) { + if (!(m instanceof EventMessage)) + return; + EventMessage msg = (EventMessage) m; + if (0 < msg.getEvtId() && msg.getEvtId() < MSG_MAX) { + DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]); + if (msg instanceof EventWithDataMessage) + getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData()); + else + getActor().receiveEvent(this, msg.getEvtId(), null); + } + } + + + // sent messages + public void send(DTcpPayload data) { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_send]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_send, data.deepCopy())); + } + public void send(int connectionId, int length, byte[] data) { + send(new DTcpPayload(connectionId, length, data)); + } + } + + // replicated port class + static public class PTcpPayloadConjReplPort extends ReplicatedPortBase { + + public PTcpPayloadConjReplPort(IInterfaceItemOwner actor, String name, int localId) { + super(actor, name, localId); + } + + public int getReplication() { + return getNInterfaceItems(); + } + + public int getIndexOf(InterfaceItemBase ifitem){ + return ifitem.getIdx(); + } + + public PTcpPayloadConjPort get(int idx) { + return (PTcpPayloadConjPort) getInterfaceItem(idx); + } + + protected InterfaceItemBase createInterfaceItem(IInterfaceItemOwner rcv, String name, int lid, int idx) { + return new PTcpPayloadConjPort(rcv, name, lid, idx); + } + + // incoming messages + public void send(DTcpPayload data){ + for (InterfaceItemBase item : getItems()) { + ((PTcpPayloadConjPort)item).send( data); + } + } + } + +} diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/ATimingService.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/ATimingService.java new file mode 100644 index 000000000..89ca94411 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/ATimingService.java @@ -0,0 +1,289 @@ +package room.basic.service.timing; + +import org.eclipse.etrice.runtime.java.messaging.*; +import org.eclipse.etrice.runtime.java.modelbase.*; +import org.eclipse.etrice.runtime.java.debugging.*; + +import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*; + +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 PTimerReplPort timer = null; + + //--------------------- optional actors + + //--------------------- interface item IDs + public static final int IFITEM_timer = 1; + + /*--------------------- attributes ---------------------*/ + + /*--------------------- operations ---------------------*/ + public void stop() { + System.out.println(toString() + "::stop()"); + timerService.cancel(); + timerService = null; + } + + + //--------------------- construction + public ATimingService(IRTObject parent, String name) { + super(parent, name); + setClassName("ATimingService"); + + // initialize attributes + + // own ports + + // own saps + + // own service implementations + timer = new PTimerReplPort(this, "timer", IFITEM_timer); + + // sub actors + + // wiring + + + /* user defined constructor body */ + + } + + /* --------------------- attribute setters and getters */ + + + //--------------------- port getters + public PTimerReplPort getTimer (){ + return this.timer; + } + + //--------------------- lifecycle functions + + public void destroy(){ + /* user defined destructor body */ + DebuggingService.getInstance().addMessageActorDestroy(this); + super.destroy(); + } + + /* state IDs */ + public static final int STATE_Operational = 2; + public static final int STATE_MAX = 3; + + /* transition chains */ + public static final int CHAIN_TRANS_INITIAL_TO__Operational = 1; + public static final int CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_internalStartTimertimer_tr1 = 2; + public static final int CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_internalStartTimeouttimer_tr3 = 3; + public static final int CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4 = 4; + + /* triggers */ + public static final int POLLING = 0; + public static final int TRIG_timer__kill = IFITEM_timer + EVT_SHIFT*PTimer.IN_kill; + public static final int TRIG_timer__internalStartTimer = IFITEM_timer + EVT_SHIFT*PTimer.IN_internalStartTimer; + public static final int TRIG_timer__internalStartTimeout = IFITEM_timer + EVT_SHIFT*PTimer.IN_internalStartTimeout; + + // state names + protected static final String stateStrings[] = { + "", + "", + "Operational" + }; + + // history + protected int history[] = {NO_STATE, NO_STATE, NO_STATE}; + + private void setState(int new_state) { + DebuggingService.getInstance().addActorState(this,stateStrings[new_state]); + this.state = new_state; + } + + /* 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_tr1_FROM_Operational_TO_Operational_BY_internalStartTimertimer_tr1(InterfaceItemBase ifitem, TimerData td) { + // start timer + taskCount++; + if (taskCount>PURGE_LIMIT) timerService.purge(); + int t = td.getTime(); + timerService.scheduleAtFixedRate(((PTimerPort)ifitem).getTask(),t,t); + } + protected void action_TRANS_tr3_FROM_Operational_TO_Operational_BY_internalStartTimeouttimer_tr3(InterfaceItemBase ifitem, TimerData td) { + // start timeout + taskCount++; + if (taskCount>PURGE_LIMIT) timerService.purge(); + timerService.schedule(((PTimerPort)ifitem).getTask(), ((TimerData)td).getTime()); + } + protected void action_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4(InterfaceItemBase ifitem) { + // nothing to do to kill timer (handled by timer) + } + + /* State Switch Methods */ + /** + * calls exit codes while exiting from the current state to one of its + * parent states while remembering the history + * @param current__et - the current state + * @param to - the final parent state + */ + private void exitTo(int current__et, int to) { + while (current__et!=to) { + switch (current__et) { + case STATE_Operational: + this.history[STATE_TOP] = STATE_Operational; + current__et = STATE_TOP; + break; + default: + /* should not occur */ + 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__et - the chain ID + * @param generic_data__et - the generic data pointer + * @return the +/- ID of the final state either with a positive sign, that indicates to execute the state's entry code, or a negative sign vice versa + */ + private int executeTransitionChain(int chain__et, InterfaceItemBase ifitem, Object generic_data__et) { + switch (chain__et) { + case ATimingService.CHAIN_TRANS_INITIAL_TO__Operational: + { + action_TRANS_INITIAL_TO__Operational(); + return STATE_Operational; + } + case ATimingService.CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_internalStartTimertimer_tr1: + { + TimerData td = (TimerData) generic_data__et; + action_TRANS_tr1_FROM_Operational_TO_Operational_BY_internalStartTimertimer_tr1(ifitem, td); + return STATE_Operational; + } + case ATimingService.CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_internalStartTimeouttimer_tr3: + { + TimerData td = (TimerData) generic_data__et; + action_TRANS_tr3_FROM_Operational_TO_Operational_BY_internalStartTimeouttimer_tr3(ifitem, td); + return STATE_Operational; + } + case ATimingService.CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4: + { + action_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4(ifitem); + return STATE_Operational; + } + default: + /* should not occur */ + break; + } + return NO_STATE; + } + + /** + * calls entry codes while entering a state's history. The ID of the final leaf state is returned + * @param state__et - the state which is entered + * @return - the ID of the final leaf state + */ + private int enterHistory(int state__et) { + boolean skip_entry__et = false; + if (state__et >= STATE_MAX) { + state__et = (state__et - STATE_MAX); + skip_entry__et = true; + } + while (true) { + switch (state__et) { + case STATE_Operational: + if (!(skip_entry__et)) entry_Operational(); + /* in leaf state: return state id */ + return STATE_Operational; + case STATE_TOP: + state__et = this.history[STATE_TOP]; + break; + default: + /* should not occur */ + break; + } + skip_entry__et = false; + } + /* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */ + } + + public void executeInitTransition() { + int chain__et = ATimingService.CHAIN_TRANS_INITIAL_TO__Operational; + int next__et = executeTransitionChain(chain__et, null, null); + next__et = enterHistory(next__et); + setState(next__et); + } + + /* receiveEvent contains the main implementation of the FSM */ + public void receiveEventInternal(InterfaceItemBase ifitem, int localId, int evt, Object generic_data__et) { + int trigger__et = localId + EVT_SHIFT*evt; + int chain__et = NOT_CAUGHT; + int catching_state__et = NO_STATE; + + if (!handleSystemEvent(ifitem, evt, generic_data__et)) { + switch (getState()) { + case STATE_Operational: + switch(trigger__et) { + case TRIG_timer__internalStartTimer: + { + chain__et = ATimingService.CHAIN_TRANS_tr1_FROM_Operational_TO_Operational_BY_internalStartTimertimer_tr1; + catching_state__et = STATE_TOP; + } + break; + case TRIG_timer__internalStartTimeout: + { + chain__et = ATimingService.CHAIN_TRANS_tr3_FROM_Operational_TO_Operational_BY_internalStartTimeouttimer_tr3; + catching_state__et = STATE_TOP; + } + break; + case TRIG_timer__kill: + { + chain__et = ATimingService.CHAIN_TRANS_tr4_FROM_Operational_TO_Operational_BY_killtimer_tr4; + catching_state__et = STATE_TOP; + } + break; + default: + /* should not occur */ + break; + } + break; + default: + /* should not occur */ + break; + } + } + if (chain__et != NOT_CAUGHT) { + exitTo(getState(), catching_state__et); + { + int next__et = executeTransitionChain(chain__et, ifitem, generic_data__et); + next__et = enterHistory(next__et); + setState(next__et); + } + } + } + public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data__et) { + int localId = (ifitem==null)? 0 : ifitem.getLocalId(); + receiveEventInternal(ifitem, localId, evt, generic_data__et); + } + +}; diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/PTimer.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/PTimer.java new file mode 100644 index 000000000..7204d9562 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/PTimer.java @@ -0,0 +1,361 @@ +package room.basic.service.timing; + +import org.eclipse.etrice.runtime.java.messaging.Message; +import org.eclipse.etrice.runtime.java.modelbase.EventMessage; +import org.eclipse.etrice.runtime.java.modelbase.EventWithDataMessage; +import org.eclipse.etrice.runtime.java.modelbase.IInterfaceItemOwner; +import org.eclipse.etrice.runtime.java.modelbase.InterfaceItemBase; +import org.eclipse.etrice.runtime.java.modelbase.PortBase; +import org.eclipse.etrice.runtime.java.modelbase.ReplicatedPortBase; +import org.eclipse.etrice.runtime.java.debugging.DebuggingService; +import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*; + +/*--------------------- begin user code ---------------------*/ +import java.util.TimerTask; +import org.eclipse.etrice.runtime.java.messaging.RTServices; +/*--------------------- end user code ---------------------*/ + + +public class PTimer { + // message IDs + public static final int MSG_MIN = 0; + public static final int OUT_timeout = 1; + public static final int OUT_internalTimer = 2; + public static final int OUT_internalTimeout = 3; + public static final int IN_kill = 4; + public static final int IN_internalStartTimer = 5; + public static final int IN_internalStartTimeout = 6; + public static final int MSG_MAX = 7; + + /*--------------------- begin user code ---------------------*/ + static protected class FireTimeoutTask extends TimerTask { + + private int time; + private int id; + private boolean periodic; + private PTimerPort port; + + public FireTimeoutTask(int time, int id, boolean periodic, PTimerPort port) { + this.time = time; + this.id = id; + this.periodic = periodic; + this.port = port; + } + + @Override + public void run() { + TimerData td = new TimerData(0,id); + if (periodic) + port.internalTimer(td); + else + port.internalTimeout(td); + } + + public int getTime() { + return time; + } + + public int getId() { + return id; + } + } + + /*--------------------- end user code ---------------------*/ + + private static String messageStrings[] = {"MIN", "timeout","internalTimer","internalTimeout", "kill","internalStartTimer","internalStartTimeout","MAX"}; + + public String getMessageString(int msg_id) { + if (msg_idMSG_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 FireTimeoutTask task = null; + public TimerTask getTask() { return task; } + /*--------------------- end user code ---------------------*/ + // constructors + public PTimerPort(IInterfaceItemOwner actor, String name, int localId) { + this(actor, name, localId, 0); + } + public PTimerPort(IInterfaceItemOwner actor, String name, int localId, int idx) { + super(actor, name, localId, idx); + // initialize attributes + DebuggingService.getInstance().addPortInstance(this); + } + + public void destroy() { + DebuggingService.getInstance().removePortInstance(this); + super.destroy(); + } + + @Override + public void receive(Message m) { + if (!(m instanceof EventMessage)) + return; + EventMessage msg = (EventMessage) m; + if (0 < msg.getEvtId() && msg.getEvtId() < MSG_MAX) { + DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]); + switch (msg.getEvtId()) { + case IN_internalStartTimer: + { + EventWithDataMessage dataMsg = (EventWithDataMessage) msg; + TimerData td = (TimerData)dataMsg.getData(); + task = new FireTimeoutTask(td.time, td.id, true, this); + getActor().receiveEvent(this, IN_internalStartTimer, td); + } + break; + case IN_internalStartTimeout: + { + EventWithDataMessage dataMsg = (EventWithDataMessage) msg; + TimerData td = (TimerData)dataMsg.getData(); + task = new FireTimeoutTask(td.time, td.id, false, this); + getActor().receiveEvent(this, IN_internalStartTimeout, td); + } + break; + case IN_kill: + { + //regular PortClass handle kill + EventWithDataMessage dataMsg = (EventWithDataMessage) msg; + TimerData td = (TimerData)dataMsg.getData(); + if (task!=null && task.getId()==td.getId()) { + task.cancel(); + } + } + break; + default: + if (msg instanceof EventWithDataMessage) + getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData()); + else + getActor().receiveEvent(this, msg.getEvtId(), null); + } + } + } + + /*--------------------- attributes ---------------------*/ + /* --------------------- attribute setters and getters */ + /*--------------------- operations ---------------------*/ + + // sent messages + public void timeout() { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_timeout]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventMessage(getPeerAddress(), OUT_timeout)); + } + private void internalTimer(TimerData td) { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_internalTimer]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_internalTimer, td.deepCopy())); + } + public void internalTimer(int time, int id) { + internalTimer(new TimerData(time, id)); + } + private void internalTimeout(TimerData td) { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[OUT_internalTimeout]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), OUT_internalTimeout, td.deepCopy())); + } + public void internalTimeout(int time, int id) { + internalTimeout(new TimerData(time, id)); + } + } + + // replicated port class + static public class PTimerReplPort extends ReplicatedPortBase { + + public PTimerReplPort(IInterfaceItemOwner actor, String name, int localId) { + super(actor, name, localId); + } + + public int getReplication() { + return getNInterfaceItems(); + } + + public int getIndexOf(InterfaceItemBase ifitem){ + return ifitem.getIdx(); + } + + public PTimerPort get(int idx) { + return (PTimerPort) getInterfaceItem(idx); + } + + protected InterfaceItemBase createInterfaceItem(IInterfaceItemOwner rcv, String name, int lid, int idx) { + return new PTimerPort(rcv, name, lid, idx); + } + + // outgoing messages + public void timeout(){ + for (InterfaceItemBase item : getItems()) { + ((PTimerPort)item).timeout(); + } + } + private void internalTimer(TimerData td){ + for (InterfaceItemBase item : getItems()) { + ((PTimerPort)item).internalTimer( td); + } + } + private void internalTimeout(TimerData td){ + for (InterfaceItemBase item : getItems()) { + ((PTimerPort)item).internalTimeout( td); + } + } + } + + + // 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(IInterfaceItemOwner actor, String name, int localId) { + this(actor, name, localId, 0); + } + public PTimerConjPort(IInterfaceItemOwner actor, String name, int localId, int idx) { + super(actor, name, localId, idx); + // initialize attributes + DebuggingService.getInstance().addPortInstance(this); + } + + public void destroy() { + DebuggingService.getInstance().removePortInstance(this); + super.destroy(); + } + + @Override + public void receive(Message m) { + if (!(m instanceof EventMessage)) + return; + EventMessage msg = (EventMessage) m; + if (0 < msg.getEvtId() && msg.getEvtId() < MSG_MAX) { + DebuggingService.getInstance().addMessageAsyncIn(getPeerAddress(), getAddress(), messageStrings[msg.getEvtId()]); + switch (msg.getEvtId()) { + case OUT_internalTimer: + { + //conjugated PortClass handle timer + EventWithDataMessage dataMsg = (EventWithDataMessage) msg; + TimerData td = (TimerData) dataMsg.getData(); + if (active && td.getId()==currentId) { + getActor().receiveEvent(this, OUT_timeout, null); + } + } + break; + case OUT_internalTimeout: + { + //conjugated PortClass handle timeout + EventWithDataMessage dataMsg = (EventWithDataMessage) msg; + TimerData td = (TimerData) dataMsg.getData(); + if (active && td.getId()==currentId) { + active = false; + getActor().receiveEvent(this, OUT_timeout, null); + } + } + break; + default: + if (msg instanceof EventWithDataMessage) + getActor().receiveEvent(this, msg.getEvtId(), ((EventWithDataMessage)msg).getData()); + else + getActor().receiveEvent(this, msg.getEvtId(), null); + } + } + } + + /*--------------------- attributes ---------------------*/ + /* --------------------- attribute setters and getters */ + /*--------------------- operations ---------------------*/ + public void startTimer(int time_ms) { + if (active) return; + active = true; + + if (RTServices.getInstance().getSubSystem().hasGeneratedMSCInstrumentation()) + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_internalStartTimer]); + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalStartTimer, new TimerData(time_ms,++currentId))); + } + public void startTimeout(int time_ms) { + if (active) return; + active = true; + + if (RTServices.getInstance().getSubSystem().hasGeneratedMSCInstrumentation()) + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_internalStartTimeout]); + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalStartTimeout, new TimerData(time_ms,++currentId))); + } + + // sent messages + public void kill() { + //conjugated PortClass kill + if (active) { + active = false; + TimerData td = new TimerData(); + td.setId(currentId); + getPeerMsgReceiver().receive( + new EventWithDataMessage(getPeerAddress(), IN_kill, td)); + } + } + private void internalStartTimer(TimerData td) { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_internalStartTimer]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalStartTimer, td.deepCopy())); + } + public void internalStartTimer(int time, int id) { + internalStartTimer(new TimerData(time, id)); + } + private void internalStartTimeout(TimerData td) { + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_internalStartTimeout]); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalStartTimeout, td.deepCopy())); + } + public void internalStartTimeout(int time, int id) { + internalStartTimeout(new TimerData(time, id)); + } + } + + // replicated port class + static public class PTimerConjReplPort extends ReplicatedPortBase { + + public PTimerConjReplPort(IInterfaceItemOwner actor, String name, int localId) { + super(actor, name, localId); + } + + public int getReplication() { + return getNInterfaceItems(); + } + + public int getIndexOf(InterfaceItemBase ifitem){ + return ifitem.getIdx(); + } + + public PTimerConjPort get(int idx) { + return (PTimerConjPort) getInterfaceItem(idx); + } + + protected InterfaceItemBase createInterfaceItem(IInterfaceItemOwner rcv, String name, int lid, int idx) { + return new PTimerConjPort(rcv, name, lid, idx); + } + + // incoming messages + public void kill(){ + for (InterfaceItemBase item : getItems()) { + ((PTimerConjPort)item).kill(); + } + } + private void internalStartTimer(TimerData td){ + for (InterfaceItemBase item : getItems()) { + ((PTimerConjPort)item).internalStartTimer( td); + } + } + private void internalStartTimeout(TimerData td){ + for (InterfaceItemBase item : getItems()) { + ((PTimerConjPort)item).internalStartTimeout( td); + } + } + } + +} diff --git a/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/TimerData.java b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/TimerData.java new file mode 100644 index 000000000..a6a4dc250 --- /dev/null +++ b/runtime/org.eclipse.etrice.modellib.java/src-gen/room/basic/service/timing/TimerData.java @@ -0,0 +1,60 @@ +package room.basic.service.timing; + +import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*; +import java.io.Serializable; + + + + +public class TimerData implements Serializable { + + private static final long serialVersionUID = 633780889L; + + + /*--------------------- attributes ---------------------*/ + public int time; + public int id; + + /* --------------------- attribute setters and getters */ + public void setTime(int time) { + this.time = time; + } + public int getTime() { + return this.time; + } + public void setId(int id) { + this.id = id; + } + public int getId() { + return this.id; + } + + /*--------------------- operations ---------------------*/ + + // default constructor + public TimerData() { + super(); + + // initialize attributes + + /* user defined constructor body */ + } + + // constructor using fields + public TimerData(int time, int id) { + super(); + + this.time = time; + this.id = id; + + /* user defined constructor body */ + } + + // deep copy + public TimerData deepCopy() { + TimerData copy = new TimerData(); + copy.time = time; + copy.id = id; + return copy; + } +}; -- cgit v1.2.3