Index: TD_TreatmentAdjustmentsBolusVolume/interface.ui =================================================================== diff -u --- TD_TreatmentAdjustmentsBolusVolume/interface.ui (revision 0) +++ TD_TreatmentAdjustmentsBolusVolume/interface.ui (revision f130aeba8b9749645bf7c1f8b00c68268ad3bbc0) @@ -0,0 +1,379 @@ + + + ui_interface + + + + 0 + 0 + 459 + 159 + + + + + 100000 + 100000 + + + + + 10 + + + + &3 Treatment/&6 Bolus Adjustments + + + + 5 + + + 5 + + + 5 + + + 5 + + + 5 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + + + + 0 + 0 + + + + + 352 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + + + + color: rgb(238, 238, 236); +background-color: rgb(92, 53, 102); + + + + 122 : [0x8000] : Bolus Volume Adjustments Req + + + Qt::AlignCenter + + + + + + + + 10 + + + + Reset + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 180 + 0 + + + + + 10 + + + + Bolus Volume (mL) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 10 + + + + QFrame::Box + + + QFrame::Raised + + + -- + + + Qt::AlignCenter + + + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + + + + 10 + + + + color: rgb(238, 238, 236); +background-color: rgb(92, 53, 102); + + + + 123 : [0x8100] : Bolus Volume Adjustments Rsp + + + Qt::AlignCenter + + + + + + + + 10 + + + + Send + + + + + + + + 10 + + + + Copy + + + + + + + + 10 + + + + Reset + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 2 + + + 2 + + + + + + 10 + + + + Rejection Reason + + + + + + + + 10 + + + + Qt::AlignCenter + + + 100 + + + + + + + + 10 + + + + Bolus Volume (mL) + + + + + + + + 10 + + + + Qt::AlignCenter + + + 0 + + + 400 + + + 1 + + + 0 + + + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + + + + + Index: TD_TreatmentAdjustmentsBolusVolume/loader.py =================================================================== diff -u --- TD_TreatmentAdjustmentsBolusVolume/loader.py (revision 0) +++ TD_TreatmentAdjustmentsBolusVolume/loader.py (revision f130aeba8b9749645bf7c1f8b00c68268ad3bbc0) @@ -0,0 +1,116 @@ +""" + Treatment Adjustment Pressure Limits UI 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, MsgFieldPositions +from leahi_dialin.protocols import CAN +from leahi_dialin.utils import conversions + +# TD simulator +from leahi_dialin.ui.td_messaging import TD_Messaging + +class Loader(DynamicLoader): + """ + Treatment Adjustment Pressure Limits 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: + self.can_interface.register_receiving_publication_function( + CAN.DenaliChannels.ui_to_td_ch_id, + MsgIds.MSG_ID_UI_BOLUS_VOLUME_CHANGE_REQUEST.value, + self.handle_bolus_adjustments_request) + + + def _init_loader(self): + """ + finds and creates widgets + :return: none + """ + self.tbReqReset = self.find_widget(QtWidgets.QToolButton , 'tbReqReset' ) + self.lbBolusVolumeValue = self.find_widget(QtWidgets.QLabel , 'lbBolusVolumeValue' ) + + self.tbRspSend = self.find_widget(QtWidgets.QToolButton , 'tbRspSend' ) + self.tbRspCopy = self.find_widget(QtWidgets.QToolButton , 'tbRspCopy' ) + self.tbRspReset = self.find_widget(QtWidgets.QToolButton , 'tbRspReset' ) + self.sbRejectionReason = self.find_widget(QtWidgets.QSpinBox , 'sbRejectionReason' ) + self.sbBolusVolume = self.find_widget(QtWidgets.QSpinBox , 'sbBolusVolume' ) + + + def _init_connections(self): + """ + initializes the widgets connections + :return: none + """ + self.tbReqReset .clicked .connect(self.init_bolus_adjustments_request ) + self.tbRspSend .clicked .connect(self.do_bolus_adjustments_response ) + self.tbRspCopy .clicked .connect(self.do_copy_bolus_adjustments_request ) + self.tbRspReset .clicked .connect(self.init_bolus_adjustments_response ) + + + def _init_widgets(self): + """ + initializes the widgets' properties + :return: none + """ + self.init_bolus_adjustments_request() + self.init_bolus_adjustments_response() + + + @Slot() + def init_bolus_adjustments_request(self): + self.lbBolusVolumeValue.setText("--") + + + @Slot() + def handle_bolus_adjustments_request(self, message, timestamp = 0.0): + """ + Called when the user requests pressure adjustements from UI + @return: None + """ + message = message['message'] + index = MsgFieldPositions.START_POS_FIELD_1 + value,index = conversions.bytearray_to_integer(message, index) + + self.lbBolusVolumeValue.setText("{0}".format(value)) + + + @Slot() + def init_bolus_adjustments_response(self): + self.sbRejectionReason .setValue(0) + self.sbBolusVolume .setValue(0) + + + @Slot() + def do_copy_bolus_adjustments_request(self): + convert_to_int = lambda value : int(value) if value.isdigit() else 0 + + self.sbBolusVolume.setValue(convert_to_int(self.lbBolusVolumeValue.text())) + + + @Slot() + def do_bolus_adjustments_response(self): + """ + the slot for sending pressure adjustments response + :return: none + """ + self.td_interface.td_bolus_volume_adjustment_response( + self.sbRejectionReason .value(), + self.sbBolusVolume .value() + )