当前位置: 首页>>代码示例>>Python>>正文


Python OSCClient.connect方法代码示例

本文整理汇总了Python中OSC.OSCClient.connect方法的典型用法代码示例。如果您正苦于以下问题:Python OSCClient.connect方法的具体用法?Python OSCClient.connect怎么用?Python OSCClient.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OSC.OSCClient的用法示例。


在下文中一共展示了OSCClient.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: oscSender

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
class oscSender(object):

	def __init__(self,port):
		self.client = OSCClient()
		self.client.connect( ("172.16.1.110", port) )
		print "Started server on port : " + str(port)

	def newNode(self,args,BSSID,kind):
		msg = OSCMessage("/new" )
		msg.append(kind.strip())
		msg.append(args)
		msg.append(BSSID.strip()) 
		self.client.send(msg)
		# print "new"

	def updateNode(self,args,BSSID,kind):
		if BSSID == " ":
			return 
		msg =  OSCMessage("/update")
		msg.append(kind.strip())
		msg.append(args)
		msg.append(BSSID.strip()) 
		self.client.send(msg)
		# print "update"

	def removeNode(self,args,BSSID, kind):
		msg =  OSCMessage("/remove")
		msg.append(kind.strip())
		msg.append(args)
		msg.append(BSSID.strip())  
		self.client.send(msg)

	def closeConnection(self):
		self.client.send( OSCMessage("/quit", args ) )
开发者ID:bcadam,项目名称:airoViz,代码行数:36,代码来源:oscSender.py

示例2: init

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
def init(osc_setup):
    host, port, root = osc_setup
    client = OSCClient()
    client.connect( (host, port) )
    print "Connected to the OSC server %s:%s%s" %osc_setup
    send_parameter('osd_initialized','Done')
    return client
开发者ID:centime,项目名称:easyLeap,代码行数:9,代码来源:OscSend.py

示例3: SendOSC

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
class SendOSC(object):

    def __init__(self):
        self.osc_message = None
        self.osc_client = OSCClient()
        self.osc_message = OSCMessage()        
        
        self.ip = ""
        self.port = 0

    def connect(self, ip="localhost", port=8080):
        self.ip = ip
        self.port = port
        self.osc_client.connect((self.ip, self.port))

    def send(self, address, value):
        self.osc_message.setAddress(address)
        self.osc_message.append(value)
        self.osc_client.send(self.osc_message)

    def send_distane(self, distance):
        oscdump = "/dumpOSC/DistanceTipTarget"
        self.send(oscdump, distance)

    def send_needle_tip_position(self, x, y, z):
        oscdump = "/dumpOSC/needltip/x"
        self.send(oscdump, x)
        oscdump = "/dumpOSC/needltip/y"
        self.send(oscdump, y)
        oscdump = "/dumpOSC/needltip/z"
        self.send(oscdump, z)
开发者ID:RocioLO,项目名称:SoundGuidance,代码行数:33,代码来源:SoundGuidance.py

示例4: messageServer

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
    def messageServer(self, messagePath, argument):
        client = OSCClient()
        client.connect((self.serverIP, self.serverPort))
        message = OSCMessage(messagePath)
        message.append(argument)

        client.send(message)
开发者ID:kevinmkarol,项目名称:lotht_game,代码行数:9,代码来源:server_interface.py

示例5: step_impl

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
def step_impl(context, host, port, int_one, int_sec):
    client = OSCClient()
    client.connect((host, port))
    if int_sec > 0:
        client.send(OSCMessage('/test', int_one, int_sec))
    else:
        client.send(OSCMessage('/test', int_one))
开发者ID:iaine,项目名称:sonification,代码行数:9,代码来源:writestream.py

示例6: main

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
def main():
    global bRun
    global inOSCport, outOSCport
    global myOSC_Server, myOSC_Client

    global cTrial, nTrials, breaksxTrial

    cTrial = 1 

    global debug_data
    global CS_US_1 

    CS_US_1['inputs']=[]

    cerebellumConfig['weights']=[]
    cerebellumConfig['config']=[]
    cerebellumConfig['constants']=[]


    debug_data['trials']=[]
    if save_bases:
        debug_data['basis']=[]
    debug_data['inputs']=[]

    inOSCport = 1234
    outOSCport = 1235
    
    # myOSC_Server = OSCServer( ('' , inOSCport) )
    # myOSC_Client = OSCClient()
    # myOSC_Client.connect( ('10.0.0.116' , outOSCport) )

    myOSC_Server = OSCServer( ('127.0.0.1' , inOSCport) )
    myOSC_Client = OSCClient()
    myOSC_Client.connect( ('127.0.0.1' , outOSCport) )
    
    print "Receiving messages /trial,/input in port", inOSCport
    print "Sending messages to port", outOSCport


    myOSC_Server.addMsgHandler("/config", receiveConfig)
    myOSC_Server.addMsgHandler("/trial", receiveTrial)
    myOSC_Server.addMsgHandler("/endtrial", receiveEndTrial)
    myOSC_Server.addMsgHandler("/input", receiveInput)
    myOSC_Server.addMsgHandler("/debug", receiveDebug)
    myOSC_Server.addMsgHandler("/update", receiveUpdate)
    myOSC_Server.addMsgHandler("/freeze", receiveFreeze)
    myOSC_Server.addMsgHandler("/saveConfig", receiveSaveConf)
    

    

    # if (cTrial==nTrials):
    #     pl.figure(figsize=(10,6))
    #     plot(breaksxTrial)

    
    print "Ready"

    myOSC_Server.serve_forever()
