Commit 15ac1432 authored by Evgeny Kusmenko's avatar Evgeny Kusmenko
Browse files

Merge branch 'basic-simulator' into 'master'

Repackaging + Using new Hardware Emulator package

See merge request !9
parents 03c51cc4 efb812c1
Pipeline #177781 failed with stage
in 1 minute and 31 seconds
@rem (c) https://github.com/MontiCore/monticore
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
#!/bin/bash
# (c) https://github.com/MontiCore/monticore
cd ..
mvn clean install -s settings.xml -DskipTests
cd target
cp rmi-model-server-*-jar-with-dependencies.jar ../install/rmi-model-server.jar
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) https://github.com/MontiCore/monticore -->
<!--
(c) https://github.com/MontiCore/monticore
The license generally applicable for this project
can be found under https://github.com/MontiCore/monticore.
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
......@@ -61,106 +68,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>
......
/* (c) https://github.com/MontiCore/monticore */
package rwth.rmi.model.server;
/**
* (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 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;
......
/* (c) https://github.com/MontiCore/monticore */
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;
}
/* (c) https://github.com/MontiCore/monticore */
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 working_dir = System.getProperty("user.dir") + "/";
String system_library_name = LibraryService.getSystemLibraryName("HardwareEmulator");
LibraryService.prepareLibrary(working_dir, system_library_name);
lib_path = working_dir + system_library_name;
//Load the library
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);
}
}
/* (c) https://github.com/MontiCore/monticore */
package simulator.integration;
/**
* (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;
......
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