X-Git-Url: https://git.ucc.asn.au/?p=zanchey%2Fdispense2.git;a=blobdiff_plain;f=virtualvend%2Fvvend.py;h=c06970d258ed7b2fc3c19621191d3ac041f80e31;hp=e395589d5ced97dbc946687beb5e3803a195a1af;hb=ab13f294b1ca0956f3793fe475d3793ed0e7a9fa;hpb=169e486b289d757f99a5647fdf290cbe087aebad diff --git a/virtualvend/vvend.py b/virtualvend/vvend.py index e395589..c06970d 100644 --- a/virtualvend/vvend.py +++ b/virtualvend/vvend.py @@ -24,6 +24,18 @@ except: import pango +class Switches: + def __init__(self): + self.misc_input = 0xff + self.switch_input = 0x3f + def door_open(self): + return self.switch_input & 0x20 + def set_door_open(self, open = True): + if open: + self.switch_input |= 0x20 + else: + self.switch_input &= ~0x20 + #now we have both gtk and gtk.glade imported #Also, we know we are running GTK v2 @@ -82,6 +94,7 @@ class appgui: self.vendpw = "AAAAAAAAAAAAAAAA" self.messageid = None + self.switches = Switches() #s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) @@ -117,8 +130,11 @@ class appgui: self.do_send('2'+key+' keypress\n') def door_changed(self, widget): - print 'Door changed to', widget.pressed() - pass + self.switches.set_door_open(not widget.get_active()) + if widget.get_active(): + self.do_send('401 door closed\n') + else: + self.do_send('400 door open\n') def handleNewConnection(self,source,condition): #source is a socket in GTK v 1 and a fd in version 2 @@ -220,6 +236,7 @@ class appgui: gtk.input_remove(tag) conn.close() self.sock.close() + self.sock.shutdown() gtk.mainquit() sys.stdout.write("quit!\n")