import logging
import time

from abc import ABCMeta, abstractmethod

from jbusnet.transition import Transition
from jbusnet.request import Request


_logger = logging.getLogger(__name__)


class BaseClient(metaclass=ABCMeta):
    @abstractmethod
    def read_holding_registers():
        pass
    
    @abstractmethod
    def read_input_registers():
        pass


class Client(BaseClient):
    def __init__(self, host, port):
        self.host = host
        self.port = port
        self.transition =  Transition(host=host, port=port)
    
    def connect(self):
        """
        init a socket client
        """
        return self.transition.connect()
    
    def read_holding_registers(self, unit, address, length):
        """
        read holding registers from jbus slave
        """
        # generate jbus request 
        request = Request(function_code=3, unit=unit, address=address, length=length)
        
        _logger.debug("Request is {}".format(request.bytes))

        # generate jbus response
        response = self.transition.execute(request)
        return response
    
    def read_input_registers(self, unit, address, length):
        """
        read holding registers from jbus slave
        """
        # generate jbus request 
        request = Request(function_code=4, unit=unit, address=address, length=length)
        
        _logger.debug("Request is {}".format(request.bytes))

        # generate jbus response
        response = self.transition.execute(request)
        return response





5a5ea3a2c1e781c843e53d3600cd2aa1d302d1f2
<mask token>


class BaseClient(metaclass=ABCMeta):
    <mask token>

    @abstractmethod
    def read_input_registers():
        pass


class Client(BaseClient):

    def __init__(self, host, port):
        self.host = host
        self.port = port
        self.transition = Transition(host=host, port=port)

    def connect(self):
        """
        init a socket client
        """
        return self.transition.connect()

    def read_holding_registers(self, unit, address, length):
        """
        read holding registers from jbus slave
        """
        request = Request(function_code=3, unit=unit, address=address,
            length=length)
        _logger.debug('Request is {}'.format(request.bytes))
        response = self.transition.execute(request)
        return response

    def read_input_registers(self, unit, address, length):
        """
        read holding registers from jbus slave
        """
        request = Request(function_code=4, unit=unit, address=address,
            length=length)
        _logger.debug('Request is {}'.format(request.bytes))
        response = self.transition.execute(request)
        return response

<mask token>


class BaseClient(metaclass=ABCMeta):

    @abstractmethod
    def read_holding_registers():
        pass

    @abstractmethod
    def read_input_registers():
        pass


class Client(BaseClient):

    def __init__(self, host, port):
        self.host = host
        self.port = port
        self.transition = Transition(host=host, port=port)

    def connect(self):
        """
        init a socket client
        """
        return self.transition.connect()

    def read_holding_registers(self, unit, address, length):
        """
        read holding registers from jbus slave
        """
        request = Request(function_code=3, unit=unit, address=address,
            length=length)
        _logger.debug('Request is {}'.format(request.bytes))
        response = self.transition.execute(request)
        return response

    def read_input_registers(self, unit, address, length):
        """
        read holding registers from jbus slave
        """
        request = Request(function_code=4, unit=unit, address=address,
            length=length)
        _logger.debug('Request is {}'.format(request.bytes))
        response = self.transition.execute(request)
        return response

<mask token>
_logger = logging.getLogger(__name__)


class BaseClient(metaclass=ABCMeta):

    @abstractmethod
    def read_holding_registers():
        pass

    @abstractmethod
    def read_input_registers():
        pass


class Client(BaseClient):

    def __init__(self, host, port):
        self.host = host
        self.port = port
        self.transition = Transition(host=host, port=port)

    def connect(self):
        """
        init a socket client
        """
        return self.transition.connect()

    def read_holding_registers(self, unit, address, length):
        """
        read holding registers from jbus slave
        """
        request = Request(function_code=3, unit=unit, address=address,
            length=length)
        _logger.debug('Request is {}'.format(request.bytes))
        response = self.transition.execute(request)
        return response

    def read_input_registers(self, unit, address, length):
        """
        read holding registers from jbus slave
        """
        request = Request(function_code=4, unit=unit, address=address,
            length=length)
        _logger.debug('Request is {}'.format(request.bytes))
        response = self.transition.execute(request)
        return response

import logging
import time
from abc import ABCMeta, abstractmethod
from jbusnet.transition import Transition
from jbusnet.request import Request
_logger = logging.getLogger(__name__)


class BaseClient(metaclass=ABCMeta):

    @abstractmethod
    def read_holding_registers():
        pass

    @abstractmethod
    def read_input_registers():
        pass


class Client(BaseClient):

    def __init__(self, host, port):
        self.host = host
        self.port = port
        self.transition = Transition(host=host, port=port)

    def connect(self):
        """
        init a socket client
        """
        return self.transition.connect()

    def read_holding_registers(self, unit, address, length):
        """
        read holding registers from jbus slave
        """
        request = Request(function_code=3, unit=unit, address=address,
            length=length)
        _logger.debug('Request is {}'.format(request.bytes))
        response = self.transition.execute(request)
        return response

    def read_input_registers(self, unit, address, length):
        """
        read holding registers from jbus slave
        """
        request = Request(function_code=4, unit=unit, address=address,
            length=length)
        _logger.debug('Request is {}'.format(request.bytes))
        response = self.transition.execute(request)
        return response

import logging
import time

from abc import ABCMeta, abstractmethod

from jbusnet.transition import Transition
from jbusnet.request import Request


_logger = logging.getLogger(__name__)


class BaseClient(metaclass=ABCMeta):
    @abstractmethod
    def read_holding_registers():
        pass
    
    @abstractmethod
    def read_input_registers():
        pass


class Client(BaseClient):
    def __init__(self, host, port):
        self.host = host
        self.port = port
        self.transition =  Transition(host=host, port=port)
    
    def connect(self):
        """
        init a socket client
        """
        return self.transition.connect()
    
    def read_holding_registers(self, unit, address, length):
        """
        read holding registers from jbus slave
        """
        # generate jbus request 
        request = Request(function_code=3, unit=unit, address=address, length=length)
        
        _logger.debug("Request is {}".format(request.bytes))

        # generate jbus response
        response = self.transition.execute(request)
        return response
    
    def read_input_registers(self, unit, address, length):
        """
        read holding registers from jbus slave
        """
        # generate jbus request 
        request = Request(function_code=4, unit=unit, address=address, length=length)
        
        _logger.debug("Request is {}".format(request.bytes))

        # generate jbus response
        response = self.transition.execute(request)
        return response




