forked from M-Labs/thermostat
ctrl_panel: Code cleanup
* Remove unnecessary duplication of `THERMOSTAT_PARAMETERS` * i -> ch * Separate ParameterTree and Parameter initiation * Remove extra "channel" option to root parameters, as the "value" option is already the channel number
This commit is contained in:
parent
df9715b3ef
commit
f7c266539b
|
@ -66,31 +66,28 @@ class CtrlPanel(QObject):
|
|||
self.trees_ui = trees_ui
|
||||
self.NUM_CHANNELS = len(trees_ui)
|
||||
|
||||
self.THERMOSTAT_PARAMETERS = [param_tree for i in range(self.NUM_CHANNELS)]
|
||||
|
||||
self.params = [
|
||||
Parameter.create(
|
||||
name=f"Thermostat Channel {ch} Parameters",
|
||||
type="group",
|
||||
value=ch,
|
||||
children=self.THERMOSTAT_PARAMETERS[ch],
|
||||
children=param_tree,
|
||||
)
|
||||
for ch in range(self.NUM_CHANNELS)
|
||||
]
|
||||
|
||||
for i, param in enumerate(self.params):
|
||||
param.channel = i
|
||||
|
||||
for i, tree in enumerate(self.trees_ui):
|
||||
for ch, tree in enumerate(self.trees_ui):
|
||||
tree.setHeaderHidden(True)
|
||||
tree.setParameters(self.params[i], showTop=False)
|
||||
self.params[i].setValue = self._setValue
|
||||
self.params[i].sigTreeStateChanged.connect(sigTreeStateChanged_handle)
|
||||
tree.setParameters(self.params[ch], showTop=False)
|
||||
|
||||
set_tree_label_tips(tree)
|
||||
|
||||
for handle in sigActivated_handles[i]:
|
||||
self.params[i].child(*handle[0]).sigActivated.connect(handle[1])
|
||||
for ch, param in enumerate(self.params):
|
||||
self.params[ch].setValue = self._setValue
|
||||
param.sigTreeStateChanged.connect(sigTreeStateChanged_handle)
|
||||
|
||||
for handle in sigActivated_handles[ch]:
|
||||
param.child(*handle[0]).sigActivated.connect(handle[1])
|
||||
|
||||
def _setValue(self, value, blockSignal=None):
|
||||
"""
|
||||
|
|
|
@ -262,7 +262,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||
@asyncSlot(object, object)
|
||||
async def send_command(self, param, changes):
|
||||
"""Translates parameter tree changes into thermostat set_param calls"""
|
||||
ch = param.channel
|
||||
ch = param.value()
|
||||
|
||||
for inner_param, change, data in changes:
|
||||
if change == "value":
|
||||
|
|
Loading…
Reference in New Issue