Changes
This commit is contained in:
25
cycle.py
Normal file
25
cycle.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from algorithm import algorithm
|
||||
import json
|
||||
import math
|
||||
|
||||
|
||||
class cycle(algorithm):
|
||||
def __init__(self):
|
||||
self.config_dict_ = None
|
||||
self.config_ = None
|
||||
self.amplitude_base_ = 0.0
|
||||
self.time_base_ = 10.0
|
||||
self.start_angle_base_ = 0.0
|
||||
|
||||
def set_config(self, config):
|
||||
self.config_ = config
|
||||
self.config_dict_ = json.loads(self.config_)
|
||||
self.amplitude_base_ = self.config_dict_["CYCLE_AMPLITUDE_BASE"]
|
||||
self.time_base_ = self.config_dict_["CYCLE_TIME_BASE"]
|
||||
self.start_angle_base_ = self.config_dict_["CYCLE_START_ANGLE_BASE"]
|
||||
|
||||
def config(self):
|
||||
return self.config_
|
||||
|
||||
def eval(self, value, times):
|
||||
return value + self.amplitude_base_ * math.sin((2 * math.pi * times / self.time_base_) + self.start_angle_base_)
|
||||
Reference in New Issue
Block a user