Beispiel #1
0
 def infuse(self):
     """ Pump will move plunger down until specified volume is displaced """
     amount = self.ui.amountSpinBox.value()
     logging.info(f"pump: infusing {amount} ul")
     if self.worker.isRunning():
         logging.error("pump: error! pump not ready")
         return
     self.worker = CallbackWorker(self._pump.settargetvolume,
                                  amount,
                                  slotOnFinished=self.do_infuse)
     self.worker.start()
Beispiel #2
0
 def withdraw(self):
     """ Pump will move plunge up until specified volume is gained """
     amount = self.ui.amountSpinBox.value()
     logging.info(f"pump: withdrawing {amount} ul")
     if self.worker.isRunning():
         logging.error("pump: error! pump not ready")
         return
     self.worker = CallbackWorker(self._pump.settargetvolume,
                                  amount,
                                  slotOnFinished=self.do_withdraw)
     self.worker.start()
Beispiel #3
0
    def empty(self):
        """ Pump will empty syringe completely  

        **Caution!** only use if limitswitches are properly setup to avoid damage to syringe
        """
        logging.info("emptying syringe")
        if self.worker.isRunning():
            logging.error("pump: error! pump not ready")
            return
        self.worker = CallbackWorker(self._pump.settargetvolume,
                                     1000,
                                     slotOnFinished=self.do_infuse)
        self.worker.start()
Beispiel #4
0
    def fill(self):
        """ Pump will fill the current syringe to max level

        **Caution!** only use if limitswitches are properly setup to avoid damage to syringe
        """
        logging.info("filling syringe")
        if self.worker.isRunning():
            logging.error("pump: error! pump not ready")
            return
        self.worker = CallbackWorker(self._pump.settargetvolume,
                                     1000,
                                     slotOnFinished=self.do_withdraw)
        self.worker.start()
Beispiel #5
0
 def __init__(self, parent=None) -> None:
     super(PumpControl, self).__init__(parent)
     self.ui: Ui_main = self.window().ui
     port = self.find_com_port()
     self._context_depth = 0
     logging.debug("initialize pump")
     try:
         chain = pumpy.Chain(port)
         self._pump = pumpy.Microliter(chain, name='Pump')
     except Exception as ex:
         self._pump = None
         logging.warning('Pump Error:' + str(ex))
     self.worker: Worker = Worker(None)
Beispiel #6
0
class PumpControl(QGroupBox):
    """
    provides a grupbox with UI to control the pump 
    """
    def __init__(self, parent=None) -> None:
        super(PumpControl, self).__init__(parent)
        self.ui: Ui_main = self.window().ui
        port = self.find_com_port()
        self._context_depth = 0
        logging.debug("initialize pump")
        try:
            chain = pumpy.Chain(port)
            self._pump = pumpy.Microliter(chain, name='Pump')
        except Exception as ex:
            self._pump = None
            logging.warning('Pump Error:' + str(ex))
        self.worker: Worker = Worker(None)

    def showEvent(self, event):
        self._pump.stop()
        self._pump.setdiameter(self.ui.diamSpinBox.value())
        self._pump.setflowrate(self.ui.flowSpinBox.value())  # 2ul / s
        self.connect_signals()

    def connect_signals(self):
        self.ui.dispenseBtn.clicked.connect(self.infuse)
        self.ui.collectBtn.clicked.connect(self.withdraw)
        self.ui.fillBtn.clicked.connect(self.fill)
        self.ui.emptyBtn.clicked.connect(self.empty)
        self.ui.stopPumpBtn.clicked.connect(self.stop)
        self.ui.syringeApplyBtn.clicked.connect(self.apply_settings)

    def fill(self):
        """ Pump will fill the current syringe to max level

        **Caution!** only use if limitswitches are properly setup to avoid damage to syringe
        """
        logging.info("filling syringe")
        if self.worker.isRunning():
            logging.error("pump: error! pump not ready")
            return
        self.worker = CallbackWorker(self._pump.settargetvolume,
                                     1000,
                                     slotOnFinished=self.do_withdraw)
        self.worker.start()

    def empty(self):
        """ Pump will empty syringe completely  

        **Caution!** only use if limitswitches are properly setup to avoid damage to syringe
        """
        logging.info("emptying syringe")
        if self.worker.isRunning():
            logging.error("pump: error! pump not ready")
            return
        self.worker = CallbackWorker(self._pump.settargetvolume,
                                     1000,
                                     slotOnFinished=self.do_infuse)
        self.worker.start()

    def infuse(self):
        """ Pump will move plunger down until specified volume is displaced """
        amount = self.ui.amountSpinBox.value()
        logging.info(f"pump: infusing {amount} ul")
        if self.worker.isRunning():
            logging.error("pump: error! pump not ready")
            return
        self.worker = CallbackWorker(self._pump.settargetvolume,
                                     amount,
                                     slotOnFinished=self.do_infuse)
        self.worker.start()

    def withdraw(self):
        """ Pump will move plunge up until specified volume is gained """
        amount = self.ui.amountSpinBox.value()
        logging.info(f"pump: withdrawing {amount} ul")
        if self.worker.isRunning():
            logging.error("pump: error! pump not ready")
            return
        self.worker = CallbackWorker(self._pump.settargetvolume,
                                     amount,
                                     slotOnFinished=self.do_withdraw)
        self.worker.start()

    def do_withdraw(self):
        if self.worker.isRunning():
            logging.error("pump: error! pump not ready")
            return
        self.worker = Worker(self._pump.withdraw)
        self.worker.start()

    def do_infuse(self):
        if self.worker.isRunning():
            logging.error("pump: error! pump not ready")
            return
        self.worker = Worker(self._pump.infuse)
        self.worker.start()

    def apply_settings(self):
        """ read the values from the ui and apply them to the pump """
        self._pump.setdiameter(self.ui.diamSpinBox.value())
        self._pump.setflowrate(self.ui.flowSpinBox.value())
        logging.info(
            f"set syringe diameter to {self.ui.diamSpinBox.value()} mm, flowrate to {self.ui.flowSpinBox.value()} ul/m"
        )

    def stop(self):
        """ Immediately stop the pump """
        self._pump.stop()

    @staticmethod
    def find_com_port() -> str:
        """ find the comport the pump is connected to """
        lst = comports()
        for port in lst:
            if port.manufacturer == 'Prolific':
                return port.device
Beispiel #7
0
 def do_infuse(self):
     if self.worker.isRunning():
         logging.error("pump: error! pump not ready")
         return
     self.worker = Worker(self._pump.infuse)
     self.worker.start()
Beispiel #8
0
 def do_withdraw(self):
     if self.worker.isRunning():
         logging.error("pump: error! pump not ready")
         return
     self.worker = Worker(self._pump.withdraw)
     self.worker.start()