Skip to content

Commit

Permalink
- raise max event button limits from 4 rows a 30 buttons to 10 rows a…
Browse files Browse the repository at this point in the history
… 50 buttons

- keep custom events ordered by time
- fixes regression in Events Editor which broke any edits (after v3.1 got released)
- fixes regression introduced in v3.0 which prevented to replay events before CHARGE
- adds new flag "Set batch size" to background dialog. If ticked the batch size is taken from the background profile on load while scheduler is off
- adds new Artisan Command "setBatchSize(<float>)" to set the batch size. if the given number is negative the batch size is taken from the background profile, if available
- adds new Artisan Command "quantifier(n,<bool>)" to toggle quantification per event type
  • Loading branch information
MAKOMO committed Feb 3, 2025
1 parent 3a8b8b0 commit 8446e0f
Show file tree
Hide file tree
Showing 74 changed files with 64,342 additions and 63,003 deletions.
Binary file modified doc/help_dialogs/Input_files/eventbuttons.xlsx
Binary file not shown.
Binary file modified doc/help_dialogs/Input_files/eventsliders.xlsx
Binary file not shown.
10 changes: 10 additions & 0 deletions doc/help_dialogs/Output_html/eventbuttons_help.html
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,16 @@
<td>playbackmode(&lt;int&gt;)</td>
<td>sets playback mode to 0: off, 1: time, 2: BT, 3: ET</td>
</tr>
<tr>
<td>&#160;</td>
<td>quantifier(n,&lt;bool&gt;)</td>
<td>activate/deactivate quantification per event type n from {1,2,3,4}</td>
</tr>
<tr>
<td>&#160;</td>
<td>setBatchSize(&lt;float&gt;)</td>
<td>set the batch size to the given value. If the value is negative, the batch size is taken from the background profile, if any is loaded</td>
</tr>
<tr>
<td>&#160;</td>
<td>openProperties</td>
Expand Down
10 changes: 10 additions & 0 deletions doc/help_dialogs/Output_html/eventsliders_help.html
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,16 @@
<td>playbackmode(&lt;int&gt;)</td>
<td>sets playback mode to 0: off, 1: time, 2: BT, 3: ET</td>
</tr>
<tr>
<td>&#160;</td>
<td>quantifier(n,&lt;bool&gt;)</td>
<td>activate/deactivate quantification per event type n from {1,2,3,4}</td>
</tr>
<tr>
<td>&#160;</td>
<td>setBatchSize(&lt;float&gt;)</td>
<td>set the batch size to the given value. If the value is negative, the batch size is taken from the background profile, if any is loaded</td>
</tr>
<tr>
<td>&#160;</td>
<td>openProperties</td>
Expand Down
91 changes: 56 additions & 35 deletions src/artisanlib/background.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,18 @@ def __init__(self, parent:QWidget, aw:'ApplicationWindow', activeTab:int = 0) ->
self.etimeSpinBox.setValue(int(self.aw.qmc.detectBackgroundEventTime))
self.etimeSpinBox.valueChanged.connect(self.setreproduce)
self.etimeSpinBox.setEnabled(self.aw.qmc.backgroundReproduce)
self.clearBgbeforeprofileload = QCheckBox(QApplication.translate('CheckBox','Clear the background before loading a new profile'))
self.clearBgbeforeprofileload = QCheckBox(QApplication.translate('CheckBox','Clear background before loading'))
self.clearBgbeforeprofileload.setToolTip(QApplication.translate('Tooltip', 'Clear background before loading a profile'))
self.clearBgbeforeprofileload.setChecked(self.aw.qmc.clearBgbeforeprofileload)
self.clearBgbeforeprofileload.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.clearBgbeforeprofileload.stateChanged.connect(self.optclearbgbeforeprofileload)
self.hideBgafterprofileload = QCheckBox(QApplication.translate('CheckBox','Always hide background when loading a profile'))
self.setBatchSizeFromBackground = QCheckBox(QApplication.translate('CheckBox','Set batch size'))
self.setBatchSizeFromBackground.setToolTip(QApplication.translate('Tooltip', 'Set batch size from background profile on load'))
self.setBatchSizeFromBackground.setChecked(self.aw.qmc.setBatchSizeFromBackground)
self.setBatchSizeFromBackground.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.setBatchSizeFromBackground.stateChanged.connect(self.optsetBatchSizeFromBackground)
self.hideBgafterprofileload = QCheckBox(QApplication.translate('CheckBox','Always hide background on loading'))
self.hideBgafterprofileload.setToolTip(QApplication.translate('Tooltip', 'Always hide background on loading a profile'))
self.hideBgafterprofileload.setChecked(self.aw.qmc.hideBgafterprofileload)
self.hideBgafterprofileload.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.hideBgafterprofileload.stateChanged.connect(self.opthideBgafterprofileload)
Expand Down Expand Up @@ -284,37 +291,37 @@ def __init__(self, parent:QWidget, aw:'ApplicationWindow', activeTab:int = 0) ->
alignButtonBoxed.addWidget(alignButton)
alignButtonBoxed.addWidget(self.alignComboBox)

