Merge branch 'master' into live-data-2021

This commit is contained in:
rusefillc 2021-10-14 15:43:54 -04:00
commit 6aef432417
14 changed files with 47 additions and 230 deletions

View File

@ -240,6 +240,8 @@ static const void * getStructAddr(int structId) {
return static_cast<trigger_central_s*>(&engine->triggerCentral);
case LDS_TRIGGER_STATE_STATE_INDEX:
return static_cast<trigger_state_s*>(&engine->triggerCentral.triggerState);
case LDS_AC_STATE:
return static_cast<ac_control_s*>(&engine->acState);
#if EFI_ELECTRONIC_THROTTLE_BODY
case LDS_ETB_PID_STATE_INDEX:
return engine->etbControllers[0]->getPidState();

View File

@ -9,6 +9,7 @@ static Deadband<5> maxCltDeadband;
static Deadband<5> maxTpsDeadband;
bool AcState::getAcState(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
latest_usage_ac_control = getTimeNowSeconds();
auto rpm = Sensor::getOrZero(SensorType::Rpm);
engineTooSlow = rpm < 500;

View File

@ -564,47 +564,6 @@ void EtbController::update() {
&& m_function == ETB_Throttle1;
ClosedLoopController::update();
DISPLAY_STATE(Engine)
DISPLAY(DISPLAY_IF(1))
DISPLAY_TEXT(Electronic_Throttle);
DISPLAY_SENSOR(TPS)
DISPLAY_TEXT(eol);
DISPLAY_TEXT(Pedal);
DISPLAY_SENSOR(PPS);
DISPLAY(DISPLAY_CONFIG(throttlePedalPositionAdcChannel));
DISPLAY_TEXT(eol);
DISPLAY_TEXT(Feed_forward);
DISPLAY(DISPLAY_FIELD(etbFeedForward));
DISPLAY_TEXT(eol);
DISPLAY_STATE(ETB_pid)
DISPLAY_TEXT(input);
DISPLAY(DISPLAY_FIELD(input));
DISPLAY_TEXT(Output);
DISPLAY(DISPLAY_FIELD(output));
DISPLAY_TEXT(iTerm);
DISPLAY(DISPLAY_FIELD(iTerm));
DISPLAY_TEXT(eol);
DISPLAY(DISPLAY_FIELD(errorAmplificationCoef));
DISPLAY(DISPLAY_FIELD(previousError));
DISPLAY_TEXT(eol);
DISPLAY_TEXT(Settings);
DISPLAY(DISPLAY_CONFIG(ETB_PFACTOR));
DISPLAY(DISPLAY_CONFIG(ETB_IFACTOR));
DISPLAY(DISPLAY_CONFIG(ETB_DFACTOR));
DISPLAY_TEXT(eol);
DISPLAY(DISPLAY_CONFIG(ETB_OFFSET));
DISPLAY(DISPLAY_CONFIG(ETB_PERIODMS));
DISPLAY_TEXT(eol);
DISPLAY(DISPLAY_CONFIG(ETB_MINVALUE));
DISPLAY(DISPLAY_CONFIG(ETB_MAXVALUE));
/* DISPLAY_ELSE */
DISPLAY_TEXT(No_Pedal_Sensor);
/* DISPLAY_ENDIF */
}
void EtbController::autoCalibrateTps() {

View File

@ -598,46 +598,9 @@ void startIdleThread(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
initIdleHardware(PASS_ENGINE_PARAMETER_SIGNATURE);
#endif /* EFI_UNIT_TEST */
DISPLAY_STATE(Engine)
DISPLAY_TEXT(Idle_State);
engine->engineState.idle.DISPLAY_FIELD(idleState) = INIT;
DISPLAY_TEXT(EOL);
DISPLAY_TEXT(Base_Position);
engine->engineState.idle.DISPLAY_FIELD(baseIdlePosition) = -100.0f;
DISPLAY_TEXT(Position_with_Adjustments);
engine->engineState.idle.DISPLAY_FIELD(currentIdlePosition) = -100.0f;
DISPLAY_TEXT(EOL);
DISPLAY_TEXT(EOL);
DISPLAY_SENSOR(TPS);
DISPLAY_TEXT(EOL);
DISPLAY_TEXT(Throttle_Up_State);
DISPLAY(DISPLAY_FIELD(throttlePedalUpState));
DISPLAY(DISPLAY_CONFIG(throttlePedalUpPin));
DISPLAY_TEXT(eol);
DISPLAY(DISPLAY_IF(isAutomaticIdle))
DISPLAY_STATE(idle_pid)
DISPLAY_TEXT(Output);
DISPLAY(DISPLAY_FIELD(output));
DISPLAY_TEXT(iTerm);
DISPLAY(DISPLAY_FIELD(iTerm));
DISPLAY_TEXT(eol);
DISPLAY_TEXT(Settings);
DISPLAY(DISPLAY_CONFIG(IDLERPMPID_PFACTOR));
DISPLAY(DISPLAY_CONFIG(IDLERPMPID_IFACTOR));
DISPLAY(DISPLAY_CONFIG(IDLERPMPID_DFACTOR));
DISPLAY(DISPLAY_CONFIG(IDLERPMPID_OFFSET));
DISPLAY_TEXT(eol);
DISPLAY_TEXT(ETB_Idle);
DISPLAY_STATE(Engine)
DISPLAY(DISPLAY_FIELD(etbIdleAddition));
/* DISPLAY_ELSE */
DISPLAY_TEXT(Manual_idle_control);
/* DISPLAY_ENDIF */
engine->engineState.idle.idleState = INIT;
engine->engineState.idle.baseIdlePosition = -100.0f;
engine->engineState.idle.currentIdlePosition = -100.0f;
#if ! EFI_UNIT_TEST

View File

@ -80,8 +80,7 @@ floatms_t WallFuel::adjust(floatms_t desiredFuel DECLARE_ENGINE_PARAMETER_SUFFIX
// if tau is really small, we get div/0.
// you probably meant to disable wwae.
DISPLAY_STATE(wall_fuel)
float tau = CONFIG(DISPLAY_CONFIG(wwaeTau));
float tau = CONFIG(wwaeTau);
if (tau < 0.01f) {
return desiredFuel;
}
@ -93,7 +92,7 @@ floatms_t WallFuel::adjust(floatms_t desiredFuel DECLARE_ENGINE_PARAMETER_SUFFIX
}
float alpha = expf_taylor(-120 / (rpm * tau));
float beta = CONFIG(DISPLAY_CONFIG(wwaeBeta));
float beta = CONFIG(wwaeBeta);
#if EFI_TUNER_STUDIO
if (engineConfiguration->debugMode == DBG_KNOCK) {
@ -136,11 +135,8 @@ floatms_t WallFuel::adjust(floatms_t desiredFuel DECLARE_ENGINE_PARAMETER_SUFFIX
}
#endif // EFI_TUNER_STUDIO
DISPLAY_TEXT(Current_Wall_Fuel_Film);
DISPLAY_FIELD(wallFuel) = fuelFilmMassNext;
DISPLAY_TEXT(Fuel correction);
DISPLAY_FIELD(wallFuelCorrection) = M_cmd - desiredFuel;
DISPLAY_TEXT(ms);
wallFuel = fuelFilmMassNext;
wallFuelCorrection = M_cmd - desiredFuel;
return M_cmd;
}

View File

@ -42,14 +42,7 @@ static mapEstimate_Map3D_t mapEstimationTable;
#if EFI_ENGINE_CONTROL
DISPLAY_STATE(Engine)
DISPLAY(DISPLAY_FIELD(sparkDwell))
DISPLAY(DISPLAY_FIELD(dwellAngle))
DISPLAY(DISPLAY_FIELD(cltTimingCorrection))
DISPLAY_TEXT(eol);
DISPLAY(DISPLAY_IF(isCrankingState)) float getCrankingFuel3(
float getCrankingFuel3(
float baseFuel,
uint32_t revolutionCounterSinceStart DECLARE_ENGINE_PARAMETER_SUFFIX) {
// these magic constants are in Celsius
@ -63,44 +56,35 @@ DISPLAY(DISPLAY_IF(isCrankingState)) float getCrankingFuel3(
/**
* Cranking fuel changes over time
*/
DISPLAY_TEXT(Duration_coef);
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(durationCoefficient) = interpolate2d(revolutionCounterSinceStart, config->crankingCycleBins,
engine->engineState.cranking.durationCoefficient = interpolate2d(revolutionCounterSinceStart, config->crankingCycleBins,
config->crankingCycleCoef);
DISPLAY_TEXT(eol);
/**
* Cranking fuel is different depending on engine coolant temperature
* If the sensor is failed, use 20 deg C
*/
auto clt = Sensor::get(SensorType::Clt);
DISPLAY_TEXT(Coolant_coef);
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(coolantTemperatureCoefficient) =
engine->engineState.cranking.coolantTemperatureCoefficient =
interpolate2d(clt.value_or(20), config->crankingFuelBins, config->crankingFuelCoef);
DISPLAY_SENSOR(CLT);
DISPLAY_TEXT(eol);
auto tps = Sensor::get(SensorType::DriverThrottleIntent);
DISPLAY_TEXT(TPS_coef);
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(tpsCoefficient) = tps.Valid ? 1 : interpolate2d(tps.Value, engineConfiguration->crankingTpsBins,
engine->engineState.cranking.tpsCoefficient = tps.Valid ? 1 : interpolate2d(tps.Value, engineConfiguration->crankingTpsBins,
engineConfiguration->crankingTpsCoef);
/*
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(tpsCoefficient) =
engine->engineState.cranking.tpsCoefficient =
tps.Valid
? interpolate2d(tps.Value, engineConfiguration->crankingTpsBins, engineConfiguration->crankingTpsCoef)
: 1; // in case of failed TPS, don't correct.*/
DISPLAY_SENSOR(TPS);
DISPLAY_TEXT(eol);
floatms_t crankingFuel = baseCrankingFuel
* engine->engineState.cranking.durationCoefficient
* engine->engineState.cranking.coolantTemperatureCoefficient
* engine->engineState.cranking.tpsCoefficient;
DISPLAY_TEXT(Cranking_fuel);
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(fuel) = crankingFuel * 1000;
engine->engineState.cranking.fuel = crankingFuel * 1000;
if (crankingFuel <= 0) {
warning(CUSTOM_ERR_ZERO_CRANKING_FUEL, "Cranking fuel value %f", crankingFuel);
@ -108,29 +92,16 @@ DISPLAY(DISPLAY_IF(isCrankingState)) float getCrankingFuel3(
return crankingFuel;
}
/* DISPLAY_ELSE */
floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_SUFFIX) {
ScopePerf perf(PE::GetRunningFuel);
DISPLAY_TEXT(Base_fuel);
ENGINE(engineState.DISPLAY_PREFIX(running).DISPLAY_FIELD(baseFuel)) = baseFuel;
DISPLAY_TEXT(eol);
ENGINE(engineState.running.baseFuel) = baseFuel;
float iatCorrection = ENGINE(engineState.running.intakeTemperatureCoefficient);
DISPLAY_TEXT(Intake_coef);
float iatCorrection = ENGINE(engineState.DISPLAY_PREFIX(running).DISPLAY_FIELD(intakeTemperatureCoefficient));
DISPLAY_SENSOR(IAT);
DISPLAY_TEXT(eol);
float cltCorrection = ENGINE(engineState.running.coolantTemperatureCoefficient);
DISPLAY_TEXT(Coolant_coef);
float cltCorrection = ENGINE(engineState.DISPLAY_PREFIX(running).DISPLAY_FIELD(coolantTemperatureCoefficient));
DISPLAY_SENSOR(CLT);
DISPLAY_TEXT(eol);
DISPLAY_TEXT(Post_cranking_coef);
float postCrankingFuelCorrection = ENGINE(engineState.DISPLAY_PREFIX(running).DISPLAY_FIELD(postCrankingFuelCorrection));
DISPLAY_TEXT(eol);
float postCrankingFuelCorrection = ENGINE(engineState.running.postCrankingFuelCorrection);
float baroCorrection = ENGINE(engineState.baroCorrection);
@ -140,15 +111,9 @@ floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_SUFFIX) {
floatms_t runningFuel = baseFuel * baroCorrection * iatCorrection * cltCorrection * postCrankingFuelCorrection;
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(runningFuel), "NaN runningFuel", 0);
DISPLAY_TEXT(eol);
DISPLAY_TEXT(Running_fuel);
ENGINE(engineState.DISPLAY_PREFIX(running).DISPLAY_FIELD(fuel)) = runningFuel * 1000;
DISPLAY_TEXT(eol);
ENGINE(engineState.running.fuel) = runningFuel * 1000;
DISPLAY_TEXT(Injector_lag);
DISPLAY(DISPLAY_PREFIX(running).DISPLAY_FIELD(injectorLag));
DISPLAY_SENSOR(VBATT);
return runningFuel;
}

View File

@ -32,48 +32,6 @@
#include "cli_registry.h"
#endif /* __cplusplus */
/**
* reference to configuration parameter.
*/
#define DISPLAY_CONFIG(x) x
/**
* The main annotation of live data - reference to dynamic state variable
* See also 'TS_GET_STRUCT'
* The advantage of Live Data is that there is no need to copy data into tsOutputChannels structure - Live Data is reading exactly
* the same data as actual runtime logic. It's also important to have annotations of the View as close to actual implementation as possible
* to increase the changes of those being in sync.
*
* One day Live Data could be replace with a Domain Specific Language
* One day all Live Data could be provided to TS without data copy to tsOutputChannels - the idea is to have a virtual tsOutputChannels
* where rusEfi would pull data from different memory ranges depending on the requested offset, more or less virtual pages. This could depend
* on the TS bugfix described in https://github.com/rusefi/rusefi/issues/794?
*
*/
#define DISPLAY_FIELD(x) x
/**
* Advanced tag to access fields within data structures
* "running.fuel" variable would be referenced as DISPLAY_PREFIX(running).DISPLAY_FIELD(fuel)
*/
#define DISPLAY_PREFIX(x) x
/**
* we use this 'DISPLAY' macro if value is not used by C++ code in current context and we want to hide it from compiler
*/
#define DISPLAY(x)
#define DISPLAY_TAG(x)
/**
* Just a human-readable comment. '_' underscore symbols become spaces. EOL is handled as new line.
*/
#define DISPLAY_TEXT(x)
#define DISPLAY_STATE(x)
/**
* Reference to one of 'output' channels/standard gauges.
*/
#define DISPLAY_SENSOR(x) {}
#define DISPLAY_IF(x) x
#ifndef FIRMWARE_ID
#define FIRMWARE_ID "source"
#endif

View File

@ -1,4 +1,4 @@
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) integration/ac_control.txt Thu Oct 14 00:25:42 EDT 2021
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) integration/ac_control.txt Thu Oct 14 14:49:24 EDT 2021
// by class com.rusefi.output.CHeaderConsumer
// begin
#pragma once
@ -101,8 +101,12 @@ struct ac_control_s {
/**
offset 0 bit 31 */
bool unusedBit_6_31 : 1;
/** total size 4*/
/**
* offset 4
*/
int latest_usage_ac_control = (int)0;
/** total size 8*/
};
// end
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) integration/ac_control.txt Thu Oct 14 00:25:42 EDT 2021
// this section was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) integration/ac_control.txt Thu Oct 14 14:49:24 EDT 2021

View File

@ -48,9 +48,7 @@ temperature_t getTCharge(int rpm, float tps DECLARE_ENGINE_PARAMETER_SUFFIX) {
float coolantTemp = clt.Value;
DISPLAY_STATE(Engine)
if ((engine->engineState.sd.DISPLAY_IF(isTChargeAirModel) = (CONFIG(tChargeMode) == TCHARGE_MODE_AIR_INTERP))) {
if ((engine->engineState.sd.isTChargeAirModel = (CONFIG(tChargeMode) == TCHARGE_MODE_AIR_INTERP))) {
const floatms_t gramsPerMsToKgPerHour = (3600.0f * 1000.0f) / 1000.0f;
// We're actually using an 'old' airMass calculated for the previous cycle, but it's ok, we're not having any self-excitaton issues
floatms_t airMassForEngine = engine->engineState.sd./***display*/airMassInOneCylinder * CONFIG(specs.cylindersCount);
@ -58,32 +56,21 @@ temperature_t getTCharge(int rpm, float tps DECLARE_ENGINE_PARAMETER_SUFFIX) {
// And if the engine is stopped (0 rpm), then airFlow is also zero (avoiding NaN division)
floatms_t airFlow = (rpm == 0) ? 0 : airMassForEngine * gramsPerMsToKgPerHour / getEngineCycleDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX);
// just interpolate between user-specified min and max coefs, based on the max airFlow value
DISPLAY_TEXT(interpolate_Air_Flow)
engine->engineState.DISPLAY_FIELD(airFlow) = airFlow;
DISPLAY_TEXT(Between)
engine->engineState.airFlow = airFlow;
engine->engineState.sd.Tcharge_coff = interpolateClamped(0.0,
CONFIG(DISPLAY_CONFIG(tChargeAirCoefMin)),
CONFIG(DISPLAY_CONFIG(tChargeAirFlowMax)),
CONFIG(DISPLAY_CONFIG(tChargeAirCoefMax)), airFlow);
CONFIG(tChargeAirCoefMin),
CONFIG(tChargeAirFlowMax),
CONFIG(tChargeAirCoefMax), airFlow);
// save it for console output (instead of MAF massAirFlow)
} else/* DISPLAY_ELSE */ {
// TCHARGE_MODE_RPM_TPS
DISPLAY_TEXT(interpolate_3D)
DISPLAY_SENSOR(RPM)
DISPLAY_TEXT(and)
DISPLAY_SENSOR(TPS)
DISPLAY_TEXT(EOL)
DISPLAY_TEXT(Between)
} else {
float minRpmKcurrentTPS = interpolateMsg("minRpm", tpMin,
CONFIG(DISPLAY_CONFIG(tChargeMinRpmMinTps)), tpMax,
CONFIG(DISPLAY_CONFIG(tChargeMinRpmMaxTps)), tps);
DISPLAY_TEXT(EOL)
CONFIG(tChargeMinRpmMinTps), tpMax,
CONFIG(tChargeMinRpmMaxTps), tps);
float maxRpmKcurrentTPS = interpolateMsg("maxRpm", tpMin,
CONFIG(DISPLAY_CONFIG(tChargeMaxRpmMinTps)), tpMax,
CONFIG(DISPLAY_CONFIG(tChargeMaxRpmMaxTps)), tps);
CONFIG(tChargeMaxRpmMinTps), tpMax,
CONFIG(tChargeMaxRpmMaxTps), tps);
engine->engineState.sd.Tcharge_coff = interpolateMsg("Kcurr", rpmMin, minRpmKcurrentTPS, rpmMax, maxRpmKcurrentTPS, rpm);
/* DISPLAY_ENDIF */
}
if (cisnan(engine->engineState.sd.Tcharge_coff)) {

View File

@ -527,32 +527,6 @@ void TriggerState::decodeTriggerEvent(
bool isSynchronizationPoint;
bool wasSynchronized = getShaftSynchronized();
DISPLAY_STATE(Trigger_State)
DISPLAY_TEXT(Current_Gap);
DISPLAY(DISPLAY_FIELD(currentGap));
DISPLAY_TEXT(EOL);
DISPLAY_STATE(Trigger_Central)
DISPLAY(DISPLAY_CONFIG(TRIGGERINPUTPINS1));
DISPLAY_TEXT("Trigger 1: Fall");
DISPLAY(DISPLAY_FIELD(HWEVENTCOUNTERS1));
DISPLAY_TEXT(", Rise");
DISPLAY(DISPLAY_FIELD(HWEVENTCOUNTERS2));
DISPLAY_TEXT(EOL);
DISPLAY(DISPLAY_CONFIG(TRIGGERINPUTPINS2));
DISPLAY_TEXT("Trigger 2: Fall");
DISPLAY(DISPLAY_FIELD(HWEVENTCOUNTERS3));
DISPLAY_TEXT(", Rise");
DISPLAY(DISPLAY_FIELD(HWEVENTCOUNTERS4));
DISPLAY_TEXT(EOL);
DISPLAY_TEXT(VVT_1);
DISPLAY(DISPLAY_CONFIG(CAMINPUTS1));
DISPLAY(DISPLAY_FIELD(vvtEventRiseCounter));
DISPLAY(DISPLAY_FIELD(vvtEventFallCounter));
DISPLAY(DISPLAY_FIELD(vvtCamCounter));
if (triggerShape.isSynchronizationNeeded) {
currentGap = 1.0 * toothDurations[0] / toothDurations[1];

View File

@ -8,4 +8,6 @@ bit tpsTooHigh
bit acButtonState
int latest_usage_ac_control;
end_struct

View File

@ -1,6 +1,6 @@
package com.rusefi.config.generated;
// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) integration/ac_control.txt Thu Oct 14 00:25:42 EDT 2021
// this file was generated automatically by rusEFI tool ConfigDefinition.jar based on (unknown script) integration/ac_control.txt Thu Oct 14 14:49:24 EDT 2021
// by class com.rusefi.output.FileJavaFieldsConsumer
import com.rusefi.config.*;
@ -38,6 +38,7 @@ public class AcControl {
public static final Field UNUSEDBIT_6_29 = Field.create("UNUSEDBIT_6_29", 0, FieldType.BIT, 29);
public static final Field UNUSEDBIT_6_30 = Field.create("UNUSEDBIT_6_30", 0, FieldType.BIT, 30);
public static final Field UNUSEDBIT_6_31 = Field.create("UNUSEDBIT_6_31", 0, FieldType.BIT, 31);
public static final Field LATEST_USAGE_AC_CONTROL = Field.create("LATEST_USAGE_AC_CONTROL", 4, FieldType.INT);
public static final Field[] VALUES = {
ENGINETOOSLOW,
ENGINETOOFAST,
@ -71,5 +72,6 @@ public class AcControl {
UNUSEDBIT_6_29,
UNUSEDBIT_6_30,
UNUSEDBIT_6_31,
LATEST_USAGE_AC_CONTROL,
};
}

View File

@ -12,6 +12,10 @@ efitimeus_t getTimeNowUs(void) {
return timeNowUs;
}
efitimesec_t getTimeNowSeconds(void) {
return getTimeNowUs() / 1000 / 1000;
}
efitick_t getTimeNowNt(void) {
return getTimeNowUs() * US_TO_NT_MULTIPLIER;
}