Make product on conveyor stopped until path.ComponentCount >= 5

hello.

i made feeder and conveyor. and sensor on conveyor too.

want to let them stop until ComponentCount on path is more than 5 ( like, path.ComponentCount >= 5)

so i made script. but its not working.

here is code.

from vcScript import *
import vcMatrix

comp = getComponent()
C_sig = comp.getBehaviour('ComponentSignal')
path = comp.getBehaviour('Path')
startStopSignal = comp.getBehaviour('ComponentPathSensor')

def OnSignal( signal ):
  if signal.Name == 'ComponentSignal' and signal.Value:
    signal.Value.stopMovement()

def OnRun():
  
  while True:
    if startStopSignal.Enabled:
      triggerCondition(lambda: getTrigger() == C_sig and C_sig.Value)
      
      condition(lambda : path.ComponentCount >=5)
      
      print path.ComponentCount
      C_sig.Value.startMovement()
    

they stopped at sensor but keep stopping on sensor. even they are more than 5

what did i do wrong… :smiling_face_with_tear:

please help

It’s a matter of Condition triggering, whether it’s a condition or a triggerCondition in the form of a first trigger.
In my opinion, Visual Components does not set up the condition to be triggered by background data so that the simulation world is not bogged down by background data.
You can try to replace it with another evaluation method.:melting_face:

so yeah here is my way

add code like below

while path.ComponentCount < 5:
        delay(0.1)
# instead of condition

its working. but my question , is it right? hmmm :roll_eyes:

because it may cause 0.1 sec mistake maybe more.

anyway thanks for idea! :slightly_smiling_face:

In fact, all you need to do is add a transmission signal for it to work properly.

from vcScript import *
comp = getComponent()
C_sig = comp.getBehaviour('ComponentSignal')
path = comp.getBehaviour('Path__HIDE__')
startStopSignal = comp.getBehaviour('ComponentPathSensor')
signal = comp.findBehaviour('TransitionSignal')
def OnSignal( signal ):
  if signal.Name == 'ComponentSignal' and signal.Value:
    signal.Value.stopMovement()

def OnRun():
  while True:
    if startStopSignal.Enabled:
      triggerCondition(lambda: getTrigger() == C_sig and C_sig.Value)
      
      condition(lambda : getTrigger() == signal and path.ComponentCount>=5)
      #Add a trigger so that the condition can be triggered again.
      print path.ComponentCount
      C_sig.Value.startMovement()

But this is kind of a personal treatment for me, in fact, there are a lot of examples in VC’s eCatalog that use Condition (lambd: function()), you can refer to their examples to make it. :melting_face:
You can also reconfirm this through others in the forum who are knowledgeable on this point.

Do you wish to have a maximum of 5 workpieces on the conveyor belt?
Simply setup the Advanced::ConveyorCapacity.
Let’s see if this is what you need.

By the way, there 2 types of stop, stop the specific workpiece(You can stop multiple) or stop the whole conveyor.

well this is not what i want.

but thanks :slightly_smiling_face:

make more signal hmmm…

let me try this!
thanks for idea

Ah, I understand your questions now, you meant when 5 pass over the sensor, I see, so do you want to stop the conveyor or stop workpiece?

workpiece.

just stop it on sensor , then it can cause bottleneck until components on conveyor more than 5.

Stop at 5

Check sensor’s script, search # Added
Stop at 5.vcmx (245.7 KB)

Or maybe you want to create batch, there are default components in eCat

Batch sample

Batch sample.vcmx (307.0 KB)

thanks a lot .

im gonna try this too. :slightly_smiling_face: