bye bye LaTeX

This commit is contained in:
rusefillc 2021-10-31 11:30:25 -04:00
parent eec89e7118
commit bc7739de29
6 changed files with 1 additions and 226 deletions

View File

@ -1,15 +0,0 @@
<component name="libraryTable">
<library name="jlatexmath">
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/jlatexmath-1.0.6.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/lib/jlatexmath-src-1.0.3.zip!/jlatexmath-1.0.3/examples/Basic" />
<root url="jar://$PROJECT_DIR$/lib/jlatexmath-src-1.0.3.zip!/jlatexmath-1.0.3/examples/Export" />
<root url="jar://$PROJECT_DIR$/lib/jlatexmath-src-1.0.3.zip!/jlatexmath-1.0.3/examples/GIWS/src" />
<root url="jar://$PROJECT_DIR$/lib/jlatexmath-src-1.0.3.zip!/jlatexmath-1.0.3/examples/Macros" />
<root url="jar://$PROJECT_DIR$/lib/jlatexmath-src-1.0.3.zip!/jlatexmath-1.0.3/src" />
</SOURCES>
</library>
</component>

View File

@ -3,7 +3,7 @@
<property name="hw_tests" value="build_hw"/>
<property name="jar_file" value="${jar_file_folder}/rusefi_console.jar"/>
<property name="server_jar_file" value="${jar_file_folder}/rusefi_server.jar"/>
<property name="lib_list" value="lib/mockito-all-1.10.19.jar:../java_tools/configuration_definition/lib/snakeyaml.jar:lib/log4j-api-2.13.3.jar:lib/log4j-core-2.13.3.jar:lib/jsr305-2.0.1.jar:lib/dfu/dfu_java.jar:lib/dfu/IntelHexParser.jar:lib/json-simple-1.1.1.jar:lib/server/javax.json.jar:lib/server/cactoos.jar:lib/server/takes.jar:lib/json-simple-1.1.1.jar:lib/jaxb-api.jar:lib/httpclient.jar:lib/httpmime.jar:lib/httpcore.jar:lib/jSerialComm.jar:lib/jcip-annotations-1.0.jar:lib/jlatexmath-1.0.6.jar:lib/swing-layout-1.0.jar:lib/jep.jar:lib/log4j.jar:lib/junit.jar:lib/SteelSeries-3.9.30.jar:lib/annotations.jar:lib/miglayout-4.0.jar:lib/surfaceplotter-2.0.1.jar:../java_tools/configuration_definition/lib/antlr-4.5-complete.jar"/>
<property name="lib_list" value="lib/mockito-all-1.10.19.jar:../java_tools/configuration_definition/lib/snakeyaml.jar:lib/log4j-api-2.13.3.jar:lib/log4j-core-2.13.3.jar:lib/jsr305-2.0.1.jar:lib/dfu/dfu_java.jar:lib/dfu/IntelHexParser.jar:lib/json-simple-1.1.1.jar:lib/server/javax.json.jar:lib/server/cactoos.jar:lib/server/takes.jar:lib/json-simple-1.1.1.jar:lib/jaxb-api.jar:lib/httpclient.jar:lib/httpmime.jar:lib/httpcore.jar:lib/jSerialComm.jar:lib/jcip-annotations-1.0.jar:lib/swing-layout-1.0.jar:lib/jep.jar:lib/log4j.jar:lib/junit.jar:lib/SteelSeries-3.9.30.jar:lib/annotations.jar:lib/miglayout-4.0.jar:lib/surfaceplotter-2.0.1.jar:../java_tools/configuration_definition/lib/antlr-4.5-complete.jar"/>
<target name="clean">
<delete dir="build"/>
@ -176,7 +176,6 @@
<zipfileset src="lib/batik/batik-svggen.jar" includes="**/*.class"/>
<zipfileset src="lib/batik/batik-awt-util.jar" includes="**/*.class"/>
<zipfileset src="lib/batik/batik-util.jar" includes="**/*.class"/>
<zipfileset src="lib/jlatexmath-1.0.6.jar" includes="**/*.class **/*.xml **/*.ttf"/>
<zipfileset src="lib/json-simple-1.1.1.jar" includes="**/*.class"/>
<zipfileset src="lib/junit.jar" includes="**/*.class"/>
</jar>

View File

