Skip to content

Commit

Permalink
igor223's method
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Solncev committed Jan 3, 2019
1 parent 1687820 commit 270023f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 43 deletions.
3 changes: 1 addition & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 3,4 @@
import headsStep
import heartsStep
import collectingSensor
import collectingActor
import powerSensor
import collectingActor
24 changes: 7 additions & 17 deletions heartsStep.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 8,32 @@
@cbpi.step
class HeartsStep(StepBase, BaseColletingStep):
temperatureSensor = StepProperty.Sensor("Temperature sensor", description="Temperature sensor inside pot-still")
powerSensor = StepProperty.Sensor("Heater power sensor", description="Required for collecting speed calculation")
initialCollecting = Property.Number("Initial collecting, ml/h", configurable=True, default_value=1000)
endTemp = Property.Number("Completion temperature, degree Celsius", configurable=True, default_value=93)
refluxRatio = Property.Number("Reflux ratio", configurable=True, default_value=3)

collectingSpeed = 0.0
temperature = 0
heaterPower = 0

def finish(self):
self.actor_off(int(self.collectingActor))
self.notify("", "Collecting hearts completed", type="success", timeout=2000)

def execute(self):
self.updateAndCheckTemperature()
self.updateHeaterPower()
self.recountCollecting()
self.notifySensor()
self.updateMaxCollectingSpeed()
self.calculateActorPower()
self.manageActor()

def updateHeaterPower(self):
try:
sensor = self.api.cache.get("sensors").get(int(self.powerSensor)).instance
self.heaterPower = int(sensor.power)
except:
pass

def recountCollecting(self):
K = 0.174
T = float(self.temperature)
W = float(self.heaterPower)
R = float(self.refluxRatio)
self.collectingSpeed = K*(100 - T)*W/(R 1)
a = - 76.923
b = 7538.561
k = (a * self.temperature b) / 1000
k = min(k, 1) if k > 0 else 0
self.collectingSpeed = int(self.initialCollecting * k)

def updateAndCheckTemperature(self):
self.temperature = self.get_sensor_value(int(self.temperatureSensor))
self.temperature = float(self.get_sensor_value(int(self.temperatureSensor)))
if self.temperature >= int(self.endTemp):
self.next()
24 changes: 0 additions & 24 deletions powerSensor.py

This file was deleted.

39 changes: 39 additions & 0 deletions untitled.py
Original file line number Diff line number Diff line change
@@ -0,0 1,39 @@
# -*- coding: utf-8 -*-

from modules.core.props import Property, StepProperty
from modules.core.step import StepBase
from baseColletingStep import BaseColletingStep
from modules import cbpi

@cbpi.step
class HeartsStep(StepBase, BaseColletingStep):
temperatureSensor = StepProperty.Sensor("Temperature sensor", description="Temperature sensor inside pot-still")
initialCollecting = Property.Number("Initial collecting, ml/h", configurable=True, default_value=1000)
endTemp = Property.Number("Completion temperature, degree Celsius", configurable=True, default_value=93)

collectingSpeed = 0.0
temperature = 0

def finish(self):
self.actor_off(int(self.collectingActor))
self.notify("", "Collecting hearts completed", type="success", timeout=2000)

def execute(self):
self.updateAndCheckTemperature()
self.recountCollecting()
self.notifySensor()
self.updateMaxCollectingSpeed()
self.calculateActorPower()
self.manageActor()

def recountCollecting(self):
a = - 76.923
b = 7538.561
k = (a * self.temperature b) / 1000
k = min(k, 1)
self.collectingSpeed = int(self.initialCollecting * k)

def updateAndCheckTemperature(self):
self.temperature = float(self.get_sensor_value(int(self.temperatureSensor)))
if self.temperature >= int(self.endTemp):
self.next()

0 comments on commit 270023f

Please sign in to comment.