Anonymous

Changes

From Pumping Station One
233 bytes added ,  04:15, 12 January 2015
Line 47: Line 47:  
     #!/usr/bin/env python
 
     #!/usr/bin/env python
 
     import zmq
 
     import zmq
   
+
   
 +
   
 
     context = zmq.Context.instance()
 
     context = zmq.Context.instance()
 +
 +
    # Create a zmq socket that will SUBscribe to door nodes.
 
     door_socket = context.socket(zmq.SUB)
 
     door_socket = context.socket(zmq.SUB)
 
     door_socket.connect("tcp://frontdoor.pumpingstationone.org:5556")
 
     door_socket.connect("tcp://frontdoor.pumpingstationone.org:5556")
Line 54: Line 57:  
     door_socket.setsockopt(zmq.SUBSCRIBE, b"door.state.unlock")
 
     door_socket.setsockopt(zmq.SUBSCRIBE, b"door.state.unlock")
 
   
 
   
 +
    # create a zmq socket that will PUSH data to our IRC actuator node.
 
     zirc_socket = context.socket(zmq.PUSH)
 
     zirc_socket = context.socket(zmq.PUSH)
 
     zirc_socket.connect('tcp://sally.ad.pumpingstationone.org:5558')
 
     zirc_socket.connect('tcp://sally.ad.pumpingstationone.org:5558')
 +
 +
    # Loop forever
 
     while True:
 
     while True:
        topic, message = socket.recv_multipart()
  −
    print(message)
  −
    zirc.send(message)
      +
        # Read messages from the doors
 +
        topic, message = door_socket.recv_multipart()
 +
 +
        # Send the message to the irc channel
 +
        zirc.send(message)
    
== Alpha Quality: thingsbus python + zeromq system ==
 
== Alpha Quality: thingsbus python + zeromq system ==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.