question

Perla Jazmín HR avatar image
0 Likes"
Perla Jazmín HR asked tannerp commented

Code: How to create a flow item using conditional script on source?

I am trying to code the inter-arrival time of a source to create a flowitem based on a conditional.

The source checks if a rack is empty and if a processor has sent an object to th next activity, then I want to create the flowitem.

This is what I have written so far:

if current.centerObjects[1].stats.state().value < 1 and current.inObjects[1].stats.output.value==1;

I'm not the best using code so any suggestion is more than welcome!

FlexSim 19.1.0
sourceflowitemscode snippet
5 |100000

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

tannerp avatar image
1 Like"
tannerp answered tannerp edited

Hi @Perla Jazmín HR,

How often does the source check? If the source checks every time an item leaves the rack or the processor, you can listen to one of those events with a Wait for Event activity in Process Flow. Then, once the token is made, you can check the other condition and if it is also true, send the token to a Create Object activity.

If you're using an inter-arrival time to create the tokens, you would just add two Decide activities to verify both conditions are true.

Hopefully this helps. Let us know what feedback you have.


double-decide.png (18.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.

Kyle P avatar image
0 Likes"
Kyle P answered Kyle P commented

If you are doing this in the 3D model, I would suggest putting an 'OnExit' trigger on the processor which sends a message to where you'd like the flowitem to be made. Then on the location making the flowitem, put a 'OnMessage' trigger to create the item.

Here the flowitem rank is the number of the entry in the flowitem bin.


dc3yd.png (77.9 KiB)
· 3
5 |100000

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

Suhas H2 avatar image Suhas H2 commented ·

@Kyle P

In the from object(which sends the message processor in your case),what parameters(Values for param1,param2,param3) should i be sending?

0 Likes 0 ·
Suhas H2 avatar image Suhas H2 commented ·

In the processor 'On Exit' trigger, send message option what should be sent to the queue as Parameter 1, Parameter 2 and Parameter 3?

0 Likes 0 ·
Kyle P avatar image Kyle P Suhas H2 commented ·

@Suhas H2 I typically just use custom code to send the message, this is because using the custom code allows me to pass 3 labels in the parameters.

If you use the built in functionality, you lose the ability to pass labels but the parameters would map as follows:

Here, you can see that the built-in triggers use msgparam1 as the quantity and msgparam2 as the flowitem rank, but leaves no room for passing labels.

Through the code you can pass 3 variables (parameters) with in the message; so you have more flexibility in what you want to achieve. If you are always creating the same flowitem and the same quantity then you can utilize the 3 variables (parameters) as a way to pass labels to the newly created flowitem.

1 Like 1 ·
n9ul0.png (36.8 KiB)
hzpud.png (24.8 KiB)
fpnm6.png (16.1 KiB)

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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