From 195aaba8bb774d823e1964d1a048beb5dfbe927e Mon Sep 17 00:00:00 2001
From: Mitchell Pomery <bob_george33@hotmail.com>
Date: Thu, 19 Mar 2015 21:28:34 +0800
Subject: [PATCH 1/5] Rearranged items and made a snack machine

---
 virtualsnack.py | 50 ++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 40 insertions(+), 10 deletions(-)

diff --git a/virtualsnack.py b/virtualsnack.py
index 9010b27..7275349 100755
--- a/virtualsnack.py
+++ b/virtualsnack.py
@@ -1,4 +1,6 @@
 #!/usr/bin/env python
+# coding: latin-1
+
 import npyscreen
 from datetime import datetime
 
@@ -71,15 +73,15 @@ class VirtualSnack(npyscreen.Form):
 	self.door = self.add(npyscreen.MultiSelect, name = "Door", max_width=15, relx = 4, rely = 12, max_height=4, value = [], values = ["DOOR"], scroll_exit=True, value_changed_callback=self.parentApp.when_door_toggled)
 
         # The DIP switches
-	self.dip = self.add(npyscreen.MultiSelect, name = "DIP Switch", max_width=10, rely =3, relx = 35, max_height=10, value = [], values = ["DIP1", "DIP2", "DIP3","DIP4","DIP5","DIP6","DIP7","DIP8"], scroll_exit=True)
+	self.dip = self.add(npyscreen.MultiSelect, name = "DIP Switch", max_width=10, rely =3, relx = 30, max_height=10, value = [], values = ["DIP1", "DIP2", "DIP3","DIP4","DIP5","DIP6","DIP7","DIP8"], scroll_exit=True)
 
         # The coin buttons
-	self.nickel=self.add(SnackButtonPress,name="0.05", rely= 3, relx=50)
-	self.dime=self.add(SnackButtonPress,name="0.10", relx=50)
-	self.quarter=self.add(SnackButtonPress,name="0.25", relx=50)
-	self.dollar=self.add(SnackButtonPress,name="1.00", relx=50)
+	self.nickel=self.add(SnackButtonPress,name="0.05", rely= 12, relx=33)
+	self.dime=self.add(SnackButtonPress,name="0.10", relx=33)
+	self.quarter=self.add(SnackButtonPress,name="0.25", relx=33)
+	self.dollar=self.add(SnackButtonPress,name="1.00", relx=33)
         # The mode button
-	self.mode=self.add(SnackButtonPress,name="MODE", relx=50)
+	self.mode=self.add(SnackButtonPress,name="MODE", relx=33)
 
         # Space for the current time
         self.date_widget = self.add(npyscreen.FixedText, value=datetime.now().ctime(), editable=False, rely=18)
@@ -91,10 +93,10 @@ class VirtualSnack(npyscreen.Form):
 
         # The Virtual Vending Machine
         for i in range(10):
-                self.add(npyscreen.FixedText, value=str(i), editable=False, relx=62, rely=4+i)
+                self.add(npyscreen.FixedText, value=str(i), editable=False, relx=47, rely=4+i)
         for slx in range(10):
                 self.slots.append([])
-                xpos = 64 + (slx * 2)
+                xpos = 49 + (slx * 2)
                 self.add(npyscreen.FixedText, value=str(slx), editable=False, relx=xpos, rely=3)
                 for sly in range(10):
                         ypos = 4 + sly
@@ -103,7 +105,35 @@ class VirtualSnack(npyscreen.Form):
                         else:
                                 self.slots[slx].append(self.add(npyscreen.FixedText, value="/", editable=False, relx=xpos, rely=ypos))
 
