- refactored

- created TempSensorFactory
This commit is contained in:
jens
2020-12-13 16:21:08 +01:00
parent c401885967
commit 0633e464ca
9 changed files with 29 additions and 15 deletions
+1
View File
@@ -0,0 +1 @@
from components.atemperatureSensor import *
+3
View File
@@ -0,0 +1,3 @@
from components.pid.pid import *
from components.pid.kalman import *
from components.pid.temp_controller import *
+4 -5
View File
@@ -1,7 +1,6 @@
from components.pid import pid
from components.pid import kalman
from components.plant.pot import Pot
from matplotlib.pyplot import plot, figure, subplot, title, xlabel, ylabel, grid, show, legend
from components.pid import Pid, Kalman
import numpy as np
from utils.value import AttributeChange
from enum import Enum
@@ -17,8 +16,8 @@ class TempController(AttributeChange):
def __init__(self, params_pid, params_kalman):
AttributeChange.__init__(self)
self.pid_hold = pid.Pid(params_pid['Hold'])
self.pid_rate = pid.Pid(params_pid['Heat'])
self.pid_hold = Pid(params_pid['Hold'])
self.pid_rate = Pid(params_pid['Heat'])
self.theta_ist_set = 20
self.theta_soll_set = 0
self.heatrate_ist_set = 0
@@ -27,7 +26,7 @@ class TempController(AttributeChange):
self.theta_ist = 0
self.heatrate_ist = 0
self.params = params_pid
self.kalman = kalman.Kalman(params_kalman)
self.kalman = Kalman(params_kalman)
self.y = -1
self.state = States.IDLE
self.use_kalman = True
+1
View File
@@ -0,0 +1 @@
from components.plant.pot import *
+1 -3
View File
@@ -1,4 +1,3 @@
import numpy as np
from components.aplant import APlant
@@ -43,5 +42,4 @@ class Pot(APlant):
return round(self.power_actual, 1)
def getTemperature(self):
#return round(self.theta + self.theta_amb + self.kn * np.random.normal(0, 1) / np.sqrt(12.0), 1)
return self.temp
return self.temp
+3
View File
@@ -0,0 +1,3 @@
from components.sensor.tempSensorSim import *
from components.sensor.tempsensor_factory import *
from components.sensor.tempSensorSim import ATemperatureSensor
+1 -1
View File
@@ -1,4 +1,4 @@
from components.atemperatureSensor import ATemperatureSensor
from components import ATemperatureSensor
import numpy as np
+8
View File
@@ -0,0 +1,8 @@
from components.sensor.tempSensorSim import TempSensorSim
class TempSensorFactory:
@staticmethod
def create(name):
if "sim" in name:
return TempSensorSim()