Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Batch Management

Examples

  • Last UpdatedAug 26, 2016
  • 5 minute read

Because there is only a single object class in the recipe server and also due to the number of methods and properties available, specific examples were not created for each function. However, examples were created for each functional area of the recipe server and are included below.

General Recipe Manipulation

The following sample code illustrates loading a list of recipes, selecting a recipe by double-clicking the desired recipe in the list, and saving the recipe as a new recipe. The global variable for RecipeVar is defined so that it is available throughout the entire program. While not shown in these examples, specific application code can be added to provide error messages if the return code for any of the function calls indicates a failure.

' Define required global variable

Dim RecipeVar As New wwRecipe

Private Sub Form_Load()

' Define required local variable

Dim Recipes As Object

Dim i As Integer

lstRecipes.Clear

' Query for the available recipes and add to list

Recipes = RecipeVar.GetRecipes

For i = LBound(Recipes) To UBound(Recipes)

lstRecipes.AddItem Recipes(i)

Next i

End Sub

Private Sub lstRecipes_DblClick()

' Define required local variable

Dim ReturnCode As Boolean

' Open, save, and close the selected recipe

ReturnCode = RecipeVar.Open(lstRecipes.Text)

ReturnCode = RecipeVar.SaveAs("New Recipe ID", "Recipe Author", _

"Recipe Version Comments")

ReturnCode = RecipeVar.Close

End Sub

Changing a Recipe Header

The following sample code illustrates opening the recipe with ID "Recipe123", changing a few of the header fields, saving the recipe with the same ID, and then approving the recipe for production. The global variable for RecipeVar is defined so that it is available throughout the entire program. While not shown in these examples, specific application code can be added to provide error messages if the return code for any of the function calls indicates a failure.

' Define required global variable

Dim RecipeVar As New wwRecipe

Private Sub Form_Load()

' Define required local variable

Dim ReturnCode As Boolean

' Open the desired recipe

ReturnCode = RecipeVar.Open("Recipe123")

' Change the appropriate header fields

RecipeVar.ProductId = "New Product ID"

RecipeVar.ProductName = "New Product Name"

RecipeVar.MinimumBatchSize = 100

RecipeVar.MaximumBatchSize = 1000

RecipeVar.DefaultBatchSize = 500

' Save and approve the recipe

ReturnCode = RecipeVar.Save("Recipe Author", "Recipe Version Comments")

ReturnCode = RecipeVar.SetProductionApproval

ReturnCode = RecipeVar.Close

End Sub

Defining Recipe Equipment Requirements

The following sample code illustrates how to create a new recipe, add several process classes, add a second process instance, add the appropriate new transfer instances, and save the recipe as "Recipe123". The global variable for RecipeVar is defined so that it is available throughout the entire program. While not shown in these examples, specific application code can be added to provide error messages if the return code for any of the function calls indicates a failure.

' Define required global variable

Dim RecipeVar As New wwRecipe

Private Sub Form_Load()

' Define required local variable

Dim ReturnCode As Boolean

' Create a new recipe

ReturnCode = RecipeVar.NewRecipe

' Add the appropriate process classes

ReturnCode = RecipeVar.AddProcessClass("BULKTKS")

ReturnCode = RecipeVar.AddProcessClass("REACTORS")

ReturnCode = RecipeVar.AddProcessClass("MIXTANKS")

' Change name of default Reactors process instance

ReturnCode = RecipeVar.ChangeProcessInstance("REACTORS", _

"FIRST_REACTOR")

' Add a second reactor process instance

ReturnCode = RecipeVar.AddProcessInstance("REACTORS", _

"SECOND_REACTOR")

' Change name of default Bulks to Reactors transfer instance

ReturnCode = RecipeVar.ChangeTransferInstance("BULKRXS", _

"BULKS_FIRST_RX", "BULKTKS", "FIRST_REACTOR")

' Add a second Bulks to Reactors transfer instance

ReturnCode = RecipeVar.AddTransferInstance("BULKRXS", _

"BULKS_SECOND_RX", "BULKTKS", "SECOND_REACTOR")

' Change name of default Reactors to Mix Tanks transfer instance

ReturnCode = RecipeVar.ChangeTransferInstance("RXSMIXTK", _

"FIRST_RX_MIXTKS", "FIRST_REACTOR", "MIXTANKS")

' Add a second Reactors to Mix Tanks transfer instance

ReturnCode = RecipeVar.AddTransferInstance("RXSMIXTK", _

"SECOND_RX_MIXTKS", "SECOND_REACTOR", "MIXTANKS")

' Save the recipe

ReturnCode = RecipeVar.SaveAs("Recipe123", "Recipe Author", _

"Recipe Version Comments")

ReturnCode = RecipeVar.Close

End Sub

Creating a Recipe Formula

The following sample code illustrates how to create a new recipe, add several ingredients, change the properties of each material accordingly, and save the recipe as "Recipe123". This example assumes that the materials already exist in the material database. Also, two instances of a particular material are added in this example and the second instance is modified appropriately. The global variable for RecipeVar is defined so that it is available throughout the entire program. While not shown in these examples, specific application code can be added to provide error messages if the return code for any of the function calls indicates a failure.

' Define required global variable

Dim RecipeVar As New wwRecipe

Private Sub Form_Load()

' Define required local variables

Dim ReturnCode As Boolean

Dim InputMaterials(4) As String

' Create a new recipe

ReturnCode = RecipeVar.NewRecipe

' Add required input materials to array

InputMaterials(0) = "I0001"

InputMaterials(1) = "I0002"

InputMaterials(2) = "I0003"

InputMaterials(3) = "I0003"

' Add the ingredient array to the recipe formula inputs

