Creating and Configuring the Recipe Framework in Script
Creating a Batch Recipe Structure via Script
These code examples have been functionalized.
Functionalizing enables saving in the Scripts folder in the Project Browser and calling the function where needed.
|
Reference Information, not required for this example:
|
|
If you are using the starter project and want to leverage the automation scripts for batches, name all equipment exactly as given.
|
Create a Set of Unit Functionality via Script
|
phaseClassName = 'Demo' parentPhaseClass = None unitClassName = 'Premix' parentUnitClassName = 'Demo' phaseName = 'Value Prompt' recipeClassName = 'Training' parentRecipeClassName = None
def createPhaseClass(phaseClassName, parentPhaseClass): phaseClass = system.mes.batch.phase.createClass(phaseClassName, None) phaseClass.save()
def createUnitClass(unitClassName, parentUnitClassName): if parentUnitClassName == None: parentUnitClassLink = None else: parentUnitClassLink = system.mes.batch.unitclass.getLink(parentUnitClassName) unitClass = system.mes.batch.unitclass.create(unitClassName, parentUnitClassLink) unitClass.save()
def addPhaseToUnitClass(unitClassName, phaseName): unitClassLink = system.mes.batch.unitclass.getLink(unitClassName) unitClass = unitClassLink.getMESObject() phaseLink = system.mes.batch.phase.getPhaseLink(phaseName) unitClass.addPhase(phaseLink) unitClass.save()
def associateUnitClassToUnit(unitName, unitClassName): unitLink = system.mes.batch.unit.getLink(unitName) unitClassLink = system.mes.batch.unitclass.getLink(unitClassName) system.mes.batch.unit.assignUnitClass(unitLink, unitClassLink)
def createRecipeClass(recipeClassName, parentRecipeClassName): if parentRecipeClassName == None: parentRecipeClassLink = None else: parentRecipeClassLink = system.mes.batch.recipe.getRecipeLink(parentRecipeClassName) recipeClass = system.mes.batch.recipe.createRecipeClass(recipeClassName, parentRecipeClassLink) recipeClass.save() |
You can take the functions and save into an Ignition project library to reuse them.
Now that you have the recipe elements in place, do these things:
Once that is done, go to the next lesson to execute a batch via script.
Next