mirror of
https://github.com/naruxde/revpicommander.git
synced 2025-11-08 16:43:53 +01:00
Destroy changed IOs after piCtory changes
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -3,7 +3,7 @@
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
|
||||
<component name="PythonCompatibilityInspectionAdvertiser">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
|
||||
2
.idea/revpicommander.iml
generated
2
.idea/revpicommander.iml
generated
@@ -6,7 +6,7 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/revpicommander" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/lib/revpimodio2" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.6" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.8" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -194,10 +194,6 @@ class DebugControl(QtWidgets.QWidget, Ui_wid_debugcontrol):
|
||||
int.from_bytes(value_procimg, byteorder=io[5], signed=io[6]) & 1 << io[4]
|
||||
)
|
||||
|
||||
if self.driver_reset_detected:
|
||||
# Change last value to save the actual states of outputs
|
||||
win.set_last_value(io[0], value_procimg)
|
||||
|
||||
if (refresh or write_out) and io_type == "out":
|
||||
widget_value, last_value = win.get_value(io[0])
|
||||
if widget_value != last_value:
|
||||
@@ -290,7 +286,7 @@ class DebugControl(QtWidgets.QWidget, Ui_wid_debugcontrol):
|
||||
# ps_devices format: [[0, 'picore01'], [32, 'di01'], ...
|
||||
dict_devices = {v[0]: v[1] for v in helper.cm.call_remote_function("ps_devices", default_value=[])}
|
||||
if len(dict_devices) == 0:
|
||||
# There is not piCtory configuration on the Revolution Pi
|
||||
# There is no piCtory configuration on the Revolution Pi
|
||||
return False
|
||||
|
||||
# Remove not existing or renamed devices
|
||||
|
||||
@@ -20,6 +20,7 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
"""This window was closed."""
|
||||
do_read = QtCore.pyqtSignal()
|
||||
do_write = QtCore.pyqtSignal()
|
||||
search_class = (QtWidgets.QLineEdit, QtWidgets.QDoubleSpinBox, QtWidgets.QCheckBox)
|
||||
|
||||
def __init__(self, position: int, name: str, inputs: list, outputs: list, parent=None):
|
||||
super(DebugIos, self).__init__(parent)
|
||||
@@ -36,7 +37,6 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
self.name = name
|
||||
self.inputs = inputs.copy()
|
||||
self.outputs = outputs.copy()
|
||||
self.search_class = (QtWidgets.QLineEdit, QtWidgets.QDoubleSpinBox, QtWidgets.QCheckBox)
|
||||
self.write_values = False
|
||||
|
||||
min_input = min(inputs, key=lambda k: k[2])
|
||||
@@ -61,7 +61,8 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
helper.cm.debug_geos[self.position] = self.saveGeometry()
|
||||
self.device_closed.emit(self.position)
|
||||
|
||||
def _calc_min_max(self, byte_length: int, signed: bool):
|
||||
@staticmethod
|
||||
def _calc_min_max(byte_length: int, signed: bool):
|
||||
"""Calculate min an max value which fits to bytes."""
|
||||
max_int_value = 256 ** byte_length
|
||||
return max_int_value / 2 * -1 if signed else 0.0, \
|
||||
@@ -88,9 +89,18 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
byteorder = io[5]
|
||||
signed = io[6]
|
||||
|
||||
if container.findChild(self.search_class, name) is not None:
|
||||
# Check properties of this IO
|
||||
continue
|
||||
val = container.findChild(self.search_class, name)
|
||||
if val is not None:
|
||||
# Destroy IO if the properties was changed
|
||||
if byte_length != val.property("byte_length") or \
|
||||
bit_address != val.property("bit_address") or \
|
||||
byteorder != ("big" if val.property("big_endian") else "little") or \
|
||||
signed != val.property("signed"):
|
||||
del self.__qwa[name]
|
||||
layout.removeRow(layout.getWidgetPosition(val)[0])
|
||||
pi.logger.debug("Destroy property changed IO '{0}'".format(name))
|
||||
else:
|
||||
continue
|
||||
|
||||
lbl = QtWidgets.QLabel(name, container)
|
||||
lbl.setObjectName("lbl_".format(name))
|
||||
@@ -118,9 +128,6 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
# Bytes or string
|
||||
val = QtWidgets.QLineEdit()
|
||||
val.setReadOnly(read_only)
|
||||
val.setProperty("big_endian", byteorder == "big")
|
||||
val.setProperty("byte_length", byte_length)
|
||||
val.setProperty("signed", signed)
|
||||
val.setProperty("struct_type", "text")
|
||||
|
||||
val.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
||||
@@ -137,12 +144,9 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
|
||||
val = QtWidgets.QDoubleSpinBox()
|
||||
val.setReadOnly(read_only)
|
||||
val.setProperty("big_endian", byteorder == "big")
|
||||
val.setProperty("byte_length", byte_length)
|
||||
val.setProperty("signed", signed)
|
||||
val.setProperty("struct_type", struct_type)
|
||||
val.setProperty("frm", "{0}{1}".format(
|
||||
">" if val.property("big_endian") else "<",
|
||||
">" if byteorder == "big" else "<",
|
||||
struct_type.lower() if signed else struct_type
|
||||
))
|
||||
|
||||
@@ -157,6 +161,11 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
val.valueChanged.connect(self._change_sbx_dvalue)
|
||||
|
||||
val.setObjectName(name)
|
||||
val.setProperty("big_endian", byteorder == "big")
|
||||
val.setProperty("bit_address", bit_address)
|
||||
val.setProperty("byte_length", byte_length)
|
||||
val.setProperty("signed", signed)
|
||||
|
||||
self.__qwa[name] = val
|
||||
return val
|
||||
|
||||
@@ -322,28 +331,13 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
else:
|
||||
return actual_value, last_value
|
||||
|
||||
def set_last_value(self, io_name: str, value):
|
||||
"""
|
||||
Set last value for widget to sync after driver reset.
|
||||
|
||||
:param io_name: Name of IO
|
||||
:param value: Process value as <class 'bool'> or <class 'bytes'>
|
||||
"""
|
||||
# child = self.findChild(self.search_class, io_name)
|
||||
child = self.__qwa[io_name]
|
||||
if child.property("frm"):
|
||||
value = struct.unpack(child.property("frm"), value)[0]
|
||||
elif type(value) == bytearray:
|
||||
value = value.decode()
|
||||
|
||||
child.setProperty("last_value", value)
|
||||
|
||||
def set_value(self, io_name: str, value):
|
||||
def set_value(self, io_name: str, value, just_last_value=False):
|
||||
"""
|
||||
Standard set function for a value of different widgets.
|
||||
|
||||
:param io_name: Name of IO
|
||||
:param value: New value as bytes or bool for widget
|
||||
:param just_last_value: Just set last value property
|
||||
"""
|
||||
# child = self.findChild(self.search_class, io_name)
|
||||
child = self.__qwa[io_name]
|
||||
@@ -360,4 +354,5 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
|
||||
value = value.decode()
|
||||
|
||||
child.setProperty("last_value", value)
|
||||
child.setValue(value)
|
||||
if not just_last_value:
|
||||
child.setValue(value)
|
||||
|
||||
Reference in New Issue
Block a user