com.uppaal.engine
Class EngineStub

java.lang.Object
  extended by com.uppaal.engine.EngineStub

public class EngineStub
extends Object

A thin stub for the server protocol.

The EngineStub class takes care of connecting to and disconnecting from the server. Connections can be local and remote. For local (aka. native) connections, the server process is started by the engine stub on the local machine and communication is handled via pipes. On disconnect the server process is killed. Remote connections do not start a server. Instead, the stub will try to connect to a running server.

The serverHost and serverPort properties determine which host and on which port to connect to the server for remote connections. The connectionMode is used to determine the kind of connection to establish. If connectionMode is BOTH, then the stub will first attempt to create a remote connection and if that fails create a local connection. The serverPath holds the name of the server executable to execute in local mode. After a successful connection has been established the port to which the connection has been established can be queried with getConnectedPort(). Notice that the serverPort property plays no role for local connections.

The server protocol is not state less, as there is a notion of uploading a model and certain operations are only valid after uploading a model. You most likely want to use the Engine class rather than the EngineStub.


Field Summary
static int BOTH
          Try remote connection first, then local.
static String DEFAULT_HOST
          The default host for remote connections.
static int DEFAULT_PORT
          The default port for remote connections.
static int LOCAL
          Local connections only.
static int SERVER
          Remote connections only..
 
Constructor Summary
EngineStub()
          Constructs an EngineStub in LOCAL connection mode.
EngineStub(int mode, int port, String host, String path)
          Constructs an EngineStub with the given mode, port, port and server path values.
 
Method Summary
 void connect()
          Connect to the server.
 void disconnect()
          Disconnect from the server.
 int getConnectedPort()
          Returns the port the engine is connected to.
 int getConnectionMode()
          Returns the current connection mode.
 SystemState getInitial(UppaalSystem system)
          Returns the initial state for the system.
 String getOptionsInfo()
          Returns information about available options.
 String getServerHost()
          Returns the current server host.
 String getServerPath()
          Returns the current server path.
 int getServerPort()
          Returns the current server port.
 ArrayList<Transition> getTransitions(UppaalSystem system, SystemState state)
          Returns the list of outgoing transitions for the state.
 String getVersion()
          Returns the version string of the server.
 void handshake()
          Performs a handshake with the server.
 boolean isConnected()
          Returns true if the engine is connected to a server.
 boolean isRemoteConnection()
          Returns true if the engine is connected to a remote server.
 void kill()
          Kill the server connection the hard way.
 char query(UppaalSystem system, String query, QueryFeedback f)
          Verify a guery on an instantiated UPPAAL model.
 char query(UppaalSystem system, SystemState state, String query, QueryFeedback f)
          Verify a guery on an instantiated UPPAAL model with custom initial state.
 void setConnectionMode(int mode)
          Sets the connection mode.
 void setOptions(String options)
          Sets server options used for verification.
 void setServerHost(String host)
          Sets the server host.
 void setServerPath(String path)
          Sets the server path.
 void setServerPort(int port)
          Sets the server port.
 UppaalSystem upload(Document document)
          Upload the document to the server.
 UppaalSystem upload(Document document, ArrayList<Problem> problems)
          Upload the document to the server.
 LscProcess uploadLsc(Document document, ArrayList<Problem> problems)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCAL

public static int LOCAL
Local connections only.


SERVER

public static int SERVER
Remote connections only..


BOTH

public static int BOTH
Try remote connection first, then local.


DEFAULT_HOST

public static String DEFAULT_HOST
The default host for remote connections.


DEFAULT_PORT

public static int DEFAULT_PORT
The default port for remote connections.

Constructor Detail

EngineStub

public EngineStub()
Constructs an EngineStub in LOCAL connection mode.


EngineStub

public EngineStub(int mode,
                  int port,
                  String host,
                  String path)
Constructs an EngineStub with the given mode, port, port and server path values.

Method Detail

getServerPort

public int getServerPort()
Returns the current server port.


setServerPort

public void setServerPort(int port)
Sets the server port. The server port is used in REMOTE mode to dertmine which port on the server to connect to.


getConnectionMode

public int getConnectionMode()
Returns the current connection mode.


setConnectionMode

public void setConnectionMode(int mode)
Sets the connection mode. Mode is either LOCAL, SERVER or BOTH. In BOTH the stub will first try to build a remote connection and if that fails attempt to create a local connection.


