コード例 #1
0
def testProcessRetrievedInventory():
	print(sys._getframe().f_code.co_name + ": ")

	dbConnect = DbConnect(InventoryDAO.getDbDir())
	connector = dbConnect.getConnection()

	customerId = 1
	barcode = 1
	quantity = 2

	androidService = AndroidService()
	inventoryReservation = androidService.reserveInventoryIfAvailable(customerId, barcode, quantity)
	print(inventoryReservation) # (True, reservedInventoryLoc, newVirtualCartRowId)


	arduinoService = ArduinoService()
	print( arduinoService.processRetrievedInventory(1, 1) )

	inventoryDAO = InventoryDAO(connector)
	print( inventoryDAO.selectAllEntries() )

	virtualCartDAO = VirtualCartDAO(connector)
	print( virtualCartDAO.selectAllEntries() )

	print("===================================================")
	print("Testing testProcessRetrievedInventory-------------------complete\n\n\n")
コード例 #2
0
def testGetLocationBoxAbove():
	print(sys._getframe().f_code.co_name + ": ")

	dbConnect = DbConnect(InventoryDAO.getDbDir())
	connector = dbConnect.getConnection()

	arduinoService = ArduinoService()

	print(arduinoService.getLocationBoxAbove(1))

	print("===================================================")
	print("Testing testGetLocationBoxAbove-------------------complete\n\n\n")
コード例 #3
0
def testGetDepositLocation():
	print(sys._getframe().f_code.co_name + ": ")

	dbConnect = DbConnect(InventoryDAO.getDbDir())
	connector = dbConnect.getConnection()

	arduinoService = ArduinoService()

	print(arduinoService.getDepositLocation())

	print("===================================================")
	print("Testing testProcessRetrievedInventory-------------------complete\n\n\n")
コード例 #4
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)
コード例 #5
0
def testDepositInventory():
	print(sys._getframe().f_code.co_name + ": ")

	dbConnect = DbConnect(InventoryDAO.getDbDir())
	connector = dbConnect.getConnection()

	arduinoService = ArduinoService()

	[newXIdx, newYIdx, newXEncoder, newYEncoder] = arduinoService.getDepositLocation()
	print([newXIdx, newYIdx, newXEncoder, newYEncoder])

	arduinoService.depositInventory(5, newXIdx, newYIdx, newXEncoder, newYEncoder)

	inventoryDAO = InventoryDAO(connector)
	print(inventoryDAO.selectAllEntries())

	print("===================================================")
	print("Testing testDepositInventory-------------------complete\n\n\n")
コード例 #6
0
ファイル: AdminTask.py プロジェクト: RetailXP/3.14Modules
	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)
コード例 #7
0
ファイル: ArduinoComm.py プロジェクト: RetailXP/3.14Modules
	def run(self):
		print("ArduinoComm::Starting")


		# wait for initialization
		time.sleep(5)

		while True:

			## sending a message to Arduino
			while self.msgQueue.empty():
				time.sleep(1)	# poll the queue every 1 second
				
			# [ MessageFormat.retInv
			# (True, 
			#  [inventoryDetailsId, barcodeDetailsFk, X_index, Y_index, X_encoder, Y_encoder, checkoutFlag],
			#  newVirtualCartRowId)
			# ]

			# [ MessageFormat.depInv, barcode ]

			msgQueue = self.msgQueue.get()
			msgType = msgQueue[0]
			txMsg = None
			encodedMsg = None

			if msgType == MessageFormat.retInv:
				reservedInventoryLoc = msgQueue[1][1]
				virtCartRowId = msgQueue[1][2]

				txMsg = RetInvP2A()
				txMsg.invInfoRowId = reservedInventoryLoc[0]
				txMsg.virtCartId = virtCartRowId
				txMsg.x_idx = reservedInventoryLoc[1]
				txMsg.y_idx = reservedInventoryLoc[2]
				txMsg.x_enc = reservedInventoryLoc[3]
				txMsg.y_enc = reservedInventoryLoc[4]
				txMsg.x_encAbove = reservedInventoryLoc[5]
				txMsg.y_encAbove = reservedInventoryLoc[6]

				self.msgInProcess = [MessageFormat.retInv, txMsg]

			elif msgType == MessageFormat.depInv:
				barcode = msgQueue[1]

				robotService = ArduinoService()
				[x_idx, y_idx, x_enc, y_enc] = robotService.getDepositLocation()

				txMsg = DepoInvP2A()
				txMsg.barcode = barcode
				txMsg.x_enc = x_enc
				txMsg.y_enc = y_enc

				self.msgInProcess = [MessageFormat.depInv, (barcode, x_idx, y_idx, x_enc, y_enc)]


			try:
				encodedMsg = txMsg.encode()
			except CorruptData as details:
				print(details)

			for byte in encodedMsg:
				print("writing: " + str(hex(byte)))
				self.__ser.write(bytes([byte]))


			## receiving message from arduino
			print("start receiving messages")


			msgParser = MessageParser()

			isCompleteMsg = False
			while not isCompleteMsg:
				msgByte = self.__ser.read(1)		# blocking i/o with infinite timeout
				parseResult = msgParser.parseMsg((int.from_bytes(msgByte, byteorder='big', signed=False)))
				isCompleteMsg = parseResult[0]

				print("parsing Msgs: " + str(hex(int.from_bytes(msgByte, byteorder='big', signed=False) ) ) )

			parseResult = msgParser.getRetVal()		# [True, msgType, msgContent]

			msgType = parseResult[1]
			msgContent = parseResult[2]

			try:
				robotService = ArduinoService()

				if msgType == MessageFormat.retInv:
					msg = RetInvA2P()
					msg.decode(msgContent)
					robotService.processRetrievedInventory(msg.invInfoRowId, msg.virtCartId)

				elif msgType == MessageFormat.depInv:
					msg = DepoInvA2P()
					msg.decode(msgContent)
					#(barcode, x_index, y_index, x_encoder, y_encoder):
					txMsgContent = self.msgInProcess[1]
					robotService.depositInventory(txMsgContent[0],
											      txMsgContent[1],
											      txMsgContent[2],
											      txMsgContent[3],
											      txMsgContent[4])

				elif msgType == MessageFormat.homeRobot:
					msg = HomeRobotA2P()
					msg.decode(msgContent)

				elif msgType == MessageFormat.movRobot:
					msg = MovPosA2P()
					msg.decode(msgContent)

			except CorruptData as details:
				print(details)
コード例 #8
0
import sys

from ArduinoSerialInterface import ArduinoSerialInterface
from Service.AndroidService import AndroidService
from Service.ArduinoService import ArduinoService
from Service.DbConnect import DbConnect

def testRetrieval():

	tabletService = AndroidService()
	# invLoc = [inventoryDetailsId, X_index, Y_index, X_encoder, Y_encoder]
	[isAvailable, invLoc, vCartRowID] = tabletService.reserveInventoryIfAvailable(self, 1, 1, 1)


	arduinoComm = ArduinoSerialInterface()
	msg = "P>A"
	for data in invLoc:
		msg = msg + " " + str(data)

	print("msg: " + msg)

	arduinoComm.serialWrite(message)

	while (robotMsg = arduinoComm.serialRead()) == "":
		pass

	print(robotMsg)

	robotService = ArduinoService()
	robotService.processRetrievedInventory()