Search in sources :

Example 1 with IRawCommand

use of de.prob.animator.command.IRawCommand in project prob2 by bendisposto.

the class CommandProcessor method sendCommand.

public IPrologResult sendCommand(final AbstractCommand command) {
    String query;
    if (command instanceof IRawCommand) {
        query = ((IRawCommand) command).getCommand();
        if (!query.endsWith(".")) {
            query += ".";
        }
    } else {
        PrologTermStringOutput pto = new PrologTermStringOutput();
        command.writeCommand(pto);
        pto.printAtom("true");
        query = pto.fullstop().toString();
    }
    if (logger.isDebugEnabled()) {
        logger.debug(StringUtils.chomp(StringUtils.abbreviate(query, 200)));
    }
    String result = cli.send(query);
    final Start ast = parseResult(result);
    IPrologResult extractResult = extractResult(ast);
    if (logger.isDebugEnabled()) {
        logger.debug(StringUtils.chomp(StringUtils.abbreviate(extractResult.toString(), 200)));
    }
    return extractResult;
}
Also used : Start(de.prob.core.sablecc.node.Start) PrologTermStringOutput(de.prob.prolog.output.PrologTermStringOutput) IRawCommand(de.prob.animator.command.IRawCommand)

Aggregations

IRawCommand (de.prob.animator.command.IRawCommand)1 Start (de.prob.core.sablecc.node.Start)1 PrologTermStringOutput (de.prob.prolog.output.PrologTermStringOutput)1