aboutsummaryrefslogtreecommitdiff
path: root/funcGenerator.py
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-07-13 10:51:46 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-07-13 10:51:46 -0400
commit5e9c7f11e6fd6a95f198daec014826d74ed00ba6 (patch)
treef5077fed3dd986a497318f9f07c772bafdaa2858 /funcGenerator.py
parent1797335c4fd0e97e4caedd387575fb1dcb387dfe (diff)
downloadqolab-5e9c7f11e6fd6a95f198daec014826d74ed00ba6.tar.gz
qolab-5e9c7f11e6fd6a95f198daec014826d74ed00ba6.zip
some generators have getSweepDirection function
Diffstat (limited to 'funcGenerator.py')
-rw-r--r--funcGenerator.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/funcGenerator.py b/funcGenerator.py
index 54a3b1b..cd33f0b 100644
--- a/funcGenerator.py
+++ b/funcGenerator.py
@@ -72,6 +72,15 @@ class SawGen(RampGen):
if sweeper.getRelPos() < self.duty_cycle:
return self.start + sweeper.getRelPos()/self.duty_cycle*(self.stop - self.start)
return self.start + (1-sweeper.getRelPos())/(1-self.duty_cycle)*(self.stop - self.start)
+ def getSweepDirection(self, sweeper = None):
+ if sweeper is None and self.sweeper is None:
+ print("Error: generator needs sweeper")
+ return 0
+ if sweeper is None:
+ sweeper = self.sweeper
+ if sweeper.getRelPos() < self.duty_cycle:
+ return 1; # increasing value direction
+ return 0; # decreasing value direction
class TriangleGen(SawGen):
# monotonically goes from start to stop, once reaches stop goes back to start