mirror of
https://github.com/naruxde/revpimodio2.git
synced 2026-03-31 15:08:09 +02:00
style: Remove redundant whitespaces from docstrings and comments
Cleaned up excessive indentation and unnecessary spacing in docstrings and comments across multiple files to improve code readability and maintain consistency. Signed-off-by: Sven Sager <akira@narux.de>
This commit is contained in:
@@ -520,9 +520,6 @@ class Device(object):
|
|||||||
"""
|
"""
|
||||||
Read all inputs for this device from process image.
|
Read all inputs for this device from process image.
|
||||||
|
|
||||||
|
|
||||||
Same see
|
|
||||||
|
|
||||||
:return: True if successfully executed
|
:return: True if successfully executed
|
||||||
:ref: :func:`revpimodio2.modio.RevPiModIO.readprocimg()`
|
:ref: :func:`revpimodio2.modio.RevPiModIO.readprocimg()`
|
||||||
"""
|
"""
|
||||||
@@ -652,7 +649,7 @@ class ModularBase(Base):
|
|||||||
@property
|
@property
|
||||||
def unconfdevice(self) -> bool:
|
def unconfdevice(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Status bit for an IO module not configured with piCtory.
|
Status bit for an IO module not configured with piCtory.
|
||||||
|
|
||||||
:return: True if IO module is not configured
|
:return: True if IO module is not configured
|
||||||
"""
|
"""
|
||||||
@@ -661,7 +658,7 @@ class ModularBase(Base):
|
|||||||
@property
|
@property
|
||||||
def missingdeviceorgate(self) -> bool:
|
def missingdeviceorgate(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Status bit for an IO module missing or piGate configured.
|
Status bit for an IO module missing or piGate configured.
|
||||||
|
|
||||||
:return: True if IO module is missing or piGate is configured
|
:return: True if IO module is missing or piGate is configured
|
||||||
"""
|
"""
|
||||||
@@ -746,7 +743,7 @@ class ModularBase(Base):
|
|||||||
"""
|
"""
|
||||||
Sets RS485 ErrorLimit1 to new value.
|
Sets RS485 ErrorLimit1 to new value.
|
||||||
|
|
||||||
:param value: Neuer ErrorLimit1 value
|
:param value: New ErrorLimit1 value
|
||||||
"""
|
"""
|
||||||
if self._slc_errorlimit1 is None:
|
if self._slc_errorlimit1 is None:
|
||||||
raise RuntimeError("selected core item in piCtory does not support errorlimit1")
|
raise RuntimeError("selected core item in piCtory does not support errorlimit1")
|
||||||
@@ -771,7 +768,7 @@ class ModularBase(Base):
|
|||||||
"""
|
"""
|
||||||
Sets RS485 ErrorLimit2 to new value.
|
Sets RS485 ErrorLimit2 to new value.
|
||||||
|
|
||||||
:param value: Neuer ErrorLimit2 value
|
:param value: New ErrorLimit2 value
|
||||||
"""
|
"""
|
||||||
if self._slc_errorlimit2 is None:
|
if self._slc_errorlimit2 is None:
|
||||||
raise RuntimeError("selected core item in piCtory does not support errorlimit2")
|
raise RuntimeError("selected core item in piCtory does not support errorlimit2")
|
||||||
@@ -1192,7 +1189,6 @@ class ModularBaseConnect_4_5(ModularBase):
|
|||||||
exp_a5blue = exp_a1red
|
exp_a5blue = exp_a1red
|
||||||
|
|
||||||
# Create actual IOs
|
# Create actual IOs
|
||||||
"""LED A1 red."""
|
|
||||||
self.a1red = IOBase(
|
self.a1red = IOBase(
|
||||||
self,
|
self,
|
||||||
["core.a1red", 0, 1, self._slc_led.start, exp_a1red, None, "LED_A1_RED", "0"],
|
["core.a1red", 0, 1, self._slc_led.start, exp_a1red, None, "LED_A1_RED", "0"],
|
||||||
@@ -1511,7 +1507,7 @@ class Compact(Base):
|
|||||||
Class for the RevPi Compact.
|
Class for the RevPi Compact.
|
||||||
|
|
||||||
Provides functions for the LEDs. IOs are accessed via the .io
|
Provides functions for the LEDs. IOs are accessed via the .io
|
||||||
object zugegriffen.
|
object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = (
|
__slots__ = (
|
||||||
@@ -1536,7 +1532,7 @@ class Compact(Base):
|
|||||||
"""Prepare Core class."""
|
"""Prepare Core class."""
|
||||||
super()._devconfigure()
|
super()._devconfigure()
|
||||||
|
|
||||||
# Statische IO Verknüpfungen of the Compacts
|
# Link static IOs of the Compact
|
||||||
self._slc_led = slice(23, 24)
|
self._slc_led = slice(23, 24)
|
||||||
self._slc_temperature = slice(0, 1)
|
self._slc_temperature = slice(0, 1)
|
||||||
self._slc_frequency = slice(1, 2)
|
self._slc_frequency = slice(1, 2)
|
||||||
@@ -2100,7 +2096,7 @@ class Virtual(Gateway):
|
|||||||
|
|
||||||
def writeinputdefaults(self):
|
def writeinputdefaults(self):
|
||||||
"""
|
"""
|
||||||
Writes piCtory default input values for a virtual device.
|
Writes piCtory default input values for a virtual device.
|
||||||
|
|
||||||
If default values for inputs of a virtual device are specified
|
If default values for inputs of a virtual device are specified
|
||||||
in piCtory, these are only set at system startup or a piControl
|
in piCtory, these are only set at system startup or a piControl
|
||||||
@@ -2108,7 +2104,7 @@ class Virtual(Gateway):
|
|||||||
these values will be lost.
|
these values will be lost.
|
||||||
This function can only be applied to virtual devices!
|
This function can only be applied to virtual devices!
|
||||||
|
|
||||||
:return: True if operations on the virtual device were successful
|
:return: True if operations on the virtual device were successful
|
||||||
"""
|
"""
|
||||||
if self._modio._monitoring:
|
if self._modio._monitoring:
|
||||||
raise RuntimeError("can not write process image, while system is in monitoring mode")
|
raise RuntimeError("can not write process image, while system is in monitoring mode")
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class EventCallback(Thread):
|
|||||||
is called on the thread.
|
is called on the thread.
|
||||||
|
|
||||||
while not th.exit.is_set():
|
while not th.exit.is_set():
|
||||||
# IO-Arbeiten
|
# Work with IOs
|
||||||
th.exit.wait(0.5)
|
th.exit.wait(0.5)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ class EventCallback(Thread):
|
|||||||
Init EventCallback class.
|
Init EventCallback class.
|
||||||
|
|
||||||
:param func: Function that should be called at startup
|
:param func: Function that should be called at startup
|
||||||
:param name: IO-Name
|
:param name: IO name
|
||||||
:param value: IO value at the time of the event
|
:param value: IO value at the time of the event
|
||||||
"""
|
"""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -612,7 +612,7 @@ class ProcimgWriter(Thread):
|
|||||||
else:
|
else:
|
||||||
self.__dict_delay[tup_fire] -= 1
|
self.__dict_delay[tup_fire] -= 1
|
||||||
if self.__dict_delay[tup_fire] <= 0:
|
if self.__dict_delay[tup_fire] <= 0:
|
||||||
# Accept and delete delayed event
|
# Put event to queue and delete delayed event
|
||||||
if tup_fire[0].as_thread:
|
if tup_fire[0].as_thread:
|
||||||
self._eventqth.put(tup_fire, False)
|
self._eventqth.put(tup_fire, False)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
"""RevPiModIO main class for network access."""
|
"""RevPiModIO main class for network access."""
|
||||||
__author__ = "Sven Sager"
|
__author__ = "Sven Sager"
|
||||||
__copyright__ = "Copyright (C) 2023 Sven Sager"
|
__copyright__ = "Copyright (C) 2023 Sven Sager"
|
||||||
@@ -50,7 +51,7 @@ class ConfigChanged(Exception):
|
|||||||
|
|
||||||
class NetFH(Thread):
|
class NetFH(Thread):
|
||||||
"""
|
"""
|
||||||
Network file handler for the process image.
|
Network file handler for the process image.
|
||||||
|
|
||||||
This file-object-like object manages reading and writing of the
|
This file-object-like object manages reading and writing of the
|
||||||
process image via the network. A remote Revolution Pi can be controlled this way.
|
process image via the network. A remote Revolution Pi can be controlled this way.
|
||||||
@@ -131,7 +132,7 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def __check_acl(self, bytecode: bytes) -> None:
|
def __check_acl(self, bytecode: bytes) -> None:
|
||||||
"""
|
"""
|
||||||
Checks if ACL allows the operation on RevPi.
|
Checks if ACL allows the operation on RevPi.
|
||||||
|
|
||||||
If the operation is not permitted, the socket is immediately closed
|
If the operation is not permitted, the socket is immediately closed
|
||||||
and an exception is thrown.
|
and an exception is thrown.
|
||||||
@@ -151,7 +152,7 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def __set_systimeout(self, value: int) -> None:
|
def __set_systimeout(self, value: int) -> None:
|
||||||
"""
|
"""
|
||||||
System function for timeout calculation.
|
System function for timeout calculation.
|
||||||
|
|
||||||
:param value: Timeout in milliseconds 100 - 60000
|
:param value: Timeout in milliseconds 100 - 60000
|
||||||
"""
|
"""
|
||||||
@@ -284,7 +285,7 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def clear_dirtybytes(self, position=None) -> None:
|
def clear_dirtybytes(self, position=None) -> None:
|
||||||
"""
|
"""
|
||||||
Removes the configured dirty bytes from the RevPi server.
|
Removes the configured dirty bytes from the RevPi server.
|
||||||
|
|
||||||
This function does not throw an exception on transmission error,
|
This function does not throw an exception on transmission error,
|
||||||
but triggers a reconnection.
|
but triggers a reconnection.
|
||||||
@@ -392,7 +393,7 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def get_closed(self) -> bool:
|
def get_closed(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Check if connection is closed.
|
Check if connection is closed.
|
||||||
|
|
||||||
:return: True if connection is closed
|
:return: True if connection is closed
|
||||||
"""
|
"""
|
||||||
@@ -400,7 +401,7 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def get_config_changed(self) -> bool:
|
def get_config_changed(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Check if RevPi configuration was changed.
|
Check if RevPi configuration was changed.
|
||||||
|
|
||||||
:return: True if RevPi configuration was changed
|
:return: True if RevPi configuration was changed
|
||||||
"""
|
"""
|
||||||
@@ -408,7 +409,7 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def get_name(self) -> str:
|
def get_name(self) -> str:
|
||||||
"""
|
"""
|
||||||
Return connection name.
|
Return connection name.
|
||||||
|
|
||||||
:return: <class 'str'> IP:PORT
|
:return: <class 'str'> IP:PORT
|
||||||
"""
|
"""
|
||||||
@@ -416,7 +417,7 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def get_reconnecting(self) -> bool:
|
def get_reconnecting(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Internal reconnect active due to network errors.
|
Internal reconnect active due to network errors.
|
||||||
|
|
||||||
:return: True if reconnect is active
|
:return: True if reconnect is active
|
||||||
"""
|
"""
|
||||||
@@ -424,7 +425,7 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def get_timeout(self) -> int:
|
def get_timeout(self) -> int:
|
||||||
"""
|
"""
|
||||||
Returns current timeout.
|
Returns current timeout.
|
||||||
|
|
||||||
:return: <class 'int'> in milliseconds
|
:return: <class 'int'> in milliseconds
|
||||||
"""
|
"""
|
||||||
@@ -458,7 +459,7 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def read(self, length: int) -> bytes:
|
def read(self, length: int) -> bytes:
|
||||||
"""
|
"""
|
||||||
Read data via the network.
|
Read data via the network.
|
||||||
|
|
||||||
:param length: Number of bytes
|
:param length: Number of bytes
|
||||||
:return: Read <class 'bytes'>
|
:return: Read <class 'bytes'>
|
||||||
@@ -586,12 +587,12 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def set_dirtybytes(self, position: int, dirtybytes: bytes) -> None:
|
def set_dirtybytes(self, position: int, dirtybytes: bytes) -> None:
|
||||||
"""
|
"""
|
||||||
Configures dirty bytes for process image on connection error.
|
Configures dirty bytes for process image on connection error.
|
||||||
|
|
||||||
This function does not throw an exception on transmission error,
|
This function does not throw an exception on transmission error,
|
||||||
but triggers a reconnection.
|
but triggers a reconnection.
|
||||||
|
|
||||||
:param position: Start position for writing
|
:param position: Start position for writing
|
||||||
:param dirtybytes: <class 'bytes'> to be written
|
:param dirtybytes: <class 'bytes'> to be written
|
||||||
"""
|
"""
|
||||||
if self.__config_changed:
|
if self.__config_changed:
|
||||||
@@ -624,7 +625,7 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def set_timeout(self, value: int) -> None:
|
def set_timeout(self, value: int) -> None:
|
||||||
"""
|
"""
|
||||||
Sets timeout value for connection.
|
Sets timeout value for connection.
|
||||||
|
|
||||||
:param value: Timeout in milliseconds
|
:param value: Timeout in milliseconds
|
||||||
"""
|
"""
|
||||||
@@ -644,9 +645,9 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def tell(self) -> int:
|
def tell(self) -> int:
|
||||||
"""
|
"""
|
||||||
Returns aktuelle Position.
|
Returns actual position in file.
|
||||||
|
|
||||||
:return: Aktuelle Position
|
:return: Actual position in file
|
||||||
"""
|
"""
|
||||||
if self.__config_changed:
|
if self.__config_changed:
|
||||||
raise ConfigChanged("configuration on revolution pi was changed")
|
raise ConfigChanged("configuration on revolution pi was changed")
|
||||||
@@ -656,7 +657,7 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def write(self, bytebuff: bytes) -> int:
|
def write(self, bytebuff: bytes) -> int:
|
||||||
"""
|
"""
|
||||||
Write data via the network.
|
Write data via the network.
|
||||||
|
|
||||||
:param bytebuff: Bytes to write
|
:param bytebuff: Bytes to write
|
||||||
:return: <class 'int'> Number of written bytes
|
:return: <class 'int'> Number of written bytes
|
||||||
@@ -691,7 +692,7 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
class RevPiNetIO(_RevPiModIO):
|
class RevPiNetIO(_RevPiModIO):
|
||||||
"""
|
"""
|
||||||
Class for managing the piCtory configuration via the network.
|
Class for managing the piCtory configuration via the network.
|
||||||
|
|
||||||
This class takes over the entire configuration from piCtory and maps
|
This class takes over the entire configuration from piCtory and maps
|
||||||
the devices and IOs. It takes over exclusive management of the
|
the devices and IOs. It takes over exclusive management of the
|
||||||
@@ -714,7 +715,7 @@ class RevPiNetIO(_RevPiModIO):
|
|||||||
shared_procimg=False,
|
shared_procimg=False,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Instantiates the basic functions.
|
Instantiates the basic functions.
|
||||||
|
|
||||||
:param address: IP address <class 'str'> / (IP, Port) <class 'tuple'>
|
:param address: IP address <class 'str'> / (IP, Port) <class 'tuple'>
|
||||||
:param autorefresh: If True, add all devices to autorefresh
|
:param autorefresh: If True, add all devices to autorefresh
|
||||||
@@ -723,8 +724,8 @@ class RevPiNetIO(_RevPiModIO):
|
|||||||
:param simulator: Loads the module as simulator and swaps IOs
|
:param simulator: Loads the module as simulator and swaps IOs
|
||||||
:param debug: Output complete messages for all errors
|
:param debug: Output complete messages for all errors
|
||||||
:param replace_io_file: Load replace IO configuration from file
|
:param replace_io_file: Load replace IO configuration from file
|
||||||
:param shared_procimg: Share process image with other processes, this
|
:param shared_procimg: Share process image with other processes, this
|
||||||
could be insecure for automation
|
could be insecure for automation
|
||||||
"""
|
"""
|
||||||
check_ip = compile(r"^(25[0-5]|(2[0-4]|[01]?\d|)\d)(\.(25[0-5]|(2[0-4]|[01]?\d|)\d)){3}$")
|
check_ip = compile(r"^(25[0-5]|(2[0-4]|[01]?\d|)\d)(\.(25[0-5]|(2[0-4]|[01]?\d|)\d)){3}$")
|
||||||
|
|
||||||
@@ -823,7 +824,7 @@ class RevPiNetIO(_RevPiModIO):
|
|||||||
|
|
||||||
def get_config_changed(self) -> bool:
|
def get_config_changed(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Check if RevPi configuration was changed.
|
Check if RevPi configuration was changed.
|
||||||
|
|
||||||
In this case, the connection is closed and RevPiNetIO must be
|
In this case, the connection is closed and RevPiNetIO must be
|
||||||
reinstantiated.
|
reinstantiated.
|
||||||
@@ -834,7 +835,7 @@ class RevPiNetIO(_RevPiModIO):
|
|||||||
|
|
||||||
def get_jconfigrsc(self) -> dict:
|
def get_jconfigrsc(self) -> dict:
|
||||||
"""
|
"""
|
||||||
Loads the piCtory configuration and creates a <class 'dict'>.
|
Loads the piCtory configuration and creates a <class 'dict'>.
|
||||||
|
|
||||||
:return: <class 'dict'> of the piCtory configuration
|
:return: <class 'dict'> of the piCtory configuration
|
||||||
"""
|
"""
|
||||||
@@ -845,7 +846,7 @@ class RevPiNetIO(_RevPiModIO):
|
|||||||
|
|
||||||
def get_reconnecting(self) -> bool:
|
def get_reconnecting(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Internal reconnect active due to network errors.
|
Internal reconnect active due to network errors.
|
||||||
|
|
||||||
The module tries internally to reestablish the connection. No
|
The module tries internally to reestablish the connection. No
|
||||||
further action is needed.
|
further action is needed.
|
||||||
@@ -874,12 +875,12 @@ class RevPiNetIO(_RevPiModIO):
|
|||||||
|
|
||||||
def net_setdefaultvalues(self, device=None) -> None:
|
def net_setdefaultvalues(self, device=None) -> None:
|
||||||
"""
|
"""
|
||||||
Configures the PLC server with the piCtory default values.
|
Configures the PLC server with the piCtory default values.
|
||||||
|
|
||||||
These values are set on the RevPi if the connection is
|
These values are set on the RevPi if the connection is
|
||||||
unexpectedly interrupted (network error).
|
unexpectedly interrupted (network error).
|
||||||
|
|
||||||
:param device: Only apply to single device, otherwise to all
|
:param device: Only apply to single device, otherwise to all
|
||||||
"""
|
"""
|
||||||
if self.monitoring:
|
if self.monitoring:
|
||||||
raise RuntimeError("can not send default values, while system is in monitoring mode")
|
raise RuntimeError("can not send default values, while system is in monitoring mode")
|
||||||
@@ -923,7 +924,7 @@ class RevPiNetIO(_RevPiModIO):
|
|||||||
|
|
||||||
class RevPiNetIOSelected(RevPiNetIO):
|
class RevPiNetIOSelected(RevPiNetIO):
|
||||||
"""
|
"""
|
||||||
Class for managing individual devices from piCtory.
|
Class for managing individual devices from piCtory.
|
||||||
|
|
||||||
This class only takes over specified devices from the piCtory configuration
|
This class only takes over specified devices from the piCtory configuration
|
||||||
and maps them including IOs. It takes over exclusive management of the
|
and maps them including IOs. It takes over exclusive management of the
|
||||||
@@ -946,15 +947,15 @@ class RevPiNetIOSelected(RevPiNetIO):
|
|||||||
shared_procimg=False,
|
shared_procimg=False,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Instantiates the basic functions only for specified devices.
|
Instantiates the basic functions only for specified devices.
|
||||||
|
|
||||||
The parameter deviceselection can be a single
|
The parameter deviceselection can be a single
|
||||||
device position / single device name or a list with
|
device position / single device name or a list with
|
||||||
multiple positions / names
|
multiple positions / names
|
||||||
|
|
||||||
:param address: IP address <class 'str'> / (IP, Port) <class 'tuple'>
|
:param address: IP address <class 'str'> / (IP, Port) <class 'tuple'>
|
||||||
:param deviceselection: Position number or device name
|
:param deviceselection: Position number or device name
|
||||||
:ref: :func:`RevPiNetIO.__init__()`
|
:ref: :func:`RevPiNetIO.__init__()`
|
||||||
"""
|
"""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
address,
|
address,
|
||||||
@@ -1020,14 +1021,14 @@ class RevPiNetIODriver(RevPiNetIOSelected):
|
|||||||
shared_procimg=False,
|
shared_procimg=False,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Instantiates the basic functions.
|
Instantiates the basic functions.
|
||||||
|
|
||||||
Parameters 'monitoring' and 'simulator' are not available here,
|
Parameters 'monitoring' and 'simulator' are not available here,
|
||||||
as these are set automatically.
|
as these are set automatically.
|
||||||
|
|
||||||
:param address: IP address <class 'str'> / (IP, Port) <class 'tuple'>
|
:param address: IP address <class 'str'> / (IP, Port) <class 'tuple'>
|
||||||
:param virtdev: Virtual device or multiple as <class 'list'>
|
:param virtdev: Virtual device or multiple as <class 'list'>
|
||||||
:ref: :func:`RevPiModIO.__init__()`
|
:ref: :func:`RevPiModIO.__init__()`
|
||||||
"""
|
"""
|
||||||
# Load parent with monitoring=False and simulator=True
|
# Load parent with monitoring=False and simulator=True
|
||||||
if type(virtdev) not in (list, tuple):
|
if type(virtdev) not in (list, tuple):
|
||||||
|
|||||||
Reference in New Issue
Block a user