API interface for accessing the TeSSLa compiler from other Java or Scala projects. This API is optimized for a
comfortable use from Java and Scala code.
Usage example (in Java):
import de.uni_luebeck.isp.tessla.interpreter.JavaApi;
import de.uni_luebeck.isp.tessla.interpreter.JavaApi.*;
import de.uni_luebeck.isp.tessla.interpreter.StreamEngine;
class Main {
public static void main(String[] args) {
String spec_str = "in temperature: Events[Int]\r\n" +
"\r\n" +
"def low = temperature < 3\r\n" +
"def high = temperature > 8\r\n" +
"def unsafe = low || high\r\n" +
"\r\n" +
"out unsafe";
System.out.println("Compiling...");
Engine res = JavaApi.compile(spec_str ,"spec.tessla").engine();
System.out.println("Ready!");
res.addListener(new EngineListener(){
public void event(String stream, scala.math.BigInt time, Object value) {
System.out.println("Got: " + stream + " = " + value + " at " + time);
}
public void printEvent(scala.math.BigInt time, Object value) {
System.out.println("Raw output: " + value + " at " + time);
}
});
res.setTime(1);
res.provide("temperature",2);
res.setTime(2);
res.provide("temperature",15);
res.setTime(5);
res.provide("temperature",8);
res.step();
System.out.println("Finished!");
}
}
Note: This API internally uses the TeSSLa interpreter. For high performance applications it is advisable to use the
TeSSLa compiler to generate a Scala API directly for a specific specification.
Abstract interface of a Listener which can be attached to an Engine to observe the outputs generated there. Use
Engine.addListener to attach a Listener to an engine.
Abstract interface of a Listener which can be attached to an Engine to observe the outputs generated there. Use
Engine.addListener to attach a Listener to an engine.
Compiles a TeSSLa specification, i.e. generates a monitor which can then be used to receive an input trace and
generate an output trace. This variant of the function requires compiler options to handle the fine tuning of the
compiler and a CharStream for the input.
Compiles a TeSSLa specification, i.e. generates a monitor which can then be used to receive an input trace and
generate an output trace. This variant of the function requires compiler options to handle the fine tuning of the
compiler and a CharStream for the input.
Attributes
compilerOptions
The options for the compiler. See the corresponding documentation of Compiler.Options for details.
specSource
The TeSSLa specification source as a char stream.
Returns:
Object containing information about errors/warnings during compilation and an engine which can be used for
monitoring.
Compiles a TeSSLa specification, i.e. generates a monitor which can then be used to receive an input trace and
generate an output trace. This variant of the function requires a base time unit to be set, which is necessary if
the TeSSLa specification itself uses time units (like ns, ms, s).
Compiles a TeSSLa specification, i.e. generates a monitor which can then be used to receive an input trace and
generate an output trace. This variant of the function requires a base time unit to be set, which is necessary if
the TeSSLa specification itself uses time units (like ns, ms, s).
Attributes
fileName
The name of the TeSSLa file (does not really have to exist in the filesystem but is used, e.g. in error messages.
tessla
The TeSSLa code to be compiled/executed.
timeUnit
The base time unit. I.e. the unit of the input timestamps, Equal to the --base-time flag of the TeSSLa binary.
Possible valid values are e.g. 1ns, 25ms, 1s etc.
Returns:
Object containing information about errors/warnings during compilation and an engine which can be used for
monitoring.
def verify(tessla: String, fileName: String): Result
Checks a TeSSLa specification for sound compilation. I.e. checks for Errors/Warnings in the code.
Checks a TeSSLa specification for sound compilation. I.e. checks for Errors/Warnings in the code.
Attributes
fileName
The name of the TeSSLa file (does not really have to exist in the filesystem but is used, e.g. in error messages.
tessla
The TeSSLa code to be verified.
Returns:
Object containing information about errors and warnings during compilation.
def verify(tessla: String, fileName: String, timeUnit: String): Result
Checks a TeSSLa specification for sound compilation. I.e. checks for Errors/Warnings in the code. This variant of
the function requires a base time unit to be set, which is necessary if the TeSSLa specification itself uses time
units (like ns, ms, s).
Checks a TeSSLa specification for sound compilation. I.e. checks for Errors/Warnings in the code. This variant of
the function requires a base time unit to be set, which is necessary if the TeSSLa specification itself uses time
units (like ns, ms, s).
Attributes
fileName
The name of the TeSSLa file (does not really have to exist in the filesystem but is used, e.g. in error messages.
tessla
The TeSSLa code to be verified.
timeUnit
The base time unit. I.e. the unit of the input timestamps, Equal to the --base-time flag of the TeSSLa binary.
Possible valid values are e.g. 1ns, 25ms, 1s etc.
Returns:
Object containing information about errors and warnings during compilation.