Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
EMAM2Cpp
Commits
fa90d01f
Commit
fa90d01f
authored
Mar 06, 2019
by
Jean Meurice
Browse files
HardwareEmulator Interface update
parent
be5f5860
Pipeline
#109448
failed with stages
in 12 minutes and 32 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/generator/cpp/GeneratorCPP.java
View file @
fa90d01f
...
...
@@ -23,6 +23,7 @@ package de.monticore.lang.monticar.generator.cpp;
import
de.ma2cfg.helper.Names
;
import
de.monticore.lang.embeddedmontiarc.embeddedmontiarc.ComponentScanner
;
import
de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol
;
import
de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol
;
import
de.monticore.lang.embeddedmontiarcdynamic.embeddedmontiarcdynamic._symboltable.instanceStructure.EMADynamicComponentInstanceSymbol
;
import
de.monticore.lang.math._symboltable.MathStatementsSymbol
;
import
de.monticore.lang.monticar.generator.*
;
...
...
@@ -36,7 +37,7 @@ import de.monticore.lang.monticar.generator.cpp.converter.OptimizationSymbolHand
import
de.monticore.lang.monticar.generator.cpp.converter.TypeConverter
;
import
de.monticore.lang.monticar.generator.cpp.mathopt.MathOptSolverConfig
;
import
de.monticore.lang.monticar.generator.cpp.template.AllTemplates
;
import
de.monticore.lang.monticar.generator.cpp.viewmodel.AutopilotAdapter
View
Model
;
import
de.monticore.lang.monticar.generator.cpp.viewmodel.AutopilotAdapter
Data
Model
;
import
de.monticore.lang.monticar.generator.cpp.viewmodel.ServerWrapperViewModel
;
import
de.monticore.lang.monticar.generator.testing.StreamTestGenerator
;
import
de.monticore.lang.monticar.ts.MCTypeSymbol
;
...
...
@@ -482,15 +483,29 @@ public class GeneratorCPP implements Generator {
private
static
List
<
FileContent
>
getAutopilotAdapterFiles
(
EMAComponentInstanceSymbol
componentSymbol
)
{
List
<
FileContent
>
result
=
new
ArrayList
<>();
result
.
add
(
FileUtil
.
getResourceAsFile
(
"/template/autopilotadapter/AutopilotAdapter.h"
,
"AutopilotAdapter.h"
));
result
.
add
(
generateAutopilotAdapter
(
componentSymbol
));
AutopilotAdapterDataModel
dm
=
new
AutopilotAdapterDataModel
();
dm
.
setMainModelName
(
GeneralHelperMethods
.
getTargetLanguageComponentName
(
componentSymbol
.
getFullName
()));
dm
.
setInputCount
(
componentSymbol
.
getIncomingPortInstances
().
size
());
dm
.
setOutputCount
(
componentSymbol
.
getOutgoingPortInstances
().
size
());
for
(
EMAPortInstanceSymbol
port
:
componentSymbol
.
getIncomingPortInstances
()){
dm
.
addInput
(
port
.
getName
(),
port
.
getTypeReference
().
getName
());
}
for
(
EMAPortInstanceSymbol
port
:
componentSymbol
.
getOutgoingPortInstances
()){
dm
.
addOutput
(
port
.
getName
(),
port
.
getTypeReference
().
getName
());
}
result
.
add
(
generateAutopilotAdapterH
(
dm
));
result
.
add
(
generateAutopilotAdapterCpp
(
dm
));
return
result
;
}
private
static
FileContent
generateAutopilotAdapter
(
EMAComponentInstanceSymbol
componentSymbol
)
{
AutopilotAdapterViewModel
vm
=
new
AutopilotAdapterViewModel
();
vm
.
setMainModelName
(
GeneralHelperMethods
.
getTargetLanguageComponentName
(
componentSymbol
.
getFullName
()));
String
fileContents
=
AllTemplates
.
generateAutopilotAdapter
(
vm
);
private
static
FileContent
generateAutopilotAdapterH
(
AutopilotAdapterDataModel
dm
)
{
String
fileContents
=
AllTemplates
.
generateAutopilotAdapterH
(
dm
);
return
new
FileContent
(
fileContents
,
"AutopilotAdapter.h"
);
}
private
static
FileContent
generateAutopilotAdapterCpp
(
AutopilotAdapterDataModel
dm
)
{
String
fileContents
=
AllTemplates
.
generateAutopilotAdapterCpp
(
dm
);
if
(
currentInstance
.
generateCMake
)
addAutopilotAdapterCMakeConfig
();
return
new
FileContent
(
fileContents
,
"AutopilotAdapter.cpp"
);
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/template/AllTemplates.java
View file @
fa90d01f
...
...
@@ -20,7 +20,7 @@
*/
package
de.monticore.lang.monticar.generator.cpp.template
;
import
de.monticore.lang.monticar.generator.cpp.viewmodel.AutopilotAdapter
View
Model
;
import
de.monticore.lang.monticar.generator.cpp.viewmodel.AutopilotAdapter
Data
Model
;
import
de.monticore.lang.monticar.generator.cpp.viewmodel.ComponentStreamTestViewModel
;
import
de.monticore.lang.monticar.generator.cpp.viewmodel.EnumViewModel
;
import
de.monticore.lang.monticar.generator.cpp.viewmodel.ServerWrapperViewModel
;
...
...
@@ -43,7 +43,8 @@ public final class AllTemplates {
private
static
final
Template
TESTS_MAIN_ENTRY_ARMADILLO
;
private
static
final
Template
STRUCT
;
private
static
final
Template
ENUM
;
private
static
final
Template
AUTOPILOT_ADAPTER
;
private
static
final
Template
AUTOPILOT_ADAPTER_CPP
;
private
static
final
Template
AUTOPILOT_ADAPTER_H
;
private
static
final
Template
SERVER_WRAPPER
;
private
static
final
Template
DYNAMICS_EVENT_PortValueCheker
;
...
...
@@ -62,7 +63,8 @@ public final class AllTemplates {
TESTS_MAIN_ENTRY_ARMADILLO
=
conf
.
getTemplate
(
"/test/TestsMainEntryArmadillo.ftl"
);
STRUCT
=
conf
.
getTemplate
(
"/type/Struct.ftl"
);
ENUM
=
conf
.
getTemplate
(
"/type/Enum.ftl"
);
AUTOPILOT_ADAPTER
=
conf
.
getTemplate
(
"/autopilotadapter/AutopilotAdapter.ftl"
);
AUTOPILOT_ADAPTER_CPP
=
conf
.
getTemplate
(
"/autopilotadapter/AutopilotAdapterCpp.ftl"
);
AUTOPILOT_ADAPTER_H
=
conf
.
getTemplate
(
"/autopilotadapter/AutopilotAdapterH.ftl"
);
SERVER_WRAPPER
=
conf
.
getTemplate
(
"/serverwrapper/ServerWrapper.ftl"
);
DYNAMICS_EVENT_PortValueCheker
=
conf
.
getTemplate
(
"/dynamics/events_port_value_check_h.ftl"
);
DYNAMICS_EVENT_DynamicHelper
=
conf
.
getTemplate
(
"/dynamics/dynamic_port_request_connect_helper_h.ftl"
);
...
...
@@ -95,8 +97,11 @@ public final class AllTemplates {
return
generate
(
ENUM
,
viewModel
);
}
public
static
String
generateAutopilotAdapter
(
AutopilotAdapterViewModel
viewModel
)
{
return
generate
(
AUTOPILOT_ADAPTER
,
viewModel
);
public
static
String
generateAutopilotAdapterCpp
(
AutopilotAdapterDataModel
viewModel
)
{
return
generate
(
AUTOPILOT_ADAPTER_CPP
,
viewModel
);
}
public
static
String
generateAutopilotAdapterH
(
AutopilotAdapterDataModel
viewModel
)
{
return
generate
(
AUTOPILOT_ADAPTER_H
,
viewModel
);
}
public
static
String
generateServerWrapper
(
ServerWrapperViewModel
viewModel
)
{
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/viewmodel/AutopilotAdapter
View
Model.java
→
src/main/java/de/monticore/lang/monticar/generator/cpp/viewmodel/AutopilotAdapter
Data
Model.java
View file @
fa90d01f
...
...
@@ -20,15 +20,87 @@
*/
package
de.monticore.lang.monticar.generator.cpp.viewmodel
;
public
final
class
AutopilotAdapter
View
Model
extends
ViewModelBase
{
public
final
class
AutopilotAdapter
Data
Model
extends
ViewModelBase
{
private
String
mainModelName
;
private
String
inputCount
;
private
String
outputCount
;
private
String
inputNames
=
""
;
private
String
outputNames
=
""
;
private
String
inputTypes
=
""
;
private
String
outputTypes
=
""
;
private
String
functionDeclarations
=
""
;
private
String
functionImplementations
=
""
;
public
String
getMainModelName
()
{
return
mainModelName
;
}
public
String
getInputCount
()
{
return
inputCount
;
}
public
String
getOutputCount
()
{
return
outputCount
;
}
public
String
getInputNames
()
{
return
inputNames
;
}
public
String
getOutputNames
()
{
return
outputNames
;
}
public
String
getInputTypes
()
{
return
inputTypes
;
}
public
String
getOutputTypes
()
{
return
outputTypes
;
}
public
String
getFunctionDeclarations
()
{
return
functionDeclarations
;
}
public
String
getFunctionImplementations
()
{
return
functionImplementations
;
}
public
void
setMainModelName
(
String
mainModelName
)
{
this
.
mainModelName
=
mainModelName
;
}
public
void
setInputCount
(
int
count
)
{
this
.
inputCount
=
Integer
.
toString
(
count
);
}
public
void
setOutputCount
(
int
count
)
{
this
.
outputCount
=
Integer
.
toString
(
count
);
}
public
void
addInput
(
String
name
,
String
type
){
//Add lines to name and type array
this
.
inputNames
+=
"\n \""
+
name
+
"\","
;
this
.
inputTypes
+=
"\n \""
+
type
+
"\","
;
//Add line to function declarations and implementations
String
functionHeader
=
"EXPORT void set_input_"
+
name
;
if
(
type
.
equals
(
"Q"
)){
functionHeader
+=
"(double v)"
;
this
.
functionImplementations
+=
functionHeader
+
" { AUTOPILOT_INSTANCE."
+
name
+
" = v; }\n"
;
}
else
if
(
type
.
equals
(
"Z"
))
{
functionHeader
+=
"(int v)"
;
this
.
functionImplementations
+=
functionHeader
+
" { AUTOPILOT_INSTANCE."
+
name
+
" = v; }\n"
;
}
else
if
(
type
.
equals
(
"CommonMatrixType"
))
{
functionHeader
+=
"(double *data, int size)"
;
this
.
functionImplementations
+=
functionHeader
+
" { copy_double_array_to_mat( data, size, AUTOPILOT_INSTANCE."
+
name
+
"); }\n"
;
}
this
.
functionDeclarations
+=
functionHeader
+
";\n"
;
}
public
void
addOutput
(
String
name
,
String
type
){
this
.
outputNames
+=
"\n \""
+
name
+
"\","
;
this
.
outputTypes
+=
"\n \""
+
type
+
"\","
;
String
functionHeader
=
""
;
if
(
type
.
equals
(
"Q"
)){
functionHeader
=
"EXPORT double get_output_"
+
name
+
"()"
;
this
.
functionImplementations
+=
functionHeader
+
" { return AUTOPILOT_INSTANCE."
+
name
+
"; }\n"
;
}
this
.
functionDeclarations
+=
functionHeader
+
";\n"
;
}
}
src/main/resources/template/autopilotadapter/AutopilotAdapter.ftl
deleted
100644 → 0
View file @
be5f5860
<#
include
"/Common.ftl">
#
ifndef
AUTOPILOT_ADAPTER
#
define
AUTOPILOT_ADAPTER
#
include
"AutopilotAdapter.h"
#
include
"./$
{
viewModel
.mainModelName
}
.h"
#
include
<stdlib.h>
#
include
<stdio.h>
#
include
<time.h>
#
include
"armadillo.h"
${
viewModel
.mainModelName
}
AUTOPILOT_INSTANCE;
void
copyJLongArrayToMatrix(JNIEnv
*
jenv, jlongArray &source, mat &dest)
{
jsize
len
=
jenv
->
G
etArrayLength
(
source
)
;
if
(
len
<=
0
)
{
return
;
}
jlong
*
body
=
jenv
->
G
etLongArrayElements
(
source
,
0
)
;
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
dest
(
0
,
i
)
=
body
[
i
];
}
jenv
->
R
eleaseLongArrayElements
(
source
,
body
,
0
)
;
}
void
copyJDoubleArrayToMatrix(JNIEnv
*
jenv, jdoubleArray &source, mat &dest)
{
jsize
len
=
jenv
->
G
etArrayLength
(
source
)
;
if
(
len
<=
0
)
{
return
;
}
jdouble
*
body
=
jenv
->
G
etDoubleArrayElements
(
source
,
0
)
;
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
dest
(
0
,
i
)
=
body
[
i
];
}
jenv
->
R
eleaseDoubleArrayElements
(
source
,
body
,
0
)
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: set_timeIncrement
*
Signature: (D)V
*
/
JNIEXPORT
void JNICALL Java_simulator_integration_AutopilotAdapter_set_1timeIncrement
(JNIEnv
*
jenv, jobject jobj, jdouble v)
{
AUTOPILOT
_
INSTANCE
.timeIncrement
=
v
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: set_currentVelocity
*
Signature: (D)V
*
/
JNIEXPORT
void JNICALL Java_simulator_integration_AutopilotAdapter_set_1currentVelocity
(JNIEnv
*
jenv, jobject jobj, jdouble v)
{
AUTOPILOT
_
INSTANCE
.currentVelocity
=
v
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: set_currentGpsLat
*
Signature: (D)V
*
/
JNIEXPORT
void JNICALL Java_simulator_integration_AutopilotAdapter_set_1x
(JNIEnv
*
jenv, jobject jobj, jdouble v)
{
AUTOPILOT
_
INSTANCE
.x
=
v
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: set_currentGpsLon
*
Signature: (D)V
*
/
JNIEXPORT
void JNICALL Java_simulator_integration_AutopilotAdapter_set_1y
(JNIEnv
*
jenv, jobject jobj, jdouble v)
{
AUTOPILOT
_
INSTANCE
.y
=
v
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: set_compass
*
Signature: (D)V
*
/
JNIEXPORT
void JNICALL Java_simulator_integration_AutopilotAdapter_set_1compass
(JNIEnv
*
jenv, jobject jobj, jdouble v)
{
AUTOPILOT
_
INSTANCE
.compass
=
v
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: set_currentEngine
*
Signature: (D)V
*
/
JNIEXPORT
void JNICALL Java_simulator_integration_AutopilotAdapter_set_1currentEngine
(JNIEnv
*
jenv, jobject jobj, jdouble v)
{
AUTOPILOT
_
INSTANCE
.currentEngine
=
v
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: set_currentSteering
*
Signature: (D)V
*
/
JNIEXPORT
void JNICALL Java_simulator_integration_AutopilotAdapter_set_1currentSteering
(JNIEnv
*
jenv, jobject jobj, jdouble v)
{
AUTOPILOT
_
INSTANCE
.currentSteering
=
v
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: set_currentBrakes
*
Signature: (D)V
*
/
JNIEXPORT
void JNICALL Java_simulator_integration_AutopilotAdapter_set_1currentBrakes
(JNIEnv
*
jenv, jobject jobj, jdouble v)
{
AUTOPILOT
_
INSTANCE
.currentBrakes
=
v
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: set_addNodes_length
*
Signature: (I)V
*
/
JNIEXPORT
void JNICALL Java_simulator_integration_AutopilotAdapter_set_1trajectory_1length
(JNIEnv
*
jenv, jobject jobj, jint v)
{
AUTOPILOT
_
INSTANCE
.trajectory_length
=
v
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: set_addNodes_gpsLat
*
Signature: ([D)V
*
/
JNIEXPORT
void JNICALL Java_simulator_integration_AutopilotAdapter_set_1trajectory_1x
(JNIEnv
*
jenv, jobject jobj, jdoubleArray v)
{
copyJDoubleArrayToMatrix
(
jenv
,
v
,
AUTOPILOT
_
INSTANCE
.trajectory_x
)
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: set_addNodes_gpsLon
*
Signature: ([D)V
*
/
JNIEXPORT
void JNICALL Java_simulator_integration_AutopilotAdapter_set_1trajectory_1y
(JNIEnv
*
jenv, jobject jobj, jdoubleArray v)
{
copyJDoubleArrayToMatrix
(
jenv
,
v
,
AUTOPILOT
_
INSTANCE
.trajectory_y
)
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: get_engine
*
Signature: ()D
*
/
JNIEXPORT
jdouble JNICALL Java_simulator_integration_AutopilotAdapter_get_1engine
(JNIEnv
*
jenv, jobject jobj)
{
return
AUTOPILOT
_
INSTANCE
.engine
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: get_steering
*
Signature: ()D
*
/
JNIEXPORT
jdouble JNICALL Java_simulator_integration_AutopilotAdapter_get_1steering
(JNIEnv
*
jenv, jobject jobj)
{
return
AUTOPILOT
_
INSTANCE
.steering
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: get_brakes
*
Signature: ()D
*
/
JNIEXPORT
jdouble JNICALL Java_simulator_integration_AutopilotAdapter_get_1brakes
(JNIEnv
*
jenv, jobject jobj)
{
return
AUTOPILOT
_
INSTANCE
.brakes
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: exec
*
Signature: ()V
*
/
JNIEXPORT
void JNICALL Java_simulator_integration_AutopilotAdapter_exec
(JNIEnv
*
jenv, jobject jobj)
{
AUTOPILOT
_
INSTANCE
.execute
()
;
}
/*
*
Class: simulator_integration_AutopilotAdapter
*
Method: init
*
Signature: ()V
*
/
JNIEXPORT
void JNICALL Java_simulator_integration_AutopilotAdapter_init
(JNIEnv
*
jenv, jobject jobj)
{
srand
(
time
(
NULL
))
;
AUTOPILOT
_
INSTANCE
.init
()
;
}
#
endif
src/main/resources/template/autopilotadapter/AutopilotAdapter.h
deleted
100644 → 0
View file @
be5f5860
/* DO NOT EDIT THIS FILE - it is machine generated */
#include
<jni.h>
/* Header for class simulator_integration_AutopilotAdapter */
#ifndef _Included_simulator_integration_AutopilotAdapter
#define _Included_simulator_integration_AutopilotAdapter
#ifdef __cplusplus
extern
"C"
{
#endif
/*
* Class: simulator_integration_AutopilotAdapter
* Method: set_timeIncrement
* Signature: (D)V
*/
JNIEXPORT
void
JNICALL
Java_simulator_integration_AutopilotAdapter_set_1timeIncrement
(
JNIEnv
*
,
jobject
,
jdouble
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: set_currentVelocity
* Signature: (D)V
*/
JNIEXPORT
void
JNICALL
Java_simulator_integration_AutopilotAdapter_set_1currentVelocity
(
JNIEnv
*
,
jobject
,
jdouble
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: set_x
* Signature: (D)V
*/
JNIEXPORT
void
JNICALL
Java_simulator_integration_AutopilotAdapter_set_1x
(
JNIEnv
*
,
jobject
,
jdouble
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: set_y
* Signature: (D)V
*/
JNIEXPORT
void
JNICALL
Java_simulator_integration_AutopilotAdapter_set_1y
(
JNIEnv
*
,
jobject
,
jdouble
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: set_compass
* Signature: (D)V
*/
JNIEXPORT
void
JNICALL
Java_simulator_integration_AutopilotAdapter_set_1compass
(
JNIEnv
*
,
jobject
,
jdouble
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: set_currentEngine
* Signature: (D)V
*/
JNIEXPORT
void
JNICALL
Java_simulator_integration_AutopilotAdapter_set_1currentEngine
(
JNIEnv
*
,
jobject
,
jdouble
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: set_currentSteering
* Signature: (D)V
*/
JNIEXPORT
void
JNICALL
Java_simulator_integration_AutopilotAdapter_set_1currentSteering
(
JNIEnv
*
,
jobject
,
jdouble
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: set_currentBrakes
* Signature: (D)V
*/
JNIEXPORT
void
JNICALL
Java_simulator_integration_AutopilotAdapter_set_1currentBrakes
(
JNIEnv
*
,
jobject
,
jdouble
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: set_trajectory_length
* Signature: (I)V
*/
JNIEXPORT
void
JNICALL
Java_simulator_integration_AutopilotAdapter_set_1trajectory_1length
(
JNIEnv
*
,
jobject
,
jint
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: set_trajectory_x
* Signature: ([D)V
*/
JNIEXPORT
void
JNICALL
Java_simulator_integration_AutopilotAdapter_set_1trajectory_1x
(
JNIEnv
*
,
jobject
,
jdoubleArray
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: set_trajectory_y
* Signature: ([D)V
*/
JNIEXPORT
void
JNICALL
Java_simulator_integration_AutopilotAdapter_set_1trajectory_1y
(
JNIEnv
*
,
jobject
,
jdoubleArray
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: get_engine
* Signature: ()D
*/
JNIEXPORT
jdouble
JNICALL
Java_simulator_integration_AutopilotAdapter_get_1engine
(
JNIEnv
*
,
jobject
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: get_steering
* Signature: ()D
*/
JNIEXPORT
jdouble
JNICALL
Java_simulator_integration_AutopilotAdapter_get_1steering
(
JNIEnv
*
,
jobject
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: get_brakes
* Signature: ()D
*/
JNIEXPORT
jdouble
JNICALL
Java_simulator_integration_AutopilotAdapter_get_1brakes
(
JNIEnv
*
,
jobject
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: exec
* Signature: ()V
*/
JNIEXPORT
void
JNICALL
Java_simulator_integration_AutopilotAdapter_exec
(
JNIEnv
*
,
jobject
);
/*
* Class: simulator_integration_AutopilotAdapter
* Method: init
* Signature: ()V
*/
JNIEXPORT
void
JNICALL
Java_simulator_integration_AutopilotAdapter_init
(
JNIEnv
*
,
jobject
);
#ifdef __cplusplus
}
#endif
#endif
src/main/resources/template/autopilotadapter/AutopilotAdapterCpp.ftl
0 → 100644
View file @
fa90d01f
<#
include
"/Common.ftl">
#
include
"AutopilotAdapter.h"
#
include
"./$
{
viewModel
.mainModelName
}
.h"
#
include
<stdlib.h>
#
include
<stdio.h>
#
include
<time.h>
#
include
"armadillo.h"
void
copy_double_array_to_mat(double
*
data, int size, mat &dest)
{
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
dest
(
0
,
i
)
=
data
[
i
];
}
}
${
viewModel
.mainModelName
}
AUTOPILOT_INSTANCE;
int
input_count = $
{
viewModel
.inputCount
}
;
int
output_count = $
{
viewModel
.outputCount
}
;
const
char
*
input_names[] =
{
$
{
viewModel
.inputNames
}
}
;
const
char
*
output_names[] =
{
$
{
viewModel
.outputNames
}
}
;
const
char
*
input_types[] =
{
$
{
viewModel
.inputTypes
}
}
;
const
char
*
output_types[] =
{
$
{
viewModel
.outputTypes
}
}
;
extern
"C"
{
EXPORT
int
get_input_count
(){
return
input_count
;
}
EXPORT
const
char
*
get_input_name
(
int
id
){
return
input_names
[
id
]
;
}
EXPORT
const
char
*
get_input_type
(
int
id
){
return
input_types
[
id
]
;
}
EXPORT
int
get_output_count
(){
return
output_count
;
}
EXPORT
const
char
*
get_output_name
(
int
id
){
return
output_names
[
id
]
;
}
EXPORT
const
char
*
get_output_type
(
int
id
){
return
output_types
[
id
]
;
}
EXPORT
void
init
(){
srand
(
time
(
NULL
))
;
AUTOPILOT
_
INSTANCE
.init
()
;
}
EXPORT
void
execute
(){
AUTOPILOT
_
INSTANCE
.execute
()
;
}
$
{
viewModel
.functionImplementations
}
}
\ No newline at end of file
src/main/resources/template/autopilotadapter/AutopilotAdapterH.ftl
0 → 100644
View file @
fa90d01f
<#
include
"/Common.ftl">
#
pragma
once
#
if
defined(_MSC_VER)
// Microsoft
#define EXPORT __declspec(dllexport)
#define IMPORT __declspec(dllimport)
#
elif
defined(__GNUC__)