@ -1,28 +1,17 @@
package com.rusefi.ui;
import com.opensr5.ConfigurationImage;
import com.opensr5.Logger;
import com.rusefi.FileLog;
import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.config.generated.Fields;
import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral;
import com.rusefi.livedata.LiveDataParserPanel;
import com.rusefi.livedata.LiveDataView;
import com.rusefi.ui.config.ConfigField;
import com.rusefi.ui.util.UiUtils;
import com.rusefi.ui.widgets.IntGaugeLabel;
import org.jetbrains.annotations.NotNull;
import org.putgemin.VerticalFlowLayout;
import org.scilab.forge.jlatexmath.TeXConstants;
import org.scilab.forge.jlatexmath.TeXFormula;
import org.scilab.forge.jlatexmath.TeXIcon;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
/**
@ -32,20 +21,14 @@ import java.awt.image.BufferedImage;
* Andrey Belomutskiy, (c) 2013-2020
*/
public class FormulasPane {
private static final String NL = "\r\n \\\\ ";
private static final String NL2 = NL + "\\ " + NL; // two new lines
private static final String NL3 = NL2 + "\\ " + NL; // two new lines
/**
* this is the panel we expose to the outside world
*/
private final JPanel content = new JPanel(new BorderLayout());
private final JPanel formulaProxy = new JPanel(new BorderLayout());
private final UIContext uiContext;
private boolean isPaused;
public FormulasPane(UIContext uiContext) {
this.uiContext = uiContext;
JPanel vertical = new JPanel(new VerticalFlowLayout());
for (LiveDataView view : LiveDataView.values())
@ -85,197 +68,6 @@ public class FormulasPane {
bottomPanel.add(new IntGaugeLabel("error", Sensor.lastErrorCode));
content.add(bottomPanel, BorderLayout.SOUTH);
updateFormula();
new Timer(200, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!isPaused)
updateFormula();
}
}).start();
}
enum engine_load_mode_e {
// todo: this should NOT be copy-pasted from
LM_PLAIN_MAF("Plain MAF"),
LM_ALPHA_N("Alpha-N/TPS"),
UNUSED_2("Unused value 2"),
LM_SPEED_DENSITY("Speed Density/MAP"),
LM_REAL_MAF("MAF");
private final String title;
engine_load_mode_e(String title) {
this.title = title;
}
}
private void updateFormula() {
BinaryProtocol bp = uiContext.getLinkManager().getCurrentStreamState();
if (bp == null)
return;
ConfigurationImage ci = bp.getControllerConfiguration();
if (ci == null)
return;
int algorithm = ConfigField.getIntValue(ci, Fields.FUELALGORITHM);
engine_load_mode_e[] values = engine_load_mode_e.values();
if (algorithm >= values.length) {
FileLog.MAIN.logLine("Invalid algorithm: " + algorithm);
algorithm = 0; // we are here for example in case of an invalid/incompatible configuration
}
engine_load_mode_e algo = values[algorithm];
String acceleration = getAccelerationVariables(ci) + NL2;
String page;
if (algo == engine_load_mode_e.LM_SPEED_DENSITY) {
page = getSpeedDensity(ci, acceleration);
} else if (algo == engine_load_mode_e.LM_PLAIN_MAF) {
double rpm = SensorCentral.getInstance().getValue(Sensor.RPM);
double maf = SensorCentral.getInstance().getValue(Sensor.MAF);
String baseFuelStr = twoDecimals(Sensor.baseFuel);
String baseFuel = "$Table_Fuel (ms) = lookup (" +
"(RPM = " + rpm + ", " +
"MAF = " + maf + ") = " +
baseFuelStr + "ms";
String actualLastInjection = twoDecimals(Sensor.actualLastInjection);
String injTime = "$Fuel (ms) = " + baseFuel + getInjecctorLag() +
" = " + actualLastInjection + "ms_per_injection$";
page = acceleration + injTime;
} else {
page = acceleration + "todo";
}
TeXFormula formula = new TeXFormula("\r\n" +
algo.title + NL3 + page + "");
TeXIcon formulasTeX = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 20);
BufferedImage image = new BufferedImage(formulasTeX.getIconWidth(), formulasTeX.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = image.createGraphics();
g2.setColor(Color.white);
g2.fillRect(0, 0, formulasTeX.getIconWidth(), formulasTeX.getIconHeight());
JLabel formulaLabel = new JLabel(formulasTeX);
formulaProxy.removeAll();
JLabel warning = new JLabel("These values are for reference only and do not always reflect ECU logic completely. During cranking different logic is applied.");
warning.setForeground(Color.red);
formulaProxy.add(warning, BorderLayout.NORTH);
formulaProxy.add(formulaLabel, BorderLayout.CENTER);
}
@NotNull
private String getAccelerationVariables(ConfigurationImage ci) {
String tpsDelta = twoDecimals(Sensor.deltaTps);
String elDelta = twoDecimals(Sensor.engineLoadAccelDelta);
int tpsEnrichLength = ConfigField.getIntValue(ci, Fields.TPSACCELLENGTH);
int elEnrichLength = ConfigField.getIntValue(ci, Fields.ENGINELOADACCELLENGTH);
String tpsEnrichDelta = "$deltaTps = max(currentTps - previousTps, length = " + tpsEnrichLength +
") = " + tpsDelta + "$";
double tpsAccelThreshold = ConfigField.getFloatValue(ci, Fields.TPSACCELENRICHMENTTHRESHOLD);
String tpsAccelMult = "fixme";//ConfigField.getFloatValue(ci, Fields.TPSACCELENRICHMENTMULTIPLIER);
String tpsAccelValue = twoDecimals(Sensor.tpsAccelFuel);
double tpsDecelThreshold = ConfigField.getFloatValue(ci, Fields.TPSDECELENLEANMENTTHRESHOLD);
double tpsDecelMult = ConfigField.getFloatValue(ci, Fields.TPSDECELENLEANMENTMULTIPLIER);
String tpsEnrich = "$tpsAccelEnrich = if (" +
"(tpsDelta = " + tpsDelta + ") > (tpsThreshold = " + tpsAccelThreshold + "), tpsDelta, 0) * " +
"(tpsAccelMultiplier = " + tpsAccelMult + ") = " + tpsAccelValue + "$";
String loadEnrichDelta = "$deltaLoad = max(currentLoad - previousLoad, length = " + elEnrichLength +
") = " + elDelta + "$";
return tpsEnrichDelta + NL +
tpsEnrich + NL +
loadEnrichDelta;
}
@NotNull
private String getSpeedDensity(ConfigurationImage ci, String acceleration) {
String IAT = oneDecimal(Sensor.IAT);
String MAP = oneDecimal(Sensor.MAP);
String T_CHARGE = oneDecimal(Sensor.tCharge);
double rpm = SensorCentral.getInstance().getValue(Sensor.RPM);
String RPM = "" + (int) rpm;
String VE = twoDecimals(Sensor.veValue);
String TARGET_AFR = twoDecimals(Sensor.TARGET_AFR);
String tpsStr = oneDecimal(Sensor.TPS);
String chargeAirMass = String.format("%.3fgm", SensorCentral.getInstance().getValue(Sensor.CHARGE_AIR_MASS));
double displacement = ConfigField.getFloatValue(ci, Fields.DISPLACEMENT);
int cylinderCount = ConfigField.getIntValue(ci, Fields.CYLINDERSCOUNT);
String cylinderDisplacement = oneDecimal(displacement / cylinderCount);
String injectorFlow = oneDecimal((float) Fields.INJECTOR_FLOW.getValue(ci).doubleValue());
String tCharge = "$Tcharge=f(CLT=" + oneDecimal(Sensor.CLT) + "C,IAT=" + IAT
+ "C,TPS=" + tpsStr + "\\%, RPM = " + RPM + ")=" + T_CHARGE + "C$";
String rpm_map = "RPM=" + RPM + ",MAP=" + MAP + "kPa";
String mCharge = "$Airmass (g/cyl) =\\frac{(V_Cylinder = " + cylinderDisplacement + "L) " +
"* (VE(" + rpm_map + ") = " + VE + "\\%) " +
"* (MAP = " + MAP + "Kpa)" +
"}{" +
"(GAS_R = 0.28705) * ((Tcharge = " + T_CHARGE + "C) + 273.15)} = " +
chargeAirMass +
"$";
String baseFuelStr = twoDecimals(Sensor.baseFuel);
String baseFuel = "$SD_Fuel (ms) = \\frac{" +
"($Airmass = " + chargeAirMass + ")" +
"}{" +
"(TargetAFR (" + rpm_map + ") = " + TARGET_AFR + ")" +
" * (injectorFlow = " + injectorFlow + " cc/min)" +
"} = " + baseFuelStr + "ms$";
String IATcorr = twoDecimals(Sensor.iatCorrection);
String CLTcorr = twoDecimals(Sensor.cltCorrection);
String tpsAccel = twoDecimals(Sensor.tpsAccelFuel);
String tempCorrections = " * cltCorr(" + CLTcorr + ") * iatCorr(" + IATcorr + ")";
String actualLastInjection = twoDecimals(Sensor.actualLastInjection);
String injTime = "$Fuel (ms) = " +
"(SD_Fuel (" + baseFuelStr + "ms) + Tps_Accel_Corr = (" + tpsAccel + "ms))" +
tempCorrections + NL + getInjecctorLag() +
" = " + actualLastInjection + "ms_per_injection$";
return acceleration +
tCharge + NL3 +
mCharge + NL2 +
baseFuel + NL2 +
injTime + NL;
}
@NotNull
private String getInjecctorLag() {
String vBatt = twoDecimals(Sensor.VBATT);
return "+ ( injectorLag(VBatt = " + vBatt + ") = " + twoDecimals(Sensor.injectorLagMs) + ")";
}
private String oneDecimal(Sensor sensor) {
return oneDecimal(SensorCentral.getInstance().getValue(sensor));
}
private String twoDecimals(Sensor sensor) {
return twoDecimals(SensorCentral.getInstance().getValue(sensor));
}
private String oneDecimal(double ve) {
return String.format("%.1f", ve);
}
private String twoDecimals(double ve) {
return String.format("%.2f", ve);
}
public JPanel getContent() {

View File

@ -19,7 +19,6 @@
<orderEntry type="library" name="SteelSeries" level="project" />
<orderEntry type="module" module-name="autotest" />
<orderEntry type="module" module-name="romraider" />
<orderEntry type="library" name="jlatexmath" level="project" />
<orderEntry type="module" module-name="configuration_definition" />
<orderEntry type="library" name="httpclient" level="project" />
<orderEntry type="library" name="XML for 11" level="project" />