logging of live data structs was: data points #3614

progress
This commit is contained in:
rusefillc 2022-04-16 21:03:50 -04:00
parent 54be720fca
commit 0ba512c925
8 changed files with 22 additions and 17 deletions

View File

@ -315,9 +315,6 @@ expected<percent_t> EtbController::getSetpointEtb() {
// 100% target from table -> 100% target position // 100% target from table -> 100% target position
idlePosition = interpolateClamped(0, etbIdleAddition, 100, 100, targetFromTable); idlePosition = interpolateClamped(0, etbIdleAddition, 100, 100, targetFromTable);
// Apply any adjustment from Lua
luaAdjustment = engine->engineState.luaAdjustments.etbTargetPositionAdd;
percent_t targetPosition = idlePosition + luaAdjustment; percent_t targetPosition = idlePosition + luaAdjustment;
// Apply any adjustment that this throttle alone needs // Apply any adjustment that this throttle alone needs

View File

@ -24,7 +24,7 @@
#define ETB_LOOP_FREQUENCY 500 #define ETB_LOOP_FREQUENCY 500
#define DEFAULT_ETB_PWM_FREQUENCY 800 #define DEFAULT_ETB_PWM_FREQUENCY 800
class EtbController : public IEtbController, electronic_throttle_s { class EtbController : public IEtbController, public electronic_throttle_s {
public: public:
bool init(etb_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles) override; bool init(etb_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles) override;
void setIdlePosition(percent_t pos) override; void setIdlePosition(percent_t pos) override;

View File

@ -19,5 +19,8 @@ size_t getMultiSparkCount(int rpm);
class IgnitionState : public ignition_state_s { class IgnitionState : public ignition_state_s {
public: public:
IgnitionState() {
luaTimingMult = 1;
}
floatms_t getSparkDwell(int rpm); floatms_t getSparkDwell(int rpm);
}; };

View File

@ -40,6 +40,7 @@
#include "gear_detector.h" #include "gear_detector.h"
#include "advance_map.h" #include "advance_map.h"
#include "fan_control.h" #include "fan_control.h"
#include "electronic_throttle_impl.h"
#ifndef EFI_UNIT_TEST #ifndef EFI_UNIT_TEST
#error EFI_UNIT_TEST must be defined! #error EFI_UNIT_TEST must be defined!
@ -166,7 +167,7 @@ public:
PinRepository pinRepository; PinRepository pinRepository;
IEtbController *etbControllers[ETB_COUNT] = {nullptr}; EtbController *etbControllers[ETB_COUNT] = {nullptr};
IFuelComputer *fuelComputer = nullptr; IFuelComputer *fuelComputer = nullptr;
type_list< type_list<

View File

@ -143,7 +143,7 @@ void EngineState::periodicFastCallback() {
injectionOffset = getInjectionOffset(rpm, fuelLoad); injectionOffset = getInjectionOffset(rpm, fuelLoad);
float ignitionLoad = getIgnitionLoad(); float ignitionLoad = getIgnitionLoad();
float advance = getAdvance(rpm, ignitionLoad) * luaAdjustments.ignitionTimingMult + luaAdjustments.ignitionTimingAdd; float advance = getAdvance(rpm, ignitionLoad) * engine->ignitionState.luaTimingMult + engine->ignitionState.luaTimingAdd;
// compute per-bank fueling // compute per-bank fueling
for (size_t i = 0; i < STFT_BANK_COUNT; i++) { for (size_t i = 0; i < STFT_BANK_COUNT; i++) {

View File

@ -14,11 +14,9 @@
#include "engine_state_generated.h" #include "engine_state_generated.h"
struct LuaAdjustments { struct LuaAdjustments {
float ignitionTimingAdd = 0;
float ignitionTimingMult = 1;
float fuelAdd = 0; float fuelAdd = 0;
float fuelMult = 1; float fuelMult = 1;
float etbTargetPositionAdd = 0;
bool clutchUpState = false; bool clutchUpState = false;
bool brakePedalState = false; bool brakePedalState = false;
}; };

View File

@ -522,7 +522,7 @@ void configureRusefiLuaHooks(lua_State* l) {
lua_register(l, "setTimingMult", [](lua_State* l) { lua_register(l, "setTimingMult", [](lua_State* l) {
engine->engineState.luaAdjustments.ignitionTimingMult = luaL_checknumber(l, 1); engine->ignitionState.luaTimingMult = luaL_checknumber(l, 1);
return 0; return 0;
}); });
lua_register(l, "setFuelAdd", [](lua_State* l) { lua_register(l, "setFuelAdd", [](lua_State* l) {
@ -534,7 +534,10 @@ void configureRusefiLuaHooks(lua_State* l) {
return 0; return 0;
}); });
lua_register(l, "setEtbAdd", [](lua_State* l) { lua_register(l, "setEtbAdd", [](lua_State* l) {
engine->engineState.luaAdjustments.etbTargetPositionAdd = luaL_checknumber(l, 1); auto luaAdjustment = luaL_checknumber(l, 1);
for (int i = 0 ; i < ETB_COUNT; i++) {
engine->etbControllers[i]->luaAdjustment = luaAdjustment;
}
return 0; return 0;
}); });
@ -602,7 +605,7 @@ void configureRusefiLuaHooks(lua_State* l) {
}); });
lua_register(l, "setTimingAdd", [](lua_State* l) { lua_register(l, "setTimingAdd", [](lua_State* l) {
engine->engineState.luaAdjustments.ignitionTimingAdd = luaL_checknumber(l, 1); engine->ignitionState.luaTimingAdd = luaL_checknumber(l, 1);
return 0; return 0;
}); });

View File

@ -157,11 +157,14 @@ public enum Sensor {
instantMAP("Instant " + GAUGE_NAME_MAP, SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 514, 1.0 / PACK_MULT_PRESSURE, 20, 300, "kPa"), instantMAP("Instant " + GAUGE_NAME_MAP, SensorCategory.SENSOR_INPUTS, FieldType.UINT16, 514, 1.0 / PACK_MULT_PRESSURE, 20, 300, "kPa"),
baseDwell("", SensorCategory.SENSOR_INPUTS, FieldType.INT, 972, 1.0, -1.0, -1.0, ""), targetRpmAcBump("targetRpmAcBump", SensorCategory.SENSOR_INPUTS, FieldType.INT, 968, 1.0, -1.0, -1.0, ""),
dwellVoltageCorrection("", SensorCategory.SENSOR_INPUTS, FieldType.INT, 976, 1.0, -1.0, -1.0, ""), baseDwell("baseDwell", SensorCategory.SENSOR_INPUTS, FieldType.INT, 972, 1.0, -1.0, -1.0, ""),
etb_idlePosition("", SensorCategory.SENSOR_INPUTS, FieldType.INT, 980, 1.0, -1.0, -1.0, ""), dwellVoltageCorrection("dwellVoltageCorrection", SensorCategory.SENSOR_INPUTS, FieldType.INT, 976, 1.0, -1.0, -1.0, ""),
trim("", SensorCategory.SENSOR_INPUTS, FieldType.INT, 984, 1.0, -1.0, -1.0, ""), luaTimingAdd("luaTimingAdd", SensorCategory.SENSOR_INPUTS, FieldType.INT, 980, 1.0, -1.0, -1.0, ""),
luaAdjustment("", SensorCategory.SENSOR_INPUTS, FieldType.INT, 988, 1.0, -1.0, -1.0, ""), luaTimingMult("luaTimingMult", SensorCategory.SENSOR_INPUTS, FieldType.INT, 984, 1.0, -1.0, -1.0, ""),
etb_idlePosition("idlePosition", SensorCategory.SENSOR_INPUTS, FieldType.INT, 988, 1.0, -1.0, -1.0, ""),
trim("trim", SensorCategory.SENSOR_INPUTS, FieldType.INT, 992, 1.0, -1.0, -1.0, ""),
luaAdjustment("luaAdjustment", SensorCategory.SENSOR_INPUTS, FieldType.INT, 996, 1.0, -1.0, -1.0, ""),
// Synthetic (console only) channels // Synthetic (console only) channels
ETB_CONTROL_QUALITY("ETB metric", SensorCategory.SNIFFING, "", 100), ETB_CONTROL_QUALITY("ETB metric", SensorCategory.SNIFFING, "", 100),