Annotations in C++ code to produce formulas in rusEfi console #807

This commit is contained in:
rusefi 2019-07-13 09:00:03 -04:00
parent 7cc040afe0
commit 9e461e7c27
10 changed files with 62 additions and 32 deletions

View File

@ -248,6 +248,21 @@ static void onlineApplyWorkingCopyBytes(int currentPageId, uint32_t offset, int
}
}
static const void *addr getStructAddr(int structId) {
switch (structId) {
case LDS_CLT_INDEX:
return static_cast<thermistor_state_s*>(&engine->engineState.cltCurve);
case LDS_IAT_INDEX:
return static_cast<thermistor_state_s*>(&engine->engineState.iatCurve);
case LDS_ENGINE_STATE_INDEX:
return static_cast<engine_state2_s*>(&engine->engineState);
case LDS_FUEL_TRIM_INDEX:
return static_cast<wall_fuel_state*>(&engine->wallFuel);
default:
return NULL;
}
}
/**
* Read internal structure for Live Doc
* This is somewhat similar to read page and somewhat similar to read outputs
@ -256,14 +271,7 @@ static void onlineApplyWorkingCopyBytes(int currentPageId, uint32_t offset, int
static void handleGetStructContent(ts_channel_s *tsChannel, int structId, int size) {
tsState.readPageCommandsCounter++;
const void *addr = NULL;
if (structId == LDS_CLT_INDEX) {
addr = static_cast<thermistor_state_s*>(&engine->engineState.cltCurve);
} else if (structId == LDS_IAT_INDEX) {
addr = static_cast<thermistor_state_s*>(&engine->engineState.iatCurve);
} else if (structId == LDS_ENGINE_STATE_INDEX) {
addr = static_cast<engine_state2_s*>(&engine->engineState);
}
const void *addr = getStructAddr(structId);
if (addr == NULL) {
// todo: add warning code - unexpected structId
return;

View File

@ -94,7 +94,7 @@ floatms_t WallFuel::adjust(int injectorIndex, floatms_t desiredFuel DECLARE_ENGI
// if tau is really small, we get div/0.
// you probably meant to disable wwae.
float tau = CONFIG(wwaeTau);
float tau = CONFIG(DISPLAY_CONFIG(wwaeTau));
if (tau < 0.01f) {
return desiredFuel;
}
@ -106,7 +106,7 @@ floatms_t WallFuel::adjust(int injectorIndex, floatms_t desiredFuel DECLARE_ENGI
}
float alpha = expf_taylor(-120 / (rpm * tau));
float beta = CONFIG(wwaeBeta);
float beta = CONFIG(DISPLAY_CONFIG(wwaeBeta));
// If beta is larger than alpha, the system is underdamped.
// For reasonable values {tau, beta}, this should only be possible
@ -129,8 +129,11 @@ floatms_t WallFuel::adjust(int injectorIndex, floatms_t desiredFuel DECLARE_ENGI
// remainder on walls from last time + new from this time
float fuelFilmMassNext = alpha * fuelFilmMass + beta * M_cmd;
wallFuel/*[injectorIndex]*/ = fuelFilmMassNext;
wallFuelCorrection = M_cmd - desiredFuel;
DISPLAY_TEXT(Current_Wall_Fuel_Film);
DISPLAY_FIELD(wallFuel)/*[injectorIndex]*/ = fuelFilmMassNext;
DISPLAY_TEXT(Fuel correction);
DISPLAY_FIELD(wallFuelCorrection) = M_cmd - desiredFuel;
DISPLAY_TEXT(ms);
return M_cmd;
}

View File

@ -32,6 +32,7 @@
#include "loggingcentral.h"
#endif /* __cplusplus */
// See also 'TS_GET_STRUCT'
#define DISPLAY_CONFIG(x) x
#define DISPLAY_FIELD(x) x
// we use this 'DISPLAY' macro if value is not used by C++ in current context

View File

@ -1323,8 +1323,11 @@
#define lcdThreadPeriodMs_offset_hex 2d0
#define LDS_CLT_INDEX 0
#define LDS_ENGINE_STATE_INDEX 3
#define LDS_FUEL_TRIM_INDEX 4
#define LDS_IAT_INDEX 1
#define LDS_SPEED_DENSITY_INDEX 2
#define LDS_TPS_TPS_ENEICHMENT_INDEX 5
#define LDS_TRIGGER_INDEX 6
#define LE_COMMAND_LENGTH 200
#define LIS302DLCsPin_offset 2043
#define LIS302DLCsPin_offset_hex 7fb

View File

