auto-sync

This commit is contained in:
rusEfi 2015-02-16 10:14:31 -06:00
parent 3ca20dbbdf
commit fce4dae25e
59 changed files with 213 additions and 305 deletions

View File

@ -1,7 +1,7 @@
package com.rusefi; package com.rusefi;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.rusefi.waves.WaveChart; import com.rusefi.waves.WaveChart;
import static com.rusefi.IoUtil.nextChart; import static com.rusefi.IoUtil.nextChart;

View File

@ -1,6 +1,6 @@
package com.rusefi; package com.rusefi;
import com.irnems.FileLog; import com.rusefi.FileLog;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;

View File

@ -1,6 +1,6 @@
package com.rusefi; package com.rusefi;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.irnems.core.EngineState; import com.irnems.core.EngineState;
import com.irnems.core.Sensor; import com.irnems.core.Sensor;
import com.irnems.core.SensorCentral; import com.irnems.core.SensorCentral;

View File

@ -1,6 +1,6 @@
package com.rusefi; package com.rusefi;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.rusefi.waves.RevolutionLog; import com.rusefi.waves.RevolutionLog;
import com.rusefi.waves.WaveChart; import com.rusefi.waves.WaveChart;
import com.rusefi.waves.WaveReport; import com.rusefi.waves.WaveReport;

View File

@ -1,4 +1,4 @@
package com.irnems; package com.rusefi;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@ -1,6 +1,6 @@
package com.irnems.file; package com.rusefi.file;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.irnems.core.EngineState; import com.irnems.core.EngineState;
import com.irnems.models.Point3D; import com.irnems.models.Point3D;
import com.irnems.models.XYData; import com.irnems.models.XYData;

View File

@ -1,4 +1,4 @@
package com.irnems.file; package com.rusefi.file;
import com.irnems.core.EngineState; import com.irnems.core.EngineState;

View File

@ -1,4 +1,4 @@
package com.irnems.file; package com.rusefi.file;
import com.irnems.models.XYData; import com.irnems.models.XYData;
import com.irnems.models.XYDataReader; import com.irnems.models.XYDataReader;

View File

@ -1,6 +1,6 @@
package com.rusefi.io; package com.rusefi.io;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.irnems.core.EngineState; import com.irnems.core.EngineState;
import com.rusefi.io.serial.SerialConnector; import com.rusefi.io.serial.SerialConnector;
import com.rusefi.io.tcp.TcpConnector; import com.rusefi.io.tcp.TcpConnector;

View File

@ -1,6 +1,6 @@
package com.rusefi.io.serial; package com.rusefi.io.serial;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.irnems.core.EngineState; import com.irnems.core.EngineState;
import com.rusefi.io.DataListener; import com.rusefi.io.DataListener;
import jssc.SerialPort; import jssc.SerialPort;

View File

@ -1,6 +1,6 @@
package com.rusefi.io.serial; package com.rusefi.io.serial;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.irnems.core.MessagesCentral; import com.irnems.core.MessagesCentral;
import com.rusefi.io.DataListener; import com.rusefi.io.DataListener;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;

View File

@ -1,6 +1,6 @@
package com.rusefi.io.serial; package com.rusefi.io.serial;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.rusefi.io.DataListener; import com.rusefi.io.DataListener;
import jssc.SerialPort; import jssc.SerialPort;
import jssc.SerialPortEvent; import jssc.SerialPortEvent;

View File

@ -1,6 +1,6 @@
package com.rusefi.io.tcp; package com.rusefi.io.tcp;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.rusefi.io.LinkConnector; import com.rusefi.io.LinkConnector;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;

View File

