""" The Bloodset auto load/eject loader """ # Python import os import can import struct # Qt from PySide2 import QtCore, QtWidgets from PySide2.QtCore import Slot # parent from engine.dynamicloader import DynamicLoader # plugin specific from leahi_dialin.common.msg_defs import MsgIds from leahi_dialin.protocols import CAN # hd Simulator from leahi_dialin.ui.td_messaging import TD_Messaging class Loader(DynamicLoader): """ The Bloodset auto load/eject ui loader """ def __init__(self): self.td_interface = TD_Messaging() self.can_interface = self.td_interface.can_interface super().__init__(os.path.dirname(__file__)) if self.can_interface is not None: channel_id = CAN.DenaliChannels.ui_to_td_ch_id load_request_message_id = MsgIds.MSG_ID_UI_ADJUST_DISPOSABLES_CONFIRM_REQUEST.value self.can_interface.register_receiving_publication_function(channel_id, load_request_message_id, self.handle_load_request) eject_request_message_id = MsgIds.MSG_ID_UI_ADJUST_DISPOSABLES_REMOVAL_CONFIRM_REQUEST.value self.can_interface.register_receiving_publication_function(channel_id, eject_request_message_id, self.handle_eject_request) def _init_loader(self): """ finds and creates widgets :return: none """ self.sbLoadReason = self.find_widget(QtWidgets.QSpinBox , 'LoadReasonSpinBox' ) self.sbEjectReason = self.find_widget(QtWidgets.QSpinBox , 'EjectReasonSpinBox' ) def _init_connections(self): """ initializes the widgets connections :return: none """ def _init_widgets(self): """ initializes the widgets' properties :return: none """ self.sbLoadReason .setValue(0) self.sbEjectReason .setValue(0) @Slot() def handle_load_request(self, message, timestamp = 0.0): """ Called when the user requests to firmware from UI @return: None """ print(" handle_load_request") reason = self.sbLoadReason.value() self.td_interface.td_blood_set_auto_load_response(reason) def handle_eject_request(self, message, timestamp = 0.0): """ Called when the user requests to firmware from UI @return: None """ print(" handle_eject_request") reason = self.sbEjectReason.value() self.td_interface.td_blood_set_auto_eject_response(reason)