nix gauge generation

This commit is contained in:
Matthew Kennedy 2023-07-18 11:39:39 -07:00
parent aac9ea1266
commit c36840d0c3
14 changed files with 67 additions and 142 deletions

View File

@ -10,14 +10,14 @@ bit rpmTooLow
bit tpsTooLow
bit mapTooLow
int16_t autoscale luaTargetAdd;"Boost: Lua target add";"v", 0.5,0, -100,100, 1, @@GAUGE_CATEGORY_BOOST_CONTROL@@
int16_t autoscale boostOutput;@@GAUGE_NAME_BOOST_OUTPUT@@;"percent", 0.01,0, -100,100, 2, @@GAUGE_CATEGORY_BOOST_CONTROL@@
float luaTargetMult;"Boost: Lua target mult";"v", 1,0, -100,100, 1, @@GAUGE_CATEGORY_BOOST_CONTROL@@
int16_t autoscale luaTargetAdd;"Boost: Lua target add";"v", 0.5,0, -100,100, 1
int16_t autoscale boostOutput;@@GAUGE_NAME_BOOST_OUTPUT@@;"percent", 0.01,0, -100,100, 2
float luaTargetMult;"Boost: Lua target mult";"v", 1,0, -100,100, 1
float openLoopPart;@@GAUGE_NAME_BOOST_OPEN_LOOP@@;"v", 1,0, -100,100, 1, @@GAUGE_CATEGORY_BOOST_CONTROL@@
float luaOpenLoopAdd;"Boost: Lua open loop add";"v", 1,0, -100,100, 1, @@GAUGE_CATEGORY_BOOST_CONTROL@@
int8_t autoscale boostControllerClosedLoopPart;@@GAUGE_NAME_BOOST_CLOSED_LOOP@@;"%", 0.5,0, -50,50, 1, @@GAUGE_CATEGORY_BOOST_CONTROL@@
int16_t autoscale boostControlTarget;@@GAUGE_NAME_BOOST_TARGET@@;"kPa",{1/@@PACK_MULT_PRESSURE@@},0, 0, 300, 1, @@GAUGE_CATEGORY_BOOST_CONTROL@@
float openLoopPart;@@GAUGE_NAME_BOOST_OPEN_LOOP@@;"v", 1,0, -100,100, 1
float luaOpenLoopAdd;"Boost: Lua open loop add";"v", 1,0, -100,100, 1
int8_t autoscale boostControllerClosedLoopPart;@@GAUGE_NAME_BOOST_CLOSED_LOOP@@;"%", 0.5,0, -50,50, 1
int16_t autoscale boostControlTarget;@@GAUGE_NAME_BOOST_TARGET@@;"kPa",{1/@@PACK_MULT_PRESSURE@@},0, 0, 300, 1
end_struct

View File

@ -1,8 +1,8 @@
! units,scale,offset,min,max,digits
struct_no_prefix dc_motors_s
float dcOutput0;"DC: output0";"per", 1,0, 0,10, 2,@@GAUGE_CATEGORY_ETB@@
uint8_t isEnabled0_int;"DC: en0";"per", 1,0, 0,10, 2,@@GAUGE_CATEGORY_ETB@@
float dcOutput0;"DC: output0";"per", 1,0, 0,10, 2
uint8_t isEnabled0_int;"DC: en0";"per", 1,0, 0,10, 2
bit isEnabled0
end_struct

View File

