Compare commits

...

3 Commits

Author SHA1 Message Date
e1fdc86e40 ctrl_panel: Keep i_set visible when PID engaged
Since i_set is also plotted, we would also want to see its precise value
too.
2024-07-19 14:50:11 +08:00
89b908fab1 ctrl_panel: Remove MutexParameter
Use the standard ListParamenter instead, and hook up UI changes
elsewhere.
2024-07-19 14:50:11 +08:00
a1c260d52e ctrl_panel: Limits fixes
* PID Autotune test current should be positive

* Maximum absolute voltage should be 4 V not 5 V
2024-07-19 14:50:06 +08:00
2 changed files with 16 additions and 39 deletions

View File

@ -6,42 +6,6 @@ from pyqtgraph.parametertree import (
) )
class MutexParameter(pTypes.ListParameter):
"""
Mutually exclusive parameter where only one of its children is visible at a time, list selectable.
The ordering of the list items determines which children will be visible.
"""
def __init__(self, **opts):
super().__init__(**opts)
self.sigValueChanged.connect(self.show_chosen_child)
self.sigValueChanged.emit(self, self.opts["value"])
def _get_param_from_value(self, value):
if isinstance(self.opts["limits"], dict):
values_list = list(self.opts["limits"].values())
else:
values_list = self.opts["limits"]
return self.children()[values_list.index(value)]
@pyqtSlot(object, object)
def show_chosen_child(self, value):
for param in self.children():
param.hide()
child_to_show = self._get_param_from_value(value.value())
child_to_show.show()
if child_to_show.opts.get("triggerOnShow", None):
child_to_show.sigValueChanged.emit(child_to_show, child_to_show.value())
registerParameterType("mutex", MutexParameter)
def set_tree_label_tips(tree): def set_tree_label_tips(tree):
for item in tree.listAllItems(): for item in tree.listAllItems():
p = item.param p = item.param
@ -88,6 +52,18 @@ class CtrlPanel(QObject):
for handle in sigActivated_handles[ch]: for handle in sigActivated_handles[ch]:
param.child(*handle[0]).sigActivated.connect(handle[1]) param.child(*handle[0]).sigActivated.connect(handle[1])
param.child("output", "control_method").sigValueChanged.connect(
lambda param, value: param.child("i_set").setWritable(
value == "constant_current"
)
)
param.child("output", "control_method").sigValueChanged.connect(
lambda param, value: param.child("target").show(
value == "temperature_pid"
)
)
def _setValue(self, value, blockSignal=None): def _setValue(self, value, blockSignal=None):
""" """
Implement 'lock' mechanism for Parameter Type Implement 'lock' mechanism for Parameter Type

View File

@ -28,7 +28,7 @@
{ {
"name": "control_method", "name": "control_method",
"title": "Control Method", "title": "Control Method",
"type": "mutex", "type": "list",
"limits": { "limits": {
"Constant Current": "constant_current", "Constant Current": "constant_current",
"Temperature PID": "temperature_pid" "Temperature PID": "temperature_pid"
@ -68,6 +68,7 @@
"name": "target", "name": "target",
"title": "Setpoint (°C)", "title": "Setpoint (°C)",
"type": "float", "type": "float",
"visible": false,
"value": 25, "value": 25,
"step": 0.1, "step": 0.1,
"limits": [ "limits": [
@ -141,7 +142,7 @@
"step": 0.1, "step": 0.1,
"limits": [ "limits": [
0, 0,
5 4
], ],
"siPrefix": true, "siPrefix": true,
"compactHeight": false, "compactHeight": false,
@ -365,7 +366,7 @@
"compactHeight": false, "compactHeight": false,
"step": 100, "step": 100,
"limits": [ "limits": [
-2000, 0,
2000 2000
], ],
"pid_autotune": [ "pid_autotune": [