コード例 #1
0
 def __init__(self, state, meta=None):
     """Instantiate an Atom to the given state.
     
     state -- any object
     meta -- meta data to attach"""
     super(Atom, self).__init__(meta)
     self._state = AtomicReference(state)
コード例 #2
0
ファイル: server.py プロジェクト: 2emoore4/avatar
DEBUG_NET_COMM = False
DEBUG_ARDUINO_COMM = False
DEBUG_PROCESSOR = True

ARDUINO_WRITE_FREQ = 100  # approximate Hz

# add command line option for port number
define("port", default=8080, help="run on the given port", type=int)

## state variables
# threadsafe queue of received data
data_queue = Queue.Queue(maxsize=0)  # maxsize=0 means unlimited capacity

# threadsafe container with the state to tell the arduino to be.
# see ArduinoState for data format
arduino_state = AtomicReference(
    ArduinoState(pump_power=0, ledR=0, ledG=0, ledB=0))

# data processor (not threadsafe)
# the processor stores persistent data and figures out how
# to turn data received into an output state
processor = Processor(arduino_state)

# a list of known substrings of serial addresses to try to connect to.
# if None, then skip connecting
serial_addr_subs = ["ACM", "usbmodem", "usbserial"]
# serial connection to arduino, could be None if connection fails
arduino_serial = None


# response handler for web sockets
class WebSocketHandler(tornado.websocket.WebSocketHandler):