Example #1
0
        protected virtual ResponseMessage QueryAndVerify(RequestMessage reqMsg)
        {
            reqMsg.WriteTo(GetOutStream());
            ResponseMessage          respMsg   = new ResponseMessage(inStream);
            List <Command>           commands  = reqMsg.Commands();
            List <ResponseContainer> responses = respMsg.Responses();

            if (commands.Count() > responses.Count())
            {
                throw new TraCIException("not enough responses received");
            }
            for (int i = 0; i < commands.Count(); i++)
            {
                Command           cmd          = commands[i];
                ResponseContainer responsePair = responses[i];
                StatusResponse    statusResp   = responsePair.GetStatus();
                Verify("command and status IDs match", cmd.Id(), statusResp.Id());
                if (statusResp.Result() != Constants.RTYPE_OK)
                {
                    throw new TraCIException("SUMO error for command " + statusResp.Id() + ": " + statusResp.Description());
                }
            }

            return(respMsg);
        }