def __init__(self, view, predictor, workQueue, notifier):
		self.font = pygame.font.Font(None, 36)
		self.predictor = predictor
		self.workQueue = workQueue
		self.notifier = notifier
		self.view = view
		self.hitsList = []
		self.currentHit = None
		self.protocol = RallyProtocol(self.view, self.notifier, self)
class RallyController (ATTController):

	ID = "POINT_SEQUENCE"
	
	hitsList = None
	
	notifier = None	
	workQueue = None
	predictor = None
	font = None
	view = None
	
	currentHit = None

	def __init__(self, view, predictor, workQueue, notifier):
		self.font = pygame.font.Font(None, 36)
		self.predictor = predictor
		self.workQueue = workQueue
		self.notifier = notifier
		self.view = view
		self.hitsList = []
		self.currentHit = None
		self.protocol = RallyProtocol(self.view, self.notifier, self)

	def start(self):
		pass
	
	def render(self):
		
		if self.currentHit <> None:
			(x,y) = self.currentHit['coords']
			hitSide = self.currentHit["side"]
			self.view.drawHit(x, y, hitSide)
		
		#self.view.drawMessage()
		self.view.buildScene()
		#self.renderSerialLog()
		pygame.display.flip()
	
	def renderSerialLog(self):
		
		self.notifier.clearView()
		self.notifier.render()
		
	def renderSummary(self):
		if self.state == 1:
			if len(self.summary) > 0:
				self.view.renderSummary(self.summary)
				
	def process(self, app, event):
		done = False

		if not self.workQueue.empty():
			self.currentHit = self.workQueue.get()
			if self.currentHit <> "":
				self.processHit()

		self.render()
		
		if app.isPressed(pygame.K_ESCAPE):
			self.clearView()
			app.dispatcher.setCurrentController(MenuController.ID)

		return done

	def processHit(self, ):
		(y,x) = self.predictor.predictHit(self.currentHit)
		self.currentHit['coords'] = (x,y)

		self.hitsList.append(self.currentHit)
		
		logReading = "("+"{0:.0f}".format(y)+","+"{0:.0f}".format(x)+") - "+self.currentHit["raw"]
		#print logReading
		self.notifier.push(logReading)
		
		self.protocol.processSate(self.currentHit)