only:nicer logging

This commit is contained in:
rusefillc 2024-03-09 16:55:15 -05:00
parent 086372f8f0
commit 4096a61a7e
4 changed files with 32 additions and 19 deletions

View File

@ -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> T readModel(Class<?> modelClass, File xmlFile) throws JAXBException {

View File

@ -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) {

View File

@ -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"});
}
*/
}

View File

@ -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));