コード例 #1
0
ファイル: AdminTask.py プロジェクト: RetailXP/3.14Modules
class AdminTask(threading.Thread):

	def __init__(self):
		threading.Thread.__init__(self)

		self.tabletComm = TCPServlet()
		self.tabletComm.start()
		self.robotComm = ArduinoComm("/dev/ttyACM0", 9600)
		self.msgQueue = queue.Queue(0)  # infinite queue size

		self.start()

	def getMsgFromTablet(self):
		print("AdminTask::getMsgFromTablet")
		tabletQueue = self.tabletComm.getMsgQueue()
		while not tabletQueue.empty():
			self.msgQueue.put(tabletQueue.get())

	def enqueueToRobot(self):
		print("AdminTask::enqueueToRobot")
		while not self.msgQueue.empty():
			msg = self.msgQueue.get()

			if msg[0] == MessageFormat.retInv:
				for info in msg[1][1]:
					robotService = ArduinoService()
					encAbove = robotService.getLocationBoxAbove(info[0])
					aQueue = queue.Queue(0)
					aQueue.put([MessageFormat.retInv, (msg[0], list(info)+encAbove, msg[1][2]) ])

					self.robotComm.enqueue(aQueue)

			# [MessageFormat.depInv, barcode]
			elif msg[0] == MessageFormat.depInv:
				aQueue = queue.Queue(0)
				aQueue.put(msg)

				self.robotComm.enqueue(aQueue)

	def run(self):
		print("AdminTask::run")

		while True:
			
			if self.tabletComm.getMsgQueue().empty():
				time.sleep(1)		# poll tablet msgQueue every 1 second
				continue

			self.getMsgFromTablet()
			self.enqueueToRobot()
コード例 #2
0
ファイル: AdminTask.py プロジェクト: RetailXP/3.14Modules
	def __init__(self):
		threading.Thread.__init__(self)

		self.tabletComm = TCPServlet()
		self.tabletComm.start()
		self.robotComm = ArduinoComm("/dev/ttyACM0", 9600)
		self.msgQueue = queue.Queue(0)  # infinite queue size

		self.start()
コード例 #3
0
def main():

	tabletService = AndroidService()

	# (True, [inventoryDetailsId, X_index, Y_index, X_encoder, Y_encoder]..., newVirtualCartRowId)
	reservationInfo1 = tabletService.reserveInventoryIfAvailable(1, 1, 1)
	reservationInfo2 = tabletService.reserveInventoryIfAvailable(1, 2, 1)
	depositInfo1 = (MessageFormat.depInv, 1)
	depositInfo2 = (MessageFormat.depInv, 2)

	print(reservationInfo1)
	print(reservationInfo2)


	aQueue = queue.Queue(maxsize=0)

	arduinoComm = ArduinoComm("/dev/ttyACM0", baudrate=9600, timeout=None)


	# [ MessageFormat.retInv
	#  (True, 
	#  [inventoryDetailsId, barcodeDetailsFk, X_index, Y_index, X_encoder, Y_encoder, checkoutFlag],
	#  newVirtualCartRowId)
	# ]

	robotService = ArduinoService()
	
	for info in reservationInfo1[1]:
		encAbove = robotService.getLocationBoxAbove(info[0])

		aQueue.put([MessageFormat.retInv, (reservationInfo1[0], list(info)+encAbove, reservationInfo1[2])])
	arduinoComm.enqueue(aQueue)

	time.sleep(5)

	for info in reservationInfo2[1]:
		encAbove = robotService.getLocationBoxAbove(info[0])
		aQueue.put([MessageFormat.retInv, (reservationInfo2[0], list(info)+encAbove, reservationInfo2[2]) ])
	arduinoComm.enqueue(aQueue)

	time.sleep(5)

	aQueue.put(depositInfo1)
	arduinoComm.enqueue(aQueue)

	time.sleep(5)

	aQueue.put(depositInfo2)
	arduinoComm.enqueue(aQueue)