Ejemplo n.º 1
0
 def __init__(self, taxiInfo, mapManagerTaxi):
     self.odometer = taxiInfo["odometer"]
     #determine if the taxi have alreay accept a request
     if taxiInfo["destination"] != None:
         self.destination = CabRequest(taxiInfo["destination"],
                                       mapManagerTaxi)
     else:
         self.destination = None
     #initialise locations
     self.loc_now = Location(taxiInfo["loc_now"], mapManagerTaxi)
     self.loc_prior = Location(taxiInfo["loc_prior"], mapManagerTaxi)
Ejemplo n.º 2
0
class Taxi:
	##	The constructor
	#	@param taxiInfo dictinary with the Taxi datas
	#	@param mapManagerTaxi map manager for know vexteces and streets
	def __init__(self, taxiInfo, mapManagerTaxi):
		self.odometer = taxiInfo["odometer"]
		#determine if the taxi have alreay accept a request
		if taxiInfo["destination"] != None:
			self.destination = CabRequest(taxiInfo["destination"], mapManagerTaxi)
		else:
			self.destination = None
		#initialise locations
		self.loc_now = Location(taxiInfo["loc_now"], mapManagerTaxi)
		self.loc_prior = Location(taxiInfo["loc_prior"], mapManagerTaxi)

	##	Return the Taxi list to dictionary format
	def toDictFormat(self):
		#initialise the taxi dictionary
		taxi = {}
		taxi["odometer"] = self.odometer
		#determine if the taxi have alreay accept a request
		if self.destination == None:
			taxi["destination"] = None
		else:
			taxi["destination"] = self.destination.toDictFormat()
		taxi["loc_now"] = self.loc_now.toDictFormat()
		taxi["loc_prior"] = self.loc_prior.toDictFormat()
		return taxi
Ejemplo n.º 3
0
class Taxi:
    ##	The constructor
    #	@param taxiInfo dictinary with the Taxi datas
    #	@param mapManagerTaxi map manager for know vexteces and streets
    def __init__(self, taxiInfo, mapManagerTaxi):
        self.odometer = taxiInfo["odometer"]
        #determine if the taxi have alreay accept a request
        if taxiInfo["destination"] != None:
            self.destination = CabRequest(taxiInfo["destination"],
                                          mapManagerTaxi)
        else:
            self.destination = None
        #initialise locations
        self.loc_now = Location(taxiInfo["loc_now"], mapManagerTaxi)
        self.loc_prior = Location(taxiInfo["loc_prior"], mapManagerTaxi)

    ##	Return the Taxi list to dictionary format
    def toDictFormat(self):
        #initialise the taxi dictionary
        taxi = {}
        taxi["odometer"] = self.odometer
        #determine if the taxi have alreay accept a request
        if self.destination == None:
            taxi["destination"] = None
        else:
            taxi["destination"] = self.destination.toDictFormat()
        taxi["loc_now"] = self.loc_now.toDictFormat()
        taxi["loc_prior"] = self.loc_prior.toDictFormat()
        return taxi
Ejemplo n.º 4
0
	def __init__(self, taxiInfo, mapManagerTaxi):
		self.odometer = taxiInfo["odometer"]
		#determine if the taxi have alreay accept a request
		if taxiInfo["destination"] != None:
			self.destination = CabRequest(taxiInfo["destination"], mapManagerTaxi)
		else:
			self.destination = None
		#initialise locations
		self.loc_now = Location(taxiInfo["loc_now"], mapManagerTaxi)
		self.loc_prior = Location(taxiInfo["loc_prior"], mapManagerTaxi)
Ejemplo n.º 5
0
	def addCabRequest(self, request):
		#take the cab request in the json
		newCabRequest = request["cabRequest"]
		#intance the new cab request
		cabRequest = CabRequest(newCabRequest, self.mapManagerTaxi)
		self.cabRequestList.append(cabRequest)
		print 'New cab request created!'
		# Olivier: Auto broadcast on new cab request
		cabQueueJson = self.toDictFormatCabRequest()
		NetworkWebSocket.server_WEBSOCKET.broadcastAll(cabQueueJson)