Anonymous

Changes

From Pumping Station One
2,401 bytes added ,  04:12, 12 January 2015
no edit summary
Line 5: Line 5:     
Things bus is a an agreement on how devices in the space communicate to facilitate hacking and extension.
 
Things bus is a an agreement on how devices in the space communicate to facilitate hacking and extension.
 +
 +
== Node Types ==
 +
 +
There are 3 basic node types in things bus:
 +
 +
* Sensors.  Sensors produce data
 +
* Actuators.  Data Sinks consume data, and probably do something interesting with it.
 +
* Neurons.  Neurons take in sensory data, manipulate it in some way, and send the data to actuators.
 +
 +
 +
=== Sensors ===
 +
 +
A simple of an example of a sensor would be a temperature sense in the space.  A temperature sensor would be a Raspberry Pi hooked into a temperature sense, and would send out the current temperature every 5 minutes.
 +
 +
Sensors make data available by using a zmq bind PUB socket.
 +
 +
=== Actuators ===
 +
 +
An Actuator is something that, when triggered, does something.  It doesn't have to be physical.  An actuator could be as simple as an led wired into a Raspberry Pi that can be triggered by a Neuron.
 +
 +
Actuators consume data by using a zmq bind PULL socket
 +
 +
=== Neurons ===
 +
 +
Nuerons communicate between sensors and actuators, and decide what effect, if any, sensory input should have on actuators.
 +
 +
There can be more complex arrangements, Neurons are free to communicate with other neurons, and can trigger actuators without sensory input, and can read sensor data without actually forwarding it to an actuator.
 +
 +
Neurons consume information around by using zmq connect SUB sockets to sensors
 +
Nuerons send information to actualtors by using zmq connect PUSH sockets to actuators.
 +
 +
=== Mixed mode/Multi mode nodes ===
 +
 +
A given node on the things bus is likely to be of more than one type, and may exist just to proxy information around, or analyze data and have it be re-emmited as a new type of sensor.
 +
 +
 +
== A simple example ==
 +
 +
The following is an example of a Nueron.  It connects to sensory input, the hackerpspace's front and back doors, and sense data to an actuator, zirc, an actuator that writes data to #pumpingstationone on irc.freenode.net
 +
 +
    #!/usr/bin/env python
 +
    import zmq
 +
   
 +
    context = zmq.Context.instance()
 +
    door_socket = context.socket(zmq.SUB)
 +
    door_socket.connect("tcp://frontdoor.pumpingstationone.org:5556")
 +
    door_socket.connect("tcp://backdoor.pumpingstationone.org:5556")
 +
    door_socket.setsockopt(zmq.SUBSCRIBE, b"door.state.unlock")
 +
 +
    zirc_socket = context.socket(zmq.PUSH)
 +
    zirc_socket.connect('tcp://sally.ad.pumpingstationone.org:5558')
 +
    while True:
 +
        topic, message = socket.recv_multipart()
 +
    print(message)
 +
    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.