ReturnCode = RecipeVar.AddInputMaterials(InputMaterials)

' Change the properties for input material I0001. Lists are One-based.

ReturnCode = RecipeVar.SetInputValue(1, 50)

ReturnCode = RecipeVar.SetInputValueType(1, wwActualValueType)

ReturnCode = RecipeVar.SetInputTolerance(1, wwGeneralTolerance)

ReturnCode = RecipeVar.SetInputHighDev(1, 3)

ReturnCode = RecipeVar.SetInputLowDev(1, 4)

' Change the properties for input material I0002. Lists are One-based.

ReturnCode = RecipeVar.SetInputValue(2, 25)

ReturnCode = RecipeVar.SetInputValueType(2, wwActualValueType)

ReturnCode = RecipeVar.SetInputTolerance(2, wwGeneralTolerance)

ReturnCode = RecipeVar.SetInputHighDev(2, 2)

ReturnCode = RecipeVar.SetInputLowDev(2, 1)

' Change the properties for the second instance

' of input material I0003. Lists are One-based.

ReturnCode = RecipeVar.SetInputValue(4, 2.5)

ReturnCode = RecipeVar.SetInputValueType(4, wwPercentValueType)

ReturnCode = RecipeVar.SetInputTolerance(4, wwGeneralTolerance)

ReturnCode = RecipeVar.SetInputHighDev(4, 1.5)

ReturnCode = RecipeVar.SetInputLowDev(4, 2.5)

' Save the Recipe

ReturnCode = RecipeVar.SaveAs("Recipe123", "Recipe Author", _

"Recipe Version Comments")

End Sub

Building a Recipe Procedure

The following sample code illustrates how to open an existing recipe named "Recipe123", add a recipe procedure using three recipe levels, and save the recipe. This example assumes that the equipment and materials already exist in the recipe. The global variable for RecipeVar is defined so that it is available throughout the entire program. While not shown in these examples, specific application code can be added to provide error messages if the return code for any of the function calls indicates a failure.

The recipe consists of the following operations and phases:

Unit Procedure

Operation

Equipment Instance

Phase

Add Ingredients

Bulk Adds

Manual Adds

Reactors

Reactors

BulkAdd (I0001)
BulkAdd (I0002)
ManualAdd (I0003)

Process

Process

Reactors

AgitOn
Heat (250 deg. C)
Soak (250 deg. C, 30 min.)
Cool (80 deg. C)
AgitOff

Discharge

Transfer

MixTanks

Package (FG0001)

' Define required global variable

Dim RecipeVar As New wwRecipe

Private Sub Form_Load()

' Define required local variables

Dim ReturnCode As Boolean

Dim PhaseLabel As String

' Open the desired recipe

ReturnCode = RecipeVar.Open("Recipe123")

' Add first unit procedure, operations, and phases.

' Lists are One-based.

ReturnCode = RecipeVar.AddUnitProcedure("Add Ingredients", _

"FIRST_REACTOR")

ReturnCode = RecipeVar.AddOperation("Bulk Adds")

ReturnCode = RecipeVar.AddTransferPhase("BULKS_FIRST_RX", "BULKADD", _

PhaseLabel)

ReturnCode = RecipeVar.SetInputParmMaterial("QUANTITY", 1, 50)

ReturnCode = RecipeVar.AddTransferPhase("BULKS_FIRST_RX", "BULKADD", _

PhaseLabel)

ReturnCode = RecipeVar.SetInputParmMaterial("QUANTITY", 2, 25)

ReturnCode = RecipeVar.AddOperation("Manual Adds")

ReturnCode = RecipeVar.AddProcessPhase("MAN_ADD", PhaseLabel)

ReturnCode = RecipeVar.SetInputParmMaterial("QUANTITY", 4, 25)

' Add second unit procedure, operation, and phases.

' Lists are One-based.

ReturnCode = RecipeVar.AddUnitProcedure("Process", "FIRST_REACTOR")

ReturnCode = RecipeVar.AddOperation("Process")

ReturnCode = RecipeVar.AddProcessPhase("AGIT_ON", PhaseLabel)

ReturnCode = RecipeVar.SetProcessVarParmValue("SPEED", 75)

ReturnCode = RecipeVar.AddProcessPhase("HEAT", PhaseLabel)

ReturnCode = RecipeVar.SetProcessVarParmValue("TEMP", 250)

ReturnCode = RecipeVar.AddProcessPhase("SOAK", PhaseLabel)

ReturnCode = RecipeVar.SetProcessVarParmValue("TEMP", 250)

ReturnCode = RecipeVar.SetProcessVarParmValue("TIME", 30)

ReturnCode = RecipeVar.AddProcessPhase("COOL", PhaseLabel)

ReturnCode = RecipeVar.SetProcessVarParmValue("TEMP", 80)

ReturnCode = RecipeVar.AddProcessPhase("AGIT_OFF", PhaseLabel)

' Add third unit procedure, operation, and phase. Lists are One-based.

ReturnCode = RecipeVar.AddUnitProcedure("Discharge", "MIXTANKS")

ReturnCode = RecipeVar.AddOperation("Discharge")

ReturnCode = RecipeVar.AddTransferPhase("FIRST_RX_MIXTKS", "PACKAGE", _

PhaseLabel)

ReturnCode = RecipeVar.SetOutputParmMaterial("QUANTITY", 1, 100)

' Save the Recipe & Close it

ReturnCode = RecipeVar.Save("Recipe Author", "Recipe Comments")

ReturnCode = RecipeVar.SetProductionApproval

ReturnCode = RecipeVar.Close

End Sub

TitleResults for “How to create a CRG?”Also Available in