OnSignal freezes simulation

So I am trying to set a bool based on the material of a product as an input for the PLC. I worked with OnSignal but this gives problems with setting another bool and the simulation just freezes. If I delete the Sensor…signal(Value) everything works fine or if I just put a random print there. Any reason why the entire simulation just stops because of this line?

So the code works because the bool gets put on True but then it just freezes

Have you connected also your SensorSignal to the Python script? That would cause an endless loop as the script triggers itself over and over again.

VC signals can be signaled with their current value as well, there is no “value change” filtering.

1 Like

Yes I did that and I thought this was the problem but was not sure.
I also tried it in the OnRun and then it works once with triggerCondition but whenever I try to use a while loop but then for some reason it doesn’t find the material anymore.
And with the while it almost freezes everytime and I get the popup of processing as you can see on the picture.

I tried these both options with Component or ComponentSignal

I am sorry for the many questions but I just fixed it like this like you said it the first post. Just deleting the connection ( I thought I had to have a connection to be able to manipulate it with the python script. I feel so dumb :sweat_smile: and I am staying away from while loops.

If you make such a non-simulation-time-consuming loop in the OnRun method, you need to have a delay() call in the loop. A delay(0) may work, but in practice you want to have a reasonable interval like 0.05 seconds or more.

Otherwise it will be like a while(True) in any other programming language / environment i.e. just loop forever and hang.

1 Like