A sensor for conveyor that stops a component, performs task and resumes flow


I’m trying to create a Boolean signal sensor that detects a component (an open box in this instance fitted with a Works Process component) when it passes it on a conveyor and stops the component.

I need the sensor to trigger a ‘pick’ task to place items on the component from a separate Works Process component next to the conveyor. When this task is done, I need the component to start moving on the conveyor again to the next spot and so on.

My current code:

comp = getComponent()
sensor = comp.findBehaviour(“ComponentPathSensor”)

def OnSignal(signal):
if signal == sensor.ComponentSignal:
part = signal.Value

I’m getting the component and the behavior of the sensor on the path I’ve named “MainPath” and using OnSignal to stop the component’s movement. I assume I need to expand this code to include my ‘pick’ task.

Are there more relevant alternatives for connecting boolean signal and component signal to the ComponentPathSensor and does my current code even allow for enabling a task to be performed after stopping the component and the use of ‘startMovement’ to make the component move again?