Commit e9d0d471 authored by Jean Meurice's avatar Jean Meurice

Config Serialization fix & Library version check

parent 375320ad
Pipeline #230914 passed with stages
in 11 minutes and 57 seconds
......@@ -9,7 +9,8 @@
## Overview
This project allows to run **EmbeddedMontiArc** models that have a **DynamicInterface** and let them communicate with the MontiSim simulation. It allows the time evaluation of the model execution using a parametric computer model.
## Resource for processor modelling
[https://www.agner.org/optimize/](https://www.agner.org/optimize/)
## Building
The project contains a **C++ CMake project** and a **Maven project**.
......@@ -25,7 +26,7 @@ To compile the C++ project (under the [hardware_emulator](hardware_emulator) fol
The `build_emulator` script will directly install the compiled library inside the [resources](src/main/resources) folder of the Maven project.
_**NOTE:** Any changes to the C++ project **MUST** be compiled and installed under both **Linux and Windows** before being merged into the Master branch so that both updated versions are included in the maven artifact._
_**NOTE:** When changing the version of the maven project, be sure to set the version accordingly in [software_simulator_manager.h](hardware_emulator/src/software_simulator_manager.h). This ensures that the library included in the artifact is up-to-date with the Java code._
### Maven Project
......
......@@ -7,6 +7,14 @@
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_emulator_CppBridge
* Method: getVersion
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_1emulator_CppBridge_getVersion
(JNIEnv *, jclass);
/*
* Class: de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_emulator_CppBridge
* Method: initManager
......
......@@ -20,8 +20,8 @@ void OS::ElfLoader::init(const FS::File& fn, SystemCalls &sys_calls, Memory &mem
module_name = "SYSTEM";
FileReader fr;
if ( !fr.open( file_name ) )
throw_error(Error::hardware_emu_software_load_error("[ElfLoader] Could not find software program: " + fn.to_string()));
if ( !fr.open( fn ) )
throw_error(Error::hardware_emu_software_load_error("[ElfLoader] Could not find software program: " + fn.as_system_path()));
fr.read( elf.data );
......
......@@ -122,6 +122,16 @@ std::string SoftwareSimulatorManager::query( const char *msg ) {
if new data types must be converted from C types to Java types.
*/
/*
* Class: de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_emulator_CppBridge
* Method: getVersion
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_1emulator_CppBridge_getVersion
(JNIEnv *jni, jclass){
return jni->NewStringUTF(VERSION);
}
/*
* Class: de_rwth_monticore_EmbeddedMontiArc_simulators_hardware_emulator_CppBridge
......
......@@ -8,6 +8,9 @@
#include "software_simulator.h"
#include <list>
#include "utility/utility.h"
static constexpr auto VERSION = "1.0.5";
/*
The EmulatorManager is used to allocate and interact with autopilot emualtors.
The allocated autopilots are addressed through the id received when allocating.
......
......@@ -7,12 +7,13 @@
can be found under https://github.com/MontiCore/monticore.
-->
<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">
<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.4</version>
<version>1.0.5</version>
<properties>
......@@ -50,6 +51,20 @@
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>filter-src</id>
<goals>
<goal>filter-sources</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Add the option to generate the JNI headers directly to the CPP project -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
......
/**
* (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.hardware_emulator;
public class HardwareEmulatorVersion {
public final static String version = "${version}";
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ import java.util.HashMap;
import de.rwth.monticore.EmbeddedMontiArc.simulators.commons.utils.LibraryService;
import de.rwth.monticore.EmbeddedMontiArc.simulators.commons.utils.LibraryService.LibraryException;
import de.rwth.monticore.EmbeddedMontiArc.simulators.hardware_emulator.config.SoftwareSimulatorConfig;
import de.rwth.monticore.EmbeddedMontiArc.simulators.hardware_emulator.HardwareEmulatorVersion;
/// Contains the STATIC functions to interact with the native C++ library.
public class CppBridge {
......@@ -41,10 +42,16 @@ public class CppBridge {
//System.out.println("LibPath: " + lib_path);
}
static public void init(SoftwareSimulatorConfig manager_config){
static public void init(SoftwareSimulatorConfig manager_config) throws Exception{
String version = getVersion();
if (!HardwareEmulatorVersion.version.equals(version))
throw new Exception("Wrong native HardwareEmulator library version: "+version+", expected: "+HardwareEmulatorVersion.version);
initManager(manager_config.get_config_string());
loaded = true;
}
static public native String getVersion();
static private native void initManager(String config);
static public native int allocSimulator(String config) throws Exception;
......
......@@ -6,9 +6,12 @@
*/
package de.rwth.monticore.EmbeddedMontiArc.simulators.hardware_emulator.config;
import java.io.Serializable;
import java.time.Duration;
public class ControllerConfig {
public class ControllerConfig implements Serializable {
private static final long serialVersionUID = 646999434800913765L;
static public enum EmulatorType {
DIRECT("direct"), //No Emulator at all: the Autopilot library (DLL/SO/...) is loaded directly by the OS.
HARDWARE_EMULATOR("emu"); //The Autopilot is loaded in a Virtual Computer (can load autopilots cross-platform).
......@@ -66,8 +69,9 @@ public class ControllerConfig {
}
}
public static class CacheOption {
private long size; //Cache Size in bytes
public static class CacheOption implements Serializable {
private static final long serialVersionUID = 3500766901354278880L;
private long size; // Cache Size in bytes
private long read_ticks; // Number of CPU cycles for a read action
private long write_ticks; //Number of CPU cycles for a write action
......
......@@ -6,10 +6,12 @@
*/
package de.rwth.monticore.EmbeddedMontiArc.simulators.hardware_emulator.config;
import java.io.Serializable;
public class SoftwareSimulatorConfig {
public class SoftwareSimulatorConfig implements Serializable {
private static final long serialVersionUID = 60388757112555139L;
String softwares_folder = ".";
public String get_config_string() {
......
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