Example #1
0
		sender = DataSender.Sender(SERIAL_DEVICE)
	# Open the serial connection.
	with sender:

		# SendingBuffer has a list of Color objects and encapsulates
		# requisite logic for generating bytes and sending.
		# For simulating, TurtleBuffer subclasses SendingBuffer and
		# draws to the screen using Turtle Graphics as well.
		if DRAW:
			sendingColorBuffer = TurtleBuffer(sender=sender)
		else:
			sendingColorBuffer = SendingBuffer(sender=sender)

		# Put some known colors at the beginning.
		for c in Sequences.GetSentinels():
			sendingColorBuffer.insertAndPop(c)

		for c in colorSequence:
			t = time.time()

			# Insert the next color into one end of the strip (and
			# pop the oldest color from the other end).
			sendingColorBuffer.insertAndPop(c)
			"""
			insertAndPop, see Buffer.py
			Insert the given Color into the beginning (index 0) of the color
			list, and pop a Color from the end (maintaining size).
			"""

			# Send the updated colors to the Arduino.
			sendingColorBuffer.send(data_receiver_color_key="COLOR2")
		# requisite logic for generating bytes and sending.
		# For simulating, TurtleBuffer subclasses SendingBuffer and
		# draws to the screen using Turtle Graphics as well.
		if DRAW:
			sendingColorBuffer = TurtleBuffer(sender=sender)
		else:
			sendingColorBuffer = SendingBuffer(sender=sender)
			sendingColorBuffer1 = SendingBuffer(sender=sender)
			sendingColorBuffer2 = SendingBuffer(sender=sender)
			sendingColorBuffer3 = SendingBuffer(sender=sender)
			sendingColorBuffer4 = SendingBuffer(sender=sender)
			# sendingColorBufferCenter = SendingBufferCenter(sender=sender)

		# Put some known colors at the beginning.
		for c in Sequences.GetSentinels():
			sendingColorBuffer.insertAndPop(c)
			sendingColorBuffer1.insertAndPop(c)

		for c in colorSequence:
			t = time.time()
			# ipdb.set_trace()


			event_queue = eventGenerator.generateEvents()
			for event in event_queue:
				if event.get('type', None) == 'pour':
					# cup_color, light_rod, type
					light_rod = event.get('light_rod', None)

					if event.get('cup_color', None) == "red":
						c = Color(rgb=(0.0, 0.0, 1.0))