mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-09 07:28:03 +01:00
ProcimgServer.loadrevpimodio() erstellt um Veränderungen an piCtory zu laden
RevPiPyLoad prüft Änderungsdatum von piCtory und beendet ggf. ProcimgServer
This commit is contained in:
@@ -41,6 +41,9 @@ class ProcimgServer():
|
||||
self.logger = logger
|
||||
self.logger.debug("enter ProcimgServer.__init__()")
|
||||
self.acl = aclmode
|
||||
self.configrsc = configrsc
|
||||
self.procimg = procimg
|
||||
self.rpi = None
|
||||
|
||||
# XML-Server übernehmen
|
||||
self.xmlsrv = xmlserver
|
||||
@@ -55,14 +58,7 @@ class ProcimgServer():
|
||||
"ps_setvalue": self.setvalue,
|
||||
}
|
||||
|
||||
# RevPiModIO-Modul Instantiieren
|
||||
self.logger.debug("create revpimodio class")
|
||||
self.rpi = revpimodio.RevPiModIO(
|
||||
configrsc=configrsc,
|
||||
procimg=procimg,
|
||||
)
|
||||
self.rpi.devices.syncoutputs(device=0)
|
||||
self.logger.debug("created revpimodio class")
|
||||
self.loadrevpimodio()
|
||||
|
||||
self.logger.debug("leave ProcimgServer.__init__()")
|
||||
|
||||
@@ -101,6 +97,20 @@ class ProcimgServer():
|
||||
])
|
||||
return Binary(pickle.dumps(dict_ios))
|
||||
|
||||
def loadrevpimodio(self):
|
||||
"""Instantiiert das RevPiModIO Modul."""
|
||||
# RevPiModIO-Modul Instantiieren
|
||||
if self.rpi is not None:
|
||||
self.rpi.cleanup()
|
||||
|
||||
self.logger.debug("create revpimodio class")
|
||||
self.rpi = revpimodio.RevPiModIO(
|
||||
configrsc=self.configrsc,
|
||||
procimg=self.procimg,
|
||||
)
|
||||
self.rpi.devices.syncoutputs(device=0)
|
||||
self.logger.debug("created revpimodio class")
|
||||
|
||||
def setvalue(self, device, io, value):
|
||||
"""Setzt einen Wert auf dem RevPi.
|
||||
|
||||
|
||||
@@ -477,6 +477,7 @@ class RevPiPyLoad():
|
||||
|
||||
# Klassenattribute
|
||||
self._exit = True
|
||||
self.pictorymtime = os.path.getmtime(configrsc)
|
||||
self.evt_loadconfig = Event()
|
||||
self.globalconfig = ConfigParser()
|
||||
self.logr = LogReader()
|
||||
@@ -580,7 +581,7 @@ class RevPiPyLoad():
|
||||
self.xml_ps = None
|
||||
proginit.logger.warning(
|
||||
"can not load revpimodio module. maybe its not installed "
|
||||
"or an old version (required at least 0.11.0). if you "
|
||||
"or an old version (required at least 0.15.0). if you "
|
||||
"like to use the process monitor feature, update/install "
|
||||
"revpimodio: 'apt-get install python3-revpimodio'"
|
||||
)
|
||||
@@ -751,6 +752,16 @@ class RevPiPyLoad():
|
||||
|
||||
while not self._exit \
|
||||
and not self.evt_loadconfig.is_set():
|
||||
|
||||
# piCtory auf Veränderung prüfen
|
||||
if self.pictorymtime != os.path.getmtime(configrsc):
|
||||
proginit.logger.warning("piCtory configuration was changed")
|
||||
self.pictorymtime = os.path.getmtime(configrsc)
|
||||
|
||||
if self.xml_ps is not None:
|
||||
self.xml_psstop()
|
||||
self.xml_ps.loadrevpimodio()
|
||||
|
||||
self.evt_loadconfig.wait(1)
|
||||
|
||||
if not self._exit:
|
||||
|
||||
Reference in New Issue
Block a user