Skip to content

Commit 7884608

Browse files
committed
fixes replay by temp
1 parent 618dc3a commit 7884608

File tree

7 files changed

+36
-30
lines changed

7 files changed

+36
-30
lines changed

src/artisanlib/acaia.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import asyncio
1919
import logging
20-
from enum import IntEnum
20+
from enum import IntEnum, unique
2121
from typing import Optional, Union, List, Tuple, Final, Callable, TYPE_CHECKING
2222

2323
if TYPE_CHECKING:
@@ -38,6 +38,7 @@
3838

3939
####
4040

41+
@unique
4142
class UNIT(IntEnum):
4243
KG = 1
4344
G = 2

src/artisanlib/aillio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ def set_preheat(self, temp: int) -> None:
11371137
if __name__ == '__main__':
11381138
R1 = AillioR1(debug=False)
11391139
try:
1140-
R1._open_port()
1140+
R1._open_port() # pylint: disable=protected-access
11411141
print(f"Connected to {R1.model} using protocol V{R1.protocol}")
11421142

11431143
# Example reading loop
@@ -1157,4 +1157,4 @@ def set_preheat(self, temp: int) -> None:
11571157
except OSError as e:
11581158
print(f"Error: {e}")
11591159
finally:
1160-
R1._close_port()
1160+
R1._close_port() # pylint: disable=protected-access

