Exemple #1
0
 def testConnection(self):
     try:
         self.stub.testConnection(vrpAPI_pb2.Empty())
         return True
     except grpc.RpcError as e:
         self.handleGrpcError(e, 'Error when testing the connection')
         return False
Exemple #2
0
 def isReadyForOnline(self):
     try:
         response = self.stub.isReadyForOnline(vrpAPI_pb2.Empty())
         return response.b
     except grpc.RpcError as e:
         self.handleGrpcError(
             e, 'Error with function isReadyForOnline() from simulatorAPI')
Exemple #3
0
 def startOnlineSimulation(self):
     try:
         reply = self.stub.startOnlineSimulation(vrpAPI_pb2.Empty())
         return reply.value
     except grpc.RpcError as e:
         self.handleGrpcError(
             e, 'Error when sending startSimulation to solver')
Exemple #4
0
 def sendContinueMessage(self):
     try:
         reply = self.stub.continueSimulation(vrpAPI_pb2.Empty())
         return reply.value
     except grpc.RpcError as e:
         self.handleGrpcError(
             e, 'Error when sending continueMessage to solver')
 def run(self):
     try:
         reply = self.stub.pauseSimulation(vrpAPI_pb2.Empty()) #, timeout = 2)
         self.pauseMessageQueue.put(("OK", reply.value))
     except grpc.RpcError as e:
         self.handleGrpcError(e, '')
         if e.details() == "Deadline Exceeded":
             # the solver didn't answers
             self.pauseMessageQueue.put(("KO", None)) 
         else:
             print("Error when sending pauseMessage to solver")
             print(e.details())
Exemple #6
0
    def sendBestSolution(self, request, context):
        # correct the instance returned by the initial solver of michael
        # solverSol = json.loads(request.jsonstring)
        # for road in solverSol['Routes']:
        #     for node in solverSol['Routes'][road]:
        #         if 'InstanceVertexID' in node:
        #             node['RequestId'] = node['InstanceVertexID']
        #             del(node['InstanceVertexID'])
        #         if 'RequestInstanceId' in node:
        #             node['Node'] = node['RequestInstanceId']
        #             del(node['RequestInstanceId'])

        # send the sol to SimulationManager
        self.solutionsQueue.put(('updateBestSolution', request.jsonstring))
        #self.solutionsQueue.put(('updateBestSolution', json.dumps(solverSol)))
        self.eventLock.acquire()
        self.eventSMQueue.set()
        self.eventLock.release()
        return vrpAPI_pb2.Empty()
Exemple #7
0
 def testConnection(self, request, context):
     return vrpAPI_pb2.Empty()
Exemple #8
0
 def notifyEndOnline(self, request, context):
     self.eventLock.acquire()
     self.solutionsQueue.put(("SolverEndOnline", ))
     self.eventSMQueue.set()
     self.eventLock.release()
     return vrpAPI_pb2.Empty()
Exemple #9
0
 def sendCloseMessage(self):
     try:
         self.stub.shutdown(vrpAPI_pb2.Empty())
     except grpc.RpcError as e:
         self.handleGrpcError(e,
                              'Error when sending closeMessage to solver')