mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-08 15:13:52 +01:00
Merge tag 'unstable/0.11.0_rc2' into pkg/debian_rc
This commit is contained in:
@@ -2,4 +2,4 @@ setuptools>=58.0.4
|
|||||||
wheel
|
wheel
|
||||||
|
|
||||||
paho-mqtt>=1.4.0
|
paho-mqtt>=1.4.0
|
||||||
revpimodio2>=2.6.0
|
revpimodio2>=2.7.0rc2
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -18,7 +18,7 @@ setup(
|
|||||||
|
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"paho-mqtt >= 1.4.0",
|
"paho-mqtt >= 1.4.0",
|
||||||
"revpimodio2 >= 2.6.0",
|
"revpimodio2 >= 2.7.0rc2",
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ __author__ = "Sven Sager"
|
|||||||
__copyright__ = "Copyright (C) 2023 Sven Sager"
|
__copyright__ = "Copyright (C) 2023 Sven Sager"
|
||||||
__license__ = "GPLv2"
|
__license__ = "GPLv2"
|
||||||
__package__ = "revpipyload"
|
__package__ = "revpipyload"
|
||||||
__version__ = "0.11.0rc1"
|
__version__ = "0.11.0rc2"
|
||||||
|
|||||||
@@ -44,8 +44,10 @@ class ProcimgServer:
|
|||||||
"ps_inps": lambda: self.ios("inp"),
|
"ps_inps": lambda: self.ios("inp"),
|
||||||
"ps_outs": lambda: self.ios("out"),
|
"ps_outs": lambda: self.ios("out"),
|
||||||
"ps_values": self.values,
|
"ps_values": self.values,
|
||||||
|
"ps_switching_cycles": lambda io_name: self.async_call("ro_get_switching_cycles", io_name)
|
||||||
}
|
}
|
||||||
self.xmlwritefuncs = {
|
self.xmlwritefuncs = {
|
||||||
|
"ps_reset_counter": lambda io_name: self.async_call("di_reset", io_name),
|
||||||
"ps_setvalue": self.setvalue,
|
"ps_setvalue": self.setvalue,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +61,33 @@ class ProcimgServer:
|
|||||||
if self.rpi is not None:
|
if self.rpi is not None:
|
||||||
self.rpi.cleanup()
|
self.rpi.cleanup()
|
||||||
|
|
||||||
|
def async_call(self, call: str, *args):
|
||||||
|
"""
|
||||||
|
Call an async function (ioctl) of piControl.
|
||||||
|
|
||||||
|
:param call: IOCTL call
|
||||||
|
:param args: Optional arguments to pass to async function
|
||||||
|
:return: Return value of async call
|
||||||
|
"""
|
||||||
|
proginit.logger.debug("ProcimgServer.async_call({0}, {1})".format(call, args))
|
||||||
|
|
||||||
|
if call == "ro_get_switching_cycles":
|
||||||
|
# args = [io_name]
|
||||||
|
io_name = args[0]
|
||||||
|
switching_cycles = self.rpi.io[io_name].get_switching_cycles()
|
||||||
|
if not isinstance(switching_cycles, tuple):
|
||||||
|
switching_cycles = (switching_cycles,)
|
||||||
|
|
||||||
|
# int values will exceed XML-RPC limits, so we use str
|
||||||
|
return tuple(str(switching_cycle) for switching_cycle in switching_cycles)
|
||||||
|
|
||||||
|
if call == "di_reset":
|
||||||
|
# args = [io_name]
|
||||||
|
io_name = args[0]
|
||||||
|
return self.rpi.io[io_name].reset()
|
||||||
|
|
||||||
|
raise ValueError("Unknown async function name in call argument")
|
||||||
|
|
||||||
def devices(self):
|
def devices(self):
|
||||||
"""Generiert Deviceliste mit Position und Namen.
|
"""Generiert Deviceliste mit Position und Namen.
|
||||||
@return list() mit Tuple (pos, name)"""
|
@return list() mit Tuple (pos, name)"""
|
||||||
@@ -83,6 +112,16 @@ class ProcimgServer:
|
|||||||
lst_io = []
|
lst_io = []
|
||||||
|
|
||||||
for io in lst_io:
|
for io in lst_io:
|
||||||
|
lst_async_calls = []
|
||||||
|
|
||||||
|
if isinstance(io, revpimodio2.io.IntIOCounter):
|
||||||
|
# Counter IOs has a reset property
|
||||||
|
lst_async_calls.append("di_reset")
|
||||||
|
|
||||||
|
if isinstance(io, revpimodio2.io.RelaisOutput):
|
||||||
|
# Relaisoutputs can read switching cycles
|
||||||
|
lst_async_calls.append("ro_get_switching_cycles")
|
||||||
|
|
||||||
dict_ios[dev.position].append([
|
dict_ios[dev.position].append([
|
||||||
io.name,
|
io.name,
|
||||||
1 if io._bitlength == 1 else int(io._bitlength / 8),
|
1 if io._bitlength == 1 else int(io._bitlength / 8),
|
||||||
@@ -92,6 +131,7 @@ class ProcimgServer:
|
|||||||
io._byteorder,
|
io._byteorder,
|
||||||
io._signed,
|
io._signed,
|
||||||
getattr(io, "wordorder", "ignored"),
|
getattr(io, "wordorder", "ignored"),
|
||||||
|
lst_async_calls,
|
||||||
])
|
])
|
||||||
return Binary(pickle.dumps(dict_ios))
|
return Binary(pickle.dumps(dict_ios))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user