Skip to content

Commit f59e1f8

Browse files
committed
adds import/export sanity tests [skip ci]
1 parent 857e0e9 commit f59e1f8

142 files changed

Lines changed: 11006 additions & 381 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/artisanlib/comparator.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,10 +2004,16 @@ def addProfile(self, filename:str, obj:'ProfileData') -> None:
20042004
self.profileTable.setRowCount(len(self.profiles))
20052005
self.setProfileTableRow(len(self.profiles)-1)
20062006

2007-
def addProfileFromURL(self, extractor:Callable[[QUrl, 'ApplicationWindow'], Optional['ProfileData']], url:QUrl) -> None:
2007+
def addProfileFromURL(self,
2008+
extractor:Callable[[QUrl, List[str], List[str], List[str], Callable[[int],float]], Optional['ProfileData']],
2009+
url:QUrl) -> None:
20082010
_log.info('addProfileFromURL(%s)', url)
20092011
try:
2010-
obj:Optional[ProfileData] = extractor(url, self.aw)
2012+
obj:Optional[ProfileData] = extractor(url,
2013+
self.aw.qmc.etypesdefault,
2014+
self.aw.qmc.alt_etypesdefault,
2015+
self.aw.qmc.artisanflavordefaultlabels,
2016+
self.aw.qmc.eventsExternal2InternalValue)
20112017
if obj:
20122018
self.addProfile(str(url), obj)
20132019
self.updateMenus()

src/artisanlib/cropster.py

Lines changed: 72 additions & 134 deletions
Large diffs are not rendered by default.

src/artisanlib/giesen.py

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,19 @@
55
from pathlib import Path
66
import csv
77
import logging
8-
from typing import Final, List, TYPE_CHECKING
8+
from typing import Final, List, Callable
99

10-
if TYPE_CHECKING:
11-
from artisanlib.main import ApplicationWindow # pylint: disable=unused-import
12-
13-
try:
14-
from PyQt6.QtWidgets import QApplication # @UnusedImport @Reimport @UnresolvedImport
15-
except ImportError:
16-
from PyQt5.QtWidgets import QApplication # type: ignore # @UnusedImport @Reimport @UnresolvedImport
17-
18-
from artisanlib.util import replace_duplicates
10+
from artisanlib.util import replace_duplicates, encodeLocalStrict
1911
from artisanlib.atypes import ProfileData
2012

2113
_log: Final[logging.Logger] = logging.getLogger(__name__)
2214

2315
# returns a dict containing all profile information contained in the given IKAWA CSV file
24-
def extractProfileGiesenCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
16+
def extractProfileGiesenCSV(file:str,
17+
etypesdefault:List[str],
18+
_alt_etypesdefault:List[str],
19+
_artisanflavordefaultlabels:List[str],
20+
eventsExternal2InternalValue:Callable[[int],float]) -> ProfileData:
2521
res:ProfileData = ProfileData() # the interpreted data set
2622

2723
res['samplinginterval'] = 1.0
@@ -105,8 +101,7 @@ def extractProfileGiesenCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
105101
speed_last = speed
106102
speed = v
107103
speed_event = True
108-
v = v/10. + 1
109-
specialeventsvalue.append(v)
104+
specialeventsvalue.append(eventsExternal2InternalValue(int(round(v))))
110105
specialevents.append(i)
111106
specialeventstype.append(1)
112107
specialeventsStrings.append(f'{speed:.1f}%')
@@ -132,8 +127,7 @@ def extractProfileGiesenCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
132127
power_last = power
133128
power = v
134129
power_event = True
135-
v = v/10. + 1
136-
specialeventsvalue.append(v)
130+
specialeventsvalue.append(eventsExternal2InternalValue(int(round(v))))
137131
specialevents.append(i)
138132
specialeventstype.append(3)
139133
specialeventsStrings.append(f'{power:.0f}%')
@@ -143,12 +137,8 @@ def extractProfileGiesenCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
143137
_log.exception(e)
144138

145139
res['timex'] = timex
146-
if aw.qmc.dropDuplicates:
147-
res['temp1'] = replace_duplicates(temp1)
148-
res['temp2'] = replace_duplicates(temp2)
149-
else:
150-
res['temp1'] = temp1
151-
res['temp2'] = temp2
140+
res['temp1'] = replace_duplicates(temp1)
141+
res['temp2'] = replace_duplicates(temp2)
152142
res['timeindex'] = timeindex
153143

