Skip to content

Commit 5a95c3e

Browse files
committed
- scheduler updates
- improves handling of transparencies in colors
1 parent 8eef369 commit 5a95c3e

14 files changed

+583
-220
lines changed

src/artisanlib/canvas.py

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,11 @@ def __init__(self, parent:QWidget, dpi:int, locale:str, aw:'ApplicationWindow')
871871
f'+IKAWA {deltaLabelUTF8}Humidity/{deltaLabelUTF8}Humidity Dir.', #160
872872
'+Omega HH309 34', #161
873873
'Digi-Sense 20250-07', #162
874-
'Extech 42570' #163
874+
'Extech 42570', #163
875+
'Mugma BT/ET', #164
876+
'+Mugma Heater/Fan', #165
877+
'+Mugma Catalyzer', #166
878+
'+Mugma SV' #167
875879
]
876880

877881
# ADD DEVICE:
@@ -933,7 +937,8 @@ def __init__(self, parent:QWidget, dpi:int, locale:str, aw:'ApplicationWindow')
933937
133, # Yocto Sensor
934938
134, # Santoker BT/ET
935939
138, # Kaleido BT/ET
936-
142 # IKAWA
940+
142, # IKAWA,
941+
164 # Mugma BT/ET
937942
]
938943

939944
# ADD DEVICE:
@@ -1002,7 +1007,9 @@ def __init__(self, parent:QWidget, dpi:int, locale:str, aw:'ApplicationWindow')
10021007
157, # +Phidget DAQ1301 23
10031008
158, # +Phidget DAQ1301 45
10041009
159, # +Phidget DAQ1301 67
1005-
160 # IKAWA \Delta Humidity / \Delat Humidity direction
1010+
160, # IKAWA \Delta Humidity / \Delat Humidity direction
1011+
165, # +Mugma Heater/Fan
1012+
166 # +Mugma Catalyzer
10061013
]
10071014