-        self.collectionslot = self.add(npyscreen.FixedText, value="PUSH", editable=False, relx=70, rely=15)
+        self.collectionslot = self.add(npyscreen.FixedText, value=" " * 8 + "PUSH", editable=False, relx=48, rely=15)
+
+        # Draw some fancy things to make it look fancy
+	# All the big things that can be done in bulk
+	# If you ever need to modify this, see http://en.wikipedia.org/wiki/Box-drawing_character
+	self.add(npyscreen.FixedText, value="─"*28, editable=False, relx=46, rely=2)
+        self.add(npyscreen.FixedText, value="─"*24, editable=False, relx=46, rely=14)
+        self.add(npyscreen.FixedText, value="─"*28, editable=False, relx=46, rely=16)
+	for i in range(3, 18):
+	    for j in [45, 74]:
+                self.add(npyscreen.FixedText, value="│", editable=False, relx=j, rely=i)
+	for i in range(3, 16):
+            self.add(npyscreen.FixedText, value="│", editable=False, relx=69, rely=i)
+	# All the fine details
+	self.add(npyscreen.FixedText, value="┌", editable=False, relx=45, rely=2)
+	self.add(npyscreen.FixedText, value="┐", editable=False, relx=74, rely=2)
+        self.add(npyscreen.FixedText, value="┬", editable=False, relx=69, rely=2)
+        self.add(npyscreen.FixedText, value="┴", editable=False, relx=69, rely=16)
+        self.add(npyscreen.FixedText, value="├", editable=False, relx=45, rely=14)
+        self.add(npyscreen.FixedText, value="├", editable=False, relx=45, rely=16)
+        self.add(npyscreen.FixedText, value="┤", editable=False, relx=69, rely=14)
+        self.add(npyscreen.FixedText, value="┤", editable=False, relx=74, rely=16)
+        self.add(npyscreen.FixedText, value="└─┘", editable=False, relx=45, rely=18)
+        self.add(npyscreen.FixedText, value="└─┘", editable=False, relx=72, rely=18)
+        self.add(npyscreen.FixedText, value="│", editable=False, relx=47, rely=17)
+        self.add(npyscreen.FixedText, value="│", editable=False, relx=72, rely=17)
+        self.add(npyscreen.FixedText, value="┬", editable=False, relx=47, rely=16)
+        self.add(npyscreen.FixedText, value="┬", editable=False, relx=72, rely=16)
+
 
         # Ctrl + Q exits the application
 	self.add_handlers({"^Q": self.exit_application})
@@ -139,7 +169,7 @@ class VirtualSnackApp(npyscreen.NPSAppManaged):
         self.switches = Switches()
 	self.textdisplay = "*5N4CK0RZ*"
 
-	self.F = self.addForm("MAIN", VirtualSnack, name="Virtual Snack")
+	self.F = self.addForm("MAIN", VirtualSnack, name="Virtual Snack", columns=80, lines=24)
 	
 	# socket code
     	self.CONNECTION_LIST = []    # list of socket clients
-- 
2.0.1


From 3eb8bef4931e465424097ae308b1d855af320a9f Mon Sep 17 00:00:00 2001
From: Mitchell Pomery <bob_george33@hotmail.com>
Date: Thu, 19 Mar 2015 21:31:21 +0800
Subject: [PATCH 2/5] Fixing tabs and spaces

---
 virtualsnack.py | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/virtualsnack.py b/virtualsnack.py
index 7275349..3d13ec4 100755
--- a/virtualsnack.py
+++ b/virtualsnack.py
@@ -108,19 +108,19 @@ class VirtualSnack(npyscreen.Form):
         self.collectionslot = self.add(npyscreen.FixedText, value=" " * 8 + "PUSH", editable=False, relx=48, rely=15)
 
         # Draw some fancy things to make it look fancy
-	# All the big things that can be done in bulk
-	# If you ever need to modify this, see http://en.wikipedia.org/wiki/Box-drawing_character
-	self.add(npyscreen.FixedText, value="─"*28, editable=False, relx=46, rely=2)
+        # All the big things that can be done in bulk
+        # If you ever need to modify this, see http://en.wikipedia.org/wiki/Box-drawing_character
+        self.add(npyscreen.FixedText, value="─"*28, editable=False, relx=46, rely=2)
         self.add(npyscreen.FixedText, value="─"*24, editable=False, relx=46, rely=14)
         self.add(npyscreen.FixedText, value="─"*28, editable=False, relx=46, rely=16)
-	for i in range(3, 18):
-	    for j in [45, 74]:
+        for i in range(3, 18):
+            for j in [45, 74]:
                 self.add(npyscreen.FixedText, value="│", editable=False, relx=j, rely=i)
-	for i in range(3, 16):
+        for i in range(3, 16):
             self.add(npyscreen.FixedText, value="│", editable=False, relx=69, rely=i)
-	# All the fine details
-	self.add(npyscreen.FixedText, value="┌", editable=False, relx=45, rely=2)
-	self.add(npyscreen.FixedText, value="┐", editable=False, relx=74, rely=2)
+        # All the fine details
+        self.add(npyscreen.FixedText, value="┌", editable=False, relx=45, rely=2)
+        self.add(npyscreen.FixedText, value="┐", editable=False, relx=74, rely=2)
         self.add(npyscreen.FixedText, value="┬", editable=False, relx=69, rely=2)
         self.add(npyscreen.FixedText, value="┴", editable=False, relx=69, rely=16)
         self.add(npyscreen.FixedText, value="├", editable=False, relx=45, rely=14)
@@ -136,11 +136,11 @@ class VirtualSnack(npyscreen.Form):
 
 
         # Ctrl + Q exits the application
