Brewing Step¶
StepController¶
-
class
core.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_done
(topic, **kwargs)¶ Event Handler for “step/+/done”. Starts the next step
Parameters: - topic –
- kwargs –
Returns:
-
handle_next
(**kwargs)¶ Event Handler for “step/next”. It start the next step
Parameters: kwargs – Returns: None
-
handle_reset
(**kwargs)¶ Event Handler for “step/reset”. Resets the current step
Parameters: kwargs – Returns: None
-
handle_start
(**kwargs)¶ Event Handler for “step/start”. It starts the brewing process
Parameters: kwargs – Returns: None
-
handle_stop
(**kwargs)¶ Event Handler for “step/stop”. Stops the current step
Parameters: kwargs – Returns: None
-
http_action
(request)¶ HTTP Endpoint to call an action on the current step.
Parameters: request – web requset Returns: web.Response(text=”OK”
-
http_next
(request)¶ HTTP Endpoint to start the next step. The current step will be stopped
Parameters: request – Returns:
-
http_reset
(request)¶ HTTP Endpoint to call reset on the current step.
Parameters: request – Returns:
-
http_start
(request)¶ HTTP Endpoint to start the brewing process.
Parameters: request – Returns:
-
init
()¶ Initializer of the the Step Controller. :return:
-
start
()¶ Start the first step
:return:None
-
SimpleStep¶
-
class
core.api.step.
SimpleStep
(*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
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 core.api import Property, action
from core.api.step import SimpleStep
class CustomStep(SimpleStep):
name = Property.Number(label="Test")
i = 0
@action(key="name", parameters=None)
def test(self, **kwargs):
self.name="WOOHOO"
async def run_cycle(self):
#await asyncio.sleep(1)
self.i = self.i + 1
print("RUN STEP", self.id, self.name, self.__dict__)
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("CustomStep", CustomStep)
|
config.yaml
1 2 | name: DummyStep
version: 4
|