question

Rober G avatar image
0 Likes"
Rober G asked Rober G commented

Increment Value Of Token On Global List

Good Day! I have tried various coding practices and other global table referencing techniques

I wish to increment the value of my tokens (From "Warehouse Trucks") by type (On my "Bunker Bulk Inventory" global table), I have a Global table called "Material Quantity" which has the quantity of increment by type.


What customer code is necessary as seen below to increment it as such, by using the "Material Quantity" global table? It's as if the increment value operation doesn't happen with my incoming tokens and therefore doesn't update on my global table.

testing.fsm

1691572803325.png

Thank you in advance!



FlexSim 23.0.10
process flowwrite to global tableincrement value
1691572803325.png (8.9 KiB)
testing.fsm (74.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

·
Paula LG avatar image
1 Like"
Paula LG answered Rober G commented

Hi,

The value in your global table wasn't changing because you were accessing it in a way you could only read it, not change it.

To solve that the easiest way, I have used the "Write to GlobalTable" predefined custom code. I also added a label to the tokens called "index" which represents the index of each token created (the first one will have index=1, and the last one index=68), in order to access the correct row in the "MaterialQuantity" table.

1691589443880.png1691589396768.png












I also attach a new version of the model that includes this changes: testing.fsm

Let me know if you have any further questions. I hope it helps!


1691589396768.png (38.1 KiB)
1691589443880.png (96.6 KiB)
testing.fsm (73.5 KiB)
· 6
5 |100000

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

Rober G avatar image Rober G commented ·

Thank you very much for clearing up my confusion! Happy modelling :)

0 Likes 0 ·
Rober G avatar image Rober G commented ·

It seems to be not updating certain materials in the global table. Is there an explanation for this? For instance, material of type 6 was set to a very high quantity yet it does not increment Material6 in the global table.

It almost seems as if the increment value is capped below 1000. Therefore I cant increase for example Material 6 by a 1000 for a delivery

@Paula LG

testing.fsm

0 Likes 0 ·
testing.fsm (73.5 KiB)
Paula LG avatar image Paula LG commented ·

I didn't connect the new code block, in case you needed to change something else in it to match your model's logic. I don't know if that could be the reason why it isn't working for you.

I attach again your model with both updating codes connected; the one on the left increases the quantity of the material types by 32000, while the right one increases it by 200 (read every time from the "MaterialQuantity" table).

1691651839533.png

Let me know if you have any further issues or if I'm understanding anything wrong about how you want it to behave.

testing.fsm

0 Likes 0 ·
1691651839533.png (40.8 KiB)
testing.fsm (73.4 KiB)
Rober G avatar image Rober G Paula LG commented ·

Hi @Paula LG , I have made the reconnections etc. The problem that I'm facing is when I use values that are not 200 (I had only used 200 as a place holder). As seen below, when such quantities are used, it does not update the inventory for some weird reason... Please find attached the model with such changes :)


testing.fsm

0 Likes 0 ·
testing.fsm (74.2 KiB)
Paula LG avatar image Paula LG Rober G commented ·

Hi,

The problem was the index label was not correct (my bad!) and it always read the first increment quantity (which was 0). I fixed it like this:

1691653350380.png

I attach the model with the new changes: testing.fsm

1 Like 1 ·
1691653350380.png (11.9 KiB)
testing.fsm (74.1 KiB)
Show more comments

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.