self.backgroundPlaybackAid0Label = QLabel('1')
self.backgroundPlaybackAid0Label.setEnabled(self.aw.qmc.backgroundReproduce)
# self.backgroundPlaybackAid0Label = QLabel('1')
# self.backgroundPlaybackAid0Label.setEnabled(self.aw.qmc.backgroundReproduce)
self.backgroundPlaybackAid0 = QCheckBox(self.aw.qmc.etypesf(0))
self.backgroundPlaybackAid0.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.backgroundPlaybackAid0.setChecked(self.aw.qmc.specialeventplaybackaid[0])
self.backgroundPlaybackAid0.stateChanged.connect(self.setplaybackaideventtypeenabled)
self.backgroundPlaybackAid0.setEnabled(self.aw.qmc.backgroundReproduce)

# self.backgroundPlaybackAid1Label = QLabel('2')
# self.backgroundPlaybackAid1Label.setEnabled(self.aw.qmc.backgroundReproduce)
self.backgroundPlaybackAid1 = QCheckBox(self.aw.qmc.etypesf(1))
self.backgroundPlaybackAid1.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.backgroundPlaybackAid1.setChecked(self.aw.qmc.specialeventplaybackaid[1])
self.backgroundPlaybackAid1.stateChanged.connect(self.setplaybackaideventtypeenabled)
self.backgroundPlaybackAid1.setEnabled(self.aw.qmc.backgroundReproduce)
self.backgroundPlaybackAid1Label = QLabel('2')
self.backgroundPlaybackAid1Label.setEnabled(self.aw.qmc.backgroundReproduce)

# self.backgroundPlaybackAid2Label = QLabel('3')
# self.backgroundPlaybackAid2Label.setEnabled(self.aw.qmc.backgroundReproduce)
self.backgroundPlaybackAid2 = QCheckBox(self.aw.qmc.etypesf(2))
self.backgroundPlaybackAid2.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.backgroundPlaybackAid2.setChecked(self.aw.qmc.specialeventplaybackaid[2])
self.backgroundPlaybackAid2.stateChanged.connect(self.setplaybackaideventtypeenabled)
self.backgroundPlaybackAid2.setEnabled(self.aw.qmc.backgroundReproduce)
self.backgroundPlaybackAid2Label = QLabel('3')
self.backgroundPlaybackAid2Label.setEnabled(self.aw.qmc.backgroundReproduce)

# self.backgroundPlaybackAid3Label = QLabel('4')
# self.backgroundPlaybackAid3Label.setEnabled(self.aw.qmc.backgroundReproduce)
self.backgroundPlaybackAid3 = QCheckBox(self.aw.qmc.etypesf(3))
self.backgroundPlaybackAid3.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.backgroundPlaybackAid3.setChecked(self.aw.qmc.specialeventplaybackaid[3])
self.backgroundPlaybackAid3.stateChanged.connect(self.setplaybackaideventtypeenabled)
self.backgroundPlaybackAid3.setEnabled(self.aw.qmc.backgroundReproduce)
self.backgroundPlaybackAid3Label = QLabel('4')
self.backgroundPlaybackAid3Label.setEnabled(self.aw.qmc.backgroundReproduce)

tab4content1 = QHBoxLayout()
tab4content1.addWidget(self.backgroundReproduce)
Expand All @@ -326,44 +333,44 @@ def __init__(self, parent:QWidget, aw:'ApplicationWindow', activeTab:int = 0) ->
tab4content1.addWidget(self.etimeunit)
tab4content1.addSpacing(20)
tab4content1.addStretch()
tab4content1.addWidget(self.backgroundPlaybackAid0Label)
# tab4content1.addWidget(self.backgroundPlaybackAid0Label)
tab4content1.addWidget(self.backgroundPlaybackAid0)
tab4content1.addSpacing(10)
tab4content1.addWidget(self.backgroundPlaybackAid1Label)
# tab4content1.addWidget(self.backgroundPlaybackAid1Label)
tab4content1.addWidget(self.backgroundPlaybackAid1)
tab4content1.addSpacing(10)
tab4content1.addWidget(self.backgroundPlaybackAid2Label)
# tab4content1.addWidget(self.backgroundPlaybackAid2Label)
tab4content1.addWidget(self.backgroundPlaybackAid2)
tab4content1.addSpacing(10)
tab4content1.addWidget(self.backgroundPlaybackAid3Label)
# tab4content1.addWidget(self.backgroundPlaybackAid3Label)
tab4content1.addWidget(self.backgroundPlaybackAid3)

