Commit f0fa5738 authored by Jean Meurice's avatar Jean Meurice
Browse files

HardwareEmulator interface tweaks, old_execute

parent e7b36f1a
Pipeline #114849 failed with stages
in 2 minutes and 1 second
@echo off
pushd ..
call run.bat os=linux cpu_frequency=10000000 memory_frequency=1000000 cache_DL1=128,1,2 cache_IL1=128,1,2 cache_L2=1024,10,15 export debug=unsupported_syscalls
popd
\ No newline at end of file
@echo off
pushd ..
call run.bat test_real os=windows cpu_frequency=10000000 memory_frequency=1000000 cache_DL1=128,1,2 cache_IL1=128,1,2 cache_L2=1024,10,15 export
popd
\ No newline at end of file
@echo off
pushd ..
call run.bat test_real os=windows cpu_frequency=10000000 memory_frequency=1000000 export
popd
\ No newline at end of file
@echo off
pushd ..
call run.bat os=windows no_time test_real
popd
\ No newline at end of file
@echo off
pushd ..
call run.bat test_real os=windows cpu_frequency=1500000 memory_frequency=150000 cache_DL1=128,1,2 cache_IL1=128,1,2 cache_L2=1024,10,15 export
popd
\ No newline at end of file
## install
This folder contains a sample setup of the RMIModelServer using the HardwareEmulator.
This folder is used to perform a simple test including the HardwareEmulator.
Autopilots can be added in the autopilots folder and loaded on the file using HardwareEmulator configuration.
The demo folder contains examples that start the RMIModelServer with a default configuration that is added to
every allocated autopilot.
\ No newline at end of file
......@@ -23,5 +23,5 @@
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=127.0.0.1" -cp rmi-model-server.jar rwth.rmi.model.server.RMIServer %PORT% %AUTOPILOT_FOLDER%
java "-Djava.rmi.server.codebase=file:rmi-model-server.jar" "-Djava.rmi.server.hostname=127.0.0.1" -cp rmi-model-server.jar rwth.rmi.model.server.RMIServer %PORT% %AUTOPILOT_FOLDER% %*
pause
......@@ -26,7 +26,7 @@
<groupId>montisim</groupId>
<artifactId>rmi-model-server</artifactId>
<version>1.0.1-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>rmi-model-server</name>
......
......@@ -51,9 +51,9 @@ public class RMIServer {
return;
}
File autopilotAdapterDLL = new File(args[1]);
if (!autopilotAdapterDLL.exists()){
System.out.printf("AutopilotAdapter: %s not exist\n", autopilotAdapterDLL);
File autopilot_folder = new File(args[1]);
if (!autopilot_folder.exists()){
System.out.printf("The autopilot folder %s does not exist\n", autopilot_folder);
return;
}
......@@ -63,7 +63,7 @@ public class RMIServer {
zoo_servers = "localhost:2181";
}
//ZkClient zk = new ZkClient(zoo_servers, 1000, 5000);
HardwareEmulatorInterface manager = new HardwareEmulatorInterface(args[1]);
HardwareEmulatorInterface manager = new HardwareEmulatorInterface(args);
String host = InetAddress.getLocalHost().getHostName();
int port = Integer.valueOf(args[0]);
......
......@@ -33,12 +33,14 @@ public interface RMIManager extends Remote {
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 querry(String msg) throws RemoteException;
public String querry_autopilot(int id, String msg) throws RemoteException;
public String query(String msg) throws RemoteException;
public String query_autopilot(int id, String msg) throws RemoteException;
}
......@@ -19,16 +19,21 @@
* *******************************************************************************
*/
package simulator.integration;
import rwth.rmi.model.server.interfaces.RMIManager;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.io.Serializable;
import rwth.rmi.model.server.interfaces.RMIManager;
public class HardwareEmulatorInterface implements RMIManager {
public HardwareEmulatorInterface(String libraryPath) {
public HardwareEmulatorInterface(String[] args) {
super();
String default_config = "";
for (int i = 2; i < args.length; i++){
default_config += args[i] + "\n";
}
String libraryPath = args[1];
String emu = System.getProperty("user.dir") + "/HardwareEmulator";
String OS = System.getProperty("os.name").toLowerCase();
if (OS.contains("win")){
......@@ -41,16 +46,19 @@ public class HardwareEmulatorInterface implements RMIManager {
try {// Load AutopilotAdapter.dll from libraryPath
File b = new File(libraryPath);
String absolute = b.getCanonicalPath();
init("autopilots_folder=" + absolute);
init("autopilots_folder=" + absolute, default_config);
} catch (IOException e) {
e.printStackTrace();
System.out.println("Could not initiate the Hardware Emulator");
init("");
init("", default_config);
}
}
private native boolean init(String config);
private native boolean init(String config, String default_config);
@Override
public native int alloc_autopilot(String config);
@Override
......@@ -62,6 +70,19 @@ public class HardwareEmulatorInterface implements RMIManager {
}
}
@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
......@@ -70,18 +91,18 @@ public class HardwareEmulatorInterface implements RMIManager {
@Override
public HashMap<String, Serializable> get_outputs(int id) {
HashMap<String, Serializable> outputs = new HashMap<String, Serializable>();
querry_outputs(id, outputs);
query_outputs(id, outputs);
return outputs;
}
@Override
public native String querry(String msg);
public native String query(String msg);
@Override
public native String querry_autopilot(int id, String msg);
public native String query_autopilot(int id, String msg);
private native void add_one_input(int id, String key, Serializable value);
private native void querry_outputs(int id, HashMap<String, Serializable> opaque_hashmap);
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);
}
......
......@@ -30,10 +30,10 @@ public class HardwareEmulatorTest {
@Test
public void basic_test(){
System.out.println("Current test directory: " + System.getProperty("user.dir"));
HardwareEmulatorInterface manager = new HardwareEmulatorInterface("autopilots");
HardwareEmulatorInterface manager = new HardwareEmulatorInterface(new String[]{"10101", "autopilots"});
String querry = "get_available_autopilots\nget_available_threads";
String res = manager.querry(querry);
String res = manager.query(querry);
System.out.println("EmulatorManager querry response: " + res);
String lines[] = res.split("\n");
......@@ -50,7 +50,7 @@ public class HardwareEmulatorTest {
config += "\nos=windows";
int id = manager.alloc_autopilot(config);
if (id < 0){
String q = manager.querry( "get_error_msg" );
String q = manager.query( "get_error_msg" );
Assert.assertTrue("Could not allocate Emulator: " + q, id >= 0);
}
......@@ -67,11 +67,12 @@ public class HardwareEmulatorTest {
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();
String emu_querry = manager.querry_autopilot(id, "get_avg_runtime");
System.out.println("Emu querry: " + emu_querry);
HashMap<String, Serializable> outputs = manager.get_outputs(id);
//manager.start_tick(1000000);
//manager.end_tick();
HashMap<String, Serializable> outputs = manager.old_execute(id, 1000000, inputs);
//String emu_querry = manager.querry_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());
......
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