File tree Expand file tree Collapse file tree 3 files changed +11
-22
lines changed
Expand file tree Collapse file tree 3 files changed +11
-22
lines changed Original file line number Diff line number Diff line change 55(the high-order bit) in each byte. It may be further defined by bit 6.
66"""
77# pylint: disable=missing-type-doc
8- from pymodbus .exceptions import NotImplementedException , ParameterException
8+ from abc import ABC , abstractmethod
9+
10+ from pymodbus .exceptions import ParameterException
911from pymodbus .utilities import pack_bitstring , unpack_bitstring
1012
1113
12- class ModbusEvent :
14+ class ModbusEvent ( ABC ) :
1315 """Define modbus events."""
1416
15- def encode (self ):
16- """Encode the status bits to an event message.
17-
18- :raises NotImplementedException:
19- """
20- raise NotImplementedException
17+ @abstractmethod
18+ def encode (self ) -> bytes :
19+ """Encode the status bits to an event message."""
2120
21+ @abstractmethod
2222 def decode (self , event ):
2323 """Decode the event message to its status bits.
2424
2525 :param event: The event to decode
26- :raises NotImplementedException:
2726 """
28- raise NotImplementedException
2927
3028
3129class RemoteReceiveEvent (ModbusEvent ):
Original file line number Diff line number Diff line change 66 ModbusDeviceIdentification ,
77 ModbusPlusStatistics ,
88)
9- from pymodbus .events import ModbusEvent , RemoteReceiveEvent
9+ from pymodbus .events import RemoteReceiveEvent
1010
1111
1212# ---------------------------------------------------------------------------#
@@ -281,7 +281,7 @@ def test_modbus_control_block_invalid_diagnostic(self):
281281 def test_clearing_control_events (self ):
282282 """Test adding and clearing modbus events."""
283283 assert self .control .Events == []
284- event = ModbusEvent ()
284+ event = RemoteReceiveEvent ()
285285 self .control .addEvent (event )
286286 assert self .control .Events == [event ]
287287 assert self .control .Counter .Event == 1
Original file line number Diff line number Diff line change 44from pymodbus .events import (
55 CommunicationRestartEvent ,
66 EnteredListenModeEvent ,
7- ModbusEvent ,
87 RemoteReceiveEvent ,
98 RemoteSendEvent ,
109)
11- from pymodbus .exceptions import NotImplementedException , ParameterException
10+ from pymodbus .exceptions import ParameterException
1211
1312
1413class TestEvents :
1514 """Unittest for the pymodbus.device module."""
1615
17- def test_modbus_event_base_class (self ):
18- """Test modbus event base class."""
19- event = ModbusEvent ()
20- with pytest .raises (NotImplementedException ):
21- event .encode ()
22- with pytest .raises (NotImplementedException ):
23- event .decode (None )
24-
2516 def test_remote_receive_event (self ):
2617 """Test remove receive event."""
2718 event = RemoteReceiveEvent ()
You can’t perform that action at this time.
0 commit comments