154144
res['extradevices'] = [25,25]
@@ -169,16 +159,6 @@ def extractProfileGiesenCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
169159
res['specialeventsStrings'] = specialeventsStrings
170160
if power_event or speed_event:
171161
# first set etypes to defaults
172-
etypes:List[str] = [QApplication.translate('ComboBox', 'Air'),
173-
QApplication.translate('ComboBox', 'Drum'),
174-
QApplication.translate('ComboBox', 'Damper'),
175-
QApplication.translate('ComboBox', 'Burner'),
176-
'--']
177-
# update
178-
if speed_event:
179-
etypes[0] = 'Speed'
180-
if power_event:
181-
etypes[3] = 'Power'
182-
res['etypes'] = etypes
183-
res['title'] = Path(file).stem
162+
res['etypes'] = etypesdefault
163+
res['title'] = encodeLocalStrict(Path(file).stem)
184164
return res

src/artisanlib/ikawa.py

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,15 @@
99
import csv
1010
import re
1111
import logging
12-
from typing import Final, Optional, List, Dict, Callable, Any, Generator, TYPE_CHECKING
12+
from typing import Final, Optional, List, Dict, Callable, Any, Generator
1313

1414

15-
if TYPE_CHECKING:
16-
from artisanlib.main import ApplicationWindow # noqa: F401 # pylint: disable=unused-import
17-
1815
try:
1916
from PyQt6.QtCore import QDateTime, Qt, QMutex, QWaitCondition, QUrl # @UnusedImport @Reimport @UnresolvedImport
2017
except ImportError:
2118
from PyQt5.QtCore import QDateTime, Qt, QMutex, QWaitCondition, QUrl # type: ignore # @UnusedImport @Reimport @UnresolvedImport
2219

23-
from artisanlib.util import encodeLocal
20+
from artisanlib.util import encodeLocal, encodeLocalStrict
2421
from artisanlib.atypes import ProfileData
2522

2623

@@ -31,16 +28,19 @@
3128
_log: Final[logging.Logger] = logging.getLogger(__name__)
3229

3330

34-
def url_to_profile(url:str, log_data:bool = False) -> IkawaCmd_pb2.RoastProfile: # pylint: disable=no-member
31+
def url_to_profile(url:str) -> IkawaCmd_pb2.RoastProfile: # pylint: disable=no-member
3532
url += '=='
3633
base64_bytes = url.encode('ascii')
3734
message_bytes = base64.b64decode(base64_bytes)
38-
if log_data:
39-
_log.info('ikawa profile: %s',message_bytes)
35+
# _log.debug('ikawa profile: %s',message_bytes)
4036
return IkawaCmd_pb2.RoastProfile().FromString(message_bytes) # pylint: disable=no-member
4137

42-
def extractProfileIkawaURL(url:QUrl, aw:'ApplicationWindow') -> ProfileData:
43-
ikawa_profile = url_to_profile(url.query(), log_data=aw.qmc.device_logging)
38+
def extractProfileIkawaURL(url:QUrl,
39+
etypesdefault:List[str],
40+
_alt_etypesdefault:List[str],
41+
_artisanflavordefaultlabels:List[str],
42+
eventsExternal2InternalValue:Callable[[int],float]) -> ProfileData:
43+
ikawa_profile = url_to_profile(url.query())
4444
res:ProfileData = ProfileData() # the interpreted data set
4545
res['samplinginterval'] = 1.0
4646

@@ -79,8 +79,7 @@ def extractProfileIkawaURL(url:QUrl, aw:'ApplicationWindow') -> ProfileData:
7979
extra4.append(fan)
8080
extra5.append(-1.0)
8181
extra6.append(-1.0)
82-
v = fan/10. + 1
83-
specialeventsvalue.append(v)
82+
specialeventsvalue.append(eventsExternal2InternalValue(int(round(fan))))
8483
specialevents.append(idx)
8584
specialeventstype.append(0)
8685
specialeventsStrings.append(f'{int(fan)}' + '%')
@@ -98,8 +97,7 @@ def extractProfileIkawaURL(url:QUrl, aw:'ApplicationWindow') -> ProfileData:
9897
# we add the fan information
9998
fan = round(fan_points[0].power / 2.55)
10099
extra4.append(fan)
101-
v = fan/10. + 1
102-
specialeventsvalue.append(v)
100+
specialeventsvalue.append(eventsExternal2InternalValue(fan))
103101
specialevents.append(idx)
104102
specialeventstype.append(0)
105103
specialeventsStrings.append(f'{int(fan)}' + '%')
@@ -111,8 +109,7 @@ def extractProfileIkawaURL(url:QUrl, aw:'ApplicationWindow') -> ProfileData:
111109
extra6.append(-1.0)
112110

113111
cooldown_fan = round(ikawa_profile.cooldown_fan.power / 2.55)
114-
v = cooldown_fan/10. + 1
115-
specialeventsvalue.append(v)
112+
specialeventsvalue.append(eventsExternal2InternalValue(cooldown_fan))
116113
specialevents.append(len(timex)-1)
117114
specialeventstype.append(0)
118115
specialeventsStrings.append(f'{int(cooldown_fan)}' + '%')
@@ -150,12 +147,16 @@ def extractProfileIkawaURL(url:QUrl, aw:'ApplicationWindow') -> ProfileData:
150147
res['specialeventsvalue'] = specialeventsvalue
151148
res['specialeventsStrings'] = specialeventsStrings
152149

153-
res['etypes'] = aw.qmc.etypesdefault
150+
res['etypes'] = etypesdefault
154151
return res
155152

156153

157154
# returns a dict containing all profile information contained in the given IKAWA CSV file
158-
def extractProfileIkawaCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
155+
def extractProfileIkawaCSV(file:str,
156+
etypesdefault:List[str],
157+
_alt_etypesdefault:List[str],
158+
_artisanflavordefaultlabels:List[str],
159+
eventsExternal2InternalValue:Callable[[int],float]) -> ProfileData:
159160
res:ProfileData = ProfileData() # the interpreted data set
160161

161162
res['samplinginterval'] = 1.0
@@ -190,8 +191,6 @@ def extractProfileIkawaCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
190191
fan_last:Optional[float] = None # holds the fan event value before the last one
191192
heater:Optional[float] = None # holds last processed heater event value
192193
heater_last:Optional[float] = None # holds the heater event value before the last one
193-
# fan_event:bool = False # set to True if a fan event exists
194-
# heater_event:bool = False # set to True if a heater event exists
195194
specialevents:List[int] = []
196195
specialeventstype:List[int] = []
197196
specialeventsvalue:List[float] = []
@@ -282,9 +281,7 @@ def extractProfileIkawaCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
282281
else:
283282
fan_last = fan
284283
fan = v
285-
# fan_event = True
286-
v = v/10. + 1
287-
specialeventsvalue.append(v)
284+
specialeventsvalue.append(eventsExternal2InternalValue(int(round(v))))
288285
specialevents.append(i-1)
289286
specialeventstype.append(0)
290287
specialeventsStrings.append(f'{fan}' + '%')
@@ -313,9 +310,7 @@ def extractProfileIkawaCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
313310
else:
314311
heater_last = heater
315312
heater = v
316-
# heater_event = True
317-
v = v/10. + 1
318-
specialeventsvalue.append(v)
313+
specialeventsvalue.append(eventsExternal2InternalValue(int(round(v))))
319314
specialevents.append(i-1)
320315
specialeventstype.append(3)
321316
specialeventsStrings.append(f'{heater}' + '%')
@@ -357,8 +352,8 @@ def extractProfileIkawaCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
357352
res['specialeventsvalue'] = specialeventsvalue
358353
res['specialeventsStrings'] = specialeventsStrings
359354

360-
res['etypes'] = aw.qmc.etypesdefault
361-
res['title'] = Path(file).stem
355+
res['etypes'] = etypesdefault
356+
res['title'] = encodeLocalStrict(Path(file).stem)
362357
return res
363358

364359

src/artisanlib/loring.py

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,24 @@
66
import time as libtime
77
import csv
88
import logging
9-
from typing import Final, List, Optional, TYPE_CHECKING
10-
11-
if TYPE_CHECKING:
12-
from artisanlib.main import ApplicationWindow # pylint: disable=unused-import
9+
from typing import Final, List, Optional, Callable
1310