@ -1,11 +1,11 @@
! units,scale,offset,min,max,digits
struct_no_prefix electronic_throttle_s
float idlePosition;"ETB: idlePosition";"per", 1,0, 0,10, 2,@@GAUGE_CATEGORY_ETB@@
float idlePosition;"ETB: idlePosition";"per", 1,0, 0,10, 2
float trim;"ETB: trim"
float luaAdjustment;"ETB: luaAdjustment";"per", 1,0, 0,3, 2,@@GAUGE_CATEGORY_ETB@@
float luaAdjustment;"ETB: luaAdjustment";"per", 1,0, 0,3, 2
float m_wastegatePosition;"DC: wastegatePosition";"per", 1,0, 0,3, 2,@@GAUGE_CATEGORY_ETB@@
float m_wastegatePosition;"DC: wastegatePosition";"per", 1,0, 0,3, 2
custom percent_t 4 scalar, F32, @OFFSET@, "", 1, 0, 0, 100, 2
@ -18,10 +18,10 @@ struct_no_prefix electronic_throttle_s
bit etbRevLimitActive
bit jamDetected
float etbDutyRateOfChange;"ETB duty rate of change";"per", 1,0, -0,20, 2,@@GAUGE_CATEGORY_ETB@@
float etbDutyAverage;"ETB average duty";"per", 1,0, -20,50, 2,@@GAUGE_CATEGORY_ETB@@
uint16_t etbTpsErrorCounter;"ETB TPS error counter";"count", 1,0, 0,3, 0,@@GAUGE_CATEGORY_ETB@@
uint16_t etbPpsErrorCounter;"ETB pedal error counter";"count", 1,0, 0,3, 0,@@GAUGE_CATEGORY_ETB@@
float etbDutyRateOfChange;"ETB duty rate of change";"per", 1,0, -0,20, 2
float etbDutyAverage;"ETB average duty";"per", 1,0, -20,50, 2
uint16_t etbTpsErrorCounter;"ETB TPS error counter";"count", 1,0, 0,3, 0
uint16_t etbPpsErrorCounter;"ETB pedal error counter";"count", 1,0, 0,3, 0
int8_t etbErrorCode

View File

@ -1,11 +1,11 @@
struct_no_prefix fuel_computer_s
float totalFuelCorrection;Fuel: Total correction;"mult", 1,0, 0,3, 2,@@GAUGE_CATEGORY_FUEL_MATH@@
float totalFuelCorrection;Fuel: Total correction;"mult", 1,0, 0,3, 2
struct running_fuel_s
float postCrankingFuelCorrection;Fuel: Post cranking mult
float intakeTemperatureCoefficient;@@GAUGE_NAME_FUEL_IAT_CORR@@
float coolantTemperatureCoefficient;@@GAUGE_NAME_FUEL_CLT_CORR@@
float timeSinceCrankingInSecs;;"secs", 1,0, 0,600000, 0, @@GAUGE_CATEGORY_FUEL_MATH@@
float timeSinceCrankingInSecs;;"secs", 1,0, 0,600000, 0
uint16_t autoscale baseFuel;@@GAUGE_NAME_FUEL_BASE@@\nThis is the raw value we take from the fuel map or base fuel algorithm, before the corrections;"mg",{1/@@PACK_MULT_FUEL_MASS@@}, 0, 0, 0, 3
uint16_t autoscale fuel;@@GAUGE_NAME_FUEL_RUNNING@@\nTotal fuel with CLT IAT and TPS acceleration without injector lag corrections per cycle, as pulse per cycle;"mg",{1/@@PACK_MULT_FUEL_MASS@@}, 0, 0, 0, 3
@ -16,8 +16,8 @@ struct_no_prefix fuel_computer_s
running_fuel_s running
uint16_t autoscale afrTableYAxis;;"%",{1/100},0, 0, 0, 0
uint16_t autoscale targetLambda;@@GAUGE_NAME_TARGET_LAMBDA@@;"",{1/@@PACK_MULT_LAMBDA@@},0, 0.5,1.5, 2,@@GAUGE_CATEGORY_FUEL_MATH@@
uint16_t autoscale targetAFR;@@GAUGE_NAME_TARGET_AFR@@;"ratio", {1/@@PACK_MULT_AFR@@},0, 10,20, 2,@@GAUGE_CATEGORY_FUEL_MATH@@
uint16_t autoscale targetLambda;@@GAUGE_NAME_TARGET_LAMBDA@@;"",{1/@@PACK_MULT_LAMBDA@@},0, 0.5,1.5, 2
uint16_t autoscale targetAFR;@@GAUGE_NAME_TARGET_AFR@@;"ratio", {1/@@PACK_MULT_AFR@@},0, 10,20, 2
uint16_t autoscale stoichiometricRatio;Fuel: Stoich ratio;"ratio",{1/@@PACK_MULT_AFR@@}, 0, 0, 0, 2

