improve sensor chart flush behavior (#2545)
* disable sensor chart * type signature, guards * we can't log the message as that confuses the parser * dead * this syntax was technically illegal * more * turn it back on * remove config * api * implement * ui * java ui
This commit is contained in:
parent
d13fa8d1f3
commit
d7e95cd31f
|
@ -201,8 +201,6 @@ void setDodgeNeon1995EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
engineConfiguration->ignitionPinMode = OM_DEFAULT;
|
||||
|
||||
engineConfiguration->clt.config = {0, 30, 100, 32500, 7550, 700, 2700};
|
||||
|
||||
engineConfiguration->sensorChartFrequency = 7;
|
||||
}
|
||||
|
||||
void setDodgeNeonNGCEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||
|
|
|
@ -39,8 +39,6 @@ void setMazda626EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
// chartsize 600
|
||||
engineConfiguration->engineChartSize = 600;
|
||||
|
||||
engineConfiguration->sensorChartFrequency = 2;
|
||||
|
||||
engineConfiguration->injector.flow = 330;
|
||||
engineConfiguration->specs.displacement = 2.0;
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@ void setSubaru2003Wrx(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
engineConfiguration->trigger.customTotalToothCount = 5;
|
||||
engineConfiguration->trigger.customSkippedToothCount = 1;
|
||||
|
||||
engineConfiguration->sensorChartFrequency = 2;
|
||||
|
||||
engineConfiguration->useStepperIdle = true;
|
||||
|
||||
// See http://rusefi.com/forum/viewtopic.php?f=4&t=1161
|
||||
|
|
|
@ -102,6 +102,8 @@ extern int icuFallingCallbackCounter;
|
|||
extern WaveChart waveChart;
|
||||
#endif /* EFI_ENGINE_SNIFFER */
|
||||
|
||||
#include "sensor_chart.h"
|
||||
|
||||
extern pin_output_mode_e DEFAULT_OUTPUT;
|
||||
extern pin_output_mode_e INVERTED_OUTPUT;
|
||||
|
||||
|
@ -198,6 +200,10 @@ void printOverallStatus(efitimesec_t nowSeconds) {
|
|||
waveChart.publishIfFull();
|
||||
#endif /* EFI_ENGINE_SNIFFER */
|
||||
|
||||
#if EFI_SENSOR_CHART
|
||||
publishSensorChartIfFull();
|
||||
#endif // EFI_SENSOR_CHART
|
||||
|
||||
/**
|
||||
* we report the version every 4 seconds - this way the console does not need to
|
||||
* request it and we will display it pretty soon
|
||||
|
|
|
@ -971,7 +971,6 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
engineConfiguration->ignitionMode = IM_ONE_COIL;
|
||||
engineConfiguration->globalTriggerAngleOffset = 0;
|
||||
engineConfiguration->extraInjectionOffset = 0;
|
||||
engineConfiguration->sensorChartFrequency = 20;
|
||||
|
||||
engineConfiguration->fuelAlgorithm = LM_SPEED_DENSITY;
|
||||
|
||||
|
|
|
@ -19,67 +19,81 @@ static char LOGGING_BUFFER[SC_BUFFER_SIZE] CCM_OPTIONAL;
|
|||
static Logging scLogging("analog chart", LOGGING_BUFFER, sizeof(LOGGING_BUFFER));
|
||||
#endif /* EFI_TEXT_LOGGING */
|
||||
|
||||
static int pendingData = false;
|
||||
static int initialized = false;
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
enum class ScState {
|
||||
PreArm,
|
||||
Armed,
|
||||
Logging,
|
||||
Full
|
||||
};
|
||||
|
||||
static ScState state = ScState::PreArm;
|
||||
static uint32_t lastRevCount = 0;
|
||||
|
||||
void scAddData(float angle, float value) {
|
||||
#if EFI_TEXT_LOGGING
|
||||
if (!initialized) {
|
||||
return; // this is possible because of initialization sequence
|
||||
}
|
||||
|
||||
if (engineConfiguration->sensorChartFrequency < 2) {
|
||||
/**
|
||||
* analog chart frequency cannot be 1 because of the way
|
||||
* data flush is implemented, see below
|
||||
*/
|
||||
//todofirmwareError()
|
||||
// Don't log if we need a flush
|
||||
if (state == ScState::Full) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getRevolutionCounter() % engineConfiguration->sensorChartFrequency != 0) {
|
||||
/**
|
||||
* We are here if we do NOT need to add an event to the analog chart
|
||||
*/
|
||||
if (pendingData) {
|
||||
/**
|
||||
* We are here if that's the first time we do not need to add
|
||||
* data after we have added some data - meaning it's time to flush
|
||||
*/
|
||||
// message terminator
|
||||
scLogging.appendPrintf(DELIMETER);
|
||||
// output pending data
|
||||
scheduleLogging(&scLogging);
|
||||
pendingData = false;
|
||||
auto currentRev = getRevolutionCounter();
|
||||
|
||||
if (state == ScState::PreArm) {
|
||||
// nothing to do - we just need to grab the rev counter once so we can detect a change
|
||||
state = ScState::Armed;
|
||||
} else if (state == ScState::Armed) {
|
||||
// If armed, wait for a NEW revolution to start
|
||||
if (lastRevCount != currentRev) {
|
||||
state = ScState::Logging;
|
||||
|
||||
// Reset logging and append header
|
||||
scLogging.reset();
|
||||
scLogging.appendPrintf( "%s%s", PROTOCOL_ANALOG_CHART, DELIMETER);
|
||||
}
|
||||
} else if (state == ScState::Logging) {
|
||||
// If running and the revolution idx changes, terminate logging and wait for flush
|
||||
if (lastRevCount != currentRev) {
|
||||
state = ScState::Full;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!pendingData) {
|
||||
pendingData = true;
|
||||
scLogging.reset();
|
||||
// message header
|
||||
scLogging.appendPrintf( "%s%s", PROTOCOL_ANALOG_CHART, DELIMETER);
|
||||
}
|
||||
|
||||
if (scLogging.remainingSize() > 100) {
|
||||
scLogging.appendPrintf( "%.2f|%.2f|", angle, value);
|
||||
lastRevCount = currentRev;
|
||||
|
||||
if (state == ScState::Logging) {
|
||||
if (scLogging.remainingSize() > 100) {
|
||||
scLogging.appendPrintf( "%.2f|%.2f|", angle, value);
|
||||
} else {
|
||||
state = ScState::Full;
|
||||
}
|
||||
}
|
||||
#endif /* EFI_TEXT_LOGGING */
|
||||
}
|
||||
|
||||
static void setSensorChartFrequency(int value) {
|
||||
engineConfiguration->sensorChartFrequency = value;
|
||||
}
|
||||
|
||||
void initSensorChart(void) {
|
||||
#if EFI_SIMULATOR
|
||||
printf("initSensorChart\n");
|
||||
#endif
|
||||
addConsoleActionI("set_sensor_chart_freq", setSensorChartFrequency);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
void publishSensorChartIfFull() {
|
||||
if (state != ScState::Full) {
|
||||
return;
|
||||
}
|
||||
|
||||
scLogging.appendPrintf(DELIMETER);
|
||||
scheduleLogging(&scLogging);
|
||||
|
||||
state = ScState::Armed;
|
||||
}
|
||||
|
||||
#endif /* EFI_SENSOR_CHART */
|
||||
|
|
|
@ -11,3 +11,4 @@
|
|||
|
||||
void scAddData(float angle, float value);
|
||||
void initSensorChart(void);
|
||||
void publishSensorChartIfFull();
|
||||
|
|
|
@ -649,7 +649,7 @@ adc_channel_e fuelLevelSensor;+This is the processor pin that your fuel level se
|
|||
|
||||
|
||||
float idle_derivativeFilterLoss;+0.1 is a good default value; "x", 1, 0.0, -1000000, 1000000, 4
|
||||
int sensorChartFrequency;;"index", 1, 0, 0, 300, 0
|
||||
int unused520;;"index", 1, 0, 0, 300, 0
|
||||
|
||||
struct trigger_config_s @brief Trigger wheel(s) configuration
|
||||
|
||||
|
|
|
@ -2979,7 +2979,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
|
|||
dialog = monitoringSettings, "rusEFI Console Settings"
|
||||
field = "Sensor Sniffer", sensorChartMode
|
||||
field = " Threshold", sensorSnifferRpmThreshold
|
||||
field = " Each X cycle", sensorChartFrequency
|
||||
field = "Engine Sniffer", isEngineChartEnabled
|
||||
field = " Threshold", engineSnifferRpmThreshold
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ bool Logging::validateBuffer(const char *text, uint32_t extraLen) {
|
|||
if (remainingSize() < extraLen + 1) {
|
||||
#if EFI_PROD_CODE
|
||||
const char * msg = extraLen > 50 ? "(long)" : text;
|
||||
warning(CUSTOM_LOGGING_BUFFER_OVERFLOW, "output overflow %s %d [%s]", name, extraLen, msg);
|
||||
warning(CUSTOM_LOGGING_BUFFER_OVERFLOW, "output overflow %s %d", name, extraLen);
|
||||
#endif /* EFI_PROD_CODE */
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,6 @@ public class SensorSnifferPane {
|
|||
content.add(lowerPanel, BorderLayout.SOUTH);
|
||||
|
||||
lowerPanel.add(new EnumConfigField(uiContext, Fields.SENSORCHARTMODE, "Mode").getContent());
|
||||
lowerPanel.add(new ConfigField(uiContext, Fields.SENSORCHARTFREQUENCY, "Every XXX engine cycles").getContent());
|
||||
lowerPanel.add(new ConfigField(uiContext, Fields.SENSORSNIFFERRPMTHRESHOLD, "RPM threshold").getContent());
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,6 @@ public class EngineSnifferPanel {
|
|||
lowerButtons.add(new ConfigField(uiContext, Fields.GLOBALTRIGGERANGLEOFFSET, "Trigger Offset").getContent());
|
||||
lowerButtons.add(new BitConfigField(uiContext, Fields.VERBOSETRIGGERSYNCHDETAILS, "Verbose trigger Sync").getContent());
|
||||
lowerButtons.add(new BitConfigField(uiContext, Fields.ISENGINECHARTENABLED, "Collect Engine Data").getContent());
|
||||
lowerButtons.add(new ConfigField(uiContext, Fields.SENSORCHARTFREQUENCY, "Frequency").getContent());
|
||||
lowerButtons.add(new ConfigField(uiContext, Fields.ENGINECHARTSIZE, "Engine Sniffer size").getContent());
|
||||
lowerButtons.add(new ConfigField(uiContext, Fields.ENGINESNIFFERRPMTHRESHOLD, "RPM threshold").getContent());
|
||||
bottomPanel.add(lowerButtons, BorderLayout.NORTH);
|
||||
|
|
Loading…
Reference in New Issue