Search in sources :

Example 1 with TcgException

use of com.rockwellcollins.atc.tcg.TcgException in project AGREE by loonwerks.

the class TcgXmlWriter method writeTest.

private void writeTest(String name, String description, Counterexample cex) {
    try {
        out.println("    <Test name=\"" + escapeXml(name) + "\">");
        out.println("      <Description>" + escapeXml(description) + "</Description>");
        out.println("      <Length>" + cex.getLength() + "</Length>");
        writeCounterexample(cex);
        out.println("    </Test>");
    } catch (Exception e) {
        throw new TcgException("Error writing XML Test Suite", e);
    }
}
Also used : TcgException(com.rockwellcollins.atc.tcg.TcgException) FileNotFoundException(java.io.FileNotFoundException) TcgException(com.rockwellcollins.atc.tcg.TcgException)

Example 2 with TcgException

use of com.rockwellcollins.atc.tcg.TcgException in project AGREE by loonwerks.

the class TcgXmlWriter method writeSignal.

private void writeSignal(int k, Signal<Value> signal) throws Exception {
    String name = escapeXml(signal.getName());
    // TODO: fix this with the type map!
    Type type;
    if (signal.getValues().isEmpty()) {
        throw new TcgException("Unable to assertain signal type in XmlWriter");
    } else {
        Map.Entry<Integer, Value> entry = signal.getValues().entrySet().iterator().next();
        Value v = entry.getValue();
        if (v instanceof IntegerValue) {
            type = NamedType.INT;
        } else if (v instanceof RealValue) {
            type = NamedType.REAL;
        } else if (v instanceof BooleanValue) {
            type = NamedType.BOOL;
        } else {
            throw new TcgException("Unexpected signal type in XmlWriter");
        }
    }
    out.println("      <Signal name=\"" + name + "\" type=\"" + type + "\">");
    for (int i = 0; i < k; i++) {
        out.println("        <Value time=\"" + i + "\">" + formatValue(signal.getValue(i)) + "</Value>");
    }
    out.println("      </Signal>");
}
Also used : RealValue(jkind.lustre.values.RealValue) Type(jkind.lustre.Type) NamedType(jkind.lustre.NamedType) IntegerValue(jkind.lustre.values.IntegerValue) BooleanValue(jkind.lustre.values.BooleanValue) RealValue(jkind.lustre.values.RealValue) IntegerValue(jkind.lustre.values.IntegerValue) Value(jkind.lustre.values.Value) BooleanValue(jkind.lustre.values.BooleanValue) Map(java.util.Map) TcgException(com.rockwellcollins.atc.tcg.TcgException)

Example 3 with TcgException

use of com.rockwellcollins.atc.tcg.TcgException in project AGREE by loonwerks.

the class TcgXmlWriter method begin.

private void begin(String name, String description, String implUnderTest) {
    try {
        out.println("<?xml version=\"1.0\"?>");
        out.println("<TestSuite xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">");
        out.println("  <SuiteName>" + escapeXml(name) + "</SuiteName>");
        out.println("  <SuiteDescription>" + escapeXml(description) + "</SuiteDescription>");
        out.println("  <ImplementationUnderTest>" + escapeXml(implUnderTest) + "</ImplementationUnderTest>");
        out.println("  <Tests>");
    } catch (Exception e) {
        throw new TcgException("Error writing XML Test Suite", e);
    }
}
Also used : TcgException(com.rockwellcollins.atc.tcg.TcgException) FileNotFoundException(java.io.FileNotFoundException) TcgException(com.rockwellcollins.atc.tcg.TcgException)

Example 4 with TcgException

use of com.rockwellcollins.atc.tcg.TcgException in project AGREE by loonwerks.

the class OpenHandler method loadTests.

private TestSuite loadTests() throws TcgException {
    try {
        Shell activeShell = getWindow().getShell();
        syncExec(() -> {
            location = TcgPreferenceUtils.getTestCaseOpenFileDialog(activeShell, null);
        });
        if (location != null) {
            InputStream targetStream = new FileInputStream(location);
            TestSuite ts = new TestSuite();
            TcgXmlReader reader = new TcgXmlReader(targetStream);
            reader.readSuite(ts);
            ts.setState(TestSuite.State.LOADED);
            return ts;
        } else {
            return null;
        }
    } catch (IOException e) {
        throw new TcgException("Error loading test file", e);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) TestSuite(com.rockwellcollins.atc.tcg.suite.TestSuite) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) TcgXmlReader(com.rockwellcollins.atc.tcg.readers.TcgXmlReader) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) TcgException(com.rockwellcollins.atc.tcg.TcgException)

Example 5 with TcgException

use of com.rockwellcollins.atc.tcg.TcgException in project AGREE by loonwerks.

the class VerifyHandler method writeIntermediateFiles.

private void writeIntermediateFiles(Program program, Program ufcProgram) {
    if (Debug) {
        try {
            System.out.println("writing ufc obligations...");
            writeLustre("orig.lus", program);
            writeLustre("tcg.lus", ufcProgram);
        } catch (FileNotFoundException ff) {
            throw new TcgException("couldn't write .lus files in VerifyHandler", ff);
        }
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) TcgException(com.rockwellcollins.atc.tcg.TcgException)

Aggregations

TcgException (com.rockwellcollins.atc.tcg.TcgException)8 FileNotFoundException (java.io.FileNotFoundException)4 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)1 TcgPreferenceUtils (com.rockwellcollins.atc.tcg.preferences.TcgPreferenceUtils)1 TcgXmlReader (com.rockwellcollins.atc.tcg.readers.TcgXmlReader)1 TestCase (com.rockwellcollins.atc.tcg.suite.TestCase)1 TestSuite (com.rockwellcollins.atc.tcg.suite.TestSuite)1 TcgXmlWriter (com.rockwellcollins.atc.tcg.writers.TcgXmlWriter)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Map (java.util.Map)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 JKindException (jkind.JKindException)1 NamedType (jkind.lustre.NamedType)1 Type (jkind.lustre.Type)1 BooleanValue (jkind.lustre.values.BooleanValue)1 IntegerValue (jkind.lustre.values.IntegerValue)1 RealValue (jkind.lustre.values.RealValue)1 Value (jkind.lustre.values.Value)1