1411
try:
15-
from PyQt6.QtWidgets import QApplication # @UnusedImport @Reimport @UnresolvedImport
1612
from PyQt6.QtCore import QDateTime, Qt # @UnusedImport @Reimport @UnresolvedImport
1713
except ImportError:
18-
from PyQt5.QtWidgets import QApplication # type: ignore # @UnusedImport @Reimport @UnresolvedImport
1914
from PyQt5.QtCore import QDateTime, Qt # type: ignore # @UnusedImport @Reimport @UnresolvedImport
2015

21-
from artisanlib.util import replace_duplicates, fromFtoCstrict, RoRfromFtoCstrict, encodeLocal
16+
from artisanlib.util import replace_duplicates, fromFtoCstrict, RoRfromFtoCstrict, encodeLocal, encodeLocalStrict
2217
from artisanlib.atypes import ProfileData
2318

2419
_log: Final[logging.Logger] = logging.getLogger(__name__)
2520

2621
# returns a dict containing all profile information contained in the given Loring CSV file
27-
def extractProfileLoringCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
22+
def extractProfileLoringCSV(file:str,
23+
etypesdefault:List[str],
24+
_alt_etypesdefault:List[str],
25+
_artisanflavordefaultlabels:List[str],
26+
eventsExternal2InternalValue:Callable[[int],float]) -> ProfileData:
2827
res:ProfileData = ProfileData() # the interpreted data set
2928

3029
with open(file, newline='',encoding='utf-8') as csvFile:
@@ -190,8 +189,7 @@ def extractProfileLoringCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
190189
power_last = power
191190
power = v
192191
power_event = True
193-
v = v/10. + 1
194-
specialeventsvalue.append(v)
192+
specialeventsvalue.append(eventsExternal2InternalValue(int(round(v))))
195193
specialevents.append(i)
196194
specialeventstype.append(3)
197195
specialeventsStrings.append(f'{X1:.1f}%')
@@ -240,29 +238,19 @@ def extractProfileLoringCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
240238
res['samplinginterval'] = int(round(sampling_interval))
241239

242240
res['timex'] = timex
243-
if aw.qmc.dropDuplicates:
244-
res['temp1'] = replace_duplicates(temp1)
245-
res['temp2'] = replace_duplicates(temp2)
246-
else:
247-
res['temp1'] = temp1
248-
res['temp2'] = temp2
241+
res['temp1'] = replace_duplicates(temp1)
242+
res['temp2'] = replace_duplicates(temp2)
249243
res['timeindex'] = timeindex
250244

251245
res['extradevices'] = [33, 55]
252246
res['extratimex'] = [timex[:],timex[:]]
253247

254248
res['extraname1'] = ['{3}','Stack']
255-
if aw.qmc.dropDuplicates:
256-
res['extratemp1'] = [replace_duplicates(extra1), replace_duplicates(extra3)]
257-
else:
258-
res['extratemp1'] = [extra1, extra3]
249+
res['extratemp1'] = [replace_duplicates(extra1), replace_duplicates(extra3)]
259250
res['extramathexpression1'] = ['','']
260251

261252
res['extraname2'] = ['Inlet','RoR']
262-
if aw.qmc.dropDuplicates:
263-
res['extratemp2'] = [replace_duplicates(extra2), replace_duplicates(extra4)]
264-
else:
265-
res['extratemp2'] = [extra2, extra4]
253+
res['extratemp2'] = [replace_duplicates(extra2), replace_duplicates(extra4)]
266254
res['extramathexpression2'] = ['','']
267255

268256
if len(specialevents) > 0:
@@ -272,12 +260,7 @@ def extractProfileLoringCSV(file:str, aw:'ApplicationWindow') -> ProfileData:
272260
res['specialeventsStrings'] = specialeventsStrings
273261
if power_event:
274262
# first set etypes to defaults
275-
res['etypes'] = [QApplication.translate('ComboBox', 'Air'),
276-
QApplication.translate('ComboBox', 'Drum'),
277-
QApplication.translate('ComboBox', 'Damper'),
278-
QApplication.translate('ComboBox', 'Burner'),
279-
'--']
280-
263+
res['etypes'] = etypesdefault
281264

282-
res['title'] = Path(file).stem
265+
res['title'] = encodeLocalStrict(Path(file).stem)
283266
return res

0 commit comments

Comments
 (0)