예제 #1
0
def main():
    # Have to import it locally, don't know why
    from pythonosc import osc_server
    from pythonosc import dispatcher

    # OSC Server thread
    print("Starting OSC dispatcher")
    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/muse/elements/gamma_absolute", gamma_handler,
                   "GAMMA_HANDLER")

    server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)

    serverThread = Thread(target=server.serve_forever)
    serverThread.start()

    # Web server thread
    print("Starting web server")
    flaskThread = Thread(target=flaskServer)
    flaskThread.start()

    # Session thread
    print("Starting session thread")
    sessionThread = Thread(target=startSession)
    sessionThread.start()

    sessionThread.join()
예제 #2
0
 def __init__(self, prefix, number, x, y):
     self.number = number
     self.x = x
     self.y = y
     self.type = "button"
     self.osc_addr = "/" + prefix + "/" + self.type + "/" + str(self.number)
     dispatcher.map(self.osc_addr, self.handler, x, y)
예제 #3
0
파일: ttc.py 프로젝트: lightop/touch2click
 def __init__(self,number,x,y):
   self.number = number
   self.x = x
   self.y = y
   self.type = "button"
   self.osc_addr = gen_osc_addr(self.type, self.number)
   dispatcher.map (self.osc_addr, self.handler, x, y )
 def run(self):
     global FD_control
     from pythonosc import dispatcher
     dispatcher = dispatcher.Dispatcher()
     dispatcher.map('/svd', complexity2FD)
     server = osc_server.BlockingOSCUDPServer((self.addr, self.port), dispatcher)
     print("Serving on {}".format(server.server_address))
     server.serve_forever()
예제 #5
0
파일: ttc.py 프로젝트: lightop/touch2click
 def __init__(self, number,x,y):
   self.number = number
   self.x = x
   self.y = y
   self.type = "encoder"
   self.osc_addr = gen_osc_addr(self.type, self.number)
   dispatcher.map (self.osc_addr, self.handler,self.x, self.y)
   dispatcher.map (self.osc_addr+"/z", self.handler_z, self.x, self.y)
예제 #6
0
 def start(self):
     from pythonosc import dispatcher
     from pythonosc import osc_server
     dispatcher = dispatcher.Dispatcher()
     dispatcher.map(self.address, print)
     server = osc_server.ThreadingOSCUDPServer((self.ip, self.port),
                                               dispatcher)
     print("Serving on {}".format(server.server_address))
     server.serve_forever()
예제 #7
0
 def __init__(self, prefix, number, x, y, h, v):
     self.number = number
     self.x = x
     self.y = y
     self.h = h
     self.v = v
     self.type = "encoder"
     self.osc_addr = "/" + prefix + "/" + self.type + "/" + str(self.number)
     dispatcher.map(self.osc_addr, self.handler, self.x, self.y)
     dispatcher.map(self.osc_addr + "/z", self.handler_z, self.x, self.y)
예제 #8
0
def run_OSC(motor_values_):
    from pythonosc import dispatcher
    from pythonosc import osc_server

    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/motor", save_motor_value, "Motor", motor_values_)
    server = osc_server.ThreadingOSCUDPServer((server_ip, 3335), dispatcher)

    print("Serving OSC on {}".format(server.server_address))
    server.serve_forever()
예제 #9
0
def OSC_universe4_thread(name):

    dispatcher.map("/*", print_qlc_handler, "qlc_laserharp")

    server = osc_server.ThreadingOSCUDPServer(("127.0.0.1", 9003), dispatcher)

    try:
        print("Entering main loop. Press Control-C to exit.")
        server.serve_forever()
    except KeyboardInterrupt:
        exit()
예제 #10
0
def init_OSC_server(ip, port, dispatcher, osc_message_handler):
    dispatcher.map("/wek/outputs", osc_message_handler)

    server = osc_server.ThreadingOSCUDPServer((ip, port), dispatcher)
    print("Serving on {}".format(server.server_address))

    server_thread = Thread(target=server.serve_forever)
    server_thread.daemon = True
    server_thread.start()

    return server
예제 #11
0
def main(args):
    osc_ip = "127.0.0.1"
    osc_port = 1337

    print("osc test")

    dispatcher = Dispatcher()
    #dispatcher.map("/filter", print)
    dispatcher.map("/volume", print_volume_handler, "Volume")
    #dispatcher.map("/logvolume", print_compute_handler, "Log volume", math.log)
    server = osc_server.ThreadingOSCUDPServer((osc_ip, osc_port), dispatcher)
    print("Serving on {}".format(server.server_address))
    server.serve_forever()
예제 #12
0
파일: mqto.py 프로젝트: lightop/touch2click
 def __init__(self, number, x_zero, y_zero, x_full, y_full):
   self.number = number
   self.x_zero = x_zero
   self.y_zero = y_zero
   self.x_full = x_full
   self.y_full = y_full
   self.y_size = self.y_zero - self.y_full
   self.x_size = self.x_zero - self.x_full
   self.type = "fader"
   self.x_level = 0
   self.y_level = 0
   self.osc_addr = gen_osc_addr (self.type, self.number)
   dispatcher.map (self.osc_addr, self.handler, self.x_zero, self.y_zero)
   dispatcher.map (self.osc_addr+"/z",self.handler_z, self.x_zero, self.y_zero)
예제 #13
0
def init_OSC_server(ip,port,osc_message_handler):

    ## create an event dispatcher for "/wek/outputs" address.
    ## set event handler "osc_message_handler"
    dispatcher.map("/wek/outputs", osc_message_handler)

    ## setup and start an osc server thread on specified ip address and port.
    server = osc_server.ThreadingOSCUDPServer(
        (ip, port), dispatcher)
    print("Serving on {}".format(server.server_address))

    server_thread = Thread(target=server.serve_forever)
    server_thread.daemon = True
    server_thread.start()

    return server
예제 #14
0
 def __init__(self, prefix, number, x_zero, y_zero, x_full, y_full):
     self.number = number
     self.x_zero = x_zero
     self.y_zero = y_zero
     self.x_full = x_full
     self.y_full = y_full
     self.prefix = prefix
     self.y_size = self.y_zero - self.y_full
     self.x_size = self.x_zero - self.x_full
     self.type = "fader"
     self.x_level = 0
     self.y_level = 0
     self.osc_addr = "/" + self.prefix + "/" + self.type + "/" + str(
         self.number)
     print(self.osc_addr)
     dispatcher.map(self.osc_addr, self.handler, self.x_zero, self.y_zero)
     dispatcher.map(self.osc_addr + "/z", self.handler_z, self.x_zero,
                    self.y_zero)
