- fixed stirrers and plants
git-svn-id: http://moon:8086/svn/projects/HendiControl@374 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
@@ -8,6 +8,7 @@ class AStirrer(abc.ABC):
|
||||
return ""
|
||||
|
||||
def __init__(self, dt):
|
||||
self.log("Create")
|
||||
self.dt = dt
|
||||
self.speed = 0
|
||||
self.cycleTime = 1
|
||||
|
||||
@@ -4,11 +4,10 @@ import argparse
|
||||
import signal
|
||||
import json
|
||||
from controller import Controller, commands
|
||||
from mass import Mass
|
||||
from stirrer import Stirrer
|
||||
from pololu1376 import Pololu1376
|
||||
from plant_sim import Plant_sim
|
||||
from plant import Plant
|
||||
|
||||
from stirrer_sim import Stirrer_sim
|
||||
from stirrer_pololu1376 import Stirrer_pololu1376
|
||||
from matplotlib.pyplot import figure, clf, plot, xlabel, ylabel, xlim, ylim, title, grid, axes, show, subplot
|
||||
|
||||
def results_plot(self):
|
||||
@@ -99,7 +98,7 @@ if __name__ == '__main__':
|
||||
configJson = json.load(fp)
|
||||
|
||||
plant_class = globals()[configJson["Controller"]['plant_name']]
|
||||
plant = plant_class()
|
||||
plant = plant_class(configJson["Plant"])
|
||||
ruehrer_class = globals()[configJson["Controller"]['stirrer_name']]
|
||||
ruehrer = ruehrer_class(configJson["Stirrer"])
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from hendiCtrl import HendiCtrl
|
||||
from max31865 import Max31865
|
||||
|
||||
class Plant(APlant):
|
||||
def __init__(self):
|
||||
def __init__(self, params):
|
||||
self.heater = HendiCtrl('/dev/ttyUSB0', 115200)
|
||||
self.tempsensor = Max31865()
|
||||
self.P = 0
|
||||
|
||||
@@ -4,12 +4,12 @@ import time
|
||||
import serial
|
||||
|
||||
|
||||
class Pololu1376(AStirrer):
|
||||
class Stirrer_pololu1376(AStirrer):
|
||||
def name(self):
|
||||
return "Stirrer"
|
||||
return "Stirrer_pololu1376"
|
||||
|
||||
def __init__(self, params):
|
||||
super(Pololu1376, self).__init__(params["dt"])
|
||||
super(Stirrer_pololu1376, self).__init__(params["dt"])
|
||||
self.isMasterOn = 0
|
||||
|
||||
self.ser_speed = params["speed"]
|
||||
@@ -24,7 +24,6 @@ class Pololu1376(AStirrer):
|
||||
|
||||
self.ser_send('V')
|
||||
self.ser_recv()
|
||||
self.log("Create Pololu1376")
|
||||
|
||||
def ser_send(self, cmd):
|
||||
self.ser.write((cmd + '\r\n').encode())
|
||||
@@ -40,13 +39,13 @@ class Pololu1376(AStirrer):
|
||||
|
||||
def activate(self):
|
||||
if self.isMasterOn == 0:
|
||||
self.log("switched On")
|
||||
self.log("Switched On")
|
||||
self.isMasterOn = 1
|
||||
self.ser_send("go")
|
||||
|
||||
def deactivate(self):
|
||||
if self.isMasterOn == 1:
|
||||
self.log("switched Off")
|
||||
self.log("Switched Off")
|
||||
self.isMasterOn = 0
|
||||
self.ser_send("x")
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
from astirrer import AStirrer
|
||||
import time
|
||||
|
||||
class Stirrer(AStirrer):
|
||||
class Stirrer_sim(AStirrer):
|
||||
def name(self):
|
||||
return "Stirrer_sim"
|
||||
|
||||
def __init__(self, params):
|
||||
super(Stirrer, self).__init__(params['dt'])
|
||||
super(Stirrer_sim, self).__init__(params['dt'])
|
||||
self.isMasterOn = 0
|
||||
|
||||
def __del__(self):
|
||||
@@ -11,12 +14,12 @@ class Stirrer(AStirrer):
|
||||
|
||||
def activate(self):
|
||||
if self.isMasterOn == 0:
|
||||
self.log("Stirrer: switched On")
|
||||
self.log("Switched On")
|
||||
self.isMasterOn = 1
|
||||
|
||||
def deactivate(self):
|
||||
if self.isMasterOn == 1:
|
||||
self.log("Stirrer: switched Off")
|
||||
self.log("Switched Off")
|
||||
self.isMasterOn = 0
|
||||
|
||||
def getSpeed(self):
|
||||
@@ -25,11 +28,11 @@ class Stirrer(AStirrer):
|
||||
return 0
|
||||
|
||||
def onSetSpeed(self, speed):
|
||||
self.log("Stirrer: Set speed to {} %".format(speed))
|
||||
self.log("Set speed to {} %".format(speed))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
s = Stirrer(1.0)
|
||||
s = Stirrer_sim({'dt' : 1.0})
|
||||
s.activate()
|
||||
|
||||
print ("Set some speeds")
|
||||
|
||||
Reference in New Issue
Block a user