SOCIALS 

SUBSCRIBE 

 Please subscribe.   So, you will get notification of the latest exciting posts. 

© 2023 by FEEDs & GRIDs. Proudly created with Wix.com

ABOUT FEEDs & GRIDs

My name is Mike.   This blog is made especially for you to enter my technology universe.  You will find new ideas and skills that may be helpful to you.   Feel free to leave your comments.   I am excited to hear from you.  Thank you. 

Smart Chef IOT Demo (Part 2): How do these Recipe workflows work together?

May 30, 2017

Three Recipe Workflow:  Select Recipe, Recipe Flow, Process Sensor Rules

 

Function Description:

 

1. Select Recipe :

 

It is triggered by user's recipe.select.   It sets up the user choice of recipe and gets it ready to run.   Some configurations are setting the running mode on, initializing the current step to 1st step, and sending the notification message to both LCD display and phone app.  Finally, it sets recipe.start to true in order to execute the next work flow ("Recipe Flow").

 

    current_recipe = recipe[0]                              # the steak recipe
    current_recipe['running'] = True                   # run mode is enabled
    current_recipe['start_time'] = time.time()   # the start time of each step
    current_recipe['current_step'] = 0                # the first step
    current_recipe['first_pass'] = True               # set first time true for each step
    current_recipe['alerts'] = 0                            # Alert count 

 

2. Recipe Flow:

 

It is triggered by recipe.start. Its job is to set up which sensors (sensors[sensor names]) need to be called for the current step.    It will send the message of the current step to the LCD display and phone app.   When the last step is performed, it will end the recipe run and notify the user that everything is done.   

 

It is also triggered every minute by a schedule timer.   It is used to check whether the user has not responded to the recipe's request within 5 minutes elapsed time or not.   If the timer has expired, the Flow will abort the recipe run.

 

       if current_step == len(steps):                         # the last step is done.
            # done
            log("done, recipe: " + str(recipe))
            recipe['running'] = False
            recipe['current_step'] = 0
            recipe['first_pass'] = True
            notification['message'] = "Great job, you're done!"
        else:
            log("first_pass: " + str(recipe['first_pass']))
            if recipe['first_pass'] == True:
                notification['message'] = steps.get(recipe_steps[current_step],{}).get('set', "")
                recipe['first_pass'] = False

            

          

            log("processing sensors to read")
            sensor_to_read = steps.get(recipe_steps[current_step],{}).get('get', [])
            sensors = {}
            for sensor in sensor_to_read:
                sensors[sensor] = True
            log(sensors)
            if len(sensors.keys()) > 0:
                log("sending read request to sensor_read stream")
                IONode.set_output('out1', sensors)

 

3. Process Sensor Rules

 

When the sensor readings are available, it process the data against the rule of the recipe step.    If any violation of the rule such as exceeded temperature range or expired warning timer, it will send a warning message out.   If the abort timer has expired, it will send a abort message out.    

 

If the rule has been met within the required time, it will move forward to the next recipe step and it sets recipe.start to true in order to execute the next work flow ("Recipe Flow").

 

            for rule in complete_rules:
                r, m = process_rule(rule)
                if r:
                    msg = msg + m
            if r:                                                                              # r = true if rules are met.
                recipe['current_step'] = current_step + 1         # go to next step
                recipe['start_time'] = time.time()                       # set a new time for next step
                recipe['first_pass'] = True # clear first pass flag
                recipe['alerts'] = 0 # clear alerts
                IONode.set_output('out3', {"start": True})      # trigger to set up next

                                                                                              # recipe step with Recipe Flow

                                                                                                 
 

Workflow's flow chart:

 

 

 

 

 

 

Share on Facebook
Share on Twitter
Please reload

RECENT POSTS

Please reload

FEATURED POSTS

I2C Tutorial for Renesas S5D9 board: Add ThreadX real time OS support. (Part 3)

February 18, 2018

1/5
Please reload

FOLLOW US

  • Grey Facebook Icon
  • Grey Twitter Icon
  • Grey Instagram Icon
  • Grey Google+ Icon
  • Grey Pinterest Icon
This site was designed with the
.com
website builder. Create your website today.
Start Now