예제 #15
0
def run_server():
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip",
                        default="127.0.0.1",
                        help="The ip to listen on")
    parser.add_argument("--port",
                        type=int,
                        default=8000,
                        help="The port to listen on")
    args = parser.parse_args()

    dispatcher = dispatcher.Dispatcher()
    #print(getattr(dispatcher, "dispatcher"))
    dispatcher.map("/synth_receive", send_synth_values)

    server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)
    print("Serving on {}".format(server.server_address))
    server.serve_forever()
예제 #16
0
def listener():
    from pythonosc import dispatcher
    # parser = argparse.ArgumentParser()
    # parser.add_argument("--ip",
    #                     default="192.168.1.176", help="The ip to listen on")
    # parser.add_argument("--port",
    #                     type=int, default=5006, help="The port to listen on")
    # args = parser.parse_args()

    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/sensor/z", respUpd)
    dispatcher.map("/pressure", pressureUpd)

    server = osc_server.ThreadingOSCUDPServer(
    (IPAddressListener, PortListener), dispatcher)
    print("Listening on {}".format(server.server_address))
    server.serve_forever()
    if stop():
      server.close()
def initialize_server():
    """
    the  OSC server
    """
    from pythonosc import dispatcher
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip", default=OSC_LISTEN_IP, help="The ip to listen on")
    parser.add_argument("--port", type=int, default=OSC_LISTEN_PORT, help="The port to listen on")
    args = parser.parse_args()
    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/train", neuralnet_audio.continue_training)
    dispatcher.map("/save_model", neuralnet_audio.save_model)

    try:
        server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)
        server_thread=threading.Thread(target=server.serve_forever, daemon=True)
        server_thread.start()
    except OSError as e:
        server = None
        server_thread = None
        print(e)
async def osc_server_local():
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip", default="127.0.0.1", help="The ip to listen on")
    parser.add_argument("--port", type=int, default=5005, help="The port to listen on")
    args = parser.parse_args()

    dispatcher.map("/sonicpitest**", sonic_pi_test_handler)
    dispatcher.map("/pad_active", pad_active_handler)
    dispatcher.map("/pad_enabled", pad_enabled_handler)
    dispatcher.map("/pad_text", pad_text_handler)

    server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)
    print("Serving on {}".format(server.server_address))
    server.serve_forever()
예제 #19
0
def main():
    # UDP Sender to NodeMCU on NeoDisplay
    sender = DisplayDataSender("NeoDisplay", 4210)

    # The game
    snake = Snake(Display.WIDTH, Display.HEIGHT, sender.update)

    # OSC Server configuration
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip", default="0.0.0.0", help="The ip to listen on")
    parser.add_argument("--port",
                        type=int,
                        default=8888,
                        help="The port to listen on")
    args = parser.parse_args()
    dispatcher = posc.dispatcher.Dispatcher()
    #dispatcher.map("/*", print_topic) # Wildcard for all topics
    dispatcher.map("/Snake/Dir/*", snake.turn)
    dispatcher.map("/Snake/Reset", snake.reset)
    dispatcher.map("/Snake/Fader", snake.speed)
    server = posc.osc_server.ThreadingOSCUDPServer((args.ip, args.port),
                                                   dispatcher)

    sender.set_brightness(35)
    sender.set_mode(mt.DisplayEnums.Mode.DEFAULT)
    sender.clear(mt.DisplayEnums.Layer.ALL)
    sender.set_effect(mt.DisplayEnums.Effect.NONE)

    # Start Stuff:
    print("Serving OSC on {}".format(server.server_address))
    server.serve_forever()

    # Ending Stuff
    server.close
예제 #20
0
def forward_osc_to_websocket(args, num):


if __name__ == "__main__":
  parser = argparse.ArgumentParser()
  parser.add_argument("--ip",
      default="127.0.0.1", help="The ip to listen on")
  parser.add_argument("--port",
      type=int, default=5006, help="The port to listen on")
  args = parser.parse_args()

  dispatcher = dispatcher.Dispatcher()
  dispatcher.map("/debug", print)
  dispatcher.map("/name", print)
  dispatcher.map("/bcdata", print)
  dispatcher.map("/volume", print_volume_handler, "Volume")
  dispatcher.map("/logvolume", print_compute_handler, "Log volume", math.log)

  server = osc_server.ThreadingOSCUDPServer(
      (args.ip, args.port), dispatcher)
  print("Serving on {}".format(server.server_address))
  server.serve_forever()
def server():
    from pythonosc import dispatcher
    # parser = argparse.ArgumentParser()
    # parser.add_argument("--ip",
    #                     default="192.168.1.176", help="The ip to listen on")
    # parser.add_argument("--port",
    #                     type=int, default=5006, help="The port to listen on")
    # args = parser.parse_args()
    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/sensor/x", updateX)
    dispatcher.map("/sensor/y", updateY)
    dispatcher.map("/sensor/z", updateZ)

    dispatcher.map("/accxyz", updtouchOSC)

    dispatcher.map("/actuator/1/inflate", updateAct)

    server = osc_server.ThreadingOSCUDPServer(
    ("192.168.0.150", 5006), dispatcher)
    print("Serving on {}".format(server.server_address))
    server.serve_forever()
    if stop():
      server.close()
예제 #22
0
def runMuseServer():
    global dispatcher, Dispatcher, server
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip", default="localhost", help="The ip to listen on")
    parser.add_argument("--port", type=int, default=1337, help="The port to listen on")
    args = parser.parse_args()

    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/muse/elements/alpha_absolute", alphaData)
    dispatcher.map("/muse/elements/beta_absolute", betaData)
    dispatcher.map("/muse/elements/delta_absolute", deltaData)
    dispatcher.map("/muse/elements/theta_absolute", thetaData)

    server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)
    print("Serving on {}".format(server.server_address))
    server_thread = threading.Thread(target=server.serve_forever)
    server_thread.start()
def initialize_server():
  from pythonosc import dispatcher
  parser = argparse.ArgumentParser()
  parser.add_argument("--ip",
      default="2.0.0.1", help="The ip to listen on")
  parser.add_argument("--port",
      type=int, default=8000, help="The port to listen on")
  args = parser.parse_args()

  dispatcher = dispatcher.Dispatcher()
  dispatcher.map("/fft", fft_handler)
  dispatcher.map("/Playback/Recorder/frameCount", frameCountHandler)
  dispatcher.map("/train", train_handler)
  dispatcher.map("/newModel", newModel_handler)

  server = osc_server.ThreadingOSCUDPServer(
      (args.ip, args.port), dispatcher)
  server_thread=threading.Thread(target=server.serve_forever)
  server_thread.start()
