Package com.uppaal.engine
Class KeyValueProtocol
java.lang.Object
com.uppaal.engine.KeyValueProtocol
- All Implemented Interfaces:
Protocol
public class KeyValueProtocol extends Object implements Protocol
IMPORTANT
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
KeyValueProtocol.Service
-
Constructor Summary
Constructors Constructor Description KeyValueProtocol(InputStream in, OutputStream out)
Constructor -
Method Summary
Modifier and Type Method Description void
close()
Disconnect from the server.protected String
escape(String str)
Escape the string.ConcreteState
getConcreteInitial(UppaalSystem system)
Returns the concrete initial state for the system.ConcreteSuccessor
getConcreteSuccessor(UppaalSystem system, ConcreteState state, SystemEdgeSelect[] edges, BigDecimal currentTime, BigDecimal delay)
Get concrete successor: concrete state and the list of the concrete transitionsGanttChart
getGanttChart(UppaalSystem system, BigDecimal globalTime)
Get gantt chartSystemState
getInitial(UppaalSystem system)
Get the initial of the uppaal systemString
getOptionsInfo()
Returns information about available options.SymbolicState
getSymbolicInitial(UppaalSystem system)
Returns the symbolic initial state for the system.ArrayList<SymbolicTransition>
getTransitions(UppaalSystem system, SymbolicState state)
Returns the list of outgoing transitions for the state.String
getVersion()
Returns the version string of the server.protected String
localiseString(String str)
protected SystemEdgeSelect[]
parseEdges(Properties data, UppaalSystem system, String edges)
Parse edges in the systemprotected SystemLocation[]
parseLocationVector(String property, UppaalSystem system)
Parses location vectorprotected SymbolicState
parseState(Properties data, UppaalSystem system, String locations, String variables, String zone)
Parse the symbolic stateprotected int[]
parseVariableVector(String property, UppaalSystem system)
Parse the variable vectorprotected Polyhedron
parseZone(String property, UppaalSystem system)
Parse the zone of the uppaal systemQueryResult
query(UppaalSystem system, Query query, QueryFeedback f)
Verify a query on an instantiated UPPAAL model.QueryResult
query(UppaalSystem system, SymbolicState state, Query query, QueryFeedback f)
Verify a query on an instantiated UPPAAL model with custom initial state.protected List<String>
readLines()
Read lines until "."-line-terminator, remove (escaping) start-of-line-"."sprotected String
recvBlock(KeyValueProtocol.Service serviceName, boolean allow_progress)
Checks the string of the block from the BufferedReader.protected List<String>
recvLines(KeyValueProtocol.Service serviceName, boolean allow_progress)
Checks serviceName, checks for OK or ERROR (don't use for PROGRESS messages)protected List<Properties>
recvProperties(KeyValueProtocol.Service serviceName)
Recovery all propertiesprotected List<Properties>
recvProperties(KeyValueProtocol.Service serviceName, boolean allow_progress)
Recovery all properties from the allowed progressprotected String
recvString(KeyValueProtocol.Service serviceName)
Checks the imported string from the service objectprotected void
sendMessage(KeyValueProtocol.Service service)
Send the message to the out stream using only the serviceprotected void
sendMessage(KeyValueProtocol.Service service, SymbolicState state)
Send the message to the out stream using the service and symbolic stateprotected void
sendMessage(KeyValueProtocol.Service service, SymbolicState state, String query)
Send the message to the out stream using the service and symbolic stateprotected void
sendMessage(KeyValueProtocol.Service service, String data)
Send the message to the out stream using the service and data stringvoid
setOptions(String options)
Sets server options used for verification.protected void
setProgress(QueryFeedback f, Properties data)
Set the progress: When server sends a progress update on verification status.protected void
setSystemInfo(QueryFeedback f, Properties data)
Set the system information: Before start processing a queryUppaalSystem
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)
Upload the lsc.
-
Constructor Details
-
KeyValueProtocol
Constructor- Parameters:
in
- - The input streamout
- - The output stream
-
-
Method Details
-
close
Description copied from interface:Protocol
Disconnect from the server.- Specified by:
close
in interfaceProtocol
- Throws:
IOException
- engine crash or problem in communication.
-
getInitial
Get the initial of the uppaal system- Parameters:
system
- - The uppaal system- Returns:
- The system state
- Throws:
IOException
- engine crash or problem in communication.EngineException
- problem in the Uppaal engine.
-
parseLocationVector
Parses location vector- Parameters:
property
- - The property string that contains the variable datasystem
- - The uppaal system- Returns:
- locations - The array of the system locations
-
parseVariableVector
Parse the variable vector- Parameters:
property
- - The property string that includes the variablesystem
- - The uppaal system- Returns:
- variables - The list of the system variable
-
parseZone
Parse the zone of the uppaal system- Parameters:
property
- - The property that includes the zone datasystem
- - The uppaal system- Returns:
- zone - The polyhedron object
-
getOptionsInfo
Description copied from interface:Protocol
Returns information about available options. The information is returned as an XML document. The stub must be connected.- Specified by:
getOptionsInfo
in interfaceProtocol
- Returns:
- The options information
- Throws:
EngineException
- problem in the Uppaal engine.IOException
- engine crash or problem in communication.
-
getTransitions
public ArrayList<SymbolicTransition> getTransitions(UppaalSystem system, SymbolicState state) throws EngineException, IOException, CannotEvaluateExceptionDescription copied from interface:Protocol
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.- Specified by:
getTransitions
in interfaceProtocol
- Parameters:
system
- - The uppaal systemstate
- - The symbolic state of the system- Returns:
- The array list of the symbolic transition
- Throws:
EngineException
- error in the server protocol.IOException
- I/O communication error.CannotEvaluateException
- some expression could not be evaluated.
-
parseState
protected SymbolicState parseState(Properties data, UppaalSystem system, String locations, String variables, String zone)Parse the symbolic state- Parameters:
data
- - The set of the propertiessystem
- - The uppaal systemlocations
- - The locations of the systemvariables
- - The variables stringzone
- - The zone of the system- Returns:
- A new symbolic state
-
parseEdges
Parse edges in the system- Parameters:
data
- - The set of the propertiessystem
- - The uppaal systemedges
- - The string includes edges of the system- Returns:
- edgesList - The list of selected edges
-
getVersion
Description copied from interface:Protocol
Returns the version string of the server. The stub must be connected.- Specified by:
getVersion
in interfaceProtocol
- Returns:
- The version
- Throws:
IOException
- engine crash or problem in communication.EngineException
- problem in the Uppaal engine.
-
query
public QueryResult query(UppaalSystem system, Query query, QueryFeedback f) throws EngineException, IOExceptionDescription copied from interface:Protocol
Verify a query 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.- Specified by:
query
in interfaceProtocol
- Parameters:
system
- - The uppaal systemquery
- - The queryf
- - The query feed back- Returns:
- The query verification results
- Throws:
EngineException
- error in the server protocol.IOException
- I/O communication error.
-
query
public QueryResult query(UppaalSystem system, SymbolicState state, Query query, QueryFeedback f) throws EngineException, IOExceptionDescription copied from interface:Protocol
Verify a query 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.- Specified by:
query
in interfaceProtocol
- Parameters:
system
- system model representationstate
- initial symbolic statequery
- the property to check forf
- feedback handler- Returns:
- Throws:
EngineException
IOException
-
setProgress
Set the progress: When server sends a progress update on verification status.- Parameters:
f
- - The feedback from a verifierdata
- - The set of the properties
-
setSystemInfo
Set the system information: Before start processing a query- Parameters:
f
- - The feedback from a verifierdata
- - The set of the properties
-
setOptions
Description copied from interface:Protocol
Sets server options used for verification. The stub must be connected. TODO: Document format.- Specified by:
setOptions
in interfaceProtocol
- Parameters:
options
- - The options string- Throws:
EngineException
- problem in the Uppaal engine.IOException
- engine crash or problem in communication.
-
upload
public UppaalSystem upload(Document document, ArrayList<Problem> problems) throws EngineException, IOExceptionDescription copied from interface:Protocol
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.- Specified by:
upload
in interfaceProtocol
- Parameters:
document
- - The system documentproblems
- - The problem array list- Returns:
- the compiled system representation
- Throws:
EngineException
- error in the server protocol.IOException
- I/O communication error.
-
upload
Description copied from interface:Protocol
Upload the document to the server. If no errors occurred, the instantiated system is returned. Otherwise, null is returned. The stub must be connected.- Specified by:
upload
in interfaceProtocol
- Parameters:
document
- - The system document- Returns:
- The Uppaal system
- Throws:
EngineException
- error in the server protocol.IOException
- I/O communication error.
-
sendMessage
Send the message to the out stream using only the service- Parameters:
service
- - The service object- Throws:
IOException
- engine crashed or communication was disrupted.
-
sendMessage
Send the message to the out stream using the service and data string- Parameters:
service
- - The service objectdata
- - The data string- Throws:
IOException
- engine crashed or communication was disrupted.
-
sendMessage
protected void sendMessage(KeyValueProtocol.Service service, SymbolicState state) throws IOExceptionSend the message to the out stream using the service and symbolic state- Parameters:
service
- - The service objectstate
- - The symbolic state- Throws:
IOException
- engine crash or problem in communication.
-
sendMessage
protected void sendMessage(KeyValueProtocol.Service service, SymbolicState state, String query) throws IOExceptionSend the message to the out stream using the service and symbolic state- Parameters:
service
- - The service objectstate
- - The symbolic state- Throws:
IOException
- engine crash or problem in communication.
-
localiseString
- Parameters:
str
- - The localise string- Returns:
- str - The String
-
recvProperties
protected List<Properties> recvProperties(KeyValueProtocol.Service serviceName) throws IOException, EngineExceptionRecovery all properties- Parameters:
serviceName
- - The service item- Returns:
- The list of the property
- Throws:
IOException
- engine crash or problem in communication.EngineException
- problem in the Uppaal engine.
-
recvProperties
protected List<Properties> recvProperties(KeyValueProtocol.Service serviceName, boolean allow_progress) throws IOException, EngineExceptionRecovery all properties from the allowed progress- Parameters:
serviceName
- - The service objectallow_progress
- - The allowed progress- Returns:
- result - The list of the property
- Throws:
IOException
- engine crash or problem in communication.EngineException
- problem in the Uppaal engine.
-
recvString
protected String recvString(KeyValueProtocol.Service serviceName) throws IOException, EngineExceptionChecks the imported string from the service object- Parameters:
serviceName
- - The service item from the enum of the service- Returns:
- The string
- Throws:
IOException
- engine crash or problem in communication.EngineException
- problem in the Uppaal engine.
-
recvBlock
protected String recvBlock(KeyValueProtocol.Service serviceName, boolean allow_progress) throws IOException, EngineExceptionChecks the string of the block from the BufferedReader.- Parameters:
serviceName
- - The service itemallow_progress
- - The allowed progress- Returns:
- block - The string builder
- Throws:
IOException
- engine crash or problem in communication.EngineException
- problem in the Uppaal engine.
-
recvLines
protected List<String> recvLines(KeyValueProtocol.Service serviceName, boolean allow_progress) throws IOException, EngineExceptionChecks serviceName, checks for OK or ERROR (don't use for PROGRESS messages)- Parameters:
serviceName
- - The service item nameallow_progress
- - The allowed progress- Returns:
- dataLines - The list of the data line
- Throws:
IOException
- engine crash or problem in communication.EngineException
- problem in the Uppaal engine.
-
readLines
Read lines until "."-line-terminator, remove (escaping) start-of-line-"."s- Returns:
- lines - The list of the string
- Throws:
IOException
- engine crash or problem in communication.
-
escape
Escape the string.- Parameters:
str
- - The input data string- Returns:
- result - The string of the string builder
-
uploadLsc
public LscProcess uploadLsc(Document document, ArrayList<Problem> problems) throws EngineException, IOExceptionUpload the lsc.- Specified by:
uploadLsc
in interfaceProtocol
- Parameters:
document
- - The model documentproblems
- - The list of the problems- Returns:
- null
- Throws:
IOException
- engine crash or problem in communication.EngineException
- problem in the Uppaal engine.
-
getGanttChart
public GanttChart getGanttChart(UppaalSystem system, BigDecimal globalTime) throws EngineException, IOExceptionGet gantt chart- Specified by:
getGanttChart
in interfaceProtocol
- Parameters:
system
- - The uppaal systemglobalTime
- - The global time- Returns:
- The list of the gantt chart rows
- Throws:
IOException
- engine crash or problem in communication.EngineException
- problem in the Uppaal engine.
-
getConcreteSuccessor
public ConcreteSuccessor getConcreteSuccessor(UppaalSystem system, ConcreteState state, SystemEdgeSelect[] edges, BigDecimal currentTime, BigDecimal delay) throws EngineException, IOExceptionGet concrete successor: concrete state and the list of the concrete transitions- Specified by:
getConcreteSuccessor
in interfaceProtocol
- Parameters:
system
- - The uppaal systemstate
- - The concrete stateedges
- - The select edges of the systemcurrentTime
- - The current timedelay
- - The dalay time- Returns:
- The concrete successor object
- Throws:
IOException
- engine crash or problem in communication.EngineException
- problem in the Uppaal engine.
-
getConcreteInitial
Description copied from interface:Protocol
Returns the concrete initial state for the system. The stub must be connected and the system must be the last one uploaded to the server.- Specified by:
getConcreteInitial
in interfaceProtocol
- Parameters:
system
- the compiled Uppaal system representation.- Returns:
- initial concrete state
- Throws:
EngineException
- error in the server protocol.IOException
- I/O communication error.
-
getSymbolicInitial
Description copied from interface:Protocol
Returns the symbolic initial state for the system. The stub must be connected and the system must be the last one uploaded to the server.- Specified by:
getSymbolicInitial
in interfaceProtocol
- Parameters:
system
- the compiled Uppaal system representation.- Returns:
- initial symbolic state.
- Throws:
EngineException
- error in the server protocol.IOException
- I/O communication error.
-