question

Felipe V3 avatar image
0 Likes"
Felipe V3 asked Braydn T commented

Combine items by code

combiner.fsm

Hello everyone, I need some help here!.

I want my model working that way: An item arrives and is divided into two. One of them goes to a processor and the other one goes to a queue. After the process ended, I want them combining again.

The problem is, I need to catalog each created item. I mean, I don't know if it would work like a label, but I want the first item numbered as 1, second as 2, 3,4 ... 51, 52 ... 1094,1095. And at the end, I want to combine them back with de item that had been processed (the same that was splitted up before).

FlexSim 17.0.13
combinercode
combiner.fsm (17.3 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

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Braydn T commented

The original item enters the combiner by the input port number 1. You pull the secondly divided item through the input port 2 by the Requirement that the label value of the first item in the combiner matches with the label value of the currently tested item. If there a match, the tested item will enter the combiner.

Object itemToMatch = NULL; 
/**Port 1 anything, Port 2 matching label "Id" value*/
if (port == 1) return 1;
if (port > 1){
   itemToMatch = current.first;
   return itemToMatch.Id == item.Id; 
// logical comparison match = TRUE (1) or FALSE (0)
}

All items your are testing must have got the label you test. The label value must be different for non splitted items for example -100.

You assign an "Id" label value by connecting the output of an object.

Label value:

getoutput(current)+1

since FlexSim Version 18

current.stats.output.value+1

If you want that the combined items are stacked and the still look like a box, then you open the Flowitem Bin and copy a Pallet. You copy the path of the Box Flowitem for the shape to the copied Flowitem.

fs3d\General\Box.3ds

You adjust the size [0.61, 0.61, 0.30] of the copied pallet. And you pick by the sampler tool the color of the Box Flowitem from an item in your model that has ran before and has been stopped.

You set this new Flowitem Type to be created in your source.

combine-items-by-matching-id.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.

Braydn T avatar image Braydn T commented ·

@Felipe V3

Did Jorg's answer work for you? If so, could you click the accept button? Thanks!

0 Likes 0 ·