question

j08j avatar image
0 Likes"
j08j asked j08j commented

The issue related to the assigned item

I want each slot to store only one item. I referenced this question. Here's my code. How can I modify it to achieve this?

source2.setProperty("Triggers.OnCreation", "Object current = ownerobject(c);\n\
Object item = param(1);\n\
\n\
Map dimensions = current.outObjects[1].getProperty(\"Dimensions\");\n\
int Bay = dimensions.NumBays;\n\
int Level = dimensions.NumLevels;\n\
int Slot = dimensions.SlotsPerBay;\n\
\n\
int i = duniform(1, Bay, 1);\n\
int j = duniform(1, Level, 1);\n\
int k = duniform(1, Slot, 1);\n\
\n\
Storage.Slot slot = current.outObjects[1].as(Storage.Object).getSlot(i, j, k);\n\
if(slot.as(Storage.Slot).slotItems.length < 1) Storage.Item(item).as(Storage.Item).assignedSlot = current.outObjects[1].as(Storage.Object).getSlot(i, j, k);\n\
");

model.fsm

Thanks.

FlexSim 24.0.2
flexscriptcodeslot
model.fsm (42.4 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.

Hi @j08j, was Joerg Vogel'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 comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered j08j commented
· 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.

j08j avatar image j08j commented ·

I made the following modifications, but there still exists a situation where multiple items are placed in a single slot.

source2.setProperty("Triggers.OnCreation", "Object current = ownerobject(c);\n\
Object item = param(1);\n\
\n\
Storage.Item itemStorage = Storage.Item(item);// insert item into storage system\n\
Storage.Slot slotRack = Storage.system.findSlot(\"WHERE slot.slotItems.length < 1 ORDER BY slot.levelID ASC\");// place item by level\n\
itemStorage.assignedSlot = slotRack; //assign storage system item to slot\n\
");


0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel j08j commented ·

You create a model by code. Then it is a timing issue. If more sources are able to fill rack slots then timing is causing a crutial impact when and which data is present for other model objects. If you are familiar with Porcess Flow, you know that you need to add breath activities to resolve pending data into a state that it can be evaluated. In time units of a model run you are still in time 0, but the order of inserted and executed code has different impact on getting results successfully. Please test on your own, which order of inserted codes leads to a successful model.

0 Likes 0 ·
j08j avatar image j08j Joerg Vogel commented ·

I finally succeeded, thank you.

0 Likes 0 ·

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.