Commit 743eee97 authored by Evgeny Kusmenko's avatar Evgeny Kusmenko

Merge branch 'software-simulator' into 'master'

Software simulator

See merge request !12
parents 97374b5a 4195ee41
Pipeline #213688 passed with stages
in 4 minutes and 59 seconds
......@@ -28,8 +28,6 @@ masterJobLinux:
- mvn package sonar:sonar -s settings.xml
only:
- master
tags:
- se
artifacts:
paths:
- install/rmi-model-server.jar
......@@ -61,8 +59,6 @@ BranchJobLinux:
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml
except:
- master
tags:
- se
masterJobDocker:
image: docker:dind
......
......@@ -3,7 +3,7 @@
# RMIModelServer
The RMIModelServer is used to remotely allocate a series of [_HardwareEmulators_](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/hardware_emulator), which can load different autopilots generated with [_EMAM2CPP_](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/generators/EMAM2Cpp).
The RMIModelServer is used to remotely allocate a series of [_SoftwareSimulators_](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/hardware_emulator), which can load different softwares generated with [_EMAM2CPP_](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/generators/EMAM2Cpp).
## Requirements
......@@ -25,20 +25,17 @@ __NOTE:__ _MontiSim_ is the directory, in which MontiSim-belonging projects shou
To just compile the `jar`, use
mvn clean install -s settings.xml
To compile and copy the server to the local `install` folder, use the `scripts/compile_install` scripts.
__NOTE:__ New versions of the _HardwareEmulator_ must be copied into the `install` folder. This folder is used in a maven test to verify RMIModelServer/HardwareEmulator integration.
This will export the resulting jar in the `install` folder
## Running the RMI server
The `install` folder contains a sample setup for running the RMIModelServer.
The RMIModelServer jar must be in the same directory as the [HardwareEmulator](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/hardware_emulator) library it will use (_HardwareEmulator.lib_ or _HardwareEmulator.so_ for Windows or Linux).
The `run` script starts an instance of the RMIModelServer. It uses the `config` script to provide a way of changing the port or the autopilot folder used. The port defaults to 10101, and can be changed to start multiple RMIModelServers.
The `install` folder contains an exemplary setup to start the server.
The `run` script starts an instance of the RMIModelServer. It uses the `config` script to provide a way of changing the port or the softwares folder used. The port defaults to 10101, and can be changed to start multiple RMIModelServers.
The autopilot folder is a folder path (absolute or relative to the RMIModelServer) in which the RMI server will look for autopilot programs.
The softwares folder is a folder path (absolute or relative to the RMIModelServer) in which the RMI server will look for programs to run inside a SoftwareSimulator.
These programs are the EmbeddedMontiArc models compiled with EMAM2CPP (or a project using EMAM2CPP such as [EMAM-showcase](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/simulators/EMAM-showcase) or [EMAStudio](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/utilities/EMAStudioBuilder)).
The `autopilots` folder in the `install` folder contains the sample autopilot from `EMAM-Showcase`.
The `softwares` folder in the `install` folder contains the sample autopilot from `EMAM-Showcase`.
## Docker
......@@ -63,49 +60,3 @@ 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.
......@@ -17,7 +17,6 @@ RUN apt-get update && \
COPY rmi-model-server.jar ./rmi-model-server.jar
COPY ./autopilots/ ./autopilots/
COPY ./softwares/ ./softwares/
CMD exec bash -c "source ~/.bashrc && java -jar rmi-model-server.jar -Djava.rmi.server.hostname=localhost port=10101 autopilots_folder=autopilots no-zookeeper \
no_time os=windows"
CMD exec bash -c "source ~/.bashrc && java -jar -Djava.rmi.server.hostname=localhost rmi-model-server.jar port=10101 softwares_folder=softwares no-zookeeper"
......@@ -8,6 +8,6 @@
cp ../install/rmi-model-server.jar ./
cp -r ../install/autopilots ./autopilots
cp -r ../install/softwares ./softwares
docker build -t rmi-server .
\relax
\newlabel{emuconfig}{{}{1}}
\newlabel{tab:emuconfig}{{}{1}}
\newlabel{tab:managerconfig}{{}{1}}
\newlabel{tab:managerqueries}{{}{1}}
\newlabel{tab:emuqueries}{{}{1}}
# Fdb version 3
["pdflatex"] 1568890713 "b:/montisim-setup/repos/RMIModelServer/docs/latex/emulator_configuration.tex" "b:/montisim-setup/repos/RMIModelServer/docs/latex/emulator_configuration.pdf" "emulator_configuration" 1568890713
"C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmbx10.tfm" 1136768653 1328 c834bbb027764024c09d3d2bf908b5f0 ""
"C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmitt10.tfm" 1136768653 768 2297ad2ac26f37e67f756dad27c77d68 ""
"C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmti10.tfm" 1136768653 1480 aa8e34af0eb6a2941b776984cf1dfdc4 ""
"C:/Program Files/MiKTeX 2.9/fonts/tfm/public/cm/cmtt10.tfm" 1136768653 768 1321e9409b4137d6fb428ac9dc956269 ""
"C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmbx10.pfb" 1247596666 34811 78b52f49e893bcba91bd7581cdc144c0 ""
"C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmitt10.pfb" 1247596666 26057 4749ebe351ca6b60601cf0ab49d1bf5d ""
"C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmmi10.pfb" 1247596667 36299 5f9df58c2139e7edcf37c8fca4bd384d ""
"C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmmi7.pfb" 1247596667 36281 c355509802a035cadc5f15869451dcee ""
"C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr10.pfb" 1247596667 35752 024fb6c41858982481f6968b5fc26508 ""
"C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmsy10.pfb" 1247596667 32569 5e5ddc8df908dea60932f3c484a54c0d ""
"C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmtt10.pfb" 1247596667 31099 342ef5a582aacbd3346f3cf4579679fa ""
"C:/Users/Jean/AppData/Local/MiKTeX/2.9/miktex/data/le/pdftex/pdflatex.fmt" 1562925836 4235381 0468f7ea654e25346755a1cc34bf5b43 ""
"C:/Users/Jean/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map" 1562925912 80453 73224248f0a73acd005b5611945eaaa6 ""
"b:/montisim-setup/repos/RMIModelServer/docs/latex/emulator_configuration.aux" 1568890713 9 a94a2480d3289e625eea47cd1b285758 ""
"b:/montisim-setup/repos/RMIModelServer/docs/latex/emulator_configuration.tex" 1568890711 8550 c3bfea48587967d0f21fa2e13e69064c ""
"emulator_configuration.aux" 0 -1 0 "pdflatex"
"emulator_configuration.tex" 1568890711 8550 c3bfea48587967d0f21fa2e13e69064c ""
(generated)
"emulator_configuration.aux"
"emulator_configuration.pdf"
"b:/montisim-setup/repos/RMIModelServer/docs/latex/emulator_configuration.log"
"emulator_configuration.log"
"b:/montisim-setup/repos/RMIModelServer/docs/latex/emulator_configuration.pdf"
PWD b:\montisim-setup\repos\RMIModelServer\docs\latex
INPUT C:\Users\Jean\AppData\Local\MiKTeX\2.9\miktex\data\le\pdftex\pdflatex.fmt
INPUT b:\montisim-setup\repos\RMIModelServer\docs\latex\emulator_configuration.tex
OUTPUT b:\montisim-setup\repos\RMIModelServer\docs\latex\emulator_configuration.log
INPUT C:\Program Files\MiKTeX 2.9\fonts\tfm\public\cm\cmtt10.tfm
INPUT C:\Program Files\MiKTeX 2.9\fonts\tfm\public\cm\cmitt10.tfm
INPUT b:\montisim-setup\repos\RMIModelServer\docs\latex\emulator_configuration.aux
INPUT b:\montisim-setup\repos\RMIModelServer\docs\latex\emulator_configuration.aux
OUTPUT b:\montisim-setup\repos\RMIModelServer\docs\latex\emulator_configuration.aux
INPUT C:\Program Files\MiKTeX 2.9\fonts\tfm\public\cm\cmbx10.tfm
INPUT C:\Program Files\MiKTeX 2.9\fonts\tfm\public\cm\cmti10.tfm
OUTPUT b:\montisim-setup\repos\RMIModelServer\docs\latex\emulator_configuration.pdf
INPUT C:\Users\Jean\AppData\Local\MiKTeX\2.9\pdftex\config\pdftex.map
INPUT b:\montisim-setup\repos\RMIModelServer\docs\latex\emulator_configuration.aux
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmbx10.pfb
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmbx10.pfb
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmitt10.pfb
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmitt10.pfb
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmmi10.pfb
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmmi10.pfb
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmmi7.pfb
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmmi7.pfb
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmr10.pfb
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmr10.pfb
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmsy10.pfb
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmsy10.pfb
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmtt10.pfb
INPUT C:\Program Files\MiKTeX 2.9\fonts\type1\public\amsfonts\cm\cmtt10.pfb
This diff is collapsed.
% (c) https://github.com/MontiCore/monticore
%
% The license generally applicable for this project
% can be found under https://github.com/MontiCore/monticore.
\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 (c) https://github.com/MontiCore/monticore
@REM
@REM The license generally applicable for this project
@REM can be found under https://github.com/MontiCore/monticore.
@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%
......@@ -7,7 +7,7 @@
@REM Please replace this with the path to the Autopilot(s)
set AUTOPILOT_FOLDER=autopilots
set SOFTWARES_FOLDER=softwares
@REM Change the port if you need to
set PORT=10101
......@@ -8,7 +8,7 @@
# Please replace this with the path to the Autopilot(s)
AUTOPILOT_FOLDER=autopilots
SOFTWARES_FOLDER=softwares
# Change the port if you need to
PORT=10101
......@@ -9,7 +9,7 @@
@echo off
call config.bat
echo Starting RMIModelServer on port %PORT% with Autopilot folder: %AUTOPILOT_FOLDER%
echo Starting RMIModelServer on port %PORT% with with softwares folder: %SOFTWARES_FOLDER%
@REM java "-Djava.rmi.server.codebase=file:rmi-model-server.jar" "-Djava.rmi.server.hostname=localhost" -cp rmi-model-server.jar rwth.rmi.model.server.RMIServer %PORT% %AUTOPILOT_FOLDER% --no-zookeeper %*
java -jar rmi-model-server.jar port=%PORT% autopilots_folder=%AUTOPILOT_FOLDER% no-zookeeper default_config %*
java -jar rmi-model-server.jar port=%PORT% softwares_folder=%SOFTWARES_FOLDER% no-zookeeper
pause
......@@ -9,6 +9,5 @@
source ./config.sh
echo "Starting RMIModelServer on port $PORT with Autopilot folder: $AUTOPILOT_FOLDER"
# java "-Djava.rmi.server.codebase=file:rmi-model-server.jar" "-Djava.rmi.server.hostname=localhost" -cp rmi-model-server.jar rwth.rmi.model.server.RMIServer $PORT $AUTOPILOT_FOLDER --no-zookeeper os=linux no_time
java "-Djava.rmi.server.hostname=localhost" -jar rmi-model-server.jar port=$PORT autopilots_folder=$AUTOPILOT_FOLDER no-zookeeper default_config os=linux no_time
\ No newline at end of file
echo "Starting RMIModelServer on port $PORT with Autopilot folder: $SOFTWARES_FOLDER"
java "-Djava.rmi.server.hostname=localhost" -jar rmi-model-server.jar port=$PORT softwares_folder=$SOFTWARES_FOLDER no-zookeeper
\ No newline at end of file
......@@ -9,6 +9,6 @@
@echo off
call config.bat
echo Starting RMIModelServer on port %PORT% with Autopilot folder: %AUTOPILOT_FOLDER%
java "-Djava.rmi.server.codebase=file:rmi-model-server.jar" "-Djava.rmi.server.useLocalHostname" -cp rmi-model-server.jar rwth.rmi.model.server.RMIServer %PORT% %AUTOPILOT_FOLDER% os=windows no_time %*
echo Starting RMIModelServer on port %PORT% with softwares folder: %SOFTWARES_FOLDER%
java "-Djava.rmi.server.codebase=file:rmi-model-server.jar" "-Djava.rmi.server.useLocalHostname" -cp rmi-model-server.jar rwth.rmi.model.server.RMIServer port=%PORT% softwares_folder=%SOFTWARES_FOLDER%
pause
......@@ -7,15 +7,7 @@
#
if [ -z "$1" ]; then
PORT=10101
else
PORT="$1"
fi
source ./config.sh
AUTOPILOT_FOLDER=autopilots
java -cp rmi-model-server.jar\
-Djava.rmi.server.codebase=file:rmi-model-server.jar\
-Djava.rmi.server.useLocalHostname rwth.rmi.model.server.RMIServer\
$PORT $AUTOPILOT_FOLDER os=linux no_time
echo "Starting RMIModelServer on port $PORT with Autopilot folder: $SOFTWARES_FOLDER"
java "-Djava.rmi.server.hostname=localhost" -jar rmi-model-server.jar port=$PORT softwares_folder=$SOFTWARES_FOLDER
......@@ -11,7 +11,7 @@
<groupId>montisim</groupId>
<artifactId>rmi-model-server</artifactId>
<version>1.1.5</version>
<version>1.1.6</version>
<packaging>jar</packaging>
<name>rmi-model-server</name>
......@@ -19,7 +19,7 @@
<properties>
<!-- USE THESE TO SET THE VERSIONS OF THE DEPENDENCIES FOR ALL THE SUB-PROJECTS -->
<commons.version>1.0.11</commons.version>
<hardware_emulator.version>1.0.2</hardware_emulator.version>
<hardware_emulator.version>1.0.4</hardware_emulator.version>
<!-- .. SE-Libraries .................................................. -->
<monticore.version>4.5.4.08.11.2017</monticore.version>
......
......@@ -7,7 +7,9 @@
package de.rwth.monticore.EmbeddedMontiArc.simulators.rmimodelserver;
import org.I0Itec.zkclient.ZkClient;
import de.rwth.monticore.EmbeddedMontiArc.simulators.hardware_emulator.HardwareEmulatorInterface;
import de.rwth.monticore.EmbeddedMontiArc.simulators.hardware_emulator.interfaces.SoftwareSimulatorManager;
import de.rwth.monticore.EmbeddedMontiArc.simulators.hardware_emulator.RemoteSoftwareSimulatorManager;
import de.rwth.monticore.EmbeddedMontiArc.simulators.hardware_emulator.config.SoftwareSimulatorConfig;
import java.io.File;
import java.io.IOException;
......@@ -20,36 +22,27 @@ import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import java.util.Arrays;
import java.util.HashMap;
public class RMIServer {
public final static String MODEL_MANAGER = "ModelManager";
public final static String SOFTWARE_SIMULATOR_MANAGER = "SoftwareSimulatorManager";
public final static String ZK_NODE = "/rmi-servers/all";
public static void parse_args(String[] args, HashMap<String, String> options){
String default_config = "";
boolean add_to_default_config = false;
for (String arg : args){
if (add_to_default_config){
default_config += arg + "\n";
} else {
String sub_args[] = arg.split("=");
if (arg.equals("no-zookeeper")){
options.put("no-zookeeper", "true");
} else if (arg.equals("default_config")){
add_to_default_config = true;
} else if (sub_args.length > 1) {
if (sub_args[0].equals("port")){
options.put("port", sub_args[1]);
} else if (sub_args[0].equals("autopilots_folder")){
options.put("autopilots_folder", sub_args[1]);
}
String sub_args[] = arg.split("=");
if (arg.equals("no-zookeeper")){
options.put("no-zookeeper", "true");
} else if (sub_args.length > 1) {
if (sub_args[0].equals("port")){
options.put("port", sub_args[1]);
} else if (sub_args[0].equals("softwares_folder")){
options.put("softwares_folder", sub_args[1]);
}
}
}
options.put("default_config", default_config);
}
......@@ -76,32 +69,30 @@ public class RMIServer {
if (!use_zookeeper)
System.out.println("Not using Zookeeper.");
String default_config = options.get("default_config");
String emu_config = "";
SoftwareSimulatorConfig manager_config = new SoftwareSimulatorConfig();
try {// Load AutopilotAdapter.dll from libraryPath
emu_config += "autopilots_folder=" + autopilot_folder.getCanonicalPath() + "\n";
manager_config.set_softwares_folder(autopilot_folder.getCanonicalPath());
} catch (IOException e) {
e.printStackTrace();
System.out.println("Could not resolve the Hardware Emulator autopilots path.");
System.out.println("Could not resolve the SoftwareSimulator's software folder path. ("+autopilot_folder+")");
}
HardwareEmulatorInterface manager = null;
int port_id = Integer.valueOf(port);
SoftwareSimulatorManager manager = null;
try {
manager = new HardwareEmulatorInterface(emu_config, default_config);
manager = new RemoteSoftwareSimulatorManager(manager_config , port_id);
} catch (Exception e) {
e.printStackTrace();
System.exit(-2);
}
String host = InetAddress.getLocalHost().getHostName();
int port_id = Integer.valueOf(port);
try {
Registry registry = LocateRegistry.createRegistry(port_id);
System.out.println("RMIRegistry serving on port: " + port);
//bind the ModelManager to a stub, representing the remote object
registry.bind(MODEL_MANAGER, UnicastRemoteObject.exportObject(manager, port_id));
registry.bind(SOFTWARE_SIMULATOR_MANAGER, UnicastRemoteObject.exportObject(manager, port_id));
if (use_zookeeper){
String zoo_servers;
......
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
package de.rwth.monticore.EmbeddedMontiArc.simulators.rmimodelserver;
import de.rwth.monticore.EmbeddedMontiArc.simulators.hardware_emulator.HardwareEmulatorInterface;
import org.junit.Test;
import org.junit.Assert;
import java.io.File;
import java.io.Serializable;
import java.util.HashMap;
public class HardwareEmulatorTest {
@Test
public void basic_test() throws Exception {
System.out.println("Current test directory: " + System.getProperty("user.dir"));
HardwareEmulatorInterface manager = new HardwareEmulatorInterface("autopilots_folder=autopilots", "");
String querry = "get_available_autopilots\nget_available_threads";
String res = manager.query(querry);
System.out.println("EmulatorManager querry response: " + res);
String lines[] = res.split("\n");
Assert.assertEquals("Querry result line count", 2, lines.length);
String line1[] = lines[0].split("=");
Assert.assertEquals("available_autopilots two values (=)", 2, line1.length);
Assert.assertEquals("available_autopilots command", new String("available_autopilots"), line1[0]);
String line2[] = lines[1].split("=");
Assert.assertEquals("available_threads two values (=)", 2, line2.length);
Assert.assertEquals("available_threads command", new String("available_threads"), line2[0]);
String config = "autopilot=AutopilotAdapter";
config += "\nos=windows";
int id = manager.alloc_autopilot(config);
if (id < 0){
String q = manager.query( "get_error_msg" );
Assert.assertTrue("Could not allocate Emulator: " + q, id >= 0);
}
HashMap<String, Serializable> inputs = new HashMap<String, Serializable>();
inputs.put("timeIncrement", 1.0);
inputs.put("currentVelocity", 0.0);
inputs.put("x", 0.01);
inputs.put("y", 0.01);
inputs.put("compass", 0.0);
inputs.put("currentEngine", 0.0);
inputs.put("currentSteering", 0.0);
inputs.put("currentBrakes", 0.0);
inputs.put("trajectory_length", 5);
inputs.put("trajectory_x", new double[]{0.01, 0.02, 0.03, 0.04, 0.05, 0.06});
inputs.put("trajectory_y", new double[]{0.01, 0.01, 0.02, 0.02, 0.01, 0.01});
manager.update_bus(id, inputs);
//manager.start_tick(1000000);
//manager.end_tick();
HashMap<String, Serializable> outputs = manager.old_execute(id, 1000000, inputs);
String emu_querry = manager.query_autopilot(id, "get_avg_runtime");
System.out.println("Emu querry: " + emu_querry);
//HashMap<String, Serializable> outputs = manager.get_outputs(id);
Assert.assertEquals("output count", outputs.size(), 3);
for (HashMap.Entry<String, Serializable> entry : outputs.entrySet()) {
System.out.println(entry.getKey() + " = " + entry.getValue());