开发者ID:tcstewar,项目名称:telluride2014,代码行数:61,代码来源:cerebellarIROSExperimentRobotSaveConf.py

示例7: connectOsc

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
def connectOsc():
    global client, timeLastConnection
    if timeLastConnection < time.time() - 7200:
        print("connecting to OSC server")
        updateDNS()
        client = OSCClient()
        client.connect( ("146.164.80.56", 22244) )
        timeLastConnection = time.time()
开发者ID:hiperorganicos,项目名称:SHAST,代码行数:10,代码来源:old_motion.py

示例8: __init__

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
class ColorsOut:

    def __init__(self):
        self.client = OSCClient()
        self.client.connect( ("localhost",11661) )

    def write(self, pixels):
        message = OSCMessage("/setcolors")
        pixels = self.crazyMofoingReorderingOfLights(pixels)
        message.append(pixels)
        self.client.send( message )
    
    def diff(self, pixels):
        message = OSCMessage("/diffcolors")
        message.append(pixels)
        self.client.send( message )

        

    def crazyMofoingReorderingOfLights(self, pixels):
        pixels2 = pixels[:] #make a copy so we don't kerplode someone's work
        """
        what are we expecting? we want the back left (by the couches) of the room to be pixel 0, 
        and by the front is the last row
        whereas in reality, it's the opposite.
        here is the order it'd be nice to have them in:
        
        0  1  2  3
        4  5  6  7
        8  9  10 11
        12 13 14 15
        16 17 18 19
        20 21 22 23

        this is the actual order:   
        23 22 21 20
        19 16 17 18
        15 14 13 12
        11 10 9  8
        3  2  5  4
        6 *0**1**7*   *=not there
        """

        actualorder = [23,22,21,20,19,16,17,18,15,14,13,12,11,10,9,8,3,2,5,4,6,0,1,7]
        badcolors = [3,2,5,4,6,0,1,7]
        for i in range(len(actualorder)):
            (r,g,b) = pixels[i]
            r = max(0.0, min(r, 1023.0))
            g = max(0.0, min(g, 1023.0))
            b = max(0.0, min(b, 1023.0))
            pixels2[actualorder[i]] = (r,g,b)
        for i in range(len(badcolors)):
            pixels2[badcolors[i]] = (0.0,0.0,0.0)



        return pixels2
开发者ID:tdkadich,项目名称:chroma-scripts,代码行数:59,代码来源:oscapi.py

示例9: Manta

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
class Manta(object):

    def __init__(self, receive_port=31416, send_port=31417, send_address='127.0.0.1'):
        self.osc_client = OSCClient()
        self.osc_server = OSCServer(('127.0.0.1', receive_port))
        self.osc_client.connect(('127.0.0.1', send_port))
        # set the osc server to time out after 1ms
        self.osc_server.timeout = 0.001
        self.event_queue = []
        self.osc_server.addMsgHandler('/manta/continuous/pad',
                self._pad_value_callback)
        self.osc_server.addMsgHandler('/manta/continuous/slider',
                self._slider_value_callback)
        self.osc_server.addMsgHandler('/manta/continuous/button',
                self._button_value_callback)
        self.osc_server.addMsgHandler('/manta/velocity/pad',
                self._pad_velocity_callback)
        self.osc_server.addMsgHandler('/manta/velocity/button',
                self._button_velocity_callback)

    def process(self):
        self.osc_server.handle_request()
        ret_list = self.event_queue
        self.event_queue = []
        return ret_list

    def _pad_value_callback(self, path, tags, args, source):
        self.event_queue.append(PadValueEvent(args[0], args[1]))

    def _slider_value_callback(self, path, tags, args, source):
        touched = False if args[1] == 0xffff else True
        scaled_value = args[1] / 4096.0
        self.event_queue.append(SliderValueEvent(args[0], touched, scaled_value))

    def _button_value_callback(self, path, tags, args, source):
        pass

    def _pad_velocity_callback(self, path, tags, args, source):
        self.event_queue.append(PadVelocityEvent(args[0], args[1]))

    def _button_velocity_callback(self, path, tags, args, source):
        self.event_queue.append(ButtonVelocityEvent(args[0], args[1]))

    def _send_osc(self, path, *args):
        msg = OSCMessage(path)
        msg.append(args)
        self.osc_client.send(msg)

    def set_led_enable(self, led_type, enabled):
        self._send_osc('/manta/ledcontrol', led_type, 1 if enabled else 0)

    def set_led_pad(self, led_state, pad_index):
        self._send_osc('/manta/led/pad', led_state, pad_index)
