Package de.tudresden.sumo.util
Class Query
- java.lang.Object
-
- de.tudresden.sumo.util.Observable
-
- de.tudresden.sumo.util.Query
-
- Direct Known Subclasses:
CloseQuery
,CommandProcessor
public abstract class Query extends Observable
The Class Query.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doClose()
Disconnect client from the sumo server.protected ResponseMessage
doQuery(RequestMessage msg)
Sends a request message to SUMO and returns a response message.protected ResponseContainer
doQuerySingle(Command request)
LikedoQuery(RequestMessage)
, but good for one-command/ one-response queries.protected void
doSetOrder(int index)
Set multi-client ordering index.protected void
doSimulationStep(double targetTime)
Do next time step and update subscription results.protected void
fireAndForget(Command request)
fireAndForget function.DataOutputStream
getOutStream()
Gets the out stream.protected ResponseMessage
queryAndVerify(RequestMessage reqMsg)
LikedoQuery(RequestMessage)
; in addition, verifies that all responses are successful and and the statuses match the requests.protected ResponseContainer
queryAndVerifySingle(Command request)
LikequeryAndVerify(RequestMessage)
, but good for one-command/ one-response queries.protected static void
verify(String description, int expected, byte actual)
Verify.protected static void
verify(String description, int expected, short actual)
Verify.protected static void
verify(String description, Object expected, Object actual)
Verify.protected static String
verifyGetVarResponse(Command resp, int commandID, int variable, String objectID)
Verify get var response.-
Methods inherited from class de.tudresden.sumo.util.Observable
addObserver, notifyObservers
-
-
-
-
Constructor Detail
-
Query
public Query(Socket sock) throws IOException
Instantiates a new query.- Parameters:
sock
- the sock- Throws:
IOException
- Signals that an I/O exception has occurred.
-
-
Method Detail
-
doQuery
protected ResponseMessage doQuery(RequestMessage msg) throws IOException
Sends a request message to SUMO and returns a response message.- Parameters:
msg
- the msg- Returns:
- the response message
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
queryAndVerify
protected ResponseMessage queryAndVerify(RequestMessage reqMsg) throws IOException
LikedoQuery(RequestMessage)
; in addition, verifies that all responses are successful and and the statuses match the requests.- Parameters:
reqMsg
- the req msg- Returns:
- the verified response message
- Throws:
IOException
- Signals that an I/O exception has occurred.- See Also:
doQuery(RequestMessage)
-
doQuerySingle
protected ResponseContainer doQuerySingle(Command request) throws IOException
LikedoQuery(RequestMessage)
, but good for one-command/ one-response queries.- Parameters:
request
- the request- Returns:
- the response container
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
doSetOrder
protected void doSetOrder(int index) throws IOException
Set multi-client ordering index.- Parameters:
index
- the index- Throws:
IOException
- Signals that an I/O exception has occurred.
-
doClose
protected void doClose() throws IOException
Disconnect client from the sumo server.- Throws:
IOException
- Signals that an I/O exception has occurred.
-
doSimulationStep
protected void doSimulationStep(double targetTime) throws IOException
Do next time step and update subscription results.- Parameters:
targetTime
- the target time- Throws:
IOException
- Signals that an I/O exception has occurred.
-
queryAndVerifySingle
protected ResponseContainer queryAndVerifySingle(Command request) throws IOException
LikequeryAndVerify(RequestMessage)
, but good for one-command/ one-response queries.- Parameters:
request
- the request- Returns:
- the response container for the specified request
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
fireAndForget
protected void fireAndForget(Command request)
fireAndForget function.- Parameters:
request
- the request
-
verifyGetVarResponse
protected static String verifyGetVarResponse(Command resp, int commandID, int variable, String objectID) throws TraCIException.UnexpectedData
Verify get var response.- Parameters:
resp
- the respcommandID
- the command IDvariable
- the variableobjectID
- the object ID- Returns:
- the string
- Throws:
TraCIException.UnexpectedData
- the unexpected data
-
verify
protected static void verify(String description, Object expected, Object actual) throws TraCIException.UnexpectedData
Verify.- Parameters:
description
- the descriptionexpected
- the expectedactual
- the actual- Throws:
TraCIException.UnexpectedData
- the unexpected data
-
verify
protected static void verify(String description, int expected, short actual) throws TraCIException.UnexpectedData
Verify.- Parameters:
description
- the descriptionexpected
- the expectedactual
- the actual- Throws:
TraCIException.UnexpectedData
- the unexpected data
-
verify
protected static void verify(String description, int expected, byte actual) throws TraCIException.UnexpectedData
Verify.- Parameters:
description
- the descriptionexpected
- the expectedactual
- the actual- Throws:
TraCIException.UnexpectedData
- the unexpected data
-
getOutStream
public DataOutputStream getOutStream()
Gets the out stream.- Returns:
- the out stream
-
-