if (command.equals(msgTestDiffParsing) && message.arity() == 4) // this one computes a graph reflecting the differences and returns the labelling part of it as a string. Inputs are one of the original machines and the differences.
{
OtpErlangObject outcome = null;
try
{
DirectedSparseGraph diff = DifferenceVisualiser.ChangesToGraph.computeVisualisationParameters(message.elementAt(2), message.elementAt(3));
Set<String> modifiedLines = new TreeSet<String>();
for(Object obj:diff.getEdges()) // getEdges returns edges in a JDK-dependent order, we use TreeSet to sort them so that expected values can be determined without associating them with specific versions of JDK.
{
StringBuffer textOfTheOutcome = new StringBuffer();
textOfTheOutcome.append(obj.toString());textOfTheOutcome.append(":");textOfTheOutcome.append( ((Edge)obj).getUserDatum(JUConstants.DIFF) );
modifiedLines.add(textOfTheOutcome.toString());
}
outcome = new OtpErlangTuple(new OtpErlangObject[]{ref,msgOk,new OtpErlangAtom(modifiedLines.toString())});
}
catch(Throwable ex)
{
outcome = new OtpErlangTuple(new OtpErlangObject[]{ref,msgFailure,new OtpErlangList(ex.getMessage())});
}
mbox.send(erlangPartner,outcome);
}
else
// Arguments: Ref, 'displayDiff', first graph, diff, atom with the name of the difference and (optional) list of states (as atoms) to ignore.
// Upon error, no notifications are sent and instead an error is reported.
// Note: if the difference name is an empty sequence, no graph is displayed but notifications are provided (for testing).
if (command.equals(msgDisplayDiff) && message.arity() >= 5)
{
OtpErlangObject outcome = null;
try
{
DirectedSparseGraph diff = DifferenceVisualiser.ChangesToGraph.computeVisualisationParameters(message.elementAt(2), message.elementAt(3));
int windowNumber = setOptions(message,4,diff);
if (windowNumber >= 0)
Visualiser.updateFrameWithPos(diff,windowNumber);
outcome = new OtpErlangTuple(new OtpErlangObject[]{ref,msgOk});
}
catch(Throwable ex)
{
outcome = new OtpErlangTuple(new OtpErlangObject[]{ref,msgFailure,new OtpErlangList(ex.getMessage())});
}
mbox.send(erlangPartner,outcome);
}
else
// Arguments: Ref, 'displayFSM', graph, atom with the name of the difference and (optional) list of states (as atoms) to ignore.
// Upon error, no notifications are sent and instead an error is reported.
// Note: if the difference name is an empty sequence, no graph is displayed but notifications are provided (for testing).
if (command.equals(msgDisplayFSM) && message.arity() >= 4)
{
OtpErlangObject outcome = null;
try
{
Configuration config = Configuration.getDefaultConfiguration().copy();
LearnerGraphND machine = new LearnerGraphND(config);Synapse.StatechumProcess.parseStatemachine(message.elementAt(2),machine,null,true);
DirectedSparseGraph fsmPicture = machine.pathroutines.getGraph();
if (!fsmPicture.containsUserDatumKey(JUConstants.LAYOUTOPTIONS))
fsmPicture.addUserDatum(JUConstants.LAYOUTOPTIONS,new LayoutOptions(), UserData.SHARED);
int windowNumber = setOptions(message,3,fsmPicture);
if (windowNumber >= 0)
Visualiser.updateFrameWithPos(fsmPicture,windowNumber);
outcome = new OtpErlangTuple(new OtpErlangObject[]{ref,msgOk});