question

Proxima avatar image
0 Likes"
Proxima asked Felix Möhlmann commented

Let rack output goods under specified circumstances

How can I make rack send goods with a specific label (for example: the color is orange) at a specific time without using processflow

FlexSim 23.0.1
rack
· 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.

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·
We encourage students to make sure they indicate their academic status on their profile, and to look for solutions in the academic material provided to them, FlexSim's documentation and in the forum such that they can first attempt a solution themselves.
0 Likes 0 ·

1 Answer

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

You could configure the On Message trigger to release items of a given type up to a specified quantity.

Object current = ownerobject(c);
Object fromObject = param(1);
Variant msgparam1 = param(2);
Variant msgparam2 = param(3);
Variant msgparam3 = param(4);

int type = msgparam1;
int qty = msgparam2;

// Search for items in rack
Array Items = Storage.system.queryItems("WHERE Type == $1 AND item.slot.storageObject == $2", 0, type, current);

// Release found items up to specified quantity
for(int i = 1; i <= Math.min(Items.length, qty); i++)
{
    Object item = Items[i].as(Storage.Slot.Item).item;    
    releaseitem(item, 1);
}

If the release is timed, the respective message could be send by a user event (Toolbox -> Modeling Logic)

Writing this logic into the On Message trigger makes it easily accessible from anywhere in the model through the "sendmessage()" command. If the release is only triggered at a single place, you can also place the code there directly (just make sure to assign the correct rack to "current") and forego the use of the trigger.

timed_release_fm.fsm


· 13
5 |100000

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

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·

You can also put the same code on a label of the rack with an appropriate 'functional' name and invoke that 'user method' label with the evaluate() method, passing in the two parameters.

rack.labels["releaseNofType"].evaluate(<type>, <quantity>);


Or you can create a user command where you pass in the rack, type and quantity (least preferred technique).

0 Likes 0 ·
Proxima avatar image Proxima commented ·

Can I apply the same pattern to queues?

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Proxima commented ·
Yes but you'll then want to find all the items of a type iteratively, through a query or record them in a label array, table or map on the queue - you can't use findItem() as that's a Storage.System method.
0 Likes 0 ·
Proxima avatar image Proxima Jason Lightfoot ♦ commented ·

may i ask how can i make this?

0 Likes 0 ·
Show more comments
Felix Möhlmann avatar image Felix Möhlmann Proxima commented ·

The basic principle, certainly. But the queue is not part of the storage system, so you need to query for available items in a different way.

The attached model demonstrates a general approach that would also work for the rack, if you want to unify the logic.

The queue pushes all entering items to a global list in the "Send to Port" option. The list has a "Type" field that mirrors the value of the Type label and is partitioned by the object that pushed the item to the list (so you only need a single list for multiple objects).

1675250888091.png

The OnMessage code then pulls items with matching type from the correct partition, up to the specified quantity. If there are not enough items on the list to reach the quantity, the rest is ignored.

Object current = ownerobject(c);
Object fromObject = param(1);
Variant msgparam1 = param(2);
Variant msgparam2 = param(3);
Variant msgparam3 = param(4);

int type = msgparam1;
int qty = msgparam2;

// Pull matching items from list
string pullQuery = "WHERE Type == " + string.fromNum(type, 0);
Variant pulledItems = List("ItemList").pull(pullQuery, qty, 0, current, current);

// Release pulled items
for(int i = 1; i <= pulledItems.length; i++)
{
    releaseitem(pulledItems[i], 1);
}

timed-release-fm_1.fsm

0 Likes 0 ·
Proxima avatar image Proxima Felix Möhlmann commented ·

I want to know where my settings are wrong, all the items on the rack are taken in one execution

Is there a mistake in setting the ID?螢幕擷取畫面-2023-02-01-224021.png

0 Likes 0 ·
Show more comments
Proxima avatar image Proxima commented ·

I would like to know how to set up if there are more than two output?

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Proxima commented ·
The second parameter in "releaseitem(item, port)" controls through which port the item is send. Leaving it blank means that the "Send to Port" option will be evaluated to determine the port.
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.