Skip to main content
summaryrefslogtreecommitdiffstats
blob: d244c243cbf4ffde5a88e9b6fa55d770621fa698 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
\section{HelloWorld for Java}

In this tutorial you will get a first look at a very simple \eTrice{} model. The goal is to learn the work flow of \eTrice{} and to understand a few basic features of ROOM.

\textbf{Preconditions}:
\begin{itemize}
	\item Installed JDT Eclipse
	\item Activated \emph{Build Automatically} option in Eclipse: \emph{Project -> Build Automatically}
	\item Recommended: Activate automatic resource refresh in Eclipse: \emph{Window -> Preferences -> General -> Workspace}
	\begin{itemize}
		\item \emph{Refresh using native hooks or polling}
		\item \emph{Refresh on access}
	\end{itemize}
	\item Optional: Install \href{http://trace2uml.stage.tigris.org/}{Trace2UML}, a Open Source MSC viewer
	\begin{itemize}
		\item \href{http://trace2uml.tigris.org/servlets/ProjectDocumentList?folderID=6208}{Windows download site}
		\item \href{http://apt.astade.de/}{Linux package}
	\end{itemize}
	
\end{itemize}

\subsection{Create template project}
After installation of \eTrice in Eclipse, we can use the wizard to create the template project, which is good starting point for new ROOM applications. Select the menu \emph{File -> New -> Other} (Ctrl+N) and choose \emph{eTrice Java Template Project}. Name the project \emph{TemplateModel} and press \emph{Next}. On the next page select \emph{use Eclipse JDT build} and press \emph{Finish}.

\includegraphics[width=.5\textwidth]{images/014-wizard.png}

This will add three projects into your workspace, the library projects \emph{runtime.java} and \emph{modellib.java} and our application project \emph{TemplateModel}. Now open the \emph{TemplateModel.room} in the model folder of our project.

\includegraphics[width=\textwidth]{images/014-after-wizard.png}

The model contains an ActorClass \emph{TopActor}, which is currently the only active actor. TopActor has a state machine that is intended to output a simple HelloWorld statement. To inspect its behavior graphically, we can open the behavior diagram by right click on \emph{Outline View -> TopActor -> Edit Behavior}. Alternatively we can place the cursor within the textual notation and press Alt+B.

\includegraphics[width=\textwidth]{images/014-open-hello-fsm.png}

The state machine has an initial transition that leads to \emph{helloState}. The state defines an entry code, which is executed during the transition. We can view the details by hovering over the state and edit the code with a double-click or right click and \emph{Edit State}.

\includegraphics[width=\textwidth]{images/014-hello-fsm.png}

\subsection{Generate and run application}

Now we are ready to translate the model into an executable application. The first step is to generate source files from the model. Therefore we run the eTrice model generator by right click on file \begin{quote}
	\emph{generate\_TemplateModel.launch -> Run As -> generate\_TemplateModel}.
\end{quote}
After that we can build and run the application by right click on file
\begin{quote}
	\emph{run\_TemplateModel.launch -> Run As -> run\_TemplateModel}
\end{quote}.
This will trigger the build process, carried out by JDT Eclipse and then subsequently start our application.

\begin{tabular}{cc}
	\includegraphics[width=.45\textwidth]{images/014-generate.png} & 
	\includegraphics[width=.45\textwidth]{images/014-build_run.png} \\
	1. Invoke generator & 2. Build and run application
\end{tabular}

The output of our application is logged in the Console View and it shows the "Hello World". By typing "quit", as prompt, and pressing enter, the application terminates regularly.

\includegraphics[width=\textwidth]{images/014-quit-hello-msc.png}

\input{015.2-hello-world-open-msc}

\includegraphics[width=0.6\textwidth]{images/014-hello-msc.png}

Back to the top