question

Unax Urrutia avatar image
0 Likes"
Unax Urrutia asked Felix Möhlmann commented

Creating a variable in the sink to count items

I want to know how could I create a varible in the sink triggers (On Entry) that is based on a Table. The value, I want it to be a code.

FlexSim 23.2.3
sinkvariablecounter
5 |100000

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

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

If you assign flexscript to a table cell that is does not need any external paramters then you can use the standard syntax "Table(tableName)[row][col]".

To pass in parameters, access the node of the cell and use "evaluate()" on it. ("Table(tableName).cell(row, col).evaluate(params)")

flexscript-table-example.fsm


· 9
5 |100000

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

Unax Urrutia avatar image Unax Urrutia commented ·
The thing is I want to create a varible as a trigger "on entry" of a sink to count items with the following code:

gettablecell(label(current,"ItemCounts"),item.Type,1)

For this reason, I need to specify the varible "As.Table"

The questions would be:

· Where in the triggers could I create the variable?

· How could I speccify to the trigger that is a table?

· Where could I add the code mentioned previosly in the trigger?

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Unax Urrutia commented ·

You don't need to create a table variable for that command. Either the label node has the correct structure for a table and the command works or it doesn't.

The non-deprecated expression would be "current.labels["ItemCounts"].as(Table).cell(item.Type, 1)". In this case the as.(Table) is needed for the compiler to recognize cell() as a valid method.

label-table-example.fsm

0 Likes 0 ·
Unax Urrutia avatar image Unax Urrutia Felix Möhlmann commented ·
Hello again,


Sorry but I can't oper the files. Actually, I have the FlexSim 23.0.14 version...

I don't know if you could help me in another way.

Thanks!

Regards,

0 Likes 0 ·
Show more comments
Unax Urrutia avatar image
0 Likes"
Unax Urrutia answered Felix Möhlmann commented

Hello @Felix Möhlmann

Thank you vey much for your detailed answer. It has been very useful.

I have some questions related to this:

  • Could it be posible to repeat the demad table from the start once it is finished and continue with the time?
  • What information gives me in a practical way the itemcounts varible table?
  • Could it be possible to define an hour in each day to start pulling the items to the sink?

Thanks a lot!

Best regards,

· 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.

Felix Möhlmann avatar image Felix Möhlmann commented ·
- As I said, instead of stopping the model you could reset the "CurrentDay" variable back to 1 if it becomes larger than the number of rows in the demand table.

- The "itemcounts" label table defines how many items of each type should still be pulled.

- The items will be pulled as soon as the user event is executed. By changing when the event triggers, you can change when the pull starts. If you want to use a non-regular interval (the pull time changes depending on the day), it would probably be easier to place the code in a Custom Code activity in Process Flow instead and generate tokens to execute the code at specific times in a schedule source.

0 Likes 0 ·