本文整理汇总了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 ) )
示例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
示例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)
示例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)
示例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))
示例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()
示例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()
示例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
示例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)
示例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 )
示例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)
示例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) )
示例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)
示例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]]]
示例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)