question

Nicolas Mbz avatar image
0 Likes"
Nicolas Mbz asked Felix Möhlmann commented

how to create a SC based on array ?


I have 2 labels. Theses two labels are arrays. The size of the arrays are the same for both arrays. But the size is random.

1675675287631.png


I need a statistics collector that create a row per index of the array and get the value of the arrays.

Table table must be like this :

1675674943141.png

is it possible ?

Thanks in advance

SC_FromArray.fsm

FlexSim 22.2.1
statistic collectorarray
1675674943141.png (14.8 KiB)
1675675287631.png (18.6 KiB)
sc-fromarray.fsm (30.7 KiB)
· 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.

Andrew O avatar image Andrew O commented ·

Hi @Nicolas M25, was Felix Möhlmann's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

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

You can create multiple rows per event by returning an array in the "Row Value(s)" field. A row will be created for each entry in the array. In your case it could make sense to use the index values the row will correspond to. So if the arrays on the token have a length of three, you would return [1, 2, 3] as the for values.

Note that it is important to "finish" the rows in this case. Otherwise new events would overwrite the rows with row values that already exist.

You can the use those to assign the correct values from the token labels to the columns.

1675678572603.png

sc-fromarray-fm.fsm


1675678572603.png (20.6 KiB)
sc-fromarray-fm.fsm (624.9 KiB)
· 2
5 |100000

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

Nicolas Mbz avatar image Nicolas Mbz commented ·

It works ! Thanks

However, how can I complete values of columns of the rows that already exist ? Example : At begining of the processflow, the SC event 1 fires. Columns 'Name', 'MyLabel1', 'Array1' and 'Array2' are completed > perfect.

Later in the processflow, the SC event 2 fires, how can I complete values of the column 'MyLabel2' (rows that already exist) ?


1676018266308.png


1676017747825.png

SC_FromArray_repFlexsim_et_Aggremente.fsm

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Nicolas Mbz commented ·

Don't finish the row on the first event and use row values that are unique. For example an array made up of tokenID and the array index (so you can still use it when assigning values to the columns. If a row value of a non-finished row appears again later, the row will get updated instead of adding a new one.

1676019981958.png

Then use the same structure for further events and set up the columns that are added later to not add data (or a default value) when the row is created and the actual row when the row is updated.

Finally, define which event will update which row(s) in the lower half of the columns tab.

(The last event can then finish the row, so FlexSim doesn't have to check if the row value already exists against all rows in the future)

1676020142584.png

sc-fromarray-fm2.fsm

0 Likes 0 ·
1676019981958.png (12.0 KiB)
1676020142584.png (36.1 KiB)
sc-fromarray-fm2.fsm (626.8 KiB)