mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-08 15:13:52 +01:00
ProcimgServer lädt standard IOs, wenn replace_ios_file nicht gültig ist
MQTT lädt standard IOs, wenn replace_ios_file nicht gültig ist replace_ios_file wird beim reload geprüft und ggf. neu geladen Startbar ohne replace_ios Parameter Bei fehlender replace_ios Datei werden standard IOs verwendet
This commit is contained in:
@@ -143,7 +143,6 @@ class MqttServer(Thread):
|
|||||||
procimg=proginit.pargs.procimg,
|
procimg=proginit.pargs.procimg,
|
||||||
replace_io_file=self._replace_ios
|
replace_io_file=self._replace_ios
|
||||||
)
|
)
|
||||||
|
|
||||||
# Schreibenen Zugriff
|
# Schreibenen Zugriff
|
||||||
if self._write_outputs:
|
if self._write_outputs:
|
||||||
self._rpi_write = revpimodio2.RevPiModIO(
|
self._rpi_write = revpimodio2.RevPiModIO(
|
||||||
@@ -152,13 +151,36 @@ class MqttServer(Thread):
|
|||||||
replace_io_file=self._replace_ios
|
replace_io_file=self._replace_ios
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self._replace_ios:
|
||||||
|
proginit.logger.info("loaded replace_ios to MQTT")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._rpi = None
|
try:
|
||||||
self._rpi_write = None
|
# Lesend und Eventüberwachung
|
||||||
proginit.logger.error(
|
self._rpi = revpimodio2.RevPiModIO(
|
||||||
"piCtory configuration not loadable for MQTT"
|
autorefresh=self._send_events,
|
||||||
)
|
monitoring=True,
|
||||||
raise e
|
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
|
||||||
|
)
|
||||||
|
proginit.logger.warning(
|
||||||
|
"replace_ios_file not loadable for MQTT - using "
|
||||||
|
"defaults now | {0}".format(e)
|
||||||
|
)
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
self._rpi = None
|
||||||
|
self._rpi_write = None
|
||||||
|
proginit.logger.error(
|
||||||
|
"piCtory configuration not loadable for MQTT"
|
||||||
|
)
|
||||||
|
raise e
|
||||||
|
|
||||||
# Exportierte IOs laden
|
# Exportierte IOs laden
|
||||||
for dev in self._rpi.device:
|
for dev in self._rpi.device:
|
||||||
|
|||||||
@@ -101,12 +101,26 @@ class ProcimgServer():
|
|||||||
procimg=proginit.pargs.procimg,
|
procimg=proginit.pargs.procimg,
|
||||||
replace_io_file=self.replace_ios
|
replace_io_file=self.replace_ios
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self.replace_ios:
|
||||||
|
proginit.logger.info("loaded replace_ios to ProcimgServer")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.rpi = None
|
try:
|
||||||
proginit.logger.error(
|
self.rpi = revpimodio2.RevPiModIO(
|
||||||
"piCtory configuration not loadable for ProcimgServer"
|
configrsc=proginit.pargs.configrsc,
|
||||||
)
|
procimg=proginit.pargs.procimg,
|
||||||
return e
|
)
|
||||||
|
proginit.logger.warning(
|
||||||
|
"replace_ios_file not loadable for ProcimgServer - using "
|
||||||
|
"defaults now | {0}".format(e)
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
self.rpi = None
|
||||||
|
proginit.logger.error(
|
||||||
|
"piCtory configuration not loadable for ProcimgServer"
|
||||||
|
)
|
||||||
|
return e
|
||||||
|
|
||||||
# NOTE: Warum das?
|
# NOTE: Warum das?
|
||||||
self.rpi.syncoutputs(device=0)
|
self.rpi.syncoutputs(device=0)
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class RevPiPyLoad():
|
|||||||
# Klassenattribute
|
# Klassenattribute
|
||||||
self._exit = True
|
self._exit = True
|
||||||
self.pictorymtime = os.path.getmtime(proginit.pargs.configrsc)
|
self.pictorymtime = os.path.getmtime(proginit.pargs.configrsc)
|
||||||
|
self.replaceiosmtime = 0
|
||||||
self.evt_loadconfig = Event()
|
self.evt_loadconfig = Event()
|
||||||
self.globalconfig = ConfigParser()
|
self.globalconfig = ConfigParser()
|
||||||
self.logr = logsystem.LogReader()
|
self.logr = logsystem.LogReader()
|
||||||
@@ -230,6 +231,24 @@ class RevPiPyLoad():
|
|||||||
self.zeroonexit = \
|
self.zeroonexit = \
|
||||||
self.globalconfig["DEFAULT"].getboolean("zeroonexit", True)
|
self.globalconfig["DEFAULT"].getboolean("zeroonexit", True)
|
||||||
|
|
||||||
|
# MTime für replace io übernehmen
|
||||||
|
mtime = 0
|
||||||
|
if self.replace_ios_config:
|
||||||
|
if os.access(self.replace_ios_config, os.R_OK | os.W_OK):
|
||||||
|
mtime = os.path.getmtime(self.replace_ios_config)
|
||||||
|
else:
|
||||||
|
proginit.logger.error(
|
||||||
|
"can not access (r/w) the replace_ios file '{0}' "
|
||||||
|
"using defaults".format(self.replace_ios_config)
|
||||||
|
)
|
||||||
|
self.replace_ios_config = ""
|
||||||
|
|
||||||
|
if self.replaceiosmtime != mtime:
|
||||||
|
# MQTT reload erforderlich
|
||||||
|
restart_plcmqtt = True
|
||||||
|
|
||||||
|
self.replaceiosmtime = mtime
|
||||||
|
|
||||||
# Konfiguration verarbeiten [MQTT]
|
# Konfiguration verarbeiten [MQTT]
|
||||||
self.mqtt = 0
|
self.mqtt = 0
|
||||||
if "MQTT" in self.globalconfig:
|
if "MQTT" in self.globalconfig:
|
||||||
@@ -405,7 +424,9 @@ class RevPiPyLoad():
|
|||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
self.xml_ps = procimgserver.ProcimgServer(
|
self.xml_ps = procimgserver.ProcimgServer(
|
||||||
self.xsrv, self.replace_ios_config
|
self.xsrv,
|
||||||
|
None if not self.replace_ios_config
|
||||||
|
else self.replace_ios_config,
|
||||||
)
|
)
|
||||||
self.xsrv.register_function(1, self.xml_psstart, "psstart")
|
self.xsrv.register_function(1, self.xml_psstart, "psstart")
|
||||||
self.xsrv.register_function(1, self.xml_psstop, "psstop")
|
self.xsrv.register_function(1, self.xml_psstop, "psstop")
|
||||||
@@ -492,7 +513,8 @@ class RevPiPyLoad():
|
|||||||
self.mqttclient_id,
|
self.mqttclient_id,
|
||||||
self.mqttsend_on_event,
|
self.mqttsend_on_event,
|
||||||
self.mqttwrite_outputs,
|
self.mqttwrite_outputs,
|
||||||
self.replace_ios_config,
|
None if not self.replace_ios_config
|
||||||
|
else self.replace_ios_config,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
proginit.logger.error(e)
|
proginit.logger.error(e)
|
||||||
|
|||||||
1
setup.py
1
setup.py
@@ -41,6 +41,7 @@ setup(
|
|||||||
("/etc/revpipyload", [
|
("/etc/revpipyload", [
|
||||||
"data/etc/revpipyload/aclplcslave.conf",
|
"data/etc/revpipyload/aclplcslave.conf",
|
||||||
"data/etc/revpipyload/aclxmlrpc.conf",
|
"data/etc/revpipyload/aclxmlrpc.conf",
|
||||||
|
"data/etc/revpipyload/replace_ios.conf",
|
||||||
"data/etc/revpipyload/revpipyload.conf",
|
"data/etc/revpipyload/revpipyload.conf",
|
||||||
]),
|
]),
|
||||||
("share/revpipyload", glob("revpipyload/*.*")),
|
("share/revpipyload", glob("revpipyload/*.*")),
|
||||||
|
|||||||
Reference in New Issue
Block a user