question

Roberto avatar image
0 Likes"
Roberto asked Roberto commented

run a processor when it receives two items

Hi, I am new to Flexsim. I would like to run a processor only if it receives two items. I tried to use a "trigger on entry", i wrote a code but it does not work. Could you please help me finding where is the error? Thanks

object Processor7 = model.find("Processor7");

if(content(current) == 2) {

// Start processing the items

setstate(current, STATE_PROCESSING);

} else {

// Stop the processor if there are fewer than two items

stopobject(Processor7);

}


The error is the following:

1724002521519.png
FlexSim 24.2.0
entry trigger
1724002521519.png (35.6 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Roberto commented

Syntax wise, in the first line it has to be "Object" instead of "object" and either "Model.find()" or "model().find()".

The code would still not work though, because you don't resume the processor, setting the state does not change anything about it being stopped. A stopped processor will also not receive a any items, so no second item will ever enter the processor, if you don't put it there 'manually'.

What you can do is place a queue in front of the processor that collects items up to the target batch quantity. When they enter the processor, close the input of the queue and open it again when the second item leaves the processor (see processor triggers in attached model). This way the queue is treated as a part of the processor for all intents and purposes.

process-batches-fm.fsm


· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Roberto avatar image Roberto commented ·
thanks a lot for your help!


0 Likes 0 ·