本文整理汇总了Python中OSC.OSCServer.timeout方法的典型用法代码示例。如果您正苦于以下问题:Python OSCServer.timeout方法的具体用法?Python OSCServer.timeout怎么用?Python OSCServer.timeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSC.OSCServer
的用法示例。
在下文中一共展示了OSCServer.timeout方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import timeout [as 别名]
def main():
print("Waiting for boot signal")
print(s.read())
print("Writing sway command")
s.write("".join(map(chr, [0x55, 0x0, 0x3, 0, 2, 72]))) # equivalent to .join['U', '\x00', '\x03', '\x00', '\x02', 'H']
# between every elements in the list, put ""
# that will convert it as one string ''Ux00x03x00x02H''
print(s.read())
# print("Reading motor encoders")
# s.write("".join(map(chr, [0x55, 0x1, 0x12])))
# print(["0x%.02x " % ord(x) for x in s.read(12)])
server = OSCServer( ("192.168.123.75", 10000) )
server.timeout = 0
# funny python's way to add a method to an instance of a class
import types
server.handle_timeout = types.MethodType(handle_timeout, server)
server.addMsgHandler( "/rotate", rotate_callback )
server.addMsgHandler( "/bf", bf_callback )
try:
while 1:
server.handle_request()
except KeyboardInterrupt:
pass
server.close()
示例2: setupServer
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import timeout [as 别名]
def setupServer():
global server
server = OSCServer( (HOST_NAME, PORT_NUM) )
server.timeout = 0
server.handle_timeout = types.MethodType(handle_timeout, server)
server.addMsgHandler( "/dmx", user_callback )
print(server)
示例3: main
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import timeout [as 别名]
def main():
print("Waiting for boot signal")
print(s.read())
print("Writing sway command")
s.write("".join(map(chr, [0x55, 0x0, 0x3, 0, 2, 72])))
print(s.read())
# print("Reading motor encoders")
# s.write("".join(map(chr, [0x55, 0x1, 0x12])))
# print(["0x%.02x " % ord(x) for x in s.read(12)])
server = OSCServer( ("192.168.123.75", 10000) )
server.timeout = 0
# funny python's way to add a method to an instance of a class
import types
server.handle_timeout = types.MethodType(handle_timeout, server)
server.addMsgHandler( "/rotate", rotate_callback )
server.addMsgHandler( "/bf", bf_callback )
try:
while 1:
server.handle_request()
except KeyboardInterrupt:
pass
server.close()
示例4: server_start
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import timeout [as 别名]
def server_start(port=7110):
global server
server = OSCServer ( ("localhost", 7110))
server.timeout = 0
server.handle_timeout = types.MethodType(handle_timeout, server)
server.addMsgHandler("/sco", handle_score)
server.addMsgHandler("/cc", handle_cc)
server.addMsgHandler("/quit", quit_callback)
server.addMsgHandler("default", default_callback)
示例5: main
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import timeout [as 别名]
def main(hostname="localhost",port="8000"):
server = OSCServer((hostname, int(port)))
server.timeout = 0
run = True
global message_count
message_count = 0
# this method of reporting timeouts only works by convention
# that before calling handle_request() field .timed_out is
# set to False
def handle_timeout(self):
self.timed_out = True
# funny python's way to add a method to an instance of a class
import types
server.handle_timeout = types.MethodType(handle_timeout, server)
def user_callback(path, tags, args, source):
log("%s %s\n" % (path, args))
global message_count
message_count += 1
def quit_callback(path, tags, args, source):
#global run
run = False
server.addMsgHandler( "default", user_callback )
server.addMsgHandler( "/quit", quit_callback )
# user script that's called by the game engine every frame
def each_frame():
log("Messages received: %s\n" % message_count)
# clear timed_out flag
server.timed_out = False
# handle all pending requests then return
while not server.timed_out:
server.handle_request()
# simulate a "game engine"
print "Server running at %s:%s" % (hostname, port)
while run:
# do the game stuff:
sleep(1)
# call user script
each_frame()
server.close()
示例6: OSCServer
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import timeout [as 别名]
__author__ = 'benjamindeleener'
#!/usr/bin/env python3
from OSC import OSCServer
import sys
from time import sleep
server = OSCServer( ("localhost", 5005) )
server.timeout = 0
run = True
# this method of reporting timeouts only works by convention
# that before calling handle_request() field .timed_out is
# set to False
def handle_timeout(self):
self.timed_out = True
# funny python's way to add a method to an instance of a class
import types
server.handle_timeout = types.MethodType(handle_timeout, server)
def user_callback(path, tags, args, source):
# which user will be determined by path:
# we just throw away all slashes and join together what's left
user = ''.join(path.split("/"))
# tags will contain 'ffff'
# args is a OSCMessage with data
# source is where the message came from (in case you need to reply)
print ("Now do something with ", user, args[0], args[1], args[2], args[3])
def quit_callback(path, tags, args, source):
# don't do this at home (or it'll quit blender)
示例7: home
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import timeout [as 别名]
# don't do this at home (or it'll quit blender)
global run
run = False
# user script that's called by the game engine every frame
def each_frame(*args):
while True:
# clear timed_out flag
server.timed_out = False
# handle all pending requests then return
if not server.timed_out:
server.handle_request()
time.sleep(0.001)
server = OSCServer( ("0.0.0.0", 6666) )
server.timeout = 0.001
run = True
server.handle_timeout = types.MethodType(handle_timeout, server)
server.addMsgHandler( "/m", user_callback )
server.addMsgHandler( "/s", user_callback )
#server.addMsgHandler( "/quit", quit_callback )
data = ""
sleeptime = 0.001
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
sock.bind(("0.0.0.0", 6454))
sock.settimeout(0.001)
#27 28 29 30 31 32 33 34 35 36 37 38 39 40
示例8: Serial
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import timeout [as 别名]
# ip address finder
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
ifname = 'eth0'
localIP = socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915, # SIOCGIFADDR
struct.pack('256s', ifname[:15])
)[20:24])
clientAddress = '192.168.0.153', 9999
serverAddress = localIP, 9998
ser = Serial('/dev/ttyUSB0', 9600)
columnServer = OSCServer( serverAddress )
columnServer.timeout = 0
run = True
columnClient = OSCClient()
columnClient.connect(clientAddress)
# Audio player
pygame.mixer.init()
uniqueSound = pygame.mixer.Sound("testSound.wav")
uniqueSound.set_volume(0)
uniqueSound.play(-1)
pygame.mixer.music.load("testSound.wav")
pygame.mixer.music.set_volume(0)
#pygame.mixer.music.play(-1)
示例9: OSCServer
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import timeout [as 别名]
import struct
# ip address finder
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
ifname = 'eth0'
localIP = socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915, # SIOCGIFADDR
struct.pack('256s', ifname[:15])
)[20:24])
clientAddress = '192.168.2.1', 9999
serverAddress = localIP, 9998
lockerServer = OSCServer( serverAddress )
lockerServer.timeout = 0
run = True
lockerClient = OSCClient()
lockerClient.connect(clientAddress)
# Create a default object, no changes to I2C address or frequency
locker = Adafruit_MotorHAT(addr=0x60)
totalPixels = 1000 # Number of LEDs in Locker
pixel = 0
# Control Pins for the Raspberry Pi to the Dot Star strip
datapin = 23
clockpin = 24
#strip = Adafruit_DotStar(totalPixels, datapin, clockpin)
示例10: remote_started_callback
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import timeout [as 别名]
def remote_started_callback(path, tags, args, source):
print "Player started", args
# global running
# running = True
def remote_files_callback(path, tags, args, source):
print "Player has these files:", args
if __name__ == "__main__":
try:
sys.excepthook = log_uncaught_exceptions
notifications = OSCServer( (args.notifierip, args.notifierport) )
notifications.timeout = 0.1
# funny python's way to add a method to an instance of a class
notifications.handle_timeout = types.MethodType(handle_timeout, notifications)
# RPi.GPIO Layout verwenden (wie Pin-Nummern)
GPIO.setmode(GPIO.BOARD)
for _button in button_map:
GPIO.setup(_button, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # PUD_DOWN, because we use a pull down resistor, use RISING in next line then!
GPIO.add_event_detect(_button, GPIO.RISING, callback=button_press, bouncetime=args.bouncetime)
client.connect( (args.ip, args.port) )
notifications.addMsgHandler( "/stopped", remote_stopped_callback )
notifications.addMsgHandler( "/playing", remote_started_callback )
notifications.addMsgHandler( "/files", remote_files_callback )
示例11: step_impl
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import timeout [as 别名]
def step_impl(context, message):
listen = OSCServer(("127.0.0.1", 4589))
listen.timeout = 0 #infinite timeout
listen.addMsgHandler("/err", listen_handler)
listen.close()