Skip to content
Snippets Groups Projects
Commit 89240b65 authored by Sebastian Krings's avatar Sebastian Krings
Browse files

get unit analysis result (string form) from prolog and print on console

parent 070b9e3b
Branches
Tags
No related merge requests found
/**
* (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.parser.BindingGenerator;
import de.prob.parser.ISimplifiedROMap;
import de.prob.parser.ResultParserException;
import de.prob.prolog.output.IPrologTermOutput;
import de.prob.prolog.term.ListPrologTerm;
import de.prob.prolog.term.PrologTerm;
public final class GetPluginResultCommand implements IComposableCommand {
private final String resultID;
private String result;
public GetPluginResultCommand(final String resultID) {
this.resultID = resultID;
}
public String getResult() {
return result;
}
public void processResult(
final ISimplifiedROMap<String, PrologTerm> bindings)
throws CommandException {
ListPrologTerm list;
try {
list = BindingGenerator.getList(bindings, "Bindings");
} catch (ResultParserException e) {
CommandException commandException = new CommandException(
e.getLocalizedMessage(), e);
commandException.notifyUserOnce();
throw commandException;
}
for (PrologTerm term : list) {
int nextCharCode = BindingGenerator.getInteger(term).getValue()
.intValue();
result += (char) nextCharCode;
}
}
public void writeCommand(final IPrologTermOutput pto) {
pto.openTerm("getPluginOutput").printAtomOrNumber(resultID)
.printVariable("Bindings").closeTerm();
}
}
......@@ -38,12 +38,10 @@ import de.prob.core.LimitedLogger;
import de.prob.core.command.ActivateUnitPluginCommand;
import de.prob.core.command.ClearMachineCommand;
import de.prob.core.command.ComposedCommand;
import de.prob.core.command.GetCurrentStateIdCommand;
import de.prob.core.command.GetStateValuesCommand;
import de.prob.core.command.GetPluginResultCommand;
import de.prob.core.command.SetPreferencesCommand;
import de.prob.core.command.StartAnimationCommand;
import de.prob.core.command.internal.InternalLoadCommand;
import de.prob.core.domainobjects.Variable;
import de.prob.exceptions.ProBException;
import de.prob.logging.Logger;
......@@ -131,17 +129,14 @@ public class StartUnitAnalysisHandler extends AbstractHandler implements
animator.execute(composed);
// TODO: get resulting state and fill attributes
String currentID = GetCurrentStateIdCommand.getID(animator);
GetStateValuesCommand stateValuesCommand = new GetStateValuesCommand(
currentID);
GetPluginResultCommand stateValuesCommand = new GetPluginResultCommand(
"Static Analysis Result");
animator.execute(stateValuesCommand);
List<Variable> vars = stateValuesCommand.getResult();
String output = stateValuesCommand.getResult();
for (Variable v : vars) {
System.out.println(v.getIdentifier());
}
System.out.println(output);
// shutdown animator
animator.shutdown();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment