Index: TD_End_Treatment/interface.ui =================================================================== diff -u --- TD_End_Treatment/interface.ui (revision 0) +++ TD_End_Treatment/interface.ui (revision e06da14c8ff72d3543dd9124def3485460222c1b) @@ -0,0 +1,306 @@ + + + ui_interface + + + + 0 + 0 + 427 + 105 + + + + + 100000 + 100000 + + + + &3 Treatment/&9 End Treatment + + + + + + + + + + + 0 + 0 + + + + + 352 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 238 + 238 + 236 + + + + + + + 193 + 125 + 17 + + + + + + + 238 + 238 + 236 + + + + + + + 238 + 238 + 236 + + + + + + + 193 + 125 + 17 + + + + + + + 193 + 125 + 17 + + + + + + + 238 + 238 + 236 + + + + + + + + + 238 + 238 + 236 + + + + + + + 193 + 125 + 17 + + + + + + + 238 + 238 + 236 + + + + + + + 238 + 238 + 236 + + + + + + + 193 + 125 + 17 + + + + + + + 193 + 125 + 17 + + + + + + + 238 + 238 + 236 + + + + + + + + + 238 + 238 + 236 + + + + + + + 193 + 125 + 17 + + + + + + + 238 + 238 + 236 + + + + + + + 238 + 238 + 236 + + + + + + + 193 + 125 + 17 + + + + + + + 193 + 125 + 17 + + + + + + + 238 + 238 + 236 + + + + + + + + + 10 + + + + 2 + + + color: rgb(238, 238, 236); +background-color: rgb(193, 125, 17); + + + + 142 : [0x8E00] : End Of Treatment + + + Qt::AlignCenter + + + + + + + send + + + + + + + + + + + + 180 + 0 + + + + Reason + + + + + + + 900 + + + + + + + + + + + + Index: TD_End_Treatment/loader.py =================================================================== diff -u --- TD_End_Treatment/loader.py (revision 0) +++ TD_End_Treatment/loader.py (revision e06da14c8ff72d3543dd9124def3485460222c1b) @@ -0,0 +1,91 @@ +""" + The End Treatment 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 +from leahi_dialin.common.td_defs import TDTreatmentStates +from leahi_dialin.protocols import CAN + +# hd Simulator +from leahi_dialin.ui.td_messaging import TD_Messaging + +class Loader(DynamicLoader): + """ + The End Treatment 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 + message_id = MsgIds.MSG_ID_TD_END_TREATMENT_REQUEST.value + self.can_interface.register_receiving_publication_function(channel_id, + message_id, + self.handle_end_tx_request) + + 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 , 'reasonSpinBox' ) + + def _init_connections(self): + """ + initializes the widgets connections + :return: none + """ + self.tbSend .clicked .connect(self.do_send) + + + def _init_widgets(self): + """ + initializes the widgets' properties + :return: none + """ + + @Slot() + def handle_end_tx_request(self, message, timestamp = 0.0): + """ + Called when the user requests to firmware from UI + @return: None + """ + reason = self.sbReason.value() + self.td_interface.td_end_tx_response(reason) + + if ( reason == 0 ): + self.td_interface.td_tx_state( + TDTreatmentStates.TREATMENT_RINSEBACK_STATE.value , + 0 , + 0 , + 0 , + 0 , + 0 , + 0 , + 0 , + 0 , + 0 ) + + @Slot() + def do_send(self): + """ + the slot for treatment set point Data + :return: none + """ + self.handle_end_tx_request("")