Index: DD_DateTime/interface.ui =================================================================== diff -u --- DD_DateTime/interface.ui (revision 0) +++ DD_DateTime/interface.ui (revision 2dadf8b01fa9cb57aa6fc936a6c2c4ff0adbc5e1) @@ -0,0 +1,141 @@ + + + ui_interface + + + + 0 + 0 + 396 + 197 + + + + + 100000 + 100000 + + + + &Misc/&5 DD DateTime + + + + + + + + + 0 + 0 + + + + + 352 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + + + + color: white; +background-color: rgb(114, 159, 207); + + + + 110 : [0x6E00] : DD Date/TIme + + + Qt::AlignCenter + + + + + + + + + + 180 + 0 + + + + Reason + + + + + + + 900 + + + + + + + + + + + + 0 + 0 + + + + + 180 + 0 + + + + Date/Time (epoch) + + + + + + + + 0 + 0 + + + + false + + + QFrame::WinPanel + + + QFrame::Sunken + + + - + + + Qt::AlignCenter + + + + + + + + + + + + Index: DD_DateTime/loader.py =================================================================== diff -u --- DD_DateTime/loader.py (revision 0) +++ DD_DateTime/loader.py (revision 2dadf8b01fa9cb57aa6fc936a6c2c4ff0adbc5e1) @@ -0,0 +1,80 @@ +""" + The DD Date/ Time 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.dd_messaging import DD_Messaging + +class Loader(DynamicLoader): + """ + The DD Date and Time ui loader + """ + + def __init__(self): + self.dd_interface = DD_Messaging() + self.can_interface = self.dd_interface.can_interface + super().__init__(os.path.dirname(__file__)) + + if self.can_interface is not None: + channel_id = CAN.DenaliChannels.ui_sync_broadcast_ch_id + dd_date_request_message_id = MsgIds.MSG_ID_DD_DATE_AND_TIME_REQUEST.value + self.can_interface.register_receiving_publication_function(channel_id, + dd_date_request_message_id, + self.handle_DD_Date_Time_request) + + def _init_loader(self): + """ + finds and creates widgets + :return: none + """ + self.lbDateTime = self.find_widget(QtWidgets.QLabel , 'lbDateTime' ) + self.sbDateTimeReason = self.find_widget(QtWidgets.QSpinBox , 'DateTimeReasonSpinBox' ) + + def _init_connections(self): + """ + initializes the widgets connections + :return: none + """ + pass + + + def _init_widgets(self): + """ + initializes the widgets' properties + :return: none + """ + self.sbDateTimeReason .setValue(0) + + @Slot() + def handle_DD_Date_Time_request(self, message, timestamp = 0.0): + """ + Called when the user requests to firmware from UI + @return: None + """ + reason = self.sbDateTimeReason.value() + self.dd_interface.dd_date_time_response(reason) + + if ( reason == 0 ): + message = message['message'] + index = MsgFieldPositions.START_POS_FIELD_1 + dateTime,index = conversions.bytearray_to_integer( message, index) + self.lbDateTime .setText( str(dateTime) ) + + + Index: TD_DateTime/interface.ui =================================================================== diff -u --- TD_DateTime/interface.ui (revision 0) +++ TD_DateTime/interface.ui (revision 2dadf8b01fa9cb57aa6fc936a6c2c4ff0adbc5e1) @@ -0,0 +1,141 @@ + + + ui_interface + + + + 0 + 0 + 396 + 197 + + + + + 100000 + 100000 + + + + &Misc/&4 TD DateTime + + + + + + + + + 0 + 0 + + + + + 352 + 0 + + + + + 16777215 + 16777215 + + + + + 10 + + + + color: rgb(238, 238, 236); +background-color: rgb(92, 53, 102); + + + + 108 : [0x6C00] : TD Date/TIme + + + Qt::AlignCenter + + + + + + + + + + 180 + 0 + + + + Reason + + + + + + + 900 + + + + + + + + + + + + 0 + 0 + + + + + 180 + 0 + + + + Date/Time (epoch) + + + + + + + + 0 + 0 + + + + false + + + QFrame::WinPanel + + + QFrame::Sunken + + + - + + + Qt::AlignCenter + + + + + + + + + + + + Index: TD_DateTime/loader.py =================================================================== diff -u --- TD_DateTime/loader.py (revision 0) +++ TD_DateTime/loader.py (revision 2dadf8b01fa9cb57aa6fc936a6c2c4ff0adbc5e1) @@ -0,0 +1,80 @@ +""" + The TD Date/ Time 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 TD Date and Time 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 + td_date_request_message_id = MsgIds.MSG_ID_TD_DATE_AND_TIME_REQUEST.value + self.can_interface.register_receiving_publication_function(channel_id, + td_date_request_message_id, + self.handle_TD_Date_Time_request) + + def _init_loader(self): + """ + finds and creates widgets + :return: none + """ + self.lbDateTime = self.find_widget(QtWidgets.QLabel , 'lbDateTime' ) + self.sbDateTimeReason = self.find_widget(QtWidgets.QSpinBox , 'DateTimeReasonSpinBox' ) + + def _init_connections(self): + """ + initializes the widgets connections + :return: none + """ + pass + + + def _init_widgets(self): + """ + initializes the widgets' properties + :return: none + """ + self.sbDateTimeReason .setValue(0) + + @Slot() + def handle_TD_Date_Time_request(self, message, timestamp = 0.0): + """ + Called when the user requests to firmware from UI + @return: None + """ + reason = self.sbDateTimeReason.value() + self.td_interface.td_date_time_response(reason) + + if ( reason == 0 ): + message = message['message'] + index = MsgFieldPositions.START_POS_FIELD_1 + dateTime,index = conversions.bytearray_to_integer( message, index) + self.lbDateTime .setText( str(dateTime) ) + + +