-	self.add_handlers({"^Q": self.exit_application})
-	self.add_handlers({"^C": self.exit_application})
+        self.add_handlers({"^Q": self.exit_application})
+        self.add_handlers({"^C": self.exit_application})
         
         # Display info about what has been comminucated to and by the vending machine
-	self.sentfield = self.add(npyscreen.TitleText, name = "Sent:", value="", editable=False, rely=20 )
+        self.sentfield = self.add(npyscreen.TitleText, name = "Sent:", value="", editable=False, rely=20 )
         self.receivedfield = self.add(npyscreen.TitleText, name = "Received:", value="", editable=False )
 
     def exit_application(self,name):
-- 
2.0.1


From d35d3785deebbb83d5ff6c582dfd908f26dfd625 Mon Sep 17 00:00:00 2001
From: Mitchell Pomery <bob_george33@hotmail.com>
Date: Thu, 19 Mar 2015 21:37:01 +0800
Subject: [PATCH 3/5] Added mini display. Currenlty does nothing

---
 virtualsnack.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/virtualsnack.py b/virtualsnack.py
index 3d13ec4..b6e4d34 100755
--- a/virtualsnack.py
+++ b/virtualsnack.py
@@ -134,6 +134,8 @@ class VirtualSnack(npyscreen.Form):
         self.add(npyscreen.FixedText, value="┬", editable=False, relx=47, rely=16)
         self.add(npyscreen.FixedText, value="┬", editable=False, relx=72, rely=16)
 
+        self.textdisplaymini = self.add(npyscreen.FixedText, value="██", editable=False, relx=71, rely=5)
+        self.textdisplaymini.important = True
 
         # Ctrl + Q exits the application
         self.add_handlers({"^Q": self.exit_application})
-- 
2.0.1


From 95c82f104732b8ff32b1b02f1b03f02de73dcf5e Mon Sep 17 00:00:00 2001
From: Mitchell Pomery <bob_george33@hotmail.com>
Date: Fri, 20 Mar 2015 23:02:48 +0800
Subject: [PATCH 4/5] Adding Thunk notification and fixing secket error

---
 virtualsnack.py | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/virtualsnack.py b/virtualsnack.py
index b6e4d34..ab88673 100755
--- a/virtualsnack.py
+++ b/virtualsnack.py
@@ -105,36 +105,37 @@ class VirtualSnack(npyscreen.Form):
                         else:
                                 self.slots[slx].append(self.add(npyscreen.FixedText, value="/", editable=False, relx=xpos, rely=ypos))
 
-        self.collectionslot = self.add(npyscreen.FixedText, value=" " * 8 + "PUSH", editable=False, relx=48, rely=15)
+        self.collectionslot = self.add(npyscreen.FixedText, value="  PUSH", editable=False, relx=54, rely=15)
 
         # Draw some fancy things to make it look fancy
         # All the big things that can be done in bulk
         # If you ever need to modify this, see http://en.wikipedia.org/wiki/Box-drawing_character
         self.add(npyscreen.FixedText, value="─"*28, editable=False, relx=46, rely=2)
         self.add(npyscreen.FixedText, value="─"*24, editable=False, relx=46, rely=14)
-        self.add(npyscreen.FixedText, value="─"*28, editable=False, relx=46, rely=16)
-        for i in range(3, 18):
+        self.add(npyscreen.FixedText, value="─"*24, editable=False, relx=46, rely=16)
+        self.add(npyscreen.FixedText, value="─"*28, editable=False, relx=46, rely=18)
+        for i in range(3, 19):
             for j in [45, 74]:
                 self.add(npyscreen.FixedText, value="│", editable=False, relx=j, rely=i)
-        for i in range(3, 16):
+        for i in range(3, 18):
             self.add(npyscreen.FixedText, value="│", editable=False, relx=69, rely=i)
         # All the fine details
         self.add(npyscreen.FixedText, value="┌", editable=False, relx=45, rely=2)
         self.add(npyscreen.FixedText, value="┐", editable=False, relx=74, rely=2)
         self.add(npyscreen.FixedText, value="┬", editable=False, relx=69, rely=2)
-        self.add(npyscreen.FixedText, value="┴", editable=False, relx=69, rely=16)
+        self.add(npyscreen.FixedText, value="┴", editable=False, relx=69, rely=18)
         self.add(npyscreen.FixedText, value="├", editable=False, relx=45, rely=14)
         self.add(npyscreen.FixedText, value="├", editable=False, relx=45, rely=16)
+        self.add(npyscreen.FixedText, value="├", editable=False, relx=45, rely=18)
         self.add(npyscreen.FixedText, value="┤", editable=False, relx=69, rely=14)