예제 #24
0
def main():
    from pythonosc import dispatcher
    from pythonosc import osc_server
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip",
                        default="127.0.0.1",
                        help="The ip to listen on")
    parser.add_argument("--port",
                        type=int,
                        default=5000,
                        help="The port to listen on")
    args = parser.parse_args()

    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/debug", print)
    dispatcher.map("/eeg", eeg_handler, "EEG")
    # dispatcher.map("/eeg",raw_printer)
    dispatcher.map("", print_volume_handler, "Volume")
    dispatcher.map("/logvolume", print_compute_handler, "Log volume", math.log)

    server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)
    print("Serving on {}".format(server.server_address))
    server.serve_forever()
예제 #25
0
def main():
    from pythonosc import osc_server
    from pythonosc import dispatcher

    # Start server
    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/muse/elements/gamma_absolute", gamma_handler,
                   "CONCENTRATION")
    dispatcher.map("/muse/elements/jaw_clench", jaw_handler, "JAW")
    dispatcher.map("/muse/elements/blink", blink_handler, "BLINK")

    server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)

    serverThread = Thread(target=server.serve_forever)
    serverThread.start()

    # Start blink service
    clickThread = Thread(target=manageBlink)
    clickThread.start()

    # Start cursor
    cursorThread = Thread(target=manageCursor)
    cursorThread.start()
    cursorThread.join()
		procs[5] = subprocess.Popen(["python3", "sub_directions_listener.py", str(start), str(end)])
	else:
		procs[5].kill()
		print("exited directions")

# Debug - tests whether script recieves messages from Max through OSC
def db_handler(unused_addr, args, val):
	print(val)
	sendOSCMessage(val * 2, "/pyDebug")

if __name__ == "__main__":
	dispatcher = dispatcher.Dispatcher()

	procs[0] = subprocess.Popen(["python3", "sub_type_monitor.py"])

	dispatcher.map("/listen_to_cpu", listen_to_cpu, "val")
	dispatcher.map("/listen_to_weather", listen_to_weather, "val")
	dispatcher.map("/listen_to_calendar", listen_to_calendar, "val")
	dispatcher.map("/listen_to_gmail", listen_to_gmail, "val")
	dispatcher.map("/listen_to_directions", listen_to_directions, "val")
	dispatcher.map("/debug", db_handler, "val")
	
	server = osc_server.ThreadingOSCUDPServer(
      ("127.0.0.1", 54322), dispatcher)
	server.serve_forever()

# Once the program is finished, make sure to kill all remaining subprocesses
@atexit.register
def kill_subprocesses():
	for proc in procs:
		if proc != '':
예제 #27
0
def eeg_handler(unused_addr, args, ch1, ch2, ch3, ch4):
    print("EEG (uV) per channel: ", ch1, ch2, ch3, ch4)
def con_handler(f1,f2,f3):
    print(len(readings))
    # print(type(f3))
    if(f3 == 1 or f3 == 0):
      print("CALIBRATING")
    else:
      readings.append(f3)
    if(len(readings)==25):
      # THIS NEEDS TO BE THE SAME PATH FOR WHICHEVER LAPTOP WE USE!
      with open('C:/Users/Xactimate1/Desktop/mindTrack/hackusu-master/data.json','w') as outfile:
        json.dump(sum(readings)/len(readings),outfile)
      del readings[:]
      # def mellow_handler(f1,f2,f3):
      #       print(f1,f2,f3)
if __name__ == "__main__": readings = []
parser = argparse.ArgumentParser()
parser.add_argument("--ip",
    default="127.0.0.1", help="The ip to listen on")
parser.add_argument("--port",
    type=int, default=5000, help="The port to listen on")
args = parser.parse_args() 
dispatcher = dispatcher.Dispatcher()
dispatcher.map("/debug", print)
dispatcher.map("/muse/elements/experimental/concentration", con_handler,"CONCENTRATED")
  # print(os.path.dirname(os.path.abspath("data.json")))
  # dispatcher.map("/muse/elements/experimental/mellow", mellow_handler,"MELLOW") # dispatcher.map("/muse/eeg", eeg_handler, "EEG") 
server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)
print("Serving on {}".format(server.server_address))
server.serve_forever() 
예제 #28
0
if __name__ == '__main__':
    print ("Display info")

    parser = argparse.ArgumentParser()
    parser.add_argument("--ip",
                        default="127.0.0.1", help="The ip to listen on")
    parser.add_argument("--port",
                        type=int, default=9997, help="The port to listen on")
    args = parser.parse_args()

    # 設定python-osc接收頻道和呼叫函式

    dispatcher = dispatcher.Dispatcher()
    if ds.id == 1:
        dispatcher.map("/omxplayer", display_osc_master_message)
        print("master's server")
    else:
        dispatcher.map("/omxplayer", display_osc_slave_message)
        print("slave's server")

    server = osc_server.ThreadingOSCUDPServer(
        (args.ip, args.port), dispatcher)
    print("Serving on {}".format(server.server_address))

    # 用多線程執行main
    try:
        _thread.start_new_thread(main, ("main", 0))
    except:
        print("something wrong")
예제 #29
0
    ip = "127.0.0.1" 

    # This should match the outPort in the Arduino sketch
    port = 9999

    # these lines set things up to recieve input from the command line
    #  that will over write the default ip and port above
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip", default=ip, help="The ip to listen on")
    parser.add_argument("--port", type=int, default=port, 
                        help="The port to listen on")
    args = parser.parse_args()

    # set up the dispatcher to handle the osc
    dispatcher = dispatcher.Dispatcher()

    # Send the address and data of an osc message to a function 
    #  of your choice. You can use the same function for multiple addresses.
    #  Check out the examples at https://github.com/attwad/python-osc
    #  for more info on what you can do with the dispatchers
    dispatcher.map("/button", printButton)
    dispatcher.map("/text", print)

    # Start the server to recieve osc
    server = osc_server.ThreadingOSCUDPServer(
        (args.ip, args.port), dispatcher)
    print("Serving on {}".format(server.server_address))
    server.serve_forever()

    # no commands below the serve_forever() line will execute
예제 #30
0
from pythonosc import dispatcher
import threading

