예제 #1
0
 def _create_protocol(self):
     """
     Factory function to create initialized protocol instance.
     """
     protocol = self.protocol_class(framer=self.framer, **self._proto_args)
     protocol.transaction = FifoTransactionManager(self)
     protocol.factory = self
     return protocol
예제 #2
0
 def __init__(self, framer=None, **kwargs):
     self._connected = False
     self.framer = framer or ModbusSocketFramer(ClientDecoder())
     if isinstance(self.framer, type):
         # Framer class not instance
         self.framer = self.framer(ClientDecoder(), client=None)
     if isinstance(self.framer, ModbusSocketFramer):
         self.transaction = DictTransactionManager(self, **kwargs)
     else:
         self.transaction = FifoTransactionManager(self, **kwargs)
예제 #3
0
    def __init__(self, framer, **kwargs):
        ''' Initialize a client instance

        :param framer: The modbus framer implementation to use
        '''
        self.framer = framer
        if isinstance(self.framer, ModbusSocketFramer):
            self.transaction = DictTransactionManager(self, **kwargs)
        else:
            self.transaction = FifoTransactionManager(self, **kwargs)
예제 #4
0
파일: async.py 프로젝트: vincsdev/pymodbus
    def __init__(self, framer=None):
        ''' Initializes the framer module

        :param framer: The framer to use for the protocol
        '''
        self.framer = framer or ModbusSocketFramer(ClientDecoder())
        if isinstance(self.framer, ModbusSocketFramer):
            self.transaction = DictTransactionManager(self)
        else:
            self.transaction = FifoTransactionManager(self)
예제 #5
0
    def __init__(self, framer=None, **kwargs):
        """ Initializes the framer module

        :param framer: The framer to use for the protocol
        """
        deprecated(self.__class__.__name__)
        self.framer = framer or ModbusSocketFramer(ClientDecoder())
        if isinstance(self.framer, ModbusSocketFramer):
            self.transaction = DictTransactionManager(self, **kwargs)
        else:
            self.transaction = FifoTransactionManager(self, **kwargs)
예제 #6
0
    def __init__(self, framer, **kwargs):
        """ Initialize a client instance

        :param framer: The modbus framer implementation to use
        """
        self.framer = framer
        if isinstance(self.framer, ModbusSocketFramer):
            self.transaction = DictTransactionManager(self, **kwargs)
        else:
            self.transaction = FifoTransactionManager(self, **kwargs)
        self._debug = False
        self._debugfd = None
예제 #7
0
    def connectionMade(self):
        # 初始化Framer
        self.framer = self.factory.framer
        # 初始化TransactionT
        if isinstance(self.framer, ModbusSocketFramer):
            self.transaction = DictTransactionManager(self)
        else:
            self.transaction = FifoTransactionManager(self)

        self._addr = '%s:%d' % (self.transport.getPeer().host,
                                self.transport.getPeer().port)
        self.factory.addClient(self._addr, self, None)
        log.debug("Client Connected [%s]" % self._addr)
        self._connected = True
예제 #8
0
    def __init__(self, framer=None, **kwargs):
        ''' Initializes the framer module

        :param framer: The framer to use for the protocol
        '''
        self._connected = False
        self.framer = framer or ModbusSocketFramer(ClientDecoder())
        if isinstance(self.framer, type):
            # Framer class not instance
            self.framer = self.framer(ClientDecoder(), client=None)
        if isinstance(self.framer, ModbusSocketFramer):
            self.transaction = DictTransactionManager(self, **kwargs)
        else:
            self.transaction = FifoTransactionManager(self, **kwargs)