Skip to content

Commit

Permalink
- reimplementation of Hottop communication using asyncio
Browse files Browse the repository at this point in the history
- allow the import of IKAWA profiles from URLs on platforms without Bluetooh BLE support
  • Loading branch information
MAKOMO committed Sep 29, 2023
1 parent ed1bfa9 commit 205e242
Show file tree
Hide file tree
Showing 15 changed files with 736 additions and 630 deletions.
44 changes: 31 additions & 13 deletions src/artisanlib/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
from Phidget22.VoltageRange import VoltageRange # type: ignore

try:
# spanning a second multiprocessing instance (Hottop server) on macOS falils to import the YAPI interface
# spanning a second multiprocessing instance on macOS falils to import the YAPI interface
from yoctopuce.yocto_api import YAPI # type: ignore
except Exception: # pylint: disable=broad-except
pass
Expand Down Expand Up @@ -11351,8 +11351,19 @@ def OnMonitor(self):
if not bool(self.aw.simulator):
if self.device == 53:
# connect HOTTOP
from artisanlib.hottop import startHottop
startHottop(0.6,self.aw.ser.comport,self.aw.ser.baudrate,self.aw.ser.bytesize,self.aw.ser.parity,self.aw.ser.stopbits,self.aw.ser.timeout,self.device_logging)
from artisanlib.hottop import Hottop
self.aw.hottop = Hottop()
self.aw.hottop.setLogging(self.device_logging)
hottop_serial:SerialSettings = {
'port': self.aw.ser.comport,
'baudrate': self.aw.ser.baudrate,
'bytesize': self.aw.ser.bytesize,
'stopbits': self.aw.ser.stopbits,
'parity': self.aw.ser.parity,
'timeout': self.aw.ser.timeout}
self.aw.hottop.start(hottop_serial,
connected_handler=lambda : self.aw.sendmessageSignal.emit(QApplication.translate('Message', '{} connected').format('Hottop'),True,None),
disconnected_handler=lambda : self.aw.sendmessageSignal.emit(QApplication.translate('Message', '{} disconnected').format('Hottop'),True,None))
elif self.device == 134:
# connect Santoker
from artisanlib.santoker import SantokerNetwork
Expand Down Expand Up @@ -11395,13 +11406,20 @@ def OnMonitor(self):
connected_handler=lambda : self.aw.sendmessageSignal.emit(QApplication.translate('Message', '{} connected').format('Kaleido'),True,None),
disconnected_handler=lambda : self.aw.sendmessageSignal.emit(QApplication.translate('Message', '{} disconnected').format('Kaleido'),True,None))
elif self.device == 142:
from artisanlib.ikawa import IKAWA_BLE
self.aw.ikawa = IKAWA_BLE(
connected_handler=lambda : self.aw.sendmessageSignal.emit(QApplication.translate('Message', '{} connected').format('IKAWA'),True,None),
disconnected_handler=lambda : self.aw.sendmessageSignal.emit(QApplication.translate('Message', '{} disconnected').format('IKAWA'),True,None))
if self.aw.ikawa is not None:
self.aw.ikawa.start()
self.aw.sendmessageSignal.emit(QApplication.translate('Message', 'scanning for device'),True,None)
try:
from artisanlib.ikawa import IKAWA_BLE
self.aw.ikawa = IKAWA_BLE(
connected_handler=lambda : self.aw.sendmessageSignal.emit(QApplication.translate('Message', '{} connected').format('IKAWA'),True,None),
disconnected_handler=lambda : self.aw.sendmessageSignal.emit(QApplication.translate('Message', '{} disconnected').format('IKAWA'),True,None))
if self.aw.ikawa is not None:
self.aw.ikawa.start()
self.aw.sendmessageSignal.emit(QApplication.translate('Message', 'scanning for device'),True,None)
except Exception as ex: # pylint: disable=broad-except
_log.error(ex)
_, _, exc_tb = sys.exc_info()
self.adderror((QApplication.translate('Error Message', 'Exception:') + ' Bluetooth BLE support not available {0}').format(str(ex)),getattr(exc_tb, 'tb_lineno', '?'))



self.aw.initializedMonitoringExtraDeviceStructures()

Expand Down Expand Up @@ -11487,11 +11505,11 @@ def OffMonitorCloseDown(self):
self.aw.pidcontrol.pidOff(send_command=self.device != 138)

try:
if not bool(self.aw.simulator) and self.device == 53:
if not bool(self.aw.simulator) and self.device == 53 and self.aw.hottop is not None:
self.aw.HottopControlOff()
# disconnect HOTTOP
from artisanlib.hottop import stopHottop
stopHottop()
self.aw.hottop.stop()
self.aw.hottop = None

# disconnect Santoker
if not bool(self.aw.simulator) and self.device == 134 and self.aw.santoker is not None:
Expand Down
18 changes: 9 additions & 9 deletions src/artisanlib/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2250,15 +2250,15 @@ def BEHMORtemperatures(self,ch1,ch2) -> Tuple[float, float]:

def HOTTOPtemperatures(self) -> Tuple[float, float]:
try:
from artisanlib.hottop import getHottop
BT, ET, heater, main_fan = getHottop()
self.aw.qmc.hottop_HEATER = heater
self.aw.qmc.hottop_MAIN_FAN = main_fan
self.aw.qmc.hottop_ET = ET
self.aw.qmc.hottop_BT = BT
if self.aw.qmc.mode == 'F':
self.aw.qmc.hottop_ET = fromCtoF(self.aw.qmc.hottop_ET)
self.aw.qmc.hottop_BT = fromCtoF(self.aw.qmc.hottop_BT)
if self.aw.hottop is not None:
BT, ET, heater, main_fan = self.aw.hottop.getState()
self.aw.qmc.hottop_HEATER = heater
self.aw.qmc.hottop_MAIN_FAN = main_fan
self.aw.qmc.hottop_ET = ET
self.aw.qmc.hottop_BT = BT
if self.aw.qmc.mode == 'F':
self.aw.qmc.hottop_ET = fromCtoF(self.aw.qmc.hottop_ET)
self.aw.qmc.hottop_BT = fromCtoF(self.aw.qmc.hottop_BT)
return self.aw.qmc.hottop_BT,self.aw.qmc.hottop_ET
except Exception as ex: # pylint: disable=broad-except
_log.exception(ex)
Expand Down
4 changes: 2 additions & 2 deletions src/artisanlib/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ def __init__(self, parent:Optional[QWidget] = None, selection:Optional[str] = No
self.edited:Optional[str] = None
if self.selection is not None:
self.setCurrentText(self.selection)
self.editTextChanged.connect(self.textEdited)
self.currentIndexChanged.connect(self.setSelection)

# we prefer the device name if available over the selection port
Expand All @@ -304,6 +303,7 @@ def __init__(self, parent:Optional[QWidget] = None, selection:Optional[str] = No
self.setCurrentIndex(pos)
except Exception: # pylint: disable=broad-except
pass
self.editTextChanged.connect(self.textEdited) # this has to be done after the setCurrentIndex above to avoid setting the self.edited to the currents ports name

@pyqtSlot(str)
def textEdited(self, txt:str) -> None:
Expand All @@ -316,8 +316,8 @@ def getSelection(self) -> Optional[str]:
def setSelection(self, i:int) -> None:
if i >= 0:
try:
self.selection = self.ports[i][0]
self.edited = None # reset the user text editing
self.selection = self.ports[i][0]
except Exception: # pylint: disable=broad-except
pass

Expand Down
Loading

0 comments on commit 205e242

Please sign in to comment.