Sepasoft MES Module Suite
Batch Recipe with Custom Parameters
The Allocate and Deallocate Phases are used to control allocation of shared Units. An example of a shared Unit is a heater that is used by multiple Mixer Units. When a Mixer Unit needs heat, it can allocate the heater by using the Allocate Phase. When it is done with the heat, it can deallocate it using the Deallocate Phase making it available to other Units to use the heater.
Python |
#CREATE RECIPE INCLUDING ALLOCATE AND DEALLOCATE #It allocates the shared unit "Enterprise\Site\Area\Process Cell\Shared Unit" #It will wait unitil it can allocate the shared unit and then delay 30 seconds. Once the delay is done, #it will deallocate the shared unit "Enterprise\Site\Area\Process Cell\Shared Unit" recipeCls = system.mes.batch.recipe.loadClass('My Recipes', None) recipe = system.mes.batch.recipe.createRecipe('Recipe 1090', recipeCls.asLink()) recipe.setRecipeState('Production Ready') recipe.setRecipeScale(0.5) recipe.setUserVersion(3) procedure = recipe.createLogic('Procedure'); unitProcedure = procedure.createLogic('Unit Procedure') operation = unitProcedure.createLogic('Operation') procedure.addStep("P1", 1, system.mes.batch.phase.getBuiltInPhaseLink('Start')) p2 = procedure.addStep("P2", 2, system.mes.batch.phase.getBuiltInPhaseLink('Unit Procedure')) p3 = procedure.addStep("P3", 3, system.mes.batch.phase.getBuiltInPhaseLink('Transition')) procedure.addStep("P4", 4, system.mes.batch.phase.getBuiltInPhaseLink('Terminator')) p2.setLogicRefUUID(unitProcedure.getUUID()) p3.setParameterValue('Transition_Expression', 'P2.Complete = True') procedure.addLink(1, 2) procedure.addLink(2, 3) procedure.addLink(3, 4) unitClassLink = system.mes.batch.unitclass.getLink('Mixer') unitProcedure.setUnitClassRef(unitClassLink) unitProcedure.addStep("UP1", 1, system.mes.batch.phase.getBuiltInPhaseLink('Start')) uP2 = unitProcedure.addStep("UP2", 2, system.mes.batch.phase.getPhaseLink('Operation')) uP3 = unitProcedure.addStep("UP3", 3, system.mes.batch.phase.getBuiltInPhaseLink('Transition')) unitProcedure.addStep("UP4", 4, system.mes.batch.phase.getBuiltInPhaseLink('Terminator')) uP2.setLogicRefUUID(operation.getUUID()) uP3.setParameterValue('Transition_Expression', 'UP2.Complete = True') unitProcedure.addLink(1, 2) unitProcedure.addLink(2, 3) unitProcedure.addLink(3, 4) operation.addStep("O1", 1, system.mes.batch.phase.getBuiltInPhaseLink('Start')) o2 = operation.addStep("O2", 2, system.mes.batch.phase.getPhaseLink('Allocate')) o3 = operation.addStep("O3", 3, system.mes.batch.phase.getBuiltInPhaseLink('Transition')) o4 = operation.addStep("O4", 4, system.mes.batch.phase.getPhaseLink('Timer')) o5 = operation.addStep("O5", 5, system.mes.batch.phase.getBuiltInPhaseLink('Transition')) o6 = operation.addStep("O6", 6, system.mes.batch.phase.getPhaseLink('Deallocate')) o7 = operation.addStep("O7", 7, system.mes.batch.phase.getBuiltInPhaseLink('Transition')) operation.addStep("O8", 8, system.mes.batch.phase.getBuiltInPhaseLink('Terminator')) o2.setParameterValue('Unit_Path', 'Enterprise\Site\Area\Process Cell\Shared Unit') o2.setParameterValue('Allocate_Priority', 10) o3.setParameterValue('Transition_Expression', 'O2.Allocated = True') o4.setParameterValue('Mode', 'Retentive') o4.setParameterValue('Timer_Direction', 'Up') o4.setParameterValue('Target_Duration', '00:00:30') o5.setParameterValue('Transition_Expression', 'O4.Complete = True') o6.setParameterValue('Unit_Path', 'Enterprise\Site\Area\Process Cell\Shared Unit') o7.setParameterValue('Transition_Expression', 'O6.Deallocated = True') operation.addLink(1, 2) operation.addLink(2, 3) operation.addLink(3, 4) operation.addLink(4, 5) operation.addLink(5, 6) operation.addLink(6, 7) operation.addLink(7, 8) saveList = system.mes.object.list.createList() saveList.add(recipe) saveList.add(procedure) saveList.add(unitProcedure) saveList.add(operation) system.mes.batch.recipe.saveRecipe(saveList) #RUN RECIPE #This will run two recipes that can run on multiple units. Only one will proceed past the Allocate Phase. #The second one will wait on the Allocate Phase until the first recipe deallocate the shared unit. recipeCls = system.mes.batch.recipe.loadClass('My Recipes', None) recipeLink = system.mes.batch.recipe.getRecipeLink('Recipe 1090', recipeCls.asLink()) queueEntry = system.mes.batch.queue.addEntry(recipeLink, "Batch 1090F", "1090F", 1, 1.0, None) system.mes.batch.queue.executeEntryCommand(queueEntry, system.mes.batch.queue.COMMAND_START()) queueEntry = system.mes.batch.queue.addEntry(recipeLink, "Batch 1090G", "1090G", 1, 1.0, None) system.mes.batch.queue.executeEntryCommand(queueEntry, system.mes.batch.queue.COMMAND_START()) allocList = system.mes.batch.unit.getAllocationList(0, 1000, '', True, True) for alloc in allocList: print(alloc) |
Sepasoft MES Module Suite