"""OSC Servers that receive UDP packets and invoke handlers accordingly.
Use like this:"""

dispatcher = dispatcher.Dispatcher()
# This will print all parameters to stdout.
dispatcher.map("/bpm", print)
#server = ForkingOSCUDPServer((ip, port), dispatcher)
#server.serve_forever()
#or run the server on its own thread:
server = ForkingOSCUDPServer((ip, port), dispatcher)
server_thread = threading.Thread(target=server.serve_forever)
server_thread.start()
...
server.shutdown()
예제 #31
0
import threading
from datetime import datetime
from pythonosc import osc_message_builder, udp_client, dispatcher, osc_server

#
# SERVER
#

def debug_handler(address):
    print('Received debug')

def timing_handler(address, seconds, microseconds):
    print('Received timing {}:{} at {}'.format(seconds, microseconds, datetime.now()))

dispatcher = dispatcher.Dispatcher()
dispatcher.map("/debug", debug_handler)
dispatcher.map("/timing", timing_handler)

server = osc_server.ThreadingOSCUDPServer(
    ('localhost', 5005), dispatcher)
print("Serving on {}".format(server.server_address))
server_thread = threading.Thread(target=server.serve_forever)
server_thread.start()

#
# CLIENT
#

try:
    client = udp_client.UDPClient('localhost', 5005)
예제 #32
0
		secondlast=node[0]
	return(number)

def clenchHandler(*data):
	global legalValues, lastClenchPeriod
	handleType, value = data
	print(value)
	curTime = time.time()
	legalValues.append([value, curTime])
	for node in legalValues:
		if node[1]<curTime-threshold:
			legalValues.pop(legalValues.index(node))
	numClenchPeriod = numClenches(legalValues)
	if numClenchPeriod==desiredClenches and lastClenchPeriod!=desiredClenches:
		ser.write(bytes([1]))
		print("serial print")
	
	lastClenchPeriod=numClenchPeriod

global dispatcher, Dispatcher, server
parser = argparse.ArgumentParser()
parser.add_argument("--ip", default="localhost", help="The ip to listen on")
parser.add_argument("--port",type=int, default=1337, help="The port to listen on")
args = parser.parse_args()
dispatcher = dispatcher.Dispatcher()
dispatcher.map("/muse/elements/jaw_clench", clenchHandler)
server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)
server_thread = threading.Thread(target=server.serve_forever)
server_thread.start()
 
#muse-io --osc osc.udp://localhost:1337 
예제 #33
0
    outlet.push_sample( single_data, osc_time)


unique_id = 'Muse1234567890'
outlet = get_outlet(unique_id)

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip",
                        default="10.0.0.5",
                        help="The ip to listen on")
    parser.add_argument("--port",
                        type=int,
                        default=5001,
                        help="The port to listen on")
    args = parser.parse_args()
    print("unique id:" + unique_id)

    dispatcher = dispatcher.Dispatcher()
    # dispatcher.map("/debug", print)
    dispatcher.map("/muse/eeg", eeg_handler, "EEG")
    # dispatcher.map("/muse/elements/alpha_absolute", print)
    # dispatcher.map("/muse/elements/beta_absolute", print)
    # dispatcher.map("/muse/elements/gamma_absolute", print)
    # dispatcher.map("/muse/elements/delta_absolute", print)
    # dispatcher.map("/muse/elements/theta_absolute", print)
    server = osc_server.ThreadingOSCUDPServer(
        (args.ip, args.port), dispatcher)
    print("Serving on {}".format(server.server_address))
    server.serve_forever()
예제 #34
0
		if devmode:
			print("shutting down...")
		GPIO.cleanup()
		server.shutdown()


if __name__ == "__main__":
  parser = argparse.ArgumentParser()
  parser.add_argument("--ip",
      default="127.0.0.1", help="The ip to listen on")
  parser.add_argument("--port",
      type=int, default=5005, help="The port to listen on")
  args = parser.parse_args()

  dispatcher = dispatcher.Dispatcher()
  dispatcher.map("/debug", print)
#  dispatcher.map("/volume", print_volume_handler, "Volume")
#  dispatcher.map("/logvolume", print_compute_handler, "Log volume", math.log)
  dispatcher.map("/pinout1", pinout_1_handler, "PinOut_1")
  dispatcher.map("/pinout2", pinout_2_handler, "PinOut_2")
  dispatcher.map("/pinout3", pinout_3_handler, "PinOut_3")
  dispatcher.map("/pinout4", pinout_4_handler, "PinOut_4")

#  """ # added but not tested 3 of 3 
  dispatcher.map("/pinout5", pinout_5_handler, "PinOut_5")
  dispatcher.map("/pinout6", pinout_6_handler, "PinOut_6")
  dispatcher.map("/pinout7", pinout_7_handler, "PinOut_7")
  dispatcher.map("/pinout8", pinout_8_handler, "PinOut_8")
  
  # end of added but not tested 3 of 3 """ 
예제 #35
0
import argparse
import math

from pythonosc import dispatcher
from pythonosc import osc_server


def eeg_handler(unused_addr, args, ch1, ch2, ch3, ch4):
    print("EEG (uV) per channel: ", ch1, ch2, ch3, ch4)

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip",
                        default="127.0.0.1",
                        help="The ip to listen on")
    parser.add_argument("--port",
                        type=int,
                        default=5000,
                        help="The port to listen on")
    args = parser.parse_args()

    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/debug", print)
    dispatcher.map("/muse/eeg", eeg_handler, "EEG")

    server = osc_server.ThreadingOSCUDPServer(
        (args.ip, args.port), dispatcher)
    print("Serving on {}".format(server.server_address))
    server.serve_forever()
예제 #36
0
def bind_dispatcher(dispatcher, model):
    state['model'] = model
    dispatcher.map("/start", engine_set, 'is_running', True)
    dispatcher.map("/pause", engine_set, 'is_running', False)
    dispatcher.map("/reset", server_reset)
    dispatcher.map("/reboot", server_reboot)  # event2word
    dispatcher.map("/end", shutdown)
    dispatcher.map("/quit", shutdown)
    dispatcher.map("/exit", shutdown)
    dispatcher.map("/debug", engine_print)
    dispatcher.map("/tfdebug", debug_tensorflow)
    dispatcher.map("/event", push_event)  # event2word

    dispatcher.map("/set", lambda addr, k, v: engine_set(addr, [k, v]))

    if (model):
        dispatcher.map("/sample", sample_model, model)
    
    if (state['playback'] == True):
      dispatcher.map("/play", lambda _,note: play(note))
예제 #37
0
def print_volume_handler(unused_addr, args, volume):
    print("[{0}] ~ {1}".format(args[0], volume))


def print_compute_handler(unused_addr, args, volume):
    try:
        print("[{0}] ~ {1}".format(args[0], args[1](volume)))
    except ValueError:
        pass


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip",
                        default="192.168.0.30",
                        help="The ip to listen on")
    parser.add_argument("--port",
                        type=int,
                        default=5005,
                        help="the port to listen on")
    args = parser.parse_args()

    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/filter", print)
    dispatcher.map("/volume", print_volume_handler, "Volume")
    dispatcher.map("/logvolume", print_compute_handler, "log volume", math.log)

    server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)
    print("serving on {}".format(server.server_address))
    server.serve_forever()
예제 #38
0
    for IP in wallIPs:
        # sets up arguments for the dispatcher
        wallIP = IP
        parser = argparse.ArgumentParser()
        parser.add_argument("--ip",
                            default=wallIP, help="The ip to listen to")
        parser.add_argument("--port",
                            type=int, default=port, help="The port to listen on")
        args = parser.parse_args()
        client = udp_client.SimpleUDPClient(args.ip, args.port)
        client_list.append(client)
    ctl_settings.wallSensor_clients = client_list

    # the thread that listens for the OSC messages
    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/w", print)

    # the server we're listening on
    server = osc_server.ThreadingOSCUDPServer(
        (args.ip, args.port), dispatcher)

    print("Serving on {}".format(server.server_address))

    # here we go!
    server.serve_forever()

while True:

    msg = "/w"
    for index, client in enumerate(ctl_settings.wallSensor_clients):
        client.send_message(msg, 0) # is a val needed here?
예제 #39
0
        #Sends to the Slaves
        writeNumber(int(ord(i)))
        time.sleep(.001)

    writeNumber(int(0x0A))
    print("send_run = {}".format(args[0]))


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip",
                        default="127.0.0.1",
                        help="The ip to listen on")
    parser.add_argument("--port",
                        type=int,
                        default=port,
                        help="The port to listen on")
    args = parser.parse_args()

    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/zero", send_set_zero)  #Z
    dispatcher.map("/maxspeed", send_vitesse_value)  #S
    dispatcher.map("/moveto", send_mouvement_value)  #M
    dispatcher.map("/acceleration", send_acceleration_value)  #A
    dispatcher.map("/run", send_run)  #R
    dispatcher.map("/dir", change_direction)  #D

    server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)
    print("Serving on {}".format(server.server_address))
    server.serve_forever()
예제 #40
0
if __name__ == "__main__":
  # parse input args
  parser = argparse.ArgumentParser()
  parser.add_argument("--ip",
      default="127.0.0.1", help="The ip to listen on")
  parser.add_argument("--port",
      type=int, default=12345, help="The port to listen on")
  args = parser.parse_args()
  
  if args.ip == "127.0.0.1":
    host = socket.gethostbyname(socket.gethostname())
  else:
    host = args.ip
  print("hostAddress:",host)
  
  # dispatcher
  dispatcher = dispatcher.Dispatcher()
  dispatcher.map("/debug", print)
  dispatcher.map("/volume", print_volume_handler, "Volume")
  dispatcher.map("/logvolume", print_compute_handler, "Log volume", math.log)
  dispatcher.map("/filter",print_filter,"arg1","arg2","arg3")
  dispatcher.map("/left",print_lenseValue,"L")
  dispatcher.map("/right",print_lenseValue,"R")

  # make server
  print("ip:",host," port",args.port)
  server = osc_server.ThreadingOSCUDPServer(
      (host, args.port), dispatcher)
  print("Serving on {}".format(server.server_address))
  server.serve_forever()
예제 #41
0
파일: server.py 프로젝트: natashad/Max_Ros
#   try:
#     print("[{0}] ~ {1}".format(args[0], args[1](volume)))
#   except ValueError: pass

def print_anything(unused_addr, args, param):
  print("[{0}] ~ {1}".format(args[0], param))

if __name__ == "__main__":
  parser = argparse.ArgumentParser()
  parser.add_argument("--ip",
      default="127.0.0.1", help="The ip to listen on")
  parser.add_argument("--port",
      type=int, default=5005, help="The port to listen on")
  args = parser.parse_args()

  dispatcher = dispatcher.Dispatcher()
  dispatcher.map("/debug", print)
  dispatcher.map("/transport/timesig", print_anything, "TimeSignature")
  dispatcher.map("/transport/tempo", print_anything, "Tempo")
  dispatcher.map("/transport/resolution", print_anything, "Resolution")
  dispatcher.map("/transport/units", print_anything, "Units")
  dispatcher.map("/transport/beat", print_anything, "Beat")
  dispatcher.map("/transport/bar", print_anything, "Bar")

  # dispatcher.map("/volume", print_volume_handler, "Volume")
  # dispatcher.map("/logvolume", print_compute_handler, "Log volume", math.log)

  server = osc_server.ThreadingOSCUDPServer(
      (args.ip, args.port), dispatcher)
  print("Serving on {}".format(server.server_address))
  server.serve_forever()
예제 #42
0
        sleep(msec/1000.0) #sleep for duration of note
        #stop current song if playing set to False by received "/abort" message
        if playing==False: 
            break 
    client.send_message("/finished",True) #broadcasts osc msg when finished
    
def killPlay(unused_addr): #sets playing flag to False when "/abort" received
    global playing    
    playing=False
    print("Playing stopped")

try:
    #set up dispatcher to handle incoming OSC messages
    dispatcher = dispatcher.Dispatcher() #initialise dispatcher
    #check incoming OSC messages and dispatch handlers for matching ones
    #handler for "/name" calls getData with name of ringtone as a parameter
    dispatcher.map("/name", getData,"name") #get name of ringtone to play
    #handler for "/abort" calls killPlay
    dispatcher.map("/abort",killPlay) #this dispatcher is used to abort playing
    #set up server on localhost linked to dispatcher
    server = osc_server.ThreadingOSCUDPServer( ('127.0.0.1', 8000), dispatcher)
    #print configuration data on terminal screen
    print("Serving on {}".format(server.server_address))
    print("Data broadcast to {} to port {}".format(broadcastAddress,4559))
    #start serving    
    server.serve_forever()

#allow clean ctrl-C exit
except KeyboardInterrupt:
    print("\nProgram exit")
