forked from M-Labs/thermostat
Compare commits
2 Commits
a5c40f706a
...
27baddf49e
Author | SHA1 | Date | |
---|---|---|---|
27baddf49e | |||
458912bd8d |
@ -9,42 +9,6 @@ from qasync import asyncSlot
|
||||
from pythermostat.autotune import PIDAutotuneState
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
class CtrlPanel(QObject):
|
||||
def __init__(
|
||||
self,
|
||||
@ -94,6 +58,30 @@ class CtrlPanel(QObject):
|
||||
"PID Config", "PID Auto Tune", "Run"
|
||||
).sigActivated.connect(partial(self.pid_auto_tune_request, i))
|
||||
|
||||
def _indicate_usage(param, control_method="Constant Current"):
|
||||
for item in param.child("Set Current").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("Set Temperature").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)
|
||||
|
||||
self.params[i].child("Output Config", "Control Method").sigValueChanged.connect(
|
||||
_indicate_usage
|
||||
)
|
||||
_indicate_usage(self.params[i].child("Output Config", "Control Method"))
|
||||
|
||||
for item in self.params[i].child("Output Config", "Control Method").items:
|
||||
font = item.font(0)
|
||||
font.setBold(True)
|
||||
item.setFont(0, font)
|
||||
|
||||
self.thermostat.pid_update.connect(self.update_pid)
|
||||
self.thermostat.report_update.connect(self.update_report)
|
||||
self.thermostat.thermistor_update.connect(self.update_thermistor)
|
||||
@ -151,7 +139,9 @@ class CtrlPanel(QObject):
|
||||
thermostat_param["field"] = "off"
|
||||
new_value = ""
|
||||
case "Control Method", "Constant Current":
|
||||
return
|
||||
thermostat_param = thermostat_param.copy()
|
||||
thermostat_param["field"] = "i_set"
|
||||
new_value = inner_param.child("Set Current").value()
|
||||
case "Control Method", "Temperature PID":
|
||||
new_value = ""
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
"children": [
|
||||
{
|
||||
"name": "Control Method",
|
||||
"type": "mutex",
|
||||
"type": "list",
|
||||
"limits": [
|
||||
"Constant Current",
|
||||
"Temperature PID"
|
||||
@ -40,7 +40,6 @@
|
||||
-2000,
|
||||
2000
|
||||
],
|
||||
"triggerOnShow": true,
|
||||
"decimals": 6,
|
||||
"suffix": "mA",
|
||||
"compactHeight": false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user