Compare commits

..

119 Commits

Author SHA1 Message Date
085e3a5fd3 QVariantList -> list & QVariantMap -> dict 2024-10-07 13:27:54 +08:00
1035978ce4 No need to create a new task for waiting 2024-10-07 13:27:54 +08:00
1481819233 super init's first 2024-10-07 13:27:54 +08:00
75f05aa252 Format 2024-10-07 13:27:54 +08:00
0833813909 ch_tuning -> autotuning_channels 2024-10-07 13:27:54 +08:00
6b30c33c1b Module docstring?? 2024-10-07 13:27:54 +08:00
56200902f3 Reorder imports 2024-10-07 13:27:54 +08:00
fae9122ad5 Sensible names for views 2024-10-07 13:27:54 +08:00
28a76d091d Unprivate conn_menu
Used for autoconnect
2024-10-07 13:27:54 +08:00
9c0c6ab323 Order? 2024-10-07 13:27:54 +08:00
242b516acc Reorder 2024-10-07 13:27:54 +08:00
524b6d9bce Not async 2024-10-07 13:27:54 +08:00
a84ebdd6ad Remove report mode from thermostat data model 2024-10-07 13:27:54 +08:00
7cf5bcb400 Remove report mode box 2024-10-07 13:27:54 +08:00
2b33d1f75a More sensible names 2024-10-07 13:27:54 +08:00
938d92ce02 tec_qt: Private everything possible 2024-10-07 13:27:54 +08:00
1099f6d9ec Remove error handling for connecting task
Just let the exception propagate, even when stopping the connection
2024-10-07 13:27:54 +08:00
97d26e3c65 Update thermostat state from controller code 2024-10-07 13:27:54 +08:00
60672d9590 extra func out 2024-10-07 13:27:54 +08:00
7f62c6ae4f No need extra function 2024-10-07 13:27:54 +08:00
f5cab6b825 State update explicitly 2024-10-07 13:27:54 +08:00
8f088e43cf Zero limits warning cleanup 2024-10-07 13:27:54 +08:00
25990d19a9 Add NUM_CHANNELS to Thermostat! 2024-10-07 13:27:54 +08:00
db7cdca24c Real concurrently 2024-10-07 13:27:54 +08:00
969a7be0cc Don't create report task if not polling for it 2024-10-07 13:27:54 +08:00
f45d2c5c9e PIDAutotuner: Don't use separate sig for interval 2024-10-07 13:27:54 +08:00
5c8270834a aioexample: Show polling while report mode on
WIP: handle KeyboardInterrupt
2024-10-07 13:27:54 +08:00
52550cf721 aioclient: More accurate DFU docstring 2024-10-07 13:27:54 +08:00
d1692ad0e6 No need for async as well 2024-10-07 13:27:54 +08:00
940603e7cf No need for async 2024-10-07 13:27:54 +08:00
b873b03aaf Remove extra imports 2024-10-07 13:27:54 +08:00
cd38a1c303 report group 2024-10-07 13:27:54 +08:00
9787dc1e8b end_session in thermostat itself afterall 2024-10-07 13:27:54 +08:00
02aab70e82 Reorder MainWindow 2024-10-07 13:27:54 +08:00
3c9b6a40d9 Rearrange MainWindow.__init__ 2024-10-07 13:27:54 +08:00
c549d0344e Thermostat: Add disconnect callback
For communicating with the autotuner before the client fully
disconnects

