mirror of https://github.com/FOME-Tech/fome-fw.git
I'm drowning in dead code
This commit is contained in:
parent
3d8fdcc089
commit
dcb1ca5f83
|
@ -1,78 +0,0 @@
|
|||
package com.rusefi.logic;
|
||||
|
||||
/**
|
||||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
* 12/24/2015
|
||||
*/
|
||||
public class IgnitionMapBuilder {
|
||||
public enum ChamberStyle {
|
||||
OPEN_CHAMBER(33),
|
||||
CLOSED_CHAMBER(28),
|
||||
SWIRL_TUMBLE(22);
|
||||
|
||||
|
||||
private final int advance;
|
||||
|
||||
ChamberStyle(int advance) {
|
||||
this.advance = advance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static double getTopAdvanceForBore(ChamberStyle style, int octane, double compression, double bore) {
|
||||
int octaneCorrection;
|
||||
if ( octane <= 90) {
|
||||
octaneCorrection = -2;
|
||||
} else if (octane < 94) {
|
||||
octaneCorrection = -1;
|
||||
} else {
|
||||
octaneCorrection = 0;
|
||||
}
|
||||
|
||||
int compressionCorrection;
|
||||
if (compression <= 9) {
|
||||
compressionCorrection = 2;
|
||||
} else if (compression <= 10) {
|
||||
compressionCorrection = 1;
|
||||
} else if (compression <= 11) {
|
||||
compressionCorrection = 0;
|
||||
} else {
|
||||
// compression ratio above 11
|
||||
compressionCorrection = -2;
|
||||
}
|
||||
|
||||
double result = style.advance + octaneCorrection + compressionCorrection + getBoreCorrection(bore);
|
||||
return round10(result);
|
||||
}
|
||||
|
||||
public static double interpolate(double x1, double y1, double x2, double y2, double x) {
|
||||
double a = ((y1 - y2) / (x1 - x2));
|
||||
double b = y1 - a * x1;
|
||||
return a * x + b;
|
||||
}
|
||||
|
||||
public static double getAdvanceForRpm(int rpm, double advanceMax) {
|
||||
if (rpm >= 3000)
|
||||
return advanceMax;
|
||||
if (rpm < 600)
|
||||
return 10;
|
||||
return interpolate(600, 10, 3000, advanceMax, rpm);
|
||||
}
|
||||
|
||||
public static double getInitialAdvance(int rpm, double map, double advanceMax) {
|
||||
double advance = getAdvanceForRpm(rpm, advanceMax);
|
||||
|
||||
if (rpm > 3000)
|
||||
return round10(advance + 0.1 * (100 - map));
|
||||
|
||||
return round10(advance + 0.1 * (100 - map) * rpm / 3000);
|
||||
}
|
||||
|
||||
public static double round10(double result) {
|
||||
return ((int)(result * 10)) / 10.0;
|
||||
}
|
||||
|
||||
public static double getBoreCorrection(double bore) {
|
||||
return (bore - 4 * 25.4) / 25.4 * 6;
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package com.rusefi.logic.test;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.rusefi.logic.IgnitionMapBuilder.*;
|
||||
import static com.rusefi.logic.IgnitionMapBuilder.ChamberStyle.*;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
* 12/24/2015
|
||||
*/
|
||||
public class IgnitionMapBuilderTest {
|
||||
private static final double EPS = 0.001;
|
||||
|
||||
@Test
|
||||
public void testIgnitionMapBuilder() {
|
||||
assertEquals(1.1, round10(1.1));
|
||||
assertEquals(1.1, round10(1.123));
|
||||
|
||||
assertEquals(0.0, getBoreCorrection(4 * 25.4));
|
||||
assertEquals(6.0, getBoreCorrection(5 * 25.4), EPS);
|
||||
|
||||
assertEquals(35.0, getTopAdvanceForBore(OPEN_CHAMBER, 98, 8, 101.6));
|
||||
assertEquals(33.0, getTopAdvanceForBore(OPEN_CHAMBER, 98, 11, 101.6));
|
||||
|
||||
assertEquals(22.0, getTopAdvanceForBore(SWIRL_TUMBLE, 89, 9, 101.6));
|
||||
assertEquals(32.2, getTopAdvanceForBore(SWIRL_TUMBLE, 89, 9, 145));
|
||||
|
||||
assertEquals(10.0, interpolate(0, 10, 10, 20, 0));
|
||||
assertEquals(20.0, interpolate(0, 10, 10, 20, 10));
|
||||
|
||||
assertEquals(10.0, getAdvanceForRpm(0, 36));
|
||||
assertEquals(10.0, getAdvanceForRpm(600, 36));
|
||||
assertEquals(36.0, getAdvanceForRpm(6500, 36));
|
||||
|
||||
assertEquals(16.5, getAdvanceForRpm(1200, 36));
|
||||
assertEquals(29.5, getAdvanceForRpm(2400, 36));
|
||||
|
||||
assertEquals(36.0, getInitialAdvance(6000, 100, 36));
|
||||
assertEquals(10.0, getInitialAdvance(600, 100, 36));
|
||||
|
||||
assertEquals(44.0, getInitialAdvance(6000, 20, 36));
|
||||
|
||||
assertEquals(34.3, getInitialAdvance(2400, 40, 36));
|
||||
assertEquals(42.0, getInitialAdvance(4400, 40, 36));
|
||||
assertEquals(11.6, getInitialAdvance(600, 20, 36));
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package com.rusefi.maintenance;
|
||||
|
||||
import com.rusefi.ui.StatusWindow;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
/**
|
||||
* This class is in charge of status bar animation with dots running from empty to DOTS_COUNT
|
||||
*/
|
||||
public class StatusAnimation {
|
||||
private static final String WORKING = "Working";
|
||||
private static final int DOTS_COUNT = 5;
|
||||
|
||||
private final Timer timer;
|
||||
private volatile boolean isStopped;
|
||||
private int counter;
|
||||
|
||||
public StatusAnimation(StatusWindow wnd) {
|
||||
timer = new Timer(200 /*ms*/, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (isStopped)
|
||||
return;
|
||||
counter++;
|
||||
StringBuilder status = new StringBuilder(WORKING);
|
||||
for (int i = 0; i < counter % DOTS_COUNT; i++) {
|
||||
status.append(".");
|
||||
}
|
||||
wnd.setStatus(status.toString());
|
||||
}
|
||||
});
|
||||
timer.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
timer.stop();
|
||||
isStopped = true;
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package com.rusefi.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 7/27/13
|
||||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
*/
|
||||
public class ChartRepository {
|
||||
private static final ChartRepository instance = new ChartRepository();
|
||||
|
||||
private final List<String> charts = new ArrayList<>();
|
||||
|
||||
private ChartRepository() {
|
||||
}
|
||||
|
||||
public static ChartRepository getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public String getChart(int index) {
|
||||
if (index < 0 || index >= charts.size())
|
||||
throw new IllegalArgumentException("No chart by index " + index);
|
||||
return charts.get(index);
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return charts.size();
|
||||
}
|
||||
|
||||
public void addChart(String value) {
|
||||
charts.add(value);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
charts.clear();
|
||||
}
|
||||
|
||||
public interface ChartRepositoryListener {
|
||||
void onDigitalChart(String chart);
|
||||
}
|
||||
|
||||
public ChartScrollControl createControls(final ChartRepositoryListener listener) {
|
||||
return new ChartScrollControl(listener);
|
||||
}
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
package com.rusefi.ui;
|
||||
|
||||
import com.rusefi.KeyStrokeShortcut;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 4/7/14
|
||||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
*/
|
||||
public class ChartScrollControl {
|
||||
private final JPanel content = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
|
||||
private final AtomicInteger index = new AtomicInteger();
|
||||
private static final JLabel info = new JLabel();
|
||||
private final ChartRepository.ChartRepositoryListener listener;
|
||||
|
||||
public ChartScrollControl(final ChartRepository.ChartRepositoryListener listener) {
|
||||
|
||||
this.listener = listener;
|
||||
info.setToolTipText("Current page index / total pages count");
|
||||
|
||||
content.setBorder(BorderFactory.createLineBorder(Color.red));
|
||||
|
||||
setInfoText(index);
|
||||
|
||||
JButton prev = new JButton("<");
|
||||
prev.setToolTipText("Previous page");
|
||||
prev.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
previousPage();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
JButton next = new JButton(">");
|
||||
next.setToolTipText("Next page");
|
||||
next.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
nextPage();
|
||||
}
|
||||
});
|
||||
|
||||
content.add(prev);
|
||||
content.add(info);
|
||||
content.add(next);
|
||||
|
||||
bindKeyStrokeActions();
|
||||
}
|
||||
|
||||
private void previousPage() {
|
||||
if (ChartRepository.getInstance().getSize() < index.get()) {
|
||||
index.set(0);
|
||||
}
|
||||
if (ChartRepository.getInstance().getSize() == 0)
|
||||
return;
|
||||
if (index.intValue() > 0) {
|
||||
index.decrementAndGet();
|
||||
showChart();
|
||||
} else if (index.intValue() == 0) {
|
||||
// let's go to the last chart if chart repository is not empty
|
||||
index.set(ChartRepository.getInstance().getSize() - 1);
|
||||
showChart();
|
||||
}
|
||||
}
|
||||
|
||||
private void showChart() {
|
||||
listener.onDigitalChart(ChartRepository.getInstance().getChart(index.get()));
|
||||
setInfoText(index);
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
if (index.intValue() < ChartRepository.getInstance().getSize() - 1) {
|
||||
index.incrementAndGet();
|
||||
showChart();
|
||||
}
|
||||
}
|
||||
|
||||
private void bindKeyStrokeActions() {
|
||||
InputMap inputMap = content.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
|
||||
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), KeyStrokeShortcut.PREVIOUS_PAGE);
|
||||
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), KeyStrokeShortcut.NEXT_PAGE);
|
||||
|
||||
content.getActionMap().put(KeyStrokeShortcut.PREVIOUS_PAGE, new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
previousPage();
|
||||
}
|
||||
});
|
||||
content.getActionMap().put(KeyStrokeShortcut.NEXT_PAGE, new AbstractAction() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
nextPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public JPanel getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
private void setInfoText(AtomicInteger index) {
|
||||
int humanIndex = index.get() + 1;
|
||||
info.setText(humanIndex + "/" + ChartRepository.getInstance().getSize());
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
index.set(0);
|
||||
setInfoText(index);
|
||||
}
|
||||
}
|
||||
|
|
@ -67,7 +67,6 @@ public class EngineSnifferPanel {
|
|||
private final ZoomControl zoomControl = new ZoomControl();
|
||||
private final EngineSnifferStatusPanel statusPanel = new EngineSnifferStatusPanel();
|
||||
private final UpDownImage crank = createImage(Fields.PROTOCOL_CRANK1);
|
||||
private final ChartScrollControl scrollControl;
|
||||
private final AnyCommand command;
|
||||
|
||||
private boolean isPaused;
|
||||
|
@ -100,9 +99,6 @@ public class EngineSnifferPanel {
|
|||
|
||||
upperPanel.add(zoomControl);
|
||||
|
||||
scrollControl = ChartRepository.getInstance().createControls(this::displayChart);
|
||||
upperPanel.add(scrollControl.getContent());
|
||||
|
||||
upperPanel.add(new URLLabel(HELP_TEXT, HELP_URL));
|
||||
|
||||
JPanel bottomPanel = new JPanel(new BorderLayout());
|
||||
|
@ -287,11 +283,6 @@ public class EngineSnifferPanel {
|
|||
return image;
|
||||
}
|
||||
|
||||
public void reloadFile() {
|
||||
displayChart(ChartRepository.getInstance().getChart(0));
|
||||
scrollControl.reset();
|
||||
}
|
||||
|
||||
public ActionListener getTabSelectedListener() {
|
||||
return e -> {
|
||||
if (command != null)
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.awt.event.KeyEvent;
|
|||
class ZoomControl extends JPanel {
|
||||
private double value;
|
||||
public ZoomControlListener listener = null;
|
||||
private final JButton resetZoom = new JButton("*");
|
||||
private final JButton resetZoom = new JButton("reset");
|
||||
|
||||
private final ZoomProvider zoomProvider = new ZoomProvider() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue