def on_token_placed(self, instance, value): self.tk_placed = value # Send OSC message ################################################ # Simplified Tuio Message # s Session ID (temporary object ID) int32 - knob_id # i Class ID (e.g. marker ID) int32 - pattern_id # x, y, z Position float32, range 0...1 - knob position # a, b, c Angle float32, range 0..2PI - knob angle # P Free parameter - token_placed s = self.knob_id i = self.pattern_id x = self.token_pos[0] y = self.token_pos[1] z = 0 a = -1 p = True print [s,i,x,y,z,a,p] oscAPI.sendMsg('/tuios/tok', [s,i,x,y,z,a,p], ipAddr= self.ip, port= self.port)
def setup_service(): Logger.info('service: setup_service') setup_logger('mi') # add this dir to module search path app_dir = os.path.join(mi2app_utils.get_files_dir(), "app") sys.path.append(os.path.join(app_dir, 'service')) Logger.info('service: sys path added: ' + str(sys.path)) # setup control and listen to osc signal control = Control() Logger.info('service: control created' + repr(control)) osc.init() OSCID = osc.listen(port=OSCConfig.service_port) # def dummy_callback(msg, *args): # Logger.info('service: dummy callback: ' + str(msg)) # osc.bind(OSCID, dummy_callback, OSCConfig.control_addr) osc.bind(OSCID, control.osc_callback, OSCConfig.control_addr) Logger.info('service: osc setup, id: ' + OSCID) gps_provider = GpsListener(on_gps) gps_provider.start() osc.sendMsg(OSCConfig.control_addr, dataArray=[ 'service ready', ], port=OSCConfig.app_port) Logger.info('service SEND>: service ready msg sent') while True: osc.readQueue(thread_id=OSCID) time.sleep(.5)
def on_knob(self, value, pattern_id): self.knob_angle = value # update the rotation of the scatter widget self.obj.rotation = self.knob_angle # Send OSC message ################################################ # Simplified Tuio Message # s Session ID (temporary object ID) int32 - knob_id # i Class ID (e.g. marker ID) int32 - pattern_id # x, y, z Position float32 - knob position # a Angle float32 - knob angle # p Free parameter - token_placed s = self.knob_id i = self.pattern_id x = self.token_pos[0] y = self.token_pos[1] z = 0 a = self.knob_angle p = False #Token placed print [s,i,x,y,z,a,p] oscAPI.sendMsg('/tuios/tok', [s,i,x,y,z,a,p], ipAddr= self.ip, port= self.port)
def sendMessage(self, tokenNum): # ip = '198.21.242.1' #ip = '192.168.43.151' ip = '198.21.199.177' port = 5000 print("Sending Message! " + tokenNum) oscAPI.sendMsg( '0', [tokenNum], ipAddr= ip, port= port)
def send(self, widget_id, value): '''Send the passed value over network to all devices in the same session :attr:`widget_id` it refers to the assigned id of given widget producing the value. :attr:`value` can be any type of value accepted from OSC standard. ''' completePath = "/" + str(self.session_id) + "/" + str(widget_id) oscAPI.sendMsg(completePath, [value], '255.255.255.255', 57120)
def send(self, popup=-1): x = self.renderer.rotx.angle y = self.renderer.roty.angle z = self.renderer.scale.xyz[0] print "sending:", x, y, z, popup oscAPI.sendMsg('/tuios/intra', [x, y, z, popup], ipAddr=self.sendip, port=5000)
def thread_target(msg): # wait for service ready event self._service_ready.wait() osc.sendMsg(OSCConfig.control_addr, dataArray=[ str(msg), ], port=OSCConfig.service_port) Logger.info('coordinator SEND>: control msg: ' + msg)
def send_osc_message(osc_address, msg, typehint=None): app = kivy.app.App.get_running_app() ip_address = app.osc_ip_address port = int(app.osc_port) try: oscAPI.sendMsg( osc_address, dataArray=msg, ipAddr=ip_address, port=port, typehint=typehint) print "\nsent:" print msg print "\nto: ", ip_address, port, osc_address if len(msg) > 12: long_flash_osc_indicator_trigger() else: short_flash_osc_indicator_trigger() except Exception as e: print "Problem sending OSC message" print e #The oscAPI creates a threading lock when sending an OSC message. #If there is an exception this lock isn't released and the application will hang #the next time an OSC message is sent because oscAPI will attempt to acquire a lock #and threading.Lock() will block. oscAPI.oscLock.release() for i in range(2): Clock.schedule_once(partial(set_osc_indicator, -1), i) Clock.schedule_once(partial(set_osc_indicator, 0), (i + 0.5)) if _DEBUG: raise(e)
def pressBtn(self, event): print("button touched") self.label.text = "------------" #Adding 1 to counter #self.counter += 1 # Send OSC message oscAPI.sendMsg('0', [90], ipAddr=self.ip, port=self.port) oscAPI.sendMsg('0', [360], ipAddr=self.ip, port=self.port) oscAPI.sendMsg('0', [127], ipAddr=self.ip, port=self.port)
def coord_callback(event, *args): # send event data to event address and app port, # this will be received by screens' coordinator Logger.info('control SEND>: event msg: ' + str(event)) osc.sendMsg(OSCConfig.event_addr, dataArray=[str(event),], port=OSCConfig.app_port)
def sendVid(self, start, stop, value): oscAPI.sendMsg('/tuios/video', [start, stop, value], ipAddr=self.controller.sendip, port=5000)