mirror of https://github.com/Nonannet/pyhoff.git
missing explicit function return types added
This commit is contained in:
parent
61f431a534
commit
96c716b1c5
|
@ -41,7 +41,7 @@ class BusTerminal():
|
|||
self._mixed_mapping = mixed_mapping
|
||||
|
||||
@classmethod
|
||||
def select(cls, bus_coupler: 'BusCoupler', terminal_number: int = 0):
|
||||
def select(cls, bus_coupler: 'BusCoupler', terminal_number: int = 0) -> 'BusTerminal':
|
||||
terminal_list = [bt for bt in bus_coupler.bus_terminals if isinstance(bt, cls)]
|
||||
assert terminal_list, f'No instance of {cls.__name__} configured at this BusCoupler'
|
||||
assert 0 <= terminal_number < len(terminal_list), f'Out of range, select in range: 0..{len(terminal_list) - 1}'
|
||||
|
@ -247,7 +247,7 @@ class BusCoupler():
|
|||
self.add_bus_terminals(bus_terminals)
|
||||
self._init_hardware(watchdog)
|
||||
|
||||
def _init_hardware(self, watchdog: float):
|
||||
def _init_hardware(self, watchdog: float) -> None:
|
||||
pass
|
||||
|
||||
def add_bus_terminals(self, *new_bus_terminals: Type[BusTerminal] | Iterable[Type[BusTerminal]]) -> list[BusTerminal]:
|
||||
|
@ -272,7 +272,7 @@ class BusCoupler():
|
|||
for terminal_class in terminal_classes:
|
||||
assert _is_bus_terminal(terminal_class), f'{terminal_class} is not a bus terminal'
|
||||
|
||||
def get_para(key: str):
|
||||
def get_para(key: str) -> int:
|
||||
return terminal_class.parameters.get(key, 0)
|
||||
|
||||
new_terminal = terminal_class(
|
||||
|
|
|
@ -7,7 +7,7 @@ class BK9000(BusCoupler):
|
|||
"""
|
||||
BK9000 ModBus TCP bus coupler
|
||||
"""
|
||||
def _init_hardware(self, watchdog: float):
|
||||
def _init_hardware(self, watchdog: float) -> None:
|
||||
# https://download.beckhoff.com/download/document/io/bus-terminals/bk9000_bk9050_bk9100de.pdf
|
||||
# config watchdog on page 58
|
||||
|
||||
|
@ -44,7 +44,7 @@ class WAGO_750_352(BusCoupler):
|
|||
"""
|
||||
Wago 750-352 ModBus TCP bus coupler
|
||||
"""
|
||||
def _init_hardware(self, watchdog: float):
|
||||
def _init_hardware(self, watchdog: float) -> None:
|
||||
# deactivate/reset watchdog timer:
|
||||
self.modbus.write_single_register(0x1005, 0xAAAA)
|
||||
self.modbus.write_single_register(0x1005, 0x5555)
|
||||
|
|
|
@ -87,7 +87,7 @@ class SimpleModbusClient:
|
|||
self._socket: None | socket.socket = None
|
||||
self.debug = debug
|
||||
|
||||
def connect(self):
|
||||
def connect(self) -> bool:
|
||||
for af, st, pr, _, sa in socket.getaddrinfo(self.host, self.port,
|
||||
socket.AF_UNSPEC,
|
||||
socket.SOCK_STREAM):
|
||||
|
@ -110,7 +110,7 @@ class SimpleModbusClient:
|
|||
self.last_error = 'connection failed'
|
||||
return False
|
||||
|
||||
def close(self):
|
||||
def close(self) -> bytes:
|
||||
"""
|
||||
Close connection
|
||||
|
||||
|
|
Loading…
Reference in New Issue