[Pybrainsim-activity] SF.net SVN: pybrainsim:[79] trunk/src/GeneratorSine.py
Status: Planning
Brought to you by:
rgoj
From: <rg...@us...> - 2009-08-05 06:59:09
|
Revision: 79 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=79&view=rev Author: rgoj Date: 2009-08-05 06:58:57 +0000 (Wed, 05 Aug 2009) Log Message: ----------- * Reworking GeneratorSine: ** added printInfo method ** corrected the receiveInput method ** the runGenerator method is now much cleaner Modified Paths: -------------- trunk/src/GeneratorSine.py Modified: trunk/src/GeneratorSine.py =================================================================== --- trunk/src/GeneratorSine.py 2009-08-03 18:36:14 UTC (rev 78) +++ trunk/src/GeneratorSine.py 2009-08-05 06:58:57 UTC (rev 79) @@ -23,28 +23,29 @@ stimulus. """ -import math +from math import pi +from math import sin + from Generator import Generator class GeneratorSine(Generator): def __init__(self, name, head, frequency = 2, phaseShift = 0): Generator.__init__(self, name, head) self.frequency = frequency - self.phaseShift = phaseShift + self.currentPhase = phaseShift + self.lastTimePoint = 0 + + def printInfo(self): + print(self.name + ": A GeneratorSine object") def receiveInput(self, input): if input == 'Stimulus': - self.phaseShift = -self.activation - else: - self.activation += input + self.currentPhase = 0 def runGenerator(self, time): -# self.phase = (2 * math.pi * self.frequency * time + 2 * math.pi * self.phaseShift) \ -# % (2 * math.pi / self.frequency) / (2 * math.pi) - self.phase = ((2 * math.pi * self.frequency * time + 2 * math.pi * self.phaseShift) \ - % (2 * math.pi)) / (2 * math.pi) -# self.activation += math.sin(self.phase * 2 * math.pi) - self.activation = math.sin(self.phase * 2 * math.pi) - print("Output is now: " + str(self.activation)) - + timeStep = time - self.lastTimePoint + self.lastTimePoint = time + self.currentPhase += self.frequency * timeStep + self.activation = sin(self.currentPhase * 2 * pi) + return self.activation This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |