Commit 347563bb authored by Jean Meurice's avatar Jean Meurice

README update (+doc)

parent 9ed06263
......@@ -64,3 +64,48 @@ Or, for example with port 5000:
$ docker run --name=rmi-server -p 5000:10101 --rm rmi-server
```
# Dev Documentation
## Emulator configuration
The [emulator_configuration](docs/emulator_configuration.pdf) document shows the configuration possibilities for the autopilot emulators.
## HardwareEmulator JNI interface
The interface of between the RMIModelServer and the HardwareEmulator works with _Java Native Interface (JNI)_. In case of an update
of the interface (file: [src/main/java/simulator/integration/HardwareEmulatorInterface.java](src/main/java/simulator/integration/HardwareEmulatorInterface.java)),
the corresponding C header has to be generated.
Currently, this happens in the [hardware_emulator](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/hardware_emulator) project under the `jni` folder,
where the HardwareEmulatorInterface.java has to be copied. `generate.bat` shows how to update the interface on Windows.
The java file has to be adapted to compile without its dependencies, since the JNI header will only
be generated from compilable java files. Since the actual header file only depends on the `native` functions from the java file, the other dependencies can
be safely deleted. The resulting header file then has to be renamed `emulator_server.h` and placed in the `hardware_emulator/src/emulator` source folder.
The corresponding implementations of the C interface have to be updated in `hardware_emulator/src/emulator/emulator_server.cpp`.
A better approach would be a script in the RMIModelServer project generating the header and copying it to the *hardware_emulator* project.
## New autopilot EMA port types
To communicate with the ports from the autopilot, an _AutopilotAdapter_ encapsulates the EMA model. For new port data types,
the *EMAM2CPP* generator and the *hardware_emulator* have to be updated to handle the new data type.
In the EMAM2CPP project, the `de.monticore.lang.monticar.generator.cpp.viewmodel.AutopilotAdapterDataModel` class is responsible to create the _AutopilotAdapter_.
In its `addInput` and `addOutput` functions, the new function definition and declarations for the data type have to be defined.
In the *hardware_emulator* projects, three places require updates for new data types.
1. The `hardware_emulator/src/emulator/function_values.h / .cpp` files need to updated with the new data type (`enum class VALUE_TYPE`), buffer entry (`struct FunctionValue`) and type name (`FunctionValue::get_type()`).
2. The `call_input()` and `call_output()` functions from the `HardwareEmulator` structure (`hardware_emulator/src/emulator/hardware_emulator.h`) must be updated. They need to know how to pass the arguments to the emulated autopilots.
3. The `Java_simulator_integration_HardwareEmulatorInterface_add_1one_1input()` and `Java_simulator_integration_HardwareEmulatorInterface_query_1outputs()` functions need to know how to pass and read port data to and from Java. (`hardware_emulator/src/emulator/emulator_server.h`)
## Unsupported autopilot functionalities.
The emulator used in this RMIModelServer only implements features encountered in previous autopilots.
New autopilots might trigger new unsupported features:
* Unsupported system calls (enable `debug=unsupported_syscalls` flag for the autopilot emulator). These are operating system functions for which no current emulation is implemented. These have to be added and registered in the `hardware_emulator/src/os_linux/linux_calls.h / .cpp` files for Linux and in the `hardware_emulator/src/os_windows/windows_calls.h / .cpp` files for Windows.
* Unsupported instruction time value. The time table (currently `hardware_emulator/src/timetable/skylake.txt`) describing the number of CPU cycles for every instruction is manually filled. It currently only contains entries (!=0) for encountered instructions. It can be filled with elements from the `hardware_emulator/docs/instruction_time.txt` file (which contains entries from the instruction_tables.pdf file).
To make sure the autopilot emulation is correct, allocate an autopilot emulator with the `test_real` flag. When loading an autopilot with the same OS as the RMIModelServer, the emulator will compare the outputs of the emulated autopilot with the outputs of the actual autopilot program.
\ No newline at end of file
%
% ******************************************************************************
% MontiCAR Modeling Family, www.se-rwth.de
% Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
% All rights reserved.
%
% This project is free software; you can redistribute it and/or
% modify it under the terms of the GNU Lesser General Public
% License as published by the Free Software Foundation; either
% version 3.0 of the License, or (at your option) any later version.
% This library is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
% Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License along with this project. If not, see <http://www.gnu.org/licenses/>.
% *******************************************************************************
\documentclass[a4paper,11pt,twoside,openright]{report}
\usepackage{graphicx}
%\usepackage{ngerman}
\usepackage[utf8x]{inputenc}
\usepackage{fancyvrb}
\usepackage{courier}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{helvet}
\usepackage{pbox}
\usepackage{xcolor}
\usepackage{pdfpages}
\usepackage[strict]{changepage}
\usepackage{calc}
\usepackage{enumitem}
\usepackage{array}
\usepackage{tabularx}
\usepackage{tabu}
\usepackage{multirow}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{datavisualization}
\usepackage[htt]{hyphenat}
\usepackage{float}
\newfloat{example}{tbh}{exa}[chapter]
\floatname{example}{Example}
\usepackage{siunitx}
\usepackage{pgfplots}
%\usepackage{hyperref}
%\usepackage{url}
\pgfplotsset{compat=newest} % Allows to place the legend below plot
\usepgfplotslibrary{units} % Allows to enter the units nicely
%\the\textwidth = 426.79pt
%\the\arrayrulewidth = 0.4pt
\pdfoptionpdfminorversion=6
% \definecolor{se_dark_blue}{RGB}{0,103,166} % powerpoint
\definecolor{se_dark_blue}{RGB}{0,96,178} % website
% \definecolor{se_light_blue}{RGB}{119,158,201} % powerpoint
\definecolor{se_light_blue}{RGB}{129,160,225} % website
\graphicspath{{src/pic/}}
%%\newcommand{\tc}[1]{\Large{\fontfamily{ph v}\selectfont{#1}}}
\newcommand{\tc}[1]{\normalsize{#1}}
\newcommand{\tm}[1]{\scriptsize{#1}}
\newcommand{\ttt}[1]{\scriptsize{\texttt{#1}}}
\newcommand{\tsf}[1]{\scriptsize{\textsf{#1}}}
\newcommand{\tit}[1]{\scriptsize{\textit{#1}}}
%% setup listings
\usepackage{listings}
\lstset{
language=C++,
frame=none,
basicstyle=\small\ttfamily,
}
\lstset{
language=Java,
frame=none,
basicstyle=\small\ttfamily,
}
\lstdefinestyle{MontiArcStyle}{
numbers=left,
numberstyle=\tiny,
numbersep=5pt,
xleftmargin=11pt,
xrightmargin=4pt,
frame=single,
aboveskip=0pt,
belowskip=-6pt,
sensitive=true,
float=!t,
breaklines=false,
captionpos=b,
tabsize=2,
showstringspaces=false,
basicstyle=\small\ttfamily,
morecomment=[l]{//},
morecomment=[s][\itshape]{/**}{*/}
}
%% defines the listings laguage named 'MontiArc' derived from the language 'Java'
%% adding the below listed keywords. See
%% ftp://ftp.tex.ac.uk/tex-archive/macros/latex/contrib/listings/listings.pdf
%% for listings documentation
\lstdefinelanguage{MontiArc}[]{Java}{
morekeywords={component, port, in, out, inv, package, import, connect, autoconnect}
}
% Seite einrichten
\setlength{\voffset}{-1in}
\setlength{\hoffset}{-1in}
\setlength{\topmargin}{2.5cm}
\setlength{\headheight}{0cm}
\setlength{\headsep}{0cm}
\setlength{\oddsidemargin}{3,3cm} % innen ein wenig mehr Rand für die Klebebindung
\setlength{\evensidemargin}{2,7cm} % dafür außen ein wenig weniger
\setlength{\textwidth}{15cm}
\setlength{\textheight}{23,5cm}
\setlength{\parindent}{0cm}
\newcommand{\emptyLine}{{\LARGE ~\\}}
\begin{document}
\setcounter{page}{1}
\pagenumbering{arabic}
\section{Configuration}
\label{emuconfig}
The HardwareEmulator and the EmulatorManager support a simple fail-safe way of configuring them and making queries to them. A message is made of a String where each line (separated by a newline character) is a name followed by optional parameters.
The syntax is whitespace insensitive and as follows:
\begin{verbatim}
name = param1, param2, param...
or
name
\end{verbatim}
Whitespace is optional, and the only separating characters are the equal sign ($=$), the comma (,) and the newline character (\texttt{\textbackslash n}).
\subsection{Configuration}
The current settings supported when allocating an emulator are shown in Table~\ref{tab:emuconfig}.
\begin{table}[!htb]
\begin{tabularx}{\textwidth}{ | X |}
\hline
\texttt{autopilot=name} \\
Name of the autopilot program file, without extension.\\ \hline
\texttt{os=name} \\
Name of the operating system used. Currently \texttt{linux} or \texttt{windows}. This implies the extension of the autopilot file searched. If the os command is not given, the Emulator will search for any autopilot with the given name in the search folder. \\ \hline
\texttt{debug=flag1,flag2,\dots} \\
Enable the debugging outputs for the specified flags, where the flags are any of \texttt{mem}, \texttt{regs}, \texttt{reg\_update}, \texttt{syscalls}, \texttt{unsupported\_syscalls}, \texttt{code} or \texttt{call}. \\\hline
\texttt{cpu\_frequency=value} \\
The CPU frequency in Hertz used to evaluate the computation time. \\\hline
\texttt{memory\_frequency=value} \\
The RAM frequency in Hertz used to evaluate the computation time. \\\hline
\texttt{cache\_name=size,read\_ticks,write\_ticks} \\
Where \texttt{name} is \texttt{IL1}, \texttt{DL1}, \texttt{L2} or \texttt{L3}.
This setting enables and sets the parameters of the named cache layer. Set \texttt{size} to 0 to disable this cache level. The ticks refer to the CPU ticks.\\\hline
\texttt{no\_time} \\
Disables the delaying of the autopilot in the simulation. \\\hline
\texttt{test\_real} \\
If the RMIModelServer and the autopilot are of the same operating system type, this flag makes the emulator load the autopilot directly as a library (not emulated) and uses its outputs to validate those of the emulated instance. \\
\texttt{export} \\
Enables the \texttt{HardwareEmulator} to export the deviation from the planned trajectory and the evaluated execution time of the autopilot. Data is currently exported for the first 60 seconds of the simulation. The output files are \texttt{autopilot\_dist.txt} and \texttt{autopilot\_time.txt}.
\\\hline
\end{tabularx}
\caption{HardwareEmulator Configuration}
\label{tab:emuconfig}
\end{table}
The \texttt{EmulatorManager} itself also supports a config string on initialization. Table~\ref{tab:managerconfig} shows the supported config.
\begin{table}[!htb]
\begin{tabularx}{\textwidth}{ | X |}
\hline
\texttt{autopilots\_folder=folder} \\
Sets the folder in which to look for autopilot programs.\\ \hline
\end{tabularx}
\caption{EmulatorManager Configuration}
\label{tab:managerconfig}
\end{table}
\subsection{Queries}
The query system uses the same presented syntax, but also sends a response for every query, using the same syntax.
Queries supported by the \texttt{EmulatorManager} are shown in Table~\ref{tab:managerqueries}.
\begin{table}[!htb]
\begin{tabularx}{\textwidth}{ >{\em}l | X |}
\cline{2-2}
Query & \texttt{get\_error\_msg} \\
Response & \texttt{error\_msg=msg} \\
& Returns the last error message that occurred while allocating an autopilot emulator. \\ \cline{2-2}
Query & \texttt{get\_available\_autopilots} \\
Response & \texttt{available\_autopilots=autopilot1, autopilot2, \dots} \\
& Returns the list of autopilot files available in the autopilot folder. \\ \cline{2-2}
Query & \texttt{get\_available\_threads} \\
Response & \texttt{available\_threads=thread\_count} \\
& Returns the number of concurrent threads the machine running the RMIModelServer supports.\\ \cline{2-2}
Query & \texttt{get\_autopilots\_folder} \\
Response & \texttt{autopilots\_folder=folder} \\
& Returns the current autopilots folder.\\ \cline{2-2}
\end{tabularx}
\caption{EmulatorManager queries.}
\label{tab:managerqueries}
\end{table}
Queries supported by querying a specific emulator are shown in Table~\ref{tab:emuqueries}.
\begin{table}[!htb]
\begin{tabularx}{\textwidth}{ >{\em}l | X |}
\cline{2-2}
Query & \texttt{get\_avg\_runtime} \\
Response & \texttt{avg\_runtime=time} \\
& Returns the mean average time of autopilot execution.\\ \cline{2-2}
Query & \texttt{is\_computing} \\
Response & \texttt{computing=1 or 0} \\
& Returns 1 if the computer is considered to be computing in simulation time.\\ \cline{2-2}
Query & \texttt{get\_computer\_time} \\
Response & \texttt{computer\_time=time} \\
& Returns the time counter of the computer, in microseconds.\\ \cline{2-2}
\end{tabularx}
\caption{HardwareEmulator queries.}
\label{tab:emuqueries}
\end{table}
\end{document}
@REM
@REM
@REM ******************************************************************************
@REM MontiCAR Modeling Family, www.se-rwth.de
@REM Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
@REM All rights reserved.
@REM
@REM This project is free software; you can redistribute it and/or
@REM modify it under the terms of the GNU Lesser General Public
@REM License as published by the Free Software Foundation; either
@REM version 3.0 of the License, or (at your option) any later version.
@REM This library is distributed in the hope that it will be useful,
@REM but WITHOUT ANY WARRANTY; without even the implied warranty of
@REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@REM Lesser General Public License for more details.
@REM
@REM You should have received a copy of the GNU Lesser General Public
@REM License along with this project. If not, see <http://www.gnu.org/licenses/>.
@REM *******************************************************************************
@REM
@echo off
set GENDIR=target\
set MAINNAME=emulator_configuration
set MAINTEX=%MAINNAME%.tex
set TARGET=%GENDIR%%MAINNAME%.pdf
mkdir %GENDIR%
@echo ------------initial pdf-latex run
pdflatex -output-directory=%GENDIR% %MAINTEX%
@echo ------------Make index
IF EXIST "%GENDIR%%MAINNAME%.idx" makeindex %GENDIR%%MAINNAME%.idx
@echo ------------2nd pdf-latex run
pdflatex -output-directory=%GENDIR% %MAINTEX%
@echo ------------3rd pdf-latex run
pdflatex -output-directory=%GENDIR% %MAINTEX%
......@@ -19,9 +19,9 @@
@REM *******************************************************************************
@REM
pushd ..
pushd %~dp0..
call mvn clean install -s "settings.xml"
cd target
ren "rmi-model-server-1.1.0-jar-with-dependencies.jar" "rmi-model-server.jar"
ren "rmi-model-server-*-jar-with-dependencies.jar" "rmi-model-server.jar"
copy "rmi-model-server.jar" "..\install"
popd
\ No newline at end of file
#!/bin/bash
#
#
# ******************************************************************************
......@@ -19,7 +20,9 @@
# *******************************************************************************
#
pushd ..
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
pushd DIR/..
mvn clean install -s "settings.xml"
cd target
cp "rmi-model-server-*-jar-with-dependencies.jar" "../install/rmi-model-server.jar"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment