Skip to content

Commit

Permalink
start-stop method
Browse files Browse the repository at this point in the history
  • Loading branch information
saniaxxx committed Jul 2, 2020
1 parent 13771f3 commit 01f2ccd
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 2,7 @@

import headsStep
import heartsStep
import startStopStep
import periodicHeadsStep
import collectingSensor
import collectingActor
48 changes: 48 additions & 0 deletions startStopStep.py
Original file line number Diff line number Diff line change
@@ -0,0 1,48 @@
# -*- 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 StartStopStep(StepBase, BaseColletingStep):
temperatureSensor = StepProperty.Sensor("Датчик температуры", description="Датчик температуры в царге")
initialCollecting = Property.Number("Стартовая скорость отбора, мл/ч", configurable=True, default_value=1000)
deltaTemp = Property.Number("Разрешенный залет температуры, °C", configurable=True, default_value=0.3)
decrement = Property.Number("Уменьшение отбора при залете температуры, %", configurable=True, default_value=10)
endTemp = Property.Number("Температура завершения отбора", configurable=True, default_value=93)

initialTemp = None
currentCollecting = None
collectingSpeed = 0.0
temperature = 0
stopped = False

def finish(self):
self.actor_off(int(self.collectingActor))
self.notify("", "Отбор тела завершен", type="success", timeout=2000)

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

def recountCollecting(self):
if not self.currentCollecting:
self.currentCollecting = int(initialCollecting)
if not self.initialTemp:
self.initialTemp = float(self.temperature)
excess = float(self.temperature) - self.initialTemp > float(self.deltaTemp)
if excess and not self.stopped:
self.currentCollecting = self.currentCollecting * (100 - int(decrement)) / 100
self.stopped = excess
self.collectingSpeed = 0 if self.stopped else self.currentCollecting

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 01f2ccd

Please sign in to comment.