@@ -951,6 +951,7 @@ def __init__(self, parent:QWidget, dpi:int, locale:str, aw:'ApplicationWindow')
951
951
# ids of (main) devices (without a + in front of their name string)
952
952
# that do NOT communicate via any serial port thus do not need any serial port configuration
953
953
self.nonSerialDevices : Final[List[int]] = self.phidgetDevices + [
954
+ 18, # NONE (manual)
954
955
27, # Program
955
956
45, # Yocto Thermocouple
956
957
46, # Yocto PT100
@@ -3696,6 +3697,14 @@ def onclick(self, event:'MouseEvent') -> None:
3696
3697
QDesktopServices.openUrl(QUrl(roastLink(self.roastUUID), QUrl.ParsingMode.TolerantMode))
3697
3698
return
3698
3699
3700
+ if event.dblclick and event.button == 1 and not self.designerflag and not self.wheelflag and event.inaxes:
3701
+ if self.ax.get_autoscaley_on():
3702
+ self.ax.autoscale(enable=False, axis='y', tight=False)
3703
+ self.redraw(recomputeAllDeltas=False)
3704
+ else:
3705
+ self.ax.autoscale(enable=True, axis='y', tight=False)
3706
+ self.fig.canvas.draw_idle()
3707
+
3699
3708
if not self.wheelflag and event.inaxes is None and event.button == 1 and event.dblclick and event.x > event.y:
3700
3709
fig = self.ax.get_figure()
3701
3710
if fig is None:
@@ -5837,7 +5846,6 @@ def turn_playback_event_OFF(self) -> None:
5837
5846
# called only after CHARGE
5838
5847
def playbackevent(self) -> None:
5839
5848
try:
5840
-
5841
5849
#needed when using device NONE
5842
5850
if self.timex:
5843
5851
#find time or temp distances
@@ -5874,12 +5882,23 @@ def playbackevent(self) -> None:
5874
5882
5875
5883
timed = self.timeB[bge] - now
5876
5884
delta:float = 1 # by default don't trigger this one
5885
+ increasing:bool = True
5877
5886
if self.replayType == 0: # replay by time
5878
5887
delta = timed
5879
5888
elif not next_byTemp_checked[event_type] and self.replayType == 1: # replay by BT (after TP)
5880
5889
if self.TPalarmtimeindex is not None:
5881
5890
if len(self.ctemp2)>0 and self.ctemp2[-1] is not None and len(self.stemp2B)>bge:
5882
5891
delta = self.stemp2B[bge] - self.ctemp2[-1]
5892
+ try:
5893
+ # if last registered event of event_type has higher BT as next to be replayed one, we
5894
+ # expect a temperature decrease instead of an increase
5895
+ last_registered_event_index = len(self.specialeventstype) - 1 - self.specialeventstype[::-1].index(event_type)
5896
+ if self.stemp2B[self.specialevents[last_registered_event_index]] > self.stemp2B[bge]:
5897
+ delta = self.ctemp2[-1] - self.stemp2B[bge]
5898
+ increasing = False
5899
+ except Exception: # pylint: disable=broad-except
5900
+ # a previous event of that type might not yet exist
5901
+ pass
5883
5902
next_byTemp_checked[event_type] = True
5884
5903
else: # before TP we switch back to time-based
5885
5904
delta = timed
@@ -5888,6 +5907,16 @@ def playbackevent(self) -> None:
5888
5907
if self.TPalarmtimeindex is not None:
5889
5908
if len(self.ctemp1)> 0 and self.ctemp1[-1] is not None and len(self.stemp1)>bge:
5890
5909
delta = self.stemp1B[bge] - self.ctemp1[-1]
5910
+ try:
5911
+ # if last registered event of event_type has higher BT as next to be replayed one, we
5912
+ # expect a temperature decrease instead of an increase
5913
+ last_registered_event_index = len(self.specialeventstype) - 1 - self.specialeventstype[::-1].index(event_type)
5914
+ if self.stemp1B[self.specialevents[last_registered_event_index]] > self.stemp1B[bge]:
5915
+ delta = self.ctemp1[-1] - self.stemp1B[bge]
5916
+ increasing = False
5917
+ except Exception: # pylint: disable=broad-except
5918
+ # a previous event of that type might not yet exist
5919
+ pass
5891
5920
next_byTemp_checked[event_type] = True
5892
5921
else: # before TP we switch back to time-based
5893
5922
delta = timed
@@ -5986,7 +6015,8 @@ def playbackevent(self) -> None:
5986
6015
5987
6016
# for ramp by BT only after TP and if BT increased
5988
6017
if (self.TPalarmtimeindex is not None and self.replayType == 1 and len(self.temp2)>1 and self.temp2[-1] != -1 and
5989
- self.temp2[-2] != -1 and self.temp2[-1] > self.temp2[-2] and len(self.specialevents) > last_registered_event_idx and
6018
+ self.temp2[-2] != -1 and ((increasing and self.temp2[-1] >= self.temp2[-2]) or (not increasing and self.temp2[-1] <= self.temp2[-2])) and
6019
+ len(self.specialevents) > last_registered_event_idx and
5990
6020
len(self.temp2)> self.specialevents[last_registered_event_idx] and
5991
6021
len(self.temp2B) > bge):
5992
6022
# we ramp by BT only after TP and if BT increased, however, last event could be before TP
@@ -5997,7 +6027,8 @@ def playbackevent(self) -> None:
5997
6027
next_event_temp = self.temp2B[bge]
5998
6028
current_temp = self.temp2[-1]
5999
6029
elif (self.TPalarmtimeindex is not None and self.replayType == 2 and len(self.temp1)>1 and self.temp1[-1] != -1 and
6000
- self.temp1[-2] != -1 and self.temp1[-1] > self.temp1[-2] and len(self.specialevents) > last_registered_event_idx and
6030
+ self.temp1[-2] != -1 and ((increasing and self.temp1[-1] >= self.temp1[-2]) or (not increasing and self.temp1[-1] <= self.temp1[-2])) and
6031
+ len(self.specialevents) > last_registered_event_idx and
6001
6032
len(self.temp1)> self.specialevents[last_registered_event_idx] and
6002
6033
len(self.temp1B) > bge):
6003
6034
# we ramp by ET only after TP and if ET increased
@@ -6010,15 +6041,15 @@ def playbackevent(self) -> None:
6010
6041
6011
6042
# compute ramp value if possible
6012
6043
if (self.replayType in {1,2} and last_event_temp is not None and next_event_temp is not None and
6013
- current_temp is not None and next_event_temp > last_event_temp ):
6014
- # if background event target temperature did increase we ramp by temperature
6044
+ current_temp is not None):
6045
+ # if background event target temperature did increase (or decrease) as the foreground, we ramp by temperature
6015
6046
coefficients = numpy.polyfit([last_event_temp, next_event_temp] , [last_value, next_value], 1)
6016
6047
ramps[event_type] = numpy.poly1d(coefficients)(current_temp)
6017
- elif (last_event_temp is None and next_event_temp is None and
6048
+ elif (last_event_temp is None and next_event_temp is None and
6018
6049
# if replay by temp (as one or both of those event_temps is not None), but current temp did not increase we don't
6019
6050
# ramp by time instead as this would confuse everything.
6020
6051
len(self.timex)> self.specialevents[last_registered_event_idx] and len(self.timeB)>bge):
6021
- # otherwise we ramp by time
6052
+ # we ramp by time
6022
6053
last_time = self.timex[self.specialevents[last_registered_event_idx]]
6023
6054
next_time = self.timeB[bge]
6024
6055
coefficients = numpy.polyfit([last_time, next_time], [last_value, next_value], 1)
0 commit comments