Skip to content

Commit 6f8cbfa

Browse files
committed
- double click on canvas auto scales y-axis to cover all artists
- improves Cropster importer - adds replay by falling temperatures - adds 'auto' setup which picks up CHARGE and DROP events set form Atilla Gold Plus machines with automation
1 parent 2623627 commit 6f8cbfa

13 files changed

+1198
-160
lines changed

src/artisanlib/canvas.py

+38-7
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ def __init__(self, parent:QWidget, dpi:int, locale:str, aw:'ApplicationWindow')
951951
# ids of (main) devices (without a + in front of their name string)
952952
# that do NOT communicate via any serial port thus do not need any serial port configuration
953953
self.nonSerialDevices : Final[List[int]] = self.phidgetDevices + [
954+
18, # NONE (manual)
954955
27, # Program
955956
45, # Yocto Thermocouple
956957
46, # Yocto PT100
@@ -3696,6 +3697,14 @@ def onclick(self, event:'MouseEvent') -> None:
36963697
QDesktopServices.openUrl(QUrl(roastLink(self.roastUUID), QUrl.ParsingMode.TolerantMode))
36973698
return
36983699

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+
36993708
if not self.wheelflag and event.inaxes is None and event.button == 1 and event.dblclick and event.x > event.y:
37003709
fig = self.ax.get_figure()
37013710
if fig is None:
@@ -5837,7 +5846,6 @@ def turn_playback_event_OFF(self) -> None:
58375846
# called only after CHARGE
58385847
def playbackevent(self) -> None:
58395848
try:
5840-
58415849
#needed when using device NONE
58425850
if self.timex:
58435851
#find time or temp distances
@@ -5874,12 +5882,23 @@ def playbackevent(self) -> None:
58745882

58755883
timed = self.timeB[bge] - now
58765884
delta:float = 1 # by default don't trigger this one
5885+
increasing:bool = True
58775886
if self.replayType == 0: # replay by time
58785887
delta = timed
58795888
elif not next_byTemp_checked[event_type] and self.replayType == 1: # replay by BT (after TP)
58805889
if self.TPalarmtimeindex is not None:
58815890
if len(self.ctemp2)>0 and self.ctemp2[-1] is not None and len(self.stemp2B)>bge:
58825891
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
58835902
next_byTemp_checked[event_type] = True
58845903
else: # before TP we switch back to time-based
58855904
delta = timed
@@ -5888,6 +5907,16 @@ def playbackevent(self) -> None:
58885907
if self.TPalarmtimeindex is not None:
58895908
if len(self.ctemp1)> 0 and self.ctemp1[-1] is not None and len(self.stemp1)>bge:
58905909
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
58915920
next_byTemp_checked[event_type] = True
58925921
else: # before TP we switch back to time-based
58935922
delta = timed
@@ -5986,7 +6015,8 @@ def playbackevent(self) -> None:
59866015

59876016
# for ramp by BT only after TP and if BT increased
59886017
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
59906020
len(self.temp2)> self.specialevents[last_registered_event_idx] and
59916021
len(self.temp2B) > bge):
59926022
# 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:
59976027
next_event_temp = self.temp2B[bge]
59986028
current_temp = self.temp2[-1]
59996029
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
60016032
len(self.temp1)> self.specialevents[last_registered_event_idx] and
60026033
len(self.temp1B) > bge):
60036034
# we ramp by ET only after TP and if ET increased
@@ -6010,15 +6041,15 @@ def playbackevent(self) -> None:
60106041

60116042
# compute ramp value if possible
60126043
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
60156046
coefficients = numpy.polyfit([last_event_temp, next_event_temp] , [last_value, next_value], 1)
60166047
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
60186049
# if replay by temp (as one or both of those event_temps is not None), but current temp did not increase we don't
60196050
# ramp by time instead as this would confuse everything.
60206051
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
60226053
last_time = self.timex[self.specialevents[last_registered_event_idx]]
60236054
next_time = self.timeB[bge]
60246055
coefficients = numpy.polyfit([last_time, next_time], [last_value, next_value], 1)

0 commit comments

Comments
 (0)