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

View File

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