question

Pijus Leonavicius avatar image
0 Likes"
Pijus Leonavicius asked Pijus Leonavicius answered

sending a message every n-th item

Hello,

I am trying to do a simple model, where a in item is split (into 9) and each instance is processed and then routed to a combiner. My problem is- I can not have another item arrive on the separator while anything is still standing on the following processor, such a case happens when the combiner is processing a certain number of the split and processed items (26 in my case).

So, I get 26 items in my combiner, it is stuck joining them for 30s, and another instance is stuck on the processor, I want the separator to have its input closed during this situation.

Basically I want to know how to be able to send a message to the separator to open its input after the 9th item has left the processor, I know it is possible to script it but I am very new at this.

FlexSim 16.2.0
combinerseparatorscripttriggermessages
5 |100000

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

Pijus Leonavicius avatar image
2 Likes"
Pijus Leonavicius answered

Thank you for the quick answer!

Although I figured out how to do this a few minutes ago without any script writing, I basically just set up the processor to send a message to the separator to close input on each item received and also open the input after each item sent out, this is not ideal i suppose, but i did not see any obvious errors yet.

5 |100000

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

Joerg Vogel avatar image
1 Like"
Joerg Vogel answered Joerg Vogel edited

try the modulus operator "%". The result is the remain of an integer division. 1%9 = 1; 2%9 = 2; 3 % 9 = 3; 4 % 9 = 4; 5 % 9 = 5; 6 % 9 = 6; 7 % 9 = 7; 8 % 9 = 8; 9 % 9 = 0; 10 % 9 = 1; 11 %9 = 2; ...

The inverse of null is 1. if a modulus division of 9 returns a "0" invert this value and use it as a true condition:

if (!((getoutput(current)+1) % 9))) sendmessage(...);

You have to add +1 at the current object output of an object's OnExit Trigger, because the actual releasing item isn't counted.


modulusoperator.gif (35.7 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.