Sepasoft MES Module Suite
Batch Formula Scripting Examples
Create/Save Formula Class
Python |
formulaClassName = "exampleFormulaClass" # Create the formula class object formulaClass = system.mes.batch.formula.createFormulaClass(formulaClassName) # Save the formula class object system.mes.batch.formula.saveFormulaClass(formulaClass) |
Create/Save Formula
Python |
formulaClassName = "exampleFormulaClass" recipeName = "exampleRecipe" # Get the recipe link for the recipe to base the formula on recipeLink = system.mes.batch.recipe.getRecipeLink(recipeName) # Get the formula class link for the class to create the formula under formulaClassLink = system.mes.batch.formula.getFormulaClassLink(formulaClassName) formulaName = "exampleFormula" # Create the formula objectformula = system.mes.batch.formula.createFormula(formulaName, recipeLink, formulaClassLink) # Set the formula state, defaults to Inactive state if not setformula.setState("Production Ready") # Save the formula object system.mes.batch.formula.saveFormula(formula) |
Load Formula and Edit Parameters
Python |
formulaName = "exampleFormula" formulaClassName = "exampleFormulaClass" parameterPath = "/exampleRecipe.exampleParameter" # Get the formula class link for the formula class that is the parent of the formula to load formulaClassLink = system.mes.batch.formula.getFormulaClassLink(formulaClassName) loadedFormula = system.mes.batch.formula.loadFormula(formulaName, parentLink=formulaClassLink) # Modify desired parameter for formula object system.mes.batch.formula.setFormulaParameterValue(loadedFormula, parameterPath, 10) system.mes.batch.formula.setFormulaParameterMaxValue(loadedFormula, parameterPath, 100) system.mes.batch.formula.setFormulaParameterMinValue(loadedFormula, parameterPath, -100) # Re-save the formula object system.mes.batch.formula.saveFormula(loadedFormula) |
Export/Import Formula
Python |
formulaName = "exampleFormula" formulaClassName = "exampleFormulaClass" newFormulaClassName = "importedFormulas" # Get the formula class link for the formula class that is a parent of the formula to export formulaClassLink = system.mes.batch.formula.getFormulaClassLink(formulaClassName) # Get the formula link for the formula to export formulaLink = system.mes.batch.formula.getFormulaLink(formulaName, formulaClassLink) # Export the formula exportedFormulaXML = system.mes.batch.formula.exportFormula(formulaLink) # Create new formula class to import formula under newFormulaClass = system.mes.batch.formula.createFormulaClass(newFormulaClassName) # Save new formula class system.mes.batch.formula.saveFormulaClass(newFormulaClass) # Get the formula class link for the class to import formulas under newFormulaClassLink = system.mes.batch.formula.getFormulaClassLink(newFormulaClassName) # Import the formula importedFormula = system.mes.batch.formula.importFormula(exportedFormulaXML, newFormulaClassLink) # Set the name for the imported formula importedFormula.setName("importedFormula") # Save the imported formula system.mes.batch.formula.saveFormula(importedFormula) |
Sepasoft MES Module Suite