From 4096a61a7e065ec5e91a86b2c0d407892921bcac Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sat, 9 Mar 2024 16:55:15 -0500 Subject: [PATCH] only:nicer logging --- .../src/main/java/com/rusefi/xml/XmlUtil.java | 18 ++++++++----- .../main/java/com/rusefi/tools/tune/TS2C.java | 3 ++- .../com/rusefi/tools/tune/TS2CRunner.java | 3 +++ .../com/rusefi/tools/tune/TuneCanTool.java | 27 ++++++++++--------- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/java_console/inifile/src/main/java/com/rusefi/xml/XmlUtil.java b/java_console/inifile/src/main/java/com/rusefi/xml/XmlUtil.java index 75ec04ef9d..524d574560 100644 --- a/java_console/inifile/src/main/java/com/rusefi/xml/XmlUtil.java +++ b/java_console/inifile/src/main/java/com/rusefi/xml/XmlUtil.java @@ -1,5 +1,7 @@ package com.rusefi.xml; +import com.devexperts.logging.Logging; + import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; @@ -9,7 +11,11 @@ import java.io.FileWriter; import java.io.IOException; import java.io.StringWriter; +import static com.devexperts.logging.Logging.getLogging; + public class XmlUtil { + private static final Logging log = getLogging(XmlUtil.class); + static { XmlUtil.setParserImpl(); } @@ -22,13 +28,13 @@ public class XmlUtil { StringWriter xmlWriter = new StringWriter(); marshaller.marshal(instance, xmlWriter); - System.out.println(xmlWriter.toString()); - System.out.println("Writing " + fileName); - FileWriter writer = new FileWriter(fileName); - marshaller.marshal(instance, writer); - System.out.println("Marshalling finished " + fileName); - writer.close(); + log.info("Writing " + fileName); + try (FileWriter writer = new FileWriter(fileName)) { + marshaller.marshal(instance, writer); + } finally { + log.info("Marshalling finished " + fileName); + } } public static T readModel(Class modelClass, File xmlFile) throws JAXBException { diff --git a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TS2C.java b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TS2C.java index 7db6dd7818..ef71ff30ea 100644 --- a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TS2C.java +++ b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TS2C.java @@ -32,10 +32,11 @@ public class TS2C { /** * @see TS2CRunner */ +/* public static void main(String[] args) throws IOException { new TS2C(args); } - +*/ private TS2C(String[] args) throws IOException { System.out.println("This tool reads TS tune file and produces some C code for hardcoded base tunes"); if (args.length != 3 && args.length != 4 && args.length != 5) { diff --git a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TS2CRunner.java b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TS2CRunner.java index bfb36b0422..2c86ce3fd7 100644 --- a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TS2CRunner.java +++ b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TS2CRunner.java @@ -3,6 +3,7 @@ package com.rusefi.tools.tune; import java.io.IOException; public class TS2CRunner { +/* public static void main(String[] args) throws IOException { String tuneFileName = "CurrentTune.msq"; @@ -27,4 +28,6 @@ public class TS2CRunner { // TS2C.main(new String[]{tuneFileName, "fuelLoadBins", "fuelRpmBins", "fuelTable"}); } +*/ } + diff --git a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TuneCanTool.java b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TuneCanTool.java index f0397450f1..00a5ad41aa 100644 --- a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TuneCanTool.java +++ b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/TuneCanTool.java @@ -57,7 +57,11 @@ public class TuneCanTool implements TuneCanToolConstants { public static void main(String[] args) throws Exception { - writeDiffBetweenLocalTuneFileAndDefaultTune("../1.msq"); + //writeDiffBetweenLocalTuneFileAndDefaultTune("../1.msq"); + + writeDiffBetweenLocalTuneFileAndDefaultTune("vehicleName", getDefaultTuneName(engine_type_e.HONDA_OBD1), + "C:\\stuff\\\\2024-03-09-CurrentTune.msq", "comment", ""); + // writeDiffBetweenLocalTuneFileAndDefaultTune("vehicleName", getDefaultTuneName(Fields.engine_type_e_MAVERICK_X3), // "C:\\stuff\\i\\canam-2022-short\\canam-progress-pnp-dec-29.msq", "comment"); @@ -175,12 +179,11 @@ public class TuneCanTool implements TuneCanToolConstants { StringBuilder sb = new StringBuilder(); for (DialogModel.Field f : ini.fieldsInUiOrder.values()) { String fieldName = f.getKey(); -// System.out.println("Processing " + fieldName); Constant customValue = customTune.getConstantsAsMap().get(fieldName); Constant defaultValue = defaultTune.getConstantsAsMap().get(fieldName); if (defaultValue == null) { // no longer present? - System.out.println("Not found in default tune: " + fieldName); + log.info("Not found in default tune: " + fieldName); continue; } Objects.requireNonNull(defaultValue.getValue(), "d value"); @@ -192,7 +195,7 @@ public class TuneCanTool implements TuneCanToolConstants { boolean isSameValue = simplerSpaces(defaultValue.getValue()).equals(simplerSpaces(customValue.getValue())); if (isSameValue) { - System.out.println("Even text form matches default: " + fieldName); + log.info("Even text form matches default: " + fieldName); continue; } @@ -208,7 +211,7 @@ public class TuneCanTool implements TuneCanToolConstants { float floatDefaultValue = Float.parseFloat(defaultValue.getValue()); float floatCustomValue = Float.parseFloat(customValue.getValue()); if (floatCustomValue != 0 && Math.abs(floatDefaultValue / floatCustomValue - 1) < 0.001) { - System.out.println("Skipping rounding error " + floatDefaultValue + " vs " + floatCustomValue); + log.info("Skipping rounding error " + floatDefaultValue + " vs " + floatCustomValue); continue; } } @@ -232,7 +235,7 @@ public class TuneCanTool implements TuneCanToolConstants { } else { // todo: for instance map.samplingAngle //throw new IllegalStateException("Unexpected " + cf.getParent()); - System.out.println(" " + cf); + log.info(" " + cf); continue; } @@ -240,19 +243,19 @@ public class TuneCanTool implements TuneCanToolConstants { if (cf.getArraySizes().length == 2) { TableData tableData = TableData.readTable(customTuneFileName, fieldName, ini); if (tableData == null) { - System.out.println(" " + fieldName); + log.info(" " + fieldName); continue; } - System.out.println("Handling table " + fieldName + " with " + cf.autoscaleSpecPair()); + log.info("Handling table " + fieldName + " with " + cf.autoscaleSpecPair()); if (defaultTuneFileName != null) { TableData defaultTableData = TableData.readTable(defaultTuneFileName, fieldName, ini); if (defaultTableData.getCsourceMethod(parentReference, methodNamePrefix).equals(tableData.getCsourceMethod(parentReference, methodNamePrefix))) { - System.out.println("Table " + fieldName + " matches default content"); + log.info("Table " + fieldName + " matches default content"); continue; } } - System.out.println("Custom content in table " + fieldName); + log.info("Custom content in table " + fieldName); methods.append(tableData.getCsourceMethod(parentReference, methodNamePrefix)); @@ -267,11 +270,11 @@ public class TuneCanTool implements TuneCanToolConstants { if (defaultTuneFileName != null) { CurveData defaultCurveData = CurveData.valueOf(defaultTuneFileName, fieldName, ini); if (defaultCurveData.getCinvokeMethod(methodNamePrefix).equals(data.getCinvokeMethod(methodNamePrefix))) { - System.out.println("Curve " + fieldName + " matches default content"); + log.info("Curve " + fieldName + " matches default content"); continue; } } - System.out.println("Custom content in curve " + fieldName); + log.info("Custom content in curve " + fieldName); methods.append(data.getCsourceMethod(parentReference, methodNamePrefix)); invokeMethods.append(data.getCinvokeMethod(methodNamePrefix));