예제 #43
0
# SET UP OSC CLIENT
parser = argparse.ArgumentParser()
parser.add_argument("--ip", default="127.0.0.1",
                    help="The ip of the OSC server")
parser.add_argument("--ClientPort", type=int, default=6449,
                    help="The port the OSC client is listening on")
parser.add_argument("--ServerPort", type=int, default=6450,
                    help="The port the OSC server is listening on")

# args = parser.parse_args()
args, unknown = parser.parse_known_args()
client = udp_client.UDPClient(args.ip, args.ClientPort)

# OSC Server
dispatcher = dispatcher.Dispatcher()
dispatcher.map("/done", print)
server = osc_server.ForkingOSCUDPServer((args.ip, args.ServerPort), dispatcher)
server_thread = threading.Thread(target=server.serve_forever)
server_thread.start()
print("Serving on {}".format(server.server_address))


# 64 is the default hop size for librosa's native 22k sampling rate.
print(str(sys.argv[0]))
print(str(sys.argv[1]))

if(sys.argv[1] is not None):
    audio_path = (str(sys.argv[1]))
else:
    print('please choose audio file to analyze')
    parser.add_argument("--touchosc-port", type=int, default=9000, help="Touch OSC port to send messages to")
    parser.add_argument("--sooperlooper-ip", default="0.0.0.0", help="SooperLooper client ip")
    parser.add_argument("--sooperlooper-port", type=int, default=9951, help="SooperLooper port to send messages to")
    argv = parser.parse_args()

    debug = argv.d

    sooperlooper_client = udp_client.UDPClient(argv.sooperlooper_ip, argv.sooperlooper_port)
    touchosc_client = udp_client.UDPClient(argv.touchosc_ip, argv.touchosc_port)

    dispatcher = dispatcher.Dispatcher()

    sooperlooper_urls = []
    for touchosc_page in touchosc_pages_range:
        url = "/{}/touchosc".format(touchosc_page)
        dispatcher.map(url, receive_from_sooperlooper)
        if debug:
            print("Registered url: {}".format(url))

        for loop in overall_loop_range:
            for hit_arg in hit_args:
                sooperlooper_urls.append("/{}{}/sl/{}/hit{}{}".format(touchosc_page, separator, loop, separator, hit_arg))

            for set_arg in set_args:
                sooperlooper_urls.append("/{}{}/sl/{}/set{}{}".format(touchosc_page, separator, loop, separator, set_arg))

    for url in sooperlooper_urls:
        dispatcher.map(url, receive_from_touchosc)
        if debug:
            print("Registered url: {}".format(url))
예제 #45
0


#if __name__ == "__main__":


parser = argparse.ArgumentParser()
parser.add_argument("--ip", default=hostip, help="The ip to listen on")
parser.add_argument("--port", type=int, default=8000, help="The port to listen on")
args = parser.parse_args()

dispatcher = dispatcher.Dispatcher()
#dispatcher.map("/b", print)
#  dispatcher.map("/b", print_volume_handler, "Volume")
#dispatcher.map("", begin_handler, "Vol")
dispatcher.map("/s", sensor_handler, "Vol")
#dispatcher.map("", end_handler, "Vol")
#  dispatcher.map("/b", print_compute_handler, "Log volume", math.log)

server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)


# to use this code, ip will be changed to server's ip address
client = udp_client.UDPClient(args.ip, args.port)


msg = osc_message_builder.OscMessageBuilder(address = "/rpiIP")
msg.add_arg(args.ip)		#need to change ip

msg=msg.build()
예제 #46
0
from pythonosc import dispatcher



client = udp_client.UDPClient("127.0.0.1", 8103)


scale = Scale()
timer = time.time()
calibrationStarted = False

def parseLightChange(index, r, g, b):
	scale.changeColor(index, [r, g, b])

dispatcher = dispatcher.Dispatcher()
dispatcher.map("/changeLight", parseLightChange)

server = osc_server.ThreadingOSCUDPServer(("127.0.0.1", 8102), dispatcher)
print("ready to serve")
serverThread = Thread(target = server.serve_forever)
print("readier")
serverThread.daemon = True
serverThread.start()
print("started")
#serverThread.run()
print("serving")


while True:
	
	if(not calibrationStarted and time.time() - timer > 5):
예제 #47
0
if __name__ == "__main__":
	clf = joblib.load('machinelearning.pkl')

	parser = argparse.ArgumentParser()
	parser.add_argument("--ip", default="127.0.0.1",
		help="the ip of the osc server")
	parser.add_argument("--port", type=int, default=8000,
		help="The port the OSC server is listening on")
	args = parser.parse_args()

	# needs to be 9000 for beginning loop
	client = udp_client.UDPClient(args.ip, 9000)

	dispatcher = dispatcher.Dispatcher()
	dispatcher.map("/skeletal_data", print_click, "Click")

	# needs to be port 9000 to receive data from cinder
	server = osc_server.ThreadingOSCUDPServer(
		(args.ip, 8000), dispatcher)
	print("Serving on {}".format(server.server_address))
	for x in range(5):
		msg = osc_message_builder.OscMessageBuilder(address="/prediction")
		msg.add_arg(random.random())
		msg = msg.build()
		client.send(msg)
		time.sleep(1)
	server.serve_forever()


예제 #48
0
    chw_calibration_mean['delta'] = delta_means
    chw_calibration_mean['theta'] = theta_means

    print ("Absolute Alpha Wave Avg: ", alpha_means)
    print ("Absolute Beta Wave Avg: ", beta_means)
    print ("Absolute Delta Wave Avg: ", delta_means)
    print ("Absolute Gamma Wave Avg: ", gamma_means)
    print ("Absolute Theta Wave Avg: ", theta_means)
    print ("Theta/Beta Ratio: ", thetaBetaRatio)
    #os._exit(0)
    finished_phase = 1

Timer(calibrate_time, exitfunc).start() # exit in 30 seconds

dispatcher = dispatcher.Dispatcher()
dispatcher.map("/debug", print)
dispatcher.map("/muse/eeg", eeg_handler, "EEG")
dispatcher.map("/muse/elements/alpha_absolute", eeg_handler1, "ALPHA")
dispatcher.map("/muse/elements/beta_absolute", eeg_handler2, "BETA")
dispatcher.map("/muse/elements/delta_absolute", eeg_handler3, "DELTA")
dispatcher.map("/muse/elements/gamma_absolute", eeg_handler4, "GAMMA")
dispatcher.map("/muse/elements/theta_absolute", eeg_handler5, "THETA")
server = osc_server.ThreadingOSCUDPServer(
    (args.ip, args.port), dispatcher)
