Brewing Step

StepController

class cbpi.controller.step_controller.StepController(cbpi)

The Step Controller. This controller is responsible to start and stop the brewing steps.

Undoc-members:
Show-inheritance:
 
handle_action(action, **kwargs)

Event Handler for “step/action”. It invokes the provided method name on the current step

Parameters:
  • action – the method name which will be invoked
  • kwargs
Returns:

None

handle_reset(**kwargs)

Event Handler for “step/reset”. Resets the current step

Parameters:kwargs
Returns:None
init()

Initializer of the the Step Controller. :return:

next(**kwargs)

Event Handler for “step/next”. It start the next step

Parameters:kwargs
Returns:None
start(**kwargs)

Start the first step

:return:None

CBPiSimpleStep

class cbpi.api.CBPiSimpleStep(*args, **kwargs)

Bases: object

is_dirty()

Check if a managed variable has a new value

Returns:True if at least one managed variable has a new value assigend. Otherwise False
managed_fields = []
next()

Request to stop the the step

Returns:None
reset()

Reset the step. This method needs to be overwritten by the custom step implementation

Returns:None
reset_dirty()

Reset the dirty flag

Returns:
run()

This method in running in the background. It invokes the run_cycle method in the configured interval It checks if a managed variable was modified in the last exection cycle. If yes, the method will persisit the new value of the managed property

Returns:None
run_cycle()

This method is executed in the defined interval. That the place to put your step logic. The method need to be overwritten in the Ccstom step implementaion

Returns:None
running()

Method checks if the step should continue running. The method will return False if the step is requested to stop or the next step should start

Returns:True if the step is running. Otherwise False.
stop()

Request to stop the step

Returns:None

Custom Step

This is an example of a custom step. The Step class need to extend Simple step. In addtion at least the run_cycle method needs to be overwritten

__init__.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import asyncio

from cbpi.api import *


class CustomStepCBPi(CBPiSimpleStep):

    name = Property.Number(label="Test")

    i = 0
    
    @action(key="name", parameters=None)
    def test(self, **kwargs):
        self.name="WOOHOO"

    async def run_cycle(self):
        print("RUN", self.name)
        self.i = self.i + 1
        if self.i == 5:
        #    print("NEXT")
            self.next()
        #self.cbpi.notify(key="step", message="HELLO FROM STEP")



def setup(cbpi):
    '''
    This method is called by the server during startup 
    Here you need to register your plugins at the server

    :param cbpi: the cbpi core 
    :return: 
    '''

    cbpi.plugin.register("CustomStepCBPi", CustomStepCBPi)

config.yaml

1
2
name: DummyStep
version: 4