示例#1
0
 def _set_callbacks(self, callback, error_callback):
     if callable(callback):
         self.__callback = SpecEventsDispatcher.callableObjectRef(callback)
     else:
         self.__callback = None
     if callable(error_callback):
         self.__error_callback = SpecEventsDispatcher.callableObjectRef(error_callback)
     else:
         self.__error_callback = None
示例#2
0
 def _set_callbacks(self, callback, error_callback):
     if callable(callback):
         self.__callback = SpecEventsDispatcher.callableObjectRef(callback)
     else:
         self.__callback = None
     if callable(error_callback):
         self.__error_callback = SpecEventsDispatcher.callableObjectRef(error_callback)
     else:
         self.__error_callback = None
示例#3
0
    def __init__(self, varName = None, specVersion = None, dispatchMode = UPDATEVALUE, prefix=True, callbacks={}):
        """Constructor

        Keyword arguments:
        varName -- name of the variable to monitor (defaults to None)
        specVersion -- 'host:port' string representing a Spec server to connect to (defaults to None)
        """
        self.connection = None
        self.dispatchMode = UPDATEVALUE
        self.channelName = ''
        self.__callbacks = {
          'connected': None,
          'disconnected': None,
          'update': None,
        }
        for cb_name in iter(self.__callbacks.keys()):
          if callable(callbacks.get(cb_name)):
            self.__callbacks[cb_name] = SpecEventsDispatcher.callableObjectRef(callbacks[cb_name])


        if varName is not None and specVersion is not None:
            self.connectToSpec(varName, specVersion, dispatchMode = dispatchMode, prefix=prefix)
        else:
            self.varName = None
            self.specVersion = None
示例#4
0
    def __init__(self, varName = None, specVersion = None, dispatchMode = UPDATEVALUE,
                 prefix=True, callbacks={}, timeout=None):
        """Constructor

        Keyword arguments:
        varName -- name of the variable to monitor (defaults to None)
        specVersion -- 'host:port' string representing a Spec server to connect to (defaults to None)
        """
        self.connection = None
        self.timeout = timeout
        self.dispatchMode = UPDATEVALUE
        self.channelName = ''
        self.__callbacks = {
          'connected': None,
          'disconnected': None,
          'update': None,
        }
        for cb_name in self.__callbacks.iterkeys():
          if callable(callbacks.get(cb_name)):
            self.__callbacks[cb_name] = SpecEventsDispatcher.callableObjectRef(callbacks[cb_name])


        if varName is not None and specVersion is not None:
            self.connectToSpec(varName, specVersion, dispatchMode = dispatchMode, prefix=prefix)
        else:
            self.varName = None
            self.specVersion = None
示例#5
0
    def __init__(self, specName = None, specVersion = None, callbacks={}):
        """Constructor

        Keyword arguments:
        specName -- name of the motor in Spec (defaults to None)
        specVersion -- 'host:port' string representing a Spec server to connect to (defaults to None)
        """
        self.motorState = NOTINITIALIZED
        self.limit = NOLIMIT
        self.limits = (None, None)
        self.chanNamePrefix = ''
        self.connection = None
        self.__old_position = None
        # the callbacks listed below can be set directly using the 'callbacks' keyword argument ;
        # when the event occurs, the corresponding callback will be called automatically
	self.__callbacks = {
          'connected': None,
          'disconnected': None,
          'motorLimitsChanged': None,
          'motorPositionChanged': None,
          'motorStateChanged': None
        }
        for cb_name in self.__callbacks.iterkeys():
          if callable(callbacks.get(cb_name)):
            self.__callbacks[cb_name] = SpecEventsDispatcher.callableObjectRef(callbacks[cb_name])

        if specName is not None and specVersion is not None:
            self.connectToSpec(specName, specVersion)
        else:
            self.specName = None
            self.specVersion = None
示例#6
0
    def __init__(self, conn, varname, dispatchMode=UPDATEVALUE, callbacks={}):
        """Constructor

        Keyword arguments:
        varname -- name of the variable to monitor (defaults to None)
        specapp -- 'host:port' string representing a Spec server to connect to (defaults to None)
        """
        self.__callbacks = {
            'connected': None,
            'disconnected': None,
            'update': None,
        }

        for cb_name in iter(self.__callbacks.keys()):
            if callable(callbacks.get(cb_name)):
                self.__callbacks[
                    cb_name] = SpecEventsDispatcher.callableObjectRef(
                        callbacks[cb_name])

        super(SpecVariableA, self).__init__(conn, varname)

        self._conn.connect_event('connected', self._connected)
        self._conn.connect_event('disconnected', self._disconnected)

        self.dispatchMode = dispatchMode

        if self._conn.is_connected():
            self._connected()
示例#7
0
    def __init__(self, conn, command, callbacks = {}, timeout=5):

        self.command = command
        self._conn = conn
        self.timeout = timeout

        self.reply_pending = False
        self.retvalue = None

        self.specapp = self._conn.get_specname()

        # save callbacks
        self.__callback = None
        self.__error_callback = None

        self.__callbacks = {
            'connected': None,
            'disconnected': None,
            'statusChanged': None,
        }
       
        for cb_name in iter(self.__callbacks.keys()):
            if callable(callbacks.get(cb_name)):
                self.__callbacks[cb_name] = SpecEventsDispatcher.callableObjectRef(callbacks[cb_name])

        if self.synchronous:
            self._conn.wait_connected()
        else:
            SpecEventsDispatcher.connect(self._conn, 'connected', self._connected)
            SpecEventsDispatcher.connect(self._conn, 'disconnected', self._disconnected)

            if self._conn.is_connected():
                self._connected()
示例#8
0
    def __init__(self, specName=None, specVersion=None, callbacks={}):
        """Constructor

        Keyword arguments:
        specName -- name of the motor in Spec (defaults to None)
        specVersion -- 'host:port' string representing a Spec server to connect to (defaults to None)
        """
        self.motorState = NOTINITIALIZED
        self.limit = NOLIMIT
        self.limits = (None, None)
        self.chanNamePrefix = ''
        self.connection = None
        self.__old_position = None
        # the callbacks listed below can be set directly using the 'callbacks' keyword argument ;
        # when the event occurs, the corresponding callback will be called automatically
        self.__callbacks = {
            'connected': None,
            'disconnected': None,
            'motorLimitsChanged': None,
            'motorPositionChanged': None,
            'motorStateChanged': None
        }
        for cb_name in iter(self.__callbacks.keys()):
            if callable(callbacks.get(cb_name)):
                self.__callbacks[
                    cb_name] = SpecEventsDispatcher.callableObjectRef(
                        callbacks[cb_name])

        if specName is not None and specVersion is not None:
            self.connectToSpec(specName, specVersion)
        else:
            self.specName = None
            self.specVersion = None
示例#9
0
    def __init__(self, specName=None, specVersion=None, callbacks=None, timeout=None):
        """Constructor

         Keyword arguments:
         specName -- the name of the counter in Spec (defaults to None)
         specVersion -- 'host:port' string representing a Spec server to connect to (defaults to None)
         callbacks -- dict of callbacks. key is callback name; value is a python callable
                      allowed keys: connected, disconnected, counterStateChanged, counterValueChanged
         timeout -- optional timeout for connection (defaults to None)
         """
        self.counterState = NOTINITIALIZED
        self.chanNamePrefix = ""
        self.connection = None
        self.type = UNKNOWN
        self.__old_value = None
        self.__callbacks = {
            "counterStateChanged": None,
            "counterValueChanged": None,
            "connected": None,
            "disconnected": None,
        }
        if callbacks is None:
            callbacks = {}
        for cb_name in self.__callbacks.iterkeys():
            if callable(callbacks.get(cb_name)):
                self.__callbacks[cb_name] = SpecEventsDispatcher.callableObjectRef(callbacks[cb_name])

        if specName is not None and specVersion is not None:
            self.connectToSpec(specName, specVersion, timeout)
        else:
            self.specName = None
            self.specVersion = None
示例#10
0
    def __init__(self, *args, **kwargs):
        self._reply_arrived_event = Event()
        self._last_reply = None
        self.__callback = None
        self.__error_callback = None
        self.__callbacks = {"connected": None, "disconnected": None, "statusChanged": None}
        callbacks = kwargs.get("callbacks", {})
        for cb_name in self.__callbacks.iterkeys():
            if callable(callbacks.get(cb_name)):
                self.__callbacks[cb_name] = SpecEventsDispatcher.callableObjectRef(callbacks[cb_name])

        BaseSpecCommand.__init__(self, *args, **kwargs)
示例#11
0
    def __init__(self, *args, **kwargs):
        self.__callback = None
        self.__error_callback = None
        self.__callbacks = {
          'connected': None,
          'disconnected': None,
          'statusChanged': None,
        }
        callbacks = kwargs.get("callbacks", {})
        for cb_name in iter(self.__callbacks.keys()):
          if callable(callbacks.get(cb_name)):
            self.__callbacks[cb_name] = SpecEventsDispatcher.callableObjectRef(callbacks[cb_name])

        BaseSpecCommand.__init__(self, *args, **kwargs)
示例#12
0
    def __init__(self, *args, **kwargs):
        self.__callback = None
        self.__error_callback = None
        self.__callbacks = {
          'connected': None,
          'disconnected': None,
          'statusChanged': None,
        }
        callbacks = kwargs.get("callbacks", {})
        for cb_name in self.__callbacks.iterkeys():
          if callable(callbacks.get(cb_name)):
            self.__callbacks[cb_name] = SpecEventsDispatcher.callableObjectRef(callbacks[cb_name])

        BaseSpecCommand.__init__(self, *args, **kwargs)
示例#13
0
    def __init__(self,
                 specName=None,
                 specVersion=None,
                 callbacks=None,
                 timeout=None):
        """Constructor

         Keyword arguments:
         specName -- the name of the counter in Spec (defaults to None)
         specVersion -- 'host:port' string representing a Spec server to connect to (defaults to None)
         callbacks -- dict of callbacks. key is callback name; value is a python callable
                      allowed keys: connected, disconnected, counterStateChanged, counterValueChanged
         timeout -- optional timeout for connection (defaults to None)
         """
        self.counterState = NOTINITIALIZED
        self.chanNamePrefix = ""
        self.connection = None
        self.type = UNKNOWN
        self.__old_value = None
        self.__callbacks = {
            "counterStateChanged": None,
            "counterValueChanged": None,
            "connected": None,
            "disconnected": None,
        }
        if callbacks is None:
            callbacks = {}
        for cb_name in self.__callbacks.iterkeys():
            if callable(callbacks.get(cb_name)):
                self.__callbacks[
                    cb_name] = SpecEventsDispatcher.callableObjectRef(
                        callbacks[cb_name])

        if specName is not None and specVersion is not None:
            self.connectToSpec(specName, specVersion, timeout)
        else:
            self.specName = None
            self.specVersion = None