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
02d04dbae5
commit
8ec7bb833a
@ -65,31 +65,28 @@ class CtrlPanel(QObject):
|
|||||||
self.trees_ui = trees_ui
|
self.trees_ui = trees_ui
|
||||||
self.NUM_CHANNELS = len(trees_ui)
|
self.NUM_CHANNELS = len(trees_ui)
|
||||||
|
|
||||||
self.THERMOSTAT_PARAMETERS = [param_tree for i in range(self.NUM_CHANNELS)]
|
|
||||||
|
|
||||||
self.params = [
|
self.params = [
|
||||||
Parameter.create(
|
Parameter.create(
|
||||||
name=f"Thermostat Channel {ch} Parameters",
|
name=f"Thermostat Channel {ch} Parameters",
|
||||||
type="group",
|
type="group",
|
||||||
value=ch,
|
value=ch,
|
||||||
children=self.THERMOSTAT_PARAMETERS[ch],
|
children=param_tree,
|
||||||
)
|
)
|
||||||
for ch in range(self.NUM_CHANNELS)
|
for ch in range(self.NUM_CHANNELS)
|
||||||
]
|
]
|
||||||
|
|
||||||
for i, param in enumerate(self.params):
|
for ch, tree in enumerate(self.trees_ui):
|
||||||
param.channel = i
|
|
||||||
|
|
||||||
for i, tree in enumerate(self.trees_ui):
|
|
||||||
tree.setHeaderHidden(True)
|
tree.setHeaderHidden(True)
|
||||||
tree.setParameters(self.params[i], showTop=False)
|
tree.setParameters(self.params[ch], showTop=False)
|
||||||
self.params[i].setValue = self._setValue
|
|
||||||
self.params[i].sigTreeStateChanged.connect(sigTreeStateChanged_handle)
|
|
||||||
|
|
||||||
set_tree_label_tips(tree)
|
set_tree_label_tips(tree)
|
||||||
|
|
||||||
for handle in sigActivated_handles[i]:
|
for ch, param in enumerate(self.params):
|
||||||
self.params[i].child(*handle[0]).sigActivated.connect(handle[1])
|
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):
|
def _setValue(self, value, blockSignal=None):
|
||||||
"""
|
"""
|
||||||
|
@ -262,7 +262,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
@asyncSlot(object, object)
|
@asyncSlot(object, object)
|
||||||
async def send_command(self, param, changes):
|
async def send_command(self, param, changes):
|
||||||
"""Translates parameter tree changes into thermostat set_param calls"""
|
"""Translates parameter tree changes into thermostat set_param calls"""
|
||||||
ch = param.channel
|
ch = param.value()
|
||||||
|
|
||||||
for inner_param, change, data in changes:
|
for inner_param, change, data in changes:
|
||||||
if change == "value":
|
if change == "value":
|
||||||
|
Loading…
Reference in New Issue
Block a user