self.backgroundPlaybackEvent0Label = QLabel('1')
self.backgroundPlaybackEvent0Label.setEnabled(self.aw.qmc.backgroundPlaybackEvents)
# self.backgroundPlaybackEvent0Label = QLabel('1')
# self.backgroundPlaybackEvent0Label.setEnabled(self.aw.qmc.backgroundPlaybackEvents)
self.backgroundPlaybackEvent0 = QCheckBox(self.aw.qmc.etypesf(0))
self.backgroundPlaybackEvent0.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.backgroundPlaybackEvent0.setChecked(self.aw.qmc.specialeventplayback[0])
self.backgroundPlaybackEvent0.stateChanged.connect(self.setplaybackeventtypeenabled)
self.backgroundPlaybackEvent0.setEnabled(self.aw.qmc.backgroundPlaybackEvents)

self.backgroundPlaybackEvent1Label = QLabel('2')
self.backgroundPlaybackEvent1Label.setEnabled(self.aw.qmc.backgroundPlaybackEvents)
# self.backgroundPlaybackEvent1Label = QLabel('2')
# self.backgroundPlaybackEvent1Label.setEnabled(self.aw.qmc.backgroundPlaybackEvents)
self.backgroundPlaybackEvent1 = QCheckBox(self.aw.qmc.etypesf(1))
self.backgroundPlaybackEvent1.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.backgroundPlaybackEvent1.setChecked(self.aw.qmc.specialeventplayback[1])
self.backgroundPlaybackEvent1.stateChanged.connect(self.setplaybackeventtypeenabled)
self.backgroundPlaybackEvent1.setEnabled(self.aw.qmc.backgroundPlaybackEvents)

self.backgroundPlaybackEvent2Label = QLabel('3')
self.backgroundPlaybackEvent2Label.setEnabled(self.aw.qmc.backgroundPlaybackEvents)
# self.backgroundPlaybackEvent2Label = QLabel('3')
# self.backgroundPlaybackEvent2Label.setEnabled(self.aw.qmc.backgroundPlaybackEvents)
self.backgroundPlaybackEvent2 = QCheckBox(self.aw.qmc.etypesf(2))
self.backgroundPlaybackEvent2.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.backgroundPlaybackEvent2.setChecked(self.aw.qmc.specialeventplayback[2])
self.backgroundPlaybackEvent2.stateChanged.connect(self.setplaybackeventtypeenabled)
self.backgroundPlaybackEvent2.setEnabled(self.aw.qmc.backgroundPlaybackEvents)

self.backgroundPlaybackEvent3Label = QLabel('4')
self.backgroundPlaybackEvent3Label.setEnabled(self.aw.qmc.backgroundPlaybackEvents)
# self.backgroundPlaybackEvent3Label = QLabel('4')
# self.backgroundPlaybackEvent3Label.setEnabled(self.aw.qmc.backgroundPlaybackEvents)
self.backgroundPlaybackEvent3 = QCheckBox(self.aw.qmc.etypesf(3))
self.backgroundPlaybackEvent3.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.backgroundPlaybackEvent3.setChecked(self.aw.qmc.specialeventplayback[3])
Expand All @@ -372,34 +379,39 @@ def __init__(self, parent:QWidget, aw:'ApplicationWindow', activeTab:int = 0) ->

tab4content2 = QHBoxLayout()
tab4content2.addWidget(self.backgroundPlaybackDROP)
tab4content2.addSpacing(25)
tab4content2.addSpacing(10)
tab4content2.addStretch()
tab4content2.addWidget(self.backgroundPlaybackEvents)
tab4content2.addSpacing(10)
tab4content2.addWidget(self.replayComboBox)
tab4content2.addSpacing(10)
tab4content2.addStretch()
tab4content2.addWidget(self.backgroundPlaybackEvent0Label)
# tab4content2.addWidget(self.backgroundPlaybackEvent0Label)
tab4content2.addWidget(self.backgroundPlaybackEvent0)
tab4content2.addSpacing(10)
tab4content2.addWidget(self.backgroundPlaybackEvent1Label)
# tab4content2.addWidget(self.backgroundPlaybackEvent1Label)
tab4content2.addWidget(self.backgroundPlaybackEvent1)
tab4content2.addSpacing(10)
tab4content2.addWidget(self.backgroundPlaybackEvent2Label)
# tab4content2.addWidget(self.backgroundPlaybackEvent2Label)
tab4content2.addWidget(self.backgroundPlaybackEvent2)
tab4content2.addSpacing(10)
tab4content2.addWidget(self.backgroundPlaybackEvent3Label)
# tab4content2.addWidget(self.backgroundPlaybackEvent3Label)
tab4content2.addWidget(self.backgroundPlaybackEvent3)

