Class Query

Direct Known Subclasses:
CloseQuery, CommandProcessor

public abstract class Query extends Observable
The Class Query.
  • Constructor Details

    • 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 Details

    • 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
      Like doQuery(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:
    • doQuerySingle

      protected ResponseContainer doQuerySingle(Command request) throws IOException
      Like doQuery(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
      Like queryAndVerify(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 resp
      commandID - the command ID
      variable - the variable
      objectID - 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 description
      expected - the expected
      actual - 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 description
      expected - the expected
      actual - 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 description
      expected - the expected
      actual - the actual
      Throws:
      TraCIException.UnexpectedData - the unexpected data
    • getOutStream

      public DataOutputStream getOutStream()
      Gets the out stream.
      Returns:
      the out stream