10081015
# ADD DEVICE:
@@ -1031,6 +1038,8 @@ def __init__(self, parent:QWidget, dpi:int, locale:str, aw:'ApplicationWindow')
10311038
#extra devices
10321039
self.extradevices:List[int] = [] # list with indexes for extra devices
10331040
self.extratimex:List[List[float]] = [] # individual time for each extra device (more accurate). List of lists (2 dimension)
1041+
#NOTE: extra device colors may contain alpha information thus to turn them into QColors, one needs to truncate the string by [:7] to remove the alpha or
1042+
# or first convert the color string using util.rgba_colorname2argb_colorname to preserve the alpha information
10341043
self.extradevicecolor1:List[str] = [] # extra line 1 color. list with colors.
10351044
self.extradevicecolor2:List[str] = [] # extra line 2 color. list with colors.
10361045
self.extratemp1:List[List[float]] = [] # extra temp1. List of lists
@@ -3314,6 +3323,9 @@ def updateLargeExtraLCDs(self, extra1:Optional[List[Optional[str]]] = None, extr
33143323
except Exception as e: # pylint: disable=broad-except
33153324
_log.exception(e)
33163325

3326+
3327+
# ADD DEVICE:
3328+
33173329
# returns True if the extra device n, channel c, is of type MODBUS or S7, has no factor defined, nor any math formula, and is of type int
33183330
# channel c is either 0 or 1
33193331
@functools.lru_cache(maxsize=None) # noqa: B019 # pylint: disable=W1518 #for Python >= 3.9 can use @functools.cache; Not relevant here, as qmc is only created once: [B019] Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
@@ -3374,7 +3386,7 @@ def intChannel(self, n:int, c:int) -> bool:
33743386
return self.aw.s7.type[6+c] != 1 and self.aw.s7.mode[6+c] == 0 and (self.aw.s7.div[6+c] == 0 or self.aw.s7.type[6+c] == 2) and no_math_formula_defined
33753387
if self.extradevices[n] == 110: # S7_910
33763388
return self.aw.s7.type[8+c] != 1 and self.aw.s7.mode[8+c] == 0 and (self.aw.s7.div[8+c] == 0 or self.aw.s7.type[8+c] == 2) and no_math_formula_defined
3377-
if self.extradevices[n] in {54, 90, 91, 135, 136, 140, 141}: # Hottop Heater/Fan, Slider 12, Slider 34, Santoker Power / Fan, Kaleido Fan/Drum, Kaleido Heater/AH
3389+
if self.extradevices[n] in {54, 90, 91, 135, 136, 140, 141, 165}: # Hottop Heater/Fan, Slider 12, Slider 34, Santoker Power / Fan, Kaleido Fan/Drum, Kaleido Heater/AH, Mugma Heater/Fan
33783390
return True
33793391
if self.extradevices[n] == 136 and c == 0: # Santoker Drum
33803392
return True
@@ -6365,7 +6377,7 @@ def formtime(self, x:float, _pos:Optional[int]) -> str:
63656377
if s >= 59:
63666378
return f'{m+1:.0f}'
63676379
if abs(s - 30) < 1:
6368-
return f'{m:d.5}'
6380+
return f'{m:d}.5'
63696381
if s > 1:
63706382
return f'{m:.0f}:{s:02.0f}'
63716383
return f'{m:.0f}'
@@ -6377,7 +6389,7 @@ def formtime(self, x:float, _pos:Optional[int]) -> str:
63776389
if s >= 59:
63786390
return f'-{m+1:.0f}'
63796391
if abs(s-30) < 1:
6380-
return f'-{m:d.5}'
6392+
return f'-{m:d}.5'
63816393
if s > 1:
63826394
return f'-{m:.0f}:{s:02.0f}'
63836395
if m == 0:
@@ -11670,6 +11682,15 @@ def OnMonitor(self) -> None:
1167011682
_log.error(ex)
1167111683
_, _, exc_tb = sys.exc_info()
1167211684
self.adderror((QApplication.translate('Error Message', 'Exception:') + ' Bluetooth BLE support not available {0}').format(str(ex)),getattr(exc_tb, 'tb_lineno', '?'))
11685+
elif self.device == 164:
11686+
# connect Mugma
11687+
from artisanlib.mugma import Mugma
11688+
self.aw.mugma = Mugma(self.aw.mugmaHost, self.aw.mugmaPort,
11689+
connected_handler=lambda : self.aw.sendmessageSignal.emit(QApplication.translate('Message', '{} connected').format('Mugma'),True,None),
11690+
disconnected_handler=lambda : self.aw.sendmessageSignal.emit(QApplication.translate('Message', '{} disconnected').format('Mugma'),True,None))
11691+
self.aw.mugma.setLogging(self.device_logging)
11692+
self.aw.mugma.start()
11693+
1167311694

1167411695
self.aw.initializedMonitoringExtraDeviceStructures()
1167511696

@@ -11791,6 +11812,11 @@ def OffMonitorCloseDown(self) -> None:
1179111812
_log.error(e)
1179211813
self.aw.ikawa = None
1179311814

11815+
# disconnect Mugma
11816+
if not bool(self.aw.simulator) and self.device == 164 and self.aw.mugma is not None:
11817+
self.aw.mugma.stop()
11818+
self.aw.mugma = None
11819+
1179411820
# at OFF we stop the follow-background on FujiPIDs and set the SV to 0
1179511821
if self.device == 0 and self.aw.fujipid.followBackground and self.aw.fujipid.sv and self.aw.fujipid.sv > 0:
1179611822
try:
@@ -12305,8 +12331,8 @@ def OnRecorder(self) -> None:
1230512331
self.aw.updateReadingsLCDsVisibility() # update visibility of reading LCDs based on the user preference
1230612332
if self.phasesLCDflag:
1230712333
self.aw.phasesLCDs.show()
12308-
self.aw.TP2DRYlabel.setStyleSheet("background-color:'transparent'; color: " + self.palette['messages'] + ';')
12309-
self.aw.DRY2FCslabel.setStyleSheet("background-color:'transparent'; color: " + self.palette['messages'] + ';')
12334+
self.aw.TP2DRYlabel.setStyleSheet("background-color:'transparent'; color: " + self.palette['messages'][:7] + ';')
12335+
self.aw.DRY2FCslabel.setStyleSheet("background-color:'transparent'; color: " + self.palette['messages'][:7] + ';')
1231012336
if self.AUClcdFlag:
1231112337
self.aw.AUCLCD.show()
1231212338

@@ -16009,11 +16035,11 @@ def phases_to_messageline(self) -> None:
1600916035

1601016036
margin = '&nbsp;&nbsp;&nbsp;'
1601116037
text_color_rect1 = '#ffffff' if self.aw.QColorBrightness(QColor(self.palette['rect1'])) < 128 else '#000000'
16012-
string1 = f" <font color = \"{text_color_rect1}\" style=\"BACKGROUND-COLOR: {self.palette['rect1']}\">{margin}{stringfromseconds(dryphasetime)}{margin}{dryphaseP}%{margin}{dryroc}{margin}</font>"
16038+
string1 = f" <font color = \"{text_color_rect1[:7]}\" style=\"BACKGROUND-COLOR: {self.palette['rect1'][:7]}\">{margin}{stringfromseconds(dryphasetime)}{margin}{dryphaseP}%{margin}{dryroc}{margin}</font>"
1601316039
text_color_rect2 = '#ffffff' if self.aw.QColorBrightness(QColor(self.palette['rect2'])) < 128 else '#000000'
16014-
string2 = f" <font color = \"{text_color_rect2}\" style=\"BACKGROUND-COLOR: {self.palette['rect2']}\">{margin} {stringfromseconds(midphasetime)} {margin} {midphaseP}% {margin} {midroc} {margin}</font>"
16040+
string2 = f" <font color = \"{text_color_rect2[:7]}\" style=\"BACKGROUND-COLOR: {self.palette['rect2'][:7]}\">{margin} {stringfromseconds(midphasetime)} {margin} {midphaseP}% {margin} {midroc} {margin}</font>"
1601516041
text_color_rect3 = '#ffffff' if self.aw.QColorBrightness(QColor(self.palette['rect3'])) < 128 else '#000000'
16016-
string3 = f" <font color = \"{text_color_rect3}\" style=\"BACKGROUND-COLOR: {self.palette['rect3']}\">{margin} {stringfromseconds(finishphasetime)} {margin} {finishphaseP}% {margin} {finishroc} {margin}</font>"
16042+
string3 = f" <font color = \"{text_color_rect3[:7]}\" style=\"BACKGROUND-COLOR: {self.palette['rect3'][:7]}\">{margin} {stringfromseconds(finishphasetime)} {margin} {finishphaseP}% {margin} {finishroc} {margin}</font>"
1601716043
self.aw.sendmessage(f'<PRE>{string1}{string2}{string3}</PRE>',append=False)
1601816044

1601916045
#handler for moving point

0 commit comments

Comments
 (0)