Ejemplo n.º 1
0
    def quit(self) :
	from XML.XMLMessageExternalCommand import XMLMessageExternalCommand

	# Send a set of exit commands to the different agents. First
	# create the message itself.
	parameter = XMLMessageExternalCommand()
	parameter.setParameterValue(XMLMessageExternalCommand.EXIT)
	parameter.createRootNode()

	# Send the message to each agent.
	self.channel.sendString(Router.SENSORARRAY,parameter.xml2Char(False))
	self.channel.sendString(Router.PLANNER,parameter.xml2Char(False))
	self.channel.sendString(Router.COMMANDER,parameter.xml2Char(False))
	
	for definedVacuum in self.vacuumArray :
	    # Send the message to each vacuum
	    self.channel.sendString(Router.VACUUM,parameter.xml2Char(False),definedVacuum.getID())
	    definedVacuum.checkIncomingQueue()  # Make sure the vacuum processes its world queue.
	    
		    
        exit(0) # Say bye bye!
Ejemplo n.º 2
0
    def start(self) :
	# Get the parameters from the inputs in the window.
        N = int(self.NValue.get())
        self.r = float(self.rValue.get())
        self.s = float(self.sValue.get())
        self.v = float(self.vValue.get())
        self.cloudSize = float(self.cloudSizeValue.get())

        self.intializeVariables(self.r,self.s,self.v,self.cloudsize)

	from XML.XMLMessageExternalCommand import XMLMessageExternalCommand
	parameter = XMLMessageExternalCommand()
	parameter.setParameterValue(XMLMessageExternalCommand.RESTART)
	parameter.createRootNode()
        for vacuum in self.vacuumArray:
	    # Turn on each of the vacuums - i.e. reset the vacuum.
	    # print("GraphicalWorld.start - Vacuum: {0}".format(vacuum))
            #vacuum.setWorking(True)
            #vacuum.setStatus(3)
            #vacuum.initializeTime(0.0)
	    self.channel.getRouter().sendString(
		Router.VACUUM,parameter.xml2Char(False),vacuum.getID())

        H = []
        R = []
        self.draw()
        skip = 10;
        for i in range(N) :
            #import time # DEBUG
            #time.sleep(1) # DEBUG
            self.inc()
            #if(i%skip==0) :
	    self.draw()

            H.append(sum(sum(self.A)))
            R.append(sum(self.Moisture>0))

	    #self.printVacuumInfo(i)
	    
        print("Mean of H: {0}".format(mean(H)))