Visual Components' Community

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

A conveyor that holds components for specific time

Last post pe, touko 2 2008 14:27 by RicardoVelez. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • pe, touko 2 2008 14:27

    A conveyor that holds components for specific time

    This conveyor has two sensors, one in the BeginFrame and another in the EndFrame. The Python script creates a "TimeStamp" property to every entering component. In the end the Python script will hold the component until it has been on the conveyor for certain time. The conveyor has a parameter called "TimeToSpend" which defines how long each component must be on the conveyor until they can exit.

     

    This is the Python script: 

    from vcScript import *

    def OnSignal(Signal):
      global EnterS, Sim

      if Signal == EnterS:
        part = EnterS.Value
        #create a "TimeStamp" property to the dynamic component on path
        part.createProperty(VC_REAL, "TimeStamp")
        #set the current simulation time to that property
        part.TimeStamp = Sim.SimTime


    def OnRun():
      global EnterS, Sim
     
      #get handles to behaviors
      comp= getComponent()
      path=comp.findBehaviour("One-WayPath")
      EnterS=comp.findBehaviour("EnterSignal")
      ExitS=comp.findBehaviour("ExitSignal")
      Sim=getSimulation()
      SpendTime = comp.TimeToSpend


      #main loop is only for the exiting components
      while True:

        #wait for the ExitSignal    
        triggerCondition(lambda: getTrigger() == ExitS)

        #get the handle for exiting part
        ExitPart = ExitS.Value

        #this is the time that part has spent on a conveyor
        TimeSpent = Sim.SimTime-ExitPart.TimeStamp
        print "The exiting component has spent " +str(TimeSpent) + " seconds on this conveyor"

        #if the part has not yet been on conveyor long enough
        if TimeSpent < SpendTime:

          #Stop the part
          ExitPart.stopMovement()

          #calculate how much time stille remains
          WaitTime = (SpendTime - (Sim.SimTime - ExitPart.TimeStamp))
          print "The part will still wait for " +str (WaitTime) + " seconds"

          #delay for this time
          delay(WaitTime)

          #Start movement again
          ExitPart.startMovement()

    And this is the actual component file: 

    conveyorTimestamp.vcm 

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