@@ -39,6 +39,24 @@ class GenericWorker(QtCore.QObject):
39
39
kill = QtCore .Signal ()
40
40
41
41
def __init__ (self , mprx ):
42
+ """
43
+ establishes a `QMutex` and `QTimer` instance, setting the period to 30,
44
+ to manage access to and timing of tasks.
45
+
46
+ Args:
47
+ mprx (`object`/`instance`.): Qt core mutex, which is used to implement
48
+ recursive mutual exclusion.
49
+
50
+ - `super(GenericWorker, self).__init__()` calls the constructor
51
+ of the parent class `QtCore.QObject`.
52
+ - `self.mutex = QtCore.QMutex(QtCore.QMutex.Recursive)` creates
53
+ a recursive mutex with a name "mutex".
54
+ - `self.Period = 30` sets the period of the worker to 30 seconds.
55
+ - `self.timer = QtCore.QTimer(self)` creates an instance of the
56
+ timer class and stores it in the member variable `self.timer`.
57
+
58
+
59
+ """
42
60
super (GenericWorker , self ).__init__ ()
43
61
44
62
@@ -49,13 +67,28 @@ def __init__(self, mprx):
49
67
50
68
@QtCore .Slot ()
51
69
def killYourSelf (self ):
70
+ """
71
+ emits the `kill` signal, which is likely to cause an immediate termination
72
+ or shutdown of the program or component that contains the function.
73
+
74
+ """
52
75
rDebug ("Killing myself" )
53
76
self .kill .emit ()
54
77
55
78
# \brief Change compute period
56
79
# @param per Period in ms
57
80
@QtCore .Slot (int )
58
81
def setPeriod (self , p ):
82
+ """
83
+ updates the instance variable ` Period` and starts a timer with the new
84
+ period value using the `timer.start()` method.
85
+
86
+ Args:
87
+ p (float): new period to be set for the instance's timer, and it is
88
+ used to update the ` Period` attribute and start the timer with
89
+ the new period.
90
+
91
+ """
59
92
print ("Period changed" , p )
60
93
self .Period = p
61
94
self .timer .start (self .Period )
0 commit comments