本文整理汇总了Python中OSC.OSCServer.handle_timeout方法的典型用法代码示例。如果您正苦于以下问题:Python OSCServer.handle_timeout方法的具体用法?Python OSCServer.handle_timeout怎么用?Python OSCServer.handle_timeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSC.OSCServer
的用法示例。
在下文中一共展示了OSCServer.handle_timeout方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import handle_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: main
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import handle_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()
示例3: setupServer
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import handle_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)
示例4: server_start
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import handle_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 handle_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 handle_timeout [as 别名]
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)
global run
run = False
示例7: run
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import handle_timeout [as 别名]
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
def run(self):
print "Starting " + self.name
serialComms()
# 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
columnServer.handle_timeout = types.MethodType(handle_timeout, columnServer)
def clearStrip():
for pixel in range(totalPixels):
strip.setPixelColor(pixel, 0x000000)
strip.show()
def displayColumn():
while True:
global color
global prevColor
time.sleep(0.001)
if prevColor != color:
#print str(color)
for pixel in range(totalPixels):
strip.setPixelColor(pixel, color) #Assign Color to pixel
示例8: run
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import handle_timeout [as 别名]
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
def run(self):
print "Starting " + self.name
testStrip()
# 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
lockerServer.handle_timeout = types.MethodType(handle_timeout, lockerServer)
# recommended for auto-disabling motors on shutdown!
def turnOffSolenoid():
locker.getMotor(1).run(Adafruit_MotorHAT.RELEASE)
def clearStrip():
for pixel in range(totalPixels):
strip.setPixelColor(pixel, 0x000000)
strip.show()
def testStrip():
while True:
global color
global prevColor
time.sleep(0.001)
示例9: remote_files_callback
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import handle_timeout [as 别名]
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 )
print "StaalPiPlayer Button Client ready!"
print "\tListening for player with:",notifications