|
31 | 31 | # For asyncio the actual client is returned and event loop is asyncio loop |
32 | 32 |
|
33 | 33 | """ |
34 | | -from __future__ import unicode_literals |
35 | | -from __future__ import absolute_import |
36 | | - |
37 | | -import logging |
38 | | - |
39 | | -from pymodbus.client.sync import BaseModbusClient |
40 | | - |
41 | | -from pymodbus.constants import Defaults |
42 | | - |
43 | | -from pymodbus.factory import ClientDecoder |
44 | | -from pymodbus.transaction import ModbusSocketFramer |
45 | | - |
46 | | - |
47 | | -LOGGER = logging.getLogger(__name__) |
48 | | - |
49 | | - |
50 | | -class BaseAsyncModbusClient(BaseModbusClient): |
51 | | - """ |
52 | | - This represents the base ModbusAsyncClient. |
53 | | - """ |
54 | | - |
55 | | - def __init__(self, framer=None, **kwargs): |
56 | | - """ Initializes the framer module |
57 | | -
|
58 | | - :param framer: The framer to use for the protocol. Default: |
59 | | - ModbusSocketFramer |
60 | | - :type framer: pymodbus.transaction.ModbusSocketFramer |
61 | | - """ |
62 | | - self._connected = False |
63 | | - |
64 | | - super(BaseAsyncModbusClient, self).__init__( |
65 | | - framer or ModbusSocketFramer(ClientDecoder()), **kwargs |
66 | | - ) |
67 | | - |
68 | | - |
69 | | -class AsyncModbusClientMixin(BaseAsyncModbusClient): |
70 | | - """ |
71 | | - Async Modbus client mixing for UDP and TCP clients |
72 | | - """ |
73 | | - def __init__(self, host="127.0.0.1", port=Defaults.Port, framer=None, |
74 | | - source_address=None, timeout=None, **kwargs): |
75 | | - """ |
76 | | - Initializes a Modbus TCP/UDP async client |
77 | | - :param host: Host IP address |
78 | | - :param port: Port |
79 | | - :param framer: Framer to use |
80 | | - :param source_address: Specific to underlying client being used |
81 | | - :param timeout: Timeout in seconds |
82 | | - :param kwargs: Extra arguments |
83 | | - """ |
84 | | - super(AsyncModbusClientMixin, self).__init__(framer=framer, **kwargs) |
85 | | - self.host = host |
86 | | - self.port = port |
87 | | - self.source_address = source_address or ("", 0) |
88 | | - self.timeout = timeout if timeout is not None else Defaults.Timeout |
89 | | - |
90 | | - |
91 | | -class AsyncModbusSerialClientMixin(BaseAsyncModbusClient): |
92 | | - """ |
93 | | - Async Modbus Serial Client Mixing |
94 | | - """ |
95 | | - def __init__(self, framer=None, port=None, **kwargs): |
96 | | - """ |
97 | | - Initializes a Async Modbus Serial Client |
98 | | - :param framer: Modbus Framer |
99 | | - :param port: Serial port to use |
100 | | - :param kwargs: Extra arguments if any |
101 | | - """ |
102 | | - super(AsyncModbusSerialClientMixin, self).__init__(framer=framer) |
103 | | - self.port = port |
104 | | - self.serial_settings = kwargs |
105 | | - |
| 34 | +from pymodbus.client.async.deprecated.async import * |
0 commit comments