rusefi-1/unit_tests/native/native_impl.cpp

60 lines
1.6 KiB
C++
Raw Normal View History

2022-02-26 09:51:50 -08:00
/*
* native_impl.cpp
*
* @date Feb 26, 2022
* @author Andrey Belomutskiy, (c) 2012-2022
*/
2022-02-26 14:48:07 -08:00
#include "pch.h"
#include "com_rusefi_native__EngineLogic.h"
2022-03-12 20:47:38 -08:00
#include "auto_generated_sensor.h"
2022-02-26 09:51:50 -08:00
#include <memory>
static std::unique_ptr<EngineTestHelper> eth;
static EngineTestHelper* getEth() {
if (!eth) {
eth = std::make_unique<EngineTestHelper>(TEST_ENGINE);
}
return eth.get();
}
2022-02-28 09:29:02 -08:00
2022-02-26 14:48:07 -08:00
JNIEXPORT jstring JNICALL Java_com_rusefi_native_1_EngineLogic_getVersion(JNIEnv * env, jobject) {
const char msg[60] = "Hello from unit tests";
const char* fileName = msg;
jstring result = env->NewStringUTF(msg);
2022-02-28 09:29:02 -08:00
printf("[native] hello\n");
2022-02-26 14:48:07 -08:00
return result;
}
2022-02-26 09:51:50 -08:00
2022-03-12 20:47:38 -08:00
JNIEXPORT jbyteArray JNICALL Java_com_rusefi_native_1_EngineLogic_getConfiguration(JNIEnv *env, jobject instance) {
2022-02-28 09:29:02 -08:00
return nullptr;
}
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_setConfiguration(JNIEnv *env, jobject instance,
jbyteArray data, jint offset, jint size) {
printf("[native] setConfiguration %d %d\n", offset, size);
// printf("[native] engine %d %d\n", engineConfiguration->engineType);
}
2022-03-12 20:47:38 -08:00
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_setSensor
(JNIEnv *env, jobject instance, jstring sensorName, jdouble sensorValue) {
const char *sensorNameNative = env->GetStringUTFChars(sensorName, 0);
SensorType type = findSensorTypeByName(sensorNameNative);
printf("Setting [%s] to %f\n", getSensorType(type), sensorValue);
Sensor::setMockValue(type, sensorValue);
env->ReleaseStringUTFChars(sensorName, sensorNameNative);
}
2022-03-12 21:06:26 -08:00
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_invokePeriodicCallback
(JNIEnv *, jobject) {
EngineTestHelper* eth = getEth();
2022-03-12 21:06:26 -08:00
}