def get_trace(
     self,
     sid: SimulationID,
     vid: Optional[VehicleID] = None
 ) -> List[Tuple[str, str, int, DataResponse]]:
     """
     Return all the collected data of a single or all participants in a simulation.
     :param sid: The simulation to request all the collected data from.
     :param vid: The vehicle whose collected data has to be returned. If None this method returns all the collected
     data.
     :return: The JSON serialized object representing all the collected data of a simulation or a participant in a
     simulation.
     """
     from drivebuildclient.httpUtil import do_get_request
     import dill as pickle
     args = {"sid": sid.SerializeToString()}
     if vid:
         args["vid"] = vid.SerializeToString()
     response = do_get_request(self.host, self.port, "/stats/trace", args)
     if response.status == 200:
         response_content = b"".join(response.readlines())
         trace_data = pickle.loads(response_content)
         trace = []
         for entry in trace_data:
             sid = SimulationID()
             sid.sid = str(entry[0])
             vid = VehicleID()
             vid.vid = entry[1]
             data = DataResponse()
             data.ParseFromString(entry[3])
             trace.append((sid, vid, entry[2], data))
         return trace
     else:
         AIExchangeService._print_error(response)
         return "The trace could not be retrieved."
Beispiel #2
0
 def _generate_sid() -> SimulationID:
     sid_cursor = _DB_CONNECTION.run_query("""
     INSERT INTO tests VALUES (DEFAULT, NULL, NULL, NULL, NULL, NULL, NULL, NULL) RETURNING sid;
     """)
     if sid_cursor:
         result = sid_cursor.fetchall()
         sid = SimulationID()
         sid.sid = str(result[0][0])
         return sid
     else:
         _logger.error("Generation of sid failed.")
Beispiel #3
0
from AIExchangeService import AIExchangeService
from drivebuildclient.aiExchangeMessages_pb2 import SimulationID, TestResult

if __name__ == "__main__":
    sid = SimulationID()
    sid.sid = "<ID of simulation>"
    result = TestResult()
    result.result = TestResult.Result.FAILED
    AIExchangeService("localhost", 8383).control_sim(sid, result)