Skip to content

Commit

Permalink
- faster termination of the sampling loop
Browse files Browse the repository at this point in the history
- faster WebLCDs startup
- delayed start of WebLCDs on app start
- use spawn instead fork multiprocessing also on macOS (now supported by py2app)
- fixes missing qtbase translations
- updated translations
- adds additional translatable button labels (\i: STIRRER, \f: FILL, \r: RELEASE)
- adds further Carmomaq machine setups (PR #1233)
  • Loading branch information
MAKOMO committed Aug 22, 2023
1 parent a4d71bf commit 01cbe9e
Show file tree
Hide file tree
Showing 80 changed files with 106,651 additions and 104,118 deletions.
Binary file modified doc/help_dialogs/Input_files/eventbuttons.xlsx
Binary file not shown.
14 changes: 13 additions & 1 deletion doc/help_dialogs/Output_html/eventbuttons_help.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@
<td>\M</td>
<td>MANUAL (translated, respecting button state)</td>
</tr>
<tr>
<td>\i</td>
<td>STIRRER</td>
</tr>
<tr>
<td>\f</td>
<td>FILL</td>
</tr>
<tr>
<td>\r</td>
<td>RELEASE</td>
</tr>
<tr>
<td>\h</td>
<td>HEATING</td>
Expand Down Expand Up @@ -937,4 +949,4 @@
<td>if the `&lt;json&gt;` text respects the JSON format it is send to the connected WebSocket server and the response is bound to the variable `_`</td>
</tr>
</tbody>
</table></body>
</table></body>
9 changes: 8 additions & 1 deletion src/artisanlib/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -16694,7 +16694,11 @@ def accurate_delay(self, delay):
_ = libtime.perf_counter() + delay
# use the standard sleep until one 5ms before the timeout (Windows <10 might need a limit of 5.5ms)
if delay > self.accurate_delay_cutoff:
libtime.sleep(delay - self.accurate_delay_cutoff)
half_delay = (delay - self.accurate_delay_cutoff) / 2.0
libtime.sleep(half_delay)
if not self.aw.qmc.flagon:
return # we leave this sleep earlier as sampling was terminated
libtime.sleep(half_delay)
# continuous with a busy sleep
while libtime.perf_counter() < _:
pass # this raises CPU to 100%
Expand Down Expand Up @@ -16734,6 +16738,9 @@ def run(self):
self.sample()
finally:
self.aw.qmc.flagsampling = False # we signal that we are done with sampling
else:
self.quit()
break #thread ends
else:
self.aw.qmc.flagsampling = False # type: ignore # mypy: Statement is unreachable [unreachable] # we signal that we are done with sampling
# port is disconnected in OFFmonitor by calling disconnectProbes() => disconnectProbesFromSerialDevice()
Expand Down
417 changes: 214 additions & 203 deletions src/artisanlib/main.py

Large diffs are not rendered by default.

30 changes: 25 additions & 5 deletions src/artisanlib/weblcds.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@
if psystem() != 'Windows':
from signal import SIGQUIT # type: ignore[attr-defined] # pylint: disable=no-name-in-module # not available on Windows

import logging
import multiprocessing as mp

from json import dumps as jdumps
from requests import get as rget

import time as libtime
from typing import Any, List
from typing import Any, List, Final


_log: Final[logging.Logger] = logging.getLogger(__name__)

wsocks: List[Any] = [] # list of open web sockets
process = None
port = None
Expand Down Expand Up @@ -85,6 +88,7 @@ def startWeb(p,resourcePath,nonesym,timec,timebg,btc,btbg,etc,etbg,showetflag,sh
etbackground = etbg
showet = showetflag
showbt = showbtflag
r = None
if psystem() != 'Windows':
gsignal(SIGQUIT, kill)

Expand All @@ -102,14 +106,30 @@ def startWeb(p,resourcePath,nonesym,timec,timebg,btc,btbg,etc,etbg,showetflag,sh
showbtflag))
process.start()

libtime.sleep(4)
libtime.sleep(2)

while not process.is_alive():
libtime.sleep(0.1)

if process.is_alive():
# check successful start
url = f'http://127.0.0.1:{port}/status'
r = rget(url,timeout=2)

return bool(r.status_code == 200)
for _ in range(10):
libtime.sleep(1)
try:
r = rget(url, timeout=(6.1,10))
except Exception: # pylint: disable=broad-except
pass
if r is not None:
break
if r is None:
return False
res: bool = bool(r.status_code == 200)
if res:
_log.info('WebLCDs started')
else:
_log.info('WebLCDs start failed')
return res
return False

def stopWeb():
Expand Down
3 changes: 3 additions & 0 deletions src/help/eventbuttons_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def content():
tbl_Labels.add_row(['\\m',QApplication.translate('HelpDlg','MANUAL (translated)')])
tbl_Labels.add_row(['\\A',QApplication.translate('HelpDlg','AUTO (translated, respecting button state)')])
tbl_Labels.add_row(['\\M',QApplication.translate('HelpDlg','MANUAL (translated, respecting button state)')])
tbl_Labels.add_row(['\\i',QApplication.translate('HelpDlg','STIRRER')])
tbl_Labels.add_row(['\\f',QApplication.translate('HelpDlg','FILL')])
tbl_Labels.add_row(['\\r',QApplication.translate('HelpDlg','RELEASE')])
tbl_Labels.add_row(['\\h',QApplication.translate('HelpDlg','HEATING')])
tbl_Labels.add_row(['\\l',QApplication.translate('HelpDlg','COOLING')])
strlist.append(tbl_Labels.get_html_string(attributes={'width':'100%','border':'1','padding':'1','border-collapse':'collapse'}))
Expand Down
95 changes: 95 additions & 0 deletions src/includes/Machines/Carmomaq/Caloratto-Materatto_Legacy.aset
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
[General]
Delay=2000
roastertype_setup=Carmomaq Caloratto/Materattor Legacy

[Device]
id=29

[Modbus]
PID_OFF_action=
PID_ON_action=
PID_SV_register=0
PID_d_register=0
PID_i_register=0
PID_p_register=0
PID_slave_ID=0
PIDmultiplier=0
SVmultiplier=1
baudrate=115200
bytesize=8
comport=COM4
host=192.168.0.10
input1bcd=false
input1code=3
input1div=0
input1float=false
input1FloatsAsInt=false
input1Signed=false
input1mode=C
input1register=8000
input1slave=1
input2bcd=false
input2code=3
input2div=0
input2float=false
input2FloatsAsInt=false
input2mode=C
input2register=8001
input2slave=1
input3bcd=false
input3code=4
input3div=0
input3float=false
input3FloatsAsInt=false
input3mode=C
input3register=0
input3slave=0
input4bcd=false
input4code=4
input4div=0
input4float=false
input4FloatsAsInt=false
input4mode=C
input4register=0
input4slave=0
input5bcd=false
input5code=3
input5div=0
input5float=false
input5FloatsAsInt=false
input5mode=C
input5register=0
input5slave=0
input6bcd=false
input6code=3
input6div=0
input6float=false
input6FloatsAsInt=false
input6mode=C
input6register=0
input6slave=0
input7bcd=false
input7code=3
input7div=0
input7float=false
input7FloatsAsInt=false
input7mode=C
input7register=0
input7slave=0
input8bcd=false
input8code=3
input8div=0
input8float=false
input8FloatsAsInt=false
input8mode=C
input8register=0
input8slave=0
littleEndianFloats=false
parity=N
port=502
stopbits=1
timeout=0.4
type=3
wordorderLittle=true
optimizer=true
fetch_max_blocks=false
Loading

0 comments on commit 01cbe9e

Please sign in to comment.