Commit 298e3ad5 authored by Jean Meurice's avatar Jean Meurice

New Package structure + New Hardware Emulator usage

parent 5446235f
Pipeline #169810 failed with stage
in 1 minute and 3 seconds
......@@ -4,4 +4,6 @@
*.iml
.classpath
/.settings
.vscode/
\ No newline at end of file
.vscode/
*.jar
*.dll
\ No newline at end of file
......@@ -23,5 +23,6 @@
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.hostname=localhost" -cp rmi-model-server.jar rwth.rmi.model.server.RMIServer %PORT% %AUTOPILOT_FOLDER% --no-zookeeper %*
@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 %*
pause
......@@ -23,4 +23,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.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
......@@ -20,68 +20,73 @@
*******************************************************************************
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>montisim</groupId>
<artifactId>rmi-model-server</artifactId>
<version>1.1.3</version>
<packaging>jar</packaging>
<groupId>montisim</groupId>
<artifactId>rmi-model-server</artifactId>
<version>1.1.3</version>
<packaging>jar</packaging>
<name>rmi-model-server</name>
<name>rmi-model-server</name>
<properties>
<properties>
<!-- USE THESE TO SET THE VERSIONS OF THE DEPENDENCIES FOR ALL THE SUB-PROJECTS -->
<commons.version>1.0.8</commons.version>
<hardware_emulator.version>1.0.0</hardware_emulator.version>
<!-- .. SE-Libraries .................................................. -->
<!-- .. SE-Libraries .................................................. -->
<monticore.version>4.5.4.08.11.2017</monticore.version>
<se-commons.version>1.7.7</se-commons.version>
<mc.grammars.assembly.version>0.0.8</mc.grammars.assembly.version>
<SIUnit.version>0.0.10-SNAPSHOT</SIUnit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- .. Plugins ....................................................... -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- .. Plugins ....................................................... -->
<monticore.plugin>4.5.3.1</monticore.plugin>
<assembly.plugin>2.5.4</assembly.plugin>
<compiler.plugin>3.3</compiler.plugin>
<source.plugin>2.4</source.plugin>
<!-- .. Misc .......................................................... -->
<!-- .. Misc .......................................................... -->
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.2</version>
</dependency>
<dependency>
<groupId>montisim</groupId>
<artifactId>commons</artifactId>
<version>${commons.version}</version>
</dependency>
</dependencies>
<!-- == PROJECT BUILD SETTINGS =========================================== -->
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.2</version>
</dependency>
<dependency>
<groupId>montisim</groupId>
<artifactId>commons</artifactId>
<version>${commons.version}</version>
</dependency>
<dependency>
<groupId>montisim</groupId>
<artifactId>hardware_emulator</artifactId>
<version>${hardware_emulator.version}</version>
</dependency>
</dependencies>
<!-- == PROJECT BUILD SETTINGS =========================================== -->
<build>
<plugins>
......@@ -132,6 +137,29 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>de.rwth.monticore.EmbeddedMontiArc.simulators.rmimodelserver.RMIServer</mainClass>
</transformer>
</transformers>
<outputFile>${project.basedir}/install/${project.name}.jar</outputFile>
</configuration>
</execution>
</executions>
</plugin>
<!-- Source Jar Configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......@@ -180,22 +208,12 @@
<phase>process-sources</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<workingDirectory>${project.basedir}/install</workingDirectory>
<argLine>-Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
</configuration>
<configuration></configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
......@@ -207,7 +225,7 @@
<!-- aggregated reports for multi-module projects -->
<aggregate>true</aggregate>
</configuration>
</plugin>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
......@@ -234,18 +252,63 @@
</plugins>
</build>
<!-- == DISTRIBUTION ==================================================== -->
<distributionManagement>
<repository>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-releases/</url>
</repository>
<snapshotRepository>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>eclipse</id>
<url>https://repo.eclipse.org/content/groups/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>topobyte</id>
<url>http://mvn.topobyte.de/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<!-- == DISTRIBUTION ==================================================== -->
<distributionManagement>
<repository>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-releases/</url>
</repository>
<snapshotRepository>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
\ No newline at end of file
@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
pushd %~dp0..
call mvn clean install -s "settings.xml"
cd target
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
#
#
# ******************************************************************************
# 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/>.
# *******************************************************************************
#
cd ..
mvn clean install -s settings.xml -DskipTests
cd target
cp rmi-model-server-*-jar-with-dependencies.jar ../install/rmi-model-server.jar
......@@ -82,106 +82,7 @@
</profile>
<profile>
<id>se-nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled /></releases>
<snapshots><enabled /></snapshots>
</repository>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>eclipse</id>
<url>https://repo.eclipse.org/content/groups/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>topobyte</id>
<url>http://mvn.topobyte.de/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled /></releases>
<snapshots><enabled /></snapshots>
</pluginRepository>
<pluginRepository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>eclipse</id>
<url>https://repo.eclipse.org/content/groups/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>topobyte</id>
<url>http://mvn.topobyte.de/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
......
......@@ -18,10 +18,10 @@
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package rwth.rmi.model.server;
package de.rwth.monticore.EmbeddedMontiArc.simulators.rmimodelserver;
import org.I0Itec.zkclient.ZkClient;
import simulator.integration.HardwareEmulatorInterface;
import de.rwth.monticore.EmbeddedMontiArc.simulators.hardware_emulator.HardwareEmulatorInterface;
import java.io.File;
import java.io.IOException;
......
/**
*
* ******************************************************************************
* 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/>.
* *******************************************************************************
*/
package rwth.rmi.model.server.interfaces;
import java.rmi.AlreadyBoundException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.io.Serializable;
import java.util.HashMap;
public interface RMIManager extends Remote {
public int alloc_autopilot(String config) throws RemoteException;
public void free_autopilot(int id) throws RemoteException;
public void update_bus(int id, HashMap<String, Serializable> inputs) throws RemoteException;
public HashMap<String, Serializable> old_execute(int id, long time_delta, HashMap<String, Serializable> inputs) throws RemoteException;
public void start_tick(long time_delta) throws RemoteException;
public void end_tick() throws RemoteException;
public HashMap<String, Serializable> get_outputs(int id) throws RemoteException;
public String query(String msg) throws RemoteException;
public String query_autopilot(int id, String msg) throws RemoteException;
}
/**
*
* ******************************************************************************
* 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/>.
* *******************************************************************************
*/
package simulator.integration;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.io.Serializable;
import rwth.rmi.model.server.interfaces.RMIManager;
import commons.utils.LibraryService;
public class HardwareEmulatorInterface implements RMIManager {
String lib_path = "";
public HardwareEmulatorInterface(String emu_config, String default_config) throws LibraryService.LibraryException, Exception {
super();
load_library();
if (!init(emu_config, default_config)){
String error_msg = query("get_error_msg");
throw new Exception("Error initializing the HardwareEmulator: " + error_msg);
}
}
public void load_library() throws LibraryService.LibraryException {
//Use LibraryService to get the library from resources to the working directory (if not already there)
String system_library_name = LibraryService.getSystemLibraryName("HardwareEmulator");
LibraryService.prepareLibrary(system_library_name);
//Load the library
lib_path = LibraryService.getWorkingDirectory() + system_library_name;
System.load(lib_path);
//System.out.println("LibPath: " + lib_path);
}
public File get_library(){
return new File(lib_path);
}
private native boolean init(String config, String default_config);
@Override
public native int alloc_autopilot(String config);
@Override
public native void free_autopilot(int id);
@Override
public void update_bus(int id, HashMap<String, Serializable> inputs){
for (HashMap.Entry<String, Serializable> entry : inputs.entrySet()){
add_one_input(id, entry.getKey(), entry.getValue());
}
}
@Override
public HashMap<String, Serializable> old_execute(int id, long time_delta, HashMap<String, Serializable> inputs){
for (HashMap.Entry<String, Serializable> entry : inputs.entrySet()){
add_one_input(id, entry.getKey(), entry.getValue());
}
execute_one(id, time_delta);
HashMap<String, Serializable> outputs = new HashMap<String, Serializable>();
query_outputs(id, outputs);
return outputs;
}
private native void execute_one(int id, long time_delta);
@Override
public native void start_tick(long time_delta);
@Override
public native void end_tick();
@Override
public HashMap<String, Serializable> get_outputs(int id) {
HashMap<String, Serializable> outputs = new HashMap<String, Serializable>();
query_outputs(id, outputs);
return outputs;
}
@Override
public native String query(String msg);
@Override
public native String query_autopilot(int id, String msg);
private native void add_one_input(int id, String key, Serializable value);
private native void query_outputs(int id, HashMap<String, Serializable> opaque_hashmap);
private void add_one_output(HashMap<String, Serializable> opaque_hashmap, String key, Serializable value) {
opaque_hashmap.put(key, value);
}
}
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de