getServerHost

public String getServerHost()
Returns the current server host.


setServerHost

public void setServerHost(String host)
Sets the server host. In SERVER mode the engine will try to connect to this host.


getServerPath

public String getServerPath()
Returns the current server path.


getConnectedPort

public int getConnectedPort()
Returns the port the engine is connected to.


setServerPath

public void setServerPath(String path)
Sets the server path. The server path should include the path to, filename of and options for the server binary.


isConnected

public boolean isConnected()
Returns true if the engine is connected to a server.


isRemoteConnection

public boolean isRemoteConnection()
Returns true if the engine is connected to a remote server.


connect

public void connect()
             throws EngineException,
                    IOException
Connect to the server. Depending on the connection mode setting either a remote or local connection will be established (or both). Remote connections are made according to the server host and server port settings. Local connections are established according to the server path setting.

Throws:
EngineException
IOException

disconnect

public void disconnect()
Disconnect from the server. If connected to the server, the connection will be cut by closing the socket and making sure the socket server process is terminated if in LOCAL mode. The engine waits for the socket server to terminate by itself after closing the socket connection. If the socket server is still running after 2 seconds it is killed.


kill

public void kill()
Kill the server connection the hard way. The socket is closed, and the socket server is killed.


handshake

public void handshake()
               throws IOException,
                      EngineException
Performs a handshake with the server. Done automatically by connect().

Throws:
IOException
EngineException

getVersion

public String getVersion()
                  throws IOException,
                         EngineException
Returns the version string of the server. The stub must be connected.

Throws:
IOException
EngineException

getOptionsInfo

public String getOptionsInfo()
                      throws EngineException,
                             IOException
Returns information about available options. The information is returned as an XML document. The stub must be connected.

Throws:
EngineException
IOException

setOptions

public void setOptions(String options)
                throws EngineException,
                       IOException
Sets server options used for verification. The stub must be connected. TODO: Document format.

Throws:
EngineException
IOException

getInitial

public SystemState getInitial(UppaalSystem system)
                       throws EngineException,
                              IOException
Returns the initial state for the system. The stub must be connected and the system must be the last one uploaded to the server.

Throws:
EngineException
IOException

getTransitions

public ArrayList<Transition> getTransitions(UppaalSystem system,
                                            SystemState state)
                                     throws EngineException,
                                            IOException
Returns the list of outgoing transitions for the state. The stub must be connected, the state must belong to the system, and the system must be the last one uploaded to the server.

Throws:
EngineException
IOException

upload

public UppaalSystem upload(Document document,
                           ArrayList<Problem> problems)
                    throws EngineException,
                           IOException
Upload the document to the server. If no errors occurred, the instantiated system is returned. Otherwise, null is returned and error reports are stored in the problems vector. Even if no errors occurred, warnings may have been added to the problems vector. The stub must be connected.

Throws:
EngineException
IOException

uploadLsc

public LscProcess uploadLsc(Document document,
                            ArrayList<Problem> problems)
                     throws EngineException,
                            IOException
Throws:
EngineException
IOException

upload

public UppaalSystem upload(Document document)
                    throws EngineException,
                           IOException
Upload the document to the server. If no errors occurred, the instantiated system is returned. Otherwise, null is returned. The stub must be connected.

Throws:
EngineException
IOException

query

public char query(UppaalSystem system,
                  String query,
                  QueryFeedback f)
           throws EngineException,
                  IOException
Verify a guery on an instantiated UPPAAL model. Returns 'T' if property is satisfied, 'F' if it is not satisfied, 'M' if it is maybe satisfied, and 'E' if an error occurred. Progress feedback and traces are provided via the feedback object. The stub must be connected and the system must be the last one uploaded to the server.

Throws:
EngineException
IOException

query

public char query(UppaalSystem system,
                  SystemState state,
                  String query,
                  QueryFeedback f)
           throws EngineException,
                  IOException
Verify a guery on an instantiated UPPAAL model with custom initial state. Returns 'T' if property is satisfied, 'F' if it is not satisfied, 'M' if it is maybe satisfied, and 'E' if an error occurred. Progress feedback and traces are provided via the feedback object. The stub must be connected and the system must be the last one uploaded to the server.

Throws:
EngineException
IOException


Copyright © 2012 Uppsala University and Aalborg University. All Rights Reserved.