print("Serving on {}".format(server.server_address))
server.serve_forever()

while not(finished_phase):
    print (finished_phase)
    time.sleep(1)
예제 #49
0
from pythonosc import dispatcher
from pythonosc import osc_server


def handler(addr, arg, data):
    print(addr, arg, data)


dispatcher = dispatcher.Dispatcher()
dispatcher.map("/filter",
print)

server = osc_server.ThreadingOSCUDPServer(("192.168.0.14", 5000), dispatcher)
print("Serving on {}".format(server.server_address))
server.serve_forever()
from pythonosc import osc_server

def print_volume_handler(unused_addr, args, volume):
  print("[{0}] ~ {1}".format(args[0], volume))

def print_compute_handler(unused_addr, args, volume):
  try:
    print("[{0}] ~ {1}".format(args[0], args[1](volume)))
  except ValueError: pass

if __name__ == "__main__":
  parser = argparse.ArgumentParser()
  parser.add_argument("--ip",
      default="172.16.12.168", help="The ip to listen on")
  parser.add_argument("--port",
      type=int, default=5006, help="The port to listen on")
  args = parser.parse_args()

  dispatcher = dispatcher.Dispatcher()
  dispatcher.map("/1/red", print)
  dispatcher.map("/1/green", print)
  dispatcher.map("/1/blue", print)
  dispatcher.map("/1/black1", print)
  dispatcher.map("/1/black2", print)


  server = osc_server.ThreadingOSCUDPServer(
      (args.ip, args.port), dispatcher)
  print("Serving on {}".format(server.server_address))
  server.serve_forever()
예제 #51
0
import math

from pythonosc import dispatcher
from pythonosc import osc_server

def print_volume_handler(args, volume):
  print("[{0}] ~ {1}".format(args[0], volume))

def print_compute_handler(args, volume):
  try:
    print("[{0}] ~ {1}".format(args[0], args[1](volume)))
  except ValueError: pass

if __name__ == "__main__":
  parser = argparse.ArgumentParser()
  parser.add_argument("--ip",
      default="0.0.0.0", help="The ip to listen on")
  parser.add_argument("--port",
      type=int, default=5005, help="The port to listen on")
  args = parser.parse_args()

  dispatcher = dispatcher.Dispatcher()
  dispatcher.map("/debug", print)
  dispatcher.map("/volume", print_volume_handler, "Volume")
  dispatcher.map("/logvolume", print_compute_handler, "Log volume", math.log)

  server = osc_server.ThreadingOSCUDPServer(
      (args.ip, args.port), dispatcher)
  print("Serving on {}".format(server.server_address))
  server.serve_forever()
예제 #52
0
  # Collect command line arguments
  parser = argparse.ArgumentParser()
  parser.add_argument("--ip",
      default="localhost", help="The ip to listen on")
  parser.add_argument("--port",
      type=int, default=12345, help="The port to listen on")
  parser.add_argument("--address",default="/openbci", help="address to listen to")
  parser.add_argument("--option",default="print",help="Debugger option")
  args = parser.parse_args()


  if sys.version_info.major == 3:
  # Set up necessary parameters from command line
      dispatcher = dispatcher.Dispatcher()
      if args.option=="print":
          dispatcher.map("/openbci", print_message)
          signal.signal(signal.SIGINT, exit_print)

      elif args.option=="record":
          i = 0
          while os.path.exists("osc_test%s.txt" % i):
            i += 1
          filename = "osc_test%i.txt" % i
          textfile = open(filename, "w")
          textfile.write("time,address,messages\n")
          textfile.write("-------------------------\n")
          print("Recording to %s" % filename)
          dispatcher.map("/openbci", record_to_file)
          signal.signal(signal.SIGINT, close_file)

      # Display server attributes
        print(
            "To run with a different midi port, rerun this program with the command line"
            + "argument '--midi_port 'port name goes here' ")
        print(
            "Where 'port name goes here' corresponds to one of the following recognized midi ports:"
        )
        print(mido.get_output_names())
        sys.exit()

    min_note = args.minnote
    max_note = args.maxnote
    guitar_notes = create_notebins(min_note, max_note)
    NONZERO_COEFS = args.max_notes_per_chord
    datafilename = args.datafile
    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/fftmag", fft_handler)
    dispatcher.map("/on", on_handler)
    dispatcher.map("/off", off_handler)

    try:
        data_per_fret = pickle.load(open(datafilename, "rb"))
    except:
        print("file {} not found".format(datafilename))
        sys.exit()
    data_per_fret = data_to_dict_matrix(data_per_fret)
    client = udp_client.SimpleUDPClient(args.ip, args.clientport)
    #print(data_per_fret.shape)
    server = osc_server.ThreadingOSCUDPServer((args.ip, args.serverport),
                                              dispatcher)
    print("Serving on {}".format(server.server_address))
    print("Ctrl+C to quit")
예제 #54
0
  client = udp_client.UDPClient(args.client_ip, args.client_port)

  bq = multiprocessing.Queue()
  reaktor = ReaktorDisplay(bq,client)

  def put_in_queue(_,b, value):
    """Put a named argument in the queue to be able to use a single queue."""
    bq.put([b[0], value])

  dispatcher = dispatcher.Dispatcher()
  #dispatcher.map("/debug", logging.debug)
  #dispatcher.map("/activeclip/video/position/values", print)
  for i in range(8):
    st_1 = "/pyaud/out/{}".format(i)
    st_2 = "block{}".format(i+1)
    dispatcher.map(st_1, put_in_queue, st_2)
  #dispatcher.map("/activeclip/video/position/direction", put_in_queue, "blocks")
  #dispatcher.map("/activeclip/video/position/speed", put_in_queue, "basic_Model")
  #dispatcher.map("/Do!", put_in_queue, "Do!")

  #server = osc_server.ThreadingOSCUDPServer(
  #    (args.server_ip, args.server_port), dispatcher)
  #logging.info("Serving on {}".format(server.server_address))

  # Exit thread when the main thread terminates.
  reaktor.daemon = True
  reaktor.start()
  server = osc_server.ThreadingOSCUDPServer((args.server_ip, args.server_port), dispatcher)
  server_thread = threading.Thread(target=server.serve_forever)
  server_thread.start()
  #time.sleep(5)
