Index: TD_Recirculate/interface.ui =================================================================== diff -u --- TD_Recirculate/interface.ui (revision 0) +++ TD_Recirculate/interface.ui (revision 6ce38e97779ae1fd01397438d8e8fd05e5232047) @@ -0,0 +1,224 @@ + + + ui_interface + + + + 0 + 0 + 463 + 166 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 100000 + 100000 + + + + + 10 + + + + &3 Treatment/&B Recirculation + + + + + + + + + 40 + 0 + + + + 0 + + + Qt::AlignCenter + + + + + + + Rejection Reason + + + + + + + + 40 + 0 + + + + 0 + + + Qt::AlignCenter + + + + + + + Qt::AlignCenter + + + 100 + + + + + + + Reset + + + + + + + Timeout + + + + + + + Send + + + + + + + Req [0xA600] + + + + + + + Send + + + + + + + color: rgb(238, 238, 236); +background-color: #0E4C92; + + + + 167 : [0xA700] : Recirculation Command Response + + + Qt::AlignCenter + + + + + + + Reset + + + + + + + Countdown + + + + + + + color: rgb(238, 238, 236); +background-color: #0E4C92; + + + + 168 : [0xA800] : Recirculation Data + + + Qt::AlignCenter + + + + + + + + 200 + 0 + + + + 480 + + + Qt::Horizontal + + + + + + + + 200 + 0 + + + + 480 + + + Qt::Horizontal + + + + + + + QFrame::Box + + + QFrame::Sunken + + + -- + + + Qt::AlignCenter + + + + + + + + + + Index: TD_Recirculate/loader.py =================================================================== diff -u --- TD_Recirculate/loader.py (revision 0) +++ TD_Recirculate/loader.py (revision 6ce38e97779ae1fd01397438d8e8fd05e5232047) @@ -0,0 +1,134 @@ +""" + TD Recirculate 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): + """ + TD Recirculate 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_RECIRCULATE_REQUEST.value, + self.handle_recirculate_cmd_request) + + + def _init_loader(self): + """ + finds and creates widgets + :return: none + """ + self.cmdStrings = [ + "Request Reconnect to system", + "Confirm Reconnect", + "Resume Recirculation", + "End Treatment", + "Confirm Disconnect/ Begin Recirc", + ] + + self.tbProgReset = self.find_widget(QtWidgets.QToolButton , 'tbProgReset' ) + self.tbProgSend = self.find_widget(QtWidgets.QToolButton , 'tbProgSend' ) + self.slTimeout = self.find_widget(QtWidgets.QSlider , 'slTimeout' ) + self.lbTimeout = self.find_widget(QtWidgets.QLabel , 'lbTimeout' ) + self.slCountdown = self.find_widget(QtWidgets.QSlider , 'slCountdown' ) + self.lbCountdown = self.find_widget(QtWidgets.QLabel , 'lbCountdown' ) + self.lbReqCommand = self.find_widget(QtWidgets.QLabel , 'lbReqCommand' ) + self.tbRspReset = self.find_widget(QtWidgets.QToolButton , 'tbRspReset' ) + self.tbRspSend = self.find_widget(QtWidgets.QToolButton , 'tbRspSend' ) + self.sbRspRejectReason = self.find_widget(QtWidgets.QSpinBox , 'sbRspRejectReason' ) + + + def _init_connections(self): + """ + initializes the widget's connections + :return: none + """ + self.tbProgReset .clicked.connect ( self.init_progress ) + self.tbProgSend .clicked.connect ( self.do_recirculate_progress ) + + self.slTimeout .valueChanged.connect ( self.do_recirculate_progress ) + self.slTimeout .valueChanged.connect ( lambda value: self.lbTimeout.setText(f"{value}") ) + self.slCountdown .valueChanged.connect ( self.do_recirculate_progress ) + self.slCountdown .valueChanged.connect ( lambda value: self.lbCountdown.setText(f"{value}") ) + + self.tbRspReset .clicked.connect ( self.init_cmd_response ) + self.tbRspSend .clicked.connect ( self.do_recirculate_cmd_response ) + + + @Slot() + def _init_widgets(self): + """ + initializes the widget's properties + :return: none + """ + self.init_progress() + self.init_cmd_response() + + + @Slot() + def init_progress(self): + self.slTimeout .setValue ( 0 ) + self.slCountdown .setValue ( 0 ) + + + @Slot() + def init_cmd_response(self): + self.lbReqCommand .setText ("-- --") + self.sbRspRejectReason .setValue (0) + + + @Slot() + def do_recirculate_progress(self): + """ + the slot for sending rinseback progress data + :return: none + """ + print("do_recirculate_progress") + + # self.td_interface.td_recirculate_progress( + # self.slTimeout .value(), + # self.slCountdown .value(), + # ) + + + @Slot() + def handle_recirculate_cmd_request(self, message, timestamp = 0.0): + """ + Called when the user sends a rinseback command request to firmware from UI + @return: None + """ + message = message['message'] + index = MsgFieldPositions.START_POS_FIELD_1 + value,index = conversions.bytearray_to_integer(message, index) + cmdString = self.cmdStrings[value] if value >= 0 and value < len(self.cmdStrings) else "" + self.lbReqCommand.setText(f"{cmdString} ({value})") + + + @Slot() + def do_recirculate_cmd_response(self): + print("do_recirculate_cmd_response") + # self.td_interface.td_recirculate_cmd_response(self.sbRspRejectReason.value()) Index: TD_Rinseback/interface.ui =================================================================== diff -u -r888d30a914d3a6bae125b8c564f48d53762b0c26 -r6ce38e97779ae1fd01397438d8e8fd05e5232047 --- TD_Rinseback/interface.ui (.../interface.ui) (revision 888d30a914d3a6bae125b8c564f48d53762b0c26) +++ TD_Rinseback/interface.ui (.../interface.ui) (revision 6ce38e97779ae1fd01397438d8e8fd05e5232047) @@ -34,7 +34,7 @@ - &4 Rinseback/&Rinseback + &3 Treatment/&A Rinseback