@ -1,5 +1,6 @@
package com.irnems; package com.irnems;
import com.rusefi.FileLog;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.text.FieldPosition; import java.text.FieldPosition;
@ -18,7 +19,7 @@ public final class Histograms {
// ======= Initialization ======= // ======= Initialization =======
private final HashMap<String, StatisticsGroup> total_stats = new HashMap<String, StatisticsGroup>(); private final HashMap<String, StatisticsGroup> total_stats = new HashMap<>();
private final long start_time = System.currentTimeMillis(); private final long start_time = System.currentTimeMillis();
public final ThreadLocal<LocalStats> local_stats = new ThreadLocal<LocalStats>() { public final ThreadLocal<LocalStats> local_stats = new ThreadLocal<LocalStats>() {
@Override @Override
@ -26,7 +27,7 @@ public final class Histograms {
return new LocalStats(); return new LocalStats();
} }
}; };
private final HashSet<LocalStats> all_local_stats = new HashSet<LocalStats>(); private final HashSet<LocalStats> all_local_stats = new HashSet<>();
private long last_dump = System.currentTimeMillis(); private long last_dump = System.currentTimeMillis();
@ -39,7 +40,7 @@ public final class Histograms {
@NotNull @NotNull
public List<String> dumpStats() { public List<String> dumpStats() {
Collection<StatisticsGroup> values = takeAndResetSnapshot(); Collection<StatisticsGroup> values = takeAndResetSnapshot();
List<StatisticsGroup> al = new ArrayList<StatisticsGroup>(); List<StatisticsGroup> al = new ArrayList<>();
al.addAll(values); al.addAll(values);
synchronized (total_stats) { synchronized (total_stats) {
for (StatisticsGroup source : values) { for (StatisticsGroup source : values) {
@ -59,10 +60,11 @@ public final class Histograms {
* *
* @see #dumpStats() * @see #dumpStats()
*/ */
@SuppressWarnings("UnusedDeclaration")
@NotNull @NotNull
public List<String> getCurrentStatistics() { public List<String> getCurrentStatistics() {
Collection<StatisticsGroup> snapshot = getCurrentSnapshot(); Collection<StatisticsGroup> snapshot = getCurrentSnapshot();
return sortAndAddTimes(new ArrayList<StatisticsGroup>(snapshot)); return sortAndAddTimes(new ArrayList<>(snapshot));
} }
private List<String> sortAndAddTimes(List<StatisticsGroup> al) { private List<String> sortAndAddTimes(List<StatisticsGroup> al) {
@ -72,7 +74,7 @@ public final class Histograms {
} }
}); });
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
List<String> result = new ArrayList<String>(); List<String> result = new ArrayList<>();
for (StatisticsGroup sg : al) for (StatisticsGroup sg : al)
result.add(toString(sg, time - (sg.type.endsWith(".TOTAL") ? start_time : last_dump))); result.add(toString(sg, time - (sg.type.endsWith(".TOTAL") ? start_time : last_dump)));
last_dump = time; last_dump = time;
@ -178,7 +180,7 @@ public final class Histograms {
boolean create; boolean create;
create = ls.stats == null; create = ls.stats == null;
if (create) if (create)
ls.stats = new HashMap<ValueType, StatisticsGroup>(); ls.stats = new HashMap<>();
StatisticsGroup sg = ls.stats.get(t); StatisticsGroup sg = ls.stats.get(t);
if (sg == null) if (sg == null)
ls.stats.put(t, sg = new StatisticsGroup(type)); ls.stats.put(t, sg = new StatisticsGroup(type));
@ -194,7 +196,7 @@ public final class Histograms {
*/ */
private Collection<StatisticsGroup> getCurrentSnapshot() { private Collection<StatisticsGroup> getCurrentSnapshot() {
List<LocalStats> lss = getLocalStats(false); List<LocalStats> lss = getLocalStats(false);
HashMap<String, StatisticsGroup> snapshot = new HashMap<String, StatisticsGroup>(); HashMap<String, StatisticsGroup> snapshot = new HashMap<>();
for (LocalStats ls : lss) { for (LocalStats ls : lss) {
// in case of a snapshot without reset, we have to merge under the lock // in case of a snapshot without reset, we have to merge under the lock
mergeStats(snapshot, ls.stats); mergeStats(snapshot, ls.stats);
@ -207,7 +209,7 @@ public final class Histograms {
*/ */
private Collection<StatisticsGroup> takeAndResetSnapshot() { private Collection<StatisticsGroup> takeAndResetSnapshot() {
List<LocalStats> lss = getLocalStats(true); List<LocalStats> lss = getLocalStats(true);
HashMap<String, StatisticsGroup> snapshot = new HashMap<String, StatisticsGroup>(); HashMap<String, StatisticsGroup> snapshot = new HashMap<>();
for (LocalStats ls : lss) { for (LocalStats ls : lss) {
HashMap<ValueType, StatisticsGroup> stats; HashMap<ValueType, StatisticsGroup> stats;
stats = ls.stats; stats = ls.stats;
@ -235,7 +237,7 @@ public final class Histograms {
private List<LocalStats> getLocalStats(boolean reset) { private List<LocalStats> getLocalStats(boolean reset) {
List<LocalStats> lss; List<LocalStats> lss;
synchronized (all_local_stats) { synchronized (all_local_stats) {
lss = new ArrayList<LocalStats>(all_local_stats); lss = new ArrayList<>(all_local_stats);
if (reset) if (reset)
all_local_stats.clear(); all_local_stats.clear();
} }
@ -443,7 +445,7 @@ public final class Histograms {
private StatisticsGroup(String type) { private StatisticsGroup(String type) {
this.type = type; this.type = type;
this.data = new HashMap<String, Statistics>(); this.data = new HashMap<>();
} }
public void add(String name, int index, long value) { public void add(String name, int index, long value) {

View File

@ -4,6 +4,7 @@ import com.irnems.models.Factory;
import com.irnems.models.MafValue; import com.irnems.models.MafValue;
import com.irnems.models.RpmValue; import com.irnems.models.RpmValue;
import com.irnems.models.Utils; import com.irnems.models.Utils;
import com.rusefi.FileLog;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
@ -27,7 +28,7 @@ public class ReportReader {
public static TreeMap<Integer, TreeMap<Integer, ReportLine>> readMap(String filename) { public static TreeMap<Integer, TreeMap<Integer, ReportLine>> readMap(String filename) {
if (!new File(filename).exists()) { if (!new File(filename).exists()) {
FileLog.rlog("Error: not found " + filename); FileLog.rlog("Error: not found " + filename);
return new TreeMap<Integer, TreeMap<Integer, ReportLine>>(); return new TreeMap<>();
} }
List<ReportLine> lines = read(filename); List<ReportLine> lines = read(filename);
FileLog.rlog("Got " + lines.size() + " lines"); FileLog.rlog("Got " + lines.size() + " lines");
@ -43,7 +44,7 @@ public class ReportReader {
/** /**
* map of maps by RPM. inner map is by MAF * map of maps by RPM. inner map is by MAF
*/ */
TreeMap<Integer, TreeMap<Integer, ReportLine>> rpm2mapByMaf = new TreeMap<Integer, TreeMap<Integer, ReportLine>>(); TreeMap<Integer, TreeMap<Integer, ReportLine>> rpm2mapByMaf = new TreeMap<>();
for (ReportLine cur : lines) { for (ReportLine cur : lines) {
int rpmKey = cur.getRpm().getValue(); int rpmKey = cur.getRpm().getValue();
@ -52,7 +53,7 @@ public class ReportReader {
TreeMap<Integer, ReportLine> maf2line = Utils.getOrCreate(rpm2mapByMaf, rpmKey, new Factory<Integer, TreeMap<Integer, ReportLine>>() { TreeMap<Integer, ReportLine> maf2line = Utils.getOrCreate(rpm2mapByMaf, rpmKey, new Factory<Integer, TreeMap<Integer, ReportLine>>() {
public TreeMap<Integer, ReportLine> create(Integer key) { public TreeMap<Integer, ReportLine> create(Integer key) {
return new TreeMap<Integer, ReportLine>(); return new TreeMap<>();
} }
}); });
maf2line.put(cur.getMaf().getValue(), cur); maf2line.put(cur.getMaf().getValue(), cur);
@ -78,7 +79,7 @@ public class ReportReader {
} }
private static List<ReportLine> filter(List<ReportLine> lines) { private static List<ReportLine> filter(List<ReportLine> lines) {
List<ReportLine> result = new ArrayList<ReportLine>(); List<ReportLine> result = new ArrayList<>();
int maxValidDiff = 0; int maxValidDiff = 0;
int originalCount = lines.size(); int originalCount = lines.size();
int removedCount = 0; int removedCount = 0;
@ -110,7 +111,7 @@ public class ReportReader {
} }
private static List<ReportLine> read(String filename) { private static List<ReportLine> read(String filename) {
List<ReportLine> result = new LinkedList<ReportLine>(); List<ReportLine> result = new LinkedList<>();
try { try {
BufferedReader reader = new BufferedReader(new FileReader(filename)); BufferedReader reader = new BufferedReader(new FileReader(filename));
String line; String line;
@ -120,8 +121,6 @@ public class ReportReader {
if (rl != null) if (rl != null)
result.add(rl); result.add(rl);
} }
} catch (FileNotFoundException e) {
throw new IllegalStateException(e);
} catch (IOException e) { } catch (IOException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }

View File

@ -1,6 +1,6 @@
package com.irnems.core; package com.irnems.core;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.rusefi.SensorConversion; import com.rusefi.SensorConversion;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

View File

@ -1,6 +1,6 @@
package com.irnems.core; package com.irnems.core;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.rusefi.io.serial.PortHolder; import com.rusefi.io.serial.PortHolder;
import com.rusefi.io.serial.PortHolderListener; import com.rusefi.io.serial.PortHolderListener;

View File

@ -1,6 +1,6 @@
package com.irnems.models; package com.irnems.models;
import com.irnems.FileLog; import com.rusefi.FileLog;
import java.util.Set; import java.util.Set;

View File

@ -1,6 +1,6 @@
package com.irnems.models; package com.irnems.models;
import com.irnems.FileLog; import com.rusefi.FileLog;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -15,7 +15,7 @@ import java.util.TreeMap;
* Date: 3/24/13 * Date: 3/24/13
* (c) Andrey Belomutskiy * (c) Andrey Belomutskiy
* *
* @see TableGenerator * @see com.rusefi.file.TableGenerator
*/ */
public class XYData { public class XYData {
@NotNull @NotNull

View File

@ -1,6 +1,6 @@
package com.irnems.models; package com.irnems.models;
import com.irnems.FileLog; import com.rusefi.FileLog;
import java.io.*; import java.io.*;

View File

@ -1,6 +1,6 @@
package com.irnems.models; package com.irnems.models;
import com.irnems.FileLog; import com.rusefi.FileLog;
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;

View File

@ -1,6 +1,6 @@
package com.rusefi; package com.rusefi;
import com.irnems.FileLog; import com.rusefi.FileLog;
import org.apache.commons.math3.stat.descriptive.moment.Mean; import org.apache.commons.math3.stat.descriptive.moment.Mean;
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation; import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;

View File

@ -1,6 +1,6 @@
package com.rusefi.waves; package com.rusefi.waves;
import com.irnems.FileLog; import com.rusefi.FileLog;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@ -1,4 +1,4 @@
package com.irnems.core.test; package com.rusefi.waves.test;
import com.rusefi.waves.WaveReport; import com.rusefi.waves.WaveReport;
import com.irnems.waves.ZoomProvider; import com.irnems.waves.ZoomProvider;

View File

@ -1,7 +1,7 @@
package com.irnems.ui.test; package com.irnems.ui.test;
import com.rusefi.ui.FrameHelper; import com.rusefi.ui.FrameHelper;
import com.rusefi.ui.WavePanel; import com.rusefi.ui.engine.EngineSnifferPanel;
import com.rusefi.ui.storage.PersistentConfiguration; import com.rusefi.ui.storage.PersistentConfiguration;
import javax.swing.*; import javax.swing.*;
@ -14,7 +14,7 @@ import java.lang.reflect.InvocationTargetException;
public class WavePanelSandbox extends FrameHelper { public class WavePanelSandbox extends FrameHelper {
public WavePanelSandbox() { public WavePanelSandbox() {
WavePanel wp = new WavePanel(PersistentConfiguration.getConfig().getRoot()); EngineSnifferPanel wp = new EngineSnifferPanel(PersistentConfiguration.getConfig().getRoot());
wp.displayChart("Injector 1!down!55013038!crank!up!55013444!crank!down!55013781!Injector 3!up!55013789!Injector 3!down!55013969!crank2!up!55014065!crank!up!55014358!crank!down!55014706!input1 A8!up!55014730!Injector 4!up!55014734!Injector 4!down!55014933!input1 A8!down!55014941!crank!up!55015298!crank!down!55015638!Injector 2!up!55015644!Injector 2!down!55015823!crank2!down!55015932!crank!up!55016223!crank!down!55016566!Injector 1!up!55016574!Injector 1!down!55016753!crank!up!55017148!crank!down!55017494!Injector 3!up!55017499!Injector 3!down!55017679!crank2!up!55017777!crank!up!55018070!crank!down!55018406!Injector 4!input1 A8!up!55018414!up!55018416!input1 A8!down!55018439!input1 A8!up!55018439!Injector 4!down!55018593!input1 A8!down!55018600!crank!up!55018989!crank!down!55019330!Injector 2!up!55019338!Injector 2!down!55019517!crank2!down!55019618!crank!up!55019909!crank!down!55020246!Injector 1!up!55020251!Injector 1!down!55020430!crank!up!55020827!crank!down!55021171!Injector 3!up!55021179!Injector 3!down!55021358!crank2!up!55021453!crank!up!55021747!crank!down!55022084!Injector 4input1 A8!up!55022089!!up!55022093!Injector 4!down!55022270!input1 A8!down!55022276!input1 A8!up!55022276!input1 A8!down!55022276!crank!up!55022666!crank!down!55023006!Injector 2!up!55023011!Injector 2!down!55023191!crank2!down!55023294!crank!up!55023584!crank!down!55023928!Injector 1!up!55023932!Injector 1!down!55024109!crank!up!55024507!crank!down!55024846!Injector 3!up!55024871!Injector 3!down!55025072!crank2!up!55025138!crank!up!55025440!crank!down!55025780!Injector 4input1 A8!up!55025785!!up!55025791!input1 A8!down!55025923!input1 A8!up!55025923!Injector 4!down!55025970!input1 A8!down!55025976!input1 A8!up!55025976!crank!up!55026355!crank!down!55026690!Injector 2!up!55026696!Injector 2!down!55026874!crank2!down!55026979!crank!up!55027268!crank!down!55027611!Injector 1!up!55027619!Injector 1!down!55027800!crank!up!55028186!crank!down!55028520!,"); wp.displayChart("Injector 1!down!55013038!crank!up!55013444!crank!down!55013781!Injector 3!up!55013789!Injector 3!down!55013969!crank2!up!55014065!crank!up!55014358!crank!down!55014706!input1 A8!up!55014730!Injector 4!up!55014734!Injector 4!down!55014933!input1 A8!down!55014941!crank!up!55015298!crank!down!55015638!Injector 2!up!55015644!Injector 2!down!55015823!crank2!down!55015932!crank!up!55016223!crank!down!55016566!Injector 1!up!55016574!Injector 1!down!55016753!crank!up!55017148!crank!down!55017494!Injector 3!up!55017499!Injector 3!down!55017679!crank2!up!55017777!crank!up!55018070!crank!down!55018406!Injector 4!input1 A8!up!55018414!up!55018416!input1 A8!down!55018439!input1 A8!up!55018439!Injector 4!down!55018593!input1 A8!down!55018600!crank!up!55018989!crank!down!55019330!Injector 2!up!55019338!Injector 2!down!55019517!crank2!down!55019618!crank!up!55019909!crank!down!55020246!Injector 1!up!55020251!Injector 1!down!55020430!crank!up!55020827!crank!down!55021171!Injector 3!up!55021179!Injector 3!down!55021358!crank2!up!55021453!crank!up!55021747!crank!down!55022084!Injector 4input1 A8!up!55022089!!up!55022093!Injector 4!down!55022270!input1 A8!down!55022276!input1 A8!up!55022276!input1 A8!down!55022276!crank!up!55022666!crank!down!55023006!Injector 2!up!55023011!Injector 2!down!55023191!crank2!down!55023294!crank!up!55023584!crank!down!55023928!Injector 1!up!55023932!Injector 1!down!55024109!crank!up!55024507!crank!down!55024846!Injector 3!up!55024871!Injector 3!down!55025072!crank2!up!55025138!crank!up!55025440!crank!down!55025780!Injector 4input1 A8!up!55025785!!up!55025791!input1 A8!down!55025923!input1 A8!up!55025923!Injector 4!down!55025970!input1 A8!down!55025976!input1 A8!up!55025976!crank!up!55026355!crank!down!55026690!Injector 2!up!55026696!Injector 2!down!55026874!crank2!down!55026979!crank!up!55027268!crank!down!55027611!Injector 1!up!55027619!Injector 1!down!55027800!crank!up!55028186!crank!down!55028520!,");

View File

@ -1,41 +0,0 @@
package com.irnems.ui.test;
import com.rusefi.ui.FrameHelper;
import com.rusefi.ui.WavePanel;
import org.junit.Test;
import javax.swing.*;
import java.lang.reflect.InvocationTargetException;
import java.util.Set;
import java.util.TreeSet;
import static junit.framework.Assert.assertEquals;
/**
* 6/25/14
* (c) Andrey Belomutskiy
*/
public class WavePanelTest {
@Test
public void testInsertIndex() {
Set<String> names = new TreeSet<String>();
names.add(WavePanel.CRANK1);
String name;
name = "inj2";
assertEquals(-1, WavePanel.getInsertIndex(name, names));
names.add(name);
name = "inj1";
assertEquals(1, WavePanel.getInsertIndex(name, names));
names.add(name);
assertEquals(1, WavePanel.getInsertIndex("spa1", names));
}
}

View File

@ -1,13 +1,11 @@
package com.rusefi; package com.rusefi;
import com.irnems.FileLog;
import com.rusefi.config.Fields; import com.rusefi.config.Fields;
import com.rusefi.ui.RpmModel; import com.rusefi.ui.RpmModel;
import com.rusefi.ui.UiUtils; import com.rusefi.ui.util.UiUtils;
import com.rusefi.ui.WavePanel; import com.rusefi.ui.engine.EngineSnifferPanel;
import com.rusefi.ui.config.ConfigField; import com.rusefi.ui.config.ConfigField;
import com.rusefi.ui.widgets.URLLabel; import com.rusefi.ui.util.URLLabel;
import com.rusefi.ui.widgets.UpDownImage;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -45,14 +43,14 @@ public class AnalogChartPanel {
// MessagesCentral.getConfig().postMessage(AnalogChartPanel.class, "chart arrived, len=" + message.length()); // MessagesCentral.getConfig().postMessage(AnalogChartPanel.class, "chart arrived, len=" + message.length());
processValues(); processValues();
UpDownImage.trueRepaint(analogChart); UiUtils.trueRepaint(analogChart);
} }
}); });
final JPanel upperPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0)); final JPanel upperPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
JButton imageButton = new JButton(WavePanel.SAVE_IMAGE); JButton imageButton = new JButton(EngineSnifferPanel.SAVE_IMAGE);
imageButton.setMnemonic('s'); imageButton.setMnemonic('s');
upperPanel.add(imageButton); upperPanel.add(imageButton);
imageButton.addActionListener(new imageButton.addActionListener(new
@ -71,7 +69,7 @@ public class AnalogChartPanel {
final JButton pauseButton = new JButton("Pause"); final JButton pauseButton = new JButton("Pause");
upperPanel.add(pauseButton); upperPanel.add(pauseButton);
upperPanel.add(new URLLabel(WavePanel.HELP_TEXT, HELP_URL)); upperPanel.add(new URLLabel(EngineSnifferPanel.HELP_TEXT, HELP_URL));
pauseButton.addActionListener(new pauseButton.addActionListener(new
ActionListener() { ActionListener() {
@Override @Override

View File

@ -1,11 +1,11 @@
package com.rusefi; package com.rusefi;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.irnems.core.MessagesCentral; import com.irnems.core.MessagesCentral;
import com.irnems.core.Sensor; import com.irnems.core.Sensor;
import com.irnems.core.EngineTimeListener; import com.irnems.core.EngineTimeListener;
import com.irnems.core.SensorCentral; import com.irnems.core.SensorCentral;
import com.irnems.file.TableGenerator; import com.rusefi.file.TableGenerator;
import com.irnems.models.Point3D; import com.irnems.models.Point3D;
import com.irnems.models.Range; import com.irnems.models.Range;
import com.irnems.models.XYData; import com.irnems.models.XYData;

View File

@ -1,11 +1,13 @@
package com.rusefi; package com.rusefi;
import com.irnems.FileLog;
import com.irnems.core.EngineState; import com.irnems.core.EngineState;
import com.irnems.core.MessagesCentral; import com.irnems.core.MessagesCentral;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
import com.rusefi.maintenance.VersionChecker;
import com.rusefi.ui.*; import com.rusefi.ui.*;
import com.rusefi.ui.engine.EngineSnifferPanel;
import com.rusefi.ui.storage.Node; import com.rusefi.ui.storage.Node;
import com.rusefi.ui.util.DefaultExceptionHandler;
import jssc.SerialPortList; import jssc.SerialPortList;
import javax.swing.*; import javax.swing.*;
@ -20,7 +22,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* (c) Andrey Belomutskiy 2013-2015 * (c) Andrey Belomutskiy 2013-2015
* *
* @see StartupFrame * @see StartupFrame
* @see WavePanel * @see com.rusefi.ui.engine.EngineSnifferPanel
*/ */
public class Launcher extends FrameHelper { public class Launcher extends FrameHelper {
public static final int CONSOLE_VERSION = 20150216; public static final int CONSOLE_VERSION = 20150216;
@ -40,14 +42,14 @@ public class Launcher extends FrameHelper {
FileLog.MAIN.logLine("Console " + CONSOLE_VERSION); FileLog.MAIN.logLine("Console " + CONSOLE_VERSION);
WavePanel wavePanel = new WavePanel(getConfig().getRoot().getChild("digital_sniffer")); EngineSnifferPanel engineSnifferPanel = new EngineSnifferPanel(getConfig().getRoot().getChild("digital_sniffer"));
if (LinkManager.isLogViewerMode(port)) if (LinkManager.isLogViewerMode(port))
tabbedPane.add("Log Viewer", new LogViewer(wavePanel)); tabbedPane.add("Log Viewer", new LogViewer(engineSnifferPanel));
RpmPanel mainGauges = new RpmPanel(getConfig().getRoot().getChild("main_gauges")); RpmPanel mainGauges = new RpmPanel(getConfig().getRoot().getChild("main_gauges"));
tabbedPane.addTab("Main", mainGauges.createRpmPanel()); tabbedPane.addTab("Main", mainGauges.createRpmPanel());
tabbedPane.addTab("Gauges", new GaugesPanel().getContent()); tabbedPane.addTab("Gauges", new GaugesPanel().getContent());
tabbedPane.addTab("Engine Sniffer", wavePanel.getPanel()); tabbedPane.addTab("Engine Sniffer", engineSnifferPanel.getPanel());
tabbedPane.addTab("Analog Sniffer", new AnalogChartPanel().getPanel()); tabbedPane.addTab("Analog Sniffer", new AnalogChartPanel().getPanel());
tabbedPane.addTab("LE controls", new FlexibleControls().getPanel()); tabbedPane.addTab("LE controls", new FlexibleControls().getPanel());

View File

@ -3,8 +3,8 @@ package com.rusefi;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
import com.rusefi.io.tcp.TcpConnector; import com.rusefi.io.tcp.TcpConnector;
import com.rusefi.maintenance.FirmwareFlasher; import com.rusefi.maintenance.FirmwareFlasher;
import com.rusefi.ui.UiUtils; import com.rusefi.ui.util.UiUtils;
import com.rusefi.ui.widgets.URLLabel; import com.rusefi.ui.util.URLLabel;
import jssc.SerialPortList; import jssc.SerialPortList;
import org.putgemin.VerticalFlowLayout; import org.putgemin.VerticalFlowLayout;

View File

@ -1,8 +1,7 @@
package com.rusefi.maintenance; package com.rusefi.maintenance;
import com.rusefi.ui.FrameHelper; import com.rusefi.ui.FrameHelper;
import com.rusefi.ui.UiUtils; import com.rusefi.ui.util.UiUtils;
import com.rusefi.ui.widgets.UpDownImage;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -127,7 +126,7 @@ public class FirmwareFlasher {
@Override @Override
public void run() { public void run() {
log.append(s + "\r\n"); log.append(s + "\r\n");
UpDownImage.trueLayout(log); UiUtils.trueLayout(log);
} }
}); });
} }

View File

@ -1,8 +1,8 @@
package com.rusefi; package com.rusefi.maintenance;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.rusefi.io.tcp.TcpConnector; import com.rusefi.io.tcp.TcpConnector;
import com.rusefi.ui.widgets.URLLabel; import com.rusefi.ui.util.URLLabel;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;

View File

@ -1,88 +0,0 @@
package com.rusefi.ui;
import com.irnems.core.SensorCentral;
import com.irnems.core.Pair;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Map;
import static com.irnems.core.EngineState.SNIFFED_ADC_COUNT;
/**
* Date: 1/7/13
* (c) Andrey Belomutskiy
*/
public class AdcPanel {
protected final Map<Integer, JLabel> sniffedAdcLabels = new HashMap<Integer, JLabel>();
public final Map<Integer, JLabel> inputLabels = new HashMap<Integer, JLabel>();
public final Map<Integer, JLabel> internalAdcLabels = new HashMap<Integer, JLabel>();
public AdcPanel(BooleanInputsModel inputs) {
}
public JComponent createAdcPanel() {
JComponent container = new JPanel(new MigLayout());
JButton saveAdc = new JButton("save ADC");
saveAdc.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// model.saveToFile();
}
});
container.add(saveAdc, "grow, wrap");
for (int channel1 = 0; channel1 < SNIFFED_ADC_COUNT / 2; channel1++) {
// {
// Pair<JPanel, JLabel> pair1 = createAdcLabel(channel1);
// // 2nd column of channels
// int channel2 = channel1 + SNIFFED_ADC_COUNT / 2;
// Pair<JPanel, JLabel> pair2 = createAdcLabel(channel2);
// sniffedAdcLabels.put(channel1, pair1.second);
// sniffedAdcLabels.put(channel2, pair2.second);
//
// container.add(pair1.first);
// container.add(pair2.first);
// }
{
Pair<JPanel, JLabel> inputPair = createLabelWithCaption(BooleanInputsModel.getTitle(channel1));
inputLabels.put(channel1, inputPair.second);
container.add(inputPair.first);
}
{
Pair<JPanel, JLabel> pair = createLabelWithCaption("adc " + channel1);
internalAdcLabels.put(channel1, pair.second);
container.add(pair.first, "grow, wrap");
}
}
return container;
}
// private Pair<JPanel, JLabel> createAdcLabel(final int channel) {
// final Pair<JPanel, JLabel> result = createLabelWithCaption(SensorCentral.getTitle(channel));
// model.addListener(new SensorCentral.SensorListener() {
// public void onAdcUpdate(SensorCentral model, Sensor sensor, double value) {
// if (sensor.getMazdaIndex() != channel)
// return;
// JLabel label = result.second;
// String representation = model.getSniffedAdcRepresentation(sensor);
// label.setText(representation);
// }
// });
// return result;
// }
private Pair<JPanel, JLabel> createLabelWithCaption(String title) {
JPanel panel = new JPanel(new FlowLayout());
panel.add(new JLabel(title));
JLabel value = new JLabel("");
panel.add(value);
return new Pair<JPanel, JLabel>(panel, value);
}
}

View File

@ -1,9 +1,11 @@
package com.rusefi.ui; package com.rusefi.ui;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.irnems.models.Range; import com.irnems.models.Range;
import com.irnems.models.XYData; import com.irnems.models.XYData;
import com.rusefi.ui.widgets.JTextFieldWithWidth; import com.rusefi.ui.engine.EngineSnifferPanel;
import com.rusefi.ui.util.UiUtils;
import com.rusefi.ui.util.JTextFieldWithWidth;
import net.ericaro.surfaceplotter.DefaultSurfaceModel; import net.ericaro.surfaceplotter.DefaultSurfaceModel;
import net.ericaro.surfaceplotter.JSurfacePanel; import net.ericaro.surfaceplotter.JSurfacePanel;
import net.ericaro.surfaceplotter.Mapper; import net.ericaro.surfaceplotter.Mapper;
@ -35,7 +37,7 @@ public class ChartHelper {
jsp.getSurface().setYLabel("MAF voltage"); jsp.getSurface().setYLabel("MAF voltage");
result.add(BorderLayout.CENTER, jsp); result.add(BorderLayout.CENTER, jsp);
JButton saveImageButton = new JButton(WavePanel.SAVE_IMAGE); JButton saveImageButton = new JButton(EngineSnifferPanel.SAVE_IMAGE);
saveImageButton.setMnemonic('s'); saveImageButton.setMnemonic('s');
saveImageButton.addActionListener(new ActionListener() { saveImageButton.addActionListener(new ActionListener() {
@Override @Override

View File

@ -37,11 +37,11 @@ public class ChartRepository {
charts.clear(); charts.clear();
} }
public interface CRListener { public interface ChartRepositoryListener {
public void onDigitalChart(String chart); public void onDigitalChart(String chart);
} }
public ChartScrollControl createControls(final CRListener listener) { public ChartScrollControl createControls(final ChartRepositoryListener listener) {
return new ChartScrollControl(listener); return new ChartScrollControl(listener);
} }
} }

View File

@ -17,9 +17,9 @@ public class ChartScrollControl {
private final JPanel content = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0)); private final JPanel content = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 0));
private final AtomicInteger index = new AtomicInteger(); private final AtomicInteger index = new AtomicInteger();
private static final JLabel info = new JLabel(); private static final JLabel info = new JLabel();
private ChartRepository.CRListener listener; private ChartRepository.ChartRepositoryListener listener;
public ChartScrollControl(final ChartRepository.CRListener listener) { public ChartScrollControl(final ChartRepository.ChartRepositoryListener listener) {
this.listener = listener; this.listener = listener;

View File

@ -0,0 +1,5 @@
package com.rusefi.ui;
public class ConnectionStatus {
}

View File

@ -1,6 +1,6 @@
package com.rusefi.ui; package com.rusefi.ui;
import com.irnems.FileLog; import com.rusefi.FileLog;
import javax.swing.*; import javax.swing.*;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;

View File

@ -1,9 +1,10 @@
package com.rusefi.ui; package com.rusefi.ui;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.irnems.core.EngineState; import com.irnems.core.EngineState;
import com.irnems.file.FileUtils; import com.rusefi.file.FileUtils;
import com.rusefi.ui.widgets.UpDownImage; import com.rusefi.ui.engine.EngineSnifferPanel;
import com.rusefi.ui.util.UiUtils;
import com.rusefi.FIleItem; import com.rusefi.FIleItem;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
@ -36,16 +37,16 @@ public class LogViewer extends JPanel {
private final JLabel fileLabel = new JLabel(); private final JLabel fileLabel = new JLabel();
private final DefaultListModel<FIleItem> fileListModel = new DefaultListModel<FIleItem>(); private final DefaultListModel<FIleItem> fileListModel = new DefaultListModel<FIleItem>();
private final JList<FIleItem> fileList = new JList<FIleItem>(fileListModel); private final JList<FIleItem> fileList = new JList<FIleItem>(fileListModel);
private final WavePanel wavePanel; private final EngineSnifferPanel engineSnifferPanel;
private String currentFolder; private String currentFolder;
private static JPanel descPanel = new JPanel(); private static JPanel descPanel = new JPanel();
// int currentChartIndex = 0; // int currentChartIndex = 0;
public LogViewer(WavePanel wavePanel) { public LogViewer(EngineSnifferPanel engineSnifferPanel) {
super(new BorderLayout()); super(new BorderLayout());
this.wavePanel = wavePanel; this.engineSnifferPanel = engineSnifferPanel;
setBackground(Color.green); setBackground(Color.green);
@ -101,7 +102,7 @@ public class LogViewer extends JPanel {
descPanel.removeAll(); descPanel.removeAll();
descPanel.add(new JLabel("Total digital charts: ")); descPanel.add(new JLabel("Total digital charts: "));
descPanel.add(new JLabel("" + ChartRepository.getInstance().getSize())); descPanel.add(new JLabel("" + ChartRepository.getInstance().getSize()));
UpDownImage.trueRepaint(descPanel); UiUtils.trueRepaint(descPanel);
} }
private void openFolder(String folderName) { private void openFolder(String folderName) {
@ -173,7 +174,7 @@ public class LogViewer extends JPanel {
FileUtils.readFile2(filename, engineState); FileUtils.readFile2(filename, engineState);
if (ChartRepository.getInstance().getSize() > 0) if (ChartRepository.getInstance().getSize() > 0)
wavePanel.reloadFile(); engineSnifferPanel.reloadFile();
refreshCountPanel(); refreshCountPanel();
} }
} }

View File

@ -25,12 +25,12 @@ public class MessagesPane {
content.add(middlePanel, BorderLayout.CENTER); content.add(middlePanel, BorderLayout.CENTER);
messagesPanel.getButtonPanel().add(new RpmControl().getContent()); messagesPanel.getButtonPanel().add(new RpmLabel().getContent());
content.add(messagesPanel.getButtonPanel(), BorderLayout.NORTH); content.add(messagesPanel.getButtonPanel(), BorderLayout.NORTH);
JPanel statsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel statsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
statsPanel.add(new RpmControl().getContent()); statsPanel.add(new RpmLabel().getContent());
statsPanel.add(new IdleLabel()); statsPanel.add(new IdleLabel());
statsPanel.add(new WarningPanel().getPanel()); statsPanel.add(new WarningPanel().getPanel());

View File

@ -4,6 +4,7 @@ import com.irnems.core.MessagesCentral;
import com.rusefi.io.CommandQueue; import com.rusefi.io.CommandQueue;
import com.rusefi.io.serial.PortHolder; import com.rusefi.io.serial.PortHolder;
import com.rusefi.ui.storage.Node; import com.rusefi.ui.storage.Node;
import com.rusefi.ui.util.UiUtils;
import com.rusefi.ui.widgets.AnyCommand; import com.rusefi.ui.widgets.AnyCommand;
import javax.swing.*; import javax.swing.*;

View File

@ -2,7 +2,7 @@ package com.rusefi.ui;
import com.rusefi.StimulationInputs; import com.rusefi.StimulationInputs;
import com.rusefi.io.CommandQueue; import com.rusefi.io.CommandQueue;
import com.rusefi.ui.widgets.UpDownImage; import com.rusefi.ui.util.UiUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -73,8 +73,8 @@ public class RecentCommands {
for (Entry entry : entries.keySet()) { for (Entry entry : entries.keySet()) {
content.add(createButton(entry)); content.add(createButton(entry));
} }
UpDownImage.trueRepaint(content.getParent()); UiUtils.trueRepaint(content.getParent());
UpDownImage.trueLayout(content.getParent()); UiUtils.trueLayout(content.getParent());
} }
}); });

View File

@ -14,14 +14,14 @@ import java.awt.event.ActionListener;
* 9/17/13 * 9/17/13
* (c) Andrey Belomutskiy * (c) Andrey Belomutskiy
*/ */
public class RpmControl { public class RpmLabel {
private static final String NO_CONNECTION = "N/C"; private static final String NO_CONNECTION = "N/C";
private final JPanel content = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); private final JPanel content = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
private final JLabel rpmValue = new JLabel(NO_CONNECTION); private final JLabel rpmValue = new JLabel(NO_CONNECTION);
private final JLabel rpmCaption = new JLabel("RPM:"); private final JLabel rpmCaption = new JLabel("RPM:");
public RpmControl() { public RpmLabel() {
rpmCaption.setBorder(BorderFactory.createLineBorder(Color.white)); rpmCaption.setBorder(BorderFactory.createLineBorder(Color.white));
rpmValue.setForeground(Color.red); rpmValue.setForeground(Color.red);
@ -64,7 +64,7 @@ public class RpmControl {
return content; return content;
} }
public RpmControl setSize(int size) { public RpmLabel setSize(int size) {
Font f = rpmCaption.getFont(); Font f = rpmCaption.getFont();
int fontSize = size * f.getSize(); int fontSize = size * f.getSize();
Font font = new Font(f.getName(), f.getStyle(), fontSize); Font font = new Font(f.getName(), f.getStyle(), fontSize);

View File

@ -19,7 +19,7 @@ import java.awt.event.ActionListener;
*/ */
public class RpmPanel { public class RpmPanel {
private final Node config; private final Node config;
private RpmControl rpmControl = new RpmControl(); private RpmLabel rpmLabel = new RpmLabel();
// that's for CKP signal emulation // that's for CKP signal emulation
public final WaveInfoPanel wave0 = new WaveInfoPanel(0); public final WaveInfoPanel wave0 = new WaveInfoPanel(0);
public final WaveInfoPanel wave1 = new WaveInfoPanel(1); public final WaveInfoPanel wave1 = new WaveInfoPanel(1);
@ -27,7 +27,7 @@ public class RpmPanel {
public RpmPanel(Node config) { public RpmPanel(Node config) {
this.config = config; this.config = config;
rpmControl.setSize(15); rpmLabel.setSize(15);
} }
public JComponent createRpmPanel() { public JComponent createRpmPanel() {
@ -57,7 +57,7 @@ public class RpmPanel {
JComponent rpmPanel = new JPanel(new BorderLayout()); JComponent rpmPanel = new JPanel(new BorderLayout());
rpmPanel.setBorder(BorderFactory.createLineBorder(Color.white)); rpmPanel.setBorder(BorderFactory.createLineBorder(Color.white));
rpmPanel.add(rpmControl.getContent(), BorderLayout.NORTH); rpmPanel.add(rpmLabel.getContent(), BorderLayout.NORTH);
rpmPanel.add(controls, BorderLayout.WEST); rpmPanel.add(controls, BorderLayout.WEST);
rpmPanel.add(gauges, BorderLayout.CENTER); rpmPanel.add(gauges, BorderLayout.CENTER);
rpmPanel.add(msgPanel, BorderLayout.EAST); rpmPanel.add(msgPanel, BorderLayout.EAST);

View File

@ -1,6 +1,6 @@
package com.rusefi.ui; package com.rusefi.ui;
import com.irnems.file.BaseMap; import com.rusefi.file.BaseMap;
import com.irnems.models.XYData; import com.irnems.models.XYData;
import javax.swing.*; import javax.swing.*;

View File

@ -6,8 +6,7 @@ import com.rusefi.OutputChannel;
import com.rusefi.io.CommandQueue; import com.rusefi.io.CommandQueue;
import com.rusefi.io.InvocationConfirmationListener; import com.rusefi.io.InvocationConfirmationListener;
import com.rusefi.trigger.TriggerShapeHolder; import com.rusefi.trigger.TriggerShapeHolder;
import com.rusefi.ui.widgets.UpDownImage; import com.rusefi.ui.util.UiUtils;
import com.sun.awt.AWTUtilities;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -113,7 +112,7 @@ public class Wizard {
Component newContent = getContent(step); Component newContent = getContent(step);
content.removeAll(); content.removeAll();
content.add(newContent); content.add(newContent);
UpDownImage.trueLayout(content); UiUtils.trueLayout(content);
} }
private Component getContent(WizardStep step) { private Component getContent(WizardStep step) {

View File

@ -1,21 +1,21 @@
package com.rusefi.ui; package com.rusefi.ui.engine;
import com.irnems.FileLog; import com.rusefi.FileLog;
import com.irnems.core.EngineState; import com.irnems.core.EngineState;
import com.irnems.core.Sensor; import com.irnems.core.Sensor;
import com.irnems.core.SensorCentral; import com.irnems.core.SensorCentral;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
import com.rusefi.ui.*;
import com.rusefi.ui.storage.Node; import com.rusefi.ui.storage.Node;
import com.rusefi.ui.util.UiUtils;
import com.rusefi.ui.widgets.AnyCommand; import com.rusefi.ui.widgets.AnyCommand;
import com.rusefi.ui.widgets.URLLabel; import com.rusefi.ui.util.URLLabel;
import com.rusefi.ui.widgets.UpDownImage;
import com.rusefi.waves.RevolutionLog; import com.rusefi.waves.RevolutionLog;
import com.rusefi.waves.WaveChart; import com.rusefi.waves.WaveChart;
import com.rusefi.waves.WaveChartParser; import com.rusefi.waves.WaveChartParser;
import com.rusefi.waves.WaveReport; import com.rusefi.waves.WaveReport;
import javax.swing.*; import javax.swing.*;
import javax.xml.bind.JAXBContext;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -29,9 +29,9 @@ import java.util.List;
* Date: 6/23/13 * Date: 6/23/13
* Andrey Belomutskiy (c) 2012-2013 * Andrey Belomutskiy (c) 2012-2013
* *
* @see ChartStatusPanel status bar * @see EngineSnifferStatusPanel status bar
*/ */
public class WavePanel { public class EngineSnifferPanel {
private static final int EFI_DEFAULT_CHART_SIZE = 180; private static final int EFI_DEFAULT_CHART_SIZE = 180;
public static final String CRANK1 = "c1"; public static final String CRANK1 = "c1";
public static final Comparator<String> INSTANCE = new ImageOrderComparator(); public static final Comparator<String> INSTANCE = new ImageOrderComparator();
@ -61,13 +61,13 @@ public class WavePanel {
JScrollPane pane = new JScrollPane(imagePanel, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); JScrollPane pane = new JScrollPane(imagePanel, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
private final ZoomControl zoomControl = new ZoomControl(); private final ZoomControl zoomControl = new ZoomControl();
private final ChartStatusPanel statusPanel = new ChartStatusPanel(zoomControl.getZoomProvider()); private final EngineSnifferStatusPanel statusPanel = new EngineSnifferStatusPanel(zoomControl.getZoomProvider());
private final UpDownImage crank = createImage(CRANK1); private final UpDownImage crank = createImage(CRANK1);
private ChartScrollControl scrollControl; private ChartScrollControl scrollControl;
private boolean isPaused; private boolean isPaused;
public WavePanel(Node config) { public EngineSnifferPanel(Node config) {
LinkManager.engineState.registerStringValueAction("outpin", new EngineState.ValueCallback<String>() { LinkManager.engineState.registerStringValueAction("outpin", new EngineState.ValueCallback<String>() {
@Override @Override
public void onUpdate(String value) { public void onUpdate(String value) {
@ -118,14 +118,14 @@ public class WavePanel {
buttonPanel.add(clearButton); buttonPanel.add(clearButton);
buttonPanel.add(saveImageButton); buttonPanel.add(saveImageButton);
buttonPanel.add(pauseButton); buttonPanel.add(pauseButton);
buttonPanel.add(new RpmControl().setSize(2).getContent()); buttonPanel.add(new RpmLabel().setSize(2).getContent());
JComponent command = new AnyCommand(config, "chartsize " + EFI_DEFAULT_CHART_SIZE).getContent(); JComponent command = new AnyCommand(config, "chartsize " + EFI_DEFAULT_CHART_SIZE).getContent();
buttonPanel.add(command); buttonPanel.add(command);
buttonPanel.add(zoomControl); buttonPanel.add(zoomControl);
scrollControl = ChartRepository.getInstance().createControls(new ChartRepository.CRListener() { scrollControl = ChartRepository.getInstance().createControls(new ChartRepository.ChartRepositoryListener() {
@Override @Override
public void onDigitalChart(String chart) { public void onDigitalChart(String chart) {
displayChart(chart); displayChart(chart);
@ -142,7 +142,7 @@ public class WavePanel {
zoomControl.listener = new ZoomControl.ZoomControlListener() { zoomControl.listener = new ZoomControl.ZoomControlListener() {
@Override @Override
public void onZoomChange() { public void onZoomChange() {
UpDownImage.trueRepaint(imagePanel); UiUtils.trueRepaint(imagePanel);
} }
}; };
@ -204,7 +204,7 @@ public class WavePanel {
/** /**
* this is to fix the UI glitch when images tab shows a tiny square * this is to fix the UI glitch when images tab shows a tiny square
*/ */
UpDownImage.trueRepaint(chartPanel.getParent()); UiUtils.trueRepaint(chartPanel.getParent());
} }
public JPanel getPanel() { public JPanel getPanel() {

View File

@ -1,7 +1,6 @@
package com.rusefi.ui; package com.rusefi.ui.engine;
import com.irnems.waves.TimeAxisTranslator; import com.irnems.waves.TimeAxisTranslator;
import com.rusefi.ui.widgets.UpDownImage;
import com.rusefi.waves.WaveReport; import com.rusefi.waves.WaveReport;
import com.irnems.waves.ZoomProvider; import com.irnems.waves.ZoomProvider;
import com.rusefi.waves.RevolutionLog; import com.rusefi.waves.RevolutionLog;
@ -13,13 +12,13 @@ import java.awt.event.MouseMotionAdapter;
import java.util.Map; import java.util.Map;
/** /**
* Status bar at the bottom of Digital Sniffer - {@link WavePanel} * Status bar at the bottom of Digital Sniffer - {@link EngineSnifferPanel}
* <p/> * <p/>
* <p/> * <p/>
* Date: 12/26/13 * Date: 12/26/13
* Andrey Belomutskiy (c) 2012-2013 * Andrey Belomutskiy (c) 2012-2013
*/ */
public class ChartStatusPanel { public class EngineSnifferStatusPanel {
public final JPanel infoPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); public final JPanel infoPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
private final JLabel xLabel = new JLabel(); private final JLabel xLabel = new JLabel();
private final JLabel timeLabel = new JLabel(); private final JLabel timeLabel = new JLabel();
@ -29,7 +28,7 @@ public class ChartStatusPanel {
private RevolutionLog time2rpm = RevolutionLog.parseRevolutions(null); private RevolutionLog time2rpm = RevolutionLog.parseRevolutions(null);
final MouseMotionAdapter motionAdapter = new MouseMotionAdapter() { public final MouseMotionAdapter motionAdapter = new MouseMotionAdapter() {
@Override @Override
public void mouseMoved(MouseEvent event) { public void mouseMoved(MouseEvent event) {
int x = event.getX(); int x = event.getX();
@ -56,7 +55,7 @@ public class ChartStatusPanel {
private ZoomProvider zoomProvider; private ZoomProvider zoomProvider;
public ChartStatusPanel(ZoomProvider zoomProvider) { public EngineSnifferStatusPanel(ZoomProvider zoomProvider) {
this.zoomProvider = zoomProvider; this.zoomProvider = zoomProvider;
infoPanel.add(new JLabel("X: ")); infoPanel.add(new JLabel("X: "));
infoPanel.add(xLabel); infoPanel.add(xLabel);

View File

@ -1,9 +1,9 @@
package com.rusefi.ui.widgets; package com.rusefi.ui.engine;
import com.irnems.core.Sensor; import com.irnems.core.Sensor;
import com.irnems.core.SensorCentral; import com.irnems.core.SensorCentral;
import com.irnems.waves.TimeAxisTranslator; import com.irnems.waves.TimeAxisTranslator;
import com.rusefi.ui.WavePanel; import com.rusefi.ui.util.UiUtils;
import com.rusefi.waves.WaveReport; import com.rusefi.waves.WaveReport;
import com.irnems.waves.ZoomProvider; import com.irnems.waves.ZoomProvider;
import com.rusefi.waves.RevolutionLog; import com.rusefi.waves.RevolutionLog;
@ -22,7 +22,7 @@ import java.util.TreeMap;
* Date: 6/23/13 * Date: 6/23/13
* (c) Andrey Belomutskiy * (c) Andrey Belomutskiy
* *
* @see WavePanel * @see EngineSnifferPanel
*/ */
public class UpDownImage extends JPanel { public class UpDownImage extends JPanel {
private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss"); private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
@ -54,45 +54,13 @@ public class UpDownImage extends JPanel {
} }
public void setToolTip() { public void setToolTip() {
setTwoLineToolTip(this, "Channel " + name, "Physical pin: " + pin); UiUtils.setTwoLineToolTip(this, "Channel " + name, "Physical pin: " + pin);
}
public static void setTwoLineToolTip(JComponent component, String line1, String line2) {
component.setToolTipText("<html>" + line1 + "<br>" + line2 + "</html>");
} }
public void setZoomProvider(ZoomProvider zoomProvider) { public void setZoomProvider(ZoomProvider zoomProvider) {
this.zoomProvider = zoomProvider; this.zoomProvider = zoomProvider;
} }
/**
* This does not make any sense :( That's an attempt
* to hack http://rusefi.com/forum/viewtopic.php?f=2&t=631&p=10083#p10081
*/
public static void trueRepaint(JComponent control) {
control.invalidate();
control.repaint();
}
public static void trueRepaint(Container control) {
trueLayout(control);
// if (control == null)
// return;
// control.invalidate();
// control.repaint();
}
/**
* todo: one 'trueXXX' method should be enough, which one?
*/
public static void trueLayout(Component component) {
if (component == null)
return;
component.invalidate();
component.validate();
component.repaint();
}
public UpDownImage(WaveReport wr, String name) { public UpDownImage(WaveReport wr, String name) {
this.name = name; this.name = name;
setWaveReport(wr, null); setWaveReport(wr, null);
@ -134,7 +102,7 @@ public class UpDownImage extends JPanel {
propagateDwellIntoSensor(wr); propagateDwellIntoSensor(wr);
this.revolutions = revolutions; this.revolutions = revolutions;
lastUpdateTime = System.currentTimeMillis(); lastUpdateTime = System.currentTimeMillis();
trueRepaint(this); UiUtils.trueRepaint(this);
} }
private void propagateDwellIntoSensor(WaveReport wr) { private void propagateDwellIntoSensor(WaveReport wr) {

View File

@ -1,4 +1,4 @@
package com.rusefi.ui; package com.rusefi.ui.engine;
import com.irnems.waves.ZoomProvider; import com.irnems.waves.ZoomProvider;
import com.rusefi.KeyStrokeShortcut; import com.rusefi.KeyStrokeShortcut;
@ -13,7 +13,7 @@ import java.awt.event.KeyEvent;
* 7/7/13 * 7/7/13
* (c) Andrey Belomutskiy * (c) Andrey Belomutskiy
*/ */
public class ZoomControl extends JPanel { class ZoomControl extends JPanel {
private final JLabel currentValue = new JLabel(); private final JLabel currentValue = new JLabel();
private double value; private double value;
public ZoomControlListener listener = null; public ZoomControlListener listener = null;

View File

@ -1,9 +1,9 @@
package com.irnems.ui.test; package com.rusefi.ui.engine.test;
import com.rusefi.waves.WaveReport; import com.rusefi.waves.WaveReport;
import com.irnems.core.test.WaveReportTest; import com.rusefi.waves.test.WaveReportTest;
import com.rusefi.ui.FrameHelper; import com.rusefi.ui.FrameHelper;
import com.rusefi.ui.widgets.UpDownImage; import com.rusefi.ui.engine.UpDownImage;
import javax.swing.*; import javax.swing.*;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;

View File

@ -1,6 +1,6 @@
package com.rusefi.ui.storage; package com.rusefi.ui.storage;
import com.irnems.FileLog; import com.rusefi.FileLog;
import java.beans.XMLDecoder; import java.beans.XMLDecoder;
import java.beans.XMLEncoder; import java.beans.XMLEncoder;

View File

@ -0,0 +1,36 @@
package com.rusefi.ui.test;
import com.rusefi.ui.engine.EngineSnifferPanel;
import org.junit.Test;
import java.util.Set;
import java.util.TreeSet;
import static junit.framework.Assert.assertEquals;
/**
* 6/25/14
* (c) Andrey Belomutskiy
*/
public class EngineSnifferPanelTest {
@Test
public void testInsertIndex() {
Set<String> names = new TreeSet<>();
names.add(EngineSnifferPanel.CRANK1);
String name;
name = "inj2";
assertEquals(-1, EngineSnifferPanel.getInsertIndex(name, names));
names.add(name);
name = "inj1";
assertEquals(1, EngineSnifferPanel.getInsertIndex(name, names));
names.add(name);
assertEquals(1, EngineSnifferPanel.getInsertIndex("spa1", names));
}
}

View File

@ -1,6 +1,6 @@
package com.rusefi.ui; package com.rusefi.ui.util;
import com.irnems.FileLog; import com.rusefi.FileLog;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;

View File

@ -1,4 +1,4 @@
package com.rusefi.ui.widgets; package com.rusefi.ui.util;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;

View File

@ -1,5 +1,4 @@
package com.rusefi.ui.widgets; package com.rusefi.ui.util;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -10,8 +9,6 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
public class URLLabel extends JLabel { public class URLLabel extends JLabel {
private static final long serialVersionUID = 8273875024682878518L;
private String text; private String text;
private URI uri; private URI uri;
@ -65,10 +62,6 @@ public class URLLabel extends JLabel {
this.text = text; this.text = text;
} }
public String getRawText() {
return text;
}
private static void open(URI uri) { private static void open(URI uri) {
if (Desktop.isDesktopSupported()) { if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop(); Desktop desktop = Desktop.getDesktop();

View File

@ -1,4 +1,4 @@
package com.rusefi.ui; package com.rusefi.ui.util;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
@ -54,4 +54,36 @@ public class UiUtils {
Dimension frameSize = w.getSize(); Dimension frameSize = w.getSize();
w.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); w.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
} }
/**
* This does not make any sense :( That's an attempt
* to hack http://rusefi.com/forum/viewtopic.php?f=2&t=631&p=10083#p10081
*/
public static void trueRepaint(JComponent control) {
control.invalidate();
control.repaint();
}
public static void trueRepaint(Container control) {
trueLayout(control);
// if (control == null)
// return;
// control.invalidate();
// control.repaint();
}
/**
* todo: one 'trueXXX' method should be enough, which one?
*/
public static void trueLayout(Component component) {
if (component == null)
return;
component.invalidate();
component.validate();
component.repaint();
}
public static void setTwoLineToolTip(JComponent component, String line1, String line2) {
component.setToolTipText("<html>" + line1 + "<br>" + line2 + "</html>");
}
} }

View File

@ -1,9 +1,9 @@
package com.rusefi.ui.widgets; package com.rusefi.ui.widgets;
import com.irnems.core.Sensor; import com.irnems.core.Sensor;
import com.rusefi.SimulatorHelper;
import com.rusefi.io.CommandQueue; import com.rusefi.io.CommandQueue;
import com.rusefi.io.LinkManager; import com.rusefi.io.LinkManager;
import com.rusefi.ui.util.UiUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
@ -58,7 +58,7 @@ public class DetachedSensor {
Component mockComponent = createMockVoltageSlider(sensor); Component mockComponent = createMockVoltageSlider(sensor);
mockControlPanel.add(mockComponent); mockControlPanel.add(mockComponent);
} }
UpDownImage.trueLayout(content); UiUtils.trueLayout(content);
int size = width; int size = width;
int h = isMockable ? (int) (size * 1.5) : size; int h = isMockable ? (int) (size * 1.5) : size;
frame.setSize(size, h); frame.setSize(size, h);

View File

@ -3,6 +3,7 @@ package com.rusefi.ui.widgets;
import com.irnems.core.Sensor; import com.irnems.core.Sensor;
import com.irnems.core.SensorCategory; import com.irnems.core.SensorCategory;
import com.irnems.core.SensorCentral; import com.irnems.core.SensorCentral;
import com.rusefi.ui.util.UiUtils;
import eu.hansolo.steelseries.gauges.Radial; import eu.hansolo.steelseries.gauges.Radial;
import eu.hansolo.steelseries.tools.ColorDef; import eu.hansolo.steelseries.tools.ColorDef;
@ -42,7 +43,7 @@ public class SensorGauge {
private static void createGaugeBody(final Sensor sensor, final JPanel wrapper, final GaugeChangeListener listener) { private static void createGaugeBody(final Sensor sensor, final JPanel wrapper, final GaugeChangeListener listener) {
final Radial gauge = createRadial(sensor.getName(), sensor.getUnits(), sensor.getMaxValue(), sensor.getMinValue()); final Radial gauge = createRadial(sensor.getName(), sensor.getUnits(), sensor.getMaxValue(), sensor.getMinValue());
UpDownImage.setTwoLineToolTip(gauge, "Double-click to detach", "Right-click to change"); UiUtils.setTwoLineToolTip(gauge, "Double-click to detach", "Right-click to change");
gauge.setBackgroundColor(sensor.getColor()); gauge.setBackgroundColor(sensor.getColor());
@ -65,8 +66,8 @@ public class SensorGauge {
}); });
wrapper.removeAll(); wrapper.removeAll();
wrapper.add(gauge, BorderLayout.CENTER); wrapper.add(gauge, BorderLayout.CENTER);
UpDownImage.trueRepaint(wrapper.getParent()); UiUtils.trueRepaint(wrapper.getParent());
UpDownImage.trueLayout(wrapper.getParent()); UiUtils.trueLayout(wrapper.getParent());
} }
private static void showPopupMenu(MouseEvent e, JPanel wrapper, GaugeChangeListener listener) { private static void showPopupMenu(MouseEvent e, JPanel wrapper, GaugeChangeListener listener) {