Esempio n. 1
0
class Acceptor(Thread):
	def __init__(self, main_window):
		Thread.__init__(self)
		self._abort = False
		self.b = BillAcceptor()
		self.start()
		self._main_window = main_window
	def run(self):
		result = []
		stacking = None
		iterator = 0
		start_time = time.time()
		#get inserted amount
		while True:
			status = self.b.run(iterator, stacking)
			if status is not None:
				if(status['status'] == 'IDLE' and time.time() - start_time > 60): #reset GUI after 60 seconds
					wx.PostEvent(self._main_window, ResultEvent({
						'error_code' : 'l1',
						'error_txt' : 'Timeout'
					}) )
					return
				if status['status'] == 'ESCROWED':
					stacking = True
				iterator += 1
				time.sleep(1)
				wx.PostEvent(self._main_window, ResultEvent(GET_INSERTED_AMOUNT_ID, status['total']) )
			if self._abort:
				return
	def abort(self):
		self._abort = True
	#duplicate method, Main class has one as well
	def AsciiToUnicode(self, ascii_text):
		decoded = ascii_text.decode('utf-8')
		unicode(decoded)
		return decoded
Esempio n. 2
0
	def __init__(self, main_window):
		Thread.__init__(self)
		self._abort = False
		self.b = BillAcceptor()
		self.start()
		self._main_window = main_window