Ejemplo n.º 1
0
    def connectToSpec(self, specVersion, timeout=200):
        if self.connection is not None:
            SpecEventsDispatcher.disconnect(self.connection, 'connected', self.connected)
            SpecEventsDispatcher.disconnect(self.connection, 'disconnected', self.disconnected)

        self.connection = SpecConnectionsManager.SpecConnectionsManager().getConnection(specVersion)
        self.specVersion = specVersion

        SpecEventsDispatcher.connect(self.connection, 'connected', self.connected)
        cb = self.__callbacks.get("connected")
        if cb is not None:
          cb = cb()
          SpecEventsDispatcher.connect(self.connection, 'connected', cb)
        SpecEventsDispatcher.connect(self.connection, 'disconnected', self.disconnected)
        cb = self.__callbacks.get("disconnected")
        if cb is not None:
          cb = cb()
          SpecEventsDispatcher.connect(self.connection, 'disconnected', cb)
        self.connection.registerChannel("status/ready", self.statusChanged)
        cb = self.__callbacks.get("statusChanged")
        if cb is not None:
          cb = cb()
          SpecEventsDispatcher.connect(self.connection, 'statusChanged', cb)

        if self.connection.isSpecConnected():
            self.connected()
        else:
            try:
              SpecWaitObject.waitConnection(self.connection, timeout)
            except SpecClientTimeoutError:
              pass
            SpecEventsDispatcher.dispatch()
Ejemplo n.º 2
0
    def connectToSpec(self, specVersion, timeout=None):
        if self.connection is not None:
            SpecEventsDispatcher.disconnect(self.connection, 'connected', self._connected)
            SpecEventsDispatcher.disconnect(self.connection, 'disconnected', self._disconnected)

        self.connection = SpecConnectionsManager.SpecConnectionsManager().getConnection(specVersion)
        self.specVersion = specVersion

        SpecEventsDispatcher.connect(self.connection, 'connected', self._connected)
        SpecEventsDispatcher.connect(self.connection, 'disconnected', self._disconnected)

        if self.connection.isSpecConnected():
            self._connected()
Ejemplo n.º 3
0
    def connectToSpec(self, specVersion, timeout=None):
        if self.connection is not None:
            SpecEventsDispatcher.disconnect(self.connection, "connected", self._connected)
            SpecEventsDispatcher.disconnect(self.connection, "disconnected", self._disconnected)

        self.connection = SpecConnectionsManager.SpecConnectionsManager().getConnection(specVersion)
        self.specVersion = specVersion

        SpecEventsDispatcher.connect(self.connection, "connected", self._connected)
        SpecEventsDispatcher.connect(self.connection, "disconnected", self._disconnected)

        if self.connection.isSpecConnected():
            self._connected()
Ejemplo n.º 4
0
    def unregister(self, chan_name, receiver_slot=None):
        """Unregister a channel

        Arguments:
        chan_name -- a string representing the channel to unregister, i.e. 'var/toto'
        """
        chan_name = str(chan_name)

        if chan_name in self.reg_channels:
            channel = self.reg_channels[chan_name]
            if receiver_slot:
                SpecEventsDispatcher.disconnect(channel, 'valueChanged',
                                                receiver_slot)
            else:
                self.reg_channels[chan_name].unregister()
                del self.reg_channels[chan_name]
Ejemplo n.º 5
0
    def connectToSpec(self, specVersion, timeout=200):
        if self.connection is not None:
            SpecEventsDispatcher.disconnect(self.connection, 'connected', self._connected)
            SpecEventsDispatcher.disconnect(self.connection, 'disconnected', self._disconnected)

        self.connection = SpecConnectionsManager().getConnection(specVersion)
        self.specVersion = specVersion

        SpecEventsDispatcher.connect(self.connection, 'connected', self._connected)
        SpecEventsDispatcher.connect(self.connection, 'disconnected', self._disconnected)

        if self.connection.isSpecConnected():
            self._connected()
        else:
            try:
              waitConnection(self.connection, timeout)
            except SpecClientTimeoutError:
              pass
            SpecEventsDispatcher.dispatch()
Ejemplo n.º 6
0
    def unregisterChannel(self, chanName, receiverSlot=None):
        """Unregister a channel

        Arguments:
        chanName -- a string representing the channel to unregister, i.e. 'var/toto'
        """
        chanName = str(chanName)

        if chanName in self.registeredChannels:
            channel = self.registeredChannels[chanName]
            if receiverSlot:
                SpecEventsDispatcher.disconnect(channel, 'valueChanged',
                                                receiverSlot)
            else:
                self.registeredChannels[chanName].unregister()
                del self.registeredChannels[chanName]

        listreg = [
            ky for ky in self.registeredChannels.keys()
            if not ky.startswith('motor')
        ]