auto-sync
This commit is contained in:
parent
bc3f53e37e
commit
795168269c
|
@ -4,11 +4,10 @@ import com.rusefi.ui.engine.UpDownImage;
|
|||
import com.rusefi.ui.util.FrameHelper;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import com.rusefi.waves.EngineReport;
|
||||
import org.putgemin.VerticalFlowLayout;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Arc2D;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -22,6 +21,7 @@ public class TriggerImage {
|
|||
|
||||
public static final String TRIGGERTYPE = "TRIGGERTYPE";
|
||||
public static final String TRIGGERS = "triggers";
|
||||
public static final String TRIGGERS_TXT = "triggers.txt";
|
||||
private static int WIDTH = 320;
|
||||
/**
|
||||
* number of extra frames
|
||||
|
@ -31,29 +31,29 @@ public class TriggerImage {
|
|||
private static int WAVE_COUNT = 2;
|
||||
|
||||
public static void main(String[] args) throws IOException, InvocationTargetException, InterruptedException {
|
||||
final String path;
|
||||
if (args.length != 1) {
|
||||
System.out.println("Path to file expected");
|
||||
System.exit(-1);
|
||||
path = ".." + File.separator + "unit_tests";
|
||||
} else {
|
||||
path = args[0];
|
||||
}
|
||||
final String path = args[0];
|
||||
|
||||
FrameHelper f = new FrameHelper();
|
||||
|
||||
final TriggerPanel trigger = new TriggerPanel(new GridLayout(WAVE_COUNT, 1)) {
|
||||
final TriggerPanel triggerPanel = new TriggerPanel(new GridLayout(WAVE_COUNT, 1)) {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension((1 + EXTRA_COUNT) * WIDTH, 480);
|
||||
}
|
||||
};
|
||||
|
||||
f.showFrame(trigger);
|
||||
|
||||
f.showFrame(triggerPanel);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
generateImages(path, trigger);
|
||||
generateImages(path, triggerPanel);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
@ -63,10 +63,14 @@ public class TriggerImage {
|
|||
}
|
||||
|
||||
private static void generateImages(String path, TriggerPanel trigger) throws IOException {
|
||||
BufferedReader br = new BufferedReader(new FileReader(path + File.separator + "triggers.txt"));
|
||||
BufferedReader br = new BufferedReader(new FileReader(path + File.separator + TRIGGERS_TXT));
|
||||
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (line.trim().startsWith("#")) {
|
||||
// skipping a comment
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.startsWith(TRIGGERTYPE)) {
|
||||
readTrigger(br, line, trigger);
|
||||
|
@ -74,23 +78,51 @@ public class TriggerImage {
|
|||
}
|
||||
}
|
||||
|
||||
private static void readTrigger(BufferedReader br, String line, TriggerPanel trigger) throws IOException {
|
||||
private static void readTrigger(BufferedReader reader, String line, TriggerPanel triggerPanel) throws IOException {
|
||||
String[] tokens = line.split(" ");
|
||||
String idStr = tokens[1];
|
||||
String countStr = tokens[2];
|
||||
String name = tokens[3];
|
||||
int count = Integer.parseInt(countStr);
|
||||
String eventCountStr = tokens[2];
|
||||
String triggerName = tokens[3];
|
||||
int eventCount = Integer.parseInt(eventCountStr);
|
||||
int id = Integer.parseInt(idStr);
|
||||
|
||||
// if (id != 4)
|
||||
// return;
|
||||
|
||||
System.out.println("id=" + id + ", count=" + count + ", name=" + name);
|
||||
System.out.println("id=" + id + ", count=" + eventCount + ", name=" + triggerName);
|
||||
|
||||
List<WaveState> waves = readTrigger(reader, eventCount);
|
||||
|
||||
EngineReport re0 = new EngineReport(waves.get(0).list, 720, 720 * (1 + EXTRA_COUNT));
|
||||
EngineReport re1 = new EngineReport(waves.get(1).list, 720, 720 * (1 + EXTRA_COUNT));
|
||||
|
||||
triggerPanel.removeAll();
|
||||
UpDownImage upDownImage0 = new UpDownImage(re0, "trigger");
|
||||
upDownImage0.showText = false;
|
||||
triggerPanel.add(upDownImage0);
|
||||
|
||||
UpDownImage upDownImage1 = new UpDownImage(re1, "trigger");
|
||||
upDownImage1.showText = false;
|
||||
if (!re1.getList().isEmpty())
|
||||
triggerPanel.add(upDownImage1);
|
||||
|
||||
triggerPanel.name = triggerName;
|
||||
triggerPanel.id = id;
|
||||
|
||||
UiUtils.trueLayout(triggerPanel);
|
||||
UiUtils.trueRepaint(triggerPanel);
|
||||
new File(TRIGGERS).mkdir();
|
||||
UiUtils.saveImage(TRIGGERS + File.separator + "trigger_" + id + ".png", triggerPanel);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<WaveState> readTrigger(BufferedReader reader, int count) throws IOException {
|
||||
String line;
|
||||
String[] tokens;
|
||||
List<Signal> signals = new ArrayList<>();
|
||||
|
||||
for (int index = 0; index < count; index++) {
|
||||
line = br.readLine();
|
||||
line = reader.readLine();
|
||||
tokens = line.split(" ");
|
||||
String signalStr = tokens[2];
|
||||
int signal = Integer.parseInt(signalStr);
|
||||
|
@ -126,26 +158,7 @@ public class TriggerImage {
|
|||
for (WaveState wave : waves)
|
||||
wave.wrap();
|
||||
|
||||
trigger.removeAll();
|
||||
|
||||
EngineReport re0 = new EngineReport(waves.get(0).list, 720, 720 * (1 + EXTRA_COUNT));
|
||||
EngineReport re1 = new EngineReport(waves.get(1).list, 720, 720 * (1 + EXTRA_COUNT));
|
||||
|
||||
UpDownImage upDownImage0 = new UpDownImage(re0, "trigger");
|
||||
upDownImage0.showText = false;
|
||||
trigger.add(upDownImage0);
|
||||
|
||||
UpDownImage upDownImage1 = new UpDownImage(re1, "trigger");
|
||||
upDownImage1.showText = false;
|
||||
trigger.add(upDownImage1);
|
||||
|
||||
trigger.name = name;
|
||||
trigger.id = id;
|
||||
|
||||
UiUtils.trueLayout(trigger);
|
||||
UiUtils.trueRepaint(trigger);
|
||||
new File(TRIGGERS).mkdir();
|
||||
UiUtils.saveImage(TRIGGERS + File.separator + "trigger_" + id + ".png", trigger);
|
||||
return waves;
|
||||
}
|
||||
|
||||
private static int angleToTime(double prevUp) {
|
||||
|
|
Loading…
Reference in New Issue