开发者ID:ssfrr,项目名称:buffering,代码行数:55,代码来源:manta.py

示例10: __init__

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
class ColorsOut:
    def __init__(self):
        self.client = OSCClient()
        self.client.connect( ("localhost",11661) )

    def write(self, pixels):
        message = OSCMessage("/setcolors")
        message.append(pixels)
        self.client.send( message )
    
    def diff(self, pixels):
        message = OSCMessage("/diffcolors")
        message.append(pixels)
        self.client.send( message )
开发者ID:SIGMusic,项目名称:twitter-music-pd,代码行数:16,代码来源:osc.py

示例11: OscSender

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
class OscSender():
    def __init__(self, osc_setup):
        self.host, self.port, self.root = osc_setup
        self.client = OSCClient()
        self.client.connect( (self.host, self.port) )
        print "Connected to the OSC server %s:%s%s" %osc_setup
        self.send_parameter('osd_initialized','Done')

    def send_parameters(self, hand_params):
        for path, value in hand_params.items():
            self.send_parameter(path, value)

    def send_parameter(self, rel_path, data):
        full_path = self.root+rel_path
        #self.client.send( OSCMessage( full_path, data ) )
        print "[osc]\t%s\t\t\t%s" %(full_path, data)
开发者ID:centime,项目名称:easyLeap,代码行数:18,代码来源:OscSend.py

示例12: OSCServer

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
class OSCServer(object):

  def __init__(self, ip, port,address="/openbci"):
    self.ip = ip
    self.port = port
    self.address = address
	if len(args) > 0:
		self.ip = args[0]
	if len(args) > 1:
		self.port = args[1]
	if len(args) > 2:
		self.address = args[2]
	# init network
	print "Selecting OSC streaming. IP: ", self.ip, ", port: ", self.port, ", address: ", self.address
	self.client = OSCClient()
	self.client.connect( (self.ip, self.port) )	
开发者ID:prescottprue,项目名称:OpenBCI_Hub,代码行数:18,代码来源:streamer_osc.py

示例13: app

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
def app():
    global dxlIO, server, client
    ports = pypot.dynamixel.get_available_ports()
    if not ports:
        raise IOError('No port available.')
    dxlIO = pypot.dynamixel.DxlIO(ports[0])
    availableIDs = dxlIO.scan()
    server = OSCServer(('0.0.0.0', 8000))
    for motorID in availableIDs:
        server.addMsgHandler('/motor/' + str(motorID), motorHandler) # Register OSC handlers for each found ID
    client = OSCClient()
    client.connect(('localhost', 8001))
    print 'Ready. Found ID(s) ' + str(availableIDs)
    while True:
        server.handle_request()
        sleep(0.01)
开发者ID:ianisl,项目名称:DOS,代码行数:18,代码来源:app.py

示例14: StreamerOSC

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
class StreamerOSC(plugintypes.IPluginExtended):
	"""

	Relay OpenBCI values to OSC clients

	Args:
	  port: Port of the server
	  ip: IP address of the server
	  address: name of the stream
	"""
	    
	def __init__(self, ip='localhost', port=12345, address="/openbci"):
		# connection infos
		self.ip = ip
		self.port = port
		self.address = address
	
	# From IPlugin
	def activate(self):
		if len(self.args) > 0:
			self.ip = self.args[0]
		if len(self.args) > 1:
			self.port = int(self.args[1])
		if len(self.args) > 2:
			self.address = self.args[2]
		# init network
		print "Selecting OSC streaming. IP: ", self.ip, ", port: ", self.port, ", address: ", self.address
		self.client = OSCClient()
		self.client.connect( (self.ip, self.port) )

	# From IPlugin: close connections, send message to client
	def deactivate(self):
		self.client.send(OSCMessage("/quit") )
	    
	# send channels values
	def __call__(self, sample):
		mes = OSCMessage(self.address)
		mes.append(sample.channel_data)
		# silently pass if connection drops
		try:
			self.client.send(mes)
		except:
			return

	def show_help(self):
	  	print """Optional arguments: [ip [port [address]]]
开发者ID:Athuli7,项目名称:pybci,代码行数:48,代码来源:streamer_osc.py

示例15: Renoise

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import connect [as 别名]
class Renoise(object):
    def __init__(self, address):
        self.client = OSCClient()
        self.client.connect(address)

    def panic(self):
        self.send_osc('/renoise/transport/panic')
    
    def note_on(self, instrument, track, note, velocity):
        self.send_osc('/renoise/trigger/note_on', instrument, track, note, velocity)
    
    def note_off(self, instrument, track, note):
        self.send_osc('/renoise/trigger/note_off', instrument, track, note)
    
    def send_osc(self, path, *args):
        msg = OSCMessage(path)
        map(msg.append, args)
        self.client.send(msg)
开发者ID:rknLA,项目名称:pymonome,代码行数:20,代码来源:renoise.py


注:本文中的OSC.OSCClient.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。