forked from M-Labs/thermostat
ctrl_panel: Indicate active parameter of control
Instead of hiding the inactive control parameter, underline and bold the active control parameter title, e.g. "Set Current" when control method is constant current, and "Setpoint" when it is temperature PID.
This commit is contained in:
parent
319fb9cf9e
commit
87ba107ce5
|
@ -7,42 +7,6 @@ from pyqtgraph.parametertree import (
|
||||||
import pytec.gui.view.lockable_unit
|
import pytec.gui.view.lockable_unit
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -89,6 +53,25 @@ 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])
|
||||||
|
|
||||||
|
def _indicate_usage(param, control_method="constant_current"):
|
||||||
|
for item in param.child("i_set").items:
|
||||||
|
is_constant_current = control_method == "constant_current"
|
||||||
|
font = item.font(0)
|
||||||
|
font.setUnderline(is_constant_current)
|
||||||
|
font.setBold(is_constant_current)
|
||||||
|
item.setFont(0, font)
|
||||||
|
for item in param.child("target").items:
|
||||||
|
is_temperature_pid = control_method == "temperature_pid"
|
||||||
|
font = item.font(0)
|
||||||
|
font.setUnderline(is_temperature_pid)
|
||||||
|
font.setBold(is_temperature_pid)
|
||||||
|
item.setFont(0, font)
|
||||||
|
|
||||||
|
param.child("output", "control_method").sigValueChanged.connect(
|
||||||
|
_indicate_usage
|
||||||
|
)
|
||||||
|
_indicate_usage(param.child("output", "control_method"))
|
||||||
|
|
||||||
def _setValue(self, value, blockSignal=None):
|
def _setValue(self, value, blockSignal=None):
|
||||||
"""
|
"""
|
||||||
Implement 'lock' mechanism for Parameter Type
|
Implement 'lock' mechanism for Parameter Type
|
||||||
|
|
|
@ -29,7 +29,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"
|
||||||
|
@ -54,7 +54,6 @@
|
||||||
-2,
|
-2,
|
||||||
2
|
2
|
||||||
],
|
],
|
||||||
"triggerOnShow": true,
|
|
||||||
"decimals": 6,
|
"decimals": 6,
|
||||||
"pinSiPrefix": "m",
|
"pinSiPrefix": "m",
|
||||||
"suffix": "A",
|
"suffix": "A",
|
||||||
|
|
|
@ -293,6 +293,10 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
if activater[1] == "ch":
|
if activater[1] == "ch":
|
||||||
activater[1] = ch
|
activater[1] = ch
|
||||||
await self.client.set_param(*activater)
|
await self.client.set_param(*activater)
|
||||||
|
else:
|
||||||
|
await self.client.set_param(
|
||||||
|
"pwm", ch, "i_set", inner_param.child("i_set").value()
|
||||||
|
)
|
||||||
|
|
||||||
@asyncSlot()
|
@asyncSlot()
|
||||||
async def pid_autotune_request(self, ch=0):
|
async def pid_autotune_request(self, ch=0):
|
||||||
|
|
Loading…
Reference in New Issue