def __init__(self, myArgs = {}):
		'''
		Create a new instance of the carambot remote sensor. 

		@param	myArgs	arguments for the sensor: host, port, sherpaPort.
		'''

		sherpaPort = '/dev/ttyUSB0'

		if myArgs.has_key('sherpaPort'):
			sherpaPort = myArgs['sherpaPort']

		dummyBot = False
	
		if myArgs.has_key('dummyBot') and myArgs['dummyBot'].lower() == 'true':
			dummyBot = True

		if dummyBot:
			self.robot = DummyBot(sherpaPort, True)
		else:
			self.robot = Robot(sherpaPort, True)
 
		RemoteSensor.__init__(self, args = myArgs)

		self.updateHandler  = self.__updateHandler
		self.messageHandler = self.__messageHandler
    def __init__(self, myArgs={}):
        '''
		Create a new instance of the carambot remote sensor. 

		@param	myArgs	arguments for the sensor: host, port, sherpaPort.
		'''

        sherpaPort = '/dev/ttyUSB0'

        if myArgs.has_key('sherpaPort'):
            sherpaPort = myArgs['sherpaPort']

        dummyBot = False

        if myArgs.has_key('dummyBot') and myArgs['dummyBot'].lower() == 'true':
            dummyBot = True

        if dummyBot:
            self.robot = DummyBot(sherpaPort, True)
        else:
            self.robot = Robot(sherpaPort, True)

        RemoteSensor.__init__(self, args=myArgs)

        self.updateHandler = self.__updateHandler
        self.messageHandler = self.__messageHandler
	def __init__(self, myArgs = {}):
		'''
		Create a new instance of the monitoring remote sensor. 

		@param	myArgs	arguments for the sensor: host and port.
		'''

		RemoteSensor.__init__(self, args = myArgs)
Beispiel #4
0
    def __init__(self, myArgs={}):
        '''
		Create a new instance of the monitoring remote sensor. 

		@param	myArgs	arguments for the sensor: host and port.
		'''

        RemoteSensor.__init__(self, args=myArgs)
	def __init__(self, myArgs = {}):
		'''
		Create a new instance of the monitoring remote sensor. 

		@param	myArgs	arguments for the sensor: host and port.
		'''

		RemoteSensor.__init__(self, args = myArgs)

		self.updateHandler  = self.__updateHandler
		self.messageHandler = self.__messageHandler
Beispiel #6
0
    def __init__(self, myArgs={}):
        '''
		Create a new instance of the monitoring remote sensor. 

		@param	myArgs	arguments for the sensor: host and port.
		'''

        RemoteSensor.__init__(self, args=myArgs)

        self.updateHandler = self.__updateHandler
        self.messageHandler = self.__messageHandler
import logging
import time

from scratch.remotesensor import RemoteSensor 

try:
	# Configure logging for RemoteSensor to show ERROR messages ...
	logging.basicConfig(
		level=logging.ERROR,
		format='%(asctime)s %(levelname)-8s %(message)s',
		datefmt='%m-%d %H:%M',
	)

	# Remote sensor connected to default host/port (localhost:42001)
	rs = RemoteSensor()
	rs.connect()

	# Start receiver thread : this starts receiving messages from Scratch
	rs.start()
	
	# Create new sensor variable 'x', set value to 1. 
	# This will result in a 'sensor-update' message sent to Scratch sensor server
	# which will create the "x" sensor value which the Scratch program can use
	# If you use this as the position of a sprite, the sprite will move across the screen ...
	rs.values.x = 1 

	# Broadcast a message ...
	rs.bcastMsg('go')

	for i in range (10):
Beispiel #8
0
import logging
import time

from scratch.remotesensor import RemoteSensor

try:
    # Configure logging for RemoteSensor to show ERROR messages ...
    logging.basicConfig(
        level=logging.ERROR,
        format='%(asctime)s %(levelname)-8s %(message)s',
        datefmt='%m-%d %H:%M',
    )

    # Remote sensor connected to default host/port (localhost:42001)
    rs = RemoteSensor()
    rs.connect()

    # Start receiver thread : this starts receiving messages from Scratch
    rs.start()

    # Create new sensor variable 'x', set value to 1.
    # This will result in a 'sensor-update' message sent to Scratch sensor server
    # which will create the "x" sensor value which the Scratch program can use
    # If you use this as the position of a sprite, the sprite will move across the screen ...
    rs.values.x = 1

    # Broadcast a message ...
    rs.bcastMsg('go')

    for i in range(10):
'''

import logging

from scratch.remotesensor import RemoteSensor 

try:
	# Configure logging for RemoteSensor to show DEBUG messages ...
	logging.basicConfig(
		level=logging.DEBUG,
		format='%(asctime)s %(levelname)-8s %(message)s',
		datefmt='%m-%d %H:%M',
	)

	# Remote sensor connected to default host/port (localhost:42001)
	rs = RemoteSensor()
	rs.connect()

	# Start receiver thread
	rs.start()
	
	# Create new sensor variable 'a', set value to 1. This will tesult
    # in a 'sensor-update' message sent to Scratch sensor server. 
	rs.values.a = 1 

	# Create an other variable
	rs.values.b = 0.2 

	# An yet an other ...
	rs.values.x = "dynamic sensor-update"
    '''
	Handler called for incoming broadcast messages ... 
	'''
    print("-> received message: %s" % msg)


try:
    # Configure logging for RemoteSensor to show DEBUG messages ...
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s %(levelname)-8s %(message)s',
        datefmt='%m-%d %H:%M',
    )

    # Remote sensor connected to default host/port (localhost:42001)
    rs = RemoteSensor()
    rs.connect()

    # Register callback handler for sensor-updates
    rs.updateHandler = updateHandler

    # Register callback handler for broadcast messages
    rs.messageHandler = messageHandler

    # Start receiver thread
    rs.start()

    raw_input('Press Enter to quit...\n')

except Exception as e:
    print(e)
def messageHandler(t, msg):
	'''
	Handler called for incoming broadcast messages ... 
	'''
	print("-> received message: %s" % msg)

try:
	# Configure logging for RemoteSensor to show DEBUG messages ...
	logging.basicConfig(
		level=logging.DEBUG,
		format='%(asctime)s %(levelname)-8s %(message)s',
		datefmt='%m-%d %H:%M',
	)

	# Remote sensor connected to default host/port (localhost:42001)
	rs = RemoteSensor()
	rs.connect()

	# Register callback handler for sensor-updates
	rs.updateHandler  = updateHandler

	# Register callback handler for broadcast messages
	rs.messageHandler = messageHandler
	
	# Start receiver thread
	rs.start()
	
	raw_input('Press Enter to quit...\n')
	
except Exception as e:
	print(e)