View File

@ -1,20 +1,20 @@
! "units",scale,offset, min,max, digits,category
struct_no_prefix ignition_state_s
float baseDwell;;"ms", 1,0, 0,30, 1,@@GAUGE_CATEGORY_TIMING@@
floatms_t sparkDwell;@@GAUGE_COIL_DWELL_TIME@@;"ms", 1,0, 0,30, 1,@@GAUGE_CATEGORY_TIMING@@
float baseDwell;;"ms", 1,0, 0,30, 1
floatms_t sparkDwell;@@GAUGE_COIL_DWELL_TIME@@;"ms", 1,0, 0,30, 1
angle_t dwellAngle;ignition dwell duration\nas crankshaft angle\nNAN if engine is stopped\nSee also sparkDwell;"deg", 1,0, 0,120, 1,@@GAUGE_CATEGORY_TIMING@@
angle_t dwellAngle;ignition dwell duration\nas crankshaft angle\nNAN if engine is stopped\nSee also sparkDwell;"deg", 1,0, 0,120, 1
int16_t autoscale cltTimingCorrection;Ign: CLT correction;"deg",{1/@@PACK_MULT_PERCENT@@},0, -20,20, 2,@@GAUGE_CATEGORY_TIMING@@
int16_t autoscale timingIatCorrection;Ign: IAT correction;"deg",{1/@@PACK_MULT_PERCENT@@},0, -20,20, 2,@@GAUGE_CATEGORY_TIMING@@
int16_t autoscale timingPidCorrection;Idle: Timing adjustment;"deg",{1/@@PACK_MULT_PERCENT@@},0, -20,20, 2,@@GAUGE_CATEGORY_TIMING@@
int16_t autoscale cltTimingCorrection;Ign: CLT correction;"deg",{1/@@PACK_MULT_PERCENT@@},0, -20,20, 2
int16_t autoscale timingIatCorrection;Ign: IAT correction;"deg",{1/@@PACK_MULT_PERCENT@@},0, -20,20, 2
int16_t autoscale timingPidCorrection;Idle: Timing adjustment;"deg",{1/@@PACK_MULT_PERCENT@@},0, -20,20, 2
float dwellVoltageCorrection;Ign: Dwell voltage correction
float luaTimingAdd;Ign: Lua timing add;"deg",1, 0, -20, 20, 2, @@GAUGE_CATEGORY_TIMING@@
float luaTimingMult;Ign: Lua timing mult;"deg",1, 0, -20, 20, 2, @@GAUGE_CATEGORY_TIMING@@
float luaTimingAdd;Ign: Lua timing add;"deg",1, 0, -20, 20, 2
float luaTimingMult;Ign: Lua timing mult;"deg",1, 0, -20, 20, 2
end_struct

View File

@ -1,5 +1,5 @@
struct sent_state_s
uint16_t value0;"ETB: SENT value0";"value", 1,0, 0,3, 0,@@GAUGE_CATEGORY_ETB@@
uint16_t value1;"ETB: SENT value1";"value", 1,0, 0,3, 0,@@GAUGE_CATEGORY_ETB@@
float errorRate;"ETB: SENT error rate";"ratio", 1,0, 0,3, 2,@@GAUGE_CATEGORY_ETB@@
uint16_t value0;"ETB: SENT value0";"value", 1,0, 0,3, 0
uint16_t value1;"ETB: SENT value1";"value", 1,0, 0,3, 0
float errorRate;"ETB: SENT error rate";"ratio", 1,0, 0,3, 2
end_struct

View File

@ -9,7 +9,6 @@ COMMON_GEN_CONFIG="
-readfile DATALOG_SECTION_FROM_FILE console/binary/generated/data_logs.ini \
-readfile LIVE_DATA_MENU_FROM_FILE console/binary/generated/fancy_menu.ini \
-readfile LIVE_DATA_PANELS_FROM_FILE console/binary/generated/fancy_content.ini \
-readfile LIVE_DATA_GAUGES_FROM_FILE console/binary/generated/gauges.ini \
-ts_destination tunerstudio \
-firing_order controllers/algo/firing_order.h \
-triggerInputFolder ../unit_tests \

