Index: TD_Confirm/interface.ui =================================================================== diff -u --- TD_Confirm/interface.ui (revision 0) +++ TD_Confirm/interface.ui (revision 535067896712b7dd0c8e013008fd1badd0e9e46a) @@ -0,0 +1,220 @@ + + + ui_interface + + + + 0 + 0 + 254 + 134 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 100000 + 100000 + + + + + 10 + + + + &5 TD Info/&0 Confirm & Power Off + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + + + + 10 + + + + color: rgb(238, 238, 236); +background-color: rgb(255, 81, 96); + + + + 182 : [0xB500] : Confirm Req + + + Qt::AlignCenter + + + + + + + Send + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + UI Confirm Rsp [0xB6] + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + false + + + QFrame::WinPanel + + + QFrame::Sunken + + + - + + + Qt::AlignCenter + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + + + color: rgb(238, 238, 236); +background-color: rgb(255, 145, 194); + + + + 183 : [0xB700] : Power Off + + + Qt::AlignCenter + + + + + + + Send + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + Qt::AlignCenter + + + 100 + + + + + + + + + + + + tbConfirmSend + + + + Index: TD_Confirm/loader.py =================================================================== diff -u --- TD_Confirm/loader.py (revision 0) +++ TD_Confirm/loader.py (revision 535067896712b7dd0c8e013008fd1badd0e9e46a) @@ -0,0 +1,101 @@ +""" + TD Confirm 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 Confirm 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.CanChannels.ui_to_td_ch_id, + MsgIds.MSG_ID_UI_CONFIRMATION_RESULT_RESPONSE.value, + self.handle_confirm_cmd_request) + + + def _init_loader(self): + """ + finds and creates widgets + :return: none + """ + self.cmdStrings = [ + "Accept", + "Reject", + ] + + self.tbConfirmSend = self.find_widget(QtWidgets.QToolButton , 'tbConfirmSend' ) + self.lbConfirmReq = self.find_widget(QtWidgets.QLabel , 'lbConfirmReq' ) + + self.tbPowerOffSend = self.find_widget(QtWidgets.QToolButton , 'tbPowerOffSend' ) + self.sbPowerOff = self.find_widget(QtWidgets.QSpinBox , 'sbPowerOff' ) + + + def _init_connections(self): + """ + initializes the widget's connections + :return: none + """ + self.tbConfirmSend .clicked.connect ( self.do_confirm_response ) + self.tbPowerOffSend .clicked.connect ( self.do_power_off ) + + + @Slot() + def _init_widgets(self): + """ + initializes the widget's properties + :return: none + """ + self.sbPowerOff .setValue (0) + self.lbConfirmReq .setText ("-") + + + + @Slot() + def handle_confirm_cmd_request(self, message, timestamp = 0.0): + """ + Called when the user sends a rinseback command request to firmware from UI + @return: None + """ + print() + message = message['message'] + index = MsgFieldPositions.START_POS_FIELD_1 + id,index = conversions.bytearray_to_integer(message, index) + confirm,index = conversions.bytearray_to_integer(message, index) + cmdString = self.cmdStrings[id] if id >= 0 and id < len(self.cmdStrings) else "" + self.lbConfirmReq.setText(f"ID ({id}), Confirm ({confirm})") + + + @Slot() + def do_confirm_response(self): + self.lbConfirmReq .setText ("-") + print("do_confirm_response") + + + + @Slot() + def do_power_off(self): + self.td_interface.td_power_off(self.sbPowerOff.value())