only:nicer logging

This commit is contained in:
rusefillc 2023-11-25 17:24:23 -05:00
parent 979f4637a9
commit e87600c748
1 changed files with 19 additions and 12 deletions

View File

@ -1,10 +1,12 @@
package com.rusefi.tools.tune; package com.rusefi.tools.tune;
import com.devexperts.logging.Logging;
import com.opensr5.ini.DialogModel; import com.opensr5.ini.DialogModel;
import com.opensr5.ini.IniFileModel; import com.opensr5.ini.IniFileModel;
import com.rusefi.*; import com.rusefi.*;
import com.rusefi.core.preferences.storage.Node; import com.rusefi.core.preferences.storage.Node;
import com.rusefi.output.ConfigStructure; import com.rusefi.output.ConfigStructure;
import com.rusefi.pinout.PinoutLogic;
import com.rusefi.tune.xml.Constant; import com.rusefi.tune.xml.Constant;
import com.rusefi.tune.xml.Msq; import com.rusefi.tune.xml.Msq;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -21,11 +23,14 @@ import java.nio.file.StandardCopyOption;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import static com.devexperts.logging.Logging.getLogging;
import static com.rusefi.ConfigFieldImpl.unquote; import static com.rusefi.ConfigFieldImpl.unquote;
import static com.rusefi.config.Field.niceToString; import static com.rusefi.config.Field.niceToString;
import static com.rusefi.tools.tune.WriteSimulatorConfiguration.INI_FILE_FOR_SIMULATOR; import static com.rusefi.tools.tune.WriteSimulatorConfiguration.INI_FILE_FOR_SIMULATOR;
public class TuneCanTool { public class TuneCanTool {
private static final Logging log = getLogging(TuneCanTool.class);
public static final String SRC_TEST_RESOURCES = "src/test/resources/"; public static final String SRC_TEST_RESOURCES = "src/test/resources/";
private static final String FOLDER = "generated"; private static final String FOLDER = "generated";
public static final String SIMULATED_PREFIX = FOLDER + File.separator + "simulator_tune"; public static final String SIMULATED_PREFIX = FOLDER + File.separator + "simulator_tune";
@ -45,12 +50,13 @@ public class TuneCanTool {
RootHolder.ROOT = "../firmware/"; RootHolder.ROOT = "../firmware/";
handle("PB", 1502); handle("BK2", 1507);
handle("Mitsubicha", 1258); // handle("PB", 1502);
handle("Scion-1NZ-FE", 1448); // handle("Mitsubicha", 1258);
handle("4g93", 1425); // handle("Scion-1NZ-FE", 1448);
handle("BMW-mtmotorsport", 1479); // handle("4g93", 1425);
handle("m111-alex", 1490); // handle("BMW-mtmotorsport", 1479);
// handle("m111-alex", 1490);
} }
private static void handle(String vehicleName, int tuneId) throws JAXBException, IOException { private static void handle(String vehicleName, int tuneId) throws JAXBException, IOException {
@ -121,18 +127,19 @@ public class TuneCanTool {
} }
Objects.requireNonNull(defaultValue.getValue(), "d value"); Objects.requireNonNull(defaultValue.getValue(), "d value");
if (customValue == null) { if (customValue == null) {
System.out.println("Skipping " + name + " TODO"); log.info("Skipping " + name + " TODO");
continue; continue;
} }
Objects.requireNonNull(customValue.getValue(), "c value"); Objects.requireNonNull(customValue.getValue(), "c value");
boolean isSameValue = simplerSpaces(defaultValue.getValue()).equals(simplerSpaces(customValue.getValue())); boolean isSameValue = simplerSpaces(defaultValue.getValue()).equals(simplerSpaces(customValue.getValue()));
if (!isSameValue) { if (!isSameValue) {
// todo: what about stuff outside of engine_configuration_s?
ConfigStructure s = state.getStructures().get("engine_configuration_s"); ConfigStructure s = state.getStructures().get("engine_configuration_s");
System.out.println(s); // log.info("We have a custom value " + name);
ConfigField cf = s.getTsFieldByName(name); ConfigField cf = s.getTsFieldByName(name);
if (cf == null) { if (cf == null) {
System.out.println("Not found " + name); log.info("Not found " + name);
continue; continue;
} }
String cName = cf.getOriginalArrayName(); String cName = cf.getOriginalArrayName();
@ -152,7 +159,7 @@ public class TuneCanTool {
} }
EnumsReader.EnumState sourceCodeEnum = state.getEnumsReader().getEnums().get(type); EnumsReader.EnumState sourceCodeEnum = state.getEnumsReader().getEnums().get(type);
if (sourceCodeEnum == null) { if (sourceCodeEnum == null) {
System.out.println("No info for " + type); log.info("No info for " + type);
continue; continue;
} }
String customEnum = state.getTsCustomLine().get(type); String customEnum = state.getTsCustomLine().get(type);
@ -161,11 +168,11 @@ public class TuneCanTool {
try { try {
ordinal = TuneTools.resolveEnumByName(customEnum, unquote(customValue.getValue())); ordinal = TuneTools.resolveEnumByName(customEnum, unquote(customValue.getValue()));
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
System.out.println("Looks like things were renamed: " + customValue.getValue() + " not found in " + customEnum); log.info("Looks like things were renamed: " + customValue.getValue() + " not found in " + customEnum);
continue; continue;
} }
System.out.println(cf + " " + sourceCodeEnum + " " + customEnum + " " + ordinal); log.info(cf + " " + sourceCodeEnum + " " + customEnum + " " + ordinal);
String sourceCodeValue = sourceCodeEnum.findByValue(ordinal); String sourceCodeValue = sourceCodeEnum.findByValue(ordinal);
sb.append(TuneTools.getAssignmentCode(defaultValue, customValue.getName(), sourceCodeValue)); sb.append(TuneTools.getAssignmentCode(defaultValue, customValue.getName(), sourceCodeValue));