Skip to content

Diagnose

Class documentation

Bases: QWidget

A class representing a widget for diagnostic motor parameters.

Attributes:

Name Type Description
graphWidget_E PlotWidget

Widget for displaying primary motor speed graph.

graphWidget_A PlotWidget

Widget for displaying secondary motor speed graph.

data_line_E PlotDataItem

Data line for primary motor speed graph.

data_line_A PlotDataItem

Data line for secondary motor speed graph.

M_E list

List to store primary motor speed data.

M_A list

List to store secondary motor speed data.

Source code in GUI.py
class Diagnose(QWidget):
    """
    A class representing a widget for diagnostic motor parameters.

    Attributes:
        graphWidget_E (PlotWidget): Widget for displaying primary motor speed graph.
        graphWidget_A (PlotWidget): Widget for displaying secondary motor speed graph.
        data_line_E (PlotDataItem): Data line for primary motor speed graph.
        data_line_A (PlotDataItem): Data line for secondary motor speed graph.
        M_E (list): List to store primary motor speed data.
        M_A (list): List to store secondary motor speed data.

    """

    def __init__(self):
        """

        Initialize the Diagnose widget.

        """
        super(Diagnose, self).__init__()
        loadUi("ui_files/Diagnose.ui", self)
        self.findChild(QWidget, "diagnose_parameters")

        #Initiating graph         
        self.graphWidget = pg.PlotWidget()
        self.motor_primary.addWidget(self.graphWidget)

        pen = pg.mkPen(color=(255, 0, 0))
        self.data_line_E = self.graphWidget.plot([], [], pen=pen,symbol="+",symbolSize=10,symbolBrush="b")
        self.graphWidget.setBackground("w")
        self.graphWidget.setLabel("left", "<span style=\"color:black;font-size:11px\">Motor speed primary [µsteps/s]</span>")
        self.graphWidget.setLabel("bottom", "<span style=\"color:black;font-size:11px\">Time [UTC + 1]</span>")
        self.graphWidget.showGrid(x=True, y=True)

        #Initiating graph         
        self.graphWidget = pg.PlotWidget()
        self.motor_secondary.addWidget(self.graphWidget)

        pen = pg.mkPen(color=(255, 0, 0))
        self.data_line_A = self.graphWidget.plot([], [], pen=pen,symbol="+",symbolSize=10,symbolBrush="b")
        self.graphWidget.setBackground("w")
        self.graphWidget.setLabel("left", "<span style=\"color:black;font-size:11px\">Motor speed secondary [µsteps/s]</span>")
        self.graphWidget.setLabel("bottom", "<span style=\"color:black;font-size:11px\">Time [UTC + 1]</span>")
        self.graphWidget.showGrid(x=True, y=True)

        self.M_E = []
        self.M_A = []
    def update_diagnose_plot(self, t, M):
        """
        Update the motor speed graphs with new data.

        Args:
            t (list): List of time values.
            M (dict): Dictionary containing motor speed data for axes A and E.
        """
        self.M_E.append(M['E'])
        if len(self.M_E) == 100:
            self.M_E = self.M_E[1:]
        self.data_line_E.setData(t,self.M_E)

        self.M_A.append(M['A'])
        if len(self.M_A) == 100:
            self.M_A = self.M_A[1:]
        self.data_line_A.setData(t,self.M_A)

__init__()

Initialize the Diagnose widget.

Source code in GUI.py
def __init__(self):
    """

    Initialize the Diagnose widget.

    """
    super(Diagnose, self).__init__()
    loadUi("ui_files/Diagnose.ui", self)
    self.findChild(QWidget, "diagnose_parameters")

    #Initiating graph         
    self.graphWidget = pg.PlotWidget()
    self.motor_primary.addWidget(self.graphWidget)

    pen = pg.mkPen(color=(255, 0, 0))
    self.data_line_E = self.graphWidget.plot([], [], pen=pen,symbol="+",symbolSize=10,symbolBrush="b")
    self.graphWidget.setBackground("w")
    self.graphWidget.setLabel("left", "<span style=\"color:black;font-size:11px\">Motor speed primary [µsteps/s]</span>")
    self.graphWidget.setLabel("bottom", "<span style=\"color:black;font-size:11px\">Time [UTC + 1]</span>")
    self.graphWidget.showGrid(x=True, y=True)

    #Initiating graph         
    self.graphWidget = pg.PlotWidget()
    self.motor_secondary.addWidget(self.graphWidget)

    pen = pg.mkPen(color=(255, 0, 0))
    self.data_line_A = self.graphWidget.plot([], [], pen=pen,symbol="+",symbolSize=10,symbolBrush="b")
    self.graphWidget.setBackground("w")
    self.graphWidget.setLabel("left", "<span style=\"color:black;font-size:11px\">Motor speed secondary [µsteps/s]</span>")
    self.graphWidget.setLabel("bottom", "<span style=\"color:black;font-size:11px\">Time [UTC + 1]</span>")
    self.graphWidget.showGrid(x=True, y=True)

    self.M_E = []
    self.M_A = []

update_diagnose_plot(t, M)

Update the motor speed graphs with new data.

Parameters:

Name Type Description Default
t list

List of time values.

required
M dict

Dictionary containing motor speed data for axes A and E.

required
Source code in GUI.py
def update_diagnose_plot(self, t, M):
    """
    Update the motor speed graphs with new data.

    Args:
        t (list): List of time values.
        M (dict): Dictionary containing motor speed data for axes A and E.
    """
    self.M_E.append(M['E'])
    if len(self.M_E) == 100:
        self.M_E = self.M_E[1:]
    self.data_line_E.setData(t,self.M_E)

    self.M_A.append(M['A'])
    if len(self.M_A) == 100:
        self.M_A = self.M_A[1:]
    self.data_line_A.setData(t,self.M_A)