Skip to content

Commit

Permalink
- increase sampling speed on Loring setups to 1sec
Browse files Browse the repository at this point in the history
- fixes a regression which prevented loading settings written (slightly broken) by Artisan v3.0 (Discussion #1692)
  • Loading branch information
MAKOMO committed Sep 12, 2024
1 parent 01555c6 commit 65cb8d6
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 15 deletions.
12 changes: 10 additions & 2 deletions src/artisanlib/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2995,14 +2995,22 @@ def onrelease(self, event:'Event') -> None: # NOTE: onrelease() is connected
bboxpatch = self.aw.analysisresultsanno.get_bbox_patch()
if bboxpatch is not None:
corners = self.ax.transAxes.inverted().transform(bboxpatch.get_extents())
self.analysisresultsloc = (float(corners[0][0]), float(corners[0][1] + (corners[1][1] - corners[0][1])/2))
self.analysisresultsloc = (toFloat(corners[0][0]), toFloat(corners[0][1] + (corners[1][1] - corners[0][1])/2))
#reset the annotation location if the origin is out of the screen
for dim in self.analysisresultsloc:
if dim >= 1 or dim <=0:
self.analysisresultsloc = self.analysisresultsloc_default
# save the location of segment results after dragging
if self.segmentpickflag and self.aw.segmentresultsanno is not None:
self.segmentpickflag = False
bbox_patch = self.aw.segmentresultsanno.get_bbox_patch()
if bbox_patch is not None:
corners = self.ax.transAxes.inverted().transform(bbox_patch.get_extents())
self.segmentresultsloc = (float(corners[0][0]), float(corners[0][1] + (corners[1][1] - corners[0][1])/2))
self.segmentresultsloc = (toFloat(corners[0][0]), toFloat(corners[0][1] + (corners[1][1] - corners[0][1])/2))
#reset the annotation location if the origin is out of the screen
for dim in self.segmentresultsloc:
if dim >= 1 or dim <=0:
self.segmentresultsloc = self.segmentresultsloc_default
except Exception as e: # pylint: disable=broad-except
_log.exception(e)
_, _, exc_tb = sys.exc_info()
Expand Down
2 changes: 1 addition & 1 deletion src/artisanlib/cup_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __init__(self, parent:'QWidget', aw:'ApplicationWindow') -> None:
mainLayout.addWidget(extraGroupLayout)
# mainLayout.addLayout(blayout)
mainLayout.addLayout(mainButtonsLayout)
mainLayout.setContentsMargins(7,5,7,0) # left, top, right, bottom
mainLayout.setContentsMargins(7,5,7,5) # left, top, right, bottom
mainLayout.setSpacing(3)
self.setLayout(mainLayout)
self.aw.qmc.updateFlavorchartValues() # fast incremental redraw
Expand Down
30 changes: 22 additions & 8 deletions src/artisanlib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16887,13 +16887,27 @@ def settingsLoad(self, filename:Optional[str] = None, theme:bool = False, machin
for _ in range(7 - len(self.qmc.statisticsflags)):
self.qmc.statisticsflags.append(0)
if settings.contains('AnalysisResultsLoc'):
arl = toList(settings.value('AnalysisResultsLoc',self.qmc.analysisresultsloc))
if len(arl)>1:
self.qmc.analysisresultsloc = (toFloat(arl[0]), toFloat(arl[1]))
# on Windows11 some Artisan v3.0 writes this as
# AnalysisResultsLoc=@Variant(\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\0), @Variant(\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\0)
# due to a missing convertion from numpy numbers to Python floats, which cannot be re-loaded by Qt

Check failure on line 16892 in src/artisanlib/main.py

View workflow job for this annotation

GitHub Actions / codespell

convertion ==> conversion
# => unable to convert a C++ 'QVariantList' instance to a Python object
try:
arl = toList(settings.value('AnalysisResultsLoc',self.qmc.analysisresultsloc))
if len(arl)>1:
self.qmc.analysisresultsloc = (toFloat(arl[0]), toFloat(arl[1]))
except Exception: # pylint: disable=broad-except
pass
if settings.contains('SegmentResultsLoc'):
srl = toList(settings.value('SegmentResultsLoc',self.qmc.segmentresultsloc))
if len(srl)>1:
self.qmc.segmentresultsloc = (toFloat(srl[0]), toFloat(srl[1]))
# on Windows11 some Artisan v3.0 writes this as
# SegmentResultsLoc=@Variant(\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\0), @Variant(\0\0\0\x7f\0\0\0\xePyQt_PyObject\0\0\0\0\0)
# due to a missing convertion from numpy numbers to Python floats, which cannot be re-loaded by Qt

Check failure on line 16903 in src/artisanlib/main.py

View workflow job for this annotation

GitHub Actions / codespell

convertion ==> conversion
# => unable to convert a C++ 'QVariantList' instance to a Python object
try:
srl = toList(settings.value('SegmentResultsLoc',self.qmc.segmentresultsloc))
if len(srl)>1:
self.qmc.segmentresultsloc = (toFloat(srl[0]), toFloat(srl[1]))
except Exception: # pylint: disable=broad-except
pass
self.qmc.analysisstartchoice = toInt(settings.value('analysisstartchoice',int(self.qmc.analysisstartchoice)))
self.qmc.analysisoffset = toInt(settings.value('analysisoffset',int(self.qmc.analysisoffset)))
self.qmc.curvefitstartchoice = toInt(settings.value('curvefitstartchoice',int(self.qmc.curvefitstartchoice)))
Expand Down Expand Up @@ -18626,8 +18640,8 @@ def saveAllSettings(self, settings:QSettings, default_settings:Optional[Dict[str
self.settingsSetValue(settings, default_settings, 'autoFCs',self.qmc.autoFCsFlag, read_defaults)
#save statistics
self.settingsSetValue(settings, default_settings, 'Statistics',self.qmc.statisticsflags, read_defaults)
self.settingsSetValue(settings, default_settings, 'AnalysisResultsLoc',list(self.qmc.analysisresultsloc), read_defaults)
self.settingsSetValue(settings, default_settings, 'SegmentResultsLoc',list(self.qmc.segmentresultsloc), read_defaults)
self.settingsSetValue(settings, default_settings, 'AnalysisResultsLoc',[toFloat(x) for x in list(self.qmc.analysisresultsloc)[:2]], read_defaults)
self.settingsSetValue(settings, default_settings, 'SegmentResultsLoc',[toFloat(x) for x in list(self.qmc.segmentresultsloc)[:2]], read_defaults)
self.settingsSetValue(settings, default_settings, 'analysisstartchoice',self.qmc.analysisstartchoice, read_defaults)
self.settingsSetValue(settings, default_settings, 'analysisoffset',self.qmc.analysisoffset, read_defaults)
self.settingsSetValue(settings, default_settings, 'curvefitstartchoice',self.qmc.curvefitstartchoice, read_defaults)
Expand Down
2 changes: 1 addition & 1 deletion src/includes/Machines/Loring/Smart_Roast.aset
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[General]
Delay=2000
Delay=1000
Oversampling=false
roastertype_setup=Loring
roastersize_setup_default=7
Expand Down
3 changes: 1 addition & 2 deletions src/includes/Machines/Loring/Smart_Roast_Auto.aset
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[General]
Delay=2000
Oversampling=false
Delay=1000
roastertype_setup=Loring Auto
roastersize_setup_default=7

Expand Down
2 changes: 1 addition & 1 deletion src/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ types-setuptools>=74.1.0.20240906
types-urllib3>=1.26.25.14
lxml-stubs>=0.5.1
mypy==1.11.2
pyright==1.1.379
pyright==1.1.380
ruff>=0.6.4
pylint==3.2.7
pre-commit>=3.8.0
Expand Down
1 change: 1 addition & 0 deletions wiki/ReleaseHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ v3.0.3
- updates Cropster XLS importer ([Issue #1685](../../../issues/1685))
- fixes regression which broke SV number switching for Fuji PIDs ([Discussion #1683](../../../discussions/1683))
- fixes missing statistic content ([Discussion #1689](../../../discussions/1689))
- fixes a regression which prevented loading settings written (slightly broken) by Artisan v3.0 ([Discussion #1692](../../../discussions/1692))



Expand Down

0 comments on commit 65cb8d6

Please sign in to comment.