tab4content = QVBoxLayout()
tab4content.addLayout(tab4content1)
tab4content.addLayout(tab4content2)
tab4content.setSpacing(7)

playbackGroupLayout = QGroupBox(QApplication.translate('GroupBox','Playback'))
playbackGroupLayout.setLayout(tab4content)

optcontent = QHBoxLayout()
optcontent.addWidget(self.clearBgbeforeprofileload)
optcontent.addSpacing(5)
optcontent.addStretch()
optcontent.addWidget(self.setBatchSizeFromBackground)
optcontent.addSpacing(5)
optcontent.addStretch()
optcontent.addWidget(self.hideBgafterprofileload)
tab1layout = QVBoxLayout()
Expand Down Expand Up @@ -531,10 +543,11 @@ def setplaybackevent(self, _:int) -> None:
self.backgroundPlaybackEvent1,
self.backgroundPlaybackEvent2,
self.backgroundPlaybackEvent3,
self.backgroundPlaybackEvent0Label,
self.backgroundPlaybackEvent1Label,
self.backgroundPlaybackEvent2Label,
self.backgroundPlaybackEvent3Label]:
# self.backgroundPlaybackEvent0Label,
# self.backgroundPlaybackEvent1Label,
# self.backgroundPlaybackEvent2Label,
# self.backgroundPlaybackEvent3Label
]:
widget.setEnabled(self.aw.qmc.backgroundPlaybackEvents)

@pyqtSlot(int)
Expand Down Expand Up @@ -591,16 +604,24 @@ def setreproduce(self, _:int) -> None:
self.backgroundPlaybackAid1,
self.backgroundPlaybackAid2,
self.backgroundPlaybackAid3,
self.backgroundPlaybackAid0Label,
self.backgroundPlaybackAid1Label,
self.backgroundPlaybackAid2Label,
self.backgroundPlaybackAid3Label]:
# self.backgroundPlaybackAid0Label,
# self.backgroundPlaybackAid1Label,
# self.backgroundPlaybackAid2Label,
# self.backgroundPlaybackAid3Label
]:
widget.setEnabled(self.aw.qmc.backgroundReproduce)
self.backgroundReproduceBeep.setEnabled(self.aw.qmc.backgroundReproduce)
self.etimeSpinBox.setEnabled(self.aw.qmc.backgroundReproduce)
self.etimelabel.setEnabled(self.aw.qmc.backgroundReproduce)
self.etimeunit.setEnabled(self.aw.qmc.backgroundReproduce)

@pyqtSlot(int)
def optsetBatchSizeFromBackground(self, _:int) -> None:
if self.setBatchSizeFromBackground.isChecked():
self.aw.qmc.setBatchSizeFromBackground = True
else:
self.aw.qmc.setBatchSizeFromBackground = False