View File

@ -39,9 +39,6 @@
#define GAUGE_NAME_TRG_ERR "Trigger Error Counter"
#define GAUGE_NAME_TRG_GAP "Trigger Sync Latest Ratio"
#define GAUGE_CATEGORY_TIMING "Timing"
#define GAUGE_CATEGORY_FUEL_MATH "Fuel: math"
#define GAUGE_CATEGORY_BOOST_CONTROL "Boost Control"
#define GAUGE_CATEGORY_ETB "ETB more"
#define GAUGE_NAME_VVT_B1I "VVT: bank 1 intake"

View File

@ -1208,7 +1208,41 @@ curve = 32Curve, "3-2 Shift Solenoid Percent by Speed"
[GaugeConfigurations]
@@LIVE_DATA_GAUGES_FROM_FILE@@
gaugeCategory = "Fuel: math"
totalFuelCorrectionGauge = totalFuelCorrection,"Fuel: Total correction", "mult", 0.0,3.0, 0.0,3.0, 0.0,3.0, 2,2
running_timeSinceCrankingInSecsGauge = running_timeSinceCrankingInSecs,"running_ timeSinceCrankingInSecs", "secs", 0.0,600000.0, 0.0,600000.0, 0.0,600000.0, 0,0
targetLambdaGauge = targetLambda,"Fuel: target lambda", "", 0.5,1.5, 0.5,1.5, 0.5,1.5, 2,2
targetAFRGauge = targetAFR,"Fuel: target AFR", "ratio", 10.0,20.0, 10.0,20.0, 10.0,20.0, 2,2
gaugeCategory = "Timing"
baseDwellGauge = baseDwell,"baseDwell", "ms", 0.0,30.0, 0.0,30.0, 0.0,30.0, 1,1
sparkDwellGauge = sparkDwell,"Ign: Dwell", "ms", 0.0,30.0, 0.0,30.0, 0.0,30.0, 1,1
dwellAngleGauge = dwellAngle,"ignition dwell duration", "deg", 0.0,120.0, 0.0,120.0, 0.0,120.0, 1,1
cltTimingCorrectionGauge = cltTimingCorrection,"Ign: CLT correction", "deg", -20.0,20.0, -20.0,20.0, -20.0,20.0, 2,2
timingIatCorrectionGauge = timingIatCorrection,"Ign: IAT correction", "deg", -20.0,20.0, -20.0,20.0, -20.0,20.0, 2,2
timingPidCorrectionGauge = timingPidCorrection,"Idle: Timing adjustment", "deg", -20.0,20.0, -20.0,20.0, -20.0,20.0, 2,2
luaTimingAddGauge = luaTimingAdd,"Ign: Lua timing add", "deg", -20.0,20.0, -20.0,20.0, -20.0,20.0, 2,2
luaTimingMultGauge = luaTimingMult,"Ign: Lua timing mult", "deg", -20.0,20.0, -20.0,20.0, -20.0,20.0, 2,2
gaugeCategory = "Boost Control"
luaTargetAddGauge = luaTargetAdd,"Boost: Lua target add", "v", -100.0,100.0, -100.0,100.0, -100.0,100.0, 1,1
boostOutputGauge = boostOutput,"Boost: Output", "percent", -100.0,100.0, -100.0,100.0, -100.0,100.0, 2,2
luaTargetMultGauge = luaTargetMult,"Boost: Lua target mult", "v", -100.0,100.0, -100.0,100.0, -100.0,100.0, 1,1
openLoopPartGauge = openLoopPart,"Boost: Open loop", "v", -100.0,100.0, -100.0,100.0, -100.0,100.0, 1,1
luaOpenLoopAddGauge = luaOpenLoopAdd,"Boost: Lua open loop add", "v", -100.0,100.0, -100.0,100.0, -100.0,100.0, 1,1
boostControllerClosedLoopPartGauge = boostControllerClosedLoopPart,"Boost: Closed loop", "%", -50.0,50.0, -50.0,50.0, -50.0,50.0, 1,1
boostControlTargetGauge = boostControlTarget,"Boost: Target", "kPa", 0.0,300.0, 0.0,300.0, 0.0,300.0, 1,1
gaugeCategory = "ETB more"
idlePositionGauge = idlePosition,"ETB: idlePosition", "per", 0.0,10.0, 0.0,10.0, 0.0,10.0, 2,2
luaAdjustmentGauge = luaAdjustment,"ETB: luaAdjustment", "per", 0.0,3.0, 0.0,3.0, 0.0,3.0, 2,2
m_wastegatePositionGauge = m_wastegatePosition,"DC: wastegatePosition", "per", 0.0,3.0, 0.0,3.0, 0.0,3.0, 2,2
etbDutyRateOfChangeGauge = etbDutyRateOfChange,"ETB duty rate of change", "per", -0.0,20.0, -0.0,20.0, -0.0,20.0, 2,2
etbDutyAverageGauge = etbDutyAverage,"ETB average duty", "per", -20.0,50.0, -20.0,50.0, -20.0,50.0, 2,2
etbTpsErrorCounterGauge = etbTpsErrorCounter,"ETB TPS error counter", "count", 0.0,3.0, 0.0,3.0, 0.0,3.0, 0,0
etbPpsErrorCounterGauge = etbPpsErrorCounter,"ETB pedal error counter", "count", 0.0,3.0, 0.0,3.0, 0.0,3.0, 0,0
dcOutput0Gauge = dcOutput0,"DC: output0", "per", 0.0,10.0, 0.0,10.0, 0.0,10.0, 2,2
isEnabled0_intGauge = isEnabled0_int,"DC: en0", "per", 0.0,10.0, 0.0,10.0, 0.0,10.0, 2,2
value0Gauge = value0,"ETB: SENT value0", "value", 0.0,3.0, 0.0,3.0, 0.0,3.0, 0,0
value1Gauge = value1,"ETB: SENT value1", "value", 0.0,3.0, 0.0,3.0, 0.0,3.0, 0,0
errorRateGauge = errorRate,"ETB: SENT error rate", "ratio", 0.0,3.0, 0.0,3.0, 0.0,3.0, 2,2
gaugeCategory = Trigger
triggerErrorsCounterGauge = totalTriggerErrorCounter, "Trigger error count", "count", 0, 15000, 0, 0, 6000, 6000, 0, 0

