def build_session_select(self):
     if self.session_select is not None:
         return
     self.iOsc.reset_interface(client=self)
     self.session_select = SessionSelect(iOsc=self.iOsc, client=self)
     self.session_select.bind(selection=self.on_session_selected)
Esempio n. 2
0
 def build_session_select(self):
     if self.session_select is not None:
         return
     self.iOsc.reset_interface(client=self)
     self.session_select = SessionSelect(iOsc=self.iOsc, client=self)
     self.session_select.bind(selection=self.on_session_selected)
class iOscClient(OSCBaseObject):
    def __init__(self, **kwargs):
        self.iOsc = kwargs.get('iOsc')
        self.osc_io = self.iOsc.comm.osc_io
        client_obj = kwargs.get('client')
        kwargs.setdefault('osc_parent_node', self.iOsc.osc_node)
        kwargs.setdefault('osc_address', client_obj.name)
        kwargs.setdefault('ParentEmissionThread',
                          self.iOsc.ParentEmissionThread)
        self.session_select_remove_thread = None
        super(iOscClient, self).__init__(**kwargs)
        print 'IOSC_CLIENT: ', client_obj.name, self.osc_node.name, self.osc_node.get_full_path(
        )
        for key in client_obj.Properties.iterkeys():
            setattr(self, key, getattr(client_obj, key))
        client_obj.bind(property_changed=self.on_client_obj_property_changed)
        self.osc_name = self.client_obj.osc_name
        self.Menu = None
        self.session_select = None

    @property
    def client_obj(self):
        return self.osc_io.clients.get(self.name)

    def unlink(self):
        self.deactivate()
        super(iOscClient, self).unlink()

    def activate(self):
        sessions = self.osc_io.discovered_sessions
        if len(sessions) == 1:
            self.build_menu()
        elif self.osc_io.isRingMaster:
            self.build_session_select()

    def deactivate(self):
        if self.Menu is not None:
            self.Menu.unlink()
            self.Menu = None
        if self.session_select is not None:
            self.session_select.unlink()
            self.session_select = None

    def build_menu(self):
        if self.Menu is not None:
            return
        self.iOsc.reset_interface(client=self)
        self.Menu = PageMenu(iOsc=self.iOsc, client=self)

    def build_session_select(self):
        if self.session_select is not None:
            return
        self.iOsc.reset_interface(client=self)
        self.session_select = SessionSelect(iOsc=self.iOsc, client=self)
        self.session_select.bind(selection=self.on_session_selected)

    def on_session_selected(self, **kwargs):
        session = kwargs.get('value')
        self.session_select.unlink()
        self.session_select = None
        self.client_obj.session_name = session

    def on_client_obj_property_changed(self, **kwargs):
        prop = kwargs.get('Property')
        value = kwargs.get('value')
        setattr(self, prop.name, value)
        if prop.name == 'session_name':
            #if self.osc_io.isMaster and self.client_obj.session_name == self.GLOBAL_CONFIG['session_name']:
            if self.osc_io.discovered_sessions[
                    value].master == self.osc_io.local_client:
                self.build_menu()
Esempio n. 4
0
class iOscClient(OSCBaseObject):
    def __init__(self, **kwargs):
        self.iOsc = kwargs.get('iOsc')
        self.osc_io = self.iOsc.comm.osc_io
        client_obj = kwargs.get('client')
        kwargs.setdefault('osc_parent_node', self.iOsc.osc_node)
        kwargs.setdefault('osc_address', client_obj.name)
        kwargs.setdefault('ParentEmissionThread', self.iOsc.ParentEmissionThread)
        self.session_select_remove_thread = None
        super(iOscClient, self).__init__(**kwargs)
        print 'IOSC_CLIENT: ', client_obj.name, self.osc_node.name, self.osc_node.get_full_path()
        for key in client_obj.Properties.iterkeys():
            setattr(self, key, getattr(client_obj, key))
        client_obj.bind(property_changed=self.on_client_obj_property_changed)
        self.osc_name = self.client_obj.osc_name
        self.Menu = None
        self.session_select = None
        
    @property
    def client_obj(self):
        return self.osc_io.clients.get(self.name)
        
    def unlink(self):
        self.deactivate()
        super(iOscClient, self).unlink()
        
    def activate(self):
        sessions = self.osc_io.discovered_sessions
        if len(sessions) == 1:
            self.build_menu()
        elif self.osc_io.isRingMaster:
            self.build_session_select()
        
    def deactivate(self):
        if self.Menu is not None:
            self.Menu.unlink()
            self.Menu = None
        if self.session_select is not None:
            self.session_select.unlink()
            self.session_select = None

    def build_menu(self):
        if self.Menu is not None:
            return
        self.iOsc.reset_interface(client=self)
        self.Menu = PageMenu(iOsc=self.iOsc, client=self)
        
    def build_session_select(self):
        if self.session_select is not None:
            return
        self.iOsc.reset_interface(client=self)
        self.session_select = SessionSelect(iOsc=self.iOsc, client=self)
        self.session_select.bind(selection=self.on_session_selected)
        
    def on_session_selected(self, **kwargs):
        session = kwargs.get('value')
        self.session_select.unlink()
        self.session_select = None
        self.client_obj.session_name = session
        
    def on_client_obj_property_changed(self, **kwargs):
        prop = kwargs.get('Property')
        value = kwargs.get('value')
        setattr(self, prop.name, value)
        if prop.name == 'session_name':
            #if self.osc_io.isMaster and self.client_obj.session_name == self.GLOBAL_CONFIG['session_name']:
            if self.osc_io.discovered_sessions[value].master == self.osc_io.local_client:
                self.build_menu()