-        self.add(npyscreen.FixedText, value="┤", editable=False, relx=74, rely=16)
-        self.add(npyscreen.FixedText, value="└─┘", editable=False, relx=45, rely=18)
-        self.add(npyscreen.FixedText, value="└─┘", editable=False, relx=72, rely=18)
-        self.add(npyscreen.FixedText, value="│", editable=False, relx=47, rely=17)
-        self.add(npyscreen.FixedText, value="│", editable=False, relx=72, rely=17)
-        self.add(npyscreen.FixedText, value="┬", editable=False, relx=47, rely=16)
-        self.add(npyscreen.FixedText, value="┬", editable=False, relx=72, rely=16)
-
-        self.textdisplaymini = self.add(npyscreen.FixedText, value="██", editable=False, relx=71, rely=5)
+        self.add(npyscreen.FixedText, value="┤", editable=False, relx=69, rely=16)
+        self.add(npyscreen.FixedText, value="┤", editable=False, relx=74, rely=18)
+	self.add(npyscreen.FixedText, value="└─┘", editable=False, relx=45, rely=19)
+	self.add(npyscreen.FixedText, value="└─┘", editable=False, relx=72, rely=19)
+        self.add(npyscreen.FixedText, value="┬", editable=False, relx=47, rely=18)
+        self.add(npyscreen.FixedText, value="┬", editable=False, relx=72, rely=18)
+
+        self.textdisplaymini = self.add(npyscreen.FixedText, value="████", editable=False, relx=70, rely=5)
         self.textdisplaymini.important = True
 
         # Ctrl + Q exits the application
@@ -185,7 +186,7 @@ class VirtualSnackApp(npyscreen.NPSAppManaged):
         # Get the list sockets which are ready to be read through select
         try:
 	    read_sockets,write_sockets,error_sockets = select.select(self.CONNECTION_LIST,[],[],0.1)
-	except secket.error as e:
+	except socket.error as e:
 	    self.CONNECTION_LIST = []
 	    self.start_listening()
 
@@ -337,7 +338,12 @@ Mark Tearle, October 2014
             for pos in "-\|/-\|/":
                 self.F.slots[int(command[2])][int(command[1])].value = pos
                 self.F.display()
-                time.sleep(0.5)
+                time.sleep(0.4)
+            self.F.collectionslot.value = "*THUNK*"
+            self.F.display()
+            time.sleep(2)
+            self.F.collectionslot.value = "  PUSH"
+            self.F.display()
             self.do_send("100 Vend successful\n")
 
     def do_display(self,string):
-- 
2.0.1


From 109f26e316940b61d94177a4d0825bc9749904f7 Mon Sep 17 00:00:00 2001
From: Mitchell Pomery <bob_george33@hotmail.com>
Date: Tue, 24 Mar 2015 23:38:03 +0800
Subject: [PATCH 5/5] Minor fixes to the code

---
 virtualsnack.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/virtualsnack.py b/virtualsnack.py
index ab88673..801b501 100755
--- a/virtualsnack.py
+++ b/virtualsnack.py
@@ -73,7 +73,7 @@ class VirtualSnack(npyscreen.Form):
 	self.door = self.add(npyscreen.MultiSelect, name = "Door", max_width=15, relx = 4, rely = 12, max_height=4, value = [], values = ["DOOR"], scroll_exit=True, value_changed_callback=self.parentApp.when_door_toggled)
 
         # The DIP switches
-	self.dip = self.add(npyscreen.MultiSelect, name = "DIP Switch", max_width=10, rely =3, relx = 30, max_height=10, value = [], values = ["DIP1", "DIP2", "DIP3","DIP4","DIP5","DIP6","DIP7","DIP8"], scroll_exit=True)
+	self.dip = self.add(npyscreen.MultiSelect, name = "DIP Switch", max_width=10, rely =3, relx = 30, max_height=8, value = [], values = ["DIP1", "DIP2", "DIP3","DIP4","DIP5","DIP6","DIP7","DIP8"], scroll_exit=True)
 
         # The coin buttons
 	self.nickel=self.add(SnackButtonPress,name="0.05", rely= 12, relx=33)
@@ -92,13 +92,13 @@ class VirtualSnack(npyscreen.Form):
         sloty = 0
 
         # The Virtual Vending Machine
-        for i in range(10):
+        for i in range(1,9):
                 self.add(npyscreen.FixedText, value=str(i), editable=False, relx=47, rely=4+i)
-        for slx in range(10):
+        for slx in range(0,10):
                 self.slots.append([])
                 xpos = 49 + (slx * 2)
                 self.add(npyscreen.FixedText, value=str(slx), editable=False, relx=xpos, rely=3)
-                for sly in range(10):
+                for sly in range(1,9):
                         ypos = 4 + sly
                         if sly == 5:
                                 self.slots[slx].append(None)
-- 
2.0.1

