Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare refactor messages. #2416

Merged
merged 13 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified doc/source/_static/examples.tgz
Binary file not shown.
Binary file modified doc/source/_static/examples.zip
Binary file not shown.
20 changes: 1 addition & 19 deletions doc/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,28 +210,10 @@ Source: :github:`examples/contrib/solar.py`
:noindex:


Redis datastore
^^^^^^^^^^^^^^^
Source: :github:`examples/contrib/redis_datastore.py`

.. automodule:: examples.contrib.redis_datastore
:undoc-members:
:noindex:


Serial Forwarder
^^^^^^^^^^^^^^^^
Source: :github:`examples/contrib/serial_forwarder.py`

.. automodule:: examples.contrib.serial_forwarder
:undoc-members:
:noindex:


Sqlalchemy datastore
^^^^^^^^^^^^^^^^^^^^
Source: :github:`examples/contrib/sql_datastore.py`

.. automodule:: examples.contrib.sql_datastore
:undoc-members:
:noindex:
:noindex:
7 changes: 1 addition & 6 deletions doc/source/library/pymodbus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ PDU classes
:undoc-members:
:show-inheritance:

.. automodule:: pymodbus.pdu.bit_read_message
:members:
:undoc-members:
:show-inheritance:

.. automodule:: pymodbus.pdu.bit_write_message
.. automodule:: pymodbus.pdu.bit_message
:members:
:undoc-members:
:show-inheritance:
Expand Down
6 changes: 3 additions & 3 deletions examples/client_custom_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pymodbus import FramerType
from pymodbus.client import AsyncModbusTcpClient as ModbusClient
from pymodbus.pdu import ModbusExceptions, ModbusPDU
from pymodbus.pdu.bit_read_message import ReadCoilsRequest
from pymodbus.pdu.bit_message import ReadCoilsRequest


# --------------------------------------------------------------------------- #
Expand All @@ -39,7 +39,7 @@ class CustomModbusPDU(ModbusPDU):
def __init__(self, values=None, slave=1, transaction=0, skip_encode=False):
"""Initialize."""
super().__init__()
super().setData(slave, transaction, skip_encode)
super().setBaseData(slave, transaction, skip_encode)
self.values = values or []

def encode(self):
Expand Down Expand Up @@ -72,7 +72,7 @@ class CustomRequest(ModbusPDU):
def __init__(self, address=None, slave=1, transaction=0, skip_encode=False):
"""Initialize."""
super().__init__()
super().setData(slave, transaction, skip_encode)
super().setBaseData(slave, transaction, skip_encode)
self.address = address
self.count = 16

Expand Down
11 changes: 5 additions & 6 deletions pymodbus/client/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from enum import Enum
from typing import Generic, TypeVar

import pymodbus.pdu.bit_read_message as pdu_bit_read
import pymodbus.pdu.bit_write_message as pdu_bit_write
import pymodbus.pdu.bit_message as pdu_bit
import pymodbus.pdu.diag_message as pdu_diag
import pymodbus.pdu.file_message as pdu_file_msg
import pymodbus.pdu.mei_message as pdu_mei
Expand Down Expand Up @@ -71,7 +70,7 @@ def read_coils(self, address: int, count: int = 1, slave: int = 1, no_response_e
:param no_response_expected: (optional) The client will not expect a response to the request
:raises ModbusException:
"""
return self.execute(no_response_expected, pdu_bit_read.ReadCoilsRequest(address=address, count=count, slave=slave))
return self.execute(no_response_expected, pdu_bit.ReadCoilsRequest(address=address, count=count, slave=slave))

def read_discrete_inputs(self,
address: int,
Expand All @@ -86,7 +85,7 @@ def read_discrete_inputs(self,
:param no_response_expected: (optional) The client will not expect a response to the request
:raises ModbusException:
"""
return self.execute(no_response_expected, pdu_bit_read.ReadDiscreteInputsRequest(address=address, count=count, slave=slave, ))
return self.execute(no_response_expected, pdu_bit.ReadDiscreteInputsRequest(address=address, count=count, slave=slave, ))

def read_holding_registers(self,
address: int,
Expand Down Expand Up @@ -127,7 +126,7 @@ def write_coil(self, address: int, value: bool, slave: int = 1, no_response_expe
:param no_response_expected: (optional) The client will not expect a response to the request
:raises ModbusException:
"""
return self.execute(no_response_expected, pdu_bit_write.WriteSingleCoilRequest(address, value, slave=slave))
return self.execute(no_response_expected, pdu_bit.WriteSingleCoilRequest(address, value, slave=slave))

def write_register(self, address: int, value: bytes | int, slave: int = 1, no_response_expected: bool = False) -> T:
"""Write register (code 0x06).
Expand Down Expand Up @@ -337,7 +336,7 @@ def write_coils(
:param no_response_expected: (optional) The client will not expect a response to the request
:raises ModbusException:
"""
return self.execute(no_response_expected, pdu_bit_write.WriteMultipleCoilsRequest(address, values=values, slave=slave))
return self.execute(no_response_expected, pdu_bit.WriteMultipleCoilsRequest(address, values=values, slave=slave))

def write_registers(
self,
Expand Down
Loading