Binary file not shown.

View File

@ -27,8 +27,6 @@ public class LiveDataProcessor {
private final static String tsOutputsDestination = "console/binary/";
private final GaugeConsumer gaugeConsumer = new GaugeConsumer(tsOutputsDestination + File.separator + "generated/gauges.ini");
private final StringBuilder enumContent = new StringBuilder(header +
"#pragma once\n" +
"\n" +
@ -71,11 +69,6 @@ public class LiveDataProcessor {
try (FileWriter fw = new FileWriter("console/binary/generated/fancy_menu.ini")) {
fw.write(liveDataProcessor.fancyNewMenu.toString());
}
liveDataProcessor.end();
}
private void end() throws IOException {
gaugeConsumer.endFile();
}
interface EntryHandler {
@ -131,12 +124,6 @@ public class LiveDataProcessor {
state.addDestination((state1, structure) -> outputValueConsumer.handleEndStruct(state1, structure));
}
state.addDestination(new ConfigurationConsumer() {
@Override
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
gaugeConsumer.handleEndStruct(readerState, structure);
}
});
state.doJob();

View File

@ -1,82 +0,0 @@
package com.rusefi.output;
import com.rusefi.ConfigField;
import com.rusefi.ConfigFieldImpl;
import com.rusefi.ReaderState;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import static com.rusefi.output.DataLogConsumer.getHumanGaugeName;
import static org.abego.treelayout.internal.util.java.lang.string.StringUtil.quote;
public class GaugeConsumer implements ConfigurationConsumer {
private final String fileName;
private final LinkedHashMap<String, StringBuilder> byCategory = new LinkedHashMap<>();
public GaugeConsumer(String fileName) {
this.fileName = fileName;
}
@Override
public void handleEndStruct(ReaderState readerState, ConfigStructure structure) throws IOException {
if (readerState.isStackEmpty()) {
PerFieldWithStructuresIterator iterator = new PerFieldWithStructuresIterator(readerState, structure.getTsFields(), "",
(state, configField, prefix) -> handle(configField, prefix));
iterator.loop();
}
}
@Override
public void endFile() throws IOException {
if (fileName != null) {
FileWriter fw = new FileWriter(fileName);
fw.write(getContent());
fw.close();
}
}
private String handle(ConfigField configField, String prefix) {
String comment = getHumanGaugeName("", configField);
comment = ConfigFieldImpl.unquote(comment);
if (!prefix.isEmpty()) {
comment = prefix + " " + comment;
}
comment = quote(comment);
double min = configField.getMin();
double max = configField.getMax();
int digits = configField.getDigits();
String category = configField.getCategory();
if (category == null)
return "";
StringBuilder sb = byCategory.computeIfAbsent(category, s -> new StringBuilder());
String fullName = prefix + configField.getName();
String gaugeEntry = fullName + "Gauge = " + fullName + "," + comment +
", " + quote(configField.getUnits()) +
", " + min + "," + max +
", " + min + "," + max +
", " + min + "," + max +
", " + digits + "," + digits +
"\n";
sb.append(gaugeEntry);
return "";
}
public String getContent() {
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, StringBuilder> e : byCategory.entrySet()) {
sb.append("\t").append("gaugeCategory = ").append(e.getKey()).append("\n");
sb.append(e.getValue());
}
return sb.toString();
}
}

View File

@ -4,7 +4,6 @@ import com.rusefi.BitState;
import com.rusefi.ReaderStateImpl;
import com.rusefi.newparse.outputs.OutputChannelWriter;
import com.rusefi.output.DataLogConsumer;
import com.rusefi.output.GaugeConsumer;
import com.rusefi.output.GetOutputValueConsumer;
import com.rusefi.output.OutputsSectionConsumer;
import org.jetbrains.annotations.NotNull;
@ -183,22 +182,13 @@ public class OutputsTest {
ReaderStateImpl state = new ReaderStateImpl();
state.getVariableRegistry().register("GAUGE_CATEGORY", "Alternator");
DataLogConsumer dataLogConsumer = new DataLogConsumer(null);
GaugeConsumer gaugeConsumer = new GaugeConsumer(null);
state.readBufferedReader(test, dataLogConsumer, gaugeConsumer);
state.readBufferedReader(test, dataLogConsumer);
assertEquals(
"entry = alternatorStatus_iTerm, \"alternatorStatus_iTerm\", float, \"%.3f\"\n" +
"entry = alternatorStatus_dTerm, \"alternatorStatus_dTerm\", float, \"%.3f\"\n" +
"entry = idleStatus_iTerm, \"idleStatus_iTerm\", float, \"%.3f\"\n" +
"entry = idleStatus_dTerm, \"idleStatus_dTerm\", float, \"%.3f\"\n",
dataLogConsumer.getContent());
assertEquals("\tgaugeCategory = Alternator\n" +
"alternatorStatus_iTermGauge = alternatorStatus_iTerm,\"alternatorStatus_ iTerm\", \"v\", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 4,4\n" +
"alternatorStatus_dTermGauge = alternatorStatus_dTerm,\"alternatorStatus_ dTerm\", \"v\", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 4,4\n" +
"idleStatus_iTermGauge = idleStatus_iTerm,\"idleStatus_ iTerm\", \"v\", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 4,4\n" +
"idleStatus_dTermGauge = idleStatus_dTerm,\"idleStatus_ dTerm\", \"v\", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 4,4\n",
gaugeConsumer.getContent());
}
@Test

Binary file not shown.