@ -2,6 +2,11 @@ rem TODO better place for this stuff, more automation so that each file does not
rm gen_config2.log
set LIVE_DOCS_COMMAND=java -DSystemOut.name=gen_config2 ^
-cp ../java_tools/ConfigDefinition.jar ^
com.rusefi.ldmp.LiveDocsMetaParser ^
"../"
java -DSystemOut.name=gen_config2 ^
-jar ../java_tools/ConfigDefinition.jar ^
-definition integration/engine_state.txt ^
@ -24,23 +29,9 @@ java -DSystemOut.name=gen_config2 ^
-java_destination ../java_console/models/src/com/rusefi/config/generated/TriggerState.java ^
-c_destination controllers/generated/trigger_structs.h
java -DSystemOut.name=gen_config2 ^
-cp ../java_tools/ConfigDefinition.jar ^
com.rusefi.ldmp.LiveDocsMetaParser ^
controllers/sensors/thermistors.cpp ^
"../"
java -DSystemOut.name=gen_config2 ^
-cp ../java_tools/ConfigDefinition.jar ^
com.rusefi.ldmp.LiveDocsMetaParser ^
controllers/sensors/tps.cpp ^
"../"
java -DSystemOut.name=gen_config2 ^
-cp ../java_tools/ConfigDefinition.jar ^
com.rusefi.ldmp.LiveDocsMetaParser ^
controllers/math/speed_density.cpp ^
"../"
%LIVE_DOCS_COMMAND% controllers/sensors/thermistors.cpp
%LIVE_DOCS_COMMAND% controllers/sensors/tps.cpp
%LIVE_DOCS_COMMAND% controllers/math/speed_density.cpp
java -DSystemOut.name=gen_config2 ^
-jar ../java_tools/ConfigDefinition.jar ^
@ -49,3 +40,4 @@ java -DSystemOut.name=gen_config2 ^
-java_destination ../java_console/models/src/com/rusefi/config/generated/WallFuelState.java ^
-c_destination controllers/generated/wall_fuel.h
%LIVE_DOCS_COMMAND% controllers/algo/accel_enrichment.cpp

View File

@ -1155,6 +1155,10 @@ end_struct
#define LDS_IAT_INDEX 1
#define LDS_SPEED_DENSITY_INDEX 2
#define LDS_ENGINE_STATE_INDEX 3
#define LDS_FUEL_TRIM_INDEX 4
#define LDS_TPS_TPS_ENEICHMENT_INDEX 5
#define LDS_TRIGGER_INDEX 6
#define GAUGE_NAME_VERSION "firmware"
#define GAUGE_NAME_VVT "VVT position"

View File

@ -1,6 +1,6 @@
package com.rusefi.config.generated;
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Fri Jul 12 14:02:49 EDT 2019
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sat Jul 13 08:43:50 EDT 2019
import com.rusefi.config.*;
@ -865,8 +865,11 @@ public class Fields {
public static final int lcdThreadPeriodMs_offset = 720;
public static final int LDS_CLT_INDEX = 0;
public static final int LDS_ENGINE_STATE_INDEX = 3;
public static final int LDS_FUEL_TRIM_INDEX = 4;
public static final int LDS_IAT_INDEX = 1;
public static final int LDS_SPEED_DENSITY_INDEX = 2;
public static final int LDS_TPS_TPS_ENEICHMENT_INDEX = 5;
public static final int LDS_TRIGGER_INDEX = 6;
public static final int LE_COMMAND_LENGTH = 200;
public static final int LIS302DLCsPin_offset = 2043;
public static final int logFormat_offset = 496;

View File

@ -0,0 +1,15 @@
package com.rusefi.ldmp.generated;
import com.rusefi.ldmp.*;
public class AccelEnrichmentMeta {
public static final Request[] CONTENT = new Request[]{
new ConfigRequest("wwaeTau"),
new ConfigRequest("wwaeBeta"),
new TextRequest("Current_Wall_Fuel_Film"),
new FieldRequest("wallFuel"),
new TextRequest("Fuel"),
new FieldRequest("wallFuelCorrection"),
new TextRequest("ms"),
};
}

Binary file not shown.

View File

@ -33,8 +33,8 @@ public class LiveDocsMetaParser {
public static void main(String[] args) throws IOException {
if (args.length != 2)
throw new IllegalArgumentException("Two arguments expected but " + Arrays.toString(args));
String fileName = args[0];
String destinationPath = args[1];
String destinationPath = args[0];
String fileName = args[1];
MetaInfo metaInfo = getMetaFromFile(fileName);
SystemOut.println(metaInfo);
@ -43,6 +43,7 @@ public class LiveDocsMetaParser {
FileWriter fw = new FileWriter(destinationPath + "java_console/ui/src/com/rusefi/ldmp/generated/" + className + ".java");
fw.write(javaCode);
fw.close();
SystemOut.close();
}
private static MetaInfo getMetaFromFile(String fileName) throws IOException {