JavaApi

de.uni_luebeck.isp.tessla.interpreter.JavaApi$
object 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 Object
trait Matchable
class Any
Self type
JavaApi.type

Members list

Concise view

Type members

Classlikes

case class CompilationResult(result: Result, engine: Engine)

Container for the result of the compilation of a TeSSLa specification.

Container for the result of the compilation of a TeSSLa specification.

Attributes

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

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
case class Diagnostic(diagnostic: Diagnostic)

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.

Attributes

diagnostic

The Diagnostic object from the core API used to generate the Diagnostic object

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
case class Engine(spec: Interpreter)

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)

Attributes

spec

The interpreter of the base specification

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
abstract class EngineListener

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

Graph
Supertypes
class Object
trait Matchable
class Any
case class Result(warnings: List[Diagnostic], errors: List[Diagnostic])

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.

Attributes

errors

Errors which occurred during compilation

warnings

Warnings which occurred during compilation

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

def compile(specSource: CharStream, compilerOptions: Options): CompilationResult

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.

def compile(tessla: String, fileName: String): CompilationResult

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.

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.

Returns:

Object containing information about errors/warnings during compilation and an engine which can be used for monitoring.

def compile(tessla: String, fileName: String, baseTime: String): CompilationResult

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.