Coffee Machine scenario SECTION 3 Advanced Tutorial
29
3. Create remaining recipes with ingredient quantities as detailed in the list
below.
Tip: You can Copy and Paste Recipe 11 and the recipe name will
automatically be incremented. The Ingredient values may then just be
edited.
4. Copy all the previous recipes for the remaining selections (21, 22, 23, 24,
25, 26) and change the sugar ingredient to 50, and name with a "with
Sugar" suffix.
5. Add the code to the Make the Drink script to download the recipe
ingredients :
aux_text = ValueToText( selection )
DownloadRecipe (aux_text)
Sleep( 1000)
'Take quantities from storage
coffee_level = coffee_level - coffee_amount
water_level = water_level - water_amount
milk_level = milk_level - milk_amount
tea_level = tea_level - tea_amount
sugar_level = sugar_level - sugar_amount
When run, you will see that each time a drink is made the storage tanks are
emptied by the correct amount for each ingredient.
3-1-8 Alarms
We can provide the mechanism to create an alarm should any of the
resources run out.
1, 2, 3… 1. Open the Alarm Editor.
2. Add the alarms with details from the list below.
Recipe
Name
Name Coffee Water Sugar Milk Tea
12 Espresso 50 75 0 0 0
13 White
Coffee
50500500
14 Milk 0 0 0 100 0
15 Tea 0 100 0 0 100
16 Water 0 100 0 0 0
Name Expression Raised
Message
Normal
Message
coffee_level_alarm coffee_level <= 0 Coffee deposit
is empty
Coffee deposit
is refilled
water_level_alarm water_level <= 0 Water deposit
is empty
Water deposit
is refilled
milk_level_alarm milk_level <= 0 Milk deposit is
empty
Milk deposit is
refilled