Index: TD_ParamRanges/interface.ui =================================================================== diff -u -ra4ce36086911dccdb53c3afadfc5c7014a1d9898 -rb908a6c7f02cb688cc67f9d999686b4ba7d6d246 --- TD_ParamRanges/interface.ui (.../interface.ui) (revision a4ce36086911dccdb53c3afadfc5c7014a1d9898) +++ TD_ParamRanges/interface.ui (.../interface.ui) (revision b908a6c7f02cb688cc67f9d999686b4ba7d6d246) @@ -80,6 +80,9 @@ 0 + + Qt::AlignCenter + @@ -110,6 +113,9 @@ 0 + + Qt::AlignCenter + @@ -120,6 +126,15 @@ 0 + + Qt::AlignCenter + + + 600 + + + 0 + @@ -130,6 +145,9 @@ 0 + + Qt::AlignCenter + 8000 @@ -146,6 +164,9 @@ 0 + + Qt::AlignCenter + 8000 @@ -165,6 +186,9 @@ 0 + + Qt::AlignCenter + @@ -176,8 +200,11 @@ - Treatment Time + Treatment Time (min) + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -189,8 +216,11 @@ - UF Volume + UF Volume (mL) + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -202,8 +232,11 @@ - Dial Rate + Dial Rate (mL/min) + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Index: TD_ParamRanges/loader.py =================================================================== diff -u -r871361792769299b3f8f2033b058ba343cec0aa7 -rb908a6c7f02cb688cc67f9d999686b4ba7d6d246 --- TD_ParamRanges/loader.py (.../loader.py) (revision 871361792769299b3f8f2033b058ba343cec0aa7) +++ TD_ParamRanges/loader.py (.../loader.py) (revision b908a6c7f02cb688cc67f9d999686b4ba7d6d246) @@ -67,9 +67,9 @@ :return: none """ self.tx_time_min .setValue(0) - self.tx_time_max .setValue(0) + self.tx_time_max .setValue(60) self.uf_volume_min .setValue(0) - self.uf_volume_max .setValue(8000) + self.uf_volume_max .setValue(2000) self.dial_rate_min .setValue(0) self.dial_rate_max .setValue(0) Index: TD_TreatmentAdjustmentDuration/interface.ui =================================================================== diff -u --- TD_TreatmentAdjustmentDuration/interface.ui (revision 0) +++ TD_TreatmentAdjustmentDuration/interface.ui (revision b908a6c7f02cb688cc67f9d999686b4ba7d6d246) @@ -0,0 +1,801 @@ + + + ui_interface + + + + 0 + 0 + 428 + 409 + + + + + 100000 + 100000 + + + + + 10 + + + + &3 Treatment/&7 Duration Adjustment + + + + 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); + + + + 125 : [0x8300] : Duration Edit Request + + + Qt::AlignCenter + + + + + + + + 10 + + + + Reset + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 0 + 0 + + + + + 10 + + + + QFrame::Box + + + QFrame::Raised + + + -- + + + Qt::AlignCenter + + + + + + + Duration (min) + + + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + + + color: rgb(238, 238, 236); +background-color: rgb(92, 53, 102); + + + + 127 : [0x8500] : Duration Confirm Request + + + Qt::AlignCenter + + + + + + + Reset + + + + + + + + + + + Duration (min) + + + + + + + + 0 + 0 + + + + QFrame::Box + + + QFrame::Sunken + + + -- + + + Qt::AlignCenter + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + + + color: rgb(238, 238, 236); +background-color: rgb(92, 53, 102); + + + + 128 : [0x8600] : Duration Confirm Response + + + Qt::AlignCenter + + + + + + + Send + + + + + + + Copy + + + + + + + Reset + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + Rejection Reason + + + + + + + Qt::AlignCenter + + + 100 + + + + + + + Duration (min) + + + + + + + + + 540 + + + Qt::Horizontal + + + + + + + + 40 + 0 + + + + -- + + + Qt::AlignCenter + + + + + + + + + UF Volume Goal (mL) + + + + + + + + + 8000 + + + 10 + + + 100 + + + Qt::Horizontal + + + + + + + + 40 + 0 + + + + -- + + + Qt::AlignCenter + + + + + + + + + UF Rate (L/hr) + + + + + + + + + 2000 + + + 10 + + + 100 + + + Qt::Horizontal + + + + + + + + 40 + 0 + + + + -- + + + Qt::AlignCenter + + + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + + + + 10 + + + + color: rgb(238, 238, 236); +background-color: rgb(92, 53, 102); + + + + 126 : [0x8200] : Duration Edit Response + + + Qt::AlignCenter + + + + + + + + 10 + + + + Send + + + + + + + + 10 + + + + Copy + + + + + + + + 10 + + + + Reset + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 2 + + + 2 + + + + + + 10 + + + + Rejection Reason + + + + + + + + 10 + + + + Qt::AlignCenter + + + 100 + + + + + + + + 10 + + + + Duration (min) + + + + + + + UF Volume Goal (mL) + + + + + + + + + 8000 + + + 10 + + + 100 + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + -- + + + Qt::AlignCenter + + + + + + + + + + + 540 + + + Qt::Horizontal + + + + + + + + 40 + 0 + + + + -- + + + Qt::AlignCenter + + + + + + + + + UF Rate (L/hr) + + + + + + + + + 2000 + + + 10 + + + 100 + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 40 + 0 + + + + -- + + + Qt::AlignCenter + + + + + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + + + color: rgb(238, 238, 236); +background-color: rgb(92, 53, 102); + + + + Duration Adjustment + + + Qt::AlignCenter + + + + + + + Reset + + + + + + + + + + Index: TD_TreatmentAdjustmentDuration/loader.py =================================================================== diff -u --- TD_TreatmentAdjustmentDuration/loader.py (revision 0) +++ TD_TreatmentAdjustmentDuration/loader.py (revision b908a6c7f02cb688cc67f9d999686b4ba7d6d246) @@ -0,0 +1,217 @@ +""" + 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_DURATION_VALIDATE_REQUEST.value, + self.handle_duration_edit_request) + self.can_interface.register_receiving_publication_function( + CAN.DenaliChannels.ui_to_td_ch_id, + MsgIds.MSG_ID_UI_DURATION_CONFIRM_REQUEST.value, + self.handle_duration_confirm_request) + + + def _init_loader(self): + """ + finds and creates widgets + :return: none + """ + self.tbReset = self.find_widget(QtWidgets.QToolButton , 'tbReset' ) + + self.tbEditReqReset = self.find_widget(QtWidgets.QToolButton , 'tbEditReqReset' ) + self.lbEditReqDuration = self.find_widget(QtWidgets.QLabel , 'lbEditReqDuration' ) + self.tbEditRspSend = self.find_widget(QtWidgets.QToolButton , 'tbEditRspSend' ) + self.tbEditRspCopy = self.find_widget(QtWidgets.QToolButton , 'tbEditRspCopy' ) + self.tbEditRspReset = self.find_widget(QtWidgets.QToolButton , 'tbEditRspReset' ) + self.sbEditRspRejectionReason = self.find_widget(QtWidgets.QSpinBox , 'sbEditRspRejectionReason' ) + self.slEditRspDuration = self.find_widget(QtWidgets.QSlider , 'slEditRspDuration' ) + self.lbEditRspDuration = self.find_widget(QtWidgets.QLabel , 'lbEditRspDuration' ) + self.slEditRspUfVolumeGoal = self.find_widget(QtWidgets.QSlider , 'slEditRspUfVolumeGoal' ) + self.lbEditRspUfVolumeGoal = self.find_widget(QtWidgets.QLabel , 'lbEditRspUfVolumeGoal' ) + self.slEditRspUfRate = self.find_widget(QtWidgets.QSlider , 'slEditRspUfRate' ) + self.lbEditRspUfRate = self.find_widget(QtWidgets.QLabel , 'lbEditRspUfRate' ) + + self.tbConfirmReqReset = self.find_widget(QtWidgets.QToolButton , 'tbConfirmReqReset' ) + self.lbConfirmReqDuration = self.find_widget(QtWidgets.QLabel , 'lbConfirmReqDuration' ) + self.tbConfirmRspSend = self.find_widget(QtWidgets.QToolButton , 'tbConfirmRspSend' ) + self.tbConfirmRspCopy = self.find_widget(QtWidgets.QToolButton , 'tbConfirmRspCopy' ) + self.tbConfirmRspReset = self.find_widget(QtWidgets.QToolButton , 'tbConfirmRspReset' ) + self.sbConfirmRspRejectionReason = self.find_widget(QtWidgets.QSpinBox , 'sbConfirmRspRejectionReason' ) + self.slConfirmRspDuration = self.find_widget(QtWidgets.QSlider , 'slConfirmRspDuration' ) + self.lbConfirmRspDuration = self.find_widget(QtWidgets.QLabel , 'lbConfirmRspDuration' ) + self.slConfirmRspUfVolumeGoal = self.find_widget(QtWidgets.QSlider , 'slConfirmRspUfVolumeGoal' ) + self.lbConfirmRspUfVolumeGoal = self.find_widget(QtWidgets.QLabel , 'lbConfirmRspUfVolumeGoal' ) + self.slConfirmRspUfRate = self.find_widget(QtWidgets.QSlider , 'slConfirmRspUfRate' ) + self.lbConfirmRspUfRate = self.find_widget(QtWidgets.QLabel , 'lbConfirmRspUfRate' ) + + + def _init_connections(self): + """ + initializes the widgets connections + :return: none + """ + self.tbReset .clicked .connect(self._init_widgets ) + + self.tbEditReqReset .clicked .connect(self.init_edit_request ) + self.tbEditRspSend .clicked .connect(self.do_send_edit_response ) + self.tbEditRspCopy .clicked .connect(self.do_copy_edit_response ) + self.tbEditRspReset .clicked .connect(self.init_edit_response ) + self.slEditRspDuration .valueChanged .connect(lambda value: self.lbEditRspDuration.setText(f"{value}") ) + self.slEditRspUfVolumeGoal .valueChanged .connect(lambda value: self.lbEditRspUfVolumeGoal.setText(f"{value/1000:.2f}") ) + self.slEditRspUfRate .valueChanged .connect(lambda value: self.lbEditRspUfRate.setText(f"{value/1000:.2f}") ) + + self.tbConfirmReqReset .clicked .connect(self.init_confirm_request ) + self.tbConfirmRspSend .clicked .connect(self.do_send_confirm_response ) + self.tbConfirmRspCopy .clicked .connect(self.do_copy_confirm_response ) + self.tbConfirmRspReset .clicked .connect(self.init_confirm_response ) + self.slConfirmRspDuration .valueChanged .connect(lambda value: self.lbConfirmRspDuration.setText(f"{value}") ) + self.slConfirmRspUfVolumeGoal .valueChanged .connect(lambda value: self.lbConfirmRspUfVolumeGoal.setText(f"{value/1000:.2f}") ) + self.slConfirmRspUfRate .valueChanged .connect(lambda value: self.lbConfirmRspUfRate.setText(f"{value/1000:.2f}") ) + + + def _init_widgets(self): + """ + initializes the widgets' properties + :return: none + """ + self.init_edit_request() + self.init_edit_response() + self.init_confirm_request() + self.init_confirm_response() + + + @Slot() + def init_edit_request(self): + self.lbEditReqDuration.setText("--") + + + @Slot() + def handle_duration_edit_request(self, message, timestamp = 0.0): + """ + Called when the user requests duration edit from UI + @return: None + """ + message = message['message'] + index = MsgFieldPositions.START_POS_FIELD_1 + value,index = conversions.bytearray_to_integer(message, index) + self.lbEditReqDuration.setText(f"{value}") + + + @Slot() + def init_edit_response(self): + self.sbEditRspRejectionReason .setValue(0) + + self.slEditRspDuration .setValue(0) + self.lbEditRspDuration .setText("{0}".format(self.slEditRspDuration.value())) + self.slEditRspUfVolumeGoal .setValue(0) + self.lbEditRspUfVolumeGoal .setText("{0:.2f}".format(self.slEditRspUfVolumeGoal.value() / 1000)) + self.slEditRspUfRate .setValue(0) + self.lbEditRspUfRate .setText("{0:.2f}".format(self.slEditRspUfRate.value() / 1000)) + + + @Slot() + def do_send_edit_response(self): + """ + the slot for sending duration edit response + :return: none + """ + self.td_interface.td_duration_validate_response( + self.sbEditRspRejectionReason .value(), + self.slEditRspDuration .value(), + self.slEditRspUfVolumeGoal .value(), + self.slEditRspUfRate .value() / 1000 + ) + + + @Slot() + def do_copy_edit_response(self): + """ + the slot for copying duration edit request data to edit response + :return: none + """ + convert_to_int = lambda value : int(value) if value.isdigit() else 0 + self.slEditRspDuration.setValue(convert_to_int(self.lbEditReqDuration.text())) + + + @Slot() + def init_confirm_request(self): + self.lbConfirmReqDuration.setText("--") + + + @Slot() + def handle_duration_confirm_request(self, message, timestamp = 0.0): + """ + Called when the user requests duration confirm from UI + @return: None + """ + message = message['message'] + index = MsgFieldPositions.START_POS_FIELD_1 + value,index = conversions.bytearray_to_integer(message, index) + self.lbConfirmReqDuration.setText(f"{value}") + + + @Slot() + def init_confirm_response(self): + self.sbConfirmRspRejectionReason .setValue(0) + + self.slConfirmRspDuration .setValue(0) + self.lbConfirmRspDuration .setText("{0}".format(self.slConfirmRspDuration.value())) + self.slConfirmRspUfVolumeGoal .setValue(0) + self.lbConfirmRspUfVolumeGoal .setText("{0:.2f}".format(self.slConfirmRspUfVolumeGoal.value() / 1000)) + self.slConfirmRspUfRate .setValue(0) + self.lbConfirmRspUfRate .setText("{0:.2f}".format(self.slConfirmRspUfRate.value() / 1000)) + + + @Slot() + def do_send_confirm_response(self): + """ + the slot for sending duration confirm response + :return: none + """ + self.td_interface.td_duration_confirm_response( + self.sbConfirmRspRejectionReason .value(), + self.slConfirmRspDuration .value(), + self.slConfirmRspUfVolumeGoal .value(), + self.slConfirmRspUfRate .value() / 1000 + ) + + + @Slot() + def do_copy_confirm_response(self): + """ + the slot for copying duration confirm request data to confirm response + :return: none + """ + convert_to_int = lambda value : int(value) if value.isdigit() else 0 + self.slConfirmRspDuration.setValue(convert_to_int(self.lbConfirmReqDuration.text()))