ETB JNI test progress
This commit is contained in:
parent
181b5b2ed8
commit
1d4a454f0c
|
@ -223,6 +223,7 @@ void EtbController::onConfigurationChange(pid_s* previousConfiguration) {
|
||||||
}
|
}
|
||||||
m_dutyRocAverage.init(engineConfiguration->etbRocExpAverageLength);
|
m_dutyRocAverage.init(engineConfiguration->etbRocExpAverageLength);
|
||||||
m_dutyAverage.init(engineConfiguration->etbExpAverageLength);
|
m_dutyAverage.init(engineConfiguration->etbExpAverageLength);
|
||||||
|
doInitElectronicThrottle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EtbController::showStatus() {
|
void EtbController::showStatus() {
|
||||||
|
@ -555,10 +556,12 @@ void EtbController::setOutput(expected<percent_t> outputValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EtbController::update() {
|
void EtbController::update() {
|
||||||
|
#if !EFI_UNIT_TEST
|
||||||
// If we didn't get initialized, fail fast
|
// If we didn't get initialized, fail fast
|
||||||
if (!m_motor) {
|
if (!m_motor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif // EFI_UNIT_TEST
|
||||||
|
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
// Only debug throttle #1
|
// Only debug throttle #1
|
||||||
|
@ -944,6 +947,11 @@ static pid_s* getEtbPidForFunction(etb_function_e function) {
|
||||||
|
|
||||||
void doInitElectronicThrottle() {
|
void doInitElectronicThrottle() {
|
||||||
bool shouldInitThrottles = Sensor::hasSensor(SensorType::AcceleratorPedalPrimary);
|
bool shouldInitThrottles = Sensor::hasSensor(SensorType::AcceleratorPedalPrimary);
|
||||||
|
|
||||||
|
#if EFI_UNIT_TEST
|
||||||
|
printf("doInitElectronicThrottle %s\n", boolToString(shouldInitThrottles));
|
||||||
|
#endif // EFI_UNIT_TEST
|
||||||
|
|
||||||
engineConfiguration->etb1configured = engineConfiguration->etb2configured = false;
|
engineConfiguration->etb1configured = engineConfiguration->etb2configured = false;
|
||||||
|
|
||||||
// todo: technical debt: we still have DC motor code initialization in ETB-specific file while DC motors are used not just as ETB
|
// todo: technical debt: we still have DC motor code initialization in ETB-specific file while DC motors are used not just as ETB
|
||||||
|
|
|
@ -400,7 +400,7 @@ static void initConfigActions() {
|
||||||
void commonInitEngineController() {
|
void commonInitEngineController() {
|
||||||
initInterpolation();
|
initInterpolation();
|
||||||
|
|
||||||
#if EFI_SIMULATOR
|
#if EFI_SIMULATOR || EFI_UNIT_TEST
|
||||||
printf("commonInitEngineController\n");
|
printf("commonInitEngineController\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ public class EngineLogic {
|
||||||
|
|
||||||
public native void setEngineType(int engineType);
|
public native void setEngineType(int engineType);
|
||||||
|
|
||||||
|
public native void initTps();
|
||||||
|
|
||||||
public native void invokePeriodicCallback();
|
public native void invokePeriodicCallback();
|
||||||
|
|
||||||
public native void invokeEtbCycle();
|
public native void invokeEtbCycle();
|
||||||
|
|
|
@ -51,6 +51,26 @@ public class JniUnitTest {
|
||||||
JniSandbox.loadLibrary();
|
JniSandbox.loadLibrary();
|
||||||
|
|
||||||
EngineLogic engineLogic = new EngineLogic();
|
EngineLogic engineLogic = new EngineLogic();
|
||||||
|
|
||||||
|
engineLogic.setSensor(SensorType.Tps1Primary.name(), 30);
|
||||||
|
engineLogic.setSensor(SensorType.Tps1Secondary.name(), 30);
|
||||||
|
|
||||||
|
engineLogic.burnRequest(); // hack: this is here to initialize engine helper prior to mocking sensors
|
||||||
|
|
||||||
|
engineLogic.setSensor(SensorType.AcceleratorPedalPrimary.name(), 40);
|
||||||
|
engineLogic.setSensor(SensorType.AcceleratorPedalSecondary.name(), 40);
|
||||||
|
|
||||||
|
engineLogic.setConfiguration(new byte[]{3}, Fields.TPS1_1ADCCHANNEL.getTotalOffset(), 1);
|
||||||
|
engineLogic.setConfiguration(new byte[]{3}, Fields.TPS1_2ADCCHANNEL.getTotalOffset(), 1);
|
||||||
|
engineLogic.setConfiguration(new byte[]{3}, Fields.THROTTLEPEDALPOSITIONADCCHANNEL.getTotalOffset(), 1);
|
||||||
|
engineLogic.setConfiguration(new byte[]{3}, Fields.THROTTLEPEDALPOSITIONSECONDADCCHANNEL.getTotalOffset(), 1);
|
||||||
|
|
||||||
|
engineLogic.initTps();
|
||||||
|
engineLogic.burnRequest();
|
||||||
|
System.out.println("engineLogic.invokeEtbCycle");
|
||||||
|
engineLogic.invokeEtbCycle();
|
||||||
|
|
||||||
|
assertEquals(120.36, getValue(engineLogic.getOutputs(), Sensor.etb1DutyCycle));
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getField(EngineLogic engineLogic, Field field) {
|
private double getField(EngineLogic engineLogic, Field field) {
|
||||||
|
|
|
@ -47,6 +47,14 @@ JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_setConfiguration
|
||||||
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_setEngineType
|
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_setEngineType
|
||||||
(JNIEnv *, jobject, jint);
|
(JNIEnv *, jobject, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: com_rusefi_native__EngineLogic
|
||||||
|
* Method: initTps
|
||||||
|
* Signature: ()V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_initTps
|
||||||
|
(JNIEnv *, jobject);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: com_rusefi_native__EngineLogic
|
* Class: com_rusefi_native__EngineLogic
|
||||||
* Method: invokePeriodicCallback
|
* Method: invokePeriodicCallback
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "auto_generated_sensor.h"
|
#include "auto_generated_sensor.h"
|
||||||
#include "tunerstudio.h"
|
#include "tunerstudio.h"
|
||||||
#include "live_data.h"
|
#include "live_data.h"
|
||||||
|
#include "init.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -17,6 +18,7 @@ static std::unique_ptr<EngineTestHelper> ethPtr;
|
||||||
|
|
||||||
static EngineTestHelper* getEth() {
|
static EngineTestHelper* getEth() {
|
||||||
if (!ethPtr) {
|
if (!ethPtr) {
|
||||||
|
printf("make_unique<EngineTestHelper>(TEST_ENGINE)\n");
|
||||||
ethPtr = std::make_unique<EngineTestHelper>(TEST_ENGINE);
|
ethPtr = std::make_unique<EngineTestHelper>(TEST_ENGINE);
|
||||||
}
|
}
|
||||||
return ethPtr.get();
|
return ethPtr.get();
|
||||||
|
@ -97,9 +99,17 @@ JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_invokeEtbCycle
|
||||||
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_burnRequest
|
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_burnRequest
|
||||||
(JNIEnv *, jobject) {
|
(JNIEnv *, jobject) {
|
||||||
printf("[native] onBurnRequest\n");
|
printf("[native] onBurnRequest\n");
|
||||||
|
getEth();// just to make sure we have initialized
|
||||||
onBurnRequest();
|
onBurnRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_com_rusefi_native_1_EngineLogic_initTps
|
||||||
|
(JNIEnv *, jobject) {
|
||||||
|
printf("[native] initTps\n");
|
||||||
|
getEth();// just to make sure we have initialized
|
||||||
|
initTps();
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jbyteArray JNICALL Java_com_rusefi_native_1_EngineLogic_getOutputs(JNIEnv * env, jobject instance) {
|
JNIEXPORT jbyteArray JNICALL Java_com_rusefi_native_1_EngineLogic_getOutputs(JNIEnv * env, jobject instance) {
|
||||||
jbyteArray retVal = env->NewByteArray(TS_TOTAL_OUTPUT_SIZE);
|
jbyteArray retVal = env->NewByteArray(TS_TOTAL_OUTPUT_SIZE);
|
||||||
jbyte *buf = env->GetByteArrayElements(retVal, NULL);
|
jbyte *buf = env->GetByteArrayElements(retVal, NULL);
|
||||||
|
|
Loading…
Reference in New Issue