This commit is contained in:
parent
20a6527615
commit
1921835f39
|
@ -3,6 +3,7 @@ package com.rusefi;
|
|||
import com.rusefi.io.CommandQueue;
|
||||
import com.rusefi.ui.MessagesView;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import com.rusefi.ui.widgets.EtbTestSequence;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.putgemin.VerticalFlowLayout;
|
||||
|
||||
|
@ -24,6 +25,7 @@ public class BenchTestPane {
|
|||
content.add(createMILTest());
|
||||
content.add(createIdleTest());
|
||||
content.add(createDizzyTest());
|
||||
content.add(UiUtils.wrap(new EtbTestSequence().getButton()));
|
||||
content.add(new MessagesView().messagesScroll);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package com.rusefi.ui.widgets;
|
||||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.io.CommandQueue;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* https://github.com/rusefi/rusefi/issues/494
|
||||
* <p>
|
||||
* Here we initiate a sequence of commands which would change target electronic throttle position so that we can
|
||||
* see how far the result would be how soon.
|
||||
* <p>
|
||||
* 11/16/2017
|
||||
* (c) Andrey Belomutskiy
|
||||
*/
|
||||
public class EtbTestSequence {
|
||||
private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||
|
||||
private final static long SECOND = 1000;
|
||||
|
||||
private final JButton button = new JButton("ETB Test");
|
||||
|
||||
private static EtbTarget FIRST_STEP = new EtbTarget(SECOND, 0)
|
||||
.addNext(5 * SECOND, 30)
|
||||
.addNext(10 * SECOND, 50);
|
||||
|
||||
public EtbTestSequence() {
|
||||
button.addActionListener(e -> FIRST_STEP.execute(executor));
|
||||
}
|
||||
|
||||
public JButton getButton() {
|
||||
return button;
|
||||
}
|
||||
|
||||
static class EtbTarget {
|
||||
final long duration;
|
||||
/**
|
||||
* 0-100 percent open
|
||||
*/
|
||||
final double position;
|
||||
|
||||
EtbTarget next;
|
||||
|
||||
public EtbTarget(long duration, double position) {
|
||||
this.duration = duration;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public EtbTarget addNext(long duration, double position) {
|
||||
next = new EtbTarget(duration, position);
|
||||
return next;
|
||||
}
|
||||
|
||||
public void execute(ScheduledExecutorService executor) {
|
||||
CommandQueue.getInstance().write("set mock_pedal_position " + position);
|
||||
if (next != null) {
|
||||
FileLog.MAIN.logLine("Scheduling " + next);
|
||||
executor.schedule(() -> next.execute(executor),
|
||||
duration, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EtbTarget{" +
|
||||
"duration=" + duration +
|
||||
", position=" + position +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue