Skip to content
Snippets Groups Projects
Commit a32f6deb authored by dgelessus's avatar dgelessus
Browse files

Remove (Get|Set)PrologRandomSeed which do nothing

The predicates on the Prolog side don't do anything anymore since 2012.
parent c2449854
No related branches found
No related tags found
No related merge requests found
Pipeline #103582 passed
......@@ -13,15 +13,7 @@ import de.prob.prolog.output.IPrologTermOutput;
import de.prob.prolog.term.PrologTerm;
public class ClearMachineCommand implements IComposableCommand {
private static final ClearCmd CLEAR_CMD = new ClearCmd();
private final GetPrologRandomSeed getRandomSeed;
private final ComposedCommand cmd;
public ClearMachineCommand() {
this.getRandomSeed = new GetPrologRandomSeed();
this.cmd = new ComposedCommand(getRandomSeed, CLEAR_CMD);
}
public ClearMachineCommand() {}
public static void clearMachine(final Animator animator)
throws ProBException {
......@@ -30,26 +22,9 @@ public class ClearMachineCommand implements IComposableCommand {
public void processResult(
final ISimplifiedROMap<String, PrologTerm> bindings)
throws CommandException {
cmd.processResult(bindings);
final Animator animator = Animator.getAnimator();
animator.setRandomSeed(getRandomSeed.getSeed());
}
public void writeCommand(final IPrologTermOutput pto)
throws CommandException {
cmd.writeCommand(pto);
}
private final static class ClearCmd implements IComposableCommand {
public void processResult(
final ISimplifiedROMap<String, PrologTerm> bindings)
throws CommandException {
}
throws CommandException {}
public void writeCommand(final IPrologTermOutput pto) {
pto.openTerm("clear_loaded_machines").closeTerm();
}
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich
* Heine Universitaet Duesseldorf This software is licenced under EPL 1.0
* (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.prob.core.command;
import java.math.BigInteger;
import de.prob.core.Animator;
import de.prob.core.domainobjects.RandomSeed;
import de.prob.exceptions.ProBException;
import de.prob.parser.BindingGenerator;
import de.prob.parser.ISimplifiedROMap;
import de.prob.parser.ResultParserException;
import de.prob.prolog.output.IPrologTermOutput;
import de.prob.prolog.term.PrologTerm;
public final class GetPrologRandomSeed implements IComposableCommand {
private RandomSeed randomSeed;
public static RandomSeed getSeed(final Animator a) throws ProBException {
final GetPrologRandomSeed cmd = new GetPrologRandomSeed();
a.execute(cmd);
return cmd.getSeed();
}
public RandomSeed getSeed() {
return randomSeed;
}
public void processResult(
final ISimplifiedROMap<String, PrologTerm> bindings)
throws CommandException {
BigInteger x, y, z, b;
try {
x = BindingGenerator.getInteger(bindings.get("X")).getValue();
y = BindingGenerator.getInteger(bindings.get("Y")).getValue();
z = BindingGenerator.getInteger(bindings.get("Z")).getValue();
b = BindingGenerator.getInteger(bindings.get("B")).getValue();
} catch (ResultParserException e) {
CommandException commandException = new CommandException(
e.getLocalizedMessage(), e);
commandException.notifyUserOnce();
throw commandException;
}
randomSeed = new RandomSeed(x, y, z, b);
}
public void writeCommand(final IPrologTermOutput pto) {
pto.openTerm("get_rand").printVariable("X").printVariable("Y")
.printVariable("Z").printVariable("B").closeTerm();
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich
* Heine Universitaet Duesseldorf This software is licenced under EPL 1.0
* (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.prob.core.command;
import de.prob.core.Animator;
import de.prob.core.domainobjects.RandomSeed;
import de.prob.exceptions.ProBException;
import de.prob.parser.ISimplifiedROMap;
import de.prob.prolog.output.IPrologTermOutput;
import de.prob.prolog.term.PrologTerm;
public final class SetPrologRandomSeed implements IComposableCommand {
private final RandomSeed seed;
public SetPrologRandomSeed(final RandomSeed seed) {
this.seed = seed;
}
public static void setSeed(final Animator a, final RandomSeed seed)
throws ProBException {
SetPrologRandomSeed cmd = new SetPrologRandomSeed(seed);
a.execute(cmd);
}
public void processResult(
final ISimplifiedROMap<String, PrologTerm> bindings)
throws CommandException {
// no result, nothing to do
}
public void writeCommand(final IPrologTermOutput pto) {
pto.openTerm("set_rand");
pto.printNumber(seed.getSeedX());
pto.printNumber(seed.getSeedY());
pto.printNumber(seed.getSeedZ());
pto.printNumber(seed.getSeedB());
pto.closeTerm();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment