diff --git a/Barcode_Reader_Python/.idea/codeStyles/codeStyleConfig.xml b/Barcode_Reader_Python/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/Barcode_Reader_Python/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/Barcode_Reader_Python/.idea/workspace.xml b/Barcode_Reader_Python/.idea/workspace.xml index 3b3af7c..e0aab74 100644 --- a/Barcode_Reader_Python/.idea/workspace.xml +++ b/Barcode_Reader_Python/.idea/workspace.xml @@ -2,9 +2,11 @@ + + + - + - + - + + - + - - + + - + + + + + + - - + + @@ -47,8 +56,17 @@ - - + + + + + + + + + + + @@ -82,6 +100,7 @@ @@ -96,10 +115,10 @@ - @@ -127,7 +146,7 @@ - + - + @@ -274,15 +335,15 @@ - + - + - + @@ -292,27 +353,27 @@ + - - - - + + + + + - - - - + - - - - + + + + + @@ -321,7 +382,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -329,26 +429,43 @@ - + - - + + - + + + + + + + + - - + + + + + + + + + + + + - - + + - + diff --git a/Barcode_Reader_Python/generate_moves.py b/Barcode_Reader_Python/generate_moves.py index 6e05a81..bd6a80d 100644 --- a/Barcode_Reader_Python/generate_moves.py +++ b/Barcode_Reader_Python/generate_moves.py @@ -7,7 +7,7 @@ moved_item_loc = None exp_date = [] shelf_new = [] repeats = 0 - +moves_return = None def backArray(myArray): global shelf_back shelf_back = [] @@ -27,6 +27,7 @@ def place(): global shelf_new global repeats global shelf_back + global moves_return repeats += 1 backArray(exp_date) moved_item = None @@ -52,13 +53,16 @@ def place(): print " Moved item {0} to location {1}. Location {2} is now empty!".format(moved_item, empty_loc + 1, moved_item_loc + 1) - print "============================================================================" + print "=============================================================================" + moves_return.append(str(moved_item_loc + 1)) + moves_return.append(str(empty_loc + 1)) else: print " Leaving item {0} in location {1}. Location {2} is still empty!".format(moved_item, moved_item_loc + 1, empty_loc + 1) print "============================================================================" correct_locs.append(moved_item_loc) + place() else: return @@ -68,6 +72,9 @@ def generate(dates,date_cur): global exp_date global shelf_new global repeats + global moves_return + shelf_new = [] + moves_return = [] exp_date = sort_date. calcDate(dates,date_cur) shelf_back = exp_date[:] try: @@ -103,8 +110,8 @@ def generate(dates,date_cur): print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n' print "============================================================================" exp_date[i] = None - - + moves_return.append(str(i + 1)) + moves_return.append(str(len(exp_date))) else: break place() @@ -113,6 +120,13 @@ def generate(dates,date_cur): print('***********************************************************************************') print(' The last {} items have expired, throwing them away.'.format(len(exp_date)-shelf_new.index(-1)-1)) print('***********************************************************************************') + for i in range(len(shelf_new)-1,len(shelf_new)-shelf_new.index(-1),-1): + print "aaa" + moves_return.append(str(i)) + moves_return.append("0") + except ValueError: print(" No items have expired") - print('***********************************************************************************') \ No newline at end of file + print('***********************************************************************************') + + return moves_return \ No newline at end of file diff --git a/Barcode_Reader_Python/generate_moves.pyc b/Barcode_Reader_Python/generate_moves.pyc index bc54bc8..bdb4a22 100644 Binary files a/Barcode_Reader_Python/generate_moves.pyc and b/Barcode_Reader_Python/generate_moves.pyc differ diff --git a/Barcode_Reader_Python/main.py b/Barcode_Reader_Python/main.py index f01d2a2..5f91c4b 100755 --- a/Barcode_Reader_Python/main.py +++ b/Barcode_Reader_Python/main.py @@ -1,4 +1,3 @@ -# import the necessary packages from imutils.video import VideoStream from pyzbar import pyzbar import imutils @@ -7,9 +6,26 @@ import cv2 import database_actions import datetime import generate_moves +import serial + +arduino = serial.Serial('/dev/ttyACM0', 115200, timeout=.1) + +def move(locations): + reps = 0 + for i in range(0,len(locations),2): + arduino.write(locations[i]) + while(arduino.read() == '\x00'): + continue + + arduino.write(locations[i+1]) + while(arduino.read() == '\x00'): + continue + + + -# initialize the video stream and allow the camera sensor to warm up print("[INFO] starting video stream...") + def dateStr(): date_cur = "" if len(str(datetime.date.today().day)) == 1: @@ -22,7 +38,6 @@ def dateStr(): date_cur = date_cur + str(datetime.date.today().month) + "." date_cur += str(datetime.date.today().year) return date_cur -# vs = VideoStream(src=0).start() vs = VideoStream().start() time.sleep(2.0) dates = [] @@ -32,10 +47,8 @@ prevcode = None exp_date = [] current_date = dateStr() -print current_date -# loop over the frames from the video stream while reps<1: - # grab the frame from the threaded video stream and resize it to + try: while (barcodes == None or barcodes == []): frame = vs.read() @@ -61,6 +74,7 @@ while reps<1: print("[INFO] Found {} barcode: {}".format(barcodeType, barcodeData)) dates.append(database_actions.getDate(barcodeData)) reps += 1 + arduino.write("1") prevcode = barcodeData barcodes = None @@ -69,10 +83,10 @@ while reps<1: break except KeyboardInterrupt: break -# close the output CSV file do a bit of cleanup + print("[INFO] cleaning up...") print dates -generate_moves.generate(dates,current_date) +print generate_moves.generate(dates,current_date) cv2.destroyAllWindows() vs.stop() \ No newline at end of file diff --git a/Barcode_Reader_Python/move.py b/Barcode_Reader_Python/move.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Barcode_Reader_Python/move.py @@ -0,0 +1 @@ +