Index: TD_Heparin/interface.ui =================================================================== diff -u --- TD_Heparin/interface.ui (revision 0) +++ TD_Heparin/interface.ui (revision 19dfca7524af56d0d755ed9df96d6646fad1cd71) @@ -0,0 +1,429 @@ + + + ui_interface + + + + 0 + 0 + 683 + 455 + + + + + 100000 + 100000 + + + + &3 Treatment/&5 Heparin + + + + + 8 + 10 + 441 + 161 + + + + + + + + + + 0 + 0 + + + + + 352 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 238 + 238 + 236 + + + + + + + 23 + 184 + 103 + + + + + + + 238 + 238 + 236 + + + + + + + 238 + 238 + 236 + + + + + + + 23 + 184 + 103 + + + + + + + 23 + 184 + 103 + + + + + + + 238 + 238 + 236 + + + + + + + + + 238 + 238 + 236 + + + + + + + 23 + 184 + 103 + + + + + + + 238 + 238 + 236 + + + + + + + 238 + 238 + 236 + + + + + + + 23 + 184 + 103 + + + + + + + 23 + 184 + 103 + + + + + + + 238 + 238 + 236 + + + + + + + + + 238 + 238 + 236 + + + + + + + 23 + 184 + 103 + + + + + + + 238 + 238 + 236 + + + + + + + 238 + 238 + 236 + + + + + + + 23 + 184 + 103 + + + + + + + 23 + 184 + 103 + + + + + + + 238 + 238 + 236 + + + + + + + + + 10 + + + + color: rgb(238, 238, 236); +background-color: rgb(23, 184, 103); + + + + XXX : [0xXX00] : Heparin + + + Qt::AlignCenter + + + + + + + send + + + + + + + + + + + + 180 + 0 + + + + Reason + + + + + + + 900 + + + + + + + + + + + + 0 + 0 + + + + + 180 + 0 + + + + Heparin Resume/Pause[0xXX00] + + + + + + + + 0 + 0 + + + + false + + + QFrame::WinPanel + + + QFrame::Sunken + + + - + + + Qt::AlignCenter + + + + + + + + + + + 120 + 290 + 481 + 41 + + + + + 10 + + + 10 + + + 10 + + + + + + 20 + 0 + + + + Target + + + + + + + + 200 + 0 + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + false + + + QFrame::WinPanel + + + QFrame::Sunken + + + - + + + Qt::AlignCenter + + + + + + + + + Index: TD_Heparin/loader.py =================================================================== diff -u --- TD_Heparin/loader.py (revision 0) +++ TD_Heparin/loader.py (revision 19dfca7524af56d0d755ed9df96d6646fad1cd71) @@ -0,0 +1,114 @@ +""" + The Heparin 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 + +# hd Simulator +from leahi_dialin.ui.td_messaging import TD_Messaging + +class Loader(DynamicLoader): + """ + The Heparin 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 + heparin_request_message_id = MsgIds.MSG_ID_TD_HEPARIN_REQUEST.value + self.can_interface.register_receiving_publication_function(channel_id, + heparin_request_message_id, + self.handle_heparin_request) + self.heparin_req.setText("Heparion Req[{0}00]".format(f"0x{heparin_request_message_id:02X}")) + + + def _init_loader(self): + """ + finds and creates widgets + :return: none + """ + self.tbSend = self.find_widget(QtWidgets.QToolButton , 'tbSend' ) + self.sbReason = self.find_widget(QtWidgets.QSpinBox , 'HeparinReasonSpinBox' ) + + self.heparin_req = self.find_widget(QtWidgets.QLabel , 'heparin_req' ) + + self.lbHeparin = self.find_widget(QtWidgets.QLabel , 'lbHeparin' ) + + def _init_connections(self): + """ + initializes the widgets connections + :return: none + """ + self.tbSend .clicked .connect(self.do_send) + # self.sbSystolic .valueChanged.connect(self.do_heparin_data) + # self.sbDiastolic .valueChanged.connect(self.do_heparin_data) + # self.sbHeartRate .valueChanged.connect(self.do_heparin_data) + + def _init_widgets(self): + """ + initializes the widgets' properties + :return: none + """ + + # self.sbSystolic .setValue(120) + # self.sbDiastolic .setValue(80) + # self.sbHeartRate .setValue(100) + self.sbReason .setValue(0) + + @Slot() + def handle_heparin_request(self, message, timestamp = 0.0): + """ + Called when the user requests to firmware from UI + @return: None + """ + message = message['message'] + print(message) + index = MsgFieldPositions.START_POS_FIELD_1 + state,index = conversions.bytearray_to_integer( message, index) + print("STATE: ") + print(state) + self.lbHeparin .setText( str(state) ) + + @Slot() + def do_heparin_data(self): + """ + the slot for Vitals Data + :return: none + """ + # systolic = self.sbSystolic .value() + # diastolic = self.sbDiastolic .value() + # heartRate = self.sbHeartRate .value() + + # self.td_interface.td_heparin( + # systolic , + # diastolic , + # heartRate + # ) + + @Slot() + def do_send(self): + """ + the slot for treatment set point Data + :return: none + """ + # reason = self.sbHeparinReason.value() + # self.td_interface.td_heparin_adjustment_response(reason) +