Visual Components' Community

New Thinking for Factory Simulation
Welcome to Visual Components' Community Sign in | Help
in Search

A conveyor that empties a container

Last post ti, touko 6 2008 15:26 by RicardoVelez. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • ti, touko 6 2008 15:26

    A conveyor that empties a container

    This conveyor component is an opposite to a component filler. There is a sensor in the MidFrame that signals a python script. The script will stop the component for a defined time and then remove all child components from a component container. The child components are components that belong to a component, like to a component container.

    The conveyor component has two parameter. A boolean parameter called "EmptyContainer", if this is checked the conveyor will actually remove these child components, otherwise components will pass through the conveyor just like any conveyor. The other parameter "TimeToEmpty" defines the time how long the process will take, it is just a simple delay function.

    This is the python script for the component:

    from vcScript import *

    def OnRun():
     
      #get handles for behaviors
      App= getApplication()
      comp= getComponent()
      path=comp.findBehaviour("One-WayPath")
      EmptyS=comp.findBehaviour("ComponentSignal")
      EmptyOrNot= comp.findBehaviour("EmptyContainer")
      Time = comp.TimeToEmpty
      Sim=getSimulation()

      #main loop
      while True:

        #wait for the signal
        triggerCondition(lambda: getTrigger() == EmptyS)

        #get handle for the component
        part = EmptyS.Value

        #if the boolean parameter EmptyContainer is true, it will empty the container
        if comp.EmptyContainer:

          #stop the component
          part.stopMovement()

          #print a text and wait
          print "Unloading a container for "+str(Time) +" seconds"
          delay(Time)

          #empty all the child components for this component (container)
          for child in part.ChildComponents:
            App.deleteComponent(child)

          #start the movement
          part.startMovement()

     And this is the component file:

     Container emptier.vcm 

     

    Ricardo Velez
    Research and Development Manager
Page 1 of 1 (1 items)