JavaApi
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.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
JavaApi.type
Members list
Type members
Classlikes
Container for the result of the compilation of a TeSSLa specification.
Container for the result of the compilation of a TeSSLa specification.
Value parameters
- engine
-
Monitor generated from the specification (can be used to receive input streams and generate output streams)
- result
-
Object containing the errors and warnings which occurred during compilation
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Diagnostic object, carrying information about errors and warnings which occur during compilation and execution.
Diagnostic object, carrying information about errors and warnings which occur during compilation and execution.
Value parameters
- diagnostic
-
The Diagnostic object from the core API used to generate the Diagnostic object
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Class for a TeSSLa monitor.
Class for a TeSSLa monitor.
Intended usage is not to directly instantiate an Engine but to use the compile function instead. See usage example of JavaApi for details.
An Engine object can be used to receive events from input streams (see provide) and to attach listeners for output streams (see addListener)
Value parameters
- spec
-
The interpreter of the base specification
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
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.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Container class for errors and warnings that occurred during compilation of a TeSSLa specification.
Container class for errors and warnings that occurred during compilation of a TeSSLa specification.
Value parameters
- errors
-
Errors which occurred during compilation
- warnings
-
Warnings which occurred during compilation
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Value members
Concrete methods
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.
Value parameters
- compilerOptions
-
The options for the compiler. See the corresponding documentation of Compiler.Options for details.
- specSource
-
The TeSSLa specification source as a char stream.
Attributes
- 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.
Compiles a TeSSLa specification, i.e. generates a monitor which can then be used to receive an input trace and generate an output trace.
Value parameters
- 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.
Attributes
- 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).
Value parameters
- 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.
Attributes
- Returns
-
Object containing information about errors/warnings during compilation and an engine which can be used for monitoring.
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.
Value parameters
- 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.
Attributes
- Returns
-
Object containing information about errors and warnings during compilation.
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).
Value parameters
- 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.
Attributes
- Returns
-
Object containing information about errors and warnings during compilation.