Skip to content

Commit e06770a

Browse files
committed
fixes long standing regression which broke the Rubasse importer (Issue #1958)
1 parent e2eae5f commit e06770a

12 files changed

Lines changed: 176 additions & 109 deletions

File tree

src/artisanlib/canvas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7220,14 +7220,14 @@ def eval_math_expression(self,mathexpression:str, t:float, equeditnumber:int|Non
72207220
else:
72217221
delta_readings = self.delta2B
72227222
if k == 0:
7223-
val, evalsign = self.shiftValueEvalsign(delta_readings,index,sign,Yshiftval)
7223+
val, evalsign = self.shiftValueEvalsign(delta_readings,index,sign,Yshiftval) # pyright:ignore[reportUnknownArgumentType]
72247224
else:
72257225
#if sampling
72267226
if RTsname is not None and RTsname != '':
72277227
idx = index + 1
72287228
else:
72297229
idx = index
7230-
val, evalsign = self.shiftValueEvalsignBackground(sample_timex, self.timeB,delta_readings,idx,sign,Yshiftval)
7230+
val, evalsign = self.shiftValueEvalsignBackground(sample_timex, self.timeB,delta_readings,idx,sign,Yshiftval) # pyright:ignore[reportUnknownArgumentType]
72317231

72327232
#add expression and values found
72337233
evaltimeexpression = ''.join((c,mathexpression[i+k+1],evalsign*2,mathexpression[i+k+4],seconddigitstr,evalsign))

src/artisanlib/main.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14239,19 +14239,19 @@ def loadbackground(self, filename:str) -> None:
1423914239
f.close()
1424014240
profile = deserialize(filename)
1424114241
self.plusAddPath(profile, filename)
14242-
self.qmc.backgroundprofile = cast('ProfileData',profile)
14243-
tb = profile['timex']
14244-
t1 = profile['temp1']
14245-
t2 = profile['temp2']
14242+
self.qmc.backgroundprofile = cast('ProfileData', profile)
14243+
tb:list[float] = profile['timex']
14244+
t1:list[float] = profile['temp1']
14245+
t2:list[float] = profile['temp2']
1424614246
# ensure that timex, temp1 and temp2 are all of the same (minimal-)length
1424714247
data_len:int = min(len(tb), len(t1), len(t2))
1424814248
tb = tb[:data_len]
1424914249
t1 = t1[:data_len]
1425014250
t2 = t2[:data_len]
1425114251

14252-
timex = profile['extratimex']
14253-
t1x = profile['extratemp1']
14254-
t2x = profile['extratemp2']
14252+
timex:list[list[float]] = profile['extratimex']
14253+
t1x:list[list[float]] = profile['extratemp1']
14254+
t2x:list[list[float]] = profile['extratemp2']
1425514255
# ensure that number of extra device data is consistent
1425614256
number_extra_devices = min(len(timex), len(t1x), len(t2x))
1425714257
timex = timex[:number_extra_devices]
@@ -14265,9 +14265,9 @@ def loadbackground(self, filename:str) -> None:
1426514265
if len(timex[c]) != data_len:
1426614266
timex[c] = tb[:]
1426714267
if len(t1x[c]) != data_len:
14268-
t1x[c] = [-1]*data_len
14268+
t1x[c] = [-1.]*data_len
1426914269
if len(t2x[c]) != data_len:
14270-
t2x[c] = [-1]*data_len
14270+
t2x[c] = [-1.]*data_len
1427114271

1427214272

1427314273
# reset the movebackground cache:
@@ -14300,7 +14300,7 @@ def loadbackground(self, filename:str) -> None:
1430014300

1430114301
names1x = [decodeLocalStrict(x) for x in profile['extraname1']]
1430214302
names2x = [decodeLocalStrict(x) for x in profile['extraname2']]
14303-
self.qmc.temp1B,self.qmc.temp2B,self.qmc.timeB, self.qmc.temp1BX, self.qmc.temp2BX = t1,t2,tb,t1x,t2x
14303+
self.qmc.temp1B,self.qmc.temp2B,self.qmc.timeB, self.qmc.temp1BX, self.qmc.temp2BX = t1,t2,tb,[numpy.array(tx) for tx in t1x],[numpy.array(tx) for tx in t2x]
1430414304
self.qmc.abs_timeB = tb.copy() #invariant copy of timeB
1430514305
self.qmc.extratimexB = timex
1430614306

@@ -14325,7 +14325,7 @@ def loadbackground(self, filename:str) -> None:
1432514325

1432614326
# we resample the temperatures to regular interval timestamps
1432714327
tb_lin:numpy.ndarray[tuple[Literal[1]],numpy.dtype[numpy.double]]|None = None
14328-
if tb is not None and tb:
14328+
if tb:
1432914329
tb_lin = cast(numpy.ndarray[tuple[Literal[1]]], numpy.linspace(tb[0],tb[-1],len(tb)))
1433014330
decay_smoothing_p = not self.qmc.optimalSmoothing
1433114331
b1 = self.qmc.smooth_list(tb,t1,window_len=self.qmc.curvefilter,decay_smoothing=decay_smoothing_p,a_lin=tb_lin)
@@ -14344,7 +14344,7 @@ def loadbackground(self, filename:str) -> None:
1434414344
if (self.qmc.xtcurveidx > 0 and n3 == i) or (self.qmc.ytcurveidx > 0 and n4 == i): # this is the 3rd or 4th background curve to be drawn, we smooth it
1434514345
tx=timex[i]
1434614346
tx_lin:numpy.ndarray[tuple[Literal[1]],numpy.dtype[numpy.double]]|None = None
14347-
if tx is not None and tx:
14347+
if tx:
1434814348
tx_lin = cast(numpy.ndarray[tuple[Literal[1]],numpy.dtype[numpy.double]], numpy.linspace(tx[0],tx[-1],len(tx)))
1434914349
if (self.qmc.xtcurveidx > 0 and n3 == i and self.qmc.xtcurveidx % 2) or (self.qmc.ytcurveidx > 0 and n4 == i and self.qmc.ytcurveidx % 2):
1435014350
b1x.append(self.qmc.smooth_list(tx,t1x[i],window_len=self.qmc.curvefilter,decay_smoothing=decay_smoothing_p,a_lin=tx_lin))

src/artisanlib/notifications.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@ def sendPlusNotificationSeen(hr_id:str, date:datetime.datetime) -> None:
125125

126126
class NotificationManager(QObject):
127127

128-
__slots__ = ( 'notification_timeout', 'notification_queue_max_length', 'notification_queue_max_age',
128+
__slots__ = ( 'tray_icon_configured', 'notification_timeout', 'notification_queue_max_length', 'notification_queue_max_age',
129129
'tray_menu', 'tray_icon', 'notifications_available', 'notifications_enabled', 'notifications_visible',
130130
'notifications_queue', 'active_notification', 'notification_menu_actions' )
131131

132132
def __init__(self) -> None:
133133
super().__init__()
134134

135+
self.tray_icon_configured:bool = False
136+
135137
# time to display a notification
136138
self.notification_timeout: Final = 12000 # 6000 # in ms
137139
# we keep the last n notifications in the tray icon menu
@@ -156,12 +158,14 @@ def __init__(self) -> None:
156158
self.active_notification:Notification|None = None
157159

158160
def configTrayIcon(self) -> None:
159-
# the tray icon is displayed only if notifications are supported by the system
160-
self.tray_icon.setIcon(self.artisanTrayIcon())
161-
self.tray_icon.setToolTip('Artisan Notifications')
162-
self.tray_icon.messageClicked.connect(self.messageClicked)
163-
#self.tray_icon.show() # if try_icon is not visible, notifications are not delivered
164-
self.tray_icon.setContextMenu(self.tray_menu)
161+
if not self.tray_icon_configured:
162+
# the tray icon is displayed only if notifications are supported by the system
163+
self.tray_icon.setIcon(self.artisanTrayIcon())
164+
self.tray_icon.setToolTip('Artisan Notifications')
165+
self.tray_icon.messageClicked.connect(self.messageClicked)
166+
#self.tray_icon.show() # if try_icon is not visible, notifications are not delivered
167+
self.tray_icon.setContextMenu(self.tray_menu)
168+
self.tray_icon_configured = True
165169

166170
@staticmethod
167171
def artisanTrayIcon() -> QIcon:
@@ -228,12 +232,16 @@ def messageClicked(self) -> None:
228232
except Exception as e: # pylint: disable=broad-except
229233
_log.exception(e)
230234

235+
def show_tray_icon(self) -> None:
236+
self.configTrayIcon()
237+
self.tray_icon.show()
238+
231239
def showNotifications(self) -> None:
232240
try:
233241
if self.notifications_available:
234242
self.notifications_visible = True
235243
if len(self.notifications_queue)>0:
236-
self.tray_icon.show()
244+
self.show_tray_icon()
237245
self.updateNotificationMenu()
238246
except Exception as e: # pylint: disable=broad-except
239247
_log.exception(e)
@@ -291,7 +299,7 @@ def updateNotificationMenu(self) -> None:
291299
self.tray_menu.clear()
292300
self.notification_menu_actions = []
293301
if len(self.notifications_queue)>0 and self.notifications_visible:
294-
self.tray_icon.show()
302+
self.show_tray_icon()
295303

296304
for n in reversed(self.notifications_queue):
297305
title = n.formatedTitle()
@@ -325,7 +333,7 @@ def showNotification(self, notification: Notification) -> None:
325333
NotificationType.PLUS_SYSTEM,
326334
NotificationType.PLUS_REMINDER,
327335
NotificationType.PLUS_ADMIN,
328-
NotificationType.PLUS_ADMIN]:
336+
NotificationType.PLUS_ADVERT]:
329337
icon = self.notificationPlusIcon()
330338
self.tray_icon.showMessage(notification.formatedTitle(), notification.message, icon, self.notification_timeout)
331339
except Exception as e: # pylint: disable=broad-except

src/artisanlib/rubasse.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def extractProfileRubasseCSV(file:str,
7878
temp1.append(et)
7979

8080
bt:float = -1.0
81+
try:
82+
bt = float(item['BT'])
83+
except Exception: # pylint: disable=broad-except
84+
pass
8185
temp2.append(bt)
8286

8387
heaterV:float = -1.0
@@ -174,7 +178,7 @@ def extractProfileRubasseCSV(file:str,
174178
specialeventsvalue.append(eventsExternal2InternalValue(int(round(v))))
175179
specialevents.append(i)
176180
specialeventstype.append(3)
177-
specialeventsStrings.append(f"{float(item['Heater'])}%")
181+
specialeventsStrings.append(f"{float(item['Heater']):.0f}%")
178182
else:
179183
heater_last = None
180184
except Exception as e: # pylint: disable=broad-except
@@ -230,8 +234,8 @@ def extractProfileRubasseCSV(file:str,
230234
res['extratemp2'] = [extra2,extra4,extra6]
231235
res['extramathexpression2'] = ['','','']
232236

233-
res['extraCurveVisibility1'] = [False, True, False, False, True, True, True, True, True, True]
234-
res['extraCurveVisibility2'] = [False, False, False, False, True, True, True, True, True, True]
237+
res['extraCurveVisibility1'] = [False, False, False, False, True, True, True, True, True, True]
238+
res['extraCurveVisibility2'] = [False, True, True, False, True, True, True, True, True, True]
235239
res['extraDelta1'] = [False]*10
236240
res['extraDelta2'] = [False]*10
237241
res['extraNoneTempHint1'] = [True, True, True]

src/includes/Machines/Behmor/1kg.aset

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)