mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-08 15:13:52 +01:00
Alle revpimodio verwenden nun direct_write
This commit is contained in:
@@ -74,7 +74,6 @@ class MqttServer(Thread):
|
||||
self._reloadmodio = False
|
||||
self._replace_ios = replace_ios
|
||||
self._rpi = None
|
||||
self._rpi_write = None
|
||||
self._send_events = send_events
|
||||
self._sendinterval = sendinterval
|
||||
self._write_outputs = write_outputs
|
||||
@@ -130,25 +129,17 @@ class MqttServer(Thread):
|
||||
# RevPiModIO-Modul Instantiieren
|
||||
if self._rpi is not None:
|
||||
self._rpi.cleanup()
|
||||
if self._rpi_write is not None:
|
||||
self._rpi_write.cleanup()
|
||||
|
||||
proginit.logger.debug("create revpimodio2 object for MQTT")
|
||||
try:
|
||||
# Lesend und Eventüberwachung
|
||||
# Vollzugriff und Eventüberwachung
|
||||
self._rpi = revpimodio2.RevPiModIO(
|
||||
autorefresh=self._send_events,
|
||||
monitoring=True,
|
||||
monitoring=not self._write_outputs,
|
||||
configrsc=proginit.pargs.configrsc,
|
||||
procimg=proginit.pargs.procimg,
|
||||
replace_io_file=self._replace_ios
|
||||
)
|
||||
# Schreibenen Zugriff
|
||||
if self._write_outputs:
|
||||
self._rpi_write = revpimodio2.RevPiModIO(
|
||||
configrsc=proginit.pargs.configrsc,
|
||||
procimg=proginit.pargs.procimg,
|
||||
replace_io_file=self._replace_ios
|
||||
replace_io_file=self._replace_ios,
|
||||
direct_output=True,
|
||||
)
|
||||
|
||||
if self._replace_ios:
|
||||
@@ -159,15 +150,10 @@ class MqttServer(Thread):
|
||||
# Lesend und Eventüberwachung
|
||||
self._rpi = revpimodio2.RevPiModIO(
|
||||
autorefresh=self._send_events,
|
||||
monitoring=True,
|
||||
monitoring=not self._write_outputs,
|
||||
configrsc=proginit.pargs.configrsc,
|
||||
procimg=proginit.pargs.procimg
|
||||
)
|
||||
# Schreibenen Zugriff
|
||||
if self._write_outputs:
|
||||
self._rpi_write = revpimodio2.RevPiModIO(
|
||||
configrsc=proginit.pargs.configrsc,
|
||||
procimg=proginit.pargs.procimg
|
||||
procimg=proginit.pargs.procimg,
|
||||
direct_output=True,
|
||||
)
|
||||
proginit.logger.warning(
|
||||
"replace_ios_file not loadable for MQTT - using "
|
||||
@@ -176,7 +162,6 @@ class MqttServer(Thread):
|
||||
|
||||
except Exception:
|
||||
self._rpi = None
|
||||
self._rpi_write = None
|
||||
proginit.logger.error(
|
||||
"piCtory configuration not loadable for MQTT"
|
||||
)
|
||||
@@ -280,11 +265,11 @@ class MqttServer(Thread):
|
||||
# IO holen
|
||||
if coreio:
|
||||
coreio = ioname.split(".")[-1]
|
||||
io = getattr(self._rpi_write.core, coreio)
|
||||
io = getattr(self._rpi.core, coreio)
|
||||
if not isinstance(io, revpimodio2.io.IOBase):
|
||||
raise RuntimeError()
|
||||
else:
|
||||
io = self._rpi_write.io[ioname]
|
||||
io = self._rpi.io[ioname]
|
||||
io_needbytes = type(io.value) == bytes
|
||||
except Exception:
|
||||
proginit.logger.error(
|
||||
@@ -300,10 +285,8 @@ class MqttServer(Thread):
|
||||
)
|
||||
|
||||
elif ioget:
|
||||
# Daten je nach IO Type aus Prozessabbild laden
|
||||
if io.type == revpimodio2.OUT:
|
||||
io._parentdevice.syncoutputs()
|
||||
else:
|
||||
# Werte laden, wenn nicht autorefresh
|
||||
if not self._send_events:
|
||||
io._parentdevice.readprocimg()
|
||||
|
||||
# Publish Wert von IO
|
||||
@@ -344,7 +327,6 @@ class MqttServer(Thread):
|
||||
return
|
||||
|
||||
# Write Value to RevPi
|
||||
io._parentdevice.syncoutputs()
|
||||
try:
|
||||
io.value = value
|
||||
except Exception:
|
||||
@@ -352,8 +334,6 @@ class MqttServer(Thread):
|
||||
"could not write '{0}' to Output '{1}'"
|
||||
"".format(value, ioname)
|
||||
)
|
||||
else:
|
||||
io._parentdevice.writeprocimg()
|
||||
|
||||
elif ioreset:
|
||||
# Counter zurücksetzen
|
||||
|
||||
@@ -99,7 +99,8 @@ class ProcimgServer():
|
||||
self.rpi = revpimodio2.RevPiModIO(
|
||||
configrsc=proginit.pargs.configrsc,
|
||||
procimg=proginit.pargs.procimg,
|
||||
replace_io_file=self.replace_ios
|
||||
replace_io_file=self.replace_ios,
|
||||
direct_output=True,
|
||||
)
|
||||
|
||||
if self.replace_ios:
|
||||
@@ -110,6 +111,7 @@ class ProcimgServer():
|
||||
self.rpi = revpimodio2.RevPiModIO(
|
||||
configrsc=proginit.pargs.configrsc,
|
||||
procimg=proginit.pargs.procimg,
|
||||
direct_output=True,
|
||||
)
|
||||
proginit.logger.warning(
|
||||
"replace_ios_file not loadable for ProcimgServer - using "
|
||||
@@ -122,9 +124,6 @@ class ProcimgServer():
|
||||
)
|
||||
return e
|
||||
|
||||
# NOTE: Warum das?
|
||||
self.rpi.syncoutputs(device=0)
|
||||
|
||||
proginit.logger.debug("created revpimodio2 object")
|
||||
|
||||
def setvalue(self, device, io, value):
|
||||
@@ -140,8 +139,6 @@ class ProcimgServer():
|
||||
if type(value) == Binary:
|
||||
value = value.data
|
||||
|
||||
self.rpi.syncoutputs(device=device)
|
||||
|
||||
try:
|
||||
# Neuen Wert übernehmen
|
||||
if type(value) == bytes or type(value) == bool:
|
||||
@@ -156,13 +153,12 @@ class ProcimgServer():
|
||||
except Exception as e:
|
||||
return [device, io, False, str(e)]
|
||||
|
||||
self.rpi.writeprocimg(device=device)
|
||||
return [device, io, True, ""]
|
||||
|
||||
def values(self):
|
||||
"""Liefert Prozessabbild an Client.
|
||||
@return Binary() bytes or None"""
|
||||
if self.rpi.readprocimg() and self.rpi.syncoutputs():
|
||||
if self.rpi.readprocimg():
|
||||
bytebuff = bytearray()
|
||||
for dev in self.rpi.device:
|
||||
bytebuff += bytes(dev)
|
||||
|
||||
@@ -49,7 +49,7 @@ from time import asctime
|
||||
from xmlrpc.client import Binary
|
||||
from xrpcserver import SaveXMLRPCServer
|
||||
|
||||
min_revpimodio = "2.3.3"
|
||||
min_revpimodio = "2.4.0"
|
||||
|
||||
|
||||
class RevPiPyLoad():
|
||||
|
||||
2
setup.py
2
setup.py
@@ -31,7 +31,7 @@ setup(
|
||||
|
||||
scripts=["data/revpipyload"],
|
||||
|
||||
install_requires=["revpimodio2 >= 2.3.3"],
|
||||
install_requires=["revpimodio2 >= 2.4.0"],
|
||||
python_requires=">=3.2",
|
||||
|
||||
data_files=[
|
||||
|
||||
Reference in New Issue
Block a user