src/artisanlib/canvas.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4776,6 +4776,14 @@ def sample_processing(self, local_flagstart:bool, temp1_readings:List[float], te
47764776
self.autoChargeIdx = length_of_qmc_timex - b
47774777
self.markChargeSignal.emit(False) # this queues an event which forces a realignment/redraw by resetting the cache ax_background and fires the CHARGE action
47784778

4779+
elif self.TPalarmtimeindex is None and self.timeindex[0] > -1 and len(sample_timex)>0 and ((sample_timex[-1] - sample_timex[self.timeindex[0]]) > self.TP_max_roasttime):
4780+
try:
4781+
# if 2:00min (self.TP_max_roasttime) into the roast and TPalarmtimeindex alarmindex not yet set,
4782+
# we place the TPalarmtimeindex at the current index to enable in airoasters without TP the autoDRY and autoFCs functions and activate the TP Phases LCDs
4783+
self.TPalarmtimeindex = length_of_qmc_timex - 1
4784+
except Exception as e: # pylint: disable=broad-except
4785+
_log.exception(e)
4786+
47794787
# check for TP event if already CHARGEed and not yet recognized (earliest in the next call to sample())
47804788
elif self.TPalarmtimeindex is None and self.timeindex[0] > -1 and not self.timeindex[1] and self.timeindex[0]+8 < len(sample_temp2) and self.checkTPalarmtime():
47814789
try:
@@ -4787,13 +4795,7 @@ def sample_processing(self, local_flagstart:bool, temp1_readings:List[float], te
47874795
self.markTPSignal.emit() # queued
47884796
except Exception as e: # pylint: disable=broad-except
47894797
_log.exception(e)
4790-
try:
4791-
# if 2:30min into the roast and TPalarmtimeindex alarmindex not yet set,
4792-
# we place the TPalarmtimeindex at the current index to enable in airoasters without TP the autoDRY and autoFCs functions and activate the TP Phases LCDs
4793-
if self.TPalarmtimeindex is None and ((sample_timex[-1] - sample_timex[self.timeindex[0]]) > self.TP_max_roasttime):
4794-
self.TPalarmtimeindex = length_of_qmc_timex - 1
4795-
except Exception as e: # pylint: disable=broad-except
4796-
_log.exception(e)
4798+
47974799
# autodetect DROP event
47984800
# only if 7min into roast and BT>160C/320F
47994801
if self.autoDropIdx == 0 and self.autoDropFlag and self.autoDROPenabled and self.timeindex[0] > -1 and self.timeindex[6] == 0 and \
@@ -6155,6 +6157,7 @@ def playbackevent(self) -> None:
61556157
last_event_idx = last_registered_foreground_event_idx
61566158
last_event_time = last_registered_foreground_event_time
61576159
last_event_value = self.eventsInternal2ExternalValue(self.specialeventsvalue[last_registered_foreground_event_idx])
6160+
61586161
# only if there is a last_event after TP we do ramping by temperature
61596162
if TP_time is not None and TP_time < last_event_time and len(self.specialevents)>last_event_idx:
61606163
last_event_temp1 = self.temp1[self.specialevents[last_event_idx]]
@@ -6188,15 +6191,16 @@ def playbackevent(self) -> None:
61886191

61896192
# compute ramp value if possible
61906193
if (self.replayType in {1,2} and last_event_temp is not None and next_event_temp is not None and
6191-
last_event_temp is not None and next_event_temp is not None and
61926194
current_temp is not None):
61936195
# if background event target temperature did increase (or decrease) as the foreground, we ramp by temperature
61946196
if min(last_event_temp, next_event_temp) <= current_temp <= max(last_event_temp, next_event_temp):
61956197
# we ramp only within the limits
61966198
coefficients = numpy.polyfit([last_event_temp, next_event_temp] , [last_event_value, next_event_value], 1)
61976199
ramps[event_type] = numpy.poly1d(coefficients)(current_temp)
61986200
elif (last_event_temp is None and next_event_temp is None and
6199-
(self.replayType == 0 or self.TPalarmtimeindex is None) and # replay by time active
6201+
(self.replayType == 0 or # if replay by time is selected
6202+
(last_event_temp1 is None and last_event_temp2 is None) or # if TP is not yet passed or no event after TP and now has been set
6203+
(last_event_temp2 is not None and self.replayType == 1) or (last_event_temp1 is not None and self.replayType == 2)) and # replay by temp, but temp did not increase
62006204
last_event_time is not None and len(self.timeB)>bge):
62016205
# if replay by temp (as one or both of those event_temps is not None), but current temp did not increase we don't
62026206
# ramp by time instead as this would confuse everything.

src/artisanlib/dialogs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,6 @@ def saveTareTable(self) -> None:
711711

712712
@pyqtSlot()
713713
def weightEdited(self) -> None:
714-
_log.debug('PRINT weightEdited')
715714
sender = self.sender()
716715
if sender and isinstance(sender, QLineEdit):
717716
text = sender.text().strip()

src/artisanlib/notifications.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import time
3030
import logging
3131
from datetime import datetime, timezone
32-
from enum import Enum
32+
from enum import Enum, unique
3333
from artisanlib.util import getResourcePath
3434
from artisanlib.qtsingleapplication import QtSingleApplication
3535
import plus.util
@@ -40,6 +40,7 @@
4040

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

43+
@unique
4344
class NotificationType(Enum):
4445
ARTISAN_SYSTEM = 1 # issued by some internal Artisan activity
4546
ARTISAN_USER = 2 # issues with notify() Artisan Command

src/artisanlib/pid_control.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,18 +1435,19 @@ def pidOn(self, send_command:bool = True) -> None:
14351435
self.aw.buttonCONTROL.setStyleSheet(self.aw.pushbuttonstyles['PIDactive'])
14361436
elif self.aw.qmc.Controlbuttonflag:
14371437
# software PID
1438-
self.aw.qmc.pid.setPID(self.pidKp,self.pidKi,self.pidKd)
1439-
self.aw.qmc.pid.setLimits((-100 if self.pidNegativeTarget else 0),(100 if self.pidPositiveTarget else 0))
1440-
self.aw.qmc.pid.setDutySteps(self.dutySteps)
1441-
self.aw.qmc.pid.setDutyMin(self.dutyMin)
1442-
self.aw.qmc.pid.setDutyMax(self.dutyMax)
1443-
self.aw.qmc.pid.setControl(self.setEnergy)
1444-
self.aw.qmc.pid.setDerivativeFilterLevel(self.derivative_filter)
1445-
if self.svMode == 0:
1446-
self.setSV(self.aw.sliderSV.value())
1447-
self.pidActive = True
1448-
self.aw.qmc.pid.on()
1449-
self.aw.buttonCONTROL.setStyleSheet(self.aw.pushbuttonstyles['PIDactive'])
1438+
if not self.pidActive: # only if not yet active!
1439+
self.aw.qmc.pid.setPID(self.pidKp,self.pidKi,self.pidKd)
1440+
self.aw.qmc.pid.setLimits((-100 if self.pidNegativeTarget else 0),(100 if self.pidPositiveTarget else 0))
1441+
self.aw.qmc.pid.setDutySteps(self.dutySteps)
1442+
self.aw.qmc.pid.setDutyMin(self.dutyMin)
1443+
self.aw.qmc.pid.setDutyMax(self.dutyMax)
1444+
self.aw.qmc.pid.setControl(self.setEnergy)
1445+
self.aw.qmc.pid.setDerivativeFilterLevel(self.derivative_filter)
1446+
if self.svMode == 0:
1447+
self.setSV(self.aw.sliderSV.value())
1448+
self.pidActive = True
1449+
self.aw.qmc.pid.on()
1450+
self.aw.buttonCONTROL.setStyleSheet(self.aw.pushbuttonstyles['PIDactive'])
14501451
if self.sv is None and self.svMode == 0: # only in manual SV mode we initialize the SV on PID ON
14511452
self.setSV(self.svValue)
14521453

src/includes/Machines/Santoker/Cube_Bluetooth_PID.aset

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ alarmoffset=2, 3, 1, 1, 1, 90, 1
130130
alarmsetlabel=
131131
alarmsfile=
132132
alarmsource=-3, -3, -3, -3, -3, -3, -3
133-
alarmstrings=60, 90, 1 # replay by time and PID ON, 100, 0, 30, 3 # event replay OFF
133+
alarmstrings=60, 50, 1 # replay by time and PID ON, 100, 0, 30, 3 # event replay OFF
134134
alarmtemperature=500, 500, 500, 500, 500, 500, 500
135135
alarmtime=-1, -1, -1, 6, 6, 10, 6
136136
loadAlarmsFromBackground=false
@@ -146,9 +146,9 @@ invertControl=false
146146
negativeTargetMax=100
147147
negativeTargetMin=0
148148
negativeTargetRangeLimit=false
149-
pidKp=0.65
150-
pidKi=0.025
151-
pidKd=3.5
149+
pidKp=1.1
150+
pidKi=0.09
151+
pidKd=5
152152
pidNegativeTarget=0
153153
pidOnCHARGE=true
154154
pidPositiveTarget=4

0 commit comments

Comments
 (0)