package net.mograsim.plugin.launch;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Consumer;
+
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.PlatformObject;
private boolean running;
+ private final List<Consumer<Double>> executionSpeedListeners;
+
public MachineDebugTarget(ILaunch launch, MachineDefinition machineDefinition)
{
this.launch = launch;
this.machine = machineDefinition.createNew();
this.exec = new LogicExecuter(machine.getTimeline());
+ this.executionSpeedListeners = new ArrayList<>();
+
exec.startLiveExecution();
running = true;
public void setExecutionSpeed(double speed)
{
if (getExecutionSpeed() != speed)
+ {
exec.setSpeedFactor(speed);
+ callExecutionSpeedListener(speed);
+ }
}
@Override
return new IThread[0];
}
+ public void addExecutionSpeedListener(Consumer<Double> executionSpeedListener)
+ {
+ executionSpeedListeners.add(executionSpeedListener);
+ }
+
+ public void removeExecutionSpeedListener(Consumer<Double> executionSpeedListener)
+ {
+ executionSpeedListeners.remove(executionSpeedListener);
+ }
+
+ private void callExecutionSpeedListener(double executionSpeed)
+ {
+ executionSpeedListeners.forEach(l -> l.accept(executionSpeed));
+ }
+
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> adapter)