@pyqtSlot(int)
def optclearbgbeforeprofileload(self, _:int) -> None:
if self.clearBgbeforeprofileload.isChecked():
Expand Down
23 changes: 19 additions & 4 deletions src/artisanlib/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class tgraphcanvas(FigureCanvas):
'backgroundReproduce', 'backgroundReproduceBeep', 'backgroundPlaybackEvents', 'backgroundPlaybackDROP', 'Betypes', 'backgroundFlavors', 'flavorbackgroundflag',
'E1backgroundtimex', 'E2backgroundtimex', 'E3backgroundtimex', 'E4backgroundtimex', 'E1backgroundvalues', 'E2backgroundvalues', 'E3backgroundvalues',
'E4backgroundvalues', 'l_backgroundeventtype1dots', 'l_backgroundeventtype2dots', 'l_backgroundeventtype3dots', 'l_backgroundeventtype4dots',
'DeltaETBflag', 'DeltaBTBflag', 'clearBgbeforeprofileload', 'hideBgafterprofileload', 'heating_types', 'operator', 'organization', 'roastertype', 'roastersize', 'roasterheating', 'drumspeed',
'DeltaETBflag', 'DeltaBTBflag', 'clearBgbeforeprofileload', 'setBatchSizeFromBackground', 'hideBgafterprofileload', 'heating_types', 'operator', 'organization', 'roastertype', 'roastersize', 'roasterheating', 'drumspeed',
'organization_setup', 'operator_setup', 'roastertype_setup', 'roastersize_setup', 'roastersize_setup_default', 'roasterheating_setup', 'roasterheating_setup_default', 'drumspeed_setup', 'last_batchsize', 'machinesetup_energy_ratings',
'machinesetup', 'roastingnotes', 'cuppingnotes', 'roastdate', 'roastepoch', 'roastepoch_timeout', 'lastroastepoch', 'batchcounter', 'batchsequence', 'batchprefix', 'neverUpdateBatchCounter',
'roastbatchnr', 'roastbatchprefix', 'roastbatchpos', 'roasttzoffset', 'roastUUID', 'scheduleID', 'scheduleDate', 'plus_default_store', 'plus_store', 'plus_store_label', 'plus_coffee',
Expand Down Expand Up @@ -1414,6 +1414,7 @@ def __init__(self, parent:QWidget, dpi:int, locale:str, aw:'ApplicationWindow')
self.DeltaETBflag:bool = False
self.DeltaBTBflag:bool = True
self.clearBgbeforeprofileload:bool = False
self.setBatchSizeFromBackground:bool = False
self.hideBgafterprofileload:bool = False

self.heating_types: Final[List[str]] = [
Expand Down Expand Up @@ -3297,6 +3298,13 @@ def event_popup_action(self, action:QAction) -> None:
self.aw.orderEvents()
self.fileDirtySignal.emit()
self.redraw_keep_view(recomputeAllDeltas=(action.key[0] in {0, 6})) # type: ignore[attr-defined] # "QAction" has no attribute "key" # on moving CHARGE or DROP, we have to recompute the Deltas
# redraw minieditor event selection line
currentevent = self.aw.eNumberSpinBox.value()
if currentevent:
self.aw.plotEventSelection(currentevent-1)
if not self.flagstart:
self.fig.canvas.draw()

try:
dlg.dialogbuttons.accepted.disconnect()
dlg.dialogbuttons.rejected.disconnect()
Expand Down Expand Up @@ -5207,7 +5215,7 @@ def playbackdrop(self) -> None:
self.adderror((QApplication.translate('Error Message','Exception:') + ' playbackdrop() {0}').format(str(ex)),getattr(exc_tb, 'tb_lineno', '?'))


# turns playback event on and fills self.replayedBackgroundEvents with already passed events if any
# turns playback event on and fills self.replayedBackgroundEvents with already passed events (w.r.t. time) if any
def turn_playback_event_ON(self) -> None:
if not self.backgroundPlaybackEvents:
# only if playback is freshly turned ON we consider to enable (potentially) already fired background events to be replayed
Expand All @@ -5223,10 +5231,13 @@ def turn_playback_event_ON(self) -> None:
additional_samples = (3 if self.autoChargeFlag else 2)
# to catch also background events scheduled for around 00:00 we relax the condition to mark
# events before now where time has already passed by 2 (or 3 with autoCHARGE) samples
short_after_CHARGE:bool = False
if self.timeindex[0] != -1 and now - start < additional_samples*sample_interval:
now -= additional_samples*sample_interval
short_after_CHARGE = True
for i, bge in enumerate(self.backgroundEvents):
if (self.timeB[bge] - now) <= 0:
if (self.timeB[bge] - now) <= 0 and not (short_after_CHARGE and self.timeB[bge] < 0):
# switching on short after CHARGE, does not disable background events before CHARGE
self.replayedBackgroundEvents.append(i)

def turn_playback_event_OFF(self) -> None:
Expand Down Expand Up @@ -6705,7 +6716,11 @@ def reset(self,redraw:bool = True, soundOn:bool = True, keepProperties:bool = Fa
self.restoreEnergyLoadDefaults()
self.restoreEnergyProtocolDefaults()
#
self.weight = (self.last_batchsize,0,self.weight[2])
if (self.backgroundprofile is not None and 'weight' in self.backgroundprofile and
self.setBatchSizeFromBackground and self.aw.schedule_window is None):
self.weight = (float(self.backgroundprofile['weight'][0]),0,str(self.backgroundprofile['weight'][2]))
else:
self.weight = (self.last_batchsize,0,self.weight[2])
self.volume = (0,0,self.volume[2])
self.density = (0,self.density[1],1,self.density[3])
# we reset ambient values to the last sampled readings in this session
Expand Down
Loading

0 comments on commit 8446e0f

Please sign in to comment.