예제 #55
0
                ws.call(requests.GetSourcesList()),
                "\n")  # Get The list of available sources in each scene in OBS
            ScenesNames.append(name)  # Add every scene to a list of scenes

        print("\n CURRENT SCENES IN OBS", ScenesNames)

        ### OSC SETTINGS
        parser = argparse.ArgumentParser()
        parser.add_argument("--ip",
                            default="127.0.0.1",
                            help="The ip to listen on")
        parser.add_argument("--port",
                            type=int,
                            default=5005,
                            help="The port to listen on")

        args = parser.parse_args()  # parser for --ip --port arguments
        dispatcher = dispatcher.Dispatcher()

        dispatcher.map("/Scene", scene_switch, "Scene")  # OSC LISTENER
        server = osc_server.ThreadingOSCUDPServer((args.ip, args.port),
                                                  dispatcher)
        print("Serving on {}".format(server.server_address))

        server.serve_forever()

    except KeyboardInterrupt:
        pass

    ws.disconnect()
예제 #56
0
    piPort = 5000
    hostPort = 12345

    piIp = get_ip()
    ultrasonic_init()

    # sets up arguments for the dispatcher
    parser = argparse.ArgumentParser()
    parser.add_argument("--hostIp",
                        type=str, default=hostIp, help="The IP address to send back to")
    parser.add_argument("--hostPort",
                        type=int, default=hostPort, help="The port to send back to")
    args = parser.parse_args()

    # this IP is set to send out
    client = udp_client.UDPClient(args.hostIp, args.hostPort)

    # the thread that listens for the OSC messages
    dispatcher = dispatcher.Dispatcher()
    dispatcher.map(piWall, send)

    # the server we're listening on
    server = osc_server.ThreadingOSCUDPServer(
        (piIp, piPort), dispatcher)

    print("Serving on " + piIp + " (" + socket.gethostname() + ")" +  " on port " + str(piPort))
    print("Sending back to " + args.hostIp + " to port " + str(args.hostPort))

    # here we go!
    server.serve_forever()
예제 #57
0
 parser = argparse.ArgumentParser()
 parser.add_argument("--ip",
     default="127.0.0.1", help="The ip to listen on")
 parser.add_argument("--port",
     type=int, default=12345, help="The port to listen on")
 args = parser.parse_args()
 
 if args.ip == "127.0.0.1":
   host = socket.gethostbyname(socket.gethostname())
 else:
   host = args.ip
 print("hostAddress:",host)
 
 # dispatcher
 dispatcher = dispatcher.Dispatcher()
 dispatcher.map("/debug", print)
 dispatcher.map("/filter",print_filter,"arg1")
 
 #velmode = True
 #if velmode:
 #  print("velmode")
 # dispatcher.map("/vel_ccw",vel_ccw ,"L")
 # dispatcher.map("/vel_cw",vel_cw,"R")
 # dispatcher.map("/vel_forward",vel_forward,"f")
 # dispatcher.map("/vel_backward",vel_backward,"b")
 #else:
 #  print("movemode")
 dispatcher.map("/vel_ccw" ,move_ccw ,"L")
 dispatcher.map("/vel_cw"  ,move_cw,"R")
 dispatcher.map("/vel_forward",move_go,"f")
 dispatcher.map("/vel_backward",move_back,"b")
예제 #58
0
파일: posc.py 프로젝트: eriser/zynthian
import threading
from pythonosc import dispatcher
from pythonosc import osc_server
from pythonosc import osc_message_builder
from pythonosc import udp_client

ip_local="127.0.0.1"
port_local=5005
ip_remote="127.0.0.1"
port_remote=6699

lo_addr="osc.udp://[::ffff:"+ip_local+"]:"+str(port_local)

dispatcher = dispatcher.Dispatcher()
# This will print all parameters to stdout.
dispatcher.map("/broadcast", print)
dispatcher.map("/echo", print)
dispatcher.map("/paths", print)
dispatcher.map("/loadbank", print)
dispatcher.map("/bank-list", print)
dispatcher.map("/bankview", print)

client = udp_client.UDPClient(ip_remote,port_remote)

#server = ForkingOSCUDPServer((ip_local, port_local), dispatcher)
#server.serve_forever()
server = osc_server.ForkingOSCUDPServer((ip_local,port_local), dispatcher)
server_thread = threading.Thread(target=server.serve_forever)
server_thread.start()

msg = osc_message_builder.OscMessageBuilder(address = "/echo")
예제 #59
0

def eeg_handler(unused_addr, args, l_ear, EEG1, EEG2, r_ear):
    if (isRecording):
        print(EEG1, EEG2, _x, _y, _z)
        with codecs.open("C:/RecordingFiles/data.csv", 'a') as logfile:
            writer = csv.DictWriter(logfile)
            writer.writerow(EEG1, EEG2, _x, _y, _z)


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip",
                        default="localhost",
                        help="The ip to listen on")
    parser.add_argument("--port",
                        type=int,
                        default=5003,
                        help="The port to listen on")
    args = parser.parse_args()

    dispatcher = dispatcher.Dispatcher()
    dispatcher.map("/debug", print)
    dispatcher.map("/muse/eeg", eeg_handler, "EEG")
    dispatcher.map("/muse/acc", acc_handler, "ACC")
    dispatcher.map("/muse/elements/horseshoe", hs_handler, "HSH")

    server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher)
    print("Serving on {}".format(server.server_address))
    server.serve_forever()
예제 #60
0
  #    default="127.0.0.1", help="The ip to listen on")
  #parser.add_argument("--client_port",
  #    type=int, default=5005, help="The port to listen on")
  args = parser.parse_args()

  #client = udp_client.UDPClient(args.client_ip, args.client_port)

  bq = multiprocessing.Queue()
  reaktor = ReaktorDisplay(bq)

  def put_in_queue(args, value):
    """Put a named argument in the queue to be able to use a single queue."""
    bq.put([args[0], value])

  dispatcher = dispatcher.Dispatcher()
  dispatcher.map("/debug", logging.debug)
  dispatcher.map("/beating", put_in_queue, "beating")
  dispatcher.map("/blocks", put_in_queue, "blocks")
  dispatcher.map("/basic_Model", put_in_queue, "basic_Model")
  dispatcher.map("/Do!", put_in_queue, "Do!")

  server = osc_server.ThreadingOSCUDPServer(
      (args.server_ip, args.server_port), dispatcher)
  logging.info("Serving on {}".format(server.server_address))

  # Exit thread when the main thread terminates.
  reaktor.daemon = True
  reaktor.start()

  server.serve_forever()