use of jkind.results.Counterexample in project AGREE by loonwerks.
the class TestCaseGeneratorMenuListener method viewCexConsole.
private void viewCexConsole(final Counterexample cex, final Layout layout, Map<String, EObject> refMap, TcgRenaming tcgRenaming) {
final MessageConsole console = findConsole("Test Case");
showConsole(console);
console.clearConsole();
console.addPatternMatchListener(new AgreePatternListener(refMap));
/*
* From the Eclipse API: "Clients should avoid writing large amounts of
* output to this stream in the UI thread. The console needs to process
* the output in the UI thread and if the client hogs the UI thread
* writing output to the console, the console will not be able to
* process the output."
*/
new Thread(() -> {
try (MessageConsoleStream out = console.newMessageStream()) {
for (String category : layout.getCategories()) {
if (isEmpty(category, cex, layout)) {
continue;
}
printHLine(out, cex.getLength());
out.println("Variables for " + category);
printHLine(out, cex.getLength());
out.print(String.format("%-60s", "Variable Name"));
for (int k1 = 0; k1 < cex.getLength(); k1++) {
out.print(String.format("%-15s", k1));
}
out.println();
printHLine(out, cex.getLength());
List<Signal<Value>> inputSignals = new ArrayList<>();
List<Signal<Value>> outputSignals = new ArrayList<>();
List<Signal<Value>> stateSignals = new ArrayList<>();
for (Signal<Value> signal : cex.getCategorySignals(layout, category)) {
// dont' print out values for properties
if (signal.getName().contains(":")) {
continue;
}
String signalName = signal.getName();
EObject ref = tcgRenaming.mapAgreeToEObject(signalName);
boolean isInput = (ref instanceof org.osate.aadl2.Port) ? ((org.osate.aadl2.Port) ref).isIn() : false;
boolean isOutput = (ref instanceof org.osate.aadl2.Port) ? ((org.osate.aadl2.Port) ref).isOut() : false;
if (isInput) {
inputSignals.add(signal);
} else if (isOutput) {
outputSignals.add(signal);
} else {
stateSignals.add(signal);
}
}
out.println("Inputs:");
inputSignals.forEach(it -> AgreeMenuListener.printSignal(out, it, cex.getLength()));
out.println("State:");
stateSignals.forEach(it -> AgreeMenuListener.printSignal(out, it, cex.getLength()));
out.println("Outputs:");
outputSignals.forEach(it -> AgreeMenuListener.printSignal(out, it, cex.getLength()));
out.println();
}
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
use of jkind.results.Counterexample in project AGREE by loonwerks.
the class TestSuiteMenuListener method viewCexConsole.
private void viewCexConsole(final Counterexample cex, final Layout layout, Map<String, EObject> refMap, final TcgRenaming tcgRenaming) {
final MessageConsole console = findConsole("Test Case");
showConsole(console);
console.clearConsole();
console.addPatternMatchListener(new AgreePatternListener(refMap));
/*
* From the Eclipse API: "Clients should avoid writing large amounts of
* output to this stream in the UI thread. The console needs to process
* the output in the UI thread and if the client hogs the UI thread
* writing output to the console, the console will not be able to
* process the output."
*/
new Thread(() -> {
try (MessageConsoleStream out = console.newMessageStream()) {
for (String category : layout.getCategories()) {
if (isEmpty(category, cex, layout)) {
continue;
}
printHLine(out, cex.getLength());
out.println("Variables for " + category);
printHLine(out, cex.getLength());
out.print(String.format("%-60s", "Variable Name"));
for (int k1 = 0; k1 < cex.getLength(); k1++) {
out.print(String.format("%-15s", k1));
}
out.println();
printHLine(out, cex.getLength());
List<Signal<Value>> inputSignals = new ArrayList<>();
List<Signal<Value>> outputSignals = new ArrayList<>();
List<Signal<Value>> stateSignals = new ArrayList<>();
for (Signal<Value> signal : cex.getCategorySignals(layout, category)) {
// dont' print out values for properties
if (signal.getName().contains(":")) {
continue;
}
String signalName = signal.getName();
EObject ref = tcgRenaming.mapAgreeToEObject(signalName);
boolean isInput = (ref instanceof org.osate.aadl2.Port) ? ((org.osate.aadl2.Port) ref).isIn() : false;
boolean isOutput = (ref instanceof org.osate.aadl2.Port) ? ((org.osate.aadl2.Port) ref).isOut() : false;
if (isInput) {
inputSignals.add(signal);
} else if (isOutput) {
outputSignals.add(signal);
} else {
stateSignals.add(signal);
}
}
out.println("Inputs:");
inputSignals.forEach(it -> AgreeMenuListener.printSignal(out, it, cex.getLength()));
out.println("State:");
stateSignals.forEach(it -> AgreeMenuListener.printSignal(out, it, cex.getLength()));
out.println("Outputs:");
outputSignals.forEach(it -> AgreeMenuListener.printSignal(out, it, cex.getLength()));
out.println();
}
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
Aggregations