Commit 402d762d authored by Evgeny Kusmenko's avatar Evgeny Kusmenko
Browse files

Merge branch 'ee-infra' into 'master'

ee infrastructure

See merge request !4
parents 69b00263 f0526697
Pipeline #188293 failed with stages
in 6 minutes
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_emulator_HardwareEmulatorInterface */
......@@ -39,6 +45,22 @@ JNIEXPORT void JNICALL Java_de_rwth_monticore_EmbeddedMontiArc_simulators_hardwa
JNIEXPORT void JNICALL Java_de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_1emulator_HardwareEmulatorInterface_execute_1one
(JNIEnv *, jobject, jint, jlong);
/*
* Class: de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_emulator_HardwareEmulatorInterface
* Method: execute_one_Event
* Signature: (IJ)V
*/
JNIEXPORT void JNICALL Java_de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_1emulator_HardwareEmulatorInterface_execute_1one_1Event
(JNIEnv *, jobject, jint, jlong);
/*
* Class: de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_emulator_HardwareEmulatorInterface
* Method: time_execute
* Signature: (I)J
*/
JNIEXPORT jlong JNICALL Java_de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_1emulator_HardwareEmulatorInterface_time_1execute
(JNIEnv *, jobject, jint);
/*
* Class: de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_emulator_HardwareEmulatorInterface
* Method: start_tick
......
......@@ -44,6 +44,16 @@ JNIEXPORT void JNICALL Java_de_rwth_monticore_EmbeddedMontiArc_simulators_hardwa
EmulatorManager::instance.emulators[id]->exec( time_delta );
}
JNIEXPORT void JNICALL Java_de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_1emulator_HardwareEmulatorInterface_execute_1one_1Event
( JNIEnv *, jobject, jint id, jlong unused_time ) {
EmulatorManager::instance.emulators[id]->exec_Event( unused_time );
}
JNIEXPORT jlong JNICALL Java_de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_1emulator_HardwareEmulatorInterface_time_1execute
(JNIEnv*, jobject, jint id){
return EmulatorManager::instance.emulators[id]->time_execute();
}
JNIEXPORT void JNICALL Java_de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_1emulator_HardwareEmulatorInterface_start_1tick
( JNIEnv *, jobject, jlong time_delta ) {
EmulatorManager::instance.start_tick( time_delta );
......
......@@ -340,6 +340,37 @@ void HardwareEmulator::exec( ulong micro_delta ) {
simulation_time += micro_delta;
}
void HardwareEmulator::exec_Event(ulong unused_time){
if ( !computing() || !computer.time.use_time ) {
for ( auto &port : input_ports )
call_input( port );
call_execute();
if ( debug_time )
Log::info << Log::tag << "Execute time: " << computer.time.micro_time << "\n";
execution_time = computer.time.micro_time;
}
if ( export_data )
export_tick();
//Upate time
avg_runtime.add( computer.time.micro_time );
//Upate outputs
for ( auto &port : output_ports )
call_output( port );
computer.time.reset();
//++debug_tick_count;
simulation_time += computer.time.micro_time + unused_time;
}
ulong HardwareEmulator::time_execute(){
return execution_time;
}
void HardwareEmulator::call_input_direct(Port& port) {
auto& input = port.buffer;
switch (input.type) {
......
......@@ -184,7 +184,8 @@ struct HardwareEmulator {
bool resolve_autopilot_os( EmulatorManager &manager );
void exec( ulong micro_delta );
void exec_Event(ulong unused_time);
ulong time_execute();
//nullptr if not found
Port *get_port( const char *port_name );
......
......@@ -9,16 +9,16 @@
-->
<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>hardware_emulator</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<properties>
<commons.version>1.0.10</commons.version>
<commons.version>1.0.11</commons.version>
<wagon.provider.version>2.6</wagon.provider.version>
<!-- .. Plugins ....................................................... -->
<compiler.plugin>3.3</compiler.plugin>
......@@ -28,8 +28,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
......@@ -37,19 +37,19 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>montisim</groupId>
<artifactId>commons</artifactId>
<version>${commons.version}</version>
</dependency>
</dependencies>
<!-- == PROJECT BUILD SETTINGS =========================================== -->
<build>
<plugins>
<!-- Add the option to generate the JNI headers directly to the CPP project -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
......@@ -64,7 +64,7 @@
<target>${java.version}</target>
</configuration>
</plugin>
<!-- Run the tests where the test/resources are located -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
......@@ -76,7 +76,7 @@
<argLine>-Xmx2048m -XX:MaxPermSize=1024m</argLine>
</configuration>
</plugin>
<!-- Source Jar Configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......@@ -130,8 +130,8 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
......@@ -155,9 +155,9 @@
</plugin>
</plugins>
</build>
<!-- == DISTRIBUTION ==================================================== -->
<distributionManagement>
<repository>
<id>se-nexus</id>
......@@ -168,5 +168,5 @@
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
......@@ -10,6 +10,7 @@ import java.io.File;
import java.util.HashMap;
import java.io.Serializable;
import de.rwth.monticore.EmbeddedMontiArc.simulators.commons.utils.LibraryService;
import java.time.Duration;
public class HardwareEmulatorInterface implements ModelServer {
String lib_path = "";
......@@ -58,8 +59,23 @@ public class HardwareEmulatorInterface implements ModelServer {
query_outputs(id, outputs);
return outputs;
}
private native void execute_one(int id, long time_delta);
@Override
public void set_inputs(int id, HashMap<String, Serializable> inputs){
for (HashMap.Entry<String, Serializable> entry : inputs.entrySet()){
add_one_input(id, entry.getKey(), entry.getValue());
}
}
@Override
public Duration time_execute(int id, Duration unused_time){
execute_one_Event(id, (unused_time.toNanos()/1000));// to microseconds
return Duration.ofNanos(time_execute(id)*1000);
}
private native void execute_one(int id, long time_delta);
private native void execute_one_Event(int id, long unused_time);
private native long time_execute(int id);
@Override
public native void start_tick(long time_delta);
......
......@@ -12,6 +12,8 @@ import java.rmi.RemoteException;
import java.io.Serializable;
import java.util.HashMap;
import java.time.Duration;
public interface ModelServer extends Remote {
public int alloc_autopilot(String config) throws RemoteException;
public void free_autopilot(int id) throws RemoteException;
......@@ -20,6 +22,9 @@ public interface ModelServer extends Remote {
public HashMap<String, Serializable> old_execute(int id, long time_delta, HashMap<String, Serializable> inputs) throws RemoteException;
public void set_inputs(int id, HashMap<String, Serializable> inputs) throws RemoteException;
public Duration time_execute(int id, Duration unused_time) throws RemoteException;
public void start_tick(long time_delta) throws RemoteException;
public void end_tick() throws RemoteException;
......
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