Also then there's no need for explicitly resetting autotune elements
2024-10-07 13:27:54 +08:00
15880290b0 Remove info_box_trigger 2024-10-07 13:27:54 +08:00
bb9a363b31 Remove connection errored 2024-10-07 13:27:54 +08:00
b3293cd431 Simply test for connectivity for turning PID off 2024-10-07 13:27:54 +08:00
d71c1f4e7e Fix pressing enter not working in conn menu 2024-10-07 13:27:54 +08:00
b5b8a374c0 Assign connection_errored as well 2024-10-07 13:27:54 +08:00
46831917ba Back out 2024-10-07 13:27:54 +08:00
6e357c14e2 Put UI changes into conn_menu 2024-10-07 13:27:54 +08:00
342f7c6655 ConnectionBtn + StatusLbl 2024-10-07 13:27:54 +08:00
f75348c69d Clear Graph UI changes 2024-10-07 13:27:54 +08:00
b98773784e Concentrate ThermostatCtrlMenu UI changes 2024-10-07 13:27:54 +08:00
b26747f527 Descriptive name 2024-10-07 13:27:54 +08:00
c81f09c9d8 Refactor repeated stuff 2024-10-07 13:27:54 +08:00
de6c16e380 Split PID handler UI up 2024-10-07 13:27:54 +08:00
d6f86c3435 Fix hwrev getting 2024-10-07 13:27:54 +08:00
6e9ded532b hwrev updates 2024-10-07 13:27:54 +08:00
d5e2abfac7 Fix info boxes for load/saving from flash 2024-10-07 13:27:54 +08:00
93d09e9467 Move reset request to thermostat control menu
We don't get auto reconnect anymore
2024-10-07 13:27:54 +08:00
1eae8029ad Move pid autotuning request to CtrlPanel
And update autotune UI only on state change instead of every single
report update
2024-10-07 13:27:54 +08:00
bb2ca2c7f8 Move channelGraph stuff inside LiveDataPlotter 2024-10-07 13:27:54 +08:00
0cf685a3a1 Move plot_options_menu stuff into menu 2024-10-07 13:27:54 +08:00
6ab41a1943 Move autotune ticking connect 2024-10-07 13:27:54 +08:00
b34c70742d Get thermostat_ctrl_menu to subscribe to hwrev updates 2024-10-07 13:27:54 +08:00
019fa31d44 Save/load info box content 2024-10-07 13:27:54 +08:00
c2fbc7029c Fix loading all channel settings would bring up 2 info boxes 2024-10-07 13:27:54 +08:00
99e1574886 Add back asyncSlot to save_cfg_request 2024-10-07 13:27:54 +08:00
1829d72536 hw_rev 2024-10-07 13:27:54 +08:00
b5a011aa0c fan_update: tec_qt to thermostat_ctrl_menu 2024-10-07 13:27:54 +08:00
c8b3bc9c0f Fix updating status label for hwrev = None 2024-10-07 13:27:54 +08:00
76a832c8ba Put some menu requests in menu itself 2024-10-07 13:27:54 +08:00
cb6c807b90 Broadcast ConnectionState changes from Thermostat 2024-10-07 13:27:54 +08:00
d3df467017 Move sigActivatedHandle to CtrlPanel 2024-10-07 13:27:54 +08:00
bd6adf9526 Get rid of timeout on readline 2024-10-07 13:27:54 +08:00
0786fa0158 Put send_command in CtrlPanel 2024-10-07 13:27:48 +08:00
547700ac51 Extra bail removed 2024-10-07 13:24:02 +08:00
a76268a81f return hwrev when start_session 2024-10-07 13:24:02 +08:00
7668bbf57e state str 2024-10-07 13:24:02 +08:00
f93e76eaa0 params update concurrently 2024-10-07 13:24:01 +08:00
067ab925dd Stuff non-UI changes in Thermostat model 2024-10-07 13:24:01 +08:00
5bef8883e0 Base Thermostat connectivity UI changes to state 2024-10-07 13:24:01 +08:00
a19c64ce98 Remove wait_for
OSError raised anyways
2024-10-07 13:24:01 +08:00
0107ed0acc Actually its OSError 2024-10-07 13:24:01 +08:00
3a1c7792c9 {start,end}_session -> [dis]connect 2024-10-07 13:24:01 +08:00
22de1b623f Simplify on_connect_btn_clicked
Raise if OSError
2024-10-07 13:24:01 +08:00
e8387acbc9 Connecting task moved? 2024-10-07 13:24:01 +08:00
7abcc63a90 AsyncIO version Client -> AsyncioClient 2024-10-07 13:24:01 +08:00
c4d31a78b1 Exclusively use the Thermostat object as a medium
All calls to the Thermostat should be forwarded by the medium.
2024-10-07 13:23:56 +08:00
047bde887e Integrate WrappedClient into Thermostat model 2024-10-07 13:22:55 +08:00
c83e6dc388 Should not stop cancelling read if timeout'd 2024-10-07 13:22:55 +08:00
d4f46b994b Fix Autotuner state for forceful disconnect 2024-10-07 13:22:55 +08:00
f61c09596e _ 2024-10-07 13:22:55 +08:00
b587a72345 Make connection loss handling more elegant
Show an info box on connection lost informing the user that the
Thermostat was forcefully disconnected.
2024-10-07 13:22:55 +08:00
ddd4ea9958 ================gui_dev-fix_asyncio=============== 2024-10-07 13:22:55 +08:00
88c3c6f815 Use new style super() 2024-10-07 13:22:55 +08:00
71d1c7390a Move command line host:port setting handling
To main
2024-10-07 13:22:55 +08:00
1256b5ff49 aioclient: Add missing readline for saving
Saving all channels returns multiple JSON objects, read the extra {}.
2024-10-07 13:22:55 +08:00
e59f8d05e0 import order rearrange 2024-10-07 13:22:55 +08:00
7f45437492 This is bail 2024-10-07 13:22:55 +08:00
dcf628b542 thermostat: Properly register task
Also Thermostat.task -> Thermostat._update_params_task
2024-10-07 13:22:55 +08:00
958fddf953 ip -> host 2024-10-07 13:22:55 +08:00
1db3a3ccb9 Lazy evaluating for debug string command 2024-10-07 13:22:55 +08:00
05d46030b4 Add pytec runnables 2024-10-07 13:22:55 +08:00
73c29338af PYTHON shell 2024-10-07 13:22:55 +08:00
d3e878e294 Exactlier wording 2024-10-07 13:22:55 +08:00
38eb1c886d unused 2024-10-07 13:22:55 +08:00
1d4bc5c53f encoding 2024-10-07 13:22:55 +08:00
1ec541d580 Just catch asyncio.TimeoutError
Will just change to TimeoutError once we switch to Python 3.11 in the
flake.
2024-10-07 13:22:55 +08:00
eb8944e5ac Remove exception too general 2024-10-07 13:22:55 +08:00
abe08e4be6 Use asserts to check for connectivity 2024-10-07 13:22:55 +08:00
0024ebae5f Add back the parent 2024-10-07 13:22:55 +08:00
3f5ae9e333 Fix method call 2024-10-07 13:22:55 +08:00
dd850d34c2 README: Proofread 2024-10-07 13:22:55 +08:00
f77f5399cf Swap order arounda bit more 2024-10-07 13:22:55 +08:00
f632349c62 Formatting 2024-10-07 13:22:55 +08:00
5bf33c01fe Use qtextras 2024-10-07 13:22:55 +08:00
5119c68c9a flake update 2024-10-07 13:22:55 +08:00
a0c8fb9285 flake.nix: nixfmt-rfc-style 2024-10-07 13:22:55 +08:00
19c3c7a8f2 Merge pull request 'GUI: Refactor send_command' (#4) from gui_dev-refactor-send_command into gui_dev
Reviewed-on: linuswck/thermostat#4
2024-10-07 13:03:38 +08:00
41abad7aa3 send_command: Remove "activater"
Interpret commands anomalies directly in send_command instead
2024-08-14 16:07:15 +08:00
5c8d9c7cce send_command: Simplify "pid_autotune" parameters 2024-08-14 16:07:15 +08:00
278898fad2 send_command: Switch to thermostat:set_param
Use a `dict` to map values to thermostat parameters, which correspond to
the `set_param` parameters in the pytec client. New tag
"thermostat:set_param" used in JSON.
2024-08-14 16:07:14 +08:00
dd83daa5d9 send_command: Remove indirect path to parameter
The child at inner_param's childpath to the root parameter... is just
inner_param itself.
2024-08-14 16:06:31 +08:00
d57cc9ef2a send_command: Alias data as new_value 2024-08-14 16:06:24 +08:00
be77a6f205 send_command: Use in syntax 2024-08-14 16:06:17 +08:00
2 changed files with 86 additions and 119 deletions

View File

@ -137,36 +137,33 @@ class CtrlPanel(QObject):
for inner_param, change, data in changes:
if change == "value":
if inner_param.opts.get("param", None) is not None:
new_value = data
if "thermostat:set_param" in inner_param.opts:
if inner_param.opts.get("suffix", None) == "mA":
data /= 1000 # Given in mA
new_value /= 1000 # Given in mA
thermostat_param = inner_param.opts["param"]
if thermostat_param[1] == "ch":
thermostat_param[1] = ch
thermostat_param = inner_param.opts["thermostat:set_param"]
if inner_param.name() == "Postfilter Rate" and data is None:
set_param_args = (*thermostat_param[:2], "off")
else:
set_param_args = (*thermostat_param, data)
param.child(*param.childPath(inner_param)).setOpts(lock=True)
await self.thermostat.set_param(*set_param_args)
param.child(*param.childPath(inner_param)).setOpts(lock=False)
# Handle thermostat command irregularities
match inner_param.name(), new_value:
case "Postfilter Rate", None:
thermostat_param = thermostat_param.copy()
thermostat_param["field"] = "off"
new_value = ""
case "Control Method", "Constant Current":
return
case "Control Method", "Temperature PID":
new_value = ""
if inner_param.opts.get("pid_autotune", None) is not None:
auto_tuner_param = inner_param.opts["pid_autotune"][0]
if inner_param.opts["pid_autotune"][1] != "ch":
ch = inner_param.opts["pid_autotune"][1]
self.autotuners.set_params(auto_tuner_param, ch, data)
inner_param.setOpts(lock=True)
await self.thermostat.set_param(
channel=ch, value=new_value, **thermostat_param
)
inner_param.setOpts(lock=False)
if inner_param.opts.get("activaters", None) is not None:
activater = inner_param.opts["activaters"][
inner_param.opts["limits"].index(data)
]
if activater is not None:
if activater[1] == "ch":
activater[1] = ch
await self.thermostat.set_param(*activater)
if "pid_autotune" in inner_param.opts:
auto_tuner_param = inner_param.opts["pid_autotune"]
self.autotuners.set_params(auto_tuner_param, ch, new_value)
@pyqtSlot(list)
def update_pid(self, pid_settings):

View File

@ -25,14 +25,10 @@
"Constant Current",
"Temperature PID"
],
"activaters":[
null,
[
"pwm",
"ch",
"pid"
]
],
"thermostat:set_param":{
"topic":"pwm",
"field":"pid"
},
"children":[
{
"name":"Set Current",
@ -46,11 +42,10 @@
"triggerOnShow":true,
"decimals":6,
"suffix":"mA",
"param":[
"pwm",
"ch",
"i_set"
],
"thermostat:set_param":{
"topic":"pwm",
"field":"i_set"
},
"lock":false
},
{
@ -63,11 +58,10 @@
300
],
"format":"{value:.4f} °C",
"param":[
"pid",
"ch",
"target"
],
"thermostat:set_param":{
"topic":"pid",
"field":"target"
},
"lock":false
}
]
@ -88,11 +82,10 @@
2000
],
"suffix":"mA",
"param":[
"pwm",
"ch",
"max_i_pos"
],
"thermostat:set_param":{
"topic":"pwm",
"field":"max_i_pos"
},
"lock":false
},
{
@ -106,11 +99,10 @@
2000
],
"suffix":"mA",
"param":[
"pwm",
"ch",
"max_i_neg"
],
"thermostat:set_param":{
"topic":"pwm",
"field":"max_i_neg"
},
"lock":false
},
{
@ -124,11 +116,10 @@
],
"siPrefix":true,
"suffix":"V",
"param":[
"pwm",
"ch",
"max_v"
],
"thermostat:set_param":{
"topic":"pwm",
"field":"max_v"
},
"lock":false
}
]
@ -150,11 +141,10 @@
100
],
"format":"{value:.4f} °C",
"param":[
"s-h",
"ch",
"t0"
],
"thermostat:set_param":{
"topic":"s-h",
"field":"t0"
},
"lock":false
},
{
@ -164,11 +154,10 @@
"step":1,
"siPrefix":true,
"suffix":"Ω",
"param":[
"s-h",
"ch",
"r0"
],
"thermostat:set_param":{
"topic":"s-h",
"field":"r0"
},
"lock":false
},
{
@ -178,22 +167,20 @@
"step":1,
"suffix":"K",
"decimals":4,
"param":[
"s-h",
"ch",
"b"
],
"thermostat:set_param":{
"topic":"s-h",
"field":"b"
},
"lock":false
},
{
"name":"Postfilter Rate",
"type":"list",
"value":16.67,
"param":[
"postfilter",
"ch",
"rate"
],
"thermostat:set_param":{
"topic":"postfilter",
"field":"rate"
},
"limits":{
"Off":null,
"16.67 Hz":16.67,
@ -215,11 +202,10 @@
"type":"float",
"step":0.1,
"suffix":"",
"param":[
"pid",
"ch",
"kp"
],
"thermostat:set_param":{
"topic":"pid",
"field":"kp"
},
"lock":false
},
{
@ -227,11 +213,10 @@
"type":"float",
"step":0.1,
"suffix":"Hz",
"param":[
"pid",
"ch",
"ki"
],
"thermostat:set_param":{
"topic":"pid",
"field":"ki"
},
"lock":false
},
{
@ -239,11 +224,10 @@
"type":"float",
"step":0.1,
"suffix":"s",
"param":[
"pid",
"ch",
"kd"
],
"thermostat:set_param":{
"topic":"pid",
"field":"kd"
},
"lock":false
},
{
@ -261,11 +245,10 @@
],
"decimals":6,
"suffix":"mA",
"param":[
"pid",
"ch",
"output_min"
],
"thermostat:set_param":{
"topic":"pid",
"field":"output_min"
},
"lock":false
},
{
@ -278,11 +261,10 @@
],
"decimals":6,
"suffix":"mA",
"param":[
"pid",
"ch",
"output_max"
],
"thermostat:set_param":{
"topic":"pid",
"field":"output_max"
},
"lock":false
}
]
@ -298,10 +280,7 @@
"value":20,
"step":0.1,
"format":"{value:.4f} °C",
"pid_autotune":[
"target_temp",
"ch"
]
"pid_autotune":"target_temp"
},
{
"name":"Test Current",
@ -314,10 +293,7 @@
2000
],
"suffix":"mA",
"pid_autotune":[
"test_current",
"ch"
]
"pid_autotune":"test_current"
},
{
"name":"Temperature Swing",
@ -326,10 +302,7 @@
"step":0.1,
"prefix":"±",
"format":"{value:.4f} °C",
"pid_autotune":[
"temp_swing",
"ch"
]
"pid_autotune":"temp_swing"
},
{
"name":"Lookback",
@ -337,10 +310,7 @@
"value":3.0,
"step":0.1,
"format":"{value:.4f} s",
"pid_autotune":[
"lookback",
"ch"
]
"pid_autotune":"lookback"
},
{
"name":"Run",