diff --git a/firmware/controllers/map_averaging.cpp b/firmware/controllers/map_averaging.cpp
index 8d71d6f021..6ed87df102 100644
--- a/firmware/controllers/map_averaging.cpp
+++ b/firmware/controllers/map_averaging.cpp
@@ -176,17 +176,17 @@ static void mapAveragingCallback(trigger_event_e ckpEventType, uint32_t index DE
MAP_sensor_config_s * config = &engineConfiguration->map;
- float startAngle = interpolate2d(rpm, config->samplingAngleBins, config->samplingAngle, MAP_ANGLE_SIZE);
- float windowAngle = interpolate2d(rpm, config->samplingWindowBins, config->samplingWindow, MAP_WINDOW_SIZE);
- if (windowAngle <= 0) {
+ angle_t samplingStart = interpolate2d(rpm, config->samplingAngleBins, config->samplingAngle, MAP_ANGLE_SIZE);
+ angle_t samplingDuration = interpolate2d(rpm, config->samplingWindowBins, config->samplingWindow, MAP_WINDOW_SIZE);
+ if (samplingDuration <= 0) {
firmwareError("map sampling angle should be positive");
return;
}
int structIndex = getRevolutionCounter() % 2;
// todo: schedule this based on closest trigger event, same as ignition works
- scheduleByAngle(rpm, &startTimer[structIndex], startAngle, startAveraging, NULL);
- scheduleByAngle(rpm, &endTimer[structIndex], startAngle + windowAngle, endAveraging, NULL);
+ scheduleByAngle(rpm, &startTimer[structIndex], samplingStart, startAveraging, NULL);
+ scheduleByAngle(rpm, &endTimer[structIndex], samplingStart + samplingDuration, endAveraging, NULL);
}
static void showMapStats(void) {
diff --git a/firmware/integration/rusefi.xml b/firmware/integration/rusefi.xml
index 403d8312cf..15d29a97ae 100644
--- a/firmware/integration/rusefi.xml
+++ b/firmware/integration/rusefi.xml
@@ -74,9 +74,9 @@
-
+
-
diff --git a/java_console/romraider/src/com/romraider/editor/ecu/ECUEditor.java b/java_console/romraider/src/com/romraider/editor/ecu/ECUEditor.java
index 65990cf123..e2ddb1a208 100644
--- a/java_console/romraider/src/com/romraider/editor/ecu/ECUEditor.java
+++ b/java_console/romraider/src/com/romraider/editor/ecu/ECUEditor.java
@@ -52,6 +52,8 @@ import java.io.FileReader;
import java.io.IOException;
import java.util.Vector;
+import javax.management.modelmbean.XMLParseException;
+import javax.naming.NameNotFoundException;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JInternalFrame;
@@ -66,6 +68,7 @@ import javax.swing.tree.TreePath;
import com.rusefi.Launcher;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import com.romraider.Settings;
@@ -171,27 +174,10 @@ public class ECUEditor {
return content;
}
- public static void openImage(byte[] input, File definitionFile, String fileName) throws Exception {
+ public static void openImage(byte[] input, File definitionFile, String fileName) throws IOException, SAXException,
+ RomNotFoundException, XMLParseException, NameNotFoundException {
ECUEditor editor = ECUEditorManager.getECUEditor();
- DOMParser parser = new DOMParser();
- Document doc;
- FileInputStream fileStream;
- fileStream = new FileInputStream(definitionFile);
- InputSource src = new InputSource(fileStream);
-
- parser.parse(src);
- doc = parser.getDocument();
-
- Rom rom;
- try {
- rom = new DOMRomUnmarshaller().unmarshallXMLDefinition(doc.getDocumentElement(), input, editor.getStatusPanel());
- } finally {
- // Release mem after unmarshall.
- parser.reset();
- doc.removeChild(doc.getDocumentElement());
- fileStream.close();
- System.gc();
- }
+ Rom rom = readRom(input, definitionFile, editor);
editor.getStatusPanel().setStatus("Populating tables...");
@@ -206,6 +192,29 @@ public class ECUEditor {
editor.getStatusPanel().setStatus("Done loading image...");
}
+ private static Rom readRom(byte[] romContent, File romDefinitionFile, ECUEditor editor) throws SAXException, IOException, RomNotFoundException, XMLParseException, NameNotFoundException {
+ DOMParser parser = new DOMParser();
+ Document doc;
+ FileInputStream fileStream;
+ fileStream = new FileInputStream(romDefinitionFile);
+ InputSource src = new InputSource(fileStream);
+
+ parser.parse(src);
+ doc = parser.getDocument();
+
+ Rom rom;
+ try {
+ rom = new DOMRomUnmarshaller().unmarshallXMLDefinition(doc.getDocumentElement(), romContent, editor.getStatusPanel());
+ } finally {
+ // Release mem after unmarshall.
+ parser.reset();
+ doc.removeChild(doc.getDocumentElement());
+ fileStream.close();
+ System.gc();
+ }
+ return rom;
+ }
+
public void initializeEditorUI() {
//create menubar
menuBar = new ECUEditorMenuBar();
diff --git a/java_console/romraider/src/com/romraider/util/ObjectCloner.java b/java_console/romraider/src/com/romraider/util/ObjectCloner.java
index 46b12425da..fb520ab1ea 100644
--- a/java_console/romraider/src/com/romraider/util/ObjectCloner.java
+++ b/java_console/romraider/src/com/romraider/util/ObjectCloner.java
@@ -19,10 +19,7 @@
package com.romraider.util;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+import java.io.*;
public final class ObjectCloner {
@@ -30,7 +27,7 @@ public final class ObjectCloner {
}
// returns a deep copy of an object
- public static Object deepCopy(Object obj) throws Exception {
+ public static Object deepCopy(Object obj) {
/*ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
ObjectOutputStream oos = new ObjectOutputStream(bos);
@@ -82,15 +79,25 @@ public final class ObjectCloner {
// read the serialized, and deep copied, object and return it
return inStream.readObject();
- } catch (Exception e) {
- throw (e);
+ } catch (Throwable e) {
+ throw new IllegalStateException(e);
} finally {
//always close your streams in finally clauses
- outStream.close();
- inStream.close();
+ close(outStream);
+ close(inStream);
}
}
+
+ public static void close(Closeable closeable) {
+ if(closeable!=null) {
+ try {
+ closeable.close();
+ } catch (IOException e) {
+ // ignoring exception during close()
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/java_console/romraider/src/com/romraider/xml/DOMRomUnmarshaller.java b/java_console/romraider/src/com/romraider/xml/DOMRomUnmarshaller.java
index a67844cb23..d136cb6881 100644
--- a/java_console/romraider/src/com/romraider/xml/DOMRomUnmarshaller.java
+++ b/java_console/romraider/src/com/romraider/xml/DOMRomUnmarshaller.java
@@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.management.modelmbean.XMLParseException;
+import javax.naming.NameNotFoundException;
import javax.swing.JOptionPane;
import com.rusefi.Launcher;
@@ -62,9 +63,9 @@ public final class DOMRomUnmarshaller {
public DOMRomUnmarshaller() {
}
- public Rom unmarshallXMLDefinition(Node rootNode, byte[] input,
+ public Rom unmarshallXMLDefinition(Node rootNode, byte[] romContent,
JProgressPane progress) throws RomNotFoundException,
- XMLParseException, StackOverflowError, Exception {
+ XMLParseException, NameNotFoundException {
this.progress = progress;
Node n;
@@ -97,13 +98,13 @@ public final class DOMRomUnmarshaller {
RomID romID = unmarshallRomID(n2, new RomID());
if (romID.getInternalIdString().length() > 0
- && foundMatch(romID, input)) {
+ && foundMatch(romID, romContent)) {
Rom output = unmarshallRom(n, new Rom());
// set ram offset
output.getRomID().setRamOffset(
output.getRomID().getFileSize()
- - input.length);
+ - romContent.length);
return output;
}
}
@@ -189,7 +190,7 @@ public final class DOMRomUnmarshaller {
}
public Rom unmarshallRom(Node rootNode, Rom rom) throws XMLParseException,
- RomNotFoundException, StackOverflowError, Exception {
+ RomNotFoundException, NameNotFoundException {
Node n;
NodeList nodes = rootNode.getChildNodes();
@@ -251,8 +252,7 @@ public final class DOMRomUnmarshaller {
}
public Rom getBaseRom(Node rootNode, String xmlID, Rom rom)
- throws XMLParseException, RomNotFoundException, StackOverflowError,
- Exception {
+ throws XMLParseException, RomNotFoundException, NameNotFoundException {
Node n;
NodeList nodes = rootNode.getChildNodes();
@@ -351,7 +351,7 @@ public final class DOMRomUnmarshaller {
}
private Table unmarshallTable(Node tableNode, Table table, Rom rom)
- throws XMLParseException, TableIsOmittedException, Exception {
+ throws XMLParseException, TableIsOmittedException, NameNotFoundException {
if (unmarshallAttribute(tableNode, "omit", "false").equalsIgnoreCase(
"true")) { // remove table if omitted