Skip to content

Real time data

Class documentation

Bases: QWidget

A class representing a widget for displaying real-time data.

Attributes:

Name Type Description
named_widget QWidget

The widget containing real-time data.

position_label_a QLabel

Label for position data of axis A.

position_label_e QLabel

Label for position data of axis E.

speed_label_a QLabel

Label for speed data of axis A.

speed_label_e QLabel

Label for speed data of axis E.

mode_label QLabel

Label for displaying current mode.

Source code in GUI.py
class RealTimeData(QWidget):

    """
    A class representing a widget for displaying real-time data.

    Attributes:
        named_widget (QWidget): The widget containing real-time data.
        position_label_a (QLabel): Label for position data of axis A.
        position_label_e (QLabel): Label for position data of axis E.
        speed_label_a (QLabel): Label for speed data of axis A.
        speed_label_e (QLabel): Label for speed data of axis E.
        mode_label (QLabel): Label for displaying current mode.

    """

    def __init__(self):
        """
        Initialize the RealTimeData widget.
        """
        super(RealTimeData, self).__init__()
        loadUi("ui_files/RealTimeData.ui", self)
        self.named_widget = self.findChild(QWidget, "real_time_data")
        self.position_label_a = self.findChild(QLabel, "position_label_a")
        self.position_label_e = self.findChild(QLabel, "position_label_e")
        self.speed_label_a = self.findChild(QLabel, "speed_label_a")
        self.speed_label_e = self.findChild(QLabel, "speed_label_e")
        self.mode_label = self.findChild(QLabel, "mode_label")
    def update_variables(self,M,pos):
        """
        Update the displayed variables based on the provided data.

        Args:
            M (dict): Dictionary containing speed data for axes A and E.
            pos (dict): Dictionary containing position data for axes A and E,
                        and active sense data for axes F and Q.
        """
        self.position_label_a.setText(str(round(pos['A'],2)))
        self.position_label_e.setText(str(round(pos['E'],2)))
        self.speed_label_a.setText(str(round(M['A'], 2)))
        self.speed_label_e.setText(str(round(M['E'],2)))
        self.active_sense_label_a.setText(str(round(pos['FQ'][0])))
        self.active_sense_label_e.setText(str(round(pos['FQ'][1])))
    def update_mode(self, mode):
        """
        Update the mode label with the provided mode.

        Args:
            mode (str): The mode to be displayed.
        """
        self.mode_label.setText(mode)

__init__()

Initialize the RealTimeData widget.

Source code in GUI.py
def __init__(self):
    """
    Initialize the RealTimeData widget.
    """
    super(RealTimeData, self).__init__()
    loadUi("ui_files/RealTimeData.ui", self)
    self.named_widget = self.findChild(QWidget, "real_time_data")
    self.position_label_a = self.findChild(QLabel, "position_label_a")
    self.position_label_e = self.findChild(QLabel, "position_label_e")
    self.speed_label_a = self.findChild(QLabel, "speed_label_a")
    self.speed_label_e = self.findChild(QLabel, "speed_label_e")
    self.mode_label = self.findChild(QLabel, "mode_label")

update_mode(mode)

Update the mode label with the provided mode.

Parameters:

Name Type Description Default
mode str

The mode to be displayed.

required
Source code in GUI.py
def update_mode(self, mode):
    """
    Update the mode label with the provided mode.

    Args:
        mode (str): The mode to be displayed.
    """
    self.mode_label.setText(mode)

update_variables(M, pos)

Update the displayed variables based on the provided data.

Parameters:

Name Type Description Default
M dict

Dictionary containing speed data for axes A and E.

required
pos dict

Dictionary containing position data for axes A and E, and active sense data for axes F and Q.

required
Source code in GUI.py
def update_variables(self,M,pos):
    """
    Update the displayed variables based on the provided data.

    Args:
        M (dict): Dictionary containing speed data for axes A and E.
        pos (dict): Dictionary containing position data for axes A and E,
                    and active sense data for axes F and Q.
    """
    self.position_label_a.setText(str(round(pos['A'],2)))
    self.position_label_e.setText(str(round(pos['E'],2)))
    self.speed_label_a.setText(str(round(M['A'], 2)))
    self.speed_label_e.setText(str(round(M['E'],2)))
    self.active_sense_label_a.setText(str(round(pos['FQ'][0])))
    self.active_sense_label_e.setText(str(round(pos['FQ'][1])))