Ejemplo n.º 1
0
    def __init__(
        self,
        name,
        conn,
        cmdInfo=None,
        callFunc=None,
        cmdClass=DevCmd,
    ):
        """!Construct a Device

        @param[in] name      a short name to identify the device
        @param[in] conn      a connection to the device; an RO.Conn.TCPDevice or similar; see below for details
        @param[in] cmdInfo   a list of (user command verb, device command verb, help string)
                    for user commands that are be sent directly to this device.
                    Specify None for the device command verb if it is the same as the user command verb
                    (strongly recommended as it is much easier for the user to figure out what is going on)
        @param[in] callFunc  function to call when state of device changes, or None if none;
                    additional functions may be added using addCallback
        @param[in] cmdClass  class for commands for this device

        conn is an RO.Conn.TCPDevice or object with these attributes (see RO.Comm.TCPConnection for descriptions):
        - connect()
        - disconnect()
        - isConnected
        - isDisconnected
        - isDone
        - didFail
        - state
        - addStateCallback(callFunc, callNow=True)
        - addReadCallback(callFunc, callNow=True)
        - writeLine(str)
        - readLine()
        """
        BaseMixin.__init__(self)
        self.name = name
        self.cmdInfo = cmdInfo or ()
        self.connReq = (False, None)
        self.conn = conn
        self.cmdClass = cmdClass
        self._state = self.Disconnected
        self._ignoreConnCallback = False  # set during connection and disconnection
        self.conn.addStateCallback(self._connCallback)
        if callFunc:
            self.addCallback(callFunc, callNow=False)
Ejemplo n.º 2
0
    def __init__(self,
        name,
        conn,
        cmdInfo = None,
        callFunc = None,
        cmdClass = DevCmd,
    ):
        """!Construct a Device

        @param[in] name      a short name to identify the device
        @param[in] conn      a connection to the device; an RO.Conn.TCPDevice or similar; see below for details
        @param[in] cmdInfo   a list of (user command verb, device command verb, help string)
                    for user commands that are be sent directly to this device.
                    Specify None for the device command verb if it is the same as the user command verb
                    (strongly recommended as it is much easier for the user to figure out what is going on)
        @param[in] callFunc  function to call when state of device changes, or None if none;
                    additional functions may be added using addCallback
        @param[in] cmdClass  class for commands for this device

        conn is an RO.Conn.TCPDevice or object with these attributes (see RO.Comm.TCPConnection for descriptions):
        - connect()
        - disconnect()
        - isConnected
        - isDisconnected
        - isDone
        - didFail
        - state
        - addStateCallback(callFunc, callNow=True)
        - addReadCallback(callFunc, callNow=True)
        - writeLine(str)
        - readLine()
        """
        BaseMixin.__init__(self)
        self.name = name
        self.cmdInfo = cmdInfo or ()
        self.connReq = (False, None)
        self.conn = conn
        self.cmdClass = cmdClass
        self._state = self.Disconnected
        self._ignoreConnCallback = False # set during connection and disconnection
        self.conn.addStateCallback(self._connCallback)
        if callFunc:
            self.addCallback(callFunc, callNow=False)
Ejemplo n.º 3
0
    def __init__(self,
        name,
        conn,
        cmdInfo = None,
        callFunc = None,
        cmdClass = DevCmd,
    ):
        """Construct a Device

        Inputs:
        - name      a short name to identify the device
        - conn      a connection to the device; see below for details
        - cmdInfo   a list of (user command verb, device command verb, help string)
                    for user commands that are be sent directly to this device.
                    Specify None for the device command verb if it is the same as the user command verb
                    (strongly recommended as it is much easier for the user to figure out what is going on)
        - callFunc  function to call when state of device changes, or None if none;
                    additional functions may be added using addCallback
        - cmdClass  class for commands for this device

        conn is an object implementing these methods:
        - connect()
        - disconnect()
        - addStateCallback(callFunc, callNow=True)
        - getFullState(): Returns the current state as a tuple:
            - state: a numeric value; named constants are available
            - stateStr: a short string describing the state
            - reason: the reason for the state ("" if none)
        - isConnected(): return True if connected, False otherwise
        - isDone(): return True if fully connected or disconnected
        - addReadCallback(callFunc, callNow=True)
        - writeLine(str)
        - readLine()
        """
        BaseMixin.__init__(self)
        self.name = name
        self.cmdInfo = cmdInfo or()
        self.connReq = (False, None)
        self.conn = conn
        self.cmdClass = cmdClass
        if